Add options to sideload owner and vendors

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-12-02 10:54:10 +01:00
parent c26b0d8423
commit 85bff72e0e
8 changed files with 432 additions and 8 deletions

View File

@@ -109,6 +109,35 @@ export const description: INodeProperties[] = [
default: '',
description: 'Comma-separated list of vendor IDs',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: ['asset'],
operation: ['create'],
},
},
options: [
{
displayName: 'Include Owner',
name: 'includeOwner',
type: 'boolean',
default: false,
description: 'Whether to include owner details in the response',
},
{
displayName: 'Include Vendors',
name: 'includeVendors',
type: 'boolean',
default: false,
description: 'Whether to include vendors in the response',
},
],
},
];
export async function execute(
@@ -122,6 +151,29 @@ export async function execute(
const assetType = this.getNodeParameter('assetType', itemIndex) as string;
const dataTypesStored = this.getNodeParameter('dataTypesStored', itemIndex) as string;
const vendorIdsStr = this.getNodeParameter('vendorIds', itemIndex, '') as string;
const options = this.getNodeParameter('options', itemIndex, {}) as {
includeOwner?: boolean;
includeVendors?: boolean;
};
const ownerFragment = options.includeOwner
? `owner {
id
fullName
primaryEmailAddress
}`
: '';
const vendorsFragment = options.includeVendors
? `vendors(first: 100) {
edges {
node {
id
name
}
}
}`
: '';
const query = `
mutation CreateAsset($input: CreateAssetInput!) {
@@ -133,6 +185,8 @@ export async function execute(
amount
assetType
dataTypesStored
${ownerFragment}
${vendorsFragment}
createdAt
updatedAt
}
@@ -162,4 +216,3 @@ export async function execute(
pairedItem: { item: itemIndex },
};
}