@gls_spain/gps-common 33.0.7 → 33.0.9

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.
@@ -1,7 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
- <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="" />
4
+ <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
+ <change afterPath="$PROJECT_DIR$/errors/SaleDoesNotExistError.js" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
8
+ </list>
5
9
  <option name="SHOW_DIALOG" value="false" />
6
10
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
7
11
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -41,7 +45,7 @@
41
45
  <property name="WebServerToolWindowFactoryState" value="false" />
42
46
  <property name="javascript.nodejs.core.library.configured.version" value="12.13.0" />
43
47
  <property name="javascript.nodejs.core.library.typings.version" value="12.12.53" />
44
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
48
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/errors" />
45
49
  <property name="node.js.detected.package.eslint" value="true" />
46
50
  <property name="node.js.detected.package.standard" value="true" />
47
51
  <property name="node.js.path.for.package.eslint" value="project" />
@@ -58,13 +62,6 @@
58
62
  <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
59
63
  </component>
60
64
  <component name="RecentsManager">
61
- <key name="MoveFile.RECENT_KEYS">
62
- <recent name="$PROJECT_DIR$/open-api" />
63
- <recent name="$PROJECT_DIR$" />
64
- <recent name="$PROJECT_DIR$/schemas" />
65
- <recent name="$PROJECT_DIR$/open-api-spec" />
66
- <recent name="$PROJECT_DIR$/errors" />
67
- </key>
68
65
  <key name="CopyFile.RECENT_KEYS">
69
66
  <recent name="$PROJECT_DIR$/errors" />
70
67
  <recent name="$PROJECT_DIR$/schemas/definitions" />
@@ -72,21 +69,15 @@
72
69
  <recent name="$PROJECT_DIR$/schemas" />
73
70
  <recent name="$PROJECT_DIR$/lib/scripts" />
74
71
  </key>
72
+ <key name="MoveFile.RECENT_KEYS">
73
+ <recent name="$PROJECT_DIR$/open-api" />
74
+ <recent name="$PROJECT_DIR$" />
75
+ <recent name="$PROJECT_DIR$/schemas" />
76
+ <recent name="$PROJECT_DIR$/open-api-spec" />
77
+ <recent name="$PROJECT_DIR$/errors" />
78
+ </key>
75
79
  </component>
76
80
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
77
- <configuration name="#errors" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
78
- <node-interpreter value="project" />
79
- <node-options value="" />
80
- <jest-package value="$PROJECT_DIR$/node_modules/jest" />
81
- <working-dir value="$PROJECT_DIR$" />
82
- <envs />
83
- <scope-kind value="SUITE" />
84
- <test-file value="$PROJECT_DIR$/index.test.js" />
85
- <test-names>
86
- <test-name value="#errors" />
87
- </test-names>
88
- <method v="2" />
89
- </configuration>
90
81
  <configuration name="index.test.js" type="JavaScriptTestRunnerJest" temporary="true" nameIsGenerated="true">
91
82
  <node-interpreter value="project" />
92
83
  <node-options value="" />
@@ -110,6 +101,16 @@
110
101
  <envs />
111
102
  <method v="2" />
112
103
  </configuration>
104
+ <configuration name="commit" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
105
+ <package-json value="$PROJECT_DIR$/package.json" />
106
+ <command value="run" />
107
+ <scripts>
108
+ <script value="commit" />
109
+ </scripts>
110
+ <node-interpreter value="project" />
111
+ <envs />
112
+ <method v="2" />
113
+ </configuration>
113
114
  <configuration name="test" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
114
115
  <package-json value="$PROJECT_DIR$/package.json" />
115
116
  <command value="run" />
@@ -122,11 +123,11 @@
122
123
  </configuration>
123
124
  <recent_temporary>
124
125
  <list>
126
+ <item itemvalue="npm.commit" />
125
127
  <item itemvalue="npm.build-documentation" />
126
128
  <item itemvalue="JavaScript Debug.documentation.html (1)" />
127
129
  <item itemvalue="npm.test" />
128
130
  <item itemvalue="Jest.index.test.js" />
129
- <item itemvalue="Jest.#errors" />
130
131
  </list>
131
132
  </recent_temporary>
132
133
  </component>
@@ -587,7 +588,8 @@
587
588
  <workItem from="1595858491503" duration="4159000" />
