@gls_spain/gps-common 27.2.0 → 28.0.0
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/.idea/workspace.xml +33 -24
- package/CHANGELOG.md +14 -0
- package/open-api-spec/index.js +274 -151
- package/package.json +1 -1
- package/schemas/definitions/common.js +4 -2
- package/schemas/definitions/expeditions.js +121 -37
- package/schemas/definitions/{integration-events.js → gls-spain-integration-events.js} +14 -7
- package/schemas/definitions/historic-records.js +119 -0
- package/schemas/definitions/integrations.js +28 -0
- package/schemas/index.js +23 -14
- package/schemas/definitions/jobs.js +0 -124
|
@@ -47,7 +47,9 @@ const findByName = () => ({
|
|
|
47
47
|
const findByAddress = () => ({
|
|
48
48
|
title: 'find by address',
|
|
49
49
|
type: 'object',
|
|
50
|
-
properties: {
|
|
50
|
+
properties: {
|
|
51
|
+
address: { type: 'string', minLength: 3, description: 'search in address street, postal code, locality and administrative area' },
|
|
52
|
+
},
|
|
51
53
|
required: ['address'],
|
|
52
54
|
additionalProperties: false,
|
|
53
55
|
});
|
|
@@ -144,7 +146,7 @@ const fiscal = () => ({
|
|
|
144
146
|
const findByFiscal = () => ({
|
|
145
147
|
title: 'find by fiscal',
|
|
146
148
|
type: 'object',
|
|
147
|
-
properties: { fiscal: { type: 'string', minLength: 3, description: 'search
|
|
149
|
+
properties: { fiscal: { type: 'string', minLength: 3, description: 'search in business name and nif' } },
|
|
148
150
|
required: ['fiscal'],
|
|
149
151
|
additionalProperties: false,
|
|
150
152
|
});
|
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
} = require('@gls_spain/common-json-schemas');
|
|
20
20
|
const { date, findById, findByIds, tags } = require('./common');
|
|
21
21
|
const { address } = require('./common');
|
|
22
|
-
const { network } = require('./networks');
|
|
22
|
+
const { network, objectWithNetworkId } = require('./networks');
|
|
23
23
|
const { shop, objectWithShopId } = require('./shops');
|
|
24
24
|
const { derivationSettings } = require('./defaults');
|
|
25
25
|
|
|
@@ -134,6 +134,7 @@ const expedition = () => ({
|
|
|
134
134
|
properties: { ...pickProperties(shop(), ['_id', 'name']) },
|
|
135
135
|
required: ['_id', 'name'],
|
|
136
136
|
additionalProperties: false,
|
|
137
|
+
description: 'not available for incoming expeditions that are not assigned to a shop until reception',
|
|
137
138
|
},
|
|
138
139
|
type: { type: 'string', enum: ['delivery', 'pickup', 'sale'] },
|
|
139
140
|
status: {
|
|
@@ -270,7 +271,6 @@ const expedition = () => ({
|
|
|
270
271
|
'updatedAt',
|
|
271
272
|
'deletable',
|
|
272
273
|
'network',
|
|
273
|
-
'shop',
|
|
274
274
|
'type',
|
|
275
275
|
'status',
|
|
276
276
|
'code',
|
|
@@ -299,57 +299,114 @@ const objectWithExpeditionId = () => ({
|
|
|
299
299
|
additionalProperties: false,
|
|
300
300
|
});
|
|
301
301
|
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
'type',
|
|
310
|
-
'code',
|
|
311
|
-
'serviceCode',
|
|
312
|
-
'scheduleCode',
|
|
313
|
-
'date',
|
|
314
|
-
'expectedDeliveryDate',
|
|
315
|
-
'barcodes',
|
|
316
|
-
'packageCount',
|
|
317
|
-
'weight',
|
|
318
|
-
'volume',
|
|
319
|
-
'origin',
|
|
320
|
-
'destination',
|
|
321
|
-
'sender',
|
|
322
|
-
'agency',
|
|
323
|
-
'client',
|
|
324
|
-
'references',
|
|
325
|
-
'packages',
|
|
326
|
-
'notes',
|
|
327
|
-
]),
|
|
328
|
-
tags: tags(),
|
|
329
|
-
},
|
|
330
|
-
required: [
|
|
331
|
-
'shop',
|
|
302
|
+
const createExpeditionWithShop = () => ({
|
|
303
|
+
title: 'create with shop',
|
|
304
|
+
type: 'object',
|
|
305
|
+
properties: {
|
|
306
|
+
...pickProperties(expedition(), ['_id', 'createdAt']),
|
|
307
|
+
shop: objectWithUuid(),
|
|
308
|
+
...pickProperties(expedition(), [
|
|
332
309
|
'type',
|
|
333
310
|
'code',
|
|
334
311
|
'serviceCode',
|
|
335
312
|
'scheduleCode',
|
|
336
313
|
'date',
|
|
337
314
|
'expectedDeliveryDate',
|
|
315
|
+
'barcodes',
|
|
338
316
|
'packageCount',
|
|
339
317
|
'weight',
|
|
318
|
+
'volume',
|
|
340
319
|
'origin',
|
|
341
320
|
'destination',
|
|
342
321
|
'sender',
|
|
343
322
|
'agency',
|
|
344
323
|
'client',
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
324
|
+
'references',
|
|
325
|
+
'packages',
|
|
326
|
+
'notes',
|
|
327
|
+
]),
|
|
328
|
+
tags: tags(),
|
|
329
|
+
},
|
|
330
|
+
required: [
|
|
331
|
+
'shop',
|
|
332
|
+
'type',
|
|
333
|
+
'code',
|
|
334
|
+
'serviceCode',
|
|
335
|
+
'scheduleCode',
|
|
336
|
+
'date',
|
|
337
|
+
'expectedDeliveryDate',
|
|
338
|
+
'packageCount',
|
|
339
|
+
'weight',
|
|
340
|
+
'origin',
|
|
341
|
+
'destination',
|
|
342
|
+
'sender',
|
|
343
|
+
'agency',
|
|
344
|
+
'client',
|
|
345
|
+
],
|
|
346
|
+
additionalProperties: false,
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const createExpeditionWithNetwork = () => ({
|
|
350
|
+
title: 'create with network',
|
|
351
|
+
type: 'object',
|
|
352
|
+
properties: {
|
|
353
|
+
...pickProperties(expedition(), ['_id', 'createdAt']),
|
|
354
|
+
network: objectWithUuid(),
|
|
355
|
+
...pickProperties(expedition(), [
|
|
356
|
+
'type',
|
|
357
|
+
'code',
|
|
358
|
+
'serviceCode',
|
|
359
|
+
'scheduleCode',
|
|
360
|
+
'date',
|
|
361
|
+
'expectedDeliveryDate',
|
|
362
|
+
'barcodes',
|
|
363
|
+
'packageCount',
|
|
364
|
+
'weight',
|
|
365
|
+
'volume',
|
|
366
|
+
'origin',
|
|
367
|
+
'destination',
|
|
368
|
+
'sender',
|
|
369
|
+
'agency',
|
|
370
|
+
'client',
|
|
371
|
+
'references',
|
|
372
|
+
'packages',
|
|
373
|
+
'notes',
|
|
374
|
+
]),
|
|
375
|
+
tags: tags(),
|
|
376
|
+
},
|
|
377
|
+
required: [
|
|
378
|
+
'network',
|
|
379
|
+
'type',
|
|
380
|
+
'code',
|
|
381
|
+
'serviceCode',
|
|
382
|
+
'scheduleCode',
|
|
383
|
+
'date',
|
|
384
|
+
'expectedDeliveryDate',
|
|
385
|
+
'packageCount',
|
|
386
|
+
'weight',
|
|
387
|
+
'origin',
|
|
388
|
+
'destination',
|
|
389
|
+
'sender',
|
|
390
|
+
'agency',
|
|
391
|
+
'client',
|
|
392
|
+
],
|
|
393
|
+
additionalProperties: false,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
const createExpeditionRequest = () => createRequest({ oneOf: [createExpeditionWithShop(), createExpeditionWithNetwork()] });
|
|
348
397
|
|
|
349
398
|
const createExpeditionResponse = () => createResponse(expedition());
|
|
350
399
|
|
|
351
400
|
const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
|
|
352
401
|
|
|
402
|
+
const findByNoShop = () => ({
|
|
403
|
+
title: 'find by no shop',
|
|
404
|
+
type: 'object',
|
|
405
|
+
properties: { shop: { type: 'null' } },
|
|
406
|
+
required: ['shop'],
|
|
407
|
+
additionalProperties: false,
|
|
408
|
+
});
|
|
409
|
+
|
|
353
410
|
const findByStatus = () => ({
|
|
354
411
|
title: 'find by status',
|
|
355
412
|
type: 'object',
|
|
@@ -367,6 +424,17 @@ const findByStatus = () => ({
|
|
|
367
424
|
|
|
368
425
|
const findByShopAndStatus = () => mergeSchemas(findByShop(), findByStatus(), { title: 'find by shop and status' });
|
|
369
426
|
|
|
427
|
+
const findByNoShopAndStatus = () => mergeSchemas(findByNoShop(), findByStatus(), { title: 'find by no shop and status' });
|
|
428
|
+
|
|
429
|
+
const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find by network' });
|
|
430
|
+
|
|
431
|
+
const findByNetworkAndStatus = () => mergeSchemas(findByNetwork(), findByStatus(), { title: 'find by network and status' });
|
|
432
|
+
|
|
433
|
+
const findByNetworkAndNoShop = () => mergeSchemas(findByNetwork(), findByNoShop(), { title: 'find by network and no shop' });
|
|
434
|
+
|
|
435
|
+
const findByNetworkAndNoShopAndStatus = () =>
|
|
436
|
+
mergeSchemas(findByNetworkAndNoShop(), findByStatus(), { title: 'find by network and no shop and status' });
|
|
437
|
+
|
|
370
438
|
const findByCode = () => ({
|
|
371
439
|
title: 'find by code',
|
|
372
440
|
type: 'object',
|
|
@@ -377,7 +445,22 @@ const findByCode = () => ({
|
|
|
377
445
|
additionalProperties: false,
|
|
378
446
|
});
|
|
379
447
|
|
|
380
|
-
const
|
|
448
|
+
const findExpeditionsSuperAdminRequest = () =>
|
|
449
|
+
findRequest({
|
|
450
|
+
oneOf: [
|
|
451
|
+
findById(),
|
|
452
|
+
findByNetwork(),
|
|
453
|
+
findByNetworkAndStatus(),
|
|
454
|
+
findByNetworkAndNoShop(),
|
|
455
|
+
findByNetworkAndNoShopAndStatus(),
|
|
456
|
+
findByShop(),
|
|
457
|
+
findByShopAndStatus(),
|
|
458
|
+
findByCode(),
|
|
459
|
+
],
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
const findExpeditionsNetworkAdminAndShopUserRequest = () =>
|
|
463
|
+
findRequest({ oneOf: [findById(), findByShop(), findByShopAndStatus(), findByNoShop(), findByNoShopAndStatus(), findByCode()] });
|
|
381
464
|
|
|
382
465
|
const findExpeditionsResponse = () => findResponse(expedition());
|
|
383
466
|
|
|
@@ -619,7 +702,8 @@ module.exports = {
|
|
|
619
702
|
objectWithExpeditionId,
|
|
620
703
|
createExpeditionRequest,
|
|
621
704
|
createExpeditionResponse,
|
|
622
|
-
|
|
705
|
+
findExpeditionsSuperAdminRequest,
|
|
706
|
+
findExpeditionsNetworkAdminAndShopUserRequest,
|
|
623
707
|
findExpeditionsResponse,
|
|
624
708
|
updateExpeditionRequest,
|
|
625
709
|
updateExpeditionResponse,
|
|
@@ -17,8 +17,9 @@ const receiveFromDriverEvent = () => ({
|
|
|
17
17
|
properties: {
|
|
18
18
|
_id: expedition().properties._id,
|
|
19
19
|
receiveFromDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId(), objectWithExpirationDate()),
|
|
20
|
+
expedition: expedition(),
|
|
20
21
|
},
|
|
21
|
-
required: ['_id', 'receiveFromDriver'],
|
|
22
|
+
required: ['_id', 'receiveFromDriver', 'expedition'],
|
|
22
23
|
additionalProperties: false,
|
|
23
24
|
});
|
|
24
25
|
|
|
@@ -33,8 +34,9 @@ const receiveFromCustomerEvent = () => ({
|
|
|
33
34
|
objectWithNetworkId(),
|
|
34
35
|
objectWithExpirationDate(),
|
|
35
36
|
),
|
|
37
|
+
expedition: expedition(),
|
|
36
38
|
},
|
|
37
|
-
required: ['_id', 'receiveFromCustomer'],
|
|
39
|
+
required: ['_id', 'receiveFromCustomer', 'expedition'],
|
|
38
40
|
additionalProperties: false,
|
|
39
41
|
});
|
|
40
42
|
|
|
@@ -44,8 +46,9 @@ const giveToCustomerEvent = () => ({
|
|
|
44
46
|
properties: {
|
|
45
47
|
_id: expedition().properties._id,
|
|
46
48
|
giveToCustomer: mergeSchemas(processedWithCustomerWithPod(), objectWithShopId(), objectWithNetworkId()),
|
|
49
|
+
expedition: expedition(),
|
|
47
50
|
},
|
|
48
|
-
required: ['_id', 'giveToCustomer'],
|
|
51
|
+
required: ['_id', 'giveToCustomer', 'expedition'],
|
|
49
52
|
additionalProperties: false,
|
|
50
53
|
});
|
|
51
54
|
|
|
@@ -55,8 +58,9 @@ const giveToDriverEvent = () => ({
|
|
|
55
58
|
properties: {
|
|
56
59
|
_id: expedition().properties._id,
|
|
57
60
|
giveToDriver: mergeSchemas(processedWithDriver(), objectWithShopId(), objectWithNetworkId()),
|
|
61
|
+
expedition: expedition(),
|
|
58
62
|
},
|
|
59
|
-
required: ['_id', 'giveToDriver'],
|
|
63
|
+
required: ['_id', 'giveToDriver', 'expedition'],
|
|
60
64
|
additionalProperties: false,
|
|
61
65
|
});
|
|
62
66
|
|
|
@@ -66,8 +70,9 @@ const expirationReminderEvent = () => ({
|
|
|
66
70
|
properties: {
|
|
67
71
|
_id: expedition().properties._id,
|
|
68
72
|
expirationReminder: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
73
|
+
expedition: expedition(),
|
|
69
74
|
},
|
|
70
|
-
required: ['_id', 'expirationReminder'],
|
|
75
|
+
required: ['_id', 'expirationReminder', 'expedition'],
|
|
71
76
|
additionalProperties: false,
|
|
72
77
|
});
|
|
73
78
|
|
|
@@ -77,8 +82,9 @@ const expiredEvent = () => ({
|
|
|
77
82
|
properties: {
|
|
78
83
|
_id: expedition().properties._id,
|
|
79
84
|
expired: mergeSchemas(objectWithExpirationDate(), objectWithShopId(), objectWithNetworkId()),
|
|
85
|
+
expedition: expedition(),
|
|
80
86
|
},
|
|
81
|
-
required: ['_id', 'expired'],
|
|
87
|
+
required: ['_id', 'expired', 'expedition'],
|
|
82
88
|
additionalProperties: false,
|
|
83
89
|
});
|
|
84
90
|
|
|
@@ -93,8 +99,9 @@ const priceEvent = () => ({
|
|
|
93
99
|
},
|
|
94
100
|
required: ['total'],
|
|
95
101
|
}),
|
|
102
|
+
expedition: expedition(),
|
|
96
103
|
},
|
|
97
|
-
required: ['_id', 'price'],
|
|
104
|
+
required: ['_id', 'price', 'expedition'],
|
|
98
105
|
additionalProperties: false,
|
|
99
106
|
});
|
|
100
107
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const { uuid, datetime, findRequest, findResponse, mergeSchemas, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
+
const { network, objectWithNetworkId } = require('./networks');
|
|
3
|
+
const { shop, objectWithShopId } = require('./shops');
|
|
4
|
+
const { expedition, objectWithExpeditionId } = require('./expeditions');
|
|
5
|
+
const { integration } = require('./integrations');
|
|
6
|
+
|
|
7
|
+
const baseHistoricRecord = () => ({
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
_id: uuid(),
|
|
11
|
+
createdAt: datetime(),
|
|
12
|
+
updatedAt: datetime(),
|
|
13
|
+
action: { type: 'string', enum: ['create', 'update', 'delete'] },
|
|
14
|
+
actionExtras: { type: 'array', items: { type: 'string' }, description: 'additional details about the action, e.g. what was updated' },
|
|
15
|
+
actor: { type: 'string', description: 'the username of the user who made the action' },
|
|
16
|
+
integrations: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
additionalProperties: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
at: datetime(),
|
|
22
|
+
result: { type: 'string', enum: ['completed', 'failed', 'ignored', 'blocked', 'needsReview'] },
|
|
23
|
+
message: { type: 'string' },
|
|
24
|
+
},
|
|
25
|
+
required: ['at', 'result', 'message'],
|
|
26
|
+
description: 'what the integration has done with this record',
|
|
27
|
+
},
|
|
28
|
+
description: 'one property per integration where the property name is the name of the integration',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ['_id', 'createdAt', 'updatedAt', 'action', 'actionExtras', 'actor', 'integrations'],
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const networkHistoricRecord = () =>
|
|
36
|
+
mergeSchemas(baseHistoricRecord(), {
|
|
37
|
+
title: 'network historic record',
|
|
38
|
+
properties: {
|
|
39
|
+
network: network(),
|
|
40
|
+
},
|
|
41
|
+
required: ['network'],
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const shopHistoricRecord = () =>
|
|
46
|
+
mergeSchemas(baseHistoricRecord(), {
|
|
47
|
+
title: 'shop historic record',
|
|
48
|
+
properties: {
|
|
49
|
+
shop: shop(),
|
|
50
|
+
},
|
|
51
|
+
required: ['shop'],
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const expeditionHistoricRecord = () =>
|
|
56
|
+
mergeSchemas(baseHistoricRecord(), {
|
|
57
|
+
title: 'expedition historic record',
|
|
58
|
+
properties: {
|
|
59
|
+
actionExtras: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
enum: [
|
|
64
|
+
'receiveFromDriver',
|
|
65
|
+
'receiveFromCustomer',
|
|
66
|
+
'giveToDriver',
|
|
67
|
+
'giveToCustomer',
|
|
68
|
+
'redirect',
|
|
69
|
+
'expirationReminder',
|
|
70
|
+
'expired',
|
|
71
|
+
'price',
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
expedition: expedition(),
|
|
76
|
+
},
|
|
77
|
+
required: ['expedition'],
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const historicRecord = () => ({ oneOf: [networkHistoricRecord(), shopHistoricRecord(), expeditionHistoricRecord()] });
|
|
82
|
+
|
|
83
|
+
const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find by network' });
|
|
84
|
+
|
|
85
|
+
const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
|
|
86
|
+
|
|
87
|
+
const findByExpedition = () => mergeSchemas(objectWithExpeditionId(), { title: 'find by expedition' });
|
|
88
|
+
|
|
89
|
+
const findByIntegrationAndResult = () => ({
|
|
90
|
+
title: 'find by integration and result',
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
integration: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
...pickProperties(integration(), ['name']),
|
|
97
|
+
...pickProperties(baseHistoricRecord().properties.integrations.additionalProperties, ['result']),
|
|
98
|
+
},
|
|
99
|
+
required: ['name', 'result'],
|
|
100
|
+
additionalProperties: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: ['integration'],
|
|
104
|
+
additionalProperties: false,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const findHistoricRecordsRequest = () =>
|
|
108
|
+
findRequest({ oneOf: [findByNetwork(), findByShop(), findByExpedition(), findByIntegrationAndResult()] });
|
|
109
|
+
|
|
110
|
+
const findHistoricRecordsResponse = () => findResponse(historicRecord());
|
|
111
|
+
|
|
112
|
+
module.exports = {
|
|
113
|
+
networkHistoricRecord,
|
|
114
|
+
shopHistoricRecord,
|
|
115
|
+
expeditionHistoricRecord,
|
|
116
|
+
historicRecord,
|
|
117
|
+
findHistoricRecordsRequest,
|
|
118
|
+
findHistoricRecordsResponse,
|
|
119
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const omit = require('lodash/omit');
|
|
2
|
+
const { uuid, datetime, findRequest, findResponse, mergeSchemas } = require('@gls_spain/common-json-schemas');
|
|
3
|
+
const { findAll, findByIds } = require('./common');
|
|
4
|
+
|
|
5
|
+
const integration = () => ({
|
|
6
|
+
title: 'integration',
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
_id: uuid(),
|
|
10
|
+
createdAt: datetime(),
|
|
11
|
+
updatedAt: datetime(),
|
|
12
|
+
name: { type: 'string' },
|
|
13
|
+
enabled: { type: 'boolean' },
|
|
14
|
+
networks: mergeSchemas(omit(findByIds(), 'title'), { description: 'the integration only applies to these networks' }),
|
|
15
|
+
},
|
|
16
|
+
required: ['_id', 'createdAt', 'updatedAt', 'name', 'enabled', 'networks'],
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const findIntegrationsRequest = () => findRequest({ oneOf: [findAll()] });
|
|
21
|
+
|
|
22
|
+
const findIntegrationsResponse = () => findResponse(integration());
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
integration,
|
|
26
|
+
findIntegrationsRequest,
|
|
27
|
+
findIntegrationsResponse,
|
|
28
|
+
};
|
package/schemas/index.js
CHANGED
|
@@ -58,7 +58,8 @@ const {
|
|
|
58
58
|
const {
|
|
59
59
|
createExpeditionRequest,
|
|
60
60
|
createExpeditionResponse,
|
|
61
|
-
|
|
61
|
+
findExpeditionsSuperAdminRequest,
|
|
62
|
+
findExpeditionsNetworkAdminAndShopUserRequest,
|
|
62
63
|
findExpeditionsResponse,
|
|
63
64
|
updateExpeditionRequest,
|
|
64
65
|
updateExpeditionResponse,
|
|
@@ -75,7 +76,6 @@ const {
|
|
|
75
76
|
receiveAllExpeditionsFromDriverResponse,
|
|
76
77
|
} = require('./definitions/expeditions');
|
|
77
78
|
const { findPodsRequest, findPodsResponse } = require('./definitions/pods');
|
|
78
|
-
const { findJobsRequest, findExpeditionJobsResponse, findShopsJobsResponse, findNetworksJobsResponse } = require('./definitions/jobs');
|
|
79
79
|
const {
|
|
80
80
|
createRepresentativeRequest,
|
|
81
81
|
createRepresentativeResponse,
|
|
@@ -100,6 +100,8 @@ const {
|
|
|
100
100
|
deleteZoneRequest,
|
|
101
101
|
deleteZoneResponse,
|
|
102
102
|
} = require('./definitions/zones');
|
|
103
|
+
const { findIntegrationsRequest, findIntegrationsResponse } = require('./definitions/integrations');
|
|
104
|
+
const { findHistoricRecordsRequest, findHistoricRecordsResponse } = require('./definitions/historic-records');
|
|
103
105
|
|
|
104
106
|
function request(schema, $id) {
|
|
105
107
|
return addMetadata(schema, $id);
|
|
@@ -173,7 +175,11 @@ const shopUsersDeleteResponse = response(deleteShopUserResponse(), 'shopUsersDel
|
|
|
173
175
|
|
|
174
176
|
const expeditionsCreateRequest = request(createExpeditionRequest(), 'expeditionsCreateRequest');
|
|
175
177
|
const expeditionsCreateResponse = response(createExpeditionResponse(), 'expeditionsCreateResponse');
|
|
176
|
-
const
|
|
178
|
+
const expeditionsFindSuperAdminRequest = request(findExpeditionsSuperAdminRequest(), 'expeditionsFindSuperAdminRequest');
|
|
179
|
+
const expeditionsFindNetworkAdminAndShopUserRequest = request(
|
|
180
|
+
findExpeditionsNetworkAdminAndShopUserRequest(),
|
|
181
|
+
'expeditionsFindNetworkAdminAndShopUserRequest',
|
|
182
|
+
);
|
|
177
183
|
const expeditionsFindResponse = response(findExpeditionsResponse(), 'expeditionsFindResponse');
|
|
178
184
|
const expeditionsUpdateRequest = request(updateExpeditionRequest(), 'expeditionsUpdateRequest');
|
|
179
185
|
const expeditionsUpdateResponse = response(updateExpeditionResponse(), 'expeditionsUpdateResponse');
|
|
@@ -195,11 +201,6 @@ const expeditionsReceiveAllFromDriverResponse = response(
|
|
|
195
201
|
const podsFindRequest = request(findPodsRequest(), 'podsFindRequest');
|
|
196
202
|
const podsFindResponse = response(findPodsResponse(), 'podsFindResponse');
|
|
197
203
|
|
|
198
|
-
const jobsFindRequest = request(findJobsRequest(), 'jobsFindRequest');
|
|
199
|
-
const jobsFindExpeditionsResponse = response(findExpeditionJobsResponse(), 'jobsFindExpeditionsResponse');
|
|
200
|
-
const jobsFindShopsResponse = response(findShopsJobsResponse(), 'jobsFindShopsResponse');
|
|
201
|
-
const jobsFindNetworksResponse = response(findNetworksJobsResponse(), 'jobsFindNetworksResponse');
|
|
202
|
-
|
|
203
204
|
const representativesCreateRequest = request(createRepresentativeRequest(), 'representativesCreateRequest');
|
|
204
205
|
const representativesCreateResponse = response(createRepresentativeResponse(), 'representativesCreateResponse');
|
|
205
206
|
const representativesListNamesResponse = response(listRepresentativesNamesResponse(), 'representativesListNamesResponse');
|
|
@@ -222,6 +223,12 @@ const zonesUpdateResponse = response(updateZoneResponse(), 'zonesUpdateResponse'
|
|
|
222
223
|
const zonesDeleteRequest = request(deleteZoneRequest(), 'zonesDeleteRequest');
|
|
223
224
|
const zonesDeleteResponse = response(deleteZoneResponse(), 'zonesDeleteResponse');
|
|
224
225
|
|
|
226
|
+
const integrationsFindRequest = request(findIntegrationsRequest(), 'integrationsFindRequest');
|
|
227
|
+
const integrationsFindResponse = response(findIntegrationsResponse(), 'integrationsFindResponse');
|
|
228
|
+
|
|
229
|
+
const historicRecordsFindRequest = request(findHistoricRecordsRequest(), 'historicRecordsFindRequest');
|
|
230
|
+
const historicRecordsFindResponse = response(findHistoricRecordsResponse(), 'historicRecordsFindResponse');
|
|
231
|
+
|
|
225
232
|
module.exports = {
|
|
226
233
|
errorResponse,
|
|
227
234
|
|
|
@@ -287,7 +294,8 @@ module.exports = {
|
|
|
287
294
|
|
|
288
295
|
expeditionsCreateRequest,
|
|
289
296
|
expeditionsCreateResponse,
|
|
290
|
-
|
|
297
|
+
expeditionsFindSuperAdminRequest,
|
|
298
|
+
expeditionsFindNetworkAdminAndShopUserRequest,
|
|
291
299
|
expeditionsFindResponse,
|
|
292
300
|
expeditionsUpdateRequest,
|
|
293
301
|
expeditionsUpdateResponse,
|
|
@@ -306,11 +314,6 @@ module.exports = {
|
|
|
306
314
|
podsFindRequest,
|
|
307
315
|
podsFindResponse,
|
|
308
316
|
|
|
309
|
-
jobsFindRequest,
|
|
310
|
-
jobsFindExpeditionsResponse,
|
|
311
|
-
jobsFindShopsResponse,
|
|
312
|
-
jobsFindNetworksResponse,
|
|
313
|
-
|
|
314
317
|
representativesCreateRequest,
|
|
315
318
|
representativesCreateResponse,
|
|
316
319
|
representativesListNamesResponse,
|
|
@@ -332,4 +335,10 @@ module.exports = {
|
|
|
332
335
|
zonesUpdateResponse,
|
|
333
336
|
zonesDeleteRequest,
|
|
334
337
|
zonesDeleteResponse,
|
|
338
|
+
|
|
339
|
+
integrationsFindRequest,
|
|
340
|
+
integrationsFindResponse,
|
|
341
|
+
|
|
342
|
+
historicRecordsFindRequest,
|
|
343
|
+
historicRecordsFindResponse,
|
|
335
344
|
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const { uuid, datetime, datetimeRange, findRequest, findResponse, mergeSchemas } = require('@gls_spain/common-json-schemas');
|
|
2
|
-
const {
|
|
3
|
-
receiveFromDriverEvent,
|
|
4
|
-
receiveFromCustomerEvent,
|
|
5
|
-
giveToCustomerEvent,
|
|
6
|
-
giveToDriverEvent,
|
|
7
|
-
expirationReminderEvent,
|
|
8
|
-
expiredEvent,
|
|
9
|
-
priceEvent,
|
|
10
|
-
upsertShopEvent,
|
|
11
|
-
upsertNetworkEvent,
|
|
12
|
-
} = require('./integration-events');
|
|
13
|
-
|
|
14
|
-
const job = () => ({
|
|
15
|
-
type: 'object',
|
|
16
|
-
properties: {
|
|
17
|
-
_id: uuid(),
|
|
18
|
-
createdAt: datetime(),
|
|
19
|
-
processAt: datetime(),
|
|
20
|
-
status: { type: 'string', enum: ['pending', 'completed', 'failed'] },
|
|
21
|
-
results: {
|
|
22
|
-
type: 'array',
|
|
23
|
-
items: {
|
|
24
|
-
oneOf: [
|
|
25
|
-
{
|
|
26
|
-
title: 'success',
|
|
27
|
-
type: 'object',
|
|
28
|
-
properties: {
|
|
29
|
-
at: datetime(),
|
|
30
|
-
success: { type: 'string' },
|
|
31
|
-
},
|
|
32
|
-
required: ['at', 'success'],
|
|
33
|
-
additionalProperties: false,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
title: 'error',
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: {
|
|
39
|
-
at: datetime(),
|
|
40
|
-
error: { type: 'string' },
|
|
41
|
-
},
|
|
42
|
-
required: ['at', 'error'],
|
|
43
|
-
additionalProperties: false,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
description: 'the result of each try to process the job',
|
|
48
|
-
},
|
|
49
|
-
payload: { type: 'object' },
|
|
50
|
-
},
|
|
51
|
-
required: ['_id', 'createdAt', 'processAt', 'status', 'results', 'payload'],
|
|
52
|
-
additionalProperties: false,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const consistencyJob = () =>
|
|
56
|
-
mergeSchemas(job(), {
|
|
57
|
-
properties: {
|
|
58
|
-
payload: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
collection: { type: 'string' },
|
|
62
|
-
_id: uuid(),
|
|
63
|
-
},
|
|
64
|
-
required: ['collection', '_id'],
|
|
65
|
-
additionalProperties: true,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const expeditionJob = () =>
|
|
71
|
-
mergeSchemas(job(), {
|
|
72
|
-
properties: {
|
|
73
|
-
payload: {
|
|
74
|
-
oneOf: [
|
|
75
|
-
receiveFromDriverEvent(),
|
|
76
|
-
receiveFromCustomerEvent(),
|
|
77
|
-
giveToCustomerEvent(),
|
|
78
|
-
giveToDriverEvent(),
|
|
79
|
-
expirationReminderEvent(),
|
|
80
|
-
expiredEvent(),
|
|
81
|
-
priceEvent(),
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const shopJob = () =>
|
|
88
|
-
mergeSchemas(job(), {
|
|
89
|
-
properties: { payload: upsertShopEvent() },
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const networkJob = () =>
|
|
93
|
-
mergeSchemas(job(), {
|
|
94
|
-
properties: { payload: upsertNetworkEvent() },
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const findByStatusAndProcessAt = () => ({
|
|
98
|
-
title: 'find by status and processAt',
|
|
99
|
-
type: 'object',
|
|
100
|
-
properties: {
|
|
101
|
-
status: job().properties.status,
|
|
102
|
-
processAtRange: datetimeRange(),
|
|
103
|
-
},
|
|
104
|
-
required: ['status', 'processAtRange'],
|
|
105
|
-
additionalProperties: false,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const findJobsRequest = () => findRequest(findByStatusAndProcessAt());
|
|
109
|
-
|
|
110
|
-
const findExpeditionJobsResponse = () => findResponse(expeditionJob());
|
|
111
|
-
|
|
112
|
-
const findShopsJobsResponse = () => findResponse(shopJob());
|
|
113
|
-
|
|
114
|
-
const findNetworksJobsResponse = () => findResponse(networkJob());
|
|
115
|
-
|
|
116
|
-
module.exports = {
|
|
117
|
-
job,
|
|
118
|
-
consistencyJob,
|
|
119
|
-
expeditionJob,
|
|
120
|
-
findJobsRequest,
|
|
121
|
-
findExpeditionJobsResponse,
|
|
122
|
-
findShopsJobsResponse,
|
|
123
|
-
findNetworksJobsResponse,
|
|
124
|
-
};
|