@gls_spain/gps-common 32.3.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,6 +2,11 @@
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/NetworkCannotBeUpdatedError.js" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/errors/ShopCannotBeUpdatedError.js" afterDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
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/networks.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/networks.js" afterDir="false" />
5
10
  <change beforePath="$PROJECT_DIR$/schemas/definitions/shops.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/shops.js" afterDir="false" />
6
11
  </list>
7
12
  <option name="SHOW_DIALOG" value="false" />
@@ -41,7 +46,7 @@
41
46
  <property name="TERMINAL_CUSTOM_COMMANDS_GOT_IT" value="true" />
42
47
  <property name="WebServerToolWindowFactoryState" value="false" />
43
48
  <property name="javascript.nodejs.core.library.configured.version" value="10.15.3" />
44
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
49
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/errors" />
45
50
  <property name="node.js.detected.package.eslint" value="true" />
46
51
  <property name="node.js.detected.package.standard" value="true" />
47
52
  <property name="node.js.path.for.package.eslint" value="project" />
@@ -58,6 +63,13 @@
58
63
  <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
59
64
  </component>
60
65
  <component name="RecentsManager">
66
+ <key name="CopyFile.RECENT_KEYS">
67
+ <recent name="$PROJECT_DIR$/errors" />
68
+ <recent name="$PROJECT_DIR$/schemas/definitions" />
69
+ <recent name="$PROJECT_DIR$" />
70
+ <recent name="$PROJECT_DIR$/schemas" />
71
+ <recent name="$PROJECT_DIR$/lib/scripts" />
72
+ </key>
61
73
  <key name="MoveFile.RECENT_KEYS">
62
74
  <recent name="$PROJECT_DIR$/open-api" />
63
75
  <recent name="$PROJECT_DIR$" />
@@ -65,13 +77,6 @@
65
77
  <recent name="$PROJECT_DIR$/open-api-spec" />
66
78
  <recent name="$PROJECT_DIR$/errors" />
67
79
  </key>
68
- <key name="CopyFile.RECENT_KEYS">
69
- <recent name="$PROJECT_DIR$" />
70
- <recent name="$PROJECT_DIR$/errors" />
71
- <recent name="$PROJECT_DIR$/schemas/definitions" />
72
- <recent name="$PROJECT_DIR$/schemas" />
73
- <recent name="$PROJECT_DIR$/lib/scripts" />
74
- </key>
75
80
  </component>
76
81
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
77
82
  <configuration name="#errors" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
@@ -122,8 +127,8 @@
122
127
  </configuration>
123
128
  <recent_temporary>
124
129
  <list>
125
- <item itemvalue="JavaScript Debug.documentation.html (1)" />
126
130
  <item itemvalue="npm.build-documentation" />
131
+ <item itemvalue="JavaScript Debug.documentation.html (1)" />
127
132
  <item itemvalue="npm.test" />
128
133
  <item itemvalue="Jest.index.test.js" />
129
134
  <item itemvalue="Jest.#errors" />
@@ -563,7 +568,8 @@
563
568
  <workItem from="1591864959459" duration="63000" />
564
569
  <workItem from="1591865082734" duration="29000" />
565
570
  <workItem from="1594828405112" duration="147000" />
566
- <workItem from="1594885748220" duration="1333000" />
571
+ <workItem from="1594885748220" duration="6957000" />
572
+ <workItem from="1594925133162" duration="587000" />
567
573
  </task>
568
574
  <servers />
569
575
  </component>
@@ -602,37 +608,21 @@
602
608
  <option name="oldMeFiltersMigrated" value="true" />
603
609
  </component>
604
610
  <component name="WindowStateProjectService">
