@gls_spain/gps-common 30.0.0 → 31.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.
@@ -3,8 +3,6 @@
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
5
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/schemas/definitions/defaults.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/defaults.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/schemas/definitions/historic-records.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/historic-records.js" afterDir="false" />
8
6
  </list>
9
7
  <option name="SHOW_DIALOG" value="false" />
10
8
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -505,7 +503,25 @@
505
503
  <workItem from="1584291295326" duration="639000" />
506
504
  <workItem from="1584346563581" duration="3782000" />
507
505
  <workItem from="1584431456137" duration="91000" />
508
- <workItem from="1584450804621" duration="5554000" />
506
+ <workItem from="1584450804621" duration="5722000" />
507
+ <workItem from="1584513827612" duration="583000" />
508
+ <workItem from="1584535774211" duration="830000" />
509
+ <workItem from="1584549919776" duration="870000" />
510
+ <workItem from="1584562718815" duration="955000" />
511
+ <workItem from="1584605080897" duration="682000" />
512
+ <workItem from="1584606282127" duration="1061000" />
513
+ <workItem from="1584633136033" duration="507000" />
514
+ <workItem from="1584637678190" duration="381000" />
515
+ <workItem from="1584696764636" duration="29000" />
516
+ <workItem from="1584696799883" duration="566000" />
517
+ <workItem from="1584699365776" duration="432000" />
518
+ <workItem from="1584726228318" duration="581000" />
519
+ <workItem from="1584731931065" duration="707000" />
520
+ <workItem from="1584741921542" duration="1232000" />
521
+ <workItem from="1584794887440" duration="928000" />
522
+ <workItem from="1584814298765" duration="350000" />
523
+ <workItem from="1584822264041" duration="1155000" />
524
+ <workItem from="1584861318833" duration="2806000" />
509
525
  </task>
510
526
  <servers />
511
527
  </component>
@@ -545,6 +561,10 @@
545
561
  </option>
546
562
  </component>
547
563
  <component name="WindowStateProjectService">
564
+ <state x="712" y="322" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog" timestamp="1584696790922">
565
+ <screen x="0" y="23" width="2048" height="1129" />
566
+ </state>
567
+ <state x="712" y="322" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1584696790922" />
548
568
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1584283363756">
549
569
  <screen x="0" y="23" width="2048" height="1129" />
550
570
  </state>
@@ -557,30 +577,30 @@
557
577
  <screen x="0" y="23" width="2048" height="1129" />
558
578
  </state>
559
579
  <state x="606" y="280" key="EditFileWatcherDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1580283934403" />
560
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1584466909333">
580
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1584864247635">
561
581
  <screen x="0" y="23" width="2048" height="1129" />
562
582
  </state>
563
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1584466909333" />
564
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1584466909333">
583
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1584864247635" />
584
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1584864247634">
565
585
  <screen x="0" y="23" width="2048" height="1129" />
566
586
  </state>
567
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1584466909333" />
568
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1584466909333">
587
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1584864247634" />
588
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1584864247634">
569
589
  <screen x="0" y="23" width="2048" height="1129" />
570
590
  </state>
571
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1584466909333" />
572
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1584466909333">
591
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1584864247634" />
592
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1584864247634">
573
593
  <screen x="0" y="23" width="2048" height="1129" />
574
594
  </state>
575
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1584466909333" />
595
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1584864247634" />
576
596
  <state x="0" y="23" width="2048" height="1129" key="SettingsEditor" timestamp="1580283935326">
577
597
  <screen x="0" y="23" width="2048" height="1129" />
578
598
  </state>
579
599
  <state x="0" y="23" width="2048" height="1129" key="SettingsEditor/0.23.2048.1129@0.23.2048.1129" timestamp="1580283935326" />
580
- <state x="1351" y="124" width="697" height="951" key="find.popup" timestamp="1584363161427">
600
+ <state x="1351" y="124" width="697" height="951" key="find.popup" timestamp="1584747151804">
581
601
  <screen x="0" y="23" width="2048" height="1129" />
582
602
  </state>
583
- <state x="1351" y="124" width="697" height="951" key="find.popup/0.23.2048.1129@0.23.2048.1129" timestamp="1584363161427" />
603
+ <state x="1351" y="124" width="697" height="951" key="find.popup/0.23.2048.1129@0.23.2048.1129" timestamp="1584747151804" />
584
604
  <state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1584284016106">
585
605
  <screen x="0" y="23" width="2048" height="1129" />
