@gls_spain/gps-common 32.3.0 → 32.4.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,7 +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 beforePath="$PROJECT_DIR$/schemas/definitions/shops.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/shops.js" afterDir="false" />
5
+ <change afterPath="$PROJECT_DIR$/errors/CountersDoNotExistError.js" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/schemas/definitions/counters.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/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" />
6
11
  </list>
7
12
  <option name="SHOW_DIALOG" value="false" />
8
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -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,7 @@
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="3069000" />
567
572
  </task>
568
573
  <servers />
569
574
  </component>
@@ -602,37 +607,21 @@
602
607
  <option name="oldMeFiltersMigrated" value="true" />
603
608
  </component>
604
609
  <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">
610
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1594890828677">
622
611
  <screen x="0" y="23" width="2048" height="1129" />
623
612
  </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">
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">
626
615
  <screen x="0" y="23" width="2048" height="1129" />
627
616
  </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">
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">
630
619
  <screen x="0" y="23" width="2048" height="1129" />
631
620
  </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">
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">
634
623
  <screen x="0" y="23" width="2048" height="1129" />
635
624
  </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" />
625
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1594890828677" />
637
626
  </component>
638
627
  </project>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [32.4.0](https://github.com/GLS-Spain/gps-common/compare/v32.3.0...v32.4.0) (2020-07-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * add counters ([54638a1](https://github.com/GLS-Spain/gps-common/commit/54638a1c54317c8adb136258837b230e025b8553))
7
+
1
8
  # [32.3.0](https://github.com/GLS-Spain/gps-common/compare/v32.2.0...v32.3.0) (2020-07-16)
2
9
 
3
10
 
@@ -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;
package/errors/index.js CHANGED
@@ -18,6 +18,7 @@ const ExpeditionAlreadyExistsError = require('./ExpeditionAlreadyExistsError');
18
18
  const ExpeditionCannotBeUpdatedError = require('./ExpeditionCannotBeUpdatedError');
19
19
  const ExpeditionCannotBeDeletedError = require('./ExpeditionCannotBeDeletedError');
20
20
  const DefaultsDoNotExistError = require('./DefaultsDoNotExistError');
21
+ const CountersDoNotExistError = require('./CountersDoNotExistError');
21
22
  const RepresentativeDoesNotExistError = require('./RepresentativeDoesNotExistError');
22
23
  const RepresentativeAlreadyExistsError = require('./RepresentativeAlreadyExistsError');
23
24
  const RepresentativeCannotBeDeletedError = require('./RepresentativeCannotBeDeletedError');
@@ -46,6 +47,7 @@ const errorsNames = {
46
47
  ExpeditionCannotBeUpdatedError: 'ExpeditionCannotBeUpdatedError',
47
48
  ExpeditionCannotBeDeletedError: 'ExpeditionCannotBeDeletedError',
48
49
  DefaultsDoNotExistError: 'DefaultsDoNotExistError',
50
+ CountersDoNotExistError: 'CountersDoNotExistError',
49
51
  RepresentativeDoesNotExistError: 'RepresentativeDoesNotExistError',
50
52
  RepresentativeAlreadyExistsError: 'RepresentativeAlreadyExistsError',
51
53
  RepresentativeCannotBeDeletedError: 'RepresentativeCannotBeDeletedError',
@@ -75,6 +77,7 @@ module.exports = {
75
77
  ExpeditionCannotBeUpdatedError,
76
78
  ExpeditionCannotBeDeletedError,
77
79
  DefaultsDoNotExistError,
80
+ CountersDoNotExistError,
78
81
  RepresentativeDoesNotExistError,
79
82
  RepresentativeAlreadyExistsError,
80
83
  RepresentativeCannotBeDeletedError,
@@ -29,6 +29,7 @@ const {
29
29
  ExpeditionCannotBeUpdatedError,
30
30
  ExpeditionCannotBeDeletedError,
31
31
  DefaultsDoNotExistError,
32
+ CountersDoNotExistError,
32
33
  RepresentativeDoesNotExistError,
33
34
  RepresentativeAlreadyExistsError,
34
35
  RepresentativeCannotBeDeletedError,
@@ -120,6 +121,7 @@ const {
120
121
  receiveAllExpeditionsFromDriverResponse,
121
122
  } = require('../schemas/definitions/expeditions');
122
123
  const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
124
+ const { counters, getCountersResponse } = require('../schemas/definitions/counters');
123
125
  const { pod, findPodsRequest, findPodsResponse } = require('../schemas/definitions/pods');
124
126
  const {
125
127
  receiveFromDriverEvent,
@@ -200,7 +202,19 @@ openApiSpec['x-tagGroups'] = [
200
202
  },
201
203
  {
202
204
  name: 'RESOURCES',
203
- tags: ['Defaults', 'Super admin', 'Network', 'Network admin', 'Zone', 'Sales representative', 'Shop', 'Shop user', 'Expedition', 'Pod'],
205
+ tags: [
206
+ 'Defaults',
207
+ 'Counters',
208
+ 'Super admin',
209
+ 'Network',
210
+ 'Network admin',
211
+ 'Zone',
212
+ 'Sales representative',
213
+ 'Shop',
214
+ 'Shop user',
215
+ 'Expedition',
216
+ 'Pod',
217
+ ],
204
218
  },
205
219
  {
206
220
  name: 'HISTORIC RECORDS',
@@ -336,6 +350,16 @@ the maximum number of days that an expedition can be in a shop before returning
336
350
  Super administrators can view and update this default settings using the [config](#tag/Config) endpoints.
337
351
 
338
352
  <SchemaDefinition schemaRef="#/components/schemas/defaults" />`,
353
+ },
354
+ {
355
+ name: 'Counters',
356
+ description: `
357
+ 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
358
+ next value to use is.
359
+
360
+ Super administrators can view the last values used for each auto incremental field using the [config](#tag/Config) endpoints.
361
+
362
+ <SchemaDefinition schemaRef="#/components/schemas/counters" />`,
339
363
  },
340
364
  {
341
365
  name: 'Super admin',
@@ -637,7 +661,9 @@ These settings can be set at various levels of specificity:
637
661
 
638
662
  - Default values: these are set in this section and apply to networks and shops that do not have custom settings.
639
663
  - 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.`,
664
+ - Shop specific values: each shop can have its custom settings, which override the network and default ones.
665
+
666
+ There is also an endpoint to view the last value used for each auto incremental field`,
641
667
  },
642
668
  {
643
669
  name: 'Super admins',
@@ -831,6 +857,7 @@ const errors = {
831
857
  expeditionCannotBeUpdated: new ExpeditionCannotBeUpdatedError(),
832
858
  expeditionCannotBeDeleted: new ExpeditionCannotBeDeletedError(),
833
859
  defaultsDoNotExist: new DefaultsDoNotExistError(),
860
+ countersDoNotExist: new CountersDoNotExistError(),
834
861
  representativeDoesNotExist: new RepresentativeDoesNotExistError(),
835
862
  representativeAlreadyExists: new RepresentativeAlreadyExistsError(),
836
863
  representativeCannotBeDeleted: new RepresentativeCannotBeDeletedError(),
@@ -948,6 +975,10 @@ const responses = {
948
975
  description: 'The defaults do not exist.',
949
976
  content: { 'application/json': { schema: specificHttpError(errors.defaultsDoNotExist) } },
950
977
  },
978
+ countersDoNotExist: {
979
+ description: 'The counters do not exist.',
980
+ content: { 'application/json': { schema: specificHttpError(errors.countersDoNotExist) } },
981
+ },
951
982
  representativeDoesNotExist: {
952
983
  description: 'The representative does not exist.',
953
984
  content: { 'application/json': { schema: specificHttpError(errors.representativeDoesNotExist) } },
@@ -1009,6 +1040,7 @@ openApiSpec.components = {
1009
1040
  schemas: {
1010
1041
  errorResponse: errorResponse(),
1011
1042
  defaults: defaults(),
1043
+ counters: counters(),
1012
1044
  superAdmin: superAdmin(),
1013
1045
  networkAdmin: networkAdmin(),
1014
1046
  shopUser: shopUser(),
@@ -1269,6 +1301,30 @@ ${securitySchemes.superAdminRole}`,
1269
1301
  },
1270
1302
  },
1271
1303
  },
1304
+ '/config/counters/get': {
1305
+ get: {
1306
+ tags: ['Config'],
1307
+ summary: '[S] Get counters',
1308
+ description: `
1309
+ Get the last value used for each auto incremental field in the API resources.
1310
+
1311
+ ${securitySchemes.tokens}
1312
+ ${securitySchemes.superAdminRole}`,
1313
+ responses: {
1314
+ ' 200': {
1315
+ description: 'Contains the counters.',
1316
+ content: { 'application/json': { schema: getCountersResponse() } },
1317
+ },
1318
+ ' 401': responses.invalidUserInCookieOrHeader,
1319
+ ' 401 ': responses.invalidCookieOrHeader,
1320
+ ' 401 ': responses.missingCookieOrHeader,
1321
+ ' 401 ': responses.unauthorized,
1322
+ ' 403': responses.forbidden,
1323
+ ' 500': responses.internalServerError,
1324
+ ' 500 ': responses.countersDoNotExist,
1325
+ },
1326
+ },
1327
+ },
1272
1328
  '/superAdmins/create': {
1273
1329
  post: {
1274
1330
  tags: ['Super admins'],
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.4.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
 
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,