@gls_spain/gps-common 32.4.0 → 32.5.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.
@@ -2,12 +2,12 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
- <change afterPath="$PROJECT_DIR$/errors/CountersDoNotExistError.js" afterDir="false" />
6
- <change afterPath="$PROJECT_DIR$/schemas/definitions/counters.js" afterDir="false" />
5
+ <change afterPath="$PROJECT_DIR$/errors/NetworkCannotBeUpdatedError.js" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/errors/ShopCannotBeUpdatedError.js" afterDir="false" />
7
7
  <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
8
8
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/schemas/definitions/init.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/init.js" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/networks.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/networks.js" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/shops.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/shops.js" afterDir="false" />
11
11
  </list>
12
12
  <option name="SHOW_DIALOG" value="false" />
13
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -568,7 +568,8 @@
568
568
  <workItem from="1591864959459" duration="63000" />
569
569
  <workItem from="1591865082734" duration="29000" />
570
570
  <workItem from="1594828405112" duration="147000" />
571
- <workItem from="1594885748220" duration="3069000" />
571
+ <workItem from="1594885748220" duration="6957000" />
572
+ <workItem from="1594925133162" duration="587000" />
572
573
  </task>
573
574
  <servers />
574
575
  </component>
@@ -607,21 +608,21 @@
607
608
  <option name="oldMeFiltersMigrated" value="true" />
608
609
  </component>
609
610
  <component name="WindowStateProjectService">
610
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1594890828677">
611
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1594925626891">
611
612
  <screen x="0" y="23" width="2048" height="1129" />
612
613
  </state>
613
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1594890828677" />
614
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1594890828676">
614
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1594925626891" />
615
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1594925626891">
615
616
  <screen x="0" y="23" width="2048" height="1129" />
616
617
  </state>
617
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1594890828676" />
618
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1594890828676">
618
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1594925626891" />
619
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1594925626890">
619
620
  <screen x="0" y="23" width="2048" height="1129" />
620
621
  </state>
621
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1594890828676" />
622
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1594890828677">
622
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1594925626890" />
623
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1594925626891">
623
624
  <screen x="0" y="23" width="2048" height="1129" />
624
625
  </state>
625
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1594890828677" />
626
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1594925626891" />
626
627
  </component>
