@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,386 +0,0 @@
|
|
1
|
-
import { type Request } from 'express';
|
2
|
-
import { mock, mockClear, mockDeep } from 'jest-mock-extended';
|
3
|
-
import { type IHookFunctions, type IWebhookFunctions } from 'n8n-workflow';
|
4
|
-
import { FulfillmenttoolsTrigger } from './FulfillmenttoolsTrigger.node';
|
5
|
-
import { fulfillmenttoolsApiRequest } from './GenericFunctions';
|
6
|
-
|
7
|
-
jest.mock('./GenericFunctions');
|
8
|
-
|
9
|
-
describe('FulfillmenttoolsTrigger', () => {
|
10
|
-
const hookFunctions = mockDeep<IHookFunctions>();
|
11
|
-
const webhookFunctions = mockDeep<IWebhookFunctions>();
|
12
|
-
|
13
|
-
let fulfillmenttoolsTrigger: FulfillmenttoolsTrigger;
|
14
|
-
|
15
|
-
beforeEach(() => {
|
16
|
-
fulfillmenttoolsTrigger = new FulfillmenttoolsTrigger();
|
17
|
-
});
|
18
|
-
|
19
|
-
afterEach(() => {
|
20
|
-
mockClear(hookFunctions);
|
21
|
-
mockClear(webhookFunctions);
|
22
|
-
});
|
23
|
-
|
24
|
-
it('should be defined', () => {
|
25
|
-
expect(fulfillmenttoolsTrigger).toBeDefined();
|
26
|
-
});
|
27
|
-
|
28
|
-
it('should check that a webhook exists', () => {
|
29
|
-
const callbackUrl =
|
30
|
-
'http://localhost:5678/webhook/c940f948-0c2e-4cba-9d47-1b38790d77bb';
|
31
|
-
const staticData: { subscriptionId?: string } = {};
|
32
|
-
|
33
|
-
hookFunctions.getNodeWebhookUrl
|
34
|
-
.calledWith('default')
|
35
|
-
.mockReturnValue(callbackUrl);
|
36
|
-
hookFunctions.getWorkflowStaticData
|
37
|
-
.calledWith('node')
|
38
|
-
.mockReturnValue(staticData);
|
39
|
-
|
40
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockResolvedValue({
|
41
|
-
subscriptions: [
|
42
|
-
{
|
43
|
-
callbackUrl,
|
44
|
-
event: 'ORDER_CREATED',
|
45
|
-
headers: [
|
46
|
-
{
|
47
|
-
key: 'user-agent',
|
48
|
-
value: 'ocff-xxx-pre/1.0',
|
49
|
-
},
|
50
|
-
{
|
51
|
-
key: 'x-fulfillmenttools-event',
|
52
|
-
value: 'ORDER_CREATED',
|
53
|
-
},
|
54
|
-
{
|
55
|
-
key: 'x-fulfillmenttools-token',
|
56
|
-
value: '43c983a2ab084b8c75f3dfa6a60dbb16',
|
57
|
-
},
|
58
|
-
],
|
59
|
-
name: 'order created',
|
60
|
-
id: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
61
|
-
created: '2024-01-29T13:19:44.453Z',
|
62
|
-
},
|
63
|
-
],
|
64
|
-
});
|
65
|
-
|
66
|
-
expect(
|
67
|
-
fulfillmenttoolsTrigger.webhookMethods.default.checkExists.call(
|
68
|
-
hookFunctions,
|
69
|
-
),
|
70
|
-
).resolves.toBe(true);
|
71
|
-
});
|
72
|
-
|
73
|
-
it('should check that a webhook does not exist', () => {
|
74
|
-
const callbackUrl =
|
75
|
-
'http://localhost:5678/webhook/c940f948-0c2e-4cba-9d47-1b38790d77bb';
|
76
|
-
const staticData: { subscriptionId?: string } = {};
|
77
|
-
|
78
|
-
hookFunctions.getNodeWebhookUrl
|
79
|
-
.calledWith('default')
|
80
|
-
.mockReturnValue(callbackUrl);
|
81
|
-
hookFunctions.getWorkflowStaticData
|
82
|
-
.calledWith('node')
|
83
|
-
.mockReturnValue(staticData);
|
84
|
-
|
85
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockResolvedValue({
|
86
|
-
subscriptions: [
|
87
|
-
{
|
88
|
-
callbackUrl:
|
89
|
-
'http://localhost:5678/webhook/5e632a06-6a4c-4372-a4e0-30afe130dbae',
|
90
|
-
event: 'ORDER_CREATED',
|
91
|
-
headers: [
|
92
|
-
{
|
93
|
-
key: 'user-agent',
|
94
|
-
value: 'ocff-xxx-pre/1.0',
|
95
|
-
},
|
96
|
-
{
|
97
|
-
key: 'x-fulfillmenttools-event',
|
98
|
-
value: 'ORDER_CREATED',
|
99
|
-
},
|
100
|
-
{
|
101
|
-
key: 'x-fulfillmenttools-token',
|
102
|
-
value: '43c983a2ab084b8c75f3dfa6a60dbb16',
|
103
|
-
},
|
104
|
-
],
|
105
|
-
name: 'order created',
|
106
|
-
id: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
107
|
-
created: '2024-01-29T13:19:44.453Z',
|
108
|
-
},
|
109
|
-
],
|
110
|
-
});
|
111
|
-
|
112
|
-
expect(
|
113
|
-
fulfillmenttoolsTrigger.webhookMethods.default.checkExists.call(
|
114
|
-
hookFunctions,
|
115
|
-
),
|
116
|
-
).resolves.toBe(false);
|
117
|
-
});
|
118
|
-
|
119
|
-
it('should create a webhook', () => {
|
120
|
-
const callbackUrl =
|
121
|
-
'http://localhost:5678/webhook/c940f948-0c2e-4cba-9d47-1b38790d77bb';
|
122
|
-
const event = 'ORDER_CREATED';
|
123
|
-
const credentials = { webhookToken: '43c983a2ab084b8c75f3dfa6a60dbb16' };
|
124
|
-
const staticData: { subscriptionId?: string } = {};
|
125
|
-
|
126
|
-
hookFunctions.getNodeWebhookUrl
|
127
|
-
.calledWith('default')
|
128
|
-
.mockReturnValue(callbackUrl);
|
129
|
-
hookFunctions.getNodeParameter.calledWith('event').mockReturnValue(event);
|
130
|
-
hookFunctions.getCredentials
|
131
|
-
.calledWith('fulfillmenttoolsApi')
|
132
|
-
.mockResolvedValue(credentials);
|
133
|
-
hookFunctions.getWorkflowStaticData
|
134
|
-
.calledWith('node')
|
135
|
-
.mockReturnValue(staticData);
|
136
|
-
|
137
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockResolvedValue({
|
138
|
-
callbackUrl:
|
139
|
-
'http://localhost:5678/webhook/5e632a06-6a4c-4372-a4e0-30afe130dbae',
|
140
|
-
event: 'ORDER_CREATED',
|
141
|
-
headers: [
|
142
|
-
{
|
143
|
-
key: 'user-agent',
|
144
|
-
value: 'ocff-xxx-pre/1.0',
|
145
|
-
},
|
146
|
-
{
|
147
|
-
key: 'x-fulfillmenttools-event',
|
148
|
-
value: 'ORDER_CREATED',
|
149
|
-
},
|
150
|
-
{
|
151
|
-
key: 'x-fulfillmenttools-token',
|
152
|
-
value: '43c983a2ab084b8c75f3dfa6a60dbb16',
|
153
|
-
},
|
154
|
-
],
|
155
|
-
name: 'order created',
|
156
|
-
id: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
157
|
-
created: '2024-01-29T13:19:44.453Z',
|
158
|
-
lastModified: '2024-01-29T13:19:44.453Z',
|
159
|
-
});
|
160
|
-
|
161
|
-
expect(
|
162
|
-
fulfillmenttoolsTrigger.webhookMethods.default.create.call(hookFunctions),
|
163
|
-
).resolves.toBe(true);
|
164
|
-
});
|
165
|
-
|
166
|
-
it('should not create a webhook', () => {
|
167
|
-
const callbackUrl =
|
168
|
-
'http://localhost:5678/webhook/c940f948-0c2e-4cba-9d47-1b38790d77bb';
|
169
|
-
const event = 'ORDER_CREATED';
|
170
|
-
const credentials = { webhookToken: '43c983a2ab084b8c75f3dfa6a60dbb16' };
|
171
|
-
const staticData: { subscriptionId?: string } = {};
|
172
|
-
|
173
|
-
hookFunctions.getNodeWebhookUrl
|
174
|
-
.calledWith('default')
|
175
|
-
.mockReturnValue(callbackUrl);
|
176
|
-
hookFunctions.getNodeParameter.calledWith('event').mockReturnValue(event);
|
177
|
-
hookFunctions.getCredentials
|
178
|
-
.calledWith('fulfillmenttoolsApi')
|
179
|
-
.mockResolvedValue(credentials);
|
180
|
-
hookFunctions.getWorkflowStaticData
|
181
|
-
.calledWith('node')
|
182
|
-
.mockReturnValue(staticData);
|
183
|
-
|
184
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockResolvedValue({
|
185
|
-
callbackUrl:
|
186
|
-
'http://localhost:5678/webhook/5e632a06-6a4c-4372-a4e0-30afe130dbae',
|
187
|
-
event: 'ORDER_CREATED',
|
188
|
-
headers: [
|
189
|
-
{
|
190
|
-
key: 'user-agent',
|
191
|
-
value: 'ocff-xxx-pre/1.0',
|
192
|
-
},
|
193
|
-
{
|
194
|
-
key: 'x-fulfillmenttools-event',
|
195
|
-
value: 'ORDER_CREATED',
|
196
|
-
},
|
197
|
-
{
|
198
|
-
key: 'x-fulfillmenttools-token',
|
199
|
-
value: '43c983a2ab084b8c75f3dfa6a60dbb16',
|
200
|
-
},
|
201
|
-
],
|
202
|
-
name: 'order created',
|
203
|
-
id: undefined,
|
204
|
-
created: '2024-01-29T13:19:44.453Z',
|
205
|
-
lastModified: '2024-01-29T13:19:44.453Z',
|
206
|
-
});
|
207
|
-
|
208
|
-
expect(
|
209
|
-
fulfillmenttoolsTrigger.webhookMethods.default.create.call(hookFunctions),
|
210
|
-
).resolves.toBe(false);
|
211
|
-
});
|
212
|
-
|
213
|
-
it('should delete a webhook', () => {
|
214
|
-
const staticData: { subscriptionId?: string } = {};
|
215
|
-
|
216
|
-
hookFunctions.getWorkflowStaticData
|
217
|
-
.calledWith('node')
|
218
|
-
.mockReturnValue(staticData);
|
219
|
-
|
220
|
-
expect(
|
221
|
-
fulfillmenttoolsTrigger.webhookMethods.default.delete.call(hookFunctions),
|
222
|
-
).resolves.toBe(true);
|
223
|
-
});
|
224
|
-
|
225
|
-
it('should delete a webhook in the API', () => {
|
226
|
-
const staticData: { subscriptionId?: string } = {
|
227
|
-
subscriptionId: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
228
|
-
};
|
229
|
-
|
230
|
-
hookFunctions.getWorkflowStaticData
|
231
|
-
.calledWith('node')
|
232
|
-
.mockReturnValue(staticData);
|
233
|
-
|
234
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockResolvedValue({
|
235
|
-
callbackUrl:
|
236
|
-
'http://localhost:5678/webhook/5e632a06-6a4c-4372-a4e0-30afe130dbae',
|
237
|
-
event: 'ORDER_CREATED',
|
238
|
-
headers: [
|
239
|
-
{
|
240
|
-
key: 'user-agent',
|
241
|
-
value: 'ocff-xxx-pre/1.0',
|
242
|
-
},
|
243
|
-
{
|
244
|
-
key: 'x-fulfillmenttools-event',
|
245
|
-
value: 'ORDER_CREATED',
|
246
|
-
},
|
247
|
-
{
|
248
|
-
key: 'x-fulfillmenttools-token',
|
249
|
-
value: '43c983a2ab084b8c75f3dfa6a60dbb16',
|
250
|
-
},
|
251
|
-
],
|
252
|
-
name: 'order created',
|
253
|
-
id: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
254
|
-
created: '2024-01-29T13:19:44.453Z',
|
255
|
-
lastModified: '2024-01-29T13:19:44.453Z',
|
256
|
-
});
|
257
|
-
|
258
|
-
expect(
|
259
|
-
fulfillmenttoolsTrigger.webhookMethods.default.delete.call(hookFunctions),
|
260
|
-
).resolves.toBe(true);
|
261
|
-
});
|
262
|
-
|
263
|
-
it('should not delete a webhook in the API', () => {
|
264
|
-
const staticData: { subscriptionId?: string } = {
|
265
|
-
subscriptionId: 'b9753da1-3e57-4c98-86f4-acada6226e09',
|
266
|
-
};
|
267
|
-
|
268
|
-
hookFunctions.getWorkflowStaticData
|
269
|
-
.calledWith('node')
|
270
|
-
.mockReturnValue(staticData);
|
271
|
-
|
272
|
-
jest.mocked(fulfillmenttoolsApiRequest).mockRejectedValue(new Error());
|
273
|
-
|
274
|
-
expect(
|
275
|
-
fulfillmenttoolsTrigger.webhookMethods.default.delete.call(hookFunctions),
|
276
|
-
).resolves.toBe(false);
|
277
|
-
});
|
278
|
-
|
279
|
-
it('should not provide workflow data when event header is missing', () => {
|
280
|
-
webhookFunctions.getHeaderData.mockReturnValue({
|
281
|
-
'x-fulfillmenttools-token': '43c983a2ab084b8c75f3dfa6a60dbb16',
|
282
|
-
});
|
283
|
-
|
284
|
-
expect(
|
285
|
-
fulfillmenttoolsTrigger.webhook.call(webhookFunctions),
|
286
|
-
).resolves.toEqual({});
|
287
|
-
});
|
288
|
-
|
289
|
-
it('should not provide workflow data when token header is missing', () => {
|
290
|
-
webhookFunctions.getHeaderData.mockReturnValue({
|
291
|
-
'x-fulfillmenttools-event': 'ORDER_CREATED',
|
292
|
-
});
|
293
|
-
|
294
|
-
expect(
|
295
|
-
fulfillmenttoolsTrigger.webhook.call(webhookFunctions),
|
296
|
-
).resolves.toEqual({});
|
297
|
-
});
|
298
|
-
|
299
|
-
it('should not provide workflow data when event does not match', () => {
|
300
|
-
webhookFunctions.getHeaderData.mockReturnValue({
|
301
|
-
'x-fulfillmenttools-event': 'ORDER_CREATED',
|
302
|
-
'x-fulfillmenttools-token': '43c983a2ab084b8c75f3dfa6a60dbb16',
|
303
|
-
});
|
304
|
-
webhookFunctions.getNodeParameter
|
305
|
-
.calledWith('event')
|
306
|
-
.mockReturnValue('ORDER_CANCELED');
|
307
|
-
|
308
|
-
expect(
|
309
|
-
fulfillmenttoolsTrigger.webhook.call(webhookFunctions),
|
310
|
-
).resolves.toEqual({});
|
311
|
-
});
|
312
|
-
|
313
|
-
it('should not provide workflow data when token does not match', () => {
|
314
|
-
webhookFunctions.getHeaderData.mockReturnValue({
|
315
|
-
'x-fulfillmenttools-event': 'ORDER_CREATED',
|
316
|
-
'x-fulfillmenttools-token': '43c983a2ab084b8c75f3dfa6a60dbb16',
|
317
|
-
});
|
318
|
-
webhookFunctions.getNodeParameter
|
319
|
-
.calledWith('event')
|
320
|
-
.mockReturnValue('ORDER_CREATED');
|
321
|
-
webhookFunctions.getCredentials
|
322
|
-
.calledWith('fulfillmenttoolsApi')
|
323
|
-
.mockResolvedValue({ webhookToken: '53c983a2ab084b8c75f3dfa6a60dbb17' });
|
324
|
-
|
325
|
-
expect(
|
326
|
-
fulfillmenttoolsTrigger.webhook.call(webhookFunctions),
|
327
|
-
).resolves.toEqual({});
|
328
|
-
});
|
329
|
-
|
330
|
-
it('should provide workflow data', () => {
|
331
|
-
const body = {
|
332
|
-
event: 'ORDER_CREATED',
|
333
|
-
eventId: '5e632a06-6a4c-4372-a4e0-30afe130dbae',
|
334
|
-
payload: {
|
335
|
-
consumer: {
|
336
|
-
addresses: [
|
337
|
-
{
|
338
|
-
city: 'Langenfeld',
|
339
|
-
country: 'DE',
|
340
|
-
houseNumber: '42a',
|
341
|
-
postalCode: '40764',
|
342
|
-
street: 'Hauptstr.',
|
343
|
-
},
|
344
|
-
],
|
345
|
-
},
|
346
|
-
orderDate: '2020-02-03T08:45:50.525Z',
|
347
|
-
orderLineItems: [
|
348
|
-
{
|
349
|
-
article: {
|
350
|
-
tenantArticleId: '4711',
|
351
|
-
title: 'Cologne Water',
|
352
|
-
},
|
353
|
-
quantity: 21,
|
354
|
-
},
|
355
|
-
],
|
356
|
-
status: 'OPEN',
|
357
|
-
version: 1,
|
358
|
-
id: 'c940f948-0c2e-4cba-9d47-1b38790d77bb',
|
359
|
-
},
|
360
|
-
};
|
361
|
-
const jsonArray = [{ json: body }];
|
362
|
-
|
363
|
-
webhookFunctions.getHeaderData.mockReturnValue({
|
364
|
-
'x-fulfillmenttools-event': 'ORDER_CREATED',
|
365
|
-
'x-fulfillmenttools-token': '43c983a2ab084b8c75f3dfa6a60dbb16',
|
366
|
-
});
|
367
|
-
webhookFunctions.getRequestObject.mockReturnValue(
|
368
|
-
mock<Request>({
|
369
|
-
body,
|
370
|
-
}),
|
371
|
-
);
|
372
|
-
webhookFunctions.getNodeParameter
|
373
|
-
.calledWith('event')
|
374
|
-
.mockReturnValue('ORDER_CREATED');
|
375
|
-
webhookFunctions.getCredentials
|
376
|
-
.calledWith('fulfillmenttoolsApi')
|
377
|
-
.mockResolvedValue({ webhookToken: '43c983a2ab084b8c75f3dfa6a60dbb16' });
|
378
|
-
webhookFunctions.helpers.returnJsonArray.mockReturnValue(jsonArray);
|
379
|
-
|
380
|
-
expect(
|
381
|
-
fulfillmenttoolsTrigger.webhook.call(webhookFunctions),
|
382
|
-
).resolves.toEqual({
|
383
|
-
workflowData: [jsonArray],
|
384
|
-
});
|
385
|
-
});
|
386
|
-
});
|