n8n-nodes-commercetools 0.1.7 → 0.1.8
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/dist/icons/Commercetools.svg +44 -44
- package/dist/nodes/Commercetools/Commercetools.node.js +9 -0
- package/dist/nodes/Commercetools/Commercetools.node.js.map +1 -1
- package/dist/nodes/Commercetools/Commercetools.svg +43 -43
- package/dist/nodes/Commercetools/descriptions/Commercetools.description.js +1618 -1
- package/dist/nodes/Commercetools/descriptions/Commercetools.description.js.map +1 -1
- package/dist/nodes/Commercetools/operations/customer.operations.d.ts +9 -0
- package/dist/nodes/Commercetools/operations/customer.operations.js +933 -0
- package/dist/nodes/Commercetools/operations/customer.operations.js.map +1 -0
- package/dist/nodes/Commercetools/utils/customer.utils.d.ts +10 -0
- package/dist/nodes/Commercetools/utils/customer.utils.js +646 -0
- package/dist/nodes/Commercetools/utils/customer.utils.js.map +1 -0
- package/dist/nodes/Commercetools/utils/product.utils.js +6 -0
- package/dist/nodes/Commercetools/utils/product.utils.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/icons/Commercetools.svg +44 -44
- package/package.json +1 -1
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildActionsFromUi = exports.coerceJsonInput = exports.applyCommonCustomerParameters = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const applyCommonCustomerParameters = (qs, additionalFields = {}, options = {}) => {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
const setArrayField = (fieldName, queryName) => {
|
|
8
|
+
const value = additionalFields[fieldName];
|
|
9
|
+
if (Array.isArray(value) && value.length) {
|
|
10
|
+
qs[queryName] = value;
|
|
11
|
+
}
|
|
12
|
+
else if (typeof value === 'string' && value.trim()) {
|
|
13
|
+
const arrayValue = value.split(',').map(item => item.trim()).filter(item => item);
|
|
14
|
+
if (arrayValue.length) {
|
|
15
|
+
qs[queryName] = arrayValue;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
setArrayField('expand', 'expand');
|
|
20
|
+
if (options.allowSort) {
|
|
21
|
+
setArrayField('sort', 'sort');
|
|
22
|
+
}
|
|
23
|
+
if (options.allowWhere) {
|
|
24
|
+
setArrayField('where', 'where');
|
|
25
|
+
}
|
|
26
|
+
if (options.allowPredicateVariables) {
|
|
27
|
+
const predicateVariables = ((_b = (_a = additionalFields.predicateVariables) === null || _a === void 0 ? void 0 : _a.variable) !== null && _b !== void 0 ? _b : []);
|
|
28
|
+
for (const predicateVariable of predicateVariables) {
|
|
29
|
+
const name = predicateVariable.name;
|
|
30
|
+
if (!name)
|
|
31
|
+
continue;
|
|
32
|
+
qs[`var.${name}`] = predicateVariable.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const customParameters = ((_d = (_c = additionalFields.customParameters) === null || _c === void 0 ? void 0 : _c.parameter) !== null && _d !== void 0 ? _d : []);
|
|
36
|
+
for (const customParameter of customParameters) {
|
|
37
|
+
const key = customParameter.key;
|
|
38
|
+
if (!key)
|
|
39
|
+
continue;
|
|
40
|
+
qs[key] = customParameter.value;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.applyCommonCustomerParameters = applyCommonCustomerParameters;
|
|
44
|
+
const coerceJsonInput = (context, raw, label, itemIndex) => {
|
|
45
|
+
let value = raw;
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
try {
|
|
48
|
+
value = JSON.parse(value);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `${label} must be valid JSON when provided as a string`, { itemIndex });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (typeof value !== 'object' || value === null) {
|
|
55
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `${label} must be a JSON object or array`, {
|
|
56
|
+
itemIndex,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
};
|
|
61
|
+
exports.coerceJsonInput = coerceJsonInput;
|
|
62
|
+
const buildActionsFromUi = (context, actionsUi, itemIndex) => {
|
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
64
|
+
const builtActions = [];
|
|
65
|
+
const rawActionEntries = actionsUi.action;
|
|
66
|
+
const actionEntries = Array.isArray(rawActionEntries)
|
|
67
|
+
? rawActionEntries
|
|
68
|
+
: rawActionEntries
|
|
69
|
+
? [rawActionEntries]
|
|
70
|
+
: [];
|
|
71
|
+
const buildAddressFromFields = (entry) => {
|
|
72
|
+
const address = {};
|
|
73
|
+
if (entry.key && typeof entry.key === 'string')
|
|
74
|
+
address.key = entry.key.trim();
|
|
75
|
+
if (entry.title && typeof entry.title === 'string')
|
|
76
|
+
address.title = entry.title.trim();
|
|
77
|
+
if (entry.firstName && typeof entry.firstName === 'string')
|
|
78
|
+
address.firstName = entry.firstName.trim();
|
|
79
|
+
if (entry.lastName && typeof entry.lastName === 'string')
|
|
80
|
+
address.lastName = entry.lastName.trim();
|
|
81
|
+
if (entry.streetName && typeof entry.streetName === 'string')
|
|
82
|
+
address.streetName = entry.streetName.trim();
|
|
83
|
+
if (entry.streetNumber && typeof entry.streetNumber === 'string')
|
|
84
|
+
address.streetNumber = entry.streetNumber.trim();
|
|
85
|
+
if (entry.city && typeof entry.city === 'string')
|
|
86
|
+
address.city = entry.city.trim();
|
|
87
|
+
if (entry.postalCode && typeof entry.postalCode === 'string')
|
|
88
|
+
address.postalCode = entry.postalCode.trim();
|
|
89
|
+
if (entry.state && typeof entry.state === 'string')
|
|
90
|
+
address.state = entry.state.trim();
|
|
91
|
+
if (entry.building && typeof entry.building === 'string')
|
|
92
|
+
address.building = entry.building.trim();
|
|
93
|
+
if (entry.apartment && typeof entry.apartment === 'string')
|
|
94
|
+
address.apartment = entry.apartment.trim();
|
|
95
|
+
if (entry.department && typeof entry.department === 'string')
|
|
96
|
+
address.department = entry.department.trim();
|
|
97
|
+
if (entry.phone && typeof entry.phone === 'string')
|
|
98
|
+
address.phone = entry.phone.trim();
|
|
99
|
+
if (entry.mobile && typeof entry.mobile === 'string')
|
|
100
|
+
address.mobile = entry.mobile.trim();
|
|
101
|
+
if (entry.addressEmail && typeof entry.addressEmail === 'string')
|
|
102
|
+
address.email = entry.addressEmail.trim();
|
|
103
|
+
if (entry.fax && typeof entry.fax === 'string')
|
|
104
|
+
address.fax = entry.fax.trim();
|
|
105
|
+
if (entry.pOBox && typeof entry.pOBox === 'string')
|
|
106
|
+
address.pOBox = entry.pOBox.trim();
|
|
107
|
+
if (entry.additionalAddressInfo && typeof entry.additionalAddressInfo === 'string') {
|
|
108
|
+
address.additionalAddressInfo = entry.additionalAddressInfo.trim();
|
|
109
|
+
}
|
|
110
|
+
if (entry.additionalStreetInfo && typeof entry.additionalStreetInfo === 'string') {
|
|
111
|
+
address.additionalStreetInfo = entry.additionalStreetInfo.trim();
|
|
112
|
+
}
|
|
113
|
+
if (entry.country && typeof entry.country === 'string') {
|
|
114
|
+
address.country = entry.country.trim();
|
|
115
|
+
}
|
|
116
|
+
return address;
|
|
117
|
+
};
|
|
118
|
+
const getIdOrKeyReference = (entry, idField, keyField, referenceType) => {
|
|
119
|
+
const id = typeof entry[idField] === 'string' ? entry[idField].trim() : '';
|
|
120
|
+
const key = typeof entry[keyField] === 'string' ? entry[keyField].trim() : '';
|
|
121
|
+
if (id) {
|
|
122
|
+
return { typeId: referenceType, id };
|
|
123
|
+
}
|
|
124
|
+
else if (key) {
|
|
125
|
+
return { typeId: referenceType, key };
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Either ${idField} or ${keyField} is required for ${referenceType} reference`, { itemIndex });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const getMultipleIdOrKeyReferences = (entry, idsField, keysField, referenceType) => {
|
|
132
|
+
const idsRaw = entry[idsField];
|
|
133
|
+
const keysRaw = entry[keysField];
|
|
134
|
+
if (Array.isArray(idsRaw) && idsRaw.length > 0) {
|
|
135
|
+
return idsRaw
|
|
136
|
+
.map(id => String(id).trim())
|
|
137
|
+
.filter(id => id.length > 0)
|
|
138
|
+
.map(id => ({ typeId: referenceType, id }));
|
|
139
|
+
}
|
|
140
|
+
else if (Array.isArray(keysRaw) && keysRaw.length > 0) {
|
|
141
|
+
return keysRaw
|
|
142
|
+
.map(key => String(key).trim())
|
|
143
|
+
.filter(key => key.length > 0)
|
|
144
|
+
.map(key => ({ typeId: referenceType, key }));
|
|
145
|
+
}
|
|
146
|
+
const ids = typeof idsRaw === 'string' ? idsRaw.trim() : '';
|
|
147
|
+
const keys = typeof keysRaw === 'string' ? keysRaw.trim() : '';
|
|
148
|
+
if (ids) {
|
|
149
|
+
return ids
|
|
150
|
+
.split(',')
|
|
151
|
+
.map(id => id.trim())
|
|
152
|
+
.filter(id => id.length > 0)
|
|
153
|
+
.map(id => ({ typeId: referenceType, id }));
|
|
154
|
+
}
|
|
155
|
+
else if (keys) {
|
|
156
|
+
return keys
|
|
157
|
+
.split(',')
|
|
158
|
+
.map(key => key.trim())
|
|
159
|
+
.filter(key => key.length > 0)
|
|
160
|
+
.map(key => ({ typeId: referenceType, key }));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Either ${idsField} or ${keysField} is required for ${referenceType} references`, { itemIndex });
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const parseCustomFieldValue = (valueRaw) => {
|
|
167
|
+
if (valueRaw === undefined || valueRaw === '') {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
return typeof valueRaw === 'string' ? JSON.parse(valueRaw) : valueRaw;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return valueRaw;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const buildCustomFieldsFromCollection = (entry) => {
|
|
178
|
+
var _a;
|
|
179
|
+
const customFields = {};
|
|
180
|
+
const customFieldsData = entry.customFields;
|
|
181
|
+
if (customFieldsData && customFieldsData.field) {
|
|
182
|
+
const fields = Array.isArray(customFieldsData.field) ? customFieldsData.field : [customFieldsData.field];
|
|
183
|
+
for (const field of fields) {
|
|
184
|
+
const name = (_a = field.name) === null || _a === void 0 ? void 0 : _a.trim();
|
|
185
|
+
const value = field.value;
|
|
186
|
+
if (name) {
|
|
187
|
+
customFields[name] = parseCustomFieldValue(value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return customFields;
|
|
192
|
+
};
|
|
193
|
+
for (const actionEntry of actionEntries) {
|
|
194
|
+
const actionType = actionEntry.actionType;
|
|
195
|
+
if (!actionType) {
|
|
196
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Action Type is required for each action', { itemIndex });
|
|
197
|
+
}
|
|
198
|
+
switch (actionType) {
|
|
199
|
+
case 'addAddress': {
|
|
200
|
+
const address = buildAddressFromFields(actionEntry);
|
|
201
|
+
builtActions.push({
|
|
202
|
+
action: 'addAddress',
|
|
203
|
+
address,
|
|
204
|
+
});
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'addBillingAddressId': {
|
|
208
|
+
const addressId = (_a = actionEntry.addressId) === null || _a === void 0 ? void 0 : _a.trim();
|
|
209
|
+
const addressKey = (_b = actionEntry.addressKey) === null || _b === void 0 ? void 0 : _b.trim();
|
|
210
|
+
if (!addressId && !addressKey) {
|
|
211
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Add Billing Address ID action', { itemIndex });
|
|
212
|
+
}
|
|
213
|
+
builtActions.push({
|
|
214
|
+
action: 'addBillingAddressId',
|
|
215
|
+
addressId: addressId || undefined,
|
|
216
|
+
addressKey: addressKey || undefined,
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
case 'addCustomerGroupAssignment': {
|
|
221
|
+
const customerGroup = getIdOrKeyReference(actionEntry, 'customerGroupId', 'customerGroupKey', 'customer-group');
|
|
222
|
+
builtActions.push({
|
|
223
|
+
action: 'addCustomerGroupAssignment',
|
|
224
|
+
customerGroup,
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'addShippingAddressId': {
|
|
229
|
+
const addressId = (_c = actionEntry.addressId) === null || _c === void 0 ? void 0 : _c.trim();
|
|
230
|
+
const addressKey = (_d = actionEntry.addressKey) === null || _d === void 0 ? void 0 : _d.trim();
|
|
231
|
+
if (!addressId && !addressKey) {
|
|
232
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Add Shipping Address ID action', { itemIndex });
|
|
233
|
+
}
|
|
234
|
+
builtActions.push({
|
|
235
|
+
action: 'addShippingAddressId',
|
|
236
|
+
addressId: addressId || undefined,
|
|
237
|
+
addressKey: addressKey || undefined,
|
|
238
|
+
});
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
case 'addStore': {
|
|
242
|
+
const store = getIdOrKeyReference(actionEntry, 'storeId', 'storeKey', 'store');
|
|
243
|
+
builtActions.push({
|
|
244
|
+
action: 'addStore',
|
|
245
|
+
store,
|
|
246
|
+
});
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case 'changeAddress': {
|
|
250
|
+
const addressId = (_e = actionEntry.addressId) === null || _e === void 0 ? void 0 : _e.trim();
|
|
251
|
+
const addressKey = (_f = actionEntry.addressKey) === null || _f === void 0 ? void 0 : _f.trim();
|
|
252
|
+
if (!addressId && !addressKey) {
|
|
253
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Change Address action', { itemIndex });
|
|
254
|
+
}
|
|
255
|
+
const address = buildAddressFromFields(actionEntry);
|
|
256
|
+
builtActions.push({
|
|
257
|
+
action: 'changeAddress',
|
|
258
|
+
addressId: addressId || undefined,
|
|
259
|
+
addressKey: addressKey || undefined,
|
|
260
|
+
address,
|
|
261
|
+
});
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case 'changeEmail': {
|
|
265
|
+
const email = (_g = actionEntry.email) === null || _g === void 0 ? void 0 : _g.trim();
|
|
266
|
+
if (!email) {
|
|
267
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Email is required for Change Email action', { itemIndex });
|
|
268
|
+
}
|
|
269
|
+
builtActions.push({
|
|
270
|
+
action: 'changeEmail',
|
|
271
|
+
email,
|
|
272
|
+
});
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
case 'removeAddress': {
|
|
276
|
+
const addressId = (_h = actionEntry.addressId) === null || _h === void 0 ? void 0 : _h.trim();
|
|
277
|
+
const addressKey = (_j = actionEntry.addressKey) === null || _j === void 0 ? void 0 : _j.trim();
|
|
278
|
+
if (!addressId && !addressKey) {
|
|
279
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Remove Address action', { itemIndex });
|
|
280
|
+
}
|
|
281
|
+
builtActions.push({
|
|
282
|
+
action: 'removeAddress',
|
|
283
|
+
addressId: addressId || undefined,
|
|
284
|
+
addressKey: addressKey || undefined,
|
|
285
|
+
});
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case 'removeBillingAddressId': {
|
|
289
|
+
const addressId = (_k = actionEntry.addressId) === null || _k === void 0 ? void 0 : _k.trim();
|
|
290
|
+
const addressKey = (_l = actionEntry.addressKey) === null || _l === void 0 ? void 0 : _l.trim();
|
|
291
|
+
if (!addressId && !addressKey) {
|
|
292
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Remove Billing Address ID action', { itemIndex });
|
|
293
|
+
}
|
|
294
|
+
builtActions.push({
|
|
295
|
+
action: 'removeBillingAddressId',
|
|
296
|
+
addressId: addressId || undefined,
|
|
297
|
+
addressKey: addressKey || undefined,
|
|
298
|
+
});
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case 'removeCustomerGroupAssignment': {
|
|
302
|
+
const customerGroup = getIdOrKeyReference(actionEntry, 'customerGroupId', 'customerGroupKey', 'customer-group');
|
|
303
|
+
builtActions.push({
|
|
304
|
+
action: 'removeCustomerGroupAssignment',
|
|
305
|
+
customerGroup,
|
|
306
|
+
});
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case 'removeShippingAddressId': {
|
|
310
|
+
const addressId = (_m = actionEntry.addressId) === null || _m === void 0 ? void 0 : _m.trim();
|
|
311
|
+
const addressKey = (_o = actionEntry.addressKey) === null || _o === void 0 ? void 0 : _o.trim();
|
|
312
|
+
if (!addressId && !addressKey) {
|
|
313
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Remove Shipping Address ID action', { itemIndex });
|
|
314
|
+
}
|
|
315
|
+
builtActions.push({
|
|
316
|
+
action: 'removeShippingAddressId',
|
|
317
|
+
addressId: addressId || undefined,
|
|
318
|
+
addressKey: addressKey || undefined,
|
|
319
|
+
});
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case 'removeStore': {
|
|
323
|
+
const store = getIdOrKeyReference(actionEntry, 'storeId', 'storeKey', 'store');
|
|
324
|
+
builtActions.push({
|
|
325
|
+
action: 'removeStore',
|
|
326
|
+
store,
|
|
327
|
+
});
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
case 'setAuthenticationMode': {
|
|
331
|
+
const authMode = (_p = actionEntry.authMode) === null || _p === void 0 ? void 0 : _p.trim();
|
|
332
|
+
const password = (_q = actionEntry.password) === null || _q === void 0 ? void 0 : _q.trim();
|
|
333
|
+
if (!authMode) {
|
|
334
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Authentication Mode is required for Set Authentication Mode action', { itemIndex });
|
|
335
|
+
}
|
|
336
|
+
const action = {
|
|
337
|
+
action: 'setAuthenticationMode',
|
|
338
|
+
authMode,
|
|
339
|
+
};
|
|
340
|
+
if (authMode === 'Password' && password) {
|
|
341
|
+
action.password = password;
|
|
342
|
+
}
|
|
343
|
+
builtActions.push(action);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
case 'setCompanyName': {
|
|
347
|
+
const companyName = (_r = actionEntry.companyName) === null || _r === void 0 ? void 0 : _r.trim();
|
|
348
|
+
builtActions.push({
|
|
349
|
+
action: 'setCompanyName',
|
|
350
|
+
companyName: companyName || undefined,
|
|
351
|
+
});
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
case 'setCustomType': {
|
|
355
|
+
const type = getIdOrKeyReference(actionEntry, 'typeId', 'typeKey', 'type');
|
|
356
|
+
const fields = buildCustomFieldsFromCollection(actionEntry);
|
|
357
|
+
builtActions.push({
|
|
358
|
+
action: 'setCustomType',
|
|
359
|
+
type,
|
|
360
|
+
fields,
|
|
361
|
+
});
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case 'setCustomTypeInAddress': {
|
|
365
|
+
const addressId = (_s = actionEntry.addressId) === null || _s === void 0 ? void 0 : _s.trim();
|
|
366
|
+
const addressKey = (_t = actionEntry.addressKey) === null || _t === void 0 ? void 0 : _t.trim();
|
|
367
|
+
if (!addressId && !addressKey) {
|
|
368
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Set Custom Type in Address action', { itemIndex });
|
|
369
|
+
}
|
|
370
|
+
const type = getIdOrKeyReference(actionEntry, 'typeId', 'typeKey', 'type');
|
|
371
|
+
const fields = buildCustomFieldsFromCollection(actionEntry);
|
|
372
|
+
builtActions.push({
|
|
373
|
+
action: 'setCustomTypeInAddress',
|
|
374
|
+
addressId: addressId || undefined,
|
|
375
|
+
addressKey: addressKey || undefined,
|
|
376
|
+
type,
|
|
377
|
+
fields,
|
|
378
|
+
});
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
case 'setCustomerNumber': {
|
|
382
|
+
const customerNumber = (_u = actionEntry.customerNumber) === null || _u === void 0 ? void 0 : _u.trim();
|
|
383
|
+
builtActions.push({
|
|
384
|
+
action: 'setCustomerNumber',
|
|
385
|
+
customerNumber: customerNumber || undefined,
|
|
386
|
+
});
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
case 'setCustomerGroup': {
|
|
390
|
+
const customerGroup = getIdOrKeyReference(actionEntry, 'customerGroupId', 'customerGroupKey', 'customer-group');
|
|
391
|
+
builtActions.push({
|
|
392
|
+
action: 'setCustomerGroup',
|
|
393
|
+
customerGroup,
|
|
394
|
+
});
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case 'setCustomerGroupAssignments': {
|
|
398
|
+
const customerGroupAssignments = getMultipleIdOrKeyReferences(actionEntry, 'customerGroupIds', 'customerGroupKeys', 'customer-group');
|
|
399
|
+
builtActions.push({
|
|
400
|
+
action: 'setCustomerGroupAssignments',
|
|
401
|
+
customerGroupAssignments,
|
|
402
|
+
});
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case 'setCustomField': {
|
|
406
|
+
const name = (_v = actionEntry.name) === null || _v === void 0 ? void 0 : _v.trim();
|
|
407
|
+
const valueRaw = actionEntry.value;
|
|
408
|
+
if (!name) {
|
|
409
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Field Name is required for Set Custom Field action', { itemIndex });
|
|
410
|
+
}
|
|
411
|
+
const value = parseCustomFieldValue(valueRaw);
|
|
412
|
+
builtActions.push({
|
|
413
|
+
action: 'setCustomField',
|
|
414
|
+
name,
|
|
415
|
+
value,
|
|
416
|
+
});
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
case 'setCustomFieldInAddress': {
|
|
420
|
+
const addressId = (_w = actionEntry.addressId) === null || _w === void 0 ? void 0 : _w.trim();
|
|
421
|
+
const addressKey = (_x = actionEntry.addressKey) === null || _x === void 0 ? void 0 : _x.trim();
|
|
422
|
+
const name = (_y = actionEntry.name) === null || _y === void 0 ? void 0 : _y.trim();
|
|
423
|
+
const valueRaw = actionEntry.value;
|
|
424
|
+
if (!addressId && !addressKey) {
|
|
425
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Set Custom Field in Address action', { itemIndex });
|
|
426
|
+
}
|
|
427
|
+
if (!name) {
|
|
428
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Field Name is required for Set Custom Field in Address action', { itemIndex });
|
|
429
|
+
}
|
|
430
|
+
const value = parseCustomFieldValue(valueRaw);
|
|
431
|
+
builtActions.push({
|
|
432
|
+
action: 'setCustomFieldInAddress',
|
|
433
|
+
addressId: addressId || undefined,
|
|
434
|
+
addressKey: addressKey || undefined,
|
|
435
|
+
name,
|
|
436
|
+
value,
|
|
437
|
+
});
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
case 'setDateOfBirth': {
|
|
441
|
+
const dateOfBirth = (_z = actionEntry.dateOfBirth) === null || _z === void 0 ? void 0 : _z.trim();
|
|
442
|
+
builtActions.push({
|
|
443
|
+
action: 'setDateOfBirth',
|
|
444
|
+
dateOfBirth: dateOfBirth || undefined,
|
|
445
|
+
});
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
case 'setDefaultBillingAddress': {
|
|
449
|
+
const addressId = (_0 = actionEntry.addressId) === null || _0 === void 0 ? void 0 : _0.trim();
|
|
450
|
+
const addressKey = (_1 = actionEntry.addressKey) === null || _1 === void 0 ? void 0 : _1.trim();
|
|
451
|
+
if (!addressId && !addressKey) {
|
|
452
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Set Default Billing Address action', { itemIndex });
|
|
453
|
+
}
|
|
454
|
+
builtActions.push({
|
|
455
|
+
action: 'setDefaultBillingAddress',
|
|
456
|
+
addressId: addressId || undefined,
|
|
457
|
+
addressKey: addressKey || undefined,
|
|
458
|
+
});
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
case 'setDefaultShippingAddress': {
|
|
462
|
+
const addressId = (_2 = actionEntry.addressId) === null || _2 === void 0 ? void 0 : _2.trim();
|
|
463
|
+
const addressKey = (_3 = actionEntry.addressKey) === null || _3 === void 0 ? void 0 : _3.trim();
|
|
464
|
+
if (!addressId && !addressKey) {
|
|
465
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Either Address ID or Address Key is required for Set Default Shipping Address action', { itemIndex });
|
|
466
|
+
}
|
|
467
|
+
builtActions.push({
|
|
468
|
+
action: 'setDefaultShippingAddress',
|
|
469
|
+
addressId: addressId || undefined,
|
|
470
|
+
addressKey: addressKey || undefined,
|
|
471
|
+
});
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
case 'setExternalId': {
|
|
475
|
+
const externalId = (_4 = actionEntry.externalId) === null || _4 === void 0 ? void 0 : _4.trim();
|
|
476
|
+
builtActions.push({
|
|
477
|
+
action: 'setExternalId',
|
|
478
|
+
externalId: externalId || undefined,
|
|
479
|
+
});
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
case 'setFirstName': {
|
|
483
|
+
const firstName = (_5 = actionEntry.firstName) === null || _5 === void 0 ? void 0 : _5.trim();
|
|
484
|
+
builtActions.push({
|
|
485
|
+
action: 'setFirstName',
|
|
486
|
+
firstName: firstName || undefined,
|
|
487
|
+
});
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
case 'setKey': {
|
|
491
|
+
const key = (_6 = actionEntry.key) === null || _6 === void 0 ? void 0 : _6.trim();
|
|
492
|
+
builtActions.push({
|
|
493
|
+
action: 'setKey',
|
|
494
|
+
key: key || undefined,
|
|
495
|
+
});
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
case 'setLastName': {
|
|
499
|
+
const lastName = (_7 = actionEntry.lastName) === null || _7 === void 0 ? void 0 : _7.trim();
|
|
500
|
+
builtActions.push({
|
|
501
|
+
action: 'setLastName',
|
|
502
|
+
lastName: lastName || undefined,
|
|
503
|
+
});
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
case 'setLocale': {
|
|
507
|
+
const locale = (_8 = actionEntry.locale) === null || _8 === void 0 ? void 0 : _8.trim();
|
|
508
|
+
builtActions.push({
|
|
509
|
+
action: 'setLocale',
|
|
510
|
+
locale: locale || undefined,
|
|
511
|
+
});
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
case 'setMiddleName': {
|
|
515
|
+
const middleName = (_9 = actionEntry.middleName) === null || _9 === void 0 ? void 0 : _9.trim();
|
|
516
|
+
builtActions.push({
|
|
517
|
+
action: 'setMiddleName',
|
|
518
|
+
middleName: middleName || undefined,
|
|
519
|
+
});
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
case 'setSalutation': {
|
|
523
|
+
const salutation = (_10 = actionEntry.salutation) === null || _10 === void 0 ? void 0 : _10.trim();
|
|
524
|
+
builtActions.push({
|
|
525
|
+
action: 'setSalutation',
|
|
526
|
+
salutation: salutation || undefined,
|
|
527
|
+
});
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
case 'setStores': {
|
|
531
|
+
const stores = getMultipleIdOrKeyReferences(actionEntry, 'storeIds', 'storeKeys', 'store');
|
|
532
|
+
builtActions.push({
|
|
533
|
+
action: 'setStores',
|
|
534
|
+
stores,
|
|
535
|
+
});
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
case 'setTitle': {
|
|
539
|
+
const title = (_11 = actionEntry.title) === null || _11 === void 0 ? void 0 : _11.trim();
|
|
540
|
+
builtActions.push({
|
|
541
|
+
action: 'setTitle',
|
|
542
|
+
title: title || undefined,
|
|
543
|
+
});
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
case 'setVatId': {
|
|
547
|
+
const vatId = (_12 = actionEntry.vatId) === null || _12 === void 0 ? void 0 : _12.trim();
|
|
548
|
+
builtActions.push({
|
|
549
|
+
action: 'setVatId',
|
|
550
|
+
vatId: vatId || undefined,
|
|
551
|
+
});
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
case 'setCustomerStatus': {
|
|
555
|
+
if (actionEntry.customerStatus === undefined) {
|
|
556
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Customer status is required for setCustomerStatus action', {
|
|
557
|
+
itemIndex,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
builtActions.push({
|
|
561
|
+
action: 'setCustomerStatus',
|
|
562
|
+
isActive: Boolean(actionEntry.customerStatus),
|
|
563
|
+
});
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
case 'setEmailVerified': {
|
|
567
|
+
if (actionEntry.emailVerified === undefined) {
|
|
568
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Email verified status is required for setEmailVerified action', {
|
|
569
|
+
itemIndex,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
builtActions.push({
|
|
573
|
+
action: 'setEmailVerified',
|
|
574
|
+
isEmailVerified: Boolean(actionEntry.emailVerified),
|
|
575
|
+
});
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
case 'setGender': {
|
|
579
|
+
const gender = (_13 = actionEntry.gender) === null || _13 === void 0 ? void 0 : _13.trim();
|
|
580
|
+
if (!gender) {
|
|
581
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Gender is required for setGender action', {
|
|
582
|
+
itemIndex,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
builtActions.push({
|
|
586
|
+
action: 'setGender',
|
|
587
|
+
gender,
|
|
588
|
+
});
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
case 'setLanguage': {
|
|
592
|
+
const language = (_14 = actionEntry.language) === null || _14 === void 0 ? void 0 : _14.trim();
|
|
593
|
+
if (!language) {
|
|
594
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Language is required for setLanguage action', {
|
|
595
|
+
itemIndex,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
builtActions.push({
|
|
599
|
+
action: 'setLanguage',
|
|
600
|
+
language,
|
|
601
|
+
});
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
case 'setMobileNumber': {
|
|
605
|
+
const mobileNumber = (_15 = actionEntry.mobileNumber) === null || _15 === void 0 ? void 0 : _15.trim();
|
|
606
|
+
builtActions.push({
|
|
607
|
+
action: 'setMobileNumber',
|
|
608
|
+
mobile: mobileNumber || undefined,
|
|
609
|
+
});
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
case 'setPhoneNumber': {
|
|
613
|
+
const phoneNumber = (_16 = actionEntry.phoneNumber) === null || _16 === void 0 ? void 0 : _16.trim();
|
|
614
|
+
builtActions.push({
|
|
615
|
+
action: 'setPhoneNumber',
|
|
616
|
+
phone: phoneNumber || undefined,
|
|
617
|
+
});
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
case 'setTaxCategory': {
|
|
621
|
+
if (!actionEntry.taxCategoryId && !actionEntry.taxCategoryKey) {
|
|
622
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Tax category ID or key is required for setTaxCategory action', {
|
|
623
|
+
itemIndex,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const taxCategoryRef = {
|
|
627
|
+
typeId: 'tax-category',
|
|
628
|
+
};
|
|
629
|
+
if (actionEntry.taxCategoryId) {
|
|
630
|
+
taxCategoryRef.id = String(actionEntry.taxCategoryId);
|
|
631
|
+
}
|
|
632
|
+
else if (actionEntry.taxCategoryKey) {
|
|
633
|
+
taxCategoryRef.key = String(actionEntry.taxCategoryKey);
|
|
634
|
+
}
|
|
635
|
+
builtActions.push({
|
|
636
|
+
action: 'setTaxCategory',
|
|
637
|
+
taxCategory: taxCategoryRef,
|
|
638
|
+
});
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return builtActions;
|
|
644
|
+
};
|
|
645
|
+
exports.buildActionsFromUi = buildActionsFromUi;
|
|
646
|
+
//# sourceMappingURL=customer.utils.js.map
|