627
628
  </project>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [32.5.0](https://github.com/GLS-Spain/gps-common/compare/v32.4.0...v32.5.0) (2020-07-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * add readonly to networks and shops, and network and shop cannot be updated errors ([8ba03cc](https://github.com/GLS-Spain/gps-common/commit/8ba03cce1e8495a7540e2726c44ddf1af7427dd5))
7
+
1
8
  # [32.4.0](https://github.com/GLS-Spain/gps-common/compare/v32.3.0...v32.4.0) (2020-07-16)
2
9
 
3
10
 
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class NetworkCannotBeUpdatedError extends DatabaseError {
4
+ constructor(message = 'Network cannot be updated.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'NetworkCannotBeUpdatedError';
8
+ }
9
+ }
10
+
11
+ module.exports = NetworkCannotBeUpdatedError;
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class ShopCannotBeUpdatedError extends DatabaseError {
4
+ constructor(message = 'Shop cannot be updated.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'ShopCannotBeUpdatedError';
8
+ }
9
+ }
10
+
11
+ module.exports = ShopCannotBeUpdatedError;
package/errors/index.js CHANGED
@@ -5,10 +5,12 @@ const UserCannotBeUpdatedError = require('./UserCannotBeUpdatedError');
5
5
  const UserCannotBeDeletedError = require('./UserCannotBeDeletedError');
6
6
  const NetworkDoesNotExistError = require('./NetworkDoesNotExistError');
7
7
  const NetworkAlreadyExistsError = require('./NetworkAlreadyExistsError');
8
+ const NetworkCannotBeUpdatedError = require('./NetworkCannotBeUpdatedError');
8
9
  const NetworkCannotBeDeletedError = require('./NetworkCannotBeDeletedError');
9
10
  const WrongNetworkError = require('./WrongNetworkError');
10
11
  const ShopDoesNotExistError = require('./ShopDoesNotExistError');
11
12
  const ShopAlreadyExistsError = require('./ShopAlreadyExistsError');
13
+ const ShopCannotBeUpdatedError = require('./ShopCannotBeUpdatedError');
12
14
  const ShopCannotBeDeletedError = require('./ShopCannotBeDeletedError');
13
15
  const ShopNotEnabledError = require('./ShopNotEnabledError');
14
16
  const WrongShopError = require('./WrongShopError');
@@ -34,10 +36,12 @@ const errorsNames = {
34
36
  UserCannotBeDeletedError: 'UserCannotBeDeletedError',
35
37
  NetworkDoesNotExistError: 'NetworkDoesNotExistError',
36
38
  NetworkAlreadyExistsError: 'NetworkAlreadyExistsError',
39
+ NetworkCannotBeUpdatedError: 'NetworkCannotBeUpdatedError',
37
40
  NetworkCannotBeDeletedError: 'NetworkCannotBeDeletedError',
38
41
  WrongNetworkError: 'WrongNetworkError',
39
42
  ShopDoesNotExistError: 'ShopDoesNotExistError',
40
43
  ShopAlreadyExistsError: 'ShopAlreadyExistsError',
44
+ ShopCannotBeUpdatedError: 'ShopCannotBeUpdatedError',
41
45
  ShopCannotBeDeletedError: 'ShopCannotBeDeletedError',
42
46
  ShopNotEnabledError: 'ShopNotEnabledError',
43
47
  WrongShopError: 'WrongShopError',
@@ -64,10 +68,12 @@ module.exports = {
64
68
  UserCannotBeDeletedError,
65
69
  NetworkDoesNotExistError,
66
70
  NetworkAlreadyExistsError,
71
+ NetworkCannotBeUpdatedError,
67
72
  NetworkCannotBeDeletedError,
68
73
  WrongNetworkError,
69
74
  ShopDoesNotExistError,
70
75
  ShopAlreadyExistsError,
76
+ ShopCannotBeUpdatedError,
71
77
  ShopCannotBeDeletedError,
72
78
  ShopNotEnabledError,
73
79
  WrongShopError,
@@ -18,9 +18,11 @@ const {
18
18
  UserCannotBeDeletedError,
19
19
  NetworkDoesNotExistError,
20
20
  NetworkAlreadyExistsError,
21
+ NetworkCannotBeUpdatedError,
21
22
  NetworkCannotBeDeletedError,
22
23
  ShopDoesNotExistError,
23
24
  ShopAlreadyExistsError,
25
+ ShopCannotBeUpdatedError,
24
26
  ShopCannotBeDeletedError,
25
27
  ShopNotEnabledError,
26
28
  WrongPasswordError,
@@ -680,6 +682,9 @@ Networks are collections of parcel shops that belong to the same provider.
680
682
  A network that has admins or parcel shops associated to it will have its \`deletable\` property automatically set to
681
683
  \`false\` and cannot be deleted.
682
684
 
685
+ A network that has its \`readonly\` property set to \`true\` cannot be updated or have shops added to it. Readonly networks usually have
686
+ their shops come from another source like an integration.
687
+
683
688
  A network may have custom derivation and expiration settings or use the defaults defined in [config](#tag/Config):
684
689
 
685
690
  - If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
@@ -713,6 +718,9 @@ A shop is assigned to a network on creation and its network cannot be changed la
713
718
  A shop that has users or expeditions associated to it will have its \`deletable\` property automatically set to \`false\`
714
719
  and cannot be deleted.
715
720
 
721
+ A shop that has its \`readonly\` property set to \`true\` cannot be updated or have expeditions added to it. Readonly shops usually come
722
+ from another source like an integration.
723
+
716
724
  A shop may have custom derivation and expiration settings, use its network values or use the defaults defined in [config](#tag/Config):
717
725
 
718
726
  - If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
@@ -846,9 +854,11 @@ const errors = {
846
854
  userCannotBeDeleted: new UserCannotBeDeletedError(),
847
855
  networkDoesNotExist: new NetworkDoesNotExistError(),
848
856
  networkAlreadyExists: new NetworkAlreadyExistsError(),
857
+ networkCannotBeUpdated: new NetworkCannotBeUpdatedError(),
849
858
  networkCannotBeDeleted: new NetworkCannotBeDeletedError(),
850
859
  shopDoesNotExist: new ShopDoesNotExistError(),
851
860
  shopAlreadyExists: new ShopAlreadyExistsError(),
861
+ shopCannotBeUpdated: new ShopCannotBeUpdatedError(),
852
862
  shopCannotBeDeleted: new ShopCannotBeDeletedError(),
853
863
  shopNotEnabled: new ShopNotEnabledError(),
854
864
  wrongPassword: new WrongPasswordError(),
@@ -931,6 +941,10 @@ const responses = {
931
941
  description: 'The network already exists.',
932
942
  content: { 'application/json': { schema: specificHttpError(errors.networkAlreadyExists) } },
933
943
  },
944
+ networkCannotBeUpdated: {
945
+ description: 'The network cannot be updated.',
946
+ content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeUpdated) } },
947
+ },
934
948
  networkCannotBeDeleted: {
935
949
  description: 'The network cannot be deleted.',
936
950
  content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeDeleted) } },
@@ -943,6 +957,10 @@ const responses = {
943
957
  description: 'The shop already exists.',
944
958
  content: { 'application/json': { schema: specificHttpError(errors.shopAlreadyExists) } },
945
959
  },
960
+ shopCannotBeUpdated: {
961
+ description: 'The shop cannot be updated.',
962
+ content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeUpdated) } },
963
+ },
946
964
  shopCannotBeDeleted: {
947
965
  description: 'The shop cannot be deleted.',
948
966
  content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
@@ -1475,6 +1493,8 @@ ${descriptions.createIdIsOptional}
1475
1493
 
1476
1494
  ${descriptions.optionalArrayPropertiesEmptyByDefault}
1477
1495
 
1496
+ The \`readonly\` property defaults to \`false\` if not provided.
1497
+
1478
1498
  To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
1479
1499
  \`defaults\` property will be used.
1480
1500
 
@@ -1566,6 +1586,9 @@ Finds a network and updates the provided properties.
1566
1586
 
1567
1587
  ${descriptions.updateSetAddOrRemove}
1568
1588
 
1589
+ If the network has its \`readonly\` property set to \`true\` then it cannot be updated and the API will return a
1590
+ \`500 NetworkCannotBeUpdatedError\`.
1591
+
1569
1592
  The \`derivationSettings\` and \`expirationSettings\` properties can be updated with a value or with \`null\`, which will remove them. The
1570
1593
  update will propagate to the \`network\` property of all the shops in the network.
1571
1594
 
@@ -1589,6 +1612,7 @@ ${securitySchemes.superAdminRole}`,
1589
1612
  ' 415': responses.unsupportedMediaType,
1590
1613
  ' 500': responses.internalServerError,
1591
1614
  ' 500 ': responses.networkDoesNotExist,
1615
+ ' 500 ': responses.networkCannotBeUpdated,
1592
1616
  },
1593
1617
  },
1594
1618
  },
@@ -2147,8 +2171,10 @@ ${descriptions.createIdIsOptional}
2147
2171
 
2148
2172
  ${descriptions.optionalArrayPropertiesEmptyByDefault}
2149
2173
 
2150
- The \`network._id\` property that associates a shop with his network cannot be changed after creation.
2151
- If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
2174
+ The \`network._id\` property that associates a shop with his network cannot be changed after creation. If the provided network does not
2175
+ exist the API will return a \`500 NetworkDoesNotExistError\`, and if it is readonly it will return a \`500 NetworkCannotBeUpdatedError\`.
2176
+
2177
+ The \`readonly\` property defaults to \`false\` if not provided.
2152
2178
 
2153
2179
  See [shops](#tag/Shops) for information about the \`status\` property.
2154
2180
 
@@ -2175,7 +2201,8 @@ ${securitySchemes.superAdminRole}`,
2175
2201
  ' 415': responses.unsupportedMediaType,
2176
2202
  ' 500': responses.internalServerError,
2177
2203
  ' 500 ': responses.networkDoesNotExist,
2178
- ' 500 ': responses.shopAlreadyExists,
2204
+ ' 500 ': responses.networkCannotBeUpdated,
2205
+ ' 500 ': responses.shopAlreadyExists,
2179
2206
  },
