@gls_spain/gps-common 27.2.0 → 28.0.1
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 +67 -20
- package/CHANGELOG.md +21 -0
- package/errors/DatabaseNotEmptyError.js +3 -1
- package/errors/DefaultsDoNotExistError.js +3 -1
- package/errors/ExpeditionAlreadyExistsError.js +3 -1
- package/errors/ExpeditionCannotBeDeletedError.js +3 -1
- package/errors/ExpeditionCannotBeUpdatedError.js +3 -1
- package/errors/ExpeditionDoesNotExistError.js +3 -1
- package/errors/NetworkAlreadyExistsError.js +3 -1
- package/errors/NetworkCannotBeDeletedError.js +3 -1
- package/errors/NetworkDoesNotExistError.js +3 -1
- package/errors/RepresentativeAlreadyExistsError.js +3 -1
- package/errors/RepresentativeCannotBeDeletedError.js +3 -1
- package/errors/RepresentativeDoesNotExistError.js +3 -1
- package/errors/ShopAlreadyExistsError.js +3 -1
- package/errors/ShopCannotBeDeletedError.js +3 -1
- package/errors/ShopDoesNotExistError.js +3 -1
- package/errors/ShopNotEnabledError.js +3 -1
- package/errors/UserAlreadyExistsError.js +3 -1
- package/errors/UserCannotBeDeletedError.js +3 -1
- package/errors/UserCannotBeUpdatedError.js +3 -1
- package/errors/UserDoesNotExistError.js +3 -1
- package/errors/WrongNetworkError.js +3 -1
- package/errors/WrongPasswordError.js +3 -1
- package/errors/WrongShopError.js +3 -1
- package/errors/ZoneAlreadyExistsError.js +3 -1
- package/errors/ZoneCannotBeDeletedError.js +3 -1
- package/errors/ZoneDoesNotExistError.js +3 -1
- package/errors/index.js +0 -3
- package/open-api-spec/index.js +274 -151
- package/package.json +2 -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/errors/JobDoesNotExistError.js +0 -9
- package/schemas/definitions/jobs.js +0 -124
package/open-api-spec/index.js
CHANGED
|
@@ -101,7 +101,8 @@ const {
|
|
|
101
101
|
expedition,
|
|
102
102
|
createExpeditionRequest,
|
|
103
103
|
createExpeditionResponse,
|
|
104
|
-
|
|
104
|
+
findExpeditionsSuperAdminRequest,
|
|
105
|
+
findExpeditionsNetworkAdminAndShopUserRequest,
|
|
105
106
|
findExpeditionsResponse,
|
|
106
107
|
updateExpeditionRequest,
|
|
107
108
|
updateExpeditionResponse,
|
|
@@ -129,13 +130,7 @@ const {
|
|
|
129
130
|
priceEvent,
|
|
130
131
|
upsertShopEvent,
|
|
131
132
|
upsertNetworkEvent,
|
|
132
|
-
} = require('../schemas/definitions/integration-events');
|
|
133
|
-
const {
|
|
134
|
-
findJobsRequest,
|
|
135
|
-
findExpeditionJobsResponse,
|
|
136
|
-
findShopsJobsResponse,
|
|
137
|
-
findNetworksJobsResponse,
|
|
138
|
-
} = require('../schemas/definitions/jobs');
|
|
133
|
+
} = require('../schemas/definitions/gls-spain-integration-events');
|
|
139
134
|
const {
|
|
140
135
|
representative,
|
|
141
136
|
createRepresentativeRequest,
|
|
@@ -162,6 +157,14 @@ const {
|
|
|
162
157
|
deleteZoneRequest,
|
|
163
158
|
deleteZoneResponse,
|
|
164
159
|
} = require('../schemas/definitions/zones');
|
|
160
|
+
const { integration, findIntegrationsRequest, findIntegrationsResponse } = require('../schemas/definitions/integrations');
|
|
161
|
+
const {
|
|
162
|
+
networkHistoricRecord,
|
|
163
|
+
shopHistoricRecord,
|
|
164
|
+
expeditionHistoricRecord,
|
|
165
|
+
findHistoricRecordsRequest,
|
|
166
|
+
findHistoricRecordsResponse,
|
|
167
|
+
} = require('../schemas/definitions/historic-records');
|
|
165
168
|
|
|
166
169
|
const openApiSpec = { openapi: '3.0.2' };
|
|
167
170
|
|
|
@@ -183,7 +186,11 @@ openApiSpec.servers = [
|
|
|
183
186
|
},
|
|
184
187
|
{
|
|
185
188
|
url: 'https://api.gps.albo.dev',
|
|
186
|
-
description: '
|
|
189
|
+
description: 'Development API and DB',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
url: 'https://api.shop.gls-spain.dev',
|
|
193
|
+
description: 'Pre-production API and DB',
|
|
187
194
|
},
|
|
188
195
|
{
|
|
189
196
|
url: 'https://api.shop.gls-spain.es',
|
|
@@ -200,9 +207,17 @@ openApiSpec['x-tagGroups'] = [
|
|
|
200
207
|
name: 'RESOURCES',
|
|
201
208
|
tags: ['Super admin', 'Network', 'Network admin', 'Zone', 'Shop', 'Shop user', 'Expedition', 'Pod', 'Sales representative'],
|
|
202
209
|
},
|
|
210
|
+
{
|
|
211
|
+
name: 'HISTORIC RECORDS',
|
|
212
|
+
tags: ['Historic records introduction', 'Network record', 'Shop record', 'Expedition record'],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'BACKGROUND WORK',
|
|
216
|
+
tags: ['Background work', 'Eventual consistency', 'Expeditions expiration'],
|
|
217
|
+
},
|
|
203
218
|
{
|
|
204
219
|
name: 'INTEGRATIONS',
|
|
205
|
-
tags: ['GLS'],
|
|
220
|
+
tags: ['Integrations introduction', 'GLS Spain'],
|
|
206
221
|
},
|
|
207
222
|
{
|
|
208
223
|
name: 'ENDPOINTS',
|
|
@@ -210,7 +225,7 @@ openApiSpec['x-tagGroups'] = [
|
|
|
210
225
|
'Authentication',
|
|
211
226
|
'Documentation',
|
|
212
227
|
'Config',
|
|
213
|
-
'
|
|
228
|
+
'Integrations',
|
|
214
229
|
'Super admins',
|
|
215
230
|
'Networks',
|
|
216
231
|
'Network admins',
|
|
@@ -220,6 +235,7 @@ openApiSpec['x-tagGroups'] = [
|
|
|
220
235
|
'Expeditions',
|
|
221
236
|
'Pods',
|
|
222
237
|
'Sales representatives',
|
|
238
|
+
'Historic records',
|
|
223
239
|
],
|
|
224
240
|
},
|
|
225
241
|
];
|
|
@@ -248,10 +264,11 @@ The API can be used by 3 kinds of users:
|
|
|
248
264
|
|
|
249
265
|
- Shop users: these are the staff that work at the parcel shops. They can:
|
|
250
266
|
|
|
251
|
-
-
|
|
267
|
+
- View the shop inventory.
|
|
252
268
|
- Receive packages from GLS.
|
|
253
269
|
- Deliver packages to customers.
|
|
254
|
-
- Receive
|
|
270
|
+
- Receive returns from customers.
|
|
271
|
+
- Give returns to GLS drivers.
|
|
255
272
|
- etc...
|
|
256
273
|
|
|
257
274
|
Every endpoint of this documentation has a caption before its name indicating who can use it: **[S]** for super admins,
|
|
@@ -417,87 +434,184 @@ endpoints, and then associate them to parcel shops on creation or update.
|
|
|
417
434
|
<SchemaDefinition schemaRef="#/components/schemas/representative" />`,
|
|
418
435
|
},
|
|
419
436
|
{
|
|
420
|
-
name: '
|
|
437
|
+
name: 'Historic records introduction',
|
|
438
|
+
'x-displayName': 'Historic records',
|
|
439
|
+
description: `
|
|
440
|
+
Every time the API creates, updates or deletes a network, shop or expedition, it stores a historic record of the action including the full
|
|
441
|
+
document as it was after the action, the time it occurred and the user that made it.
|
|
442
|
+
|
|
443
|
+
These historic records serve two purposes:
|
|
444
|
+
|
|
445
|
+
- They allow to track the full history of a document and to revert any document to a previous state by updating it again.
|
|
446
|
+
- They are the basis for integrations with other systems. Integrations work by iterating over the historic records in chronological order
|
|
447
|
+
and deciding what to do with each action, if anything.
|
|
448
|
+
|
|
449
|
+
Each record has an \`integrations\` field where each integration stores what it did with it.
|
|
450
|
+
`,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
name: 'Network record',
|
|
454
|
+
description: `
|
|
455
|
+
The API creates a record every time a network is created, updated or deleted.
|
|
456
|
+
|
|
457
|
+
Super administrators can search the historic records of networks using the [historic records](#tag/Historic-records) endpoints.
|
|
458
|
+
|
|
459
|
+
<SchemaDefinition schemaRef="#/components/schemas/networkHistoricRecord" />`,
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: 'Shop record',
|
|
463
|
+
description: `
|
|
464
|
+
The API creates a record every time a shop is created, updated or deleted.
|
|
465
|
+
|
|
466
|
+
Super administrators can search the historic records of shops using the [historic records](#tag/Historic-records) endpoints.
|
|
467
|
+
|
|
468
|
+
<SchemaDefinition schemaRef="#/components/schemas/shopHistoricRecord" />`,
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: 'Expedition record',
|
|
472
|
+
description: `
|
|
473
|
+
The API creates a record every time an expedition is created, updated, deleted, received, given or redirected.
|
|
474
|
+
|
|
475
|
+
The \`actionExtras\` field contains additional information about the action. For example:
|
|
476
|
+
|
|
477
|
+
- A reception from a customer is an \`update\` action with the \`receiveFromCustomer\` and \`price\` extras.
|
|
478
|
+
- An update of the packages is an \`update\` action with a \`price\` extra.
|
|
479
|
+
- An automatic background expiration of an expedition is an \`update\` action with an \`expired\` extra.
|
|
480
|
+
|
|
481
|
+
Super administrators can search the historic records of expeditions using the [historic records](#tag/Historic-records) endpoints.
|
|
482
|
+
|
|
483
|
+
<SchemaDefinition schemaRef="#/components/schemas/expeditionHistoricRecord" />`,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'Background work',
|
|
487
|
+
description: `
|
|
488
|
+
Besides responding to requests made to its endpoints, this API also performs some background work. This section explains this work except
|
|
489
|
+
for the integrations with other systems, which have their own [section](#tag/Integrations-introduction).`,
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: 'Eventual consistency',
|
|
493
|
+
description: `
|
|
494
|
+
Some of the resources in this API depend on others. In these situations the dependent resources store a reference to the \`_id\` of their
|
|
495
|
+
dependency, for example each shop stores the network it belong to in its \`network._id\` field.
|
|
496
|
+
|
|
497
|
+
There are other fields of the dependencies that are used so often that it makes sense to store them in the dependents too, for example each
|
|
498
|
+
shop also stores the name of its network in its \`network.name\` field.
|
|
499
|
+
|
|
500
|
+
This is called denormalization and it saves a lot of queries for the full dependency each time these fields are needed. The downside is
|
|
501
|
+
that an update in the dependency requires updating the dependents too. There are two strategies to do this:
|
|
502
|
+
|
|
503
|
+
- **Strict consistency**: the dependents are updated at the same time as the dependency. The update endpoint may become very slow if there are
|
|
504
|
+
thousands or millions of dependents, and it also requires a database transaction.
|
|
505
|
+
- **Eventual consistency**: only the dependency is updated immediately, and the dependents are updated later in the background. The update
|
|
506
|
+
endpoint returns very fast but for a few seconds the dependents are outdated.
|
|
507
|
+
|
|
508
|
+
This API uses eventual consistency because these denormalized fields are normally used for UI purposes and not for critical calculations
|
|
509
|
+
that required strict consistency.`,
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: 'Expeditions expiration',
|
|
421
513
|
description: `
|
|
422
|
-
|
|
514
|
+
Delivery expeditions can only be in a shop for a certain amount of time before GLS returns them to the sender. This information is
|
|
515
|
+
calculated when the expedition is received at a shop and stored in its \`status.expiration\` field.
|
|
423
516
|
|
|
424
|
-
|
|
425
|
-
|
|
517
|
+
This expiration information includes two kind of values that need to be checked periodically: the list of moments when the customer needs
|
|
518
|
+
to be reminded to pick up the expedition, and the moment the expedition expires.
|
|
426
519
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
for
|
|
520
|
+
The API periodically checks these moments and when the time comes it updates the expedition and stores an historic record of the update. It
|
|
521
|
+
is then the responsability of some integration to respond to that historic record. See [integrations](#tag/Integrations-introduction)
|
|
522
|
+
for more information.`,
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
name: 'Integrations introduction',
|
|
526
|
+
'x-displayName': 'Integrations',
|
|
527
|
+
description: `
|
|
528
|
+
Some of the background work of this API are integrations with other systems. These integrations work by scanning the historic records of
|
|
529
|
+
networks, shops and expeditions in chronological order and deciding what to do for each action, if anything. As these integrations iterate
|
|
530
|
+
over the records they store their results in the \`integrations\` field of each record.
|
|
430
531
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
with the \`integrations\` property of the users. If it contains the value \`glsApi\` then the API will not send events
|
|
434
|
-
for any request made by that user.
|
|
532
|
+
Super administrators can search the historic records by integration name and result to find for example those records where the integration
|
|
533
|
+
failed and why. See the [historic records](#tag/Historic-records) endpoints for more information.
|
|
435
534
|
|
|
535
|
+
Each integration also has a corresponding \`integration\` document that stores its configuration, basically if it is enabled or not and
|
|
536
|
+
what networks it applies to:
|
|
436
537
|
|
|
437
|
-
|
|
538
|
+
<SchemaDefinition schemaRef="#/components/schemas/integration" />
|
|
438
539
|
|
|
439
|
-
|
|
540
|
+
See the [integrations](#tag/Integrations) endpoints for more information.`,
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: 'GLS Spain',
|
|
544
|
+
description: `
|
|
545
|
+
This API is integrated with the main systems of GLS Spain. The integration goes in both directions:
|
|
440
546
|
|
|
441
|
-
|
|
547
|
+
- GLS Spain has a super admin user to access this API and manage its resources, e.g. creating expeditions.
|
|
548
|
+
- This API scans the historic records and sends events to GLS Spain on certain situations, e.g. when a shop receives an expedition.
|
|
442
549
|
|
|
443
|
-
|
|
444
|
-
|
|
550
|
+
This integration configuration can be found using the [find integrations endpoint](#tag/Integrations/paths/~1integrations~1find/post),
|
|
551
|
+
under the \`GLS Spain\` name. Its \`networks\` field lists the networks it applies to.
|
|
552
|
+
|
|
553
|
+
The possible events sent to GLS Spain are listed below, along with the historic record that causes them to be sent.
|
|
554
|
+
|
|
555
|
+
## Upsert network event
|
|
556
|
+
|
|
557
|
+
Sent when a network \`update\` record is found, which is created when the [/networks/update](#tag/Networks/paths/~1networks~1update/post)
|
|
558
|
+
endpoint is called.
|
|
445
559
|
|
|
446
560
|
<SchemaDefinition schemaRef="#/components/schemas/upsertNetworkEvent" />
|
|
447
561
|
|
|
448
|
-
|
|
562
|
+
## Upsert shop event
|
|
449
563
|
|
|
450
|
-
|
|
451
|
-
[/shops/update](#tag/Shops/paths/~1shops~1update/post).
|
|
564
|
+
Sent when a shop \`create\` or \`update\` record is found, which are created when the
|
|
565
|
+
[/shops/create](#tag/Shops/paths/~1shops~1create/post) or [/shops/update](#tag/Shops/paths/~1shops~1update/post) endpoints are called.
|
|
452
566
|
|
|
453
567
|
<SchemaDefinition schemaRef="#/components/schemas/upsertShopEvent" />
|
|
454
568
|
|
|
455
|
-
|
|
569
|
+
## Receive from driver event
|
|
456
570
|
|
|
457
|
-
|
|
458
|
-
|
|
571
|
+
Sent when an expedition \`update\` record with the \`receiveFromDriver\` extra is found, which is created when the
|
|
572
|
+
[/expeditions/receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) endpoint is called.
|
|
459
573
|
|
|
460
574
|
<SchemaDefinition schemaRef="#/components/schemas/receiveFromDriverEvent" />
|
|
461
575
|
|
|
462
|
-
|
|
576
|
+
## Receive from customer event
|
|
463
577
|
|
|
464
|
-
|
|
465
|
-
|
|
578
|
+
Sent when an expedition \`update\` record with the \`receiveFromCustomer\` extra is found, which is created when the
|
|
579
|
+
[/expeditions/receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) is called.
|
|
466
580
|
|
|
467
581
|
<SchemaDefinition schemaRef="#/components/schemas/receiveFromCustomerEvent" />
|
|
468
582
|
|
|
469
|
-
|
|
583
|
+
## Give to customer event
|
|
470
584
|
|
|
471
|
-
|
|
472
|
-
|
|
585
|
+
Sent when an expedition \`update\` record with the \`giveToCustomer\` extra is found, which is created when the
|
|
586
|
+
[/expeditions/giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) endpoint is called.
|
|
473
587
|
|
|
474
588
|
<SchemaDefinition schemaRef="#/components/schemas/giveToCustomerEvent" />
|
|
475
589
|
|
|
476
|
-
|
|
590
|
+
## Give to driver event
|
|
477
591
|
|
|
478
|
-
|
|
479
|
-
|
|
592
|
+
Sent when an expedition \`update\` record with the \`giveToDriver\` extra is found, which is created when the
|
|
593
|
+
[/expeditions/giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) endpoint is called.
|
|
480
594
|
|
|
481
595
|
<SchemaDefinition schemaRef="#/components/schemas/giveToDriverEvent" />
|
|
482
596
|
|
|
483
|
-
|
|
597
|
+
## Expiration reminder event
|
|
484
598
|
|
|
485
|
-
|
|
486
|
-
|
|
599
|
+
Sent when an expedition \`update\` record with the \`expirationReminder\` extra is found, which is created when the API detects in the
|
|
600
|
+
background that it is time to remind the customer to pick up the expedition.
|
|
487
601
|
|
|
488
602
|
<SchemaDefinition schemaRef="#/components/schemas/expirationReminderEvent" />
|
|
489
603
|
|
|
490
|
-
|
|
604
|
+
## Expired event
|
|
491
605
|
|
|
492
|
-
|
|
493
|
-
|
|
606
|
+
Sent when an expedition \`update\` record with the \`expired\` extra is found, which is created when the API detects in the background that
|
|
607
|
+
the expedition has expired and updates its status.
|
|
494
608
|
|
|
495
609
|
<SchemaDefinition schemaRef="#/components/schemas/expiredEvent" />
|
|
496
610
|
|
|
497
|
-
|
|
611
|
+
## Price event
|
|
498
612
|
|
|
499
|
-
|
|
500
|
-
|
|
613
|
+
Sent when an expedition \`update\` record with the \`price\` extra is found, which is created when the expedition is received and after
|
|
614
|
+
that anytime the weight or packages are updated.
|
|
501
615
|
|
|
502
616
|
<SchemaDefinition schemaRef="#/components/schemas/priceEvent" />`,
|
|
503
617
|
},
|
|
@@ -540,17 +654,8 @@ These settings can be set at various levels of specificity:
|
|
|
540
654
|
- Shop specific values: each shop can have its custom settings, which override the network and default ones.`,
|
|
541
655
|
},
|
|
542
656
|
{
|
|
543
|
-
name: '
|
|
544
|
-
description: `Find
|
|
545
|
-
|
|
546
|
-
In addition to handling requests, the API also performs background work. Some of this work is in response to a request
|
|
547
|
-
like when an expedition is given to a customer, and some of it is because the API does regular checks for certain conditions
|
|
548
|
-
like checking every day if any expedition has expired and needs to be retired by the driver.
|
|
549
|
-
|
|
550
|
-
This work is scheduled as individual jobs stored in one of several processing queues. A background process periodically
|
|
551
|
-
checks this queues and processes the pending jobs.
|
|
552
|
-
|
|
553
|
-
These endpoints allow a super admin to check the jobs in the processing queues.`,
|
|
657
|
+
name: 'Integrations',
|
|
658
|
+
description: `Find integrations configurations.`,
|
|
554
659
|
},
|
|
555
660
|
{
|
|
556
661
|
name: 'Super admins',
|
|
@@ -681,6 +786,10 @@ because it has a predetermined life cycle. The following endpoints update an exp
|
|
|
681
786
|
|
|
682
787
|
Once created, sales representatives can be associated to parcel shops.`,
|
|
683
788
|
},
|
|
789
|
+
{
|
|
790
|
+
name: 'Historic records',
|
|
791
|
+
description: `Find historic records.`,
|
|
792
|
+
},
|
|
684
793
|
];
|
|
685
794
|
|
|
686
795
|
const headers = {
|
|
@@ -932,6 +1041,10 @@ openApiSpec.components = {
|
|
|
932
1041
|
timezoneNames: timezoneNames(),
|
|
933
1042
|
representative: representative(),
|
|
934
1043
|
zone: zone(),
|
|
1044
|
+
networkHistoricRecord: networkHistoricRecord(),
|
|
1045
|
+
shopHistoricRecord: shopHistoricRecord(),
|
|
1046
|
+
expeditionHistoricRecord: expeditionHistoricRecord(),
|
|
1047
|
+
integration: integration(),
|
|
935
1048
|
},
|
|
936
1049
|
};
|
|
937
1050
|
|
|
@@ -1171,97 +1284,28 @@ ${securitySchemes.superAdminRole}`,
|
|
|
1171
1284
|
},
|
|
1172
1285
|
},
|
|
1173
1286
|
},
|
|
1174
|
-
'/
|
|
1287
|
+
'/integrations/find': {
|
|
1175
1288
|
post: {
|
|
1176
|
-
tags: ['
|
|
1177
|
-
summary: '[S] Find
|
|
1289
|
+
tags: ['Integrations'],
|
|
1290
|
+
summary: '[S] Find',
|
|
1178
1291
|
description: `
|
|
1179
|
-
Finds the
|
|
1180
|
-
|
|
1181
|
-
The \`payload\` property of the job contains the created or updated network.
|
|
1292
|
+
Finds all the integrations of the API and what networks they apply to.
|
|
1182
1293
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
requestBody: {
|
|
1186
|
-
content: { 'application/json': { schema: findJobsRequest() } },
|
|
1187
|
-
required: true,
|
|
1188
|
-
},
|
|
1189
|
-
responses: {
|
|
1190
|
-
' 200': {
|
|
1191
|
-
description: 'Contains the found jobs.',
|
|
1192
|
-
content: { 'application/json': { schema: findNetworksJobsResponse() } },
|
|
1193
|
-
},
|
|
1194
|
-
' 400': responses.badRequest,
|
|
1195
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
1196
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
1197
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
1198
|
-
' 401 ': responses.unauthorized,
|
|
1199
|
-
' 403': responses.forbidden,
|
|
1200
|
-
' 415': responses.unsupportedMediaType,
|
|
1201
|
-
' 500': responses.internalServerError,
|
|
1202
|
-
},
|
|
1203
|
-
},
|
|
1204
|
-
},
|
|
1205
|
-
'/jobs/findShops': {
|
|
1206
|
-
post: {
|
|
1207
|
-
tags: ['Background jobs'],
|
|
1208
|
-
summary: '[S] Find shop jobs',
|
|
1209
|
-
description: `
|
|
1210
|
-
Finds the status of background jobs related to shops.
|
|
1211
|
-
|
|
1212
|
-
The \`payload\` property of the job contains the created or updated shop.
|
|
1294
|
+
To see what each integration actually does read that integration documentation in the [integrations](#tag/Integrations-introduction)
|
|
1295
|
+
section.
|
|
1213
1296
|
|
|
1214
|
-
${
|
|
1215
|
-
${securitySchemes.superAdminRole}`,
|
|
1216
|
-
requestBody: {
|
|
1217
|
-
content: { 'application/json': { schema: findJobsRequest() } },
|
|
1218
|
-
required: true,
|
|
1219
|
-
},
|
|
1220
|
-
responses: {
|
|
1221
|
-
' 200': {
|
|
1222
|
-
description: 'Contains the found jobs.',
|
|
1223
|
-
content: { 'application/json': { schema: findShopsJobsResponse() } },
|
|
1224
|
-
},
|
|
1225
|
-
' 400': responses.badRequest,
|
|
1226
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
1227
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
1228
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
1229
|
-
' 401 ': responses.unauthorized,
|
|
1230
|
-
' 403': responses.forbidden,
|
|
1231
|
-
' 415': responses.unsupportedMediaType,
|
|
1232
|
-
' 500': responses.internalServerError,
|
|
1233
|
-
},
|
|
1234
|
-
},
|
|
1235
|
-
},
|
|
1236
|
-
'/jobs/findExpeditions': {
|
|
1237
|
-
post: {
|
|
1238
|
-
tags: ['Background jobs'],
|
|
1239
|
-
summary: '[S] Find expedition jobs',
|
|
1240
|
-
description: `
|
|
1241
|
-
Finds the status of background jobs related to expeditions.
|
|
1242
|
-
|
|
1243
|
-
The \`payload\` property of the job contains the \`_id\` of the affected expedition and an additional property that depends on the kind of job:
|
|
1244
|
-
|
|
1245
|
-
| Payload property | Type of job | Source |
|
|
1246
|
-
| :--- | :--- | :--- |
|
|
1247
|
-
| receiveFromDriver | An expedition has been received from a driver | Request to [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) |
|
|
1248
|
-
| receiveFromCustomer | An expedition has been received from a customer | Request to [receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) |
|
|
1249
|
-
| giveToCustomer | An expedition has been given to the customer | Request to [giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) |
|
|
1250
|
-
| giveToDriver | An expedition has been given to the driver | Request to [giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) |
|
|
1251
|
-
| expirationReminder | A reminder to pickup an expedition needs to be sent | Daily background check for expiration reminders |
|
|
1252
|
-
| expired | An expedition has expired and needs to be retired by the driver | Daily background check for expired expeditions |
|
|
1253
|
-
| price | An expedition price has been calculated or has changed | Request to [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post), [receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post), or [update](#tag/Expeditions/paths/~1expeditions~1update/post) |
|
|
1297
|
+
${descriptions.findLimitTip}
|
|
1254
1298
|
|
|
1255
1299
|
${securitySchemes.tokens}
|
|
1256
1300
|
${securitySchemes.superAdminRole}`,
|
|
1257
1301
|
requestBody: {
|
|
1258
|
-
content: { 'application/json': { schema:
|
|
1302
|
+
content: { 'application/json': { schema: findIntegrationsRequest() } },
|
|
1259
1303
|
required: true,
|
|
1260
1304
|
},
|
|
1261
1305
|
responses: {
|
|
1262
1306
|
' 200': {
|
|
1263
|
-
description: 'Contains the found
|
|
1264
|
-
content: { 'application/json': { schema:
|
|
1307
|
+
description: 'Contains the found integrations.',
|
|
1308
|
+
content: { 'application/json': { schema: findIntegrationsResponse() } },
|
|
1265
1309
|
},
|
|
1266
1310
|
' 400': responses.badRequest,
|
|
1267
1311
|
' 401': responses.invalidUserInCookieOrHeader,
|
|
@@ -2295,11 +2339,16 @@ ${descriptions.createIdIsOptional}
|
|
|
2295
2339
|
|
|
2296
2340
|
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2297
2341
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2342
|
+
An expedition can be associated on creation to either a shop or a network:
|
|
2343
|
+
|
|
2344
|
+
- Provide a shop when it is known at which shop it is going to be received. That shop network will be inserted automatically.
|
|
2345
|
+
- Provide a network when it can be received at any shop in it. When a shop receives it, that shop will be added to the expedition.
|
|
2346
|
+
|
|
2347
|
+
If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, and if it is not enabled the API
|
|
2301
2348
|
will return a \`500 ShopNotEnabledError\`.
|
|
2302
2349
|
|
|
2350
|
+
If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
|
|
2351
|
+
|
|
2303
2352
|
The \`status.code\` of a new expedition cannot be specified and it will always be \`incoming\`.
|
|
2304
2353
|
|
|
2305
2354
|
${securitySchemes.tokens}
|
|
@@ -2324,25 +2373,59 @@ ${securitySchemes.superAdminRole}`,
|
|
|
2324
2373
|
' 500 ': responses.expeditionAlreadyExists,
|
|
2325
2374
|
' 500 ': responses.shopDoesNotExist,
|
|
2326
2375
|
' 500 ': responses.shopNotEnabled,
|
|
2376
|
+
' 500 ': responses.networkDoesNotExist,
|
|
2327
2377
|
},
|
|
2328
2378
|
},
|
|
2329
2379
|
},
|
|
2330
2380
|
'/expeditions/find': {
|
|
2331
2381
|
post: {
|
|
2332
2382
|
tags: ['Expeditions'],
|
|
2333
|
-
summary: '[
|
|
2383
|
+
summary: '[S] Find',
|
|
2384
|
+
description: `
|
|
2385
|
+
Finds expeditions by one of several filters.
|
|
2386
|
+
|
|
2387
|
+
${descriptions.findLimitTip}
|
|
2388
|
+
|
|
2389
|
+
To find expeditions not assigned to a specific shop use the 'no shop' queries.
|
|
2390
|
+
|
|
2391
|
+
${securitySchemes.tokens}
|
|
2392
|
+
${securitySchemes.anyRole}`,
|
|
2393
|
+
requestBody: {
|
|
2394
|
+
content: { 'application/json': { schema: findExpeditionsSuperAdminRequest() } },
|
|
2395
|
+
required: true,
|
|
2396
|
+
},
|
|
2397
|
+
responses: {
|
|
2398
|
+
' 200': {
|
|
2399
|
+
description: 'Contains the found expeditions.',
|
|
2400
|
+
content: { 'application/json': { schema: findExpeditionsResponse() } },
|
|
2401
|
+
},
|
|
2402
|
+
' 400': responses.badRequest,
|
|
2403
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2404
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2405
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2406
|
+
' 401 ': responses.unauthorized,
|
|
2407
|
+
' 403': responses.forbidden,
|
|
2408
|
+
' 415': responses.unsupportedMediaType,
|
|
2409
|
+
' 500': responses.internalServerError,
|
|
2410
|
+
},
|
|
2411
|
+
},
|
|
2412
|
+
},
|
|
2413
|
+
'/expeditions/find ': {
|
|
2414
|
+
post: {
|
|
2415
|
+
tags: ['Expeditions'],
|
|
2416
|
+
summary: '[NU] Find',
|
|
2334
2417
|
description: `
|
|
2335
2418
|
Finds expeditions by one of several filters.
|
|
2336
2419
|
|
|
2337
2420
|
${descriptions.findLimitTip}
|
|
2338
2421
|
|
|
2339
|
-
|
|
2340
|
-
|
|
2422
|
+
Both roles can find by the same filters but the results will be limited to their network or shop, so for example if a shop user finds
|
|
2423
|
+
by \`_id\` and the expedition is from another network or shop, the find will return no results.
|
|
2341
2424
|
|
|
2342
2425
|
${securitySchemes.tokens}
|
|
2343
2426
|
${securitySchemes.anyRole}`,
|
|
2344
2427
|
requestBody: {
|
|
2345
|
-
content: { 'application/json': { schema:
|
|
2428
|
+
content: { 'application/json': { schema: findExpeditionsNetworkAdminAndShopUserRequest() } },
|
|
2346
2429
|
required: true,
|
|
2347
2430
|
},
|
|
2348
2431
|
responses: {
|
|
@@ -2436,7 +2519,7 @@ Scan a barcode or QR code and find the appropriate expedition.
|
|
|
2436
2519
|
|
|
2437
2520
|
It can return:
|
|
2438
2521
|
|
|
2439
|
-
- \`ok\`: the barcode or QR match a single expedition from the same shop
|
|
2522
|
+
- \`ok\`: the barcode or QR match a single expedition from the **same shop** or from the same network but **no shop**.
|
|
2440
2523
|
- \`notFound\`: the expedition does not exist.
|
|
2441
2524
|
- \`anotherShop\`: the expedition belongs to another shop.
|
|
2442
2525
|
- \`multipleResults\`: the barcode or QR match more than one expedition (e.g. shared reference). Try scanning another barcode.
|
|
@@ -2482,6 +2565,8 @@ and some are not. The result for each expedition depends on its situation:
|
|
|
2482
2565
|
| not found | - | not found | - | - |
|
|
2483
2566
|
| server error | - | error | - | - |
|
|
2484
2567
|
|
|
2568
|
+
If the received expedition is not associated to a shop this operation will associate it to the shop receiving it.
|
|
2569
|
+
|
|
2485
2570
|
${securitySchemes.tokens}
|
|
2486
2571
|
${securitySchemes.shopUserRole}`,
|
|
2487
2572
|
requestBody: {
|
|
@@ -2514,6 +2599,8 @@ Receives all the \`incoming\` expeditions for this shop.
|
|
|
2514
2599
|
Calling this endpoint is equivalent to calling [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) with all
|
|
2515
2600
|
the \`_ids\` of the \`incoming\` expeditions. It returns how many expeditions have been processed.
|
|
2516
2601
|
|
|
2602
|
+
If the received expedition is not associated to a shop this operation will associate it to the shop receiving it.
|
|
2603
|
+
|
|
2517
2604
|
${securitySchemes.tokens}
|
|
2518
2605
|
${securitySchemes.shopUserRole}`,
|
|
2519
2606
|
requestBody: {
|
|
@@ -2554,6 +2641,8 @@ and some are not. The result for each expedition depends on its situation:
|
|
|
2554
2641
|
| not found | - | not found | - | - |
|
|
2555
2642
|
| server error | - | error | - | - |
|
|
2556
2643
|
|
|
2644
|
+
If the received expedition is not associated to a shop this operation will associate it to the shop receiving it.
|
|
2645
|
+
|
|
2557
2646
|
${securitySchemes.tokens}
|
|
2558
2647
|
${securitySchemes.shopUserRole}`,
|
|
2559
2648
|
requestBody: {
|
|
@@ -2915,6 +3004,40 @@ ${securitySchemes.superAdminRole}`,
|
|
|
2915
3004
|
},
|
|
2916
3005
|
},
|
|
2917
3006
|
},
|
|
3007
|
+
'/history/find': {
|
|
3008
|
+
post: {
|
|
3009
|
+
tags: ['Historic records'],
|
|
3010
|
+
summary: '[S] Find',
|
|
3011
|
+
description: `
|
|
3012
|
+
Finds historic records of networks, shops and expeditions.
|
|
3013
|
+
|
|
3014
|
+
You can find all the records for a single network, shop or expedition, or all the records processed by a single integration and with a
|
|
3015
|
+
specific result, for example \`failed\`.
|
|
3016
|
+
|
|
3017
|
+
${descriptions.findLimitTip}
|
|
3018
|
+
|
|
3019
|
+
${securitySchemes.tokens}
|
|
3020
|
+
${securitySchemes.superAdminRole}`,
|
|
3021
|
+
requestBody: {
|
|
3022
|
+
content: { 'application/json': { schema: findHistoricRecordsRequest() } },
|
|
3023
|
+
required: true,
|
|
3024
|
+
},
|
|
3025
|
+
responses: {
|
|
3026
|
+
' 200': {
|
|
3027
|
+
description: 'Contains the found historic records.',
|
|
3028
|
+
content: { 'application/json': { schema: findHistoricRecordsResponse() } },
|
|
3029
|
+
},
|
|
3030
|
+
' 400': responses.badRequest,
|
|
3031
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
3032
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
3033
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
3034
|
+
' 401 ': responses.unauthorized,
|
|
3035
|
+
' 403': responses.forbidden,
|
|
3036
|
+
' 415': responses.unsupportedMediaType,
|
|
3037
|
+
' 500': responses.internalServerError,
|
|
3038
|
+
},
|
|
3039
|
+
},
|
|
3040
|
+
},
|
|
2918
3041
|
};
|
|
2919
3042
|
|
|
2920
3043
|
module.exports = openApiSpec;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gls_spain/gps-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "28.0.1",
|
|
4
4
|
"description": "Errors, schemas and documentation for the Parcel Shops project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@gls_spain/ajv-options": "^1.1.0",
|
|
50
50
|
"@gls_spain/common-errors": "^1.0.0",
|
|
51
51
|
"@gls_spain/common-json-schemas": "^1.1.0",
|
|
52
|
+
"@gls_spain/mongodb": "^1.0.3",
|
|
52
53
|
"@gls_spain/winston-transports": "^1.0.0",
|
|
53
54
|
"lodash": "^4.17.15",
|
|
54
55
|
"winston": "^3.2.1",
|