605
- <state x="712" y="322" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog" timestamp="1584696790922">
606
- <screen x="0" y="23" width="2048" height="1129" />
607
- </state>
608
- <state x="712" y="322" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1584696790922" />
609
- <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1584283363756">
610
- <screen x="0" y="23" width="2048" height="1129" />
611
- </state>
612
- <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1584283363756" />
613
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1591788974478">
614
- <screen x="0" y="23" width="2048" height="1129" />
615
- </state>
616
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1591788974478" />
617
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1591788974478">
618
- <screen x="0" y="23" width="2048" height="1129" />
619
- </state>
620
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1591788974478" />
621
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1591788974478">
611
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1594925626891">
622
612
  <screen x="0" y="23" width="2048" height="1129" />
623
613
  </state>
624
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1591788974478" />
625
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1591788974478">
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">
626
616
  <screen x="0" y="23" width="2048" height="1129" />
627
617
  </state>
628
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1591788974478" />
629
- <state x="1351" y="124" width="697" height="951" key="find.popup" timestamp="1584747151804">
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">
630
620
  <screen x="0" y="23" width="2048" height="1129" />
631
621
  </state>
632
- <state x="1351" y="124" width="697" height="951" key="find.popup/0.23.2048.1129@0.23.2048.1129" timestamp="1584747151804" />
633
- <state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1584284016106">
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">
634
624
  <screen x="0" y="23" width="2048" height="1129" />
635
625
  </state>
636
- <state x="689" y="276" width="670" height="676" key="search.everywhere.popup/0.23.2048.1129@0.23.2048.1129" timestamp="1584284016106" />
626
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1594925626891" />
637
627
  </component>