588
589
  <workItem from="1595865087442" duration="564000" />
589
590
  <workItem from="1595914052000" duration="4102000" />
590
- <workItem from="1595939490548" duration="2929000" />
591
+ <workItem from="1595939490548" duration="3433000" />
592
+ <workItem from="1595961689372" duration="947000" />
591
593
  </task>
592
594
  <servers />
593
595
  </component>
@@ -630,22 +632,22 @@
630
632
  <screen x="0" y="23" width="2048" height="1129" />
631
633
  </state>
632
634
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
633
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1595942694587">
635
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1595963463155">
634
636
  <screen x="0" y="23" width="2048" height="1129" />
635
637
  </state>
636
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1595942694587" />
637
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1595942694587">
638
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463155" />
639
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1595963463154">
638
640
  <screen x="0" y="23" width="2048" height="1129" />
639
641
  </state>
640
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1595942694587" />
641
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1595942694586">
642
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463154" />
643
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1595963463154">
642
644
  <screen x="0" y="23" width="2048" height="1129" />
643
645
  </state>
644
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1595942694586" />
645
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1595942694587">
646
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463154" />
647
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1595963463155">
646
648
  <screen x="0" y="23" width="2048" height="1129" />
647
649
  </state>
648
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1595942694587" />
650
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1595963463155" />
649
651
  <state x="689" y="276" width="670" height="676" key="search.everywhere.popup" timestamp="1595579270021">
650
652
  <screen x="0" y="23" width="2048" height="1129" />
