2023-07-03 00:31:06 -07:00
|
|
|
import type { INodeProperties } from 'n8n-workflow';
|
|
|
|
|
|
|
|
export const showFor =
|
|
|
|
(resources: string[]) =>
|
|
|
|
(operations?: string[]): Partial<INodeProperties> => {
|
|
|
|
return operations !== undefined
|
|
|
|
? {
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: resources,
|
|
|
|
operation: operations,
|
|
|
|
},
|
|
|
|
},
|
2024-03-26 06:22:57 -07:00
|
|
|
}
|
2023-07-03 00:31:06 -07:00
|
|
|
: {
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: resources,
|
|
|
|
},
|
|
|
|
},
|
2024-03-26 06:22:57 -07:00
|
|
|
};
|
2023-07-03 00:31:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
export const mapWith =
|
|
|
|
<T>(...objects: Array<Partial<T>>) =>
|
|
|
|
(item: Partial<T>) =>
|
|
|
|
Object.assign({}, item, ...objects);
|
|
|
|
|
|
|
|
export const getId = (): INodeProperties => ({
|
|
|
|
displayName: 'ID',
|
|
|
|
name: 'id',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
default: '',
|
|
|
|
routing: {
|
|
|
|
send: {
|
|
|
|
type: 'query',
|
|
|
|
property: 'ids[]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const getAdditionalOptions = (fields: INodeProperties[]): INodeProperties => {
|
|
|
|
return {
|
|
|
|
displayName: 'Additional Options',
|
|
|
|
name: 'additionalOptions',
|
|
|
|
type: 'collection',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
operation: ['getAll'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
default: {},
|
|
|
|
placeholder: 'Add Option',
|
|
|
|
options: fields,
|
|
|
|
};
|
|
|
|
};
|