refactor(core): Add more overloads for string-type node parameters (no-changelog) (#5101)

* refactor(core): Add more overloads for string-type node parameter (no-changelog)

continued from https://github.com/n8n-io/n8n/pull/4797

* include binaryPropertyOutput
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-01-06 15:09:32 +01:00 committed by GitHub
parent c97f3cad59
commit 1acc7fea89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 98 additions and 131 deletions

View file

@ -105,7 +105,7 @@ const items = this.getInputData();
for (const i = 0; i < items.length; i++) { for (const i = 0; i < items.length; i++) {
const item = items[i].binary as IBinaryKeyData; const item = items[i].binary as IBinaryKeyData;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const binaryData = item[binaryPropertyName] as IBinaryData; const binaryData = item[binaryPropertyName] as IBinaryData;
// Before 0.135.0: // Before 0.135.0:
const binaryDataBuffer = Buffer.from(binaryData.data, BINARY_ENCODING); const binaryDataBuffer = Buffer.from(binaryData.data, BINARY_ENCODING);

View file

@ -415,7 +415,7 @@ export class AwsRekognition implements INodeType {
const binaryData = this.getNodeParameter('binaryData', 0); const binaryData = this.getNodeParameter('binaryData', 0);
if (binaryData) { if (binaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -608,10 +608,7 @@ export class AwsS3 implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const data = Buffer.from(response.body as string, 'utf8'); const data = Buffer.from(response.body as string, 'utf8');
@ -806,7 +803,7 @@ export class AwsS3 implements INodeType {
const region = responseData.LocationConstraint._; const region = responseData.LocationConstraint._;
if (isBinaryData) { if (isBinaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -120,7 +120,7 @@ export class AwsTextract implements INodeType {
try { try {
//https://docs.aws.amazon.com/textract/latest/dg/API_AnalyzeExpense.html //https://docs.aws.amazon.com/textract/latest/dg/API_AnalyzeExpense.html
if (operation === 'analyzeExpense') { if (operation === 'analyzeExpense') {
const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; const binaryProperty = this.getNodeParameter('binaryPropertyName', i);
const simple = this.getNodeParameter('simple', i) as boolean; const simple = this.getNodeParameter('simple', i) as boolean;
if (items[i].binary === undefined) { if (items[i].binary === undefined) {

View file

@ -19,7 +19,7 @@ export async function upload(this: IExecuteFunctions, index: number) {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', index) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', index);
if (items[index]!.binary![propertyNameUpload] === undefined) { if (items[index]!.binary![propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(

View file

@ -19,7 +19,7 @@ export async function upload(this: IExecuteFunctions, index: number) {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', index) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', index);
if (items[index]!.binary![propertyNameUpload] === undefined) { if (items[index]!.binary![propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(

View file

@ -114,10 +114,7 @@ export class Box implements INodeType {
// https://developer.box.com/reference/get-files-id-content // https://developer.box.com/reference/get-files-id-content
if (operation === 'download') { if (operation === 'download') {
const fileId = this.getNodeParameter('fileId', i) as string; const fileId = this.getNodeParameter('fileId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
responseData = await boxApiRequest.call(this, 'GET', `/files/${fileId}`); responseData = await boxApiRequest.call(this, 'GET', `/files/${fileId}`);
const fileName = responseData.name; const fileName = responseData.name;
@ -280,7 +277,7 @@ export class Box implements INodeType {
} }
if (isBinaryData) { if (isBinaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -513,7 +513,7 @@ export class CiscoWebex implements INodeType {
// if (operation === 'download') { // if (operation === 'download') {
// for (let i = 0; i < items.length; i++) { // for (let i = 0; i < items.length; i++) {
// const transcriptId = this.getNodeParameter('transcriptId', i) as string; // const transcriptId = this.getNodeParameter('transcriptId', i) as string;
// const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; // const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
// const meetingId = this.getNodeParameter('meetingId', i) as string; // const meetingId = this.getNodeParameter('meetingId', i) as string;
// const options = this.getNodeParameter('options', i); // const options = this.getNodeParameter('options', i);

View file

@ -185,7 +185,7 @@ export class Compression implements INodeType {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
try { try {
if (operation === 'decompress') { if (operation === 'decompress') {
const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string) const binaryPropertyNames = this.getNodeParameter('binaryPropertyName', 0)
.split(',') .split(',')
.map((key) => key.trim()); .map((key) => key.trim());
@ -256,7 +256,7 @@ export class Compression implements INodeType {
} }
if (operation === 'compress') { if (operation === 'compress') {
const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string) const binaryPropertyNames = this.getNodeParameter('binaryPropertyName', 0)
.split(',') .split(',')
.map((key) => key.trim()); .map((key) => key.trim());
@ -308,7 +308,7 @@ export class Compression implements INodeType {
if (outputFormat === 'zip') { if (outputFormat === 'zip') {
const fileName = this.getNodeParameter('fileName', 0) as string; const fileName = this.getNodeParameter('fileName', 0) as string;
const binaryPropertyOutput = this.getNodeParameter('binaryPropertyOutput', 0) as string; const binaryPropertyOutput = this.getNodeParameter('binaryPropertyOutput', 0);
const buffer = await zip(zipData); const buffer = await zip(zipData);

View file

@ -201,7 +201,7 @@ export class Cortex implements INodeType {
}); });
} }
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[binaryPropertyName] === undefined) { if (item.binary[binaryPropertyName] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(

View file

@ -434,12 +434,12 @@ export class Crypto implements INodeType {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
try { try {
item = items[i]; item = items[i];
const dataPropertyName = this.getNodeParameter('dataPropertyName', i) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', i);
const value = this.getNodeParameter('value', i, '') as string; const value = this.getNodeParameter('value', i, '') as string;
let newValue; let newValue;
if (action === 'generate') { if (action === 'generate') {
const encodingType = this.getNodeParameter('encodingType', i) as string; const encodingType = this.getNodeParameter('encodingType', i);
if (encodingType === 'uuid') { if (encodingType === 'uuid') {
newValue = uuid(); newValue = uuid();
} else { } else {

View file

@ -376,7 +376,7 @@ export class DateTime implements INodeType {
if (action === 'format') { if (action === 'format') {
const currentDate = this.getNodeParameter('value', i) as string; const currentDate = this.getNodeParameter('value', i) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', i) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', i);
const toFormat = this.getNodeParameter('toFormat', i) as string; const toFormat = this.getNodeParameter('toFormat', i) as string;
const options = this.getNodeParameter('options', i); const options = this.getNodeParameter('options', i);
let newDate; let newDate;
@ -461,7 +461,7 @@ export class DateTime implements INodeType {
const duration = this.getNodeParameter('duration', i) as number; const duration = this.getNodeParameter('duration', i) as number;
const timeUnit = this.getNodeParameter('timeUnit', i) as moment.DurationInputArg2; const timeUnit = this.getNodeParameter('timeUnit', i) as moment.DurationInputArg2;
const { fromFormat } = this.getNodeParameter('options', i) as { fromFormat?: string }; const { fromFormat } = this.getNodeParameter('options', i) as { fromFormat?: string };
const dataPropertyName = this.getNodeParameter('dataPropertyName', i) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', i);
const newDate = fromFormat const newDate = fromFormat
? parseDateByFormat.call(this, dateValue, fromFormat) ? parseDateByFormat.call(this, dateValue, fromFormat)

View file

@ -769,7 +769,7 @@ export class Dropbox implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[propertyNameUpload] === undefined) { if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
@ -954,7 +954,7 @@ export class Dropbox implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
const filePathDownload = this.getNodeParameter('path', i) as string; const filePathDownload = this.getNodeParameter('path', i) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(

View file

@ -986,7 +986,7 @@ export class EditImage implements INodeType {
item = items[itemIndex]; item = items[itemIndex];
const operation = this.getNodeParameter('operation', itemIndex); const operation = this.getNodeParameter('operation', itemIndex);
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex);
const options = this.getNodeParameter('options', itemIndex, {}); const options = this.getNodeParameter('options', itemIndex, {});

View file

@ -374,10 +374,7 @@ export class FacebookGraphApi implements INodeType {
}); });
} }
const binaryPropertyNameFull = this.getNodeParameter( const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex);
'binaryPropertyName',
itemIndex,
) as string;
let propertyName = 'file'; let propertyName = 'file';
let binaryPropertyName = binaryPropertyNameFull; let binaryPropertyName = binaryPropertyNameFull;

View file

@ -518,10 +518,7 @@ export class Ftp implements INodeType {
responseData = await sftp!.get(path); responseData = await sftp!.get(path);
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const filePathDownload = this.getNodeParameter('path', i) as string; const filePathDownload = this.getNodeParameter('path', i) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
@ -546,7 +543,7 @@ export class Ftp implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[propertyNameUpload] === undefined) { if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
@ -619,10 +616,7 @@ export class Ftp implements INodeType {
// @ts-ignore // @ts-ignore
responseData = Buffer.concat(chunks); responseData = Buffer.concat(chunks);
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const filePathDownload = this.getNodeParameter('path', i) as string; const filePathDownload = this.getNodeParameter('path', i) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
@ -658,7 +652,7 @@ export class Ftp implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[propertyNameUpload] === undefined) { if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(

View file

@ -1687,7 +1687,7 @@ export class Github implements INodeType {
requestMethod = 'PUT'; requestMethod = 'PUT';
const filePath = this.getNodeParameter('filePath', i) as string; const filePath = this.getNodeParameter('filePath', i);
const additionalParameters = this.getNodeParameter( const additionalParameters = this.getNodeParameter(
'additionalParameters', 'additionalParameters',
@ -1731,7 +1731,7 @@ export class Github implements INodeType {
}); });
} }
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[binaryPropertyName] === undefined) { if (item.binary[binaryPropertyName] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
@ -1778,7 +1778,7 @@ export class Github implements INodeType {
body.branch = (additionalParameters.branch as IDataObject).branch; body.branch = (additionalParameters.branch as IDataObject).branch;
} }
const filePath = this.getNodeParameter('filePath', i) as string; const filePath = this.getNodeParameter('filePath', i);
body.message = this.getNodeParameter('commitMessage', i) as string; body.message = this.getNodeParameter('commitMessage', i) as string;
body.sha = await getFileSha.call( body.sha = await getFileSha.call(
@ -1793,7 +1793,7 @@ export class Github implements INodeType {
} else if (operation === 'get') { } else if (operation === 'get') {
requestMethod = 'GET'; requestMethod = 'GET';
const filePath = this.getNodeParameter('filePath', i) as string; const filePath = this.getNodeParameter('filePath', i);
const additionalParameters = this.getNodeParameter( const additionalParameters = this.getNodeParameter(
'additionalParameters', 'additionalParameters',
i, i,
@ -1806,7 +1806,7 @@ export class Github implements INodeType {
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`; endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
} else if (operation === 'list') { } else if (operation === 'list') {
requestMethod = 'GET'; requestMethod = 'GET';
const filePath = this.getNodeParameter('filePath', i) as string; const filePath = this.getNodeParameter('filePath', i);
endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`; endpoint = `/repos/${owner}/${repository}/contents/${encodeURI(filePath)}`;
} }
} else if (resource === 'issue') { } else if (resource === 'issue') {
@ -2117,7 +2117,7 @@ export class Github implements INodeType {
}); });
} }
// Add the returned data to the item as binary property // Add the returned data to the item as binary property
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const newItem: INodeExecutionData = { const newItem: INodeExecutionData = {
json: items[i].json, json: items[i].json,

View file

@ -243,7 +243,7 @@ export class GoogleChat implements INodeType {
items[i] = newItem; items[i] = newItem;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(
responseData, responseData,

View file

@ -2392,10 +2392,7 @@ export class GoogleDrive implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
response.body as unknown as Readable, response.body as unknown as Readable,
@ -2521,7 +2518,7 @@ export class GoogleDrive implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
const binary = item.binary[propertyNameUpload]; const binary = item.binary[propertyNameUpload];
if (binary === undefined) { if (binary === undefined) {

View file

@ -426,7 +426,7 @@ export class GraphQL implements INodeType {
response = await this.helpers.request(requestOptions); response = await this.helpers.request(requestOptions);
} }
if (responseFormat === 'string') { if (responseFormat === 'string') {
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
returnItems.push({ returnItems.push({
json: { json: {
[dataPropertyName]: response, [dataPropertyName]: response,

View file

@ -392,10 +392,7 @@ export class HomeAssistant implements INodeType {
} else if (resource === 'cameraProxy') { } else if (resource === 'cameraProxy') {
if (operation === 'getScreenshot') { if (operation === 'getScreenshot') {
const cameraEntityId = this.getNodeParameter('cameraEntityId', i) as string; const cameraEntityId = this.getNodeParameter('cameraEntityId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const endpoint = `/camera_proxy/${cameraEntityId}`; const endpoint = `/camera_proxy/${cameraEntityId}`;
let mimeType: string | undefined; let mimeType: string | undefined;

View file

@ -214,7 +214,7 @@ export class HtmlExtract implements INodeType {
let item: INodeExecutionData; let item: INodeExecutionData;
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
try { try {
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex);
const extractionValues = this.getNodeParameter( const extractionValues = this.getNodeParameter(
'extractionValues', 'extractionValues',
itemIndex, itemIndex,

View file

@ -746,10 +746,7 @@ export class HttpRequestV1 implements INodeType {
} }
if (options.bodyContentType === 'raw') { if (options.bodyContentType === 'raw') {
const binaryPropertyName = this.getNodeParameter( const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex);
'binaryPropertyName',
itemIndex,
) as string;
if (item.binary[binaryPropertyName] === undefined) { if (item.binary[binaryPropertyName] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
this.getNode(), this.getNode(),
@ -768,7 +765,7 @@ export class HttpRequestV1 implements INodeType {
const binaryPropertyNameFull = this.getNodeParameter( const binaryPropertyNameFull = this.getNodeParameter(
'binaryPropertyName', 'binaryPropertyName',
itemIndex, itemIndex,
) as string; );
const binaryPropertyNames = binaryPropertyNameFull const binaryPropertyNames = binaryPropertyNameFull
.split(',') .split(',')
.map((key) => key.trim()); .map((key) => key.trim());
@ -1012,7 +1009,7 @@ export class HttpRequestV1 implements INodeType {
const fullResponse = !!options.fullResponse; const fullResponse = !!options.fullResponse;
if (responseFormat === 'file') { if (responseFormat === 'file') {
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
const newItem: INodeExecutionData = { const newItem: INodeExecutionData = {
json: {}, json: {},
@ -1058,7 +1055,7 @@ export class HttpRequestV1 implements INodeType {
returnItems.push(newItem); returnItems.push(newItem);
} else if (responseFormat === 'string') { } else if (responseFormat === 'string') {
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
if (fullResponse) { if (fullResponse) {
const returnItem: IDataObject = {}; const returnItem: IDataObject = {};

View file

@ -785,10 +785,7 @@ export class HttpRequestV2 implements INodeType {
} }
if (options.bodyContentType === 'raw') { if (options.bodyContentType === 'raw') {
const binaryPropertyName = this.getNodeParameter( const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex);
'binaryPropertyName',
itemIndex,
) as string;
if (item.binary[binaryPropertyName] === undefined) { if (item.binary[binaryPropertyName] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
this.getNode(), this.getNode(),
@ -807,7 +804,7 @@ export class HttpRequestV2 implements INodeType {
const binaryPropertyNameFull = this.getNodeParameter( const binaryPropertyNameFull = this.getNodeParameter(
'binaryPropertyName', 'binaryPropertyName',
itemIndex, itemIndex,
) as string; );
const binaryPropertyNames = binaryPropertyNameFull const binaryPropertyNames = binaryPropertyNameFull
.split(',') .split(',')
.map((key) => key.trim()); .map((key) => key.trim());
@ -1065,7 +1062,7 @@ export class HttpRequestV2 implements INodeType {
const fullResponse = !!options.fullResponse; const fullResponse = !!options.fullResponse;
if (responseFormat === 'file') { if (responseFormat === 'file') {
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
const newItem: INodeExecutionData = { const newItem: INodeExecutionData = {
json: {}, json: {},
@ -1111,7 +1108,7 @@ export class HttpRequestV2 implements INodeType {
returnItems.push(newItem); returnItems.push(newItem);
} else if (responseFormat === 'string') { } else if (responseFormat === 'string') {
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
if (fullResponse) { if (fullResponse) {
const returnItem: IDataObject = {}; const returnItem: IDataObject = {};

View file

@ -70,7 +70,7 @@ export class HumanticAi implements INodeType {
qs.userid = userId; qs.userid = userId;
if (sendResume) { if (sendResume) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
@ -143,7 +143,7 @@ export class HumanticAi implements INodeType {
qs.userid = userId; qs.userid = userId;
if (sendResume) { if (sendResume) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -308,7 +308,7 @@ export class ICalendar implements INodeType {
const start = this.getNodeParameter('start', i) as string; const start = this.getNodeParameter('start', i) as string;
let end = this.getNodeParameter('end', i) as string; let end = this.getNodeParameter('end', i) as string;
end = allDay ? moment(end).utc().add(1, 'day').format() : end; end = allDay ? moment(end).utc().add(1, 'day').format() : end;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
let fileName = 'event.ics'; let fileName = 'event.ics';

View file

@ -975,7 +975,7 @@ export class Jira implements INodeType {
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post //https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
if (operation === 'add') { if (operation === 'add') {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const issueKey = this.getNodeParameter('issueKey', i) as string; const issueKey = this.getNodeParameter('issueKey', i) as string;
if (items[i].binary === undefined) { if (items[i].binary === undefined) {

View file

@ -827,7 +827,7 @@ export class Keap implements INodeType {
body.contact_id = contactId; body.contact_id = contactId;
} }
if (binaryData) { if (binaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -400,7 +400,7 @@ export class KoBoToolbox implements INodeType {
]; ];
if (responseData?.[0] && download) { if (responseData?.[0] && download) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const binaryItem: INodeExecutionData = { const binaryItem: INodeExecutionData = {
json: responseData[0], json: responseData[0],
@ -441,7 +441,7 @@ export class KoBoToolbox implements INodeType {
}; };
if ('binary' === fileMode) { if ('binary' === fileMode) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const item = items[i].binary as IBinaryKeyData; const item = items[i].binary as IBinaryKeyData;
const binaryData = item[binaryPropertyName]; const binaryData = item[binaryPropertyName];

View file

@ -146,7 +146,7 @@ export class LinkedIn implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[propertyNameUpload] === undefined) { if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(

View file

@ -184,7 +184,7 @@ export async function handleMatrixCall(
if (operation === 'upload') { if (operation === 'upload') {
const roomId = this.getNodeParameter('roomId', index) as string; const roomId = this.getNodeParameter('roomId', index) as string;
const mediaType = this.getNodeParameter('mediaType', index) as string; const mediaType = this.getNodeParameter('mediaType', index) as string;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', index) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', index);
let body; let body;
const qs: IDataObject = {}; const qs: IDataObject = {};

View file

@ -104,10 +104,7 @@ export class MicrosoftOneDrive implements INodeType {
//https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online
if (operation === 'download') { if (operation === 'download') {
const fileId = this.getNodeParameter('fileId', i) as string; const fileId = this.getNodeParameter('fileId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}`); responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}`);
const fileName = responseData.name; const fileName = responseData.name;
@ -199,7 +196,7 @@ export class MicrosoftOneDrive implements INodeType {
const fileName = this.getNodeParameter('fileName', i) as string; const fileName = this.getNodeParameter('fileName', i) as string;
if (isBinaryData) { if (isBinaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -370,10 +370,7 @@ export class MicrosoftOutlook implements INodeType {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
try { try {
const messageId = this.getNodeParameter('messageId', i) as string; const messageId = this.getNodeParameter('messageId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const response = await microsoftApiRequest.call( const response = await microsoftApiRequest.call(
this, this,
'GET', 'GET',
@ -557,7 +554,7 @@ export class MicrosoftOutlook implements INodeType {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
try { try {
const messageId = this.getNodeParameter('messageId', i) as string; const messageId = this.getNodeParameter('messageId', i) as string;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
@ -667,10 +664,7 @@ export class MicrosoftOutlook implements INodeType {
try { try {
const messageId = this.getNodeParameter('messageId', i) as string; const messageId = this.getNodeParameter('messageId', i) as string;
const attachmentId = this.getNodeParameter('attachmentId', i) as string; const attachmentId = this.getNodeParameter('attachmentId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
// Get attachment details first // Get attachment details first
const attachmentDetails = await microsoftApiRequest.call( const attachmentDetails = await microsoftApiRequest.call(

View file

@ -160,7 +160,7 @@ export class Mindee implements INodeType {
try { try {
if (resource === 'receipt') { if (resource === 'receipt') {
if (operation === 'predict') { if (operation === 'predict') {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const rawData = this.getNodeParameter('rawData', i); const rawData = this.getNodeParameter('rawData', i);
@ -231,7 +231,7 @@ export class Mindee implements INodeType {
if (resource === 'invoice') { if (resource === 'invoice') {
if (operation === 'predict') { if (operation === 'predict') {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const rawData = this.getNodeParameter('rawData', i); const rawData = this.getNodeParameter('rawData', i);

View file

@ -1050,7 +1050,7 @@ export class Nasa implements INodeType {
} }
if (resource === 'earthImagery') { if (resource === 'earthImagery') {
const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; const binaryProperty = this.getNodeParameter('binaryPropertyName', i);
const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null }); const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null });
@ -1072,7 +1072,7 @@ export class Nasa implements INodeType {
download = this.getNodeParameter('download', 0); download = this.getNodeParameter('download', 0);
if (download) { if (download) {
const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; const binaryProperty = this.getNodeParameter('binaryPropertyName', i);
const data = await nasaApiRequest.call( const data = await nasaApiRequest.call(
this, this,

View file

@ -911,7 +911,7 @@ export class NextCloud implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[propertyNameUpload] === undefined) { if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
@ -1144,7 +1144,7 @@ export class NextCloud implements INodeType {
items[i] = newItem; items[i] = newItem;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(
responseData, responseData,

View file

@ -4345,7 +4345,7 @@ export class Pipedrive implements INodeType {
}); });
} }
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if (item.binary[binaryPropertyName] === undefined) { if (item.binary[binaryPropertyName] === undefined) {
throw new NodeOperationError( throw new NodeOperationError(
@ -4847,7 +4847,7 @@ export class Pipedrive implements INodeType {
items[i] = newItem; items[i] = newItem;
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(
responseData.data, responseData.data,

View file

@ -407,7 +407,7 @@ export class Pushbullet implements INodeType {
} }
if (type === 'file') { if (type === 'file') {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!'); throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');

View file

@ -208,7 +208,7 @@ export class QuickBase implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
responseData = await quickbaseApiRequest.call( responseData = await quickbaseApiRequest.call(
this, this,

View file

@ -61,9 +61,9 @@ export class ReadBinaryFile implements INodeType {
Object.assign(newItem.binary, item.binary); Object.assign(newItem.binary, item.binary);
} }
const filePath = this.getNodeParameter('filePath', itemIndex) as string; const filePath = this.getNodeParameter('filePath', itemIndex);
const stream = await this.helpers.createReadStream(filePath); const stream = await this.helpers.createReadStream(filePath);
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex);
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(stream, filePath); newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(stream, filePath);
returnData.push(newItem); returnData.push(newItem);
} catch (error) { } catch (error) {

View file

@ -39,7 +39,7 @@ export class ReadBinaryFiles implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> { async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const fileSelector = this.getNodeParameter('fileSelector', 0) as string; const fileSelector = this.getNodeParameter('fileSelector', 0) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
const files = await glob(fileSelector); const files = await glob(fileSelector);

View file

@ -41,7 +41,7 @@ export class ReadPDF implements INodeType {
for (let itemIndex = 0; itemIndex < length; itemIndex++) { for (let itemIndex = 0; itemIndex < length; itemIndex++) {
try { try {
item = items[itemIndex]; item = items[itemIndex];
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex);
if (item.binary === undefined) { if (item.binary === undefined) {
item.binary = {}; item.binary = {};

View file

@ -626,10 +626,7 @@ export class S3 implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const data = Buffer.from(response.body as string, 'utf8'); const data = Buffer.from(response.body as string, 'utf8');
@ -835,7 +832,7 @@ export class S3 implements INodeType {
const region = responseData.LocationConstraint._; const region = responseData.LocationConstraint._;
if (isBinaryData) { if (isBinaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {

View file

@ -1834,7 +1834,7 @@ export class Salesforce implements INodeType {
if (operation === 'upload') { if (operation === 'upload') {
const title = this.getNodeParameter('title', i) as string; const title = this.getNodeParameter('title', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
let data; let data;
const body: { entity_content: { [key: string]: string } } = { const body: { entity_content: { [key: string]: string } } = {
entity_content: { entity_content: {
@ -2852,7 +2852,7 @@ export class Salesforce implements INodeType {
const name = this.getNodeParameter('name', i) as string; const name = this.getNodeParameter('name', i) as string;
const parentId = this.getNodeParameter('parentId', i) as string; const parentId = this.getNodeParameter('parentId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const body: IAttachment = { const body: IAttachment = {
Name: name, Name: name,
ParentId: parentId, ParentId: parentId,

View file

@ -242,7 +242,7 @@ export class SecurityScorecard implements INodeType {
items[i] = newItem; items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
const fileName = reportUrl.split('/').pop(); const fileName = reportUrl.split('/').pop();

View file

@ -1092,7 +1092,7 @@ export class Slack implements INodeType {
body.title = options.title as string; body.title = options.title as string;
} }
if (binaryData) { if (binaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
if ( if (
items[i].binary === undefined || items[i].binary === undefined ||
//@ts-ignore //@ts-ignore

View file

@ -308,7 +308,7 @@ export class SpreadsheetFile implements INodeType {
try { try {
item = items[i]; item = items[i];
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const options = this.getNodeParameter('options', i, {}); const options = this.getNodeParameter('options', i, {});
if (item.binary === undefined || item.binary[binaryPropertyName] === undefined) { if (item.binary === undefined || item.binary[binaryPropertyName] === undefined) {
@ -413,7 +413,7 @@ export class SpreadsheetFile implements INodeType {
} else if (operation === 'toFile') { } else if (operation === 'toFile') {
try { try {
// Write the workflow data to spreadsheet file // Write the workflow data to spreadsheet file
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
const fileFormat = this.getNodeParameter('fileFormat', 0) as string; const fileFormat = this.getNodeParameter('fileFormat', 0) as string;
const options = this.getNodeParameter('options', 0, {}); const options = this.getNodeParameter('options', 0, {});
const sheetToJsonOptions: JSON2SheetOpts = {}; const sheetToJsonOptions: JSON2SheetOpts = {};

View file

@ -302,10 +302,7 @@ export class Ssh implements INodeType {
if (resource === 'file') { if (resource === 'file') {
if (operation === 'download') { if (operation === 'download') {
const dataPropertyNameDownload = this.getNodeParameter( const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i);
'binaryPropertyName',
i,
) as string;
const parameterPath = this.getNodeParameter('path', i) as string; const parameterPath = this.getNodeParameter('path', i) as string;
const { path } = await file({ prefix: 'n8n-ssh-' }); const { path } = await file({ prefix: 'n8n-ssh-' });
@ -350,7 +347,7 @@ export class Ssh implements INodeType {
}); });
} }
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i);
const binaryData = item.binary[propertyNameUpload]; const binaryData = item.binary[propertyNameUpload];

View file

@ -1960,7 +1960,7 @@ export class Telegram implements INodeType {
let responseData; let responseData;
if (binaryData) { if (binaryData) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0);
const itemBinaryData = items[i].binary![binaryPropertyName]; const itemBinaryData = items[i].binary![binaryPropertyName];
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
const propertyName = getPropertyName(operation); const propertyName = getPropertyName(operation);

View file

@ -69,7 +69,7 @@ export class WriteBinaryFile implements INodeType {
for (let itemIndex = 0; itemIndex < length; itemIndex++) { for (let itemIndex = 0; itemIndex < length; itemIndex++) {
try { try {
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex);
const fileName = this.getNodeParameter('fileName', itemIndex) as string; const fileName = this.getNodeParameter('fileName', itemIndex) as string;
const options = this.getNodeParameter('options', 0, {}); const options = this.getNodeParameter('options', 0, {});

View file

@ -220,7 +220,7 @@ export class Xml implements INodeType {
const items = this.getInputData(); const items = this.getInputData();
const mode = this.getNodeParameter('mode', 0) as string; const mode = this.getNodeParameter('mode', 0) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0);
const options = this.getNodeParameter('options', 0, {}); const options = this.getNodeParameter('options', 0, {});
let item: INodeExecutionData; let item: INodeExecutionData;

View file

@ -192,7 +192,7 @@ export class Zulip implements INodeType {
//https://zulipchat.com/api/upload-file //https://zulipchat.com/api/upload-file
if (operation === 'updateFile') { if (operation === 'updateFile') {
const credentials = await this.getCredentials('zulipApi'); const credentials = await this.getCredentials('zulipApi');
const binaryProperty = this.getNodeParameter('dataBinaryProperty', i) as string; const binaryProperty = this.getNodeParameter('dataBinaryProperty', i);
if (items[i].binary === undefined) { if (items[i].binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!'); throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
} }

View file

@ -560,7 +560,16 @@ export interface IGetNodeParameterOptions {
namespace ExecuteFunctions { namespace ExecuteFunctions {
namespace StringReturning { namespace StringReturning {
export type NodeParameter = 'binaryProperty' | 'resource' | 'operation'; export type NodeParameter =
| 'binaryProperty'
| 'binaryPropertyName'
| 'binaryPropertyOutput'
| 'dataPropertyName'
| 'dataBinaryProperty'
| 'resource'
| 'operation'
| 'filePath'
| 'encodingType';
} }
namespace NumberReturning { namespace NumberReturning {