mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
Feature/paired item support (#3869)
* Add paired item helper and implement it in some nodes
This commit is contained in:
@@ -1930,7 +1930,7 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
@@ -1963,11 +1963,14 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
Object.assign(body, options);
|
||||
|
||||
const response = await googleApiRequest.call(this, 'POST', `/drive/v3/drives`, body, {
|
||||
requestId: uuid(),
|
||||
});
|
||||
const response = await googleApiRequest.call(this, 'POST', `/drive/v3/drives`, body, { requestId: uuid() });
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
@@ -1978,7 +1981,12 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
await googleApiRequest.call(this, 'DELETE', `/drive/v3/drives/${driveId}`);
|
||||
|
||||
returnData.push({ success: true });
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
@@ -1991,15 +1999,14 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
Object.assign(qs, options);
|
||||
|
||||
const response = await googleApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/drive/v3/drives/${driveId}`,
|
||||
{},
|
||||
qs,
|
||||
const response = await googleApiRequest.call(this, 'GET', `/drive/v3/drives/${driveId}`, {}, qs);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
if (operation === 'list') {
|
||||
// ----------------------------------
|
||||
@@ -2028,7 +2035,12 @@ export class GoogleDrive implements INodeType {
|
||||
response = data.drives as IDataObject[];
|
||||
}
|
||||
|
||||
returnData.push.apply(returnData, response);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
@@ -2041,14 +2053,14 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
Object.assign(body, options);
|
||||
|
||||
const response = await googleApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/drive/v3/drives/${driveId}`,
|
||||
body,
|
||||
const response = await googleApiRequest.call(this, 'PATCH', `/drive/v3/drives/${driveId}`, body);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
if (resource === 'file') {
|
||||
@@ -2074,15 +2086,14 @@ export class GoogleDrive implements INodeType {
|
||||
supportsAllDrives: true,
|
||||
};
|
||||
|
||||
const response = await googleApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/v3/files/${fileId}/copy`,
|
||||
body,
|
||||
qs,
|
||||
const response = await googleApiRequest.call(this, 'POST', `/drive/v3/files/${fileId}/copy`, body, qs);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'download') {
|
||||
// ----------------------------------
|
||||
// download
|
||||
@@ -2281,11 +2292,16 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
const version = this.getNode().typeVersion;
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(files),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
if (version === 1) {
|
||||
return [this.helpers.returnJsonArray(files as IDataObject[])];
|
||||
} else {
|
||||
returnData.push(...files);
|
||||
return [executionData];
|
||||
}
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'upload') {
|
||||
// ----------------------------------
|
||||
// upload
|
||||
@@ -2416,7 +2432,11 @@ export class GoogleDrive implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// file:update
|
||||
@@ -2454,7 +2474,12 @@ export class GoogleDrive implements INodeType {
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData as IDataObject);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
if (resource === 'folder') {
|
||||
@@ -2478,7 +2503,11 @@ export class GoogleDrive implements INodeType {
|
||||
|
||||
const response = await googleApiRequest.call(this, 'POST', '/drive/v3/files', body, qs);
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
if (['file', 'folder'].includes(resource)) {
|
||||
@@ -2498,10 +2527,15 @@ export class GoogleDrive implements INodeType {
|
||||
);
|
||||
|
||||
// If we are still here it did succeed
|
||||
returnData.push({
|
||||
fileId,
|
||||
success: true,
|
||||
});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({
|
||||
fileId,
|
||||
success: true,
|
||||
}),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
if (operation === 'share') {
|
||||
const fileId = this.getNodeParameter('fileId', i) as string;
|
||||
@@ -2530,7 +2564,11 @@ export class GoogleDrive implements INodeType {
|
||||
qs,
|
||||
);
|
||||
|
||||
returnData.push(response as IDataObject);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -2538,7 +2576,7 @@ export class GoogleDrive implements INodeType {
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
items[i].json = { error: error.message };
|
||||
} else {
|
||||
returnData.push({ error: error.message });
|
||||
returnData.push({ json: {error: error.message} });
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -2550,7 +2588,7 @@ export class GoogleDrive implements INodeType {
|
||||
return this.prepareOutputData(items);
|
||||
} else {
|
||||
// For all other ones does the output items get replaced
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user