651
653
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [33.0.9](https://github.com/GLS-Spain/gps-common/compare/v33.0.8...v33.0.9) (2020-07-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add sale does not exist error when creating an expedition with a shop and a sale ([2c7f9b1](https://github.com/GLS-Spain/gps-common/commit/2c7f9b1db39b9f68c8100b119cef80eccdf10f76))
7
+
8
+ ## [33.0.8](https://github.com/GLS-Spain/gps-common/compare/v33.0.7...v33.0.8) (2020-07-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * create expedition accepts a referenced sale only when created with a shop ([a19bfd0](https://github.com/GLS-Spain/gps-common/commit/a19bfd007d07691be15bc486a85d7392e52a2530))
14
+
1
15
  ## [33.0.7](https://github.com/GLS-Spain/gps-common/compare/v33.0.6...v33.0.7) (2020-07-28)
2
16
 
3
17
 
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class SaleDoesNotExistError extends DatabaseError {
4
+ constructor(message = 'Sale does not exist.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'SaleDoesNotExistError';
8
+ }
9
+ }
10
+
11
+ module.exports = SaleDoesNotExistError;
package/errors/index.js CHANGED
@@ -27,6 +27,7 @@ const RepresentativeCannotBeDeletedError = require('./RepresentativeCannotBeDele
27
27
  const ZoneDoesNotExistError = require('./ZoneDoesNotExistError');
28
28
  const ZoneAlreadyExistsError = require('./ZoneAlreadyExistsError');
29
29
  const ZoneCannotBeDeletedError = require('./ZoneCannotBeDeletedError');
30
+ const SaleDoesNotExistError = require('./SaleDoesNotExistError');
30
31
  const SaleAlreadyExistsError = require('./SaleAlreadyExistsError');
31
32
  const InconsistentSalesSettingsError = require('./InconsistentSalesSettingsError');
32
33
  const InvalidSaleDestinationError = require('./InvalidSaleDestinationError');
@@ -61,6 +62,7 @@ const errorsNames = {
61
62
  ZoneDoesNotExistError: 'ZoneDoesNotExistError',
62
63
  ZoneAlreadyExistsError: 'ZoneAlreadyExistsError',
63
64
  ZoneCannotBeDeletedError: 'ZoneCannotBeDeletedError',
65
+ SaleDoesNotExistError: 'SaleDoesNotExistError',
64
66
  SaleAlreadyExistsError: 'SaleAlreadyExistsError',
65
67
  InconsistentSalesSettingsError: 'InconsistentSalesSettingsError',
66
68
  InvalidSaleDestinationError: 'InvalidSaleDestinationError',
@@ -96,6 +98,7 @@ module.exports = {
96
98
  ZoneDoesNotExistError,
97
99
  ZoneAlreadyExistsError,
98
100
  ZoneCannotBeDeletedError,
101
+ SaleDoesNotExistError,
99
102
  SaleAlreadyExistsError,
100
103
  InconsistentSalesSettingsError,
101
104
  InvalidSaleDestinationError,
@@ -38,6 +38,7 @@ const {
38
38
  ZoneDoesNotExistError,
39
39
  ZoneAlreadyExistsError,
40
40
  ZoneCannotBeDeletedError,
41
+ SaleDoesNotExistError,
41
42
  SaleAlreadyExistsError,
42
43
  InconsistentSalesSettingsError,
43
44
  InvalidSaleDestinationError,
@@ -747,7 +748,7 @@ records. Since they are part of their expedition historic records, PODs do not h
747
748
  <SchemaDefinition schemaRef="#/components/schemas/pod" />`,
748
749
  },
749
750
  {
750
- name: 'Sales', // todo
751
+ name: 'Sales',
751
752
  description: `Create and find sales.
752
753
 
753
754
  Customers can go to a parcel shop at any time and pay to have a package sent to an allowed destination.
@@ -857,6 +858,7 @@ const errors = {
857
858
  zoneDoesNotExist: new ZoneDoesNotExistError(),
858
859
  zoneAlreadyExists: new ZoneAlreadyExistsError(),
859
860
  zoneCannotBeDeleted: new ZoneCannotBeDeletedError(),
861
+ saleDoesNotExist: new SaleDoesNotExistError(),
860
862
  saleAlreadyExists: new SaleAlreadyExistsError(),
861
863
  inconsistentSalesSettings: new InconsistentSalesSettingsError(),
862
864
  invalidSaleDestination: new InvalidSaleDestinationError(),
@@ -1007,6 +1009,10 @@ const responses = {
1007
1009
  description: 'The zone cannot be deleted.',
1008
1010
  content: { 'application/json': { schema: specificHttpError(errors.zoneCannotBeDeleted) } },
1009
1011
  },
1012
+ saleDoesNotExist: {
1013
+ description: 'The sale does not exist.',
1014
+ content: { 'application/json': { schema: specificHttpError(errors.saleDoesNotExist) } },
1015
+ },
1010
1016
  saleAlreadyExists: {
1011
1017
  description: 'The sale already exists.',
1012
1018
  content: { 'application/json': { schema: specificHttpError(errors.saleAlreadyExists) } },
@@ -2547,6 +2553,9 @@ An expedition can be associated on creation to either a shop or a network:
2547
2553
  If the provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, if it is not enabled it will return a
2548
2554
  \`500 ShopNotEnabledError\`, and if it is readonly it will return a \`500 ShopCannotBeUpdatedError\`.
2549
2555
 
2556
+ When providing a shop one can also provide a sale if the expedition is created because of it. If the provided sale does not
2557
+ exist the API will return a \`500 SaleDoesNotExistError\`.
2558
+
2550
2559
  If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
2551
2560
 
2552
2561
  The \`status.code\` of a new expedition cannot be specified and it will always be \`incoming\`.
@@ -2575,6 +2584,7 @@ ${securitySchemes.superAdminRole}`,
2575
2584
  ' 500 ': responses.shopNotEnabled,
2576
2585
  ' 500 ': responses.shopCannotBeUpdated,
2577
2586
  ' 500 ': responses.networkDoesNotExist,
2587
+ ' 500 ': responses.saleDoesNotExist,
2578
2588
  },
2579
2589
  },
2580
2590
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "33.0.7",
3
+ "version": "33.0.9",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -188,7 +188,7 @@ const expedition = () => ({
188
188
  additionalProperties: false,
189
189
  description: 'only available for deliveries and pickups after reception at the shop',
190
190
  },
191
- sale: mergeSchemas(objectWithUuid(), { description: 'associated sale, only for pickups created because of a sale' }),
191
+ sale: mergeSchemas(objectWithUuid(), { description: 'associated sale, only for expeditions created because of a sale' }),
192
192
  barcodes: { type: 'array', items: { type: 'string', trim: true } },
193
193
  packageCount: { type: 'integer' },
194
194
  weight: { type: 'number' },
@@ -348,7 +348,6 @@ const createExpeditionWithNetwork = () => ({
348
348
  'scheduleCode',
349
349
  'date',
350
350
  'expectedDeliveryDate',
351
- 'sale',
352
351
  'barcodes',
353
352
  'packageCount',
354
353
  'weight',