638
628
  </project>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
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
+
8
+ # [32.4.0](https://github.com/GLS-Spain/gps-common/compare/v32.3.0...v32.4.0) (2020-07-16)
9
+
10
+
11
+ ### Features
12
+
13
+ * add counters ([54638a1](https://github.com/GLS-Spain/gps-common/commit/54638a1c54317c8adb136258837b230e025b8553))
14
+
1
15
  # [32.3.0](https://github.com/GLS-Spain/gps-common/compare/v32.2.0...v32.3.0) (2020-07-16)
2
16
 
3
17
 
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class CountersDoNotExistError extends DatabaseError {
4
+ constructor(message = 'Counters do not exist.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'CountersDoNotExistError';
8
+ }
9
+ }
10
+
11
+ module.exports = CountersDoNotExistError;
@@ -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');
@@ -18,6 +20,7 @@ const ExpeditionAlreadyExistsError = require('./ExpeditionAlreadyExistsError');
18
20
  const ExpeditionCannotBeUpdatedError = require('./ExpeditionCannotBeUpdatedError');
19
21
  const ExpeditionCannotBeDeletedError = require('./ExpeditionCannotBeDeletedError');
20
22
  const DefaultsDoNotExistError = require('./DefaultsDoNotExistError');
23
+ const CountersDoNotExistError = require('./CountersDoNotExistError');
21
24
  const RepresentativeDoesNotExistError = require('./RepresentativeDoesNotExistError');
22
25
  const RepresentativeAlreadyExistsError = require('./RepresentativeAlreadyExistsError');
23
26
  const RepresentativeCannotBeDeletedError = require('./RepresentativeCannotBeDeletedError');
@@ -33,10 +36,12 @@ const errorsNames = {
33
36
  UserCannotBeDeletedError: 'UserCannotBeDeletedError',
34
37
  NetworkDoesNotExistError: 'NetworkDoesNotExistError',
35
38
  NetworkAlreadyExistsError: 'NetworkAlreadyExistsError',
39
+ NetworkCannotBeUpdatedError: 'NetworkCannotBeUpdatedError',
36
40
  NetworkCannotBeDeletedError: 'NetworkCannotBeDeletedError',
37
41
  WrongNetworkError: 'WrongNetworkError',
38
42
  ShopDoesNotExistError: 'ShopDoesNotExistError',
39
43
  ShopAlreadyExistsError: 'ShopAlreadyExistsError',
44
+ ShopCannotBeUpdatedError: 'ShopCannotBeUpdatedError',
40
45
  ShopCannotBeDeletedError: 'ShopCannotBeDeletedError',
41
46
  ShopNotEnabledError: 'ShopNotEnabledError',
42
47
  WrongShopError: 'WrongShopError',
@@ -46,6 +51,7 @@ const errorsNames = {
46
51
  ExpeditionCannotBeUpdatedError: 'ExpeditionCannotBeUpdatedError',
47
52
  ExpeditionCannotBeDeletedError: 'ExpeditionCannotBeDeletedError',
48
53
  DefaultsDoNotExistError: 'DefaultsDoNotExistError',
54
+ CountersDoNotExistError: 'CountersDoNotExistError',
49
55
  RepresentativeDoesNotExistError: 'RepresentativeDoesNotExistError',
50
56
  RepresentativeAlreadyExistsError: 'RepresentativeAlreadyExistsError',
51
57
  RepresentativeCannotBeDeletedError: 'RepresentativeCannotBeDeletedError',
@@ -62,10 +68,12 @@ module.exports = {
62
68
  UserCannotBeDeletedError,
63
69
  NetworkDoesNotExistError,
64
70
  NetworkAlreadyExistsError,
71
+ NetworkCannotBeUpdatedError,
65
72
  NetworkCannotBeDeletedError,
66
73
  WrongNetworkError,
67
74
  ShopDoesNotExistError,
68
75
  ShopAlreadyExistsError,
76
+ ShopCannotBeUpdatedError,
69
77
  ShopCannotBeDeletedError,
70
78
  ShopNotEnabledError,
71
79
  WrongShopError,
@@ -75,6 +83,7 @@ module.exports = {
75
83
  ExpeditionCannotBeUpdatedError,
76
84
  ExpeditionCannotBeDeletedError,
77
85
  DefaultsDoNotExistError,
86
+ CountersDoNotExistError,
78
87
  RepresentativeDoesNotExistError,
79
88
  RepresentativeAlreadyExistsError,
80
89
  RepresentativeCannotBeDeletedError,
@@ -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,
@@ -29,6 +31,7 @@ const {
29
31
  ExpeditionCannotBeUpdatedError,
30
32
  ExpeditionCannotBeDeletedError,
31
33
  DefaultsDoNotExistError,
34
+ CountersDoNotExistError,
32
35
  RepresentativeDoesNotExistError,
33
36
  RepresentativeAlreadyExistsError,
34
37
  RepresentativeCannotBeDeletedError,
@@ -120,6 +123,7 @@ const {
120
123
  receiveAllExpeditionsFromDriverResponse,
121
124
  } = require('../schemas/definitions/expeditions');
122
125
  const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
126
+ const { counters, getCountersResponse } = require('../schemas/definitions/counters');
123
127
  const { pod, findPodsRequest, findPodsResponse } = require('../schemas/definitions/pods');
124
128
  const {
125
129
  receiveFromDriverEvent,
@@ -200,7 +204,19 @@ openApiSpec['x-tagGroups'] = [
200
204
  },
201
205
  {
202
206
  name: 'RESOURCES',
203
- tags: ['Defaults', 'Super admin', 'Network', 'Network admin', 'Zone', 'Sales representative', 'Shop', 'Shop user', 'Expedition', 'Pod'],
207
+ tags: [
208
+ 'Defaults',
209
+ 'Counters',
210
+ 'Super admin',
211
+ 'Network',
212
+ 'Network admin',
213
+ 'Zone',
214
+ 'Sales representative',
215
+ 'Shop',
216
+ 'Shop user',
217
+ 'Expedition',
218
+ 'Pod',
219
+ ],
204
220
  },
205
221
  {
206
222
  name: 'HISTORIC RECORDS',
@@ -336,6 +352,16 @@ the maximum number of days that an expedition can be in a shop before returning
336
352
  Super administrators can view and update this default settings using the [config](#tag/Config) endpoints.
337
353
 
338
354
  <SchemaDefinition schemaRef="#/components/schemas/defaults" />`,
355
+ },
356
+ {
357
+ name: 'Counters',
358
+ description: `
359
+ Some of the API resources have fields that are auto incremental values. The API keeps a counter for each of these fields to know what the
360
+ next value to use is.
361
+
362
+ Super administrators can view the last values used for each auto incremental field using the [config](#tag/Config) endpoints.
363
+
364
+ <SchemaDefinition schemaRef="#/components/schemas/counters" />`,
339
365
  },
340
366
  {
341
367
  name: 'Super admin',
@@ -637,7 +663,9 @@ These settings can be set at various levels of specificity:
637
663
 
638
664
  - Default values: these are set in this section and apply to networks and shops that do not have custom settings.
639
665
  - Network specific values: each network can have its custom settings, which override the default ones.
640
- - Shop specific values: each shop can have its custom settings, which override the network and default ones.`,
666
+ - Shop specific values: each shop can have its custom settings, which override the network and default ones.
667
+
668
+ There is also an endpoint to view the last value used for each auto incremental field`,
641
669
  },
642
670
  {
643
671
  name: 'Super admins',
@@ -654,6 +682,9 @@ Networks are collections of parcel shops that belong to the same provider.
654
682
  A network that has admins or parcel shops associated to it will have its \`deletable\` property automatically set to
655
683
  \`false\` and cannot be deleted.
656
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
+
657
688
  A network may have custom derivation and expiration settings or use the defaults defined in [config](#tag/Config):
658
689
 
659
690
  - If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
@@ -687,6 +718,9 @@ A shop is assigned to a network on creation and its network cannot be changed la
687
718
  A shop that has users or expeditions associated to it will have its \`deletable\` property automatically set to \`false\`
688
719
  and cannot be deleted.
689
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
+
690
724
  A shop may have custom derivation and expiration settings, use its network values or use the defaults defined in [config](#tag/Config):
691
725
 
692
726
  - If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
@@ -820,9 +854,11 @@ const errors = {
820
854
  userCannotBeDeleted: new UserCannotBeDeletedError(),
821
855
  networkDoesNotExist: new NetworkDoesNotExistError(),
822
856
  networkAlreadyExists: new NetworkAlreadyExistsError(),
857
+ networkCannotBeUpdated: new NetworkCannotBeUpdatedError(),
823
858
  networkCannotBeDeleted: new NetworkCannotBeDeletedError(),
824
859
  shopDoesNotExist: new ShopDoesNotExistError(),
825
860
  shopAlreadyExists: new ShopAlreadyExistsError(),
861
+ shopCannotBeUpdated: new ShopCannotBeUpdatedError(),
826
862
  shopCannotBeDeleted: new ShopCannotBeDeletedError(),
827
863
  shopNotEnabled: new ShopNotEnabledError(),
828
864
  wrongPassword: new WrongPasswordError(),
@@ -831,6 +867,7 @@ const errors = {
831
867
  expeditionCannotBeUpdated: new ExpeditionCannotBeUpdatedError(),
832
868
  expeditionCannotBeDeleted: new ExpeditionCannotBeDeletedError(),
833
869
  defaultsDoNotExist: new DefaultsDoNotExistError(),
870
+ countersDoNotExist: new CountersDoNotExistError(),
834
871
  representativeDoesNotExist: new RepresentativeDoesNotExistError(),
835
872
  representativeAlreadyExists: new RepresentativeAlreadyExistsError(),
836
873
  representativeCannotBeDeleted: new RepresentativeCannotBeDeletedError(),
@@ -904,6 +941,10 @@ const responses = {
904
941
  description: 'The network already exists.',
905
942
  content: { 'application/json': { schema: specificHttpError(errors.networkAlreadyExists) } },
906
943
  },
944
+ networkCannotBeUpdated: {
945
+ description: 'The network cannot be updated.',
946
+ content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeUpdated) } },
947
+ },
907
948
  networkCannotBeDeleted: {
908
949
  description: 'The network cannot be deleted.',
909
950
  content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeDeleted) } },
@@ -916,6 +957,10 @@ const responses = {
916
957
  description: 'The shop already exists.',
917
958
  content: { 'application/json': { schema: specificHttpError(errors.shopAlreadyExists) } },
918
959
  },
960
+ shopCannotBeUpdated: {
961
+ description: 'The shop cannot be updated.',
962
+ content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeUpdated) } },
963
+ },
919
964
  shopCannotBeDeleted: {
920
965
  description: 'The shop cannot be deleted.',
921
966
  content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
@@ -948,6 +993,10 @@ const responses = {
948
993
  description: 'The defaults do not exist.',
949
994
  content: { 'application/json': { schema: specificHttpError(errors.defaultsDoNotExist) } },
950
995
  },
996
+ countersDoNotExist: {
997
+ description: 'The counters do not exist.',
998
+ content: { 'application/json': { schema: specificHttpError(errors.countersDoNotExist) } },
999
+ },
951
1000
  representativeDoesNotExist: {
952
1001
  description: 'The representative does not exist.',
953
1002
  content: { 'application/json': { schema: specificHttpError(errors.representativeDoesNotExist) } },
@@ -1009,6 +1058,7 @@ openApiSpec.components = {
1009
1058
  schemas: {
1010
1059
  errorResponse: errorResponse(),
1011
1060
  defaults: defaults(),
1061
+ counters: counters(),
1012
1062
  superAdmin: superAdmin(),
1013
1063
  networkAdmin: networkAdmin(),
1014
1064
  shopUser: shopUser(),
@@ -1269,6 +1319,30 @@ ${securitySchemes.superAdminRole}`,
1269
1319
  },
1270
1320
  },
1271
1321
  },
1322
+ '/config/counters/get': {
1323
+ get: {
1324
+ tags: ['Config'],
1325
+ summary: '[S] Get counters',
1326
+ description: `
1327
+ Get the last value used for each auto incremental field in the API resources.
1328
+
1329
+ ${securitySchemes.tokens}
1330
+ ${securitySchemes.superAdminRole}`,
1331
+ responses: {
1332
+ ' 200': {
1333
+ description: 'Contains the counters.',
1334
+ content: { 'application/json': { schema: getCountersResponse() } },
1335
+ },
1336
+ ' 401': responses.invalidUserInCookieOrHeader,
1337
+ ' 401 ': responses.invalidCookieOrHeader,
1338
+ ' 401 ': responses.missingCookieOrHeader,
1339
+ ' 401 ': responses.unauthorized,
1340
+ ' 403': responses.forbidden,
1341
+ ' 500': responses.internalServerError,
1342
+ ' 500 ': responses.countersDoNotExist,
1343
+ },
1344
+ },
1345
+ },
1272
1346
  '/superAdmins/create': {
1273
1347
  post: {
1274
1348
  tags: ['Super admins'],
@@ -1419,6 +1493,8 @@ ${descriptions.createIdIsOptional}
1419
1493
 
1420
1494
  ${descriptions.optionalArrayPropertiesEmptyByDefault}
1421
1495
 
1496
+ The \`readonly\` property defaults to \`false\` if not provided.
1497
+
1422
1498
  To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
1423
1499
  \`defaults\` property will be used.
1424
1500
 
@@ -1510,6 +1586,9 @@ Finds a network and updates the provided properties.
1510
1586
 
1511
1587
  ${descriptions.updateSetAddOrRemove}
1512
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
+
1513
1592
  The \`derivationSettings\` and \`expirationSettings\` properties can be updated with a value or with \`null\`, which will remove them. The
1514
1593
  update will propagate to the \`network\` property of all the shops in the network.
1515
1594
 
@@ -1533,6 +1612,7 @@ ${securitySchemes.superAdminRole}`,
1533
1612
  ' 415': responses.unsupportedMediaType,
1534
1613
  ' 500': responses.internalServerError,
1535
1614
  ' 500 ': responses.networkDoesNotExist,
1615
+ ' 500 ': responses.networkCannotBeUpdated,
1536
1616
  },
1537
1617
  },
1538
1618
  },
@@ -2091,8 +2171,10 @@ ${descriptions.createIdIsOptional}
2091
2171
 
2092
2172
  ${descriptions.optionalArrayPropertiesEmptyByDefault}
2093
2173
 
2094
- The \`network._id\` property that associates a shop with his network cannot be changed after creation.
2095
- 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.
2096
2178
 
2097
2179
  See [shops](#tag/Shops) for information about the \`status\` property.
2098
2180
 
@@ -2119,7 +2201,8 @@ ${securitySchemes.superAdminRole}`,
2119
2201
  ' 415': responses.unsupportedMediaType,
2120
2202
  ' 500': responses.internalServerError,
2121
2203
  ' 500 ': responses.networkDoesNotExist,
2122
- ' 500 ': responses.shopAlreadyExists,
2204
+ ' 500 ': responses.networkCannotBeUpdated,
2205
+ ' 500 ': responses.shopAlreadyExists,
2123
2206
  },
2124
2207
  },
2125
2208
  },
@@ -2197,6 +2280,9 @@ Finds a shop and updates the provided properties.
2197
2280
 
2198
2281
  ${descriptions.updateSetAddOrRemove}
2199
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
+
2200
2286
  See [shops](#tag/Shops) for information about the \`status\` property.
2201
2287
 
2202
2288
  ${securitySchemes.tokens}
@@ -2219,6 +2305,7 @@ ${securitySchemes.superAdminRole}`,
2219
2305
  ' 415': responses.unsupportedMediaType,
2220
2306
  ' 500': responses.internalServerError,
2221
2307
  ' 500 ': responses.shopDoesNotExist,
2308
+ ' 500 ': responses.shopCannotBeUpdated,
2222
2309
  },
2223
2310
  },
2224
2311
  },
@@ -2475,8 +2562,8 @@ An expedition can be associated on creation to either a shop or a network:
2475
2562
  - Provide a shop when it is known at which shop it is going to be received. That shop network will be inserted automatically.
2476
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.
2477
2564
 
2478
- If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, and if it is not enabled the API
2479
- 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\`.
2480
2567
 
2481
2568
  If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
2482
2569
 
@@ -2504,7 +2591,8 @@ ${securitySchemes.superAdminRole}`,
2504
2591
  ' 500 ': responses.expeditionAlreadyExists,
2505
2592
  ' 500 ': responses.shopDoesNotExist,
2506
2593
  ' 500 ': responses.shopNotEnabled,
2507
- ' 500 ': responses.networkDoesNotExist,
2594
+ ' 500 ': responses.shopCannotBeUpdated,
2595
+ ' 500 ': responses.networkDoesNotExist,
2508
2596
  },
2509
2597
  },
2510
2598
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "32.3.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": [
@@ -0,0 +1,43 @@
1
+ const { uuid, datetime } = require('@gls_spain/common-json-schemas');
2
+
3
+ const counters = () => ({
4
+ title: 'counters',
5
+ type: 'object',
6
+ properties: {
7
+ _id: uuid(),
8
+ createdAt: datetime(),
9
+ updatedAt: datetime(),
10
+ deletable: { type: 'boolean' },
11
+ shops: {
12
+ type: 'object',
13
+ properties: {
14
+ international: {
15
+ type: 'object',
16
+ properties: {
17
+ parcelShopId: { type: 'integer', minimum: 0, description: 'last id used, auto increments itself as shops are created' },
18
+ },
19
+ required: ['parcelShopId'],
20
+ additionalProperties: false,
21
+ },
22
+ },
23
+ required: ['international'],
24
+ additionalProperties: false,
25
+ },
26
+ },
27
+ required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'shops'],
28
+ additionalProperties: false,
29
+ });
30
+
31
+ const getCountersResponse = () => ({
32
+ type: 'object',
33
+ properties: {
34
+ get: counters(),
35
+ },
36
+ required: ['get'],
37
+ additionalProperties: false,
38
+ });
39
+
40
+ module.exports = {
41
+ counters,
42
+ getCountersResponse,
43
+ };
@@ -1,6 +1,7 @@
1
1
  const { password, pickProperties } = require('@gls_spain/common-json-schemas');
2
2
  const { superAdmin } = require('./users');
3
3
  const { defaults } = require('./defaults');
4
+ const { counters } = require('./counters');
4
5
 
5
6
  const initRequest = () => ({
6
7
  type: 'object',
@@ -20,8 +21,14 @@ const initRequest = () => ({
20
21
  required: ['derivationSettings', 'expirationSettings'],
21
22
  additionalProperties: false,
22
23
  },
24
+ counters: {
25
+ type: 'object',
26
+ properties: { ...pickProperties(counters(), ['shops']) },
27
+ required: ['shops'],
28
+ additionalProperties: false,
29
+ },
23
30
  },
24
- required: ['superAdmin', 'defaults'],
31
+ required: ['superAdmin', 'defaults', 'counters'],
25
32
  additionalProperties: false,
26
33
  });
27
34
 
@@ -30,9 +37,10 @@ const initResponse = () => ({
30
37
  properties: {
31
38
  superAdmin: superAdmin(),
32
39
  defaults: defaults(),
40
+ counters: counters(),
33
41
  indexes: { type: 'array', items: { type: 'string' } },
34
42
  },
35
- required: ['superAdmin', 'defaults', 'indexes'],
43
+ required: ['superAdmin', 'defaults', 'counters', 'indexes'],
36
44
  additionalProperties: false,
37
45
  });
38
46
 
@@ -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(),
package/schemas/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const { addMetadata, errorResponse: sourceErrorResponse } = require('@gls_spain/common-json-schemas');
2
2
  const { initRequest, initResponse } = require('./definitions/init');
3
3
  const { getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('./definitions/defaults');
4
+ const { getCountersResponse } = require('./definitions/counters');
4
5
  const { loginResponse: sourceLoginResponse } = require('./definitions/login');
5
6
  const { logoutResponse: sourceLogoutResponse } = require('./definitions/logout');
6
7
  const { becomeRequest: sourceBecomeRequest } = require('./definitions/become');
@@ -119,6 +120,7 @@ const configInitResponse = response(initResponse(), 'configInitResponse');
119
120
  const configDefaultsGetResponse = response(getDefaultsResponse(), 'configDefaultsGetResponse');
120
121
  const configDefaultsUpdateRequest = request(updateDefaultsRequest(), 'configDefaultsUpdateRequest');
121
122
  const configDefaultsUpdateResponse = response(updateDefaultsResponse(), 'configDefaultsUpdateResponse');
123
+ const configCountersGetResponse = response(getCountersResponse(), 'configCountersGetResponse');
122
124
 
123
125
  const loginResponse = response(sourceLoginResponse(), 'loginResponse');
124
126
  const logoutResponse = response(sourceLogoutResponse(), 'logoutResponse');
@@ -236,6 +238,7 @@ module.exports = {
236
238
  configDefaultsGetResponse,
237
239
  configDefaultsUpdateRequest,
238
240
  configDefaultsUpdateResponse,
241
+ configCountersGetResponse,
239
242
 
240
243
  loginResponse,
241
244
  logoutResponse,