@mspcopilot/n8n-nodes-connectwise 0.1.1
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/README.md +59 -0
- package/dist-community/LICENSE.md +21 -0
- package/dist-community/credentials/ConnectWisePsaApi.credentials.js +142 -0
- package/dist-community/credentials/connectwise.svg +1 -0
- package/dist-community/nodes/ConnectWise/PSA/ConnectWisePsa.node.js +180 -0
- package/dist-community/nodes/ConnectWise/PSA/connectwise.svg +1 -0
- package/dist-community/nodes/ConnectWise/PSA/descriptions/common.descriptions.js +46 -0
- package/dist-community/nodes/ConnectWise/PSA/descriptions/common.properties.js +353 -0
- package/dist-community/nodes/ConnectWise/PSA/descriptions/index.js +30 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/customFields.js +116 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/field-collector.js +83 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/field-conditions.js +86 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/index.js +33 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/logging.js +61 -0
- package/dist-community/nodes/ConnectWise/PSA/helpers/utils.js +128 -0
- package/dist-community/nodes/ConnectWise/PSA/methods/fieldOptions.js +223 -0
- package/dist-community/nodes/ConnectWise/PSA/methods/generated.js +53 -0
- package/dist-community/nodes/ConnectWise/PSA/methods/index.js +40 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/converter/index.js +66 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/converter/reference.generator.js +178 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/index.js +39 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/references.js +293 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/reports-descriptions.js +300 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/activity.schema.js +413 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/alert-consolidation.js +42 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/company.schema.js +720 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/contact.schema.js +461 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/custom.schema.js +163 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/index.js +72 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/members.schema.js +361 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/reports.schema.js +177 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/ticket.schema.js +983 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/ticketNote.schema.js +289 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/timeEntry.schema.js +407 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/static-fields.js +1813 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/transformer.js +126 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/types/index.js +33 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/types/reference.types.js +23 -0
- package/dist-community/nodes/ConnectWise/PSA/schema/types/resource.types.js +23 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/cache.js +81 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/client.js +200 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/index.js +105 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/operations.js +167 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/response-transformer.js +123 -0
- package/dist-community/nodes/ConnectWise/PSA/transport/version-check.js +128 -0
- package/dist-community/nodes/ConnectWise/PSA/types/n8n-augmentation.d.js +1 -0
- package/dist-community/nodes/ConnectWisePsa.node.json +25 -0
- package/docs/assets/screenshots/create-ticket.png +0 -0
- package/docs/assets/screenshots/field-list.png +0 -0
- package/docs/assets/screenshots/field-sort.png +0 -0
- package/index.js +0 -0
- package/package.json +73 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: !0
|
|
24
|
+
}), mod);
|
|
25
|
+
|
|
26
|
+
var common_properties_exports = {};
|
|
27
|
+
|
|
28
|
+
__export(common_properties_exports, {
|
|
29
|
+
additionalFieldsProperty: () => additionalFieldsProperty,
|
|
30
|
+
assignmentsProperty: () => assignmentsProperty,
|
|
31
|
+
getCommonFields: () => getCommonFields,
|
|
32
|
+
getCustomFieldsProperty: () => getCustomFieldsProperty,
|
|
33
|
+
queryOptions: () => queryOptions
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
module.exports = __toCommonJS(common_properties_exports);
|
|
37
|
+
|
|
38
|
+
var import_common = require("./common.descriptions");
|
|
39
|
+
|
|
40
|
+
const additionalFieldsProperty = {
|
|
41
|
+
displayName: "Additional Fields",
|
|
42
|
+
name: "additionalFields",
|
|
43
|
+
type: "fixedCollection",
|
|
44
|
+
default: {},
|
|
45
|
+
placeholder: "Add Field",
|
|
46
|
+
typeOptions: {
|
|
47
|
+
multipleValues: !0
|
|
48
|
+
},
|
|
49
|
+
options: [ {
|
|
50
|
+
name: "stringField",
|
|
51
|
+
displayName: "String Field",
|
|
52
|
+
values: [ {
|
|
53
|
+
displayName: "Field Name",
|
|
54
|
+
name: "name",
|
|
55
|
+
type: "string",
|
|
56
|
+
default: "",
|
|
57
|
+
placeholder: "e.g. fieldOne",
|
|
58
|
+
description: "Name of the field as it appears in the API"
|
|
59
|
+
}, {
|
|
60
|
+
displayName: "Value",
|
|
61
|
+
name: "value",
|
|
62
|
+
type: "string",
|
|
63
|
+
default: ""
|
|
64
|
+
} ]
|
|
65
|
+
}, {
|
|
66
|
+
name: "numberField",
|
|
67
|
+
displayName: "Number Field",
|
|
68
|
+
values: [ {
|
|
69
|
+
displayName: "Field Name",
|
|
70
|
+
name: "name",
|
|
71
|
+
type: "string",
|
|
72
|
+
default: "",
|
|
73
|
+
placeholder: "field/name"
|
|
74
|
+
}, {
|
|
75
|
+
displayName: "Value",
|
|
76
|
+
name: "value",
|
|
77
|
+
type: "number",
|
|
78
|
+
default: 0,
|
|
79
|
+
hint: "Name of the field as it appears in the API"
|
|
80
|
+
} ]
|
|
81
|
+
}, {
|
|
82
|
+
name: "booleanField",
|
|
83
|
+
displayName: "Boolean Field",
|
|
84
|
+
values: [ {
|
|
85
|
+
displayName: "Field Name",
|
|
86
|
+
name: "name",
|
|
87
|
+
type: "string",
|
|
88
|
+
default: "",
|
|
89
|
+
placeholder: "e.g. isActive",
|
|
90
|
+
description: "Name of the field as it appears in the API"
|
|
91
|
+
}, {
|
|
92
|
+
displayName: "Value",
|
|
93
|
+
name: "value",
|
|
94
|
+
type: "boolean",
|
|
95
|
+
default: !1
|
|
96
|
+
} ]
|
|
97
|
+
}, {
|
|
98
|
+
name: "dateTimeField",
|
|
99
|
+
displayName: "Date/Time Field",
|
|
100
|
+
values: [ {
|
|
101
|
+
displayName: "Field Name",
|
|
102
|
+
name: "name",
|
|
103
|
+
type: "string",
|
|
104
|
+
default: "",
|
|
105
|
+
description: "Timestamp will be converted to ConnectWise API format"
|
|
106
|
+
}, {
|
|
107
|
+
displayName: "Value",
|
|
108
|
+
name: "value",
|
|
109
|
+
type: "dateTime",
|
|
110
|
+
default: ""
|
|
111
|
+
} ]
|
|
112
|
+
}, {
|
|
113
|
+
displayName: "Raw JSON",
|
|
114
|
+
name: "jsonField",
|
|
115
|
+
values: [ {
|
|
116
|
+
displayName: "JSON Data",
|
|
117
|
+
name: "json",
|
|
118
|
+
type: "json",
|
|
119
|
+
default: "{}",
|
|
120
|
+
hint: "This JSON will be merged and replace any fields above"
|
|
121
|
+
} ]
|
|
122
|
+
} ]
|
|
123
|
+
}, assignmentsProperty = {
|
|
124
|
+
displayName: "Additional Assignments",
|
|
125
|
+
hint: "Add assignments to automatically set values based on n8n expressions",
|
|
126
|
+
name: "assignments",
|
|
127
|
+
type: "assignmentCollection",
|
|
128
|
+
default: {}
|
|
129
|
+
}, queryOptions = {
|
|
130
|
+
returnAll: {
|
|
131
|
+
displayName: "Return All",
|
|
132
|
+
name: "returnAll",
|
|
133
|
+
type: "boolean",
|
|
134
|
+
default: !1,
|
|
135
|
+
description: "Whether to return all results or only up to a given limit",
|
|
136
|
+
hint: "Use with caution on large datasets. Limited to 10,000 to prevent out of memory errors."
|
|
137
|
+
},
|
|
138
|
+
limit: {
|
|
139
|
+
displayName: "Limit",
|
|
140
|
+
name: "limit",
|
|
141
|
+
type: "number",
|
|
142
|
+
typeOptions: {
|
|
143
|
+
minValue: 1
|
|
144
|
+
},
|
|
145
|
+
default: 50,
|
|
146
|
+
description: "Max number of results to return",
|
|
147
|
+
displayOptions: {
|
|
148
|
+
show: {
|
|
149
|
+
returnAll: [ !1 ]
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
conditions: {
|
|
154
|
+
displayName: "Conditions",
|
|
155
|
+
name: "conditions",
|
|
156
|
+
type: "string",
|
|
157
|
+
default: "",
|
|
158
|
+
placeholder: 'e.g. name like "Acme%"',
|
|
159
|
+
description: "Filter conditions using ConnectWise query syntax",
|
|
160
|
+
hint: `Use <a href="https://${import_common.DOCURL_PREFIX}company/search${import_common.DOCURL_SUFFIX}">ConnectWise query syntax</a> for filtering results`
|
|
161
|
+
},
|
|
162
|
+
fields: {
|
|
163
|
+
displayName: "Field Names",
|
|
164
|
+
name: "fields",
|
|
165
|
+
type: "multiOptions",
|
|
166
|
+
typeOptions: {
|
|
167
|
+
loadOptionsMethod: "loadFieldsOptions"
|
|
168
|
+
},
|
|
169
|
+
default: [],
|
|
170
|
+
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
171
|
+
hint: "Limit the output to reduce n8n load. *In Schema but not seen in API †Found in API only"
|
|
172
|
+
},
|
|
173
|
+
orderBy: {
|
|
174
|
+
displayName: "Order By Field Name",
|
|
175
|
+
name: "orderBy",
|
|
176
|
+
type: "options",
|
|
177
|
+
typeOptions: {
|
|
178
|
+
loadOptionsMethod: "loadOrderByFieldsOptions"
|
|
179
|
+
},
|
|
180
|
+
default: "",
|
|
181
|
+
description: 'Choose from the list, or specify a field name using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
182
|
+
hint: "Select a field to sort the results by"
|
|
183
|
+
},
|
|
184
|
+
descending: {
|
|
185
|
+
displayName: "Descending",
|
|
186
|
+
name: "descending",
|
|
187
|
+
type: "boolean",
|
|
188
|
+
default: !1,
|
|
189
|
+
description: "Whether to sort in descending order",
|
|
190
|
+
displayOptions: {
|
|
191
|
+
show: {
|
|
192
|
+
orderBy: [ {
|
|
193
|
+
_cnd: {
|
|
194
|
+
not: ""
|
|
195
|
+
}
|
|
196
|
+
} ]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
childConditions: {
|
|
201
|
+
displayName: "Child Conditions",
|
|
202
|
+
name: "childConditions",
|
|
203
|
+
type: "string",
|
|
204
|
+
default: "",
|
|
205
|
+
description: "Filter on child entities"
|
|
206
|
+
},
|
|
207
|
+
customFieldConditions: {
|
|
208
|
+
displayName: "Custom Field Conditions",
|
|
209
|
+
name: "customFieldConditions",
|
|
210
|
+
type: "string",
|
|
211
|
+
default: "",
|
|
212
|
+
description: "Filter on custom fields"
|
|
213
|
+
},
|
|
214
|
+
cacheResponse: {
|
|
215
|
+
displayName: "Cache Response ✨",
|
|
216
|
+
name: "cacheResponse",
|
|
217
|
+
type: "boolean",
|
|
218
|
+
default: !1,
|
|
219
|
+
description: "Whether to cache this response for faster subsequent requests"
|
|
220
|
+
},
|
|
221
|
+
cacheDuration: {
|
|
222
|
+
displayName: "Cache Duration",
|
|
223
|
+
name: "cacheDuration",
|
|
224
|
+
type: "string",
|
|
225
|
+
default: "300s",
|
|
226
|
+
description: "How long to cache up to 1 hour (e.g., 300, 300s, 5m, 1h). Plain numbers are seconds. 0 to invalidate cache.",
|
|
227
|
+
displayOptions: {
|
|
228
|
+
show: {
|
|
229
|
+
cacheResponse: [ !0 ]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
function getCustomFieldsProperty(resourceKey) {
|
|
236
|
+
return {
|
|
237
|
+
displayName: "Custom Fields",
|
|
238
|
+
name: "customFields",
|
|
239
|
+
type: "fixedCollection",
|
|
240
|
+
placeholder: "Add Custom Field",
|
|
241
|
+
default: {},
|
|
242
|
+
displayOptions: {
|
|
243
|
+
show: {
|
|
244
|
+
operation: [ "create", "update" ]
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
typeOptions: {
|
|
248
|
+
multipleValues: !0
|
|
249
|
+
},
|
|
250
|
+
options: [ {
|
|
251
|
+
name: "field",
|
|
252
|
+
displayName: "Custom Field",
|
|
253
|
+
values: [ {
|
|
254
|
+
displayName: "Field",
|
|
255
|
+
name: "id",
|
|
256
|
+
type: "options",
|
|
257
|
+
required: !0,
|
|
258
|
+
typeOptions: {
|
|
259
|
+
loadOptionsMethod: "loadCustomFieldsOptions"
|
|
260
|
+
},
|
|
261
|
+
default: "",
|
|
262
|
+
description: "Choose from available custom fields"
|
|
263
|
+
}, {
|
|
264
|
+
displayName: "Value",
|
|
265
|
+
name: "value",
|
|
266
|
+
type: "string",
|
|
267
|
+
default: "",
|
|
268
|
+
description: "Value for the custom field. Leave empty to nullify. Ensure you pass a value compatible with the field type. Checkbox can be true/false/1/0/on/off."
|
|
269
|
+
} ]
|
|
270
|
+
} ]
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getCommonFields(resourceKey, options) {
|
|
275
|
+
let fields = [ {
|
|
276
|
+
...assignmentsProperty,
|
|
277
|
+
displayOptions: {
|
|
278
|
+
show: {
|
|
279
|
+
operation: [ "create", "update", "replace" ]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
...queryOptions.returnAll,
|
|
284
|
+
displayOptions: {
|
|
285
|
+
show: {
|
|
286
|
+
operation: [ "getAll", "getReport" ]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
...queryOptions.limit,
|
|
291
|
+
displayOptions: {
|
|
292
|
+
show: {
|
|
293
|
+
operation: [ "getAll", "getReport" ],
|
|
294
|
+
returnAll: [ !1 ]
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}, {
|
|
298
|
+
...queryOptions.orderBy,
|
|
299
|
+
displayOptions: {
|
|
300
|
+
show: {
|
|
301
|
+
operation: [ "getAll", "getReport" ]
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
...queryOptions.descending,
|
|
306
|
+
displayOptions: {
|
|
307
|
+
show: {
|
|
308
|
+
operation: [ "getAll", "getReport" ]
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}, {
|
|
312
|
+
...queryOptions.conditions,
|
|
313
|
+
displayOptions: {
|
|
314
|
+
show: {
|
|
315
|
+
operation: [ "getAll", "getReport" ]
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}, {
|
|
319
|
+
...queryOptions.fields,
|
|
320
|
+
displayOptions: {
|
|
321
|
+
show: {
|
|
322
|
+
operation: [ "get", "getAll", "getReport" ]
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
...queryOptions.childConditions,
|
|
327
|
+
displayOptions: {
|
|
328
|
+
show: {
|
|
329
|
+
operation: [ "getAll", "getReport" ]
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
...queryOptions.customFieldConditions,
|
|
334
|
+
displayOptions: {
|
|
335
|
+
show: {
|
|
336
|
+
operation: [ "getAll", "getReport" ]
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
} ];
|
|
340
|
+
return options?.only ? fields = fields.filter(f => options.only.includes(f.name)) : options?.exclude && (fields = fields.filter(f => !options.exclude.includes(f.name))),
|
|
341
|
+
options?.overrides && (fields = fields.map(field => options.overrides[field.name] ? {
|
|
342
|
+
...field,
|
|
343
|
+
...options.overrides[field.name]
|
|
344
|
+
} : field)), fields;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
0 && (module.exports = {
|
|
348
|
+
additionalFieldsProperty: additionalFieldsProperty,
|
|
349
|
+
assignmentsProperty: assignmentsProperty,
|
|
350
|
+
getCommonFields: getCommonFields,
|
|
351
|
+
getCustomFieldsProperty: getCustomFieldsProperty,
|
|
352
|
+
queryOptions: queryOptions
|
|
353
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
return to;
|
|
15
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"),
|
|
16
|
+
secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
|
|
22
|
+
var descriptions_exports = {};
|
|
23
|
+
|
|
24
|
+
module.exports = __toCommonJS(descriptions_exports);
|
|
25
|
+
|
|
26
|
+
__reExport(descriptions_exports, require("./common.descriptions"), module.exports);
|
|
27
|
+
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
...require("./common.descriptions")
|
|
30
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: !0
|
|
24
|
+
}), mod);
|
|
25
|
+
|
|
26
|
+
var customFields_exports = {};
|
|
27
|
+
|
|
28
|
+
__export(customFields_exports, {
|
|
29
|
+
CUSTOM_FIELD_TYPES: () => CUSTOM_FIELD_TYPES,
|
|
30
|
+
convertCustomFieldValue: () => convertCustomFieldValue,
|
|
31
|
+
convertCustomFieldsForCreate: () => convertCustomFieldsForCreate,
|
|
32
|
+
hasCustomFields: () => hasCustomFields,
|
|
33
|
+
mergeCustomFields: () => mergeCustomFields
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
module.exports = __toCommonJS(customFields_exports);
|
|
37
|
+
|
|
38
|
+
const CUSTOM_FIELD_TYPES = {
|
|
39
|
+
Text: "string",
|
|
40
|
+
TextArea: "string",
|
|
41
|
+
Hyperlink: "string",
|
|
42
|
+
Date: "dateTime",
|
|
43
|
+
Checkbox: "boolean",
|
|
44
|
+
Number: "number",
|
|
45
|
+
Percent: "number",
|
|
46
|
+
Button: "ignore"
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function convertCustomFieldValue(value, fieldType) {
|
|
50
|
+
const dataType = CUSTOM_FIELD_TYPES[fieldType] || "string";
|
|
51
|
+
if (dataType !== "ignore") switch (dataType) {
|
|
52
|
+
case "boolean":
|
|
53
|
+
if (value === "") return null;
|
|
54
|
+
if (typeof value == "boolean") return value;
|
|
55
|
+
if (typeof value == "number") return value !== 0;
|
|
56
|
+
const lowerValue = String(value).toLowerCase().trim();
|
|
57
|
+
if (lowerValue === "false" || lowerValue === "0" || lowerValue === "no" || lowerValue === "off") return !1;
|
|
58
|
+
if (lowerValue === "true" || lowerValue === "1" || lowerValue === "yes" || lowerValue === "on") return !0;
|
|
59
|
+
const numValue = Number(value);
|
|
60
|
+
return isNaN(numValue) ? !1 : numValue !== 0;
|
|
61
|
+
|
|
62
|
+
case "number":
|
|
63
|
+
if (value === "") return null;
|
|
64
|
+
if (typeof value == "number") return value;
|
|
65
|
+
if (typeof value == "boolean") return value ? 1 : 0;
|
|
66
|
+
const num = parseFloat(String(value));
|
|
67
|
+
return isNaN(num) ? value : num;
|
|
68
|
+
|
|
69
|
+
case "dateTime":
|
|
70
|
+
if (value === "") return null;
|
|
71
|
+
if (value instanceof Date) return value.toISOString();
|
|
72
|
+
if (typeof value == "number") return new Date(value).toISOString();
|
|
73
|
+
try {
|
|
74
|
+
return new Date(String(value)).toISOString();
|
|
75
|
+
} catch {
|
|
76
|
+
return String(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case "string":
|
|
80
|
+
default:
|
|
81
|
+
return value === "" ? null : String(value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function mergeCustomFields(existing, updates) {
|
|
86
|
+
const fieldMap = /* @__PURE__ */ new Map;
|
|
87
|
+
return existing.forEach(field => {
|
|
88
|
+
fieldMap.set(field.id, {
|
|
89
|
+
...field
|
|
90
|
+
});
|
|
91
|
+
}), updates.forEach(update => {
|
|
92
|
+
const existingField = fieldMap.get(update.id);
|
|
93
|
+
existingField && (update.value === "" ? existingField.value = null : existingField.value = convertCustomFieldValue(update.value, existingField.type));
|
|
94
|
+
}), Array.from(fieldMap.values());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function convertCustomFieldsForCreate(customFieldsData) {
|
|
98
|
+
let fields = [];
|
|
99
|
+
return customFieldsData && customFieldsData.field && Array.isArray(customFieldsData.field) ? fields = customFieldsData.field : Array.isArray(customFieldsData) && (fields = customFieldsData),
|
|
100
|
+
fields.map(field => ({
|
|
101
|
+
id: field.id,
|
|
102
|
+
value: field.value === "" ? "" : convertCustomFieldValue(field.value, field.type || "Text")
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function hasCustomFields(data) {
|
|
107
|
+
return data ? !!(data.field && Array.isArray(data.field) && data.field.length > 0 || Array.isArray(data) && data.length > 0) : !1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
CUSTOM_FIELD_TYPES: CUSTOM_FIELD_TYPES,
|
|
112
|
+
convertCustomFieldValue: convertCustomFieldValue,
|
|
113
|
+
convertCustomFieldsForCreate: convertCustomFieldsForCreate,
|
|
114
|
+
hasCustomFields: hasCustomFields,
|
|
115
|
+
mergeCustomFields: mergeCustomFields
|
|
116
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: !0
|
|
24
|
+
}), mod);
|
|
25
|
+
|
|
26
|
+
var field_collector_exports = {};
|
|
27
|
+
|
|
28
|
+
__export(field_collector_exports, {
|
|
29
|
+
collectFieldData: () => collectFieldData
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
module.exports = __toCommonJS(field_collector_exports);
|
|
33
|
+
|
|
34
|
+
function collectFieldData(context, schema, operation, index) {
|
|
35
|
+
const schemaFields = {}, additionalFields = {}, assignments = {}, relevantProperties = [], isPropertyShown = property => {
|
|
36
|
+
if (!property.displayOptions?.show?.operation) return !0;
|
|
37
|
+
const operations = property.displayOptions.show.operation;
|
|
38
|
+
return Array.isArray(operations) ? operations.includes(operation) : operations === operation;
|
|
39
|
+
}, collectFromProperty = (property, target, prefix = "") => {
|
|
40
|
+
const fullName = prefix + property.name;
|
|
41
|
+
try {
|
|
42
|
+
const value = context.getNodeParameter(fullName, index, void 0);
|
|
43
|
+
if (value != null && value !== "") if (property.type === "collection" && typeof value == "object") for (const [collectionField, collectionValue] of Object.entries(value)) collectionValue != null && collectionValue !== "" && (target[`${fullName}.${collectionField}`] = collectionValue); else target[fullName] = value;
|
|
44
|
+
} catch {}
|
|
45
|
+
}, UI_CONTROL_FIELDS = [ "operation", "assignments", "endpoint", "ticketType", "parentId", "id" ];
|
|
46
|
+
for (const field of schema.fields) if (!UI_CONTROL_FIELDS.includes(field.name) && field.x_noSubmit !== !0 && isPropertyShown(field)) if (relevantProperties.push(field),
|
|
47
|
+
field.type === "resourceLocator") try {
|
|
48
|
+
const value = context.getNodeParameter(field.name, index);
|
|
49
|
+
if (value != null && typeof value == "object") {
|
|
50
|
+
const valueObj = value;
|
|
51
|
+
valueObj.mode === "id" || valueObj.mode === "identifier" ? schemaFields[field.name] = valueObj.value : valueObj.mode === "list" && valueObj.value && (schemaFields[field.name] = valueObj.value.value || valueObj.value);
|
|
52
|
+
}
|
|
53
|
+
} catch {} else collectFromProperty(field, schemaFields);
|
|
54
|
+
try {
|
|
55
|
+
const additionalFieldsParam = context.getNodeParameter("additionalFields", index, {});
|
|
56
|
+
for (const [fieldType, fields] of Object.entries(additionalFieldsParam)) if (Array.isArray(fields)) if (fieldType === "jsonField") {
|
|
57
|
+
for (const field of fields) if (field.json) {
|
|
58
|
+
const jsonData = typeof field.json == "string" ? JSON.parse(field.json) : field.json;
|
|
59
|
+
Object.assign(additionalFields, jsonData);
|
|
60
|
+
}
|
|
61
|
+
} else for (const field of fields) field.name && field.value !== void 0 && (additionalFields[field.name] = field.value);
|
|
62
|
+
} catch {}
|
|
63
|
+
try {
|
|
64
|
+
const assignmentsParam = context.getNodeParameter("assignments", index, {}), assignmentsArray = assignmentsParam.assignments || assignmentsParam;
|
|
65
|
+
if (Array.isArray(assignmentsArray)) {
|
|
66
|
+
for (const assignment of assignmentsArray) if (assignment.name && assignment.value !== void 0) if (assignment.type === "array" || assignment.type === "object") try {
|
|
67
|
+
assignments[assignment.name] = JSON.parse(assignment.value);
|
|
68
|
+
} catch {
|
|
69
|
+
assignments[assignment.name] = assignment.value;
|
|
70
|
+
} else assignments[assignment.name] = assignment.value;
|
|
71
|
+
} else typeof assignmentsArray == "object" && assignmentsArray !== null && !assignmentsArray.assignments && Object.assign(assignments, assignmentsArray);
|
|
72
|
+
} catch {}
|
|
73
|
+
return {
|
|
74
|
+
schemaFields: schemaFields,
|
|
75
|
+
additionalFields: additionalFields,
|
|
76
|
+
assignments: assignments,
|
|
77
|
+
relevantProperties: relevantProperties
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
collectFieldData: collectFieldData
|
|
83
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: !0
|
|
24
|
+
}), mod);
|
|
25
|
+
|
|
26
|
+
var field_conditions_exports = {};
|
|
27
|
+
|
|
28
|
+
__export(field_conditions_exports, {
|
|
29
|
+
collectFieldConditions: () => collectFieldConditions,
|
|
30
|
+
extractFieldCondition: () => extractFieldCondition
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
module.exports = __toCommonJS(field_conditions_exports);
|
|
34
|
+
|
|
35
|
+
function extractFieldCondition(field, value) {
|
|
36
|
+
if (!field.x_condition || value == null || value === "") return null;
|
|
37
|
+
if (field.type === "boolean") return value ? field.x_condition : null;
|
|
38
|
+
if (field.type === "multiOptions") {
|
|
39
|
+
const values = Array.isArray(value) ? value : [ value ];
|
|
40
|
+
if (values.length === 0) return null;
|
|
41
|
+
if (field.x_condition.includes("${values}")) {
|
|
42
|
+
const formattedValues = values.map(v => typeof v == "number" || typeof v == "string" && !isNaN(Number(v)) && v.trim() !== "" ? v : `"${v}"`).join(",");
|
|
43
|
+
return field.x_condition.replace("${values}", formattedValues);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return field.x_condition.includes("${value}") ? field.x_condition.replace("${value}", String(value)) : value ? field.x_condition : null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function processFieldForConditions(context, field, index, conditions, parentPath = "") {
|
|
51
|
+
const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
52
|
+
if (field.type === "collection" && field.options) try {
|
|
53
|
+
const collectionData = context.getNodeParameter(field.name, index, {});
|
|
54
|
+
for (const option of field.options) {
|
|
55
|
+
if (!("type" in option)) continue;
|
|
56
|
+
const propertyOption = option;
|
|
57
|
+
if (propertyOption.x_condition) {
|
|
58
|
+
const optionValue = collectionData[propertyOption.name], condition = extractFieldCondition(propertyOption, optionValue);
|
|
59
|
+
condition && conditions.push(condition);
|
|
60
|
+
}
|
|
61
|
+
propertyOption.type === "collection" && propertyOption.options && processFieldForConditions(context, propertyOption, index, conditions, field.name);
|
|
62
|
+
}
|
|
63
|
+
} catch {}
|
|
64
|
+
if (field.x_condition) try {
|
|
65
|
+
const value = context.getNodeParameter(fieldPath, index, void 0), condition = extractFieldCondition(field, value);
|
|
66
|
+
condition && conditions.push(condition);
|
|
67
|
+
} catch {}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function collectFieldConditions(context, schema, operation, index) {
|
|
71
|
+
const conditions = [];
|
|
72
|
+
if (!schema.fields) return conditions;
|
|
73
|
+
for (const field of schema.fields) isFieldShownForOperation(field, operation) && processFieldForConditions(context, field, index, conditions);
|
|
74
|
+
return conditions;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isFieldShownForOperation(field, operation) {
|
|
78
|
+
if (!field.displayOptions?.show) return !1;
|
|
79
|
+
const show = field.displayOptions.show;
|
|
80
|
+
return show.operation ? (Array.isArray(show.operation) ? show.operation : [ show.operation ]).includes(operation) : !1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
collectFieldConditions: collectFieldConditions,
|
|
85
|
+
extractFieldCondition: extractFieldCondition
|
|
86
|
+
});
|