Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

82 lines
2.0 KiB
TypeScript

import set from 'lodash/set';
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { fixFieldType, prepareInputItem } from '../../helpers/utils';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [
{
displayName: 'Fields',
name: 'caseFields',
type: 'resourceMapper',
default: {
mappingMode: 'defineBelow',
value: null,
},
noDataExpression: true,
required: true,
typeOptions: {
resourceMapper: {
resourceMapperMethod: 'getCaseFields',
mode: 'add',
valuesLabel: 'Fields',
},
},
},
];
const displayOptions = {
show: {
resource: ['case'],
operation: ['create'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
item: INodeExecutionData,
): Promise<INodeExecutionData[]> {
let responseData: IDataObject | IDataObject[] = [];
let inputData: IDataObject = {};
const dataMode = this.getNodeParameter('caseFields.mappingMode', i) as string;
if (dataMode === 'autoMapInputData') {
const schema = this.getNodeParameter('caseFields.schema', i) as IDataObject[];
inputData = prepareInputItem(item.json, schema, i);
}
if (dataMode === 'defineBelow') {
const caseFields = this.getNodeParameter('caseFields.value', i, []) as IDataObject;
inputData = caseFields;
}
inputData = fixFieldType(inputData);
const body: IDataObject = {};
for (const field of Object.keys(inputData)) {
// use set to construct the updateBody, as it allows to process customFields.fieldName
// if customFields provided under customFields property, it will be send as is
set(body, field, inputData[field]);
}
responseData = await theHiveApiRequest.call(this, 'POST', '/v1/case' as string, body);
const executionData = this.helpers.constructExecutionMetaData(wrapData(responseData), {
itemData: { item: i },
});
return executionData;
}