@skriptfabrik/n8n-nodes-fulfillmenttools 0.1.0 → 0.1.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.
Files changed (42) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.json +30 -0
  3. package/CHANGELOG.md +25 -0
  4. package/jest.config.ts +11 -0
  5. package/package.json +3 -3
  6. package/project.json +37 -0
  7. package/src/api.d.ts +37084 -0
  8. package/src/credentials/FulfillmenttoolsApi.credentials.spec.ts +101 -0
  9. package/src/credentials/FulfillmenttoolsApi.credentials.ts +166 -0
  10. package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.spec.ts +1149 -0
  11. package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.ts +390 -0
  12. package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.spec.ts +386 -0
  13. package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.ts +396 -0
  14. package/src/nodes/Fulfillmenttools/GenericFunctions.spec.ts +279 -0
  15. package/src/nodes/Fulfillmenttools/GenericFunctions.ts +156 -0
  16. package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.ts +335 -0
  17. package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.ts +621 -0
  18. package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.ts +338 -0
  19. package/tsconfig.json +22 -0
  20. package/tsconfig.lib.json +10 -0
  21. package/tsconfig.spec.json +13 -0
  22. package/src/credentials/FulfillmenttoolsApi.credentials.d.ts +0 -13
  23. package/src/credentials/FulfillmenttoolsApi.credentials.js +0 -126
  24. package/src/credentials/FulfillmenttoolsApi.credentials.js.map +0 -1
  25. package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.d.ts +0 -5
  26. package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.js +0 -174
  27. package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.js.map +0 -1
  28. package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.d.ts +0 -12
  29. package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.js +0 -330
  30. package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.js.map +0 -1
  31. package/src/nodes/Fulfillmenttools/GenericFunctions.d.ts +0 -3
  32. package/src/nodes/Fulfillmenttools/GenericFunctions.js +0 -91
  33. package/src/nodes/Fulfillmenttools/GenericFunctions.js.map +0 -1
  34. package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.d.ts +0 -3
  35. package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.js +0 -322
  36. package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.js.map +0 -1
  37. package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.d.ts +0 -3
  38. package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.js +0 -610
  39. package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.js.map +0 -1
  40. package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.d.ts +0 -3
  41. package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.js +0 -328
  42. package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.js.map +0 -1
