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 },
};
}

View File

@@ -16,6 +16,35 @@ export const description: INodeProperties[] = [
description: 'The ID of the asset',
required: true,
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: ['asset'],
operation: ['get'],
},
},
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(
@@ -23,6 +52,29 @@ export async function execute(
itemIndex: number,
): Promise<INodeExecutionData> {
const assetId = this.getNodeParameter('assetId', 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 = `
query GetAsset($assetId: ID!) {
@@ -33,6 +85,8 @@ export async function execute(
amount
assetType
dataTypesStored
${ownerFragment}
${vendorsFragment}
createdAt
updatedAt
}
@@ -51,4 +105,3 @@ export async function execute(
pairedItem: { item: itemIndex },
};
}

View File

@@ -46,6 +46,35 @@ export const description: INodeProperties[] = [
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: ['asset'],
operation: ['getAll'],
},
},
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(
@@ -55,6 +84,29 @@ export async function execute(
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean;
const limit = this.getNodeParameter('limit', itemIndex, 50) as number;
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 = `
query GetAssets($organizationId: ID!, $first: Int, $after: CursorKey) {
@@ -68,6 +120,8 @@ export async function execute(
amount
assetType
dataTypesStored
${ownerFragment}
${vendorsFragment}
createdAt
updatedAt
}
@@ -96,4 +150,3 @@ export async function execute(
pairedItem: { item: itemIndex },
};
}

View File

@@ -104,6 +104,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: ['update'],
},
},
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(
@@ -117,6 +146,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 UpdateAsset($input: UpdateAssetInput!) {
@@ -127,6 +179,8 @@ export async function execute(
amount
assetType
dataTypesStored
${ownerFragment}
${vendorsFragment}
createdAt
updatedAt
}
@@ -152,4 +206,3 @@ export async function execute(
pairedItem: { item: itemIndex },
};
}