@skriptfabrik/n8n-nodes-fulfillmenttools 0.1.1 → 0.1.3
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 +28 -0
- package/package.json +5 -4
- package/src/credentials/FulfillmenttoolsApi.credentials.d.ts +13 -0
- package/src/credentials/FulfillmenttoolsApi.credentials.js +126 -0
- package/src/credentials/FulfillmenttoolsApi.credentials.js.map +1 -0
- package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.d.ts +5 -0
- package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.js +174 -0
- package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.js.map +1 -0
- package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.d.ts +12 -0
- package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.js +330 -0
- package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.js.map +1 -0
- package/src/nodes/Fulfillmenttools/GenericFunctions.d.ts +3 -0
- package/src/nodes/Fulfillmenttools/GenericFunctions.js +90 -0
- package/src/nodes/Fulfillmenttools/GenericFunctions.js.map +1 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.d.ts +3 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.js +322 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.js.map +1 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.d.ts +3 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.js +610 -0
- package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.js.map +1 -0
- package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.d.ts +3 -0
- package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.js +328 -0
- package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.js.map +1 -0
- package/.eslintrc.json +0 -30
- package/jest.config.ts +0 -11
- package/project.json +0 -38
- package/src/api.d.ts +0 -26710
- package/src/credentials/FulfillmenttoolsApi.credentials.spec.ts +0 -101
- package/src/credentials/FulfillmenttoolsApi.credentials.ts +0 -166
- package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.spec.ts +0 -1149
- package/src/nodes/Fulfillmenttools/Fulfillmenttools.node.ts +0 -390
- package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.spec.ts +0 -386
- package/src/nodes/Fulfillmenttools/FulfillmenttoolsTrigger.node.ts +0 -396
- package/src/nodes/Fulfillmenttools/GenericFunctions.spec.ts +0 -279
- package/src/nodes/Fulfillmenttools/GenericFunctions.ts +0 -156
- package/src/nodes/Fulfillmenttools/descriptions/FacilityCarrierDescription.ts +0 -335
- package/src/nodes/Fulfillmenttools/descriptions/FacilityDescription.ts +0 -621
- package/src/nodes/Fulfillmenttools/descriptions/OrderDescription.ts +0 -338
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -13
@@ -1,390 +0,0 @@
|
|
1
|
-
import type {
|
2
|
-
IDataObject,
|
3
|
-
IExecuteFunctions,
|
4
|
-
INodeExecutionData,
|
5
|
-
INodeType,
|
6
|
-
INodeTypeDescription,
|
7
|
-
NodeApiError,
|
8
|
-
} from 'n8n-workflow';
|
9
|
-
import type { components, operations } from '../../api';
|
10
|
-
import {
|
11
|
-
fulfillmenttoolsApiRequest,
|
12
|
-
fulfillmenttoolsApiRequestAllItems,
|
13
|
-
} from './GenericFunctions';
|
14
|
-
import {
|
15
|
-
facilityFields,
|
16
|
-
facilityOperations,
|
17
|
-
} from './descriptions/FacilityDescription';
|
18
|
-
import {
|
19
|
-
facilityCarrierFields,
|
20
|
-
facilityCarrierOperations,
|
21
|
-
} from './descriptions/FacilityCarrierDescription';
|
22
|
-
import { orderFields, orderOperations } from './descriptions/OrderDescription';
|
23
|
-
|
24
|
-
type FacilityForCreation = components['schemas']['FacilityForCreation'];
|
25
|
-
type Facility = components['schemas']['Facility'];
|
26
|
-
type GetAllFacilitiesQueryParameters =
|
27
|
-
operations['getAllFacilities']['parameters']['query'];
|
28
|
-
type StrippedFacilities = components['schemas']['StrippedFacilities'];
|
29
|
-
type FacilityPatchActions = components['schemas']['FacilityPatchActions'];
|
30
|
-
|
31
|
-
type CreateCarrierToFacilityQueryParameters =
|
32
|
-
operations['createCarrierToFacility']['parameters']['query'];
|
33
|
-
type FacilityCarrierConnectionForCreation =
|
34
|
-
components['schemas']['FacilityCarrierConnectionForCreation'];
|
35
|
-
type GetFacilityCarrierQueryParameters =
|
36
|
-
operations['getFacilityCarrier']['parameters']['query'];
|
37
|
-
type FacilityCarrierConnection =
|
38
|
-
components['schemas']['FacilityCarrierConnection'];
|
39
|
-
type StrippedCarriers = components['schemas']['StrippedCarriers'];
|
40
|
-
type ConnectCarrierToFacilityQueryParameters =
|
41
|
-
operations['connectCarrierToFacility']['parameters']['query'];
|
42
|
-
type FacilityCarrierConnectionForModification =
|
43
|
-
components['schemas']['FacilityCarrierConnectionForModification'];
|
44
|
-
|
45
|
-
type OrderForCreation = components['schemas']['OrderForCreation'];
|
46
|
-
type Order = components['schemas']['Order'];
|
47
|
-
type GetAllOrdersQueryParameters =
|
48
|
-
operations['getAllOrders']['parameters']['query'];
|
49
|
-
type StrippedOrders = components['schemas']['StrippedOrders'];
|
50
|
-
|
51
|
-
export class Fulfillmenttools implements INodeType {
|
52
|
-
description: INodeTypeDescription = {
|
53
|
-
name: 'fulfillmenttools',
|
54
|
-
|
55
|
-
displayName: 'fulfillmenttools',
|
56
|
-
|
57
|
-
icon: 'file:icons/fulfillmenttools.svg',
|
58
|
-
|
59
|
-
group: ['transform'],
|
60
|
-
|
61
|
-
version: 1,
|
62
|
-
|
63
|
-
subtitle: '={{$parameter["operation"] + " " + $parameter["resource"]}}',
|
64
|
-
|
65
|
-
description: 'Consume fulfillmenttools API',
|
66
|
-
|
67
|
-
defaults: {
|
68
|
-
name: 'fulfillmenttools',
|
69
|
-
},
|
70
|
-
|
71
|
-
inputs: ['main'],
|
72
|
-
|
73
|
-
outputs: ['main'],
|
74
|
-
|
75
|
-
credentials: [
|
76
|
-
{
|
77
|
-
name: 'fulfillmenttoolsApi',
|
78
|
-
required: true,
|
79
|
-
},
|
80
|
-
],
|
81
|
-
|
82
|
-
properties: [
|
83
|
-
{
|
84
|
-
displayName: 'Resource',
|
85
|
-
name: 'resource',
|
86
|
-
type: 'options',
|
87
|
-
noDataExpression: true,
|
88
|
-
options: [
|
89
|
-
{
|
90
|
-
name: 'Facility',
|
91
|
-
value: 'facility',
|
92
|
-
},
|
93
|
-
{
|
94
|
-
name: 'Facility Carrier',
|
95
|
-
value: 'facilityCarrier',
|
96
|
-
},
|
97
|
-
{
|
98
|
-
name: 'Order',
|
99
|
-
value: 'order',
|
100
|
-
},
|
101
|
-
],
|
102
|
-
default: 'order',
|
103
|
-
},
|
104
|
-
...facilityOperations,
|
105
|
-
...facilityFields,
|
106
|
-
...facilityCarrierOperations,
|
107
|
-
...facilityCarrierFields,
|
108
|
-
...orderOperations,
|
109
|
-
...orderFields,
|
110
|
-
],
|
111
|
-
};
|
112
|
-
|
113
|
-
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
114
|
-
const items = this.getInputData();
|
115
|
-
|
116
|
-
const returnData: INodeExecutionData[] = [];
|
117
|
-
|
118
|
-
let responseData: IDataObject | IDataObject[] = {};
|
119
|
-
|
120
|
-
const resource = this.getNodeParameter('resource', 0) as string;
|
121
|
-
|
122
|
-
const operation = this.getNodeParameter('operation', 0) as string;
|
123
|
-
|
124
|
-
for (let item = 0; item < items.length; item++) {
|
125
|
-
try {
|
126
|
-
if (resource === 'facility') {
|
127
|
-
if (operation === 'create') {
|
128
|
-
const body = this.getNodeParameter(
|
129
|
-
'facility',
|
130
|
-
item,
|
131
|
-
) as FacilityForCreation;
|
132
|
-
|
133
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
134
|
-
this,
|
135
|
-
'POST',
|
136
|
-
'/facilities',
|
137
|
-
body,
|
138
|
-
)) as Facility;
|
139
|
-
}
|
140
|
-
|
141
|
-
if (operation === 'delete') {
|
142
|
-
const facilityId = this.getNodeParameter(
|
143
|
-
'facilityId',
|
144
|
-
item,
|
145
|
-
) as string;
|
146
|
-
|
147
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
148
|
-
this,
|
149
|
-
'DELETE',
|
150
|
-
`/facilities/${facilityId}`,
|
151
|
-
)) as Facility;
|
152
|
-
}
|
153
|
-
|
154
|
-
if (operation === 'get') {
|
155
|
-
const facilityId = this.getNodeParameter(
|
156
|
-
'facilityId',
|
157
|
-
item,
|
158
|
-
) as string;
|
159
|
-
|
160
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
161
|
-
this,
|
162
|
-
'GET',
|
163
|
-
`/facilities/${facilityId}`,
|
164
|
-
)) as Facility;
|
165
|
-
}
|
166
|
-
|
167
|
-
if (operation === 'list') {
|
168
|
-
const returnAll = this.getNodeParameter(
|
169
|
-
'returnAll',
|
170
|
-
item,
|
171
|
-
) as boolean;
|
172
|
-
|
173
|
-
const qs = {
|
174
|
-
...(returnAll
|
175
|
-
? {}
|
176
|
-
: {
|
177
|
-
limit: this.getNodeParameter('limit', item),
|
178
|
-
startAfterId:
|
179
|
-
this.getNodeParameter('startAfterId', item) || undefined,
|
180
|
-
}),
|
181
|
-
size: this.getNodeParameter('size', item),
|
182
|
-
status: this.getNodeParameter('status', item) || undefined,
|
183
|
-
tenantFacilityId:
|
184
|
-
this.getNodeParameter('tenantFacilityId', item) || undefined,
|
185
|
-
orderBy: this.getNodeParameter('orderBy', item) || undefined,
|
186
|
-
} as GetAllFacilitiesQueryParameters;
|
187
|
-
|
188
|
-
responseData = (await fulfillmenttoolsApiRequestAllItems.call(
|
189
|
-
this,
|
190
|
-
'facilities',
|
191
|
-
'GET',
|
192
|
-
'/facilities',
|
193
|
-
undefined,
|
194
|
-
qs,
|
195
|
-
)) as StrippedFacilities;
|
196
|
-
}
|
197
|
-
|
198
|
-
if (operation === 'patch') {
|
199
|
-
const facilityId = this.getNodeParameter(
|
200
|
-
'facilityId',
|
201
|
-
item,
|
202
|
-
) as string;
|
203
|
-
const body = this.getNodeParameter(
|
204
|
-
'facility',
|
205
|
-
item,
|
206
|
-
) as FacilityPatchActions;
|
207
|
-
|
208
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
209
|
-
this,
|
210
|
-
'PATCH',
|
211
|
-
`/facilities/${facilityId}`,
|
212
|
-
body,
|
213
|
-
)) as Facility;
|
214
|
-
}
|
215
|
-
}
|
216
|
-
|
217
|
-
if (resource === 'facilityCarrier') {
|
218
|
-
if (operation === 'create') {
|
219
|
-
const facilityId = this.getNodeParameter(
|
220
|
-
'facilityId',
|
221
|
-
item,
|
222
|
-
) as string;
|
223
|
-
const carrierRef = this.getNodeParameter(
|
224
|
-
'carrierRef',
|
225
|
-
item,
|
226
|
-
) as string;
|
227
|
-
const body = this.getNodeParameter(
|
228
|
-
'facilityCarrier',
|
229
|
-
item,
|
230
|
-
) as FacilityCarrierConnectionForCreation;
|
231
|
-
const qs = {
|
232
|
-
locale:
|
233
|
-
(this.getNodeParameter('locale', item) as string) || undefined,
|
234
|
-
} as CreateCarrierToFacilityQueryParameters;
|
235
|
-
|
236
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
237
|
-
this,
|
238
|
-
'POST',
|
239
|
-
`/facilities/${facilityId}/carriers/${carrierRef}`,
|
240
|
-
body,
|
241
|
-
qs,
|
242
|
-
)) as FacilityCarrierConnection;
|
243
|
-
}
|
244
|
-
|
245
|
-
if (operation === 'get') {
|
246
|
-
const facilityId = this.getNodeParameter(
|
247
|
-
'facilityId',
|
248
|
-
item,
|
249
|
-
) as string;
|
250
|
-
const carrierRef = this.getNodeParameter(
|
251
|
-
'carrierRef',
|
252
|
-
item,
|
253
|
-
) as string;
|
254
|
-
const qs = {
|
255
|
-
locale:
|
256
|
-
(this.getNodeParameter('locale', item) as string) || undefined,
|
257
|
-
} as GetFacilityCarrierQueryParameters;
|
258
|
-
|
259
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
260
|
-
this,
|
261
|
-
'GET',
|
262
|
-
`/facilities/${facilityId}/carriers/${carrierRef}`,
|
263
|
-
undefined,
|
264
|
-
qs,
|
265
|
-
)) as FacilityCarrierConnection;
|
266
|
-
}
|
267
|
-
|
268
|
-
if (operation === 'list') {
|
269
|
-
const facilityId = this.getNodeParameter(
|
270
|
-
'facilityId',
|
271
|
-
item,
|
272
|
-
) as string;
|
273
|
-
|
274
|
-
responseData = (await fulfillmenttoolsApiRequestAllItems.call(
|
275
|
-
this,
|
276
|
-
'carriers',
|
277
|
-
'GET',
|
278
|
-
`/facilities/${facilityId}/carriers`,
|
279
|
-
)) as StrippedCarriers;
|
280
|
-
}
|
281
|
-
|
282
|
-
if (operation === 'connect') {
|
283
|
-
const facilityId = this.getNodeParameter(
|
284
|
-
'facilityId',
|
285
|
-
item,
|
286
|
-
) as string;
|
287
|
-
const carrierRef = this.getNodeParameter(
|
288
|
-
'carrierRef',
|
289
|
-
item,
|
290
|
-
) as string;
|
291
|
-
const body = this.getNodeParameter(
|
292
|
-
'facilityCarrier',
|
293
|
-
item,
|
294
|
-
) as FacilityCarrierConnectionForModification;
|
295
|
-
const qs = {
|
296
|
-
locale:
|
297
|
-
(this.getNodeParameter('locale', item) as string) || undefined,
|
298
|
-
} as ConnectCarrierToFacilityQueryParameters;
|
299
|
-
|
300
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
301
|
-
this,
|
302
|
-
'PUT',
|
303
|
-
`/facilities/${facilityId}/carriers/${carrierRef}`,
|
304
|
-
body,
|
305
|
-
qs,
|
306
|
-
)) as FacilityCarrierConnection;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
|
310
|
-
if (resource === 'order') {
|
311
|
-
if (operation === 'create') {
|
312
|
-
const body = this.getNodeParameter(
|
313
|
-
'order',
|
314
|
-
item,
|
315
|
-
) as OrderForCreation;
|
316
|
-
|
317
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
318
|
-
this,
|
319
|
-
'POST',
|
320
|
-
'/orders',
|
321
|
-
body,
|
322
|
-
)) as Order;
|
323
|
-
}
|
324
|
-
|
325
|
-
if (operation === 'get') {
|
326
|
-
const orderId = this.getNodeParameter('orderId', item) as string;
|
327
|
-
|
328
|
-
responseData = (await fulfillmenttoolsApiRequest.call(
|
329
|
-
this,
|
330
|
-
'GET',
|
331
|
-
`/orders/${orderId}`,
|
332
|
-
)) as Order;
|
333
|
-
}
|
334
|
-
|
335
|
-
if (operation === 'list') {
|
336
|
-
const returnAll = this.getNodeParameter(
|
337
|
-
'returnAll',
|
338
|
-
item,
|
339
|
-
) as boolean;
|
340
|
-
|
341
|
-
const qs = {
|
342
|
-
...(returnAll
|
343
|
-
? {}
|
344
|
-
: {
|
345
|
-
limit: this.getNodeParameter('limit', item),
|
346
|
-
startAfterId:
|
347
|
-
this.getNodeParameter('startAfterId', item) || undefined,
|
348
|
-
}),
|
349
|
-
size: this.getNodeParameter('size', item),
|
350
|
-
tenantOrderId:
|
351
|
-
this.getNodeParameter('tenantOrderId', item) || undefined,
|
352
|
-
} as GetAllOrdersQueryParameters;
|
353
|
-
|
354
|
-
responseData = (await fulfillmenttoolsApiRequestAllItems.call(
|
355
|
-
this,
|
356
|
-
'orders',
|
357
|
-
'GET',
|
358
|
-
'/orders',
|
359
|
-
undefined,
|
360
|
-
qs,
|
361
|
-
)) as StrippedOrders;
|
362
|
-
}
|
363
|
-
}
|
364
|
-
|
365
|
-
const executionData = this.helpers.constructExecutionMetaData(
|
366
|
-
this.helpers.returnJsonArray(responseData),
|
367
|
-
{ itemData: { item } },
|
368
|
-
);
|
369
|
-
|
370
|
-
returnData.push(...executionData);
|
371
|
-
} catch (error: unknown) {
|
372
|
-
if (this.continueOnFail()) {
|
373
|
-
returnData.push({
|
374
|
-
json: {
|
375
|
-
error: (error as NodeApiError).message,
|
376
|
-
},
|
377
|
-
pairedItem: {
|
378
|
-
item,
|
379
|
-
},
|
380
|
-
});
|
381
|
-
continue;
|
382
|
-
}
|
383
|
-
|
384
|
-
throw error;
|
385
|
-
}
|
386
|
-
}
|
387
|
-
|
388
|
-
return [returnData];
|
389
|
-
}
|
390
|
-
}
|