@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
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IDataObject,
|
|
3
|
-
IExecuteFunctions,
|
|
4
|
-
INode,
|
|
5
|
-
INodeProperties,
|
|
6
|
-
LoggerProxy as Logger,
|
|
7
|
-
NodeOperationError,
|
|
8
|
-
} from 'n8n-workflow';
|
|
9
|
-
import { DATA_RESOURCE } from '../../../models';
|
|
10
|
-
import {
|
|
11
|
-
BulkImportJobPayload,
|
|
12
|
-
createBulkImportJob,
|
|
13
|
-
uploadBulkImportData,
|
|
14
|
-
} from '../../../transport';
|
|
15
|
-
import {
|
|
16
|
-
BulkImportPayloadObject,
|
|
17
|
-
waitForBulkImportJob,
|
|
18
|
-
} from '../../../transport/bulkimport';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Description and metadata for the "Bulk import objects" operation in Lime CRM.
|
|
22
|
-
*
|
|
23
|
-
* @public
|
|
24
|
-
*/
|
|
25
|
-
export const description = {
|
|
26
|
-
name: 'Create or update many objects (deprecated)',
|
|
27
|
-
value: 'startBulkImport',
|
|
28
|
-
description:
|
|
29
|
-
'Create or update multiple objects via a bulk import. Skipping business logic.',
|
|
30
|
-
action: 'Create or update many objects (deprecated)',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Node properties for the "Bulk import objects" operation.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} limetype - The type of entity to update. Loaded from available Limetypes
|
|
37
|
-
* @param {string} id - The ID of the object to update
|
|
38
|
-
* @param {'simple' | 'json'} inputType - How the object data is provided: 'simple' for form inputs, 'json' for raw JSON
|
|
39
|
-
* @param {IDataObject} simpleFields - Used if `inputType` is 'simple'. List of field name/value pairs to update
|
|
40
|
-
* @param {string} jsonData - Used if `inputType` is 'json'. Full object data in JSON format
|
|
41
|
-
*
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export const properties: INodeProperties[] = [
|
|
45
|
-
{
|
|
46
|
-
displayName:
|
|
47
|
-
'<h1>Deprecated</h1>' +
|
|
48
|
-
'This action is deprecated and will be removed very soon. ' +
|
|
49
|
-
'Please use the new "Create or Update Many Objects (Alpha)" operation instead.',
|
|
50
|
-
name: 'deprecatedNotice',
|
|
51
|
-
type: 'callout',
|
|
52
|
-
displayOptions: {
|
|
53
|
-
show: {
|
|
54
|
-
resource: [DATA_RESOURCE],
|
|
55
|
-
operation: ['startBulkImport'],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
default: undefined,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
displayName: 'Limetype',
|
|
62
|
-
name: 'limetype',
|
|
63
|
-
type: 'options',
|
|
64
|
-
typeOptions: {
|
|
65
|
-
loadOptionsMethod: 'getLimetypes',
|
|
66
|
-
},
|
|
67
|
-
required: true,
|
|
68
|
-
default: '',
|
|
69
|
-
description: 'The type of object to update',
|
|
70
|
-
displayOptions: {
|
|
71
|
-
show: {
|
|
72
|
-
resource: [DATA_RESOURCE],
|
|
73
|
-
operation: ['startBulkImport'],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
displayName: 'Matching Property',
|
|
79
|
-
name: 'matchingProperty',
|
|
80
|
-
type: 'options',
|
|
81
|
-
typeOptions: {
|
|
82
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
83
|
-
loadOptionsDependsOn: ['limetype'],
|
|
84
|
-
},
|
|
85
|
-
required: true,
|
|
86
|
-
default: '',
|
|
87
|
-
description:
|
|
88
|
-
'The property to use to match existing objects. Must be a unique property.',
|
|
89
|
-
displayOptions: {
|
|
90
|
-
show: {
|
|
91
|
-
resource: [DATA_RESOURCE],
|
|
92
|
-
operation: ['startBulkImport'],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
displayName: 'Input Type',
|
|
98
|
-
name: 'inputType',
|
|
99
|
-
type: 'options',
|
|
100
|
-
options: [
|
|
101
|
-
{
|
|
102
|
-
name: 'Simple Fields',
|
|
103
|
-
value: 'simple',
|
|
104
|
-
description: 'Define fields using the UI',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: 'JSON Object',
|
|
108
|
-
value: 'json',
|
|
109
|
-
description: 'Define fields using JSON',
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
default: 'simple',
|
|
113
|
-
description: 'How to input the data',
|
|
114
|
-
displayOptions: {
|
|
115
|
-
show: {
|
|
116
|
-
resource: [DATA_RESOURCE],
|
|
117
|
-
operation: ['startBulkImport'],
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
displayName: 'Data',
|
|
123
|
-
name: 'jsonData',
|
|
124
|
-
type: 'json',
|
|
125
|
-
default:
|
|
126
|
-
'{\n "name": "Updated Company Name",\n "phone": "+987654321"\n}',
|
|
127
|
-
description:
|
|
128
|
-
'Key-value pairs for fields to update. Property names must match the Lime CRM field names.',
|
|
129
|
-
typeOptions: {
|
|
130
|
-
alwaysOpenEditWindow: true,
|
|
131
|
-
},
|
|
132
|
-
displayOptions: {
|
|
133
|
-
show: {
|
|
134
|
-
resource: [DATA_RESOURCE],
|
|
135
|
-
operation: ['startBulkImport'],
|
|
136
|
-
inputType: ['json'],
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
displayName: 'Fields',
|
|
142
|
-
name: 'simpleFields',
|
|
143
|
-
placeholder: 'Add Field',
|
|
144
|
-
type: 'fixedCollection',
|
|
145
|
-
typeOptions: {
|
|
146
|
-
multipleValues: true,
|
|
147
|
-
sortable: true,
|
|
148
|
-
},
|
|
149
|
-
default: {},
|
|
150
|
-
displayOptions: {
|
|
151
|
-
show: {
|
|
152
|
-
resource: [DATA_RESOURCE],
|
|
153
|
-
operation: ['startBulkImport'],
|
|
154
|
-
inputType: ['simple'],
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
options: [
|
|
158
|
-
{
|
|
159
|
-
name: 'field',
|
|
160
|
-
displayName: 'Field',
|
|
161
|
-
values: [
|
|
162
|
-
{
|
|
163
|
-
displayName: 'Field Name',
|
|
164
|
-
name: 'fieldName',
|
|
165
|
-
type: 'options',
|
|
166
|
-
typeOptions: {
|
|
167
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
168
|
-
loadOptionsDependsOn: ['limetype'],
|
|
169
|
-
},
|
|
170
|
-
default: '',
|
|
171
|
-
description: 'The name of the field',
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
displayName: 'Field Value',
|
|
175
|
-
name: 'fieldValue',
|
|
176
|
-
type: 'string',
|
|
177
|
-
default: '',
|
|
178
|
-
description: 'The value of the field',
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
displayName: 'Relation Lookup',
|
|
182
|
-
name: 'fieldNameDotLookup',
|
|
183
|
-
type: 'options',
|
|
184
|
-
typeOptions: {
|
|
185
|
-
loadOptionsMethod:
|
|
186
|
-
'getRelationPropertiesWithLookupField',
|
|
187
|
-
loadOptionsDependsOn: ['limetype'],
|
|
188
|
-
},
|
|
189
|
-
default: '',
|
|
190
|
-
description:
|
|
191
|
-
'For relation fields: select which property on the related object to use for matching. Leave empty for non-relation fields.',
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
];
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Extract properties to import from JSON input.
|
|
201
|
-
* @param jsonData
|
|
202
|
-
*/
|
|
203
|
-
function getPropertiesFromJson(jsonData: string): string[] {
|
|
204
|
-
const parsed = JSON.parse(jsonData);
|
|
205
|
-
return Object.keys(parsed);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Extract properties to import from simple fields input.
|
|
210
|
-
* Validates that relation lookups match their field names.
|
|
211
|
-
* @param simpleFields
|
|
212
|
-
* @param getNode
|
|
213
|
-
*/
|
|
214
|
-
function getPropertiesFromSimpleFields(
|
|
215
|
-
simpleFields: IDataObject[],
|
|
216
|
-
getNode: () => INode
|
|
217
|
-
): string[] {
|
|
218
|
-
const propertiesToImport: string[] = [];
|
|
219
|
-
|
|
220
|
-
for (const field of simpleFields) {
|
|
221
|
-
const fieldName = field.fieldName as string;
|
|
222
|
-
const fieldNameDotLookup = field.fieldNameDotLookup as string;
|
|
223
|
-
|
|
224
|
-
if (fieldNameDotLookup) {
|
|
225
|
-
const [relationField] = fieldNameDotLookup.split('.');
|
|
226
|
-
|
|
227
|
-
if (relationField !== fieldName) {
|
|
228
|
-
throw new NodeOperationError(
|
|
229
|
-
getNode(),
|
|
230
|
-
`Relation lookup "${fieldNameDotLookup}" does not match field name "${fieldName}".`
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
propertiesToImport.push(fieldNameDotLookup);
|
|
234
|
-
} else {
|
|
235
|
-
propertiesToImport.push(fieldName);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return propertiesToImport;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Build a payload object from simple fields.
|
|
244
|
-
* @param simpleFields
|
|
245
|
-
*/
|
|
246
|
-
function buildPayloadFromSimpleFields(
|
|
247
|
-
simpleFields: IDataObject[]
|
|
248
|
-
): BulkImportPayloadObject {
|
|
249
|
-
const obj: BulkImportPayloadObject = { values: {} };
|
|
250
|
-
|
|
251
|
-
for (const field of simpleFields) {
|
|
252
|
-
const fieldName = field.fieldName as string;
|
|
253
|
-
const fieldValue = field.fieldValue as string;
|
|
254
|
-
|
|
255
|
-
obj.values[fieldName] = fieldValue;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return obj;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Execute the "Bulk import objects" operation for Lime CRM.
|
|
263
|
-
*
|
|
264
|
-
* @remarks
|
|
265
|
-
* This method creates a bulk import job and uploads data.
|
|
266
|
-
*
|
|
267
|
-
* @param i - The index of the current item in the workflow execution
|
|
268
|
-
*
|
|
269
|
-
* @returns The bulk import job status and summary
|
|
270
|
-
*
|
|
271
|
-
* @public
|
|
272
|
-
*/
|
|
273
|
-
export async function execute(
|
|
274
|
-
this: IExecuteFunctions,
|
|
275
|
-
i: number
|
|
276
|
-
): Promise<IDataObject | undefined> {
|
|
277
|
-
if (i > 0) {
|
|
278
|
-
return undefined;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
282
|
-
const matchingProperty = this.getNodeParameter(
|
|
283
|
-
'matchingProperty',
|
|
284
|
-
i
|
|
285
|
-
) as string;
|
|
286
|
-
const inputType = this.getNodeParameter('inputType', i) as string;
|
|
287
|
-
const items = this.getInputData();
|
|
288
|
-
|
|
289
|
-
Logger.info(
|
|
290
|
-
`Preparing bulk import of ${items.length} objects for limetype: ${limetype}`
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
// Step 1: Compute the properties to import based on the first item
|
|
294
|
-
const propertiesToImport =
|
|
295
|
-
inputType === 'json'
|
|
296
|
-
? getPropertiesFromJson(
|
|
297
|
-
this.getNodeParameter('jsonData', 0) as string
|
|
298
|
-
)
|
|
299
|
-
: getPropertiesFromSimpleFields(
|
|
300
|
-
this.getNodeParameter(
|
|
301
|
-
'simpleFields.field',
|
|
302
|
-
0,
|
|
303
|
-
[]
|
|
304
|
-
) as IDataObject[],
|
|
305
|
-
this.getNode.bind(this)
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
Logger.info(`Properties to import: ${propertiesToImport.join(', ')}`);
|
|
309
|
-
|
|
310
|
-
// Step 2: Prepare the body for all items
|
|
311
|
-
const body: BulkImportPayloadObject[] = items.map((_, idx) => {
|
|
312
|
-
if (inputType === 'json') {
|
|
313
|
-
return JSON.parse(this.getNodeParameter('jsonData', idx) as string);
|
|
314
|
-
}
|
|
315
|
-
return buildPayloadFromSimpleFields(
|
|
316
|
-
this.getNodeParameter(
|
|
317
|
-
'simpleFields.field',
|
|
318
|
-
idx,
|
|
319
|
-
[]
|
|
320
|
-
) as IDataObject[]
|
|
321
|
-
);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
// Step 3: Create the bulk import job
|
|
325
|
-
const jobPayload: BulkImportJobPayload = {
|
|
326
|
-
mode: 'create_or_update',
|
|
327
|
-
limetype,
|
|
328
|
-
matchingProperty,
|
|
329
|
-
properties: propertiesToImport,
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const jobResponse = await createBulkImportJob(this, jobPayload);
|
|
333
|
-
const jobId = jobResponse.id;
|
|
334
|
-
|
|
335
|
-
// Step 4: Upload the data file
|
|
336
|
-
await uploadBulkImportData(this, jobId, body);
|
|
337
|
-
|
|
338
|
-
// Step 5: Poll for completion
|
|
339
|
-
const finalStatus = await waitForBulkImportJob(this, jobId, 2500);
|
|
340
|
-
|
|
341
|
-
if (finalStatus.status === 'failed') {
|
|
342
|
-
throw new NodeOperationError(
|
|
343
|
-
this.getNode(),
|
|
344
|
-
'The bulk import job failed',
|
|
345
|
-
{
|
|
346
|
-
message: 'The bulk import job failed due to a server error.',
|
|
347
|
-
description: `Bulk import job with ID ${jobId} has failed. Check the Lime CRM server for more details.`,
|
|
348
|
-
}
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Step 6: Return the results summary
|
|
353
|
-
return {
|
|
354
|
-
jobId,
|
|
355
|
-
status: finalStatus.status,
|
|
356
|
-
summary: finalStatus.result || {
|
|
357
|
-
total: 0,
|
|
358
|
-
created: 0,
|
|
359
|
-
updated: 0,
|
|
360
|
-
skipped: 0,
|
|
361
|
-
failed: 0,
|
|
362
|
-
},
|
|
363
|
-
};
|
|
364
|
-
}
|