@@ -0,0 +1,156 @@
1
+ import type {
2
+ IDataObject,
3
+ IExecuteFunctions,
4
+ IHttpRequestMethods,
5
+ IHookFunctions,
6
+ ILoadOptionsFunctions,
7
+ IPollFunctions,
8
+ IHttpRequestOptions,
9
+ } from 'n8n-workflow';
10
+ import { NodeApiError, sleep } from 'n8n-workflow';
11
+
12
+ export async function fulfillmenttoolsApiRequest(
13
+ this:
14
+ | IExecuteFunctions
15
+ | IHookFunctions
16
+ | ILoadOptionsFunctions
17
+ | IPollFunctions,
18
+ method: IHttpRequestMethods,
19
+ url: string,
20
+ body?: IDataObject,
21
+ qs?: IDataObject,
22
+ ): Promise<IDataObject> {
23
+ const credentials = await this.getCredentials('fulfillmenttoolsApi');
24
+
25
+ const requestOptions: IHttpRequestOptions = {
26
+ url,
27
+ baseURL: `https://${credentials['subDomain']}.api.fulfillmenttools.com/api`,
28
+ headers: {
29
+ accept: 'application/json',
30
+ 'content-type': 'application/json',
31
+ },
32
+ method,
33
+ body,
34
+ qs,
35
+ returnFullResponse: true,
36
+ ignoreHttpStatusErrors: true,
37
+ json: true,
38
+ };
39
+
40
+ let response: {
41
+ body: IDataObject | IDataObject[];
42
+ headers: Record<string, string>;
43
+ statusCode: number;
44
+ statusMessage: string;
45
+ };
46
+
47
+ const totalRetries = 9;
48
+
49
+ let remainingRetries = totalRetries;
50
+
51
+ do {
52
+ response = await this.helpers.httpRequestWithAuthentication.call(
53
+ this,
54
+ 'fulfillmenttoolsApi',
55
+ requestOptions,
56
+ );
57
+
58
+ if (response.statusCode === 409) {
59
+ const body = response.body as IDataObject[];
60
+
61
+ if (
62
+ remainingRetries > 1 &&
63
+ body.length > 0 &&
64
+ body[0]['version'] !== undefined
65
+ ) {
66
+ requestOptions.body.version = body[0]['version'];
67
+ remainingRetries = 1;
68
+ } else {
69
+ remainingRetries = 0;
70
+ }
71
+ } else if (response.statusCode === 429) {
72
+ await sleep(Math.pow(2, totalRetries - remainingRetries) * 500);
73
+ remainingRetries = remainingRetries - 1;
74
+ } else {
75
+ remainingRetries = 0;
76
+ }
77
+ } while (remainingRetries > 0);
78
+
79
+ if (response.statusCode === 429) {
80
+ throw new NodeApiError(
81
+ this.getNode(),
82
+ {},
83
+ {
84
+ message: response.statusMessage,
85
+ httpCode: response.statusCode.toString(),
86
+ description: 'The maximum number of retries has been reached.',
87
+ },
88
+ );
89
+ } else if (response.statusCode >= 400) {
90
+ throw new NodeApiError(
91
+ this.getNode(),
92
+ {},
93
+ {
94
+ message: response.statusMessage,
95
+ httpCode: response.statusCode.toString(),
96
+ description: (response.body as IDataObject[])
97
+ .map((error) => error['summary'])
98
+ .join('\n'),
99
+ },
100
+ );
101
+ }
102
+
103
+ return response.body as IDataObject;
104
+ }
105
+
106
+ export async function fulfillmenttoolsApiRequestAllItems<
107
+ T extends string | undefined,
108
+ >(
109
+ this:
110
+ | IExecuteFunctions
111
+ | IHookFunctions
112
+ | ILoadOptionsFunctions
113
+ | IPollFunctions,
114
+ resource: T,
115
+ method: IHttpRequestMethods,
116
+ url: string,
117
+ body?: IDataObject,
118
+ qs: IDataObject = {},
119
+ ): Promise<IDataObject[]> {
120
+ const returnData: (IDataObject & { id?: string })[] = [];
121
+
122
+ let responseItems;
123
+
124
+ do {
125
+ const responseData = (await fulfillmenttoolsApiRequest.call(
126
+ this,
127
+ method,
128
+ url,
129
+ body,
130
+ qs,
131
+ )) as T extends string
132
+ ? { [R: string]: (IDataObject & { id?: string })[] }
133
+ : (IDataObject & { id?: string })[];
134
+
135
+ if (resource === undefined) {
136
+ responseItems = responseData as (IDataObject & { id?: string })[];
137
+ } else {
138
+ responseItems = (
139
+ responseData as { [R: string]: (IDataObject & { id?: string })[] }
140
+ )[resource];
141
+ }
142
+
143
+ returnData.push(...responseItems);
144
+
145
+ if (
146
+ qs['limit'] !== undefined &&
147
+ returnData.length >= (qs['limit'] as number)
148
+ ) {
149
+ return returnData.splice(0, qs['limit'] as number);
150
+ }
151
+
152
+ qs['startAfterId'] = returnData[returnData.length - 1].id;
153
+ } while (responseItems.length > 0);
154
+
155
+ return returnData;
156
+ }
@@ -0,0 +1,335 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+
3
+ export const facilityCarrierOperations: INodeProperties[] = [
4
+ {
5
+ displayName: 'Operation',
6
+ name: 'operation',
7
+ type: 'options',
8
+ noDataExpression: true,
9
+ displayOptions: {
10
+ show: {
11
+ resource: ['facilityCarrier'],
12
+ },
13
+ },
14
+ options: [
15
+ {
16
+ name: 'Create',
17
+ value: 'create',
18
+ description:
19
+ 'Create a connection of a configured carrier to the facility with the given ID',
20
+ action: 'Create facility carrier',
21
+ },
22
+ {
23
+ name: 'Get',
24
+ value: 'get',
25
+ description:
26
+ 'Get the details for a carrier related to the facility with the given ID',
27
+ action: 'Get facility carrier',
28
+ },
29
+ {
30
+ name: 'List',
31
+ value: 'list',
32
+ description: 'Get the available CEPs for a facility',
33
+ action: 'List facility carriers',
34
+ },
35
+ {
36
+ name: 'Connect',
37
+ value: 'connect',
38
+ description:
39
+ 'Connect a configured carrier to the facility with the given ID',
40
+ action: 'Connect facility carrier',
41
+ },
42
+ ],
43
+ default: 'create',
44
+ },
45
+ ];
46
+
47
+ export const facilityCarrierFields: INodeProperties[] = [
48
+ /* -------------------------------------------------------------------------- */
49
+ /* facilityCarrier:create */
50
+ /* -------------------------------------------------------------------------- */
51
+ {
52
+ displayName: 'Facility ID',
53
+ name: 'facilityId',
54
+ type: 'string',
55
+ required: true,
56
+ default: '',
57
+ displayOptions: {
58
+ show: {
59
+ resource: ['facilityCarrier'],
60
+ operation: ['create'],
61
+ },
62
+ },
63
+ description: 'ID of facility you want to create a connection for',
64
+ },
65
+ {
66
+ displayName: 'Carrier Ref',
67
+ name: 'carrierRef',
68
+ type: 'string',
69
+ required: true,
70
+ default: '',
71
+ displayOptions: {
72
+ show: {
73
+ resource: ['facilityCarrier'],
74
+ operation: ['create'],
75
+ },
76
+ },
77
+ description: 'ID of the referenced carrier',
78
+ },
79
+ {
80
+ displayName: 'Locale',
81
+ name: 'locale',
82
+ type: 'string',
83
+ default: '',
84
+ displayOptions: {
85
+ show: {
86
+ resource: ['facilityCarrier'],
87
+ operation: ['create'],
88
+ },
89
+ },
90
+ description:
91
+ 'Localized names and descriptions for the parcel label classifications',
92
+ },
93
+ {
94
+ displayName: 'Facility Carrier',
95
+ name: 'facilityCarrier',
96
+ type: 'json',
97
+ required: true,
98
+ default: JSON.stringify(
99
+ {
100
+ credentials: {
101
+ key: 'string',
102
+ billingNumber: '22222222220101',
103
+ retoureBillingNumber: '22222222220701',
104
+ internationalBillingNumber: '22222222220701',
105
+ dhlBusinessPassword: 'string',
106
+ dhlBusinessUsername: 'string',
107
+ dhlBusinessUsergroup: 'string',
108
+ },
109
+ configuration: {
110
+ key: 'string',
111
+ contactId: 'It-aGZXHEm870vI',
112
+ returnContactId: '7g0UXSgZMQd08K7',
113
+ },
114
+ cutoffTime: {
115
+ hour: 16,
116
+ minute: 30,
117
+ },
118
+ deliveryAreas: [
119
+ {
120
+ country: 'DE',
121
+ postalCode: '40764',
122
+ },
123
+ ],
124
+ name: 'DHL Köln',
125
+ status: 'ACTIVE',
126
+ parcelLabelClassifications: [
127
+ {
128
+ nameLocalized: {
129
+ de_DE: 'Wert',
130
+ en_US: 'Value',
131
+ ru_RU: 'значение',
132
+ },
133
+ dimensions: {
134
+ height: 50,
135
+ length: 100,
136
+ weight: 1700,
137
+ width: 25,
138
+ },
139
+ },
140
+ ],
141
+ tags: [
142
+ {
143
+ value: 'string',
144
+ id: 'string',
145
+ },
146
+ ],
147
+ validDeliveryTargets: ['SHIP_TO_STORE'],
148
+ },
149
+ undefined,
150
+ 2,
151
+ ),
152
+ displayOptions: {
153
+ show: {
154
+ resource: ['facilityCarrier'],
155
+ operation: ['create'],
156
+ },
157
+ },
158
+ description: 'Representation that describes the connection',
159
+ },
160
+ /* -------------------------------------------------------------------------- */
161
+ /* facilityCarrier:get */
162
+ /* -------------------------------------------------------------------------- */
163
+ {
164
+ displayName: 'Facility ID',
165
+ name: 'facilityId',
166
+ type: 'string',
167
+ required: true,
168
+ default: '',
169
+ displayOptions: {
170
+ show: {
171
+ resource: ['facilityCarrier'],
172
+ operation: ['get'],
173
+ },
174
+ },
175
+ description: 'ID of facility you want to get',
176
+ },
177
+ {
178
+ displayName: 'Carrier Ref',
179
+ name: 'carrierRef',
180
+ type: 'string',
181
+ required: true,
182
+ default: '',
183
+ displayOptions: {
184
+ show: {
185
+ resource: ['facilityCarrier'],
186
+ operation: ['get'],
187
+ },
188
+ },
189
+ description: 'ID of the referenced carrier',
190
+ },
191
+ {
192
+ displayName: 'Locale',
193
+ name: 'locale',
194
+ type: 'string',
195
+ default: '',
196
+ displayOptions: {
197
+ show: {
198
+ resource: ['facilityCarrier'],
199
+ operation: ['get'],
200
+ },
201
+ },
202
+ description:
203
+ 'Localized names and descriptions for the parcel label classifications',
204
+ },
205
+ /* -------------------------------------------------------------------------- */
206
+ /* facilityCarrier:list */
207
+ /* -------------------------------------------------------------------------- */
208
+ {
209
+ displayName: 'Facility ID',
210
+ name: 'facilityId',
211
+ type: 'string',
212
+ required: true,
213
+ default: '',
214
+ displayOptions: {
215
+ show: {
216
+ resource: ['facilityCarrier'],
217
+ operation: ['list'],
218
+ },
219
+ },
220
+ description: 'ID of facility you want to get',
221
+ },
222
+ /* -------------------------------------------------------------------------- */
223
+ /* facilityCarrier:connect */
224
+ /* -------------------------------------------------------------------------- */
225
+ {
226
+ displayName: 'Facility ID',
227
+ name: 'facilityId',
228
+ type: 'string',
229
+ required: true,
230
+ default: '',
231
+ displayOptions: {
232
+ show: {
233
+ resource: ['facilityCarrier'],
234
+ operation: ['connect'],
235
+ },
236
+ },
237
+ description: 'ID of facility you want to patch',
238
+ },
239
+ {
240
+ displayName: 'Carrier Ref',
241
+ name: 'carrierRef',
242
+ type: 'string',
243
+ required: true,
244
+ default: '',
245
+ displayOptions: {
246
+ show: {
247
+ resource: ['facilityCarrier'],
248
+ operation: ['connect'],
249
+ },
250
+ },
251
+ description: 'ID of the referenced carrier',
252
+ },
253
+ {
254
+ displayName: 'Locale',
255
+ name: 'locale',
256
+ type: 'string',
257
+ default: '',
258
+ displayOptions: {
259
+ show: {
260
+ resource: ['facilityCarrier'],
261
+ operation: ['connect'],
262
+ },
263
+ },
264
+ description:
265
+ 'Localized names and descriptions for the parcel label classifications',
266
+ },
267
+ {
268
+ displayName: 'Facility',
269
+ name: 'facilityCarrier',
270
+ type: 'json',
271
+ required: true,
272
+ default: JSON.stringify(
273
+ {
274
+ credentials: {
275
+ key: 'string',
276
+ billingNumber: '22222222220101',
277
+ retoureBillingNumber: '22222222220701',
278
+ internationalBillingNumber: '22222222220701',
279
+ dhlBusinessPassword: 'string',
280
+ dhlBusinessUsername: 'string',
281
+ dhlBusinessUsergroup: 'string',
282
+ },
283
+ configuration: {
284
+ key: 'string',
285
+ contactId: 'D6C3fImQqpVV1E9',
286
+ returnContactId: 't1h-EQTdpiXl8J4',
287
+ },
288
+ cutoffTime: {
289
+ hour: 16,
290
+ minute: 30,
291
+ },
292
+ deliveryAreas: [
293
+ {
294
+ country: 'DE',
295
+ postalCode: '40764',
296
+ },
297
+ ],
298
+ name: 'DHL Köln',
299
+ status: 'ACTIVE',
300
+ parcelLabelClassifications: [
301
+ {
302
+ nameLocalized: {
303
+ de_DE: 'Wert',
304
+ en_US: 'Value',
305
+ ru_RU: 'значение',
306
+ },
307
+ dimensions: {
308
+ height: 50,
309
+ length: 100,
310
+ weight: 1700,
311
+ width: 25,
312
+ },
313
+ },
314
+ ],
315
+ tags: [
316
+ {
317
+ value: 'string',
318
+ id: 'string',
319
+ },
320
+ ],
321
+ version: 0,
322
+ validDeliveryTargets: ['SHIP_TO_STORE'],
323
+ },
324
+ undefined,
325
+ 2,
326
+ ),
327
+ displayOptions: {
328
+ show: {
329
+ resource: ['facilityCarrier'],
330
+ operation: ['connect'],
331
+ },
332
+ },
333
+ description: 'Representation that describes the connection',
334
+ },
335
+ ];