2180
2207
  },
2181
2208
  },
@@ -2253,6 +2280,9 @@ Finds a shop and updates the provided properties.
2253
2280
 
2254
2281
  ${descriptions.updateSetAddOrRemove}
2255
2282
 
2283
+ If the shop has its \`readonly\` property set to \`true\` then it cannot be updated and the API will return a
2284
+ \`500 ShopCannotBeUpdatedError\`.
2285
+
2256
2286
  See [shops](#tag/Shops) for information about the \`status\` property.
2257
2287
 
2258
2288
  ${securitySchemes.tokens}
@@ -2275,6 +2305,7 @@ ${securitySchemes.superAdminRole}`,
2275
2305
  ' 415': responses.unsupportedMediaType,
2276
2306
  ' 500': responses.internalServerError,
2277
2307
  ' 500 ': responses.shopDoesNotExist,
2308
+ ' 500 ': responses.shopCannotBeUpdated,
2278
2309
  },
2279
2310
  },
2280
2311
  },
@@ -2531,8 +2562,8 @@ An expedition can be associated on creation to either a shop or a network:
2531
2562
  - Provide a shop when it is known at which shop it is going to be received. That shop network will be inserted automatically.
2532
2563
  - 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.
2533
2564
 
2534
- If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, and if it is not enabled the API
2535
- will return a \`500 ShopNotEnabledError\`.
2565
+ If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, if it is not enabled it will return a
2566
+ \`500 ShopNotEnabledError\`, and if it is readonly it will return a \`500 ShopCannotBeUpdatedError\`.
2536
2567
 
2537
2568
  If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
2538
2569
 
@@ -2560,7 +2591,8 @@ ${securitySchemes.superAdminRole}`,
2560
2591
  ' 500 ': responses.expeditionAlreadyExists,
