@limetech/n8n-nodes-lime 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/nodes/common.d.ts +2 -2
- package/dist/nodes/common.js +5 -16
- package/dist/nodes/common.js.map +1 -1
- package/dist/nodes/errorHandling.d.ts +2 -2
- package/dist/nodes/errorHandling.js +5 -7
- package/dist/nodes/errorHandling.js.map +1 -1
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js +21 -1
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js.map +1 -1
- package/dist/nodes/lime-crm/resources/admin/operations/getSingleUser.operation.js +1 -1
- package/dist/nodes/lime-crm/resources/admin/operations/getSingleUser.operation.js.map +1 -1
- package/dist/nodes/lime-crm/resources/data/index.js +0 -5
- package/dist/nodes/lime-crm/resources/data/index.js.map +1 -1
- package/dist/nodes/lime-crm/resources/data/operations/index.d.ts +0 -1
- package/dist/nodes/lime-crm/resources/data/operations/index.js +1 -2
- package/dist/nodes/lime-crm/resources/data/operations/index.js.map +1 -1
- package/dist/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.operation.js +2 -2
- package/dist/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.operation.js.map +1 -1
- package/dist/nodes/lime-crm/transport/commons.js +1 -1
- package/dist/nodes/lime-crm/transport/commons.js.map +1 -1
- package/dist/nodes/lime-crm/transport/files.js +2 -2
- package/dist/nodes/lime-crm/transport/files.js.map +1 -1
- package/dist/nodes/lime-crm/transport/users.js +2 -2
- package/dist/nodes/lime-crm/transport/users.js.map +1 -1
- package/dist/nodes/lime-forms/LimeFormsTrigger.node.js +1 -1
- package/dist/nodes/lime-forms/LimeFormsTrigger.node.js.map +1 -1
- package/dist/package.json +9 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/nodes/common.ts +11 -19
- package/nodes/errorHandling.ts +10 -19
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +26 -8
- package/nodes/lime-crm/resources/admin/operations/getSingleUser.operation.ts +1 -1
- package/nodes/lime-crm/resources/data/index.ts +0 -8
- package/nodes/lime-crm/resources/data/operations/index.ts +0 -5
- package/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.operation.ts +2 -2
- package/nodes/lime-crm/transport/commons.ts +1 -1
- package/nodes/lime-crm/transport/files.ts +2 -2
- package/nodes/lime-crm/transport/users.ts +2 -2
- package/nodes/lime-forms/LimeFormsTrigger.node.ts +1 -1
- package/package.json +10 -10
- package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.js +0 -241
- package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.js.map +0 -1
- package/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.ts +0 -364
package/nodes/common.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { createHmac
|
|
2
|
-
import {
|
|
3
|
-
import { handleWorkflowError } from './errorHandling';
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
import { NodeOperationError, INode } from 'n8n-workflow';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Generate an HMAC SHA-256 hash for the given data using the provided key.
|
|
@@ -46,50 +45,43 @@ export function verifyHmac(
|
|
|
46
45
|
* - `limeSignature` is missing while `webhookSecret` is present.
|
|
47
46
|
* - The `limeSignature` does not match the HMAC generated using the `webhookSecret`.
|
|
48
47
|
*
|
|
49
|
-
* @param
|
|
48
|
+
* @param node - The node where the verification is performed.
|
|
50
49
|
* @param limeSignature - The signature included in the webhook request that needs to be verified.
|
|
51
50
|
* @param webhookSecret - The secret key used to verify the signature of the webhook request.
|
|
52
51
|
* @param data - The raw payload of the webhook request used for signature verification.
|
|
53
52
|
* @throws {NodeOperationError} If verification of the request fails due to missing or invalid authentication data.
|
|
54
53
|
*/
|
|
55
54
|
export const verifyRequest = (
|
|
56
|
-
|
|
55
|
+
node: INode,
|
|
57
56
|
limeSignature: string,
|
|
58
57
|
webhookSecret: string,
|
|
59
58
|
data: Buffer
|
|
60
59
|
): void => {
|
|
61
60
|
if (!webhookSecret && !limeSignature) {
|
|
62
61
|
throw new NodeOperationError(
|
|
63
|
-
|
|
62
|
+
node,
|
|
64
63
|
'Webhook secret and lime signature are missing!'
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
if (!webhookSecret && limeSignature) {
|
|
68
67
|
throw new NodeOperationError(
|
|
69
|
-
|
|
68
|
+
node,
|
|
70
69
|
'Webhook authentication failed, secret key is missing while signature is present!'
|
|
71
70
|
);
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
if (!limeSignature && webhookSecret) {
|
|
75
74
|
throw new NodeOperationError(
|
|
76
|
-
|
|
75
|
+
node,
|
|
77
76
|
'Webhook authentication failed, signature key is missing while secret is present!'
|
|
78
77
|
);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
const expectedHmac = generateHmac(webhookSecret, data);
|
|
82
81
|
if (expectedHmac !== limeSignature) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
handleWorkflowError(nodeContext, {
|
|
88
|
-
message: 'Webhook authentication failed, signature does not match!',
|
|
89
|
-
receivedSignature: limeSignature,
|
|
90
|
-
expectedSignature: expectedHmac,
|
|
91
|
-
bodyLength: data.length,
|
|
92
|
-
secretFingerprint,
|
|
93
|
-
});
|
|
82
|
+
throw new NodeOperationError(
|
|
83
|
+
node,
|
|
84
|
+
'Webhook authentication failed, signatures do not match'
|
|
85
|
+
);
|
|
94
86
|
}
|
|
95
87
|
};
|
package/nodes/errorHandling.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IExecuteFunctions,
|
|
3
|
-
IAllExecuteFunctions,
|
|
4
2
|
NodeApiError,
|
|
5
3
|
NodeOperationError,
|
|
6
4
|
JsonObject,
|
|
5
|
+
INode,
|
|
7
6
|
} from 'n8n-workflow';
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
* Type guard checking if the class conforms to {@link IExecuteFunctions}
|
|
11
|
-
* interface
|
|
12
|
-
* @param nodeContext - a subclass of n8n's FunctionsBase interface
|
|
13
|
-
*/
|
|
14
|
-
function isIExecuteFunctions(
|
|
15
|
-
nodeContext: IAllExecuteFunctions
|
|
16
|
-
): nodeContext is IExecuteFunctions {
|
|
17
|
-
return (nodeContext as IExecuteFunctions).continueOnFail !== undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
8
|
/**
|
|
21
9
|
* Wrapper for the error data used in Lime workflows
|
|
22
10
|
*/
|
|
@@ -36,25 +24,28 @@ export type ErrorResponse = {
|
|
|
36
24
|
* Function which handles how are the errors handled in n8n workflows. It
|
|
37
25
|
* either throws an error or returns the error data, depending on the
|
|
38
26
|
* `continue on Error` flag.
|
|
39
|
-
* @param
|
|
40
|
-
* subclass of {@link
|
|
27
|
+
* @param node - the context of a Node
|
|
28
|
+
* subclass of {@link INode}
|
|
41
29
|
* @param errorContext - the data of the error we want to return to the user
|
|
42
30
|
* @param isApiError - flag checking if the error is connected to the external
|
|
43
31
|
* API or internal N8N's logic - based on it we either throw {@link NodeApiError}
|
|
44
32
|
* or {@link NodeOperationError}
|
|
45
33
|
*/
|
|
46
34
|
export function handleWorkflowError(
|
|
47
|
-
|
|
35
|
+
node: INode,
|
|
48
36
|
errorContext: WorkflowErrorContext,
|
|
49
37
|
isApiError: boolean = false
|
|
50
38
|
): ErrorResponse {
|
|
51
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
node.onError === 'continueErrorOutput' ||
|
|
41
|
+
node.onError === 'continueRegularOutput'
|
|
42
|
+
) {
|
|
52
43
|
return {
|
|
53
44
|
success: false,
|
|
54
45
|
data: { error: errorContext },
|
|
55
46
|
};
|
|
56
47
|
} else if (isApiError) {
|
|
57
|
-
throw new NodeApiError(
|
|
48
|
+
throw new NodeApiError(node, errorContext);
|
|
58
49
|
}
|
|
59
|
-
throw new NodeOperationError(
|
|
50
|
+
throw new NodeOperationError(node, errorContext.message);
|
|
60
51
|
}
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
getSubscription,
|
|
20
20
|
listSubscriptionsWithExistingData,
|
|
21
21
|
} from './transport';
|
|
22
|
-
|
|
23
|
-
import { getWebhook } from './utils';
|
|
22
|
+
import { createHash } from 'node:crypto';
|
|
23
|
+
import { getWebhook, handleWorkflowError } from './utils';
|
|
24
24
|
import { verifyRequest } from '../common';
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -305,12 +305,30 @@ export class LimeCrmTrigger implements INodeType {
|
|
|
305
305
|
const bodyData = this.getBodyData();
|
|
306
306
|
const limeSignature = headerData['x-lime-signature'] as string;
|
|
307
307
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
308
|
+
try {
|
|
309
|
+
verifyRequest(
|
|
310
|
+
this.getNode(),
|
|
311
|
+
limeSignature,
|
|
312
|
+
webhookSecret,
|
|
313
|
+
requestObject.rawBody
|
|
314
|
+
);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
const secretFingerprint = webhookSecret
|
|
317
|
+
? createHash('sha256')
|
|
318
|
+
.update(webhookSecret)
|
|
319
|
+
.digest('hex')
|
|
320
|
+
.slice(0, 16)
|
|
321
|
+
: '';
|
|
322
|
+
const returnData = handleWorkflowError(this.getNode(), {
|
|
323
|
+
message: error.message,
|
|
324
|
+
receivedSignature: limeSignature,
|
|
325
|
+
bodyLength: requestObject.rawBody.length,
|
|
326
|
+
secretFingerprint,
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
workflowData: [this.helpers.returnJsonArray(returnData.data)],
|
|
330
|
+
};
|
|
331
|
+
}
|
|
314
332
|
|
|
315
333
|
if (!bodyData || !bodyData.event || !bodyData.body) {
|
|
316
334
|
Logger.warn('Webhook data is invalid. Missing event or body', {
|
|
@@ -103,7 +103,7 @@ export async function execute(
|
|
|
103
103
|
} else if (source == 'byLimeobject') {
|
|
104
104
|
response = await fetchSingleUserByLimeobjectId(this, id, withCoworker);
|
|
105
105
|
} else {
|
|
106
|
-
response = handleWorkflowError(this, {
|
|
106
|
+
response = handleWorkflowError(this.getNode(), {
|
|
107
107
|
message: `The source ${source} is not supported!`,
|
|
108
108
|
});
|
|
109
109
|
}
|
|
@@ -24,7 +24,6 @@ const moduleHandler = new N8NOperationModuleHandler([
|
|
|
24
24
|
operations.bulkCreateManyObjects,
|
|
25
25
|
operations.bulkUpdateManyObjects,
|
|
26
26
|
operations.bulkCreateOrUpdateManyObjects,
|
|
27
|
-
operations.startBulkImport,
|
|
28
27
|
]);
|
|
29
28
|
|
|
30
29
|
/**
|
|
@@ -141,13 +140,6 @@ export async function dataOperations(
|
|
|
141
140
|
);
|
|
142
141
|
return result && { json: result };
|
|
143
142
|
}
|
|
144
|
-
case 'startBulkImport': {
|
|
145
|
-
const result = await operations.startBulkImport.execute.call(
|
|
146
|
-
this,
|
|
147
|
-
i
|
|
148
|
-
);
|
|
149
|
-
return result && { json: result };
|
|
150
|
-
}
|
|
151
143
|
}
|
|
152
144
|
|
|
153
145
|
throw new NodeOperationError(
|
|
@@ -34,8 +34,3 @@ export * as bulkUpdateManyObjects from './bulkUpdateManyObjects.operation';
|
|
|
34
34
|
* @group Resources
|
|
35
35
|
*/
|
|
36
36
|
export * as bulkCreateOrUpdateManyObjects from './bulkCreateOrUpdateManyObjects.operation';
|
|
37
|
-
/**
|
|
38
|
-
* @group Resources
|
|
39
|
-
* @deprecated Use bulkCreateManyObjects, bulkUpdateManyObjects, or bulkCreateOrUpdateManyObjects instead.
|
|
40
|
-
*/
|
|
41
|
-
export * as startBulkImport from './deprecated-startBulkImport.operation';
|
|
@@ -142,8 +142,8 @@ export async function execute(
|
|
|
142
142
|
property
|
|
143
143
|
);
|
|
144
144
|
} else {
|
|
145
|
-
response = handleWorkflowError(this, {
|
|
146
|
-
message: `The source "${source} is not supported`,
|
|
145
|
+
response = handleWorkflowError(this.getNode(), {
|
|
146
|
+
message: `The source "${source}" is not supported`,
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
return response.data;
|
|
@@ -107,7 +107,7 @@ export async function getFileMetadataByLimeobject(
|
|
|
107
107
|
|
|
108
108
|
if (!fileId) {
|
|
109
109
|
return handleWorkflowError(
|
|
110
|
-
nodeContext,
|
|
110
|
+
nodeContext.getNode(),
|
|
111
111
|
{
|
|
112
112
|
message:
|
|
113
113
|
'The specified Limeobject does not have an associated file',
|
|
@@ -191,7 +191,7 @@ export async function getFileContentByLimetype(
|
|
|
191
191
|
|
|
192
192
|
if (!fileId) {
|
|
193
193
|
return handleWorkflowError(
|
|
194
|
-
nodeContext,
|
|
194
|
+
nodeContext.getNode(),
|
|
195
195
|
{
|
|
196
196
|
message:
|
|
197
197
|
'The specified Limeobject does not have an associated file.',
|
|
@@ -63,7 +63,7 @@ async function findCoworker(
|
|
|
63
63
|
const coworker = findCoworkerLimetype(response.data);
|
|
64
64
|
if (!coworker) {
|
|
65
65
|
return handleWorkflowError(
|
|
66
|
-
nodeContext,
|
|
66
|
+
nodeContext.getNode(),
|
|
67
67
|
{
|
|
68
68
|
message: `No limetype with 'user' property found to get coworker`,
|
|
69
69
|
},
|
|
@@ -271,7 +271,7 @@ export async function fetchSingleUserByLimeobjectId(
|
|
|
271
271
|
);
|
|
272
272
|
if (!userProperty) {
|
|
273
273
|
return handleWorkflowError(
|
|
274
|
-
nodeContext,
|
|
274
|
+
nodeContext.getNode(),
|
|
275
275
|
{
|
|
276
276
|
message: `No property of type 'user' found in ${coworkerLimetype.name} limetype`,
|
|
277
277
|
},
|
|
@@ -244,7 +244,7 @@ export class LimeFormsTrigger implements INodeType {
|
|
|
244
244
|
}
|
|
245
245
|
returnData.push(body);
|
|
246
246
|
} catch (error) {
|
|
247
|
-
const response = handleWorkflowError(this, {
|
|
247
|
+
const response = handleWorkflowError(this.getNode(), {
|
|
248
248
|
message: error.message,
|
|
249
249
|
});
|
|
250
250
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@limetech/n8n-nodes-lime",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "n8n node to connect to Lime CRM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "nodes/index.ts",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"@semantic-release/changelog": "^6.0.3",
|
|
44
44
|
"@semantic-release/git": "^10.0.1",
|
|
45
45
|
"@types/jest": "^30.0.0",
|
|
46
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^25.5.0",
|
|
47
47
|
"copyfiles": "^2.4.1",
|
|
48
|
-
"eslint": "^
|
|
49
|
-
"jest": "^30.
|
|
50
|
-
"knip": "^5.
|
|
51
|
-
"prettier": "^3.
|
|
52
|
-
"semantic-release": "^25.0.
|
|
53
|
-
"ts-jest": "^29.4.
|
|
54
|
-
"typedoc": "^0.28.
|
|
48
|
+
"eslint": "^10.0.3",
|
|
49
|
+
"jest": "^30.3.0",
|
|
50
|
+
"knip": "^5.88.1",
|
|
51
|
+
"prettier": "^3.8.1",
|
|
52
|
+
"semantic-release": "^25.0.3",
|
|
53
|
+
"ts-jest": "^29.4.6",
|
|
54
|
+
"typedoc": "^0.28.17",
|
|
55
55
|
"typescript": "^5.9.3"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"n8n-workflow": "^
|
|
58
|
+
"n8n-workflow": "^2.9.0"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=24 <25",
|
package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
export declare const description: {
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
description: string;
|
|
6
|
-
action: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const properties: INodeProperties[];
|
|
9
|
-
export declare function execute(this: IExecuteFunctions, i: number): Promise<IDataObject | undefined>;
|
package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.properties = exports.description = void 0;
|
|
4
|
-
exports.execute = execute;
|
|
5
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
-
const models_1 = require("../../../models");
|
|
7
|
-
const transport_1 = require("../../../transport");
|
|
8
|
-
const bulkimport_1 = require("../../../transport/bulkimport");
|
|
9
|
-
exports.description = {
|
|
10
|
-
name: 'Create or update many objects (deprecated)',
|
|
11
|
-
value: 'startBulkImport',
|
|
12
|
-
description: 'Create or update multiple objects via a bulk import. Skipping business logic.',
|
|
13
|
-
action: 'Create or update many objects (deprecated)',
|
|
14
|
-
};
|
|
15
|
-
exports.properties = [
|
|
16
|
-
{
|
|
17
|
-
displayName: '<h1>Deprecated</h1>' +
|
|
18
|
-
'This action is deprecated and will be removed very soon. ' +
|
|
19
|
-
'Please use the new "Create or Update Many Objects (Alpha)" operation instead.',
|
|
20
|
-
name: 'deprecatedNotice',
|
|
21
|
-
type: 'callout',
|
|
22
|
-
displayOptions: {
|
|
23
|
-
show: {
|
|
24
|
-
resource: [models_1.DATA_RESOURCE],
|
|
25
|
-
operation: ['startBulkImport'],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
default: undefined,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
displayName: 'Limetype',
|
|
32
|
-
name: 'limetype',
|
|
33
|
-
type: 'options',
|
|
34
|
-
typeOptions: {
|
|
35
|
-
loadOptionsMethod: 'getLimetypes',
|
|
36
|
-
},
|
|
37
|
-
required: true,
|
|
38
|
-
default: '',
|
|
39
|
-
description: 'The type of object to update',
|
|
40
|
-
displayOptions: {
|
|
41
|
-
show: {
|
|
42
|
-
resource: [models_1.DATA_RESOURCE],
|
|
43
|
-
operation: ['startBulkImport'],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
displayName: 'Matching Property',
|
|
49
|
-
name: 'matchingProperty',
|
|
50
|
-
type: 'options',
|
|
51
|
-
typeOptions: {
|
|
52
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
53
|
-
loadOptionsDependsOn: ['limetype'],
|
|
54
|
-
},
|
|
55
|
-
required: true,
|
|
56
|
-
default: '',
|
|
57
|
-
description: 'The property to use to match existing objects. Must be a unique property.',
|
|
58
|
-
displayOptions: {
|
|
59
|
-
show: {
|
|
60
|
-
resource: [models_1.DATA_RESOURCE],
|
|
61
|
-
operation: ['startBulkImport'],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
displayName: 'Input Type',
|
|
67
|
-
name: 'inputType',
|
|
68
|
-
type: 'options',
|
|
69
|
-
options: [
|
|
70
|
-
{
|
|
71
|
-
name: 'Simple Fields',
|
|
72
|
-
value: 'simple',
|
|
73
|
-
description: 'Define fields using the UI',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'JSON Object',
|
|
77
|
-
value: 'json',
|
|
78
|
-
description: 'Define fields using JSON',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
default: 'simple',
|
|
82
|
-
description: 'How to input the data',
|
|
83
|
-
displayOptions: {
|
|
84
|
-
show: {
|
|
85
|
-
resource: [models_1.DATA_RESOURCE],
|
|
86
|
-
operation: ['startBulkImport'],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
displayName: 'Data',
|
|
92
|
-
name: 'jsonData',
|
|
93
|
-
type: 'json',
|
|
94
|
-
default: '{\n "name": "Updated Company Name",\n "phone": "+987654321"\n}',
|
|
95
|
-
description: 'Key-value pairs for fields to update. Property names must match the Lime CRM field names.',
|
|
96
|
-
typeOptions: {
|
|
97
|
-
alwaysOpenEditWindow: true,
|
|
98
|
-
},
|
|
99
|
-
displayOptions: {
|
|
100
|
-
show: {
|
|
101
|
-
resource: [models_1.DATA_RESOURCE],
|
|
102
|
-
operation: ['startBulkImport'],
|
|
103
|
-
inputType: ['json'],
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
displayName: 'Fields',
|
|
109
|
-
name: 'simpleFields',
|
|
110
|
-
placeholder: 'Add Field',
|
|
111
|
-
type: 'fixedCollection',
|
|
112
|
-
typeOptions: {
|
|
113
|
-
multipleValues: true,
|
|
114
|
-
sortable: true,
|
|
115
|
-
},
|
|
116
|
-
default: {},
|
|
117
|
-
displayOptions: {
|
|
118
|
-
show: {
|
|
119
|
-
resource: [models_1.DATA_RESOURCE],
|
|
120
|
-
operation: ['startBulkImport'],
|
|
121
|
-
inputType: ['simple'],
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
options: [
|
|
125
|
-
{
|
|
126
|
-
name: 'field',
|
|
127
|
-
displayName: 'Field',
|
|
128
|
-
values: [
|
|
129
|
-
{
|
|
130
|
-
displayName: 'Field Name',
|
|
131
|
-
name: 'fieldName',
|
|
132
|
-
type: 'options',
|
|
133
|
-
typeOptions: {
|
|
134
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
135
|
-
loadOptionsDependsOn: ['limetype'],
|
|
136
|
-
},
|
|
137
|
-
default: '',
|
|
138
|
-
description: 'The name of the field',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
displayName: 'Field Value',
|
|
142
|
-
name: 'fieldValue',
|
|
143
|
-
type: 'string',
|
|
144
|
-
default: '',
|
|
145
|
-
description: 'The value of the field',
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
displayName: 'Relation Lookup',
|
|
149
|
-
name: 'fieldNameDotLookup',
|
|
150
|
-
type: 'options',
|
|
151
|
-
typeOptions: {
|
|
152
|
-
loadOptionsMethod: 'getRelationPropertiesWithLookupField',
|
|
153
|
-
loadOptionsDependsOn: ['limetype'],
|
|
154
|
-
},
|
|
155
|
-
default: '',
|
|
156
|
-
description: 'For relation fields: select which property on the related object to use for matching. Leave empty for non-relation fields.',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
];
|
|
163
|
-
function getPropertiesFromJson(jsonData) {
|
|
164
|
-
const parsed = JSON.parse(jsonData);
|
|
165
|
-
return Object.keys(parsed);
|
|
166
|
-
}
|
|
167
|
-
function getPropertiesFromSimpleFields(simpleFields, getNode) {
|
|
168
|
-
const propertiesToImport = [];
|
|
169
|
-
for (const field of simpleFields) {
|
|
170
|
-
const fieldName = field.fieldName;
|
|
171
|
-
const fieldNameDotLookup = field.fieldNameDotLookup;
|
|
172
|
-
if (fieldNameDotLookup) {
|
|
173
|
-
const [relationField] = fieldNameDotLookup.split('.');
|
|
174
|
-
if (relationField !== fieldName) {
|
|
175
|
-
throw new n8n_workflow_1.NodeOperationError(getNode(), `Relation lookup "${fieldNameDotLookup}" does not match field name "${fieldName}".`);
|
|
176
|
-
}
|
|
177
|
-
propertiesToImport.push(fieldNameDotLookup);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
propertiesToImport.push(fieldName);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return propertiesToImport;
|
|
184
|
-
}
|
|
185
|
-
function buildPayloadFromSimpleFields(simpleFields) {
|
|
186
|
-
const obj = { values: {} };
|
|
187
|
-
for (const field of simpleFields) {
|
|
188
|
-
const fieldName = field.fieldName;
|
|
189
|
-
const fieldValue = field.fieldValue;
|
|
190
|
-
obj.values[fieldName] = fieldValue;
|
|
191
|
-
}
|
|
192
|
-
return obj;
|
|
193
|
-
}
|
|
194
|
-
async function execute(i) {
|
|
195
|
-
if (i > 0) {
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
const limetype = this.getNodeParameter('limetype', i);
|
|
199
|
-
const matchingProperty = this.getNodeParameter('matchingProperty', i);
|
|
200
|
-
const inputType = this.getNodeParameter('inputType', i);
|
|
201
|
-
const items = this.getInputData();
|
|
202
|
-
n8n_workflow_1.LoggerProxy.info(`Preparing bulk import of ${items.length} objects for limetype: ${limetype}`);
|
|
203
|
-
const propertiesToImport = inputType === 'json'
|
|
204
|
-
? getPropertiesFromJson(this.getNodeParameter('jsonData', 0))
|
|
205
|
-
: getPropertiesFromSimpleFields(this.getNodeParameter('simpleFields.field', 0, []), this.getNode.bind(this));
|
|
206
|
-
n8n_workflow_1.LoggerProxy.info(`Properties to import: ${propertiesToImport.join(', ')}`);
|
|
207
|
-
const body = items.map((_, idx) => {
|
|
208
|
-
if (inputType === 'json') {
|
|
209
|
-
return JSON.parse(this.getNodeParameter('jsonData', idx));
|
|
210
|
-
}
|
|
211
|
-
return buildPayloadFromSimpleFields(this.getNodeParameter('simpleFields.field', idx, []));
|
|
212
|
-
});
|
|
213
|
-
const jobPayload = {
|
|
214
|
-
mode: 'create_or_update',
|
|
215
|
-
limetype,
|
|
216
|
-
matchingProperty,
|
|
217
|
-
properties: propertiesToImport,
|
|
218
|
-
};
|
|
219
|
-
const jobResponse = await (0, transport_1.createBulkImportJob)(this, jobPayload);
|
|
220
|
-
const jobId = jobResponse.id;
|
|
221
|
-
await (0, transport_1.uploadBulkImportData)(this, jobId, body);
|
|
222
|
-
const finalStatus = await (0, bulkimport_1.waitForBulkImportJob)(this, jobId, 2500);
|
|
223
|
-
if (finalStatus.status === 'failed') {
|
|
224
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'The bulk import job failed', {
|
|
225
|
-
message: 'The bulk import job failed due to a server error.',
|
|
226
|
-
description: `Bulk import job with ID ${jobId} has failed. Check the Lime CRM server for more details.`,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
jobId,
|
|
231
|
-
status: finalStatus.status,
|
|
232
|
-
summary: finalStatus.result || {
|
|
233
|
-
total: 0,
|
|
234
|
-
created: 0,
|
|
235
|
-
updated: 0,
|
|
236
|
-
skipped: 0,
|
|
237
|
-
failed: 0,
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
//# sourceMappingURL=deprecated-startBulkImport.operation.js.map
|
package/dist/nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated-startBulkImport.operation.js","sourceRoot":"","sources":["../../../../../../nodes/lime-crm/resources/data/operations/deprecated-startBulkImport.operation.ts"],"names":[],"mappings":";;;AAgRA,0BA2FC;AA3WD,+CAOsB;AACtB,4CAAgD;AAChD,kDAI4B;AAC5B,8DAGuC;AAO1B,QAAA,WAAW,GAAG;IACvB,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,iBAAiB;IACxB,WAAW,EACP,+EAA+E;IACnF,MAAM,EAAE,4CAA4C;CACvD,CAAC;AAaW,QAAA,UAAU,GAAsB;IACzC;QACI,WAAW,EACP,qBAAqB;YACrB,2DAA2D;YAC3D,+EAA+E;QACnF,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE;YACZ,IAAI,EAAE;gBACF,QAAQ,EAAE,CAAC,sBAAa,CAAC;gBACzB,SAAS,EAAE,CAAC,iBAAiB,CAAC;aACjC;SACJ;QACD,OAAO,EAAE,SAAS;KACrB;IACD;QACI,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;YACT,iBAAiB,EAAE,cAAc;SACpC;QACD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX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