586
606
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ # [31.0.0](https://github.com/GLS-Spain/gps-common/compare/v30.0.1...v31.0.0) (2020-03-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * improve documentation ([81291a0](https://github.com/GLS-Spain/gps-common/commit/81291a053380f338c96bdf06a47fd4a1799bea54))
7
+ * remove expedition.derivation.packages ([8765ca9](https://github.com/GLS-Spain/gps-common/commit/8765ca98d1b0b76681827fcf6f1ec3365d1172f3))
8
+ * remove pod network, shop and expeditions ([8407e04](https://github.com/GLS-Spain/gps-common/commit/8407e04571ec80ecb6d2023a8ebec18042f8fe37))
9
+
10
+
11
+ ### BREAKING CHANGES
12
+
13
+ * simplify pod schema, now can only be found by _id
14
+ * removed expedition.derivation.packages
15
+
16
+ ## [30.0.1](https://github.com/GLS-Spain/gps-common/compare/v30.0.0...v30.0.1) (2020-03-19)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * fix defaults denormalization in network and shop schemas ([d7984fb](https://github.com/GLS-Spain/gps-common/commit/d7984fb32b4db683777b7587b989a2f464c2c29b))
22
+
1
23
  # [30.0.0](https://github.com/GLS-Spain/gps-common/compare/v29.0.0...v30.0.0) (2020-03-17)
2
24
 
3
25
 
@@ -176,7 +176,7 @@ You can see what's new and the latest changes to the API in the [changelog](/hel
176
176
  openApiSpec.servers = [
177
177
  {
178
178
  url: 'http://localhost:3001',
179
- description: 'Localhost API connected to localhost or staging DB',
179
+ description: 'Localhost API connected to localhost DB or staging DB',
180
180
  },
181
181
  {
182
182
  url: 'https://api.gps.albo.dev',
@@ -199,7 +199,7 @@ openApiSpec['x-tagGroups'] = [
199
199
  },
200
200
  {
201
201
  name: 'RESOURCES',
202
- tags: ['Defaults', 'Super admin', 'Network', 'Network admin', 'Zone', 'Shop', 'Shop user', 'Expedition', 'Pod', 'Sales representative'],
202
+ tags: ['Defaults', 'Super admin', 'Network', 'Network admin', 'Zone', 'Sales representative', 'Shop', 'Shop user', 'Expedition', 'Pod'],
203
203
  },
204
204
  {
205
205
  name: 'HISTORIC RECORDS',
@@ -441,8 +441,8 @@ expeditions they have access to.
441
441
  name: 'Historic records introduction',
442
442
  'x-displayName': 'Historic records',
443
443
  description: `
444
- Every time the API creates, updates or deletes a resource, it stores a historic record of the action including the full document as it was
445
- after the action, the time it occurred and the user that made it.
444
+ Every time the API creates, updates or deletes a resource, it stores a historic record of: the action, the full document as it was after
445
+ the action, the time it occurred and the user that made it.
446
446
 
447
447
  The only exception are \`pods\` which have no records because they are created when their expeditions are delivered and they are never
448
448
  updated or deleted.
@@ -485,8 +485,8 @@ shop also stores the name of its network in its \`network.name\` field.
485
485
  This is called denormalization and it saves a lot of queries for the full dependency each time these fields are needed. The downside is
486
486
  that an update in the dependency requires updating the dependents too. There are two strategies to do this:
487
487
 
488
- - **Strict consistency**: the dependents are updated at the same time as the dependency. The update endpoint may become very slow if there are
489
- thousands or millions of dependents, and it also requires a database transaction.
488
+ - **Strict consistency**: the dependents are updated at the same time as the dependency. The update endpoint may become very slow if there
489
+ are thousands or millions of dependents.
490
490
  - **Eventual consistency**: only the dependency is updated immediately, and the dependents are updated later in the background. The update
491
491
  endpoint returns very fast but for a few seconds the dependents are outdated.
492
492
 
@@ -503,7 +503,7 @@ This expiration information includes two kind of values that need to be checked
503
503
  to be reminded to pick up the expedition, and the moment the expedition expires.
504
504
 
505
505
  The API periodically checks these moments and when the time comes it updates the expedition and stores an historic record of the update. It
506
- is then the responsability of some integration to respond to that historic record. See [integrations](#tag/Integrations-introduction)
506
+ is then the responsibility of some integration to respond to that historic record. See [integrations](#tag/Integrations-introduction)
507
507
  for more information.`,
508
508
  },
509
509
  {
@@ -535,19 +535,19 @@ This API is integrated with the main systems of GLS Spain. The integration goes
535
535
  This integration configuration can be found using the [find integrations endpoint](#tag/Integrations/paths/~1integrations~1find/post),
536
536
  under the \`GLS Spain\` name. Its \`networks\` field lists the networks it applies to.
537
537
 
538
- The following table lists all the possible events along with the historic record that causes them to be sent:
538
+ The following table lists all the possible events along with the situations that causes them to be sent:
539
539
 
540
- | Event | Record type | Record action | Record details |
541
- | :--- | :--- | :--- | :--- |
542
- | upsert network | \`network\` | \`update\` | - |
543
- | upsert shop | \`shop\` | \`create\` or \`update\` | - |
544
- | receive from driver | \`expedition\` | \`update\` | \`receiveFromDriver\` |
545
- | receive from customer | \`expedition\` | \`update\` | \`receiveFromCustomer\` |
546
- | give to customer | \`expedition\` | \`update\` | \`giveToCustomer\` |
547
- | give to driver | \`expedition\` | \`update\` | \`giveToDriver\` |
548
- | expiration reminder | \`expedition\` | \`update\` | \`expirationReminder\` |
549
- | expired | \`expedition\` | \`update\` | \`expired\` |
550
- | price | \`expedition\` | \`update\` | \`price\` |
540
+ | Event | Resource | Situation |
541
+ | :--- | :--- | :--- |
542
+ | upsert network | \`network\` | updated |
543
+ | upsert shop | \`shop\` | created or updated |
544
+ | receive from driver | \`expedition\` | received from driver |
545
+ | receive from customer | \`expedition\` | received from customer |
546
+ | give to customer | \`expedition\` | given to customer |
547
+ | give to driver | \`expedition\` | given to driver |
548
+ | expiration reminder | \`expedition\` | a pickup reminder needs to be sent |
549
+ | expired | \`expedition\` | has expired |
550
+ | price | \`expedition\` | received from driver or customer<br/>price changed after reception |
551
551
 
552
552
  The following are the request bodies sent for each event:
553
553
 
@@ -2664,11 +2664,11 @@ Scan a barcode or QR code and find the appropriate expedition.
2664
2664
 
2665
2665
  It can return:
2666
2666
 
2667
- - \`ok\`: the barcode or QR match a single expedition from the **same shop** or from the same network but **no shop**.
2668
- - \`notFound\`: the expedition does not exist.
2669
- - \`anotherShop\`: the expedition belongs to another shop.
2670
- - \`multipleResults\`: the barcode or QR match more than one expedition (e.g. shared reference). Try scanning another barcode.
2671
- - \`error\`: any other kind of error. You should retry the operation.
2667
+ - \`ok\`: when the barcode or QR match a single expedition from the **same shop** or from the same network but **no shop**.
2668
+ - \`notFound\`: when the expedition does not exist.
2669
+ - \`anotherShop\`: when the expedition belongs to another shop.
2670
+ - \`multipleResults\`: when the barcode or QR match more than one expedition (e.g. shared reference). Try scanning another barcode.
2671
+ - \`error\`: on any other kind of error. You should retry the operation.
2672
2672
 
2673
2673
  ${securitySchemes.tokens}
2674
2674
  ${securitySchemes.shopUserRole}`,
@@ -2702,13 +2702,13 @@ Receives expeditions from a driver, changing their status code and adding more p
2702
2702
  Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
2703
2703
  and some are not. The result for each expedition depends on its situation:
2704
2704
 
2705
- | Expedition | Type + Status code | Result | New status code | New status properties |
2706
- | :--- | :--- | :--- | :--- | :--- |
2707
- | found in same shop | delivery + incoming | ok | inShop | receivedFrom, expiration |
2708
- | found in same shop | any other combination | another situation | - | - |
2709
- | found in another shop | - | another shop | - | - |
2710
- | not found | - | not found | - | - |
2711
- | server error | - | error | - | - |
2705
+ | Expedition | Type + Status code | Result | New status code | New status properties |
2706
+ | :--- | :--- | :--- | :--- | :--- |
2707
+ | found in no shop<br/>found in same shop | delivery + incoming | ok | inShop | receivedFrom, expiration |
2708
+ | found in same shop | any other combination | another situation | - | - |
2709
+ | found in another shop | - | another shop | - | - |
2710
+ | not found | - | not found | - | - |
2711
+ | server error | - | error | - | - |
2712
2712
 
2713
2713
  If the received expedition is not associated to a shop this operation will associate it to the shop receiving it.
2714
2714
 
@@ -2778,13 +2778,13 @@ Receives expeditions from a customer, changing their status code and adding more
2778
2778
  Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
2779
2779
  and some are not. The result for each expedition depends on its situation:
2780
2780
 
2781
- | Expedition | Type + Status code | Result | New status code | New status properties |
2782
- | :--- | :--- | :--- | :--- | :--- |
2783
- | found in same shop | pickup + incoming | ok | inShop | receivedFrom |
2784
- | found in same shop | any other combination | another situation | - | - |
2785
- | found in another shop | - | another shop | - | - |
2786
- | not found | - | not found | - | - |
2787
- | server error | - | error | - | - |
2781
+ | Expedition | Type + Status code | Result | New status code | New status properties |
2782
+ | :--- | :--- | :--- | :--- | :--- |
2783
+ | found in no shop<br/>found in same shop | pickup + incoming | ok | inShop | receivedFrom |
2784
+ | found in same shop | any other combination | another situation | - | - |
2785
+ | found in another shop | - | another shop | - | - |
2786
+ | not found | - | not found | - | - |
2787
+ | server error | - | error | - | - |
2788
2788
 
2789
2789
  If the received expedition is not associated to a shop this operation will associate it to the shop receiving it.
2790
2790
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "30.0.0",
3
+ "version": "31.0.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -183,20 +183,8 @@ const expedition = () => ({
183
183
  additionalProperties: false,
184
184
  },
185
185
  settings: derivationSettings(),
186
- packages: {
187
- type: 'array',
188
- items: {
189
- type: 'object',
190
- properties: {
191
- number: { type: 'integer' },
192
- weight: { type: 'number' },
193
- },
194
- required: ['number', 'weight'],
195
- additionalProperties: false,
196
- },
197
- },
198
186
  },
199
- required: ['totalPrice', 'settings', 'packages'],
187
+ required: ['totalPrice', 'settings'],
200
188
  additionalProperties: false,
201
189
  description: 'only available for deliveries and pickups after reception at the shop',
202
190
  },
@@ -23,7 +23,12 @@ const network = () => ({
23
23
  createdAt: datetime(),
24
24
  updatedAt: datetime(),
25
25
  deletable: { type: 'boolean' },
26
- defaults: defaults(),
26
+ defaults: {
27
+ type: 'object',
28
+ properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
29
+ required: ['derivationSettings', 'expirationSettings'],
30
+ additionalProperties: false,
31
+ },
27
32
  name: { type: 'string', trim: true },
28
33
  contacts: {
29
34
  type: 'array',
@@ -1,6 +1,5 @@
1
- const { uuid, objectWithUuid, datetime, findRequest, findResponse, mergeSchemas } = require('@gls_spain/common-json-schemas');
1
+ const { uuid, datetime, findRequest, findResponse } = require('@gls_spain/common-json-schemas');
2
2
  const { findById } = require('./common');
3
- const { objectWithExpeditionId } = require('./expeditions');
4
3
 
5
4
  const pod = () => ({
6
5
  title: 'pod',
@@ -10,23 +9,13 @@ const pod = () => ({
10
9
  createdAt: datetime(),
11
10
  updatedAt: datetime(),
12
11
  deletable: { type: 'boolean' },
13
- network: objectWithUuid(),
14
- shop: objectWithUuid(),
15
- expeditions: {
16
- type: 'object',
17
- properties: { _ids: { type: 'array', items: uuid(), uniqueItems: true } },
18
- required: ['_ids'],
19
- additionalProperties: false,
20
- },
21
12
  image: { type: 'string', contentMediaType: 'image/jpg', contentEncoding: 'base64' },
22
13
  },
23
- required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'network', 'shop', 'expeditions', 'image'],
14
+ required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'image'],
24
15
  additionalProperties: false,
25
16
  });
26
17
 
27
- const findByExpedition = () => mergeSchemas(objectWithExpeditionId(), { title: 'find by expedition' });
28
-
29
- const findPodsRequest = () => findRequest({ oneOf: [findById(), findByExpedition()] });
18
+ const findPodsRequest = () => findRequest(findById());
30
19
 
31
20
  const findPodsResponse = () => findResponse(pod());
32
21
 
@@ -92,7 +92,12 @@ const shop = () => ({
92
92
  createdAt: datetime(),
93
93
  updatedAt: datetime(),
94
94
  deletable: { type: 'boolean' },
95
- defaults: defaults(),
95
+ defaults: {
96
+ type: 'object',
97
+ properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
98
+ required: ['derivationSettings', 'expirationSettings'],
99
+ additionalProperties: false,
100
+ },
96
101
  network: {
97
102
  type: 'object',
98
103
  properties: { ...pickProperties(network(), ['_id', 'name', 'derivationSettings', 'expirationSettings']) },