2561
2592
  ' 500 ': responses.shopDoesNotExist,
2562
2593
  ' 500 ': responses.shopNotEnabled,
2563
- ' 500 ': responses.networkDoesNotExist,
2594
+ ' 500 ': responses.shopCannotBeUpdated,
2595
+ ' 500 ': responses.networkDoesNotExist,
2564
2596
  },
2565
2597
  },
2566
2598
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "32.4.0",
3
+ "version": "32.5.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -23,6 +23,7 @@ const network = () => ({
23
23
  createdAt: datetime(),
24
24
  updatedAt: datetime(),
25
25
  deletable: { type: 'boolean' },
26
+ readonly: { type: 'boolean', description: 'readonly networks do not allow updates or adding shops to them' },
26
27
  defaults: {
27
28
  type: 'object',
28
29
  properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
@@ -38,7 +39,7 @@ const network = () => ({
38
39
  derivationSettings: derivationSettings(),
39
40
  expirationSettings: expirationSettings(),
40
41
  },
41
- required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'defaults', 'name', 'contacts'],
42
+ required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'readonly', 'defaults', 'name', 'contacts'],
42
43
  additionalProperties: false,
43
44
  });
44
45
 
@@ -53,7 +54,16 @@ const createNetworkRequest = () =>
53
54
  createRequest({
54
55
  type: 'object',
55
56
  properties: {
56
- ...pickProperties(network(), ['_id', 'createdAt', 'name', 'contacts', 'fiscal', 'derivationSettings', 'expirationSettings']),
57
+ ...pickProperties(network(), [
58
+ '_id',
59
+ 'createdAt',
60
+ 'readonly',
61
+ 'name',
62
+ 'contacts',
63
+ 'fiscal',
64
+ 'derivationSettings',
65
+ 'expirationSettings',
66
+ ]),
57
67
  },
58
68
  required: ['name'],
59
69
  additionalProperties: false,
@@ -127,6 +127,7 @@ const shop = () => ({
127
127
  createdAt: datetime(),
128
128
  updatedAt: datetime(),
129
129
  deletable: { type: 'boolean' },
130
+ readonly: { type: 'boolean', description: 'readonly shops do not allow updates or adding expeditions to them' },
130
131
  international: {
131
132
  type: 'object',
132
133
  properties: {
@@ -206,6 +207,7 @@ const shop = () => ({
206
207
  'createdAt',
207
208
  'updatedAt',
208
209
  'deletable',
210
+ 'readonly',
209
211
  'international',
210
212
  'defaults',
211
213
  'network',
@@ -247,7 +249,7 @@ const createShopRequest = () =>
247
249
  createRequest({
248
250
  type: 'object',
249
251
  properties: {
250
- ...pickProperties(shop(), ['_id', 'createdAt']),
252
+ ...pickProperties(shop(), ['_id', 'createdAt', 'readonly']),
251
253
  network: objectWithUuid(),
252
254
  zone: objectWithUuid(),
253
255
  openingRepresentative: setShopRepresentative(),