mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
Feature/paired item support (#3869)
* Add paired item helper and implement it in some nodes
This commit is contained in:
@@ -116,7 +116,7 @@ export class Bitwarden implements INodeType {
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
let responseData;
|
||||
const returnData: IDataObject[] = [];
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const token = await getAccessToken.call(this);
|
||||
const bitwardenApiRequest = partialRight(tokenlessBitwardenApiRequest, token);
|
||||
@@ -136,7 +136,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('collectionId', i);
|
||||
const endpoint = `/public/collections/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
|
||||
responseData = { success: true };
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// collection: get
|
||||
@@ -145,6 +150,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('collectionId', i);
|
||||
const endpoint = `/public/collections/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// collection: getAll
|
||||
@@ -152,6 +163,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = '/public/collections';
|
||||
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// collection: update
|
||||
@@ -185,6 +202,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('collectionId', i);
|
||||
const endpoint = `/public/collections/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
} else if (resource === 'event') {
|
||||
// *********************************************************************
|
||||
@@ -200,6 +223,12 @@ export class Bitwarden implements INodeType {
|
||||
const qs = isEmpty(filters) ? {} : filters;
|
||||
const endpoint = '/public/events';
|
||||
responseData = await handleGetAll.call(this, i, 'GET', endpoint, qs, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
} else if (resource === 'group') {
|
||||
// *********************************************************************
|
||||
@@ -234,6 +263,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = '/public/groups';
|
||||
responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// group: delete
|
||||
@@ -242,7 +277,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('groupId', i);
|
||||
const endpoint = `/public/groups/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
|
||||
responseData = { success: true };
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// group: get
|
||||
@@ -251,6 +291,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('groupId', i);
|
||||
const endpoint = `/public/groups/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// group: getAll
|
||||
@@ -258,6 +304,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = '/public/groups';
|
||||
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getMembers') {
|
||||
// ----------------------------------
|
||||
// group: getMembers
|
||||
@@ -267,6 +319,12 @@ export class Bitwarden implements INodeType {
|
||||
const endpoint = `/public/groups/${id}/member-ids`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
|
||||
responseData = responseData.map((memberId: string) => ({ memberId }));
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// group: update
|
||||
@@ -323,6 +381,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = `/public/groups/${groupId}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'updateMembers') {
|
||||
// ----------------------------------
|
||||
// group: updateMembers
|
||||
@@ -337,7 +401,12 @@ export class Bitwarden implements INodeType {
|
||||
const groupId = this.getNodeParameter('groupId', i);
|
||||
const endpoint = `/public/groups/${groupId}/member-ids`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
|
||||
responseData = { success: true };
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
} else if (resource === 'member') {
|
||||
// *********************************************************************
|
||||
@@ -373,6 +442,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = '/public/members/';
|
||||
responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// member: delete
|
||||
@@ -382,6 +457,12 @@ export class Bitwarden implements INodeType {
|
||||
const endpoint = `/public/members/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {});
|
||||
responseData = { success: true };
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// member: get
|
||||
@@ -390,6 +471,12 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('memberId', i);
|
||||
const endpoint = `/public/members/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// member: getAll
|
||||
@@ -397,6 +484,12 @@ export class Bitwarden implements INodeType {
|
||||
|
||||
const endpoint = '/public/members';
|
||||
responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {});
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getGroups') {
|
||||
// ----------------------------------
|
||||
// member: getGroups
|
||||
@@ -406,6 +499,11 @@ export class Bitwarden implements INodeType {
|
||||
const endpoint = `/public/members/${id}/group-ids`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {});
|
||||
responseData = responseData.map((groupId: string) => ({ groupId }));
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'update') {
|
||||
// ----------------------------------
|
||||
// member: update
|
||||
@@ -447,6 +545,11 @@ export class Bitwarden implements INodeType {
|
||||
const id = this.getNodeParameter('memberId', i);
|
||||
const endpoint = `/public/members/${id}`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'updateGroups') {
|
||||
// ----------------------------------
|
||||
// member: updateGroups
|
||||
@@ -461,15 +564,15 @@ export class Bitwarden implements INodeType {
|
||||
const memberId = this.getNodeParameter('memberId', i);
|
||||
const endpoint = `/public/members/${memberId}/group-ids`;
|
||||
responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body);
|
||||
responseData = { success: true };
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ success: true }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user