@gls_spain/gps-common 34.1.1 → 34.3.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,10 @@
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/ShopCannotSellError.js" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
5
7
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/shops.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/shops.js" afterDir="false" />
6
9
  </list>
7
10
  <option name="SHOW_DIALOG" value="false" />
8
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -61,13 +64,6 @@
61
64
  <property name="vue.rearranger.settings.migration" value="true" />
62
65
  </component>
63
66
  <component name="RecentsManager">
64
- <key name="CopyFile.RECENT_KEYS">
65
- <recent name="$PROJECT_DIR$/errors" />
66
- <recent name="$PROJECT_DIR$/schemas/definitions" />
67
- <recent name="$PROJECT_DIR$" />
68
- <recent name="$PROJECT_DIR$/schemas" />
69
- <recent name="$PROJECT_DIR$/lib/scripts" />
70
- </key>
71
67
  <key name="MoveFile.RECENT_KEYS">
72
68
  <recent name="$PROJECT_DIR$/open-api" />
73
69
  <recent name="$PROJECT_DIR$" />
@@ -75,6 +71,13 @@
75
71
  <recent name="$PROJECT_DIR$/open-api-spec" />
76
72
  <recent name="$PROJECT_DIR$/errors" />
77
73
  </key>
74
+ <key name="CopyFile.RECENT_KEYS">
75
+ <recent name="$PROJECT_DIR$/errors" />
76
+ <recent name="$PROJECT_DIR$/schemas/definitions" />
77
+ <recent name="$PROJECT_DIR$" />
78
+ <recent name="$PROJECT_DIR$/schemas" />
79
+ <recent name="$PROJECT_DIR$/lib/scripts" />
80
+ </key>
78
81
  </component>
79
82
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
80
83
  <configuration name="documentation.html (1)" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gps-common/build/documentation/documentation.html" useBuiltInWebServerPort="true">
@@ -618,7 +621,11 @@
618
621
  <workItem from="1598357442597" duration="26000" />
619
622
  <workItem from="1599218272722" duration="619000" />
620
623
  <workItem from="1599296807455" duration="54000" />
621
- <workItem from="1599574256014" duration="232000" />
624
+ <workItem from="1599574256014" duration="436000" />
625
+ <workItem from="1599675057970" duration="1442000" />
626
+ <workItem from="1599722212402" duration="763000" />
627
+ <workItem from="1600358026541" duration="773000" />
628
+ <workItem from="1600676045368" duration="641000" />
622
629
  </task>
623
630
  <servers />
624
631
  </component>
@@ -661,22 +668,22 @@
661
668
  <screen x="0" y="23" width="2048" height="1129" />
662
669
  </state>
663
670
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
664
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1598188195051">
671
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1600358643265">
665
672
  <screen x="0" y="23" width="2048" height="1129" />
666
673
  </state>
667
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195051" />
668
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1598188195050">
674
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1600358643265" />
675
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1600358643265">
669
676
  <screen x="0" y="23" width="2048" height="1129" />
670
677
  </state>
671
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195050" />
672
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1598188195050">
678
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1600358643265" />
679
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1600358643265">
673
680
  <screen x="0" y="23" width="2048" height="1129" />
674
681
  </state>
675
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195050" />
676
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1598188195051">
682
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1600358643265" />
683
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1600358643265">
677
684
  <screen x="0" y="23" width="2048" height="1129" />
678
685
  </state>
679
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195051" />
686
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1600358643265" />
680
687
  <state x="725" y="342" width="736" height="612" key="find.popup" timestamp="1598206991663">
681
688
  <screen x="0" y="23" width="2048" height="1129" />
682
689
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [34.3.0](https://github.com/GLS-Spain/gps-common/compare/v34.2.0...v34.3.0) (2020-09-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * add sell capability to shops and allow only shops with it to create sales ([74f9c41](https://github.com/GLS-Spain/gps-common/commit/74f9c415ed6b8e3c17d891a1c2c25e16193f2328))
7
+
8
+ # [34.2.0](https://github.com/GLS-Spain/gps-common/compare/v34.1.1...v34.2.0) (2020-09-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * add /sales/update ([61be4c5](https://github.com/GLS-Spain/gps-common/commit/61be4c5f9f91f4e395939ba9db8c2cf3467da171))
14
+
1
15
  ## [34.1.1](https://github.com/GLS-Spain/gps-common/compare/v34.1.0...v34.1.1) (2020-09-08)
2
16
 
3
17
 
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class ShopCannotSellError extends DatabaseError {
4
+ constructor(message = 'Shop cannot sell.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'ShopCannotSellError';
8
+ }
9
+ }
10
+
11
+ module.exports = ShopCannotSellError;
package/errors/index.js CHANGED
@@ -12,6 +12,7 @@ const ShopDoesNotExistError = require('./ShopDoesNotExistError');
12
12
  const ShopAlreadyExistsError = require('./ShopAlreadyExistsError');
13
13
  const ShopCannotBeUpdatedError = require('./ShopCannotBeUpdatedError');
14
14
  const ShopCannotBeDeletedError = require('./ShopCannotBeDeletedError');
15
+ const ShopCannotSellError = require('./ShopCannotSellError');
15
16
  const ShopNotEnabledError = require('./ShopNotEnabledError');
16
17
  const WrongShopError = require('./WrongShopError');
17
18
  const WrongPasswordError = require('./WrongPasswordError');
@@ -47,6 +48,7 @@ const errorsNames = {
47
48
  ShopAlreadyExistsError: 'ShopAlreadyExistsError',
48
49
  ShopCannotBeUpdatedError: 'ShopCannotBeUpdatedError',
49
50
  ShopCannotBeDeletedError: 'ShopCannotBeDeletedError',
51
+ ShopCannotSellError: 'ShopCannotSellError',
50
52
  ShopNotEnabledError: 'ShopNotEnabledError',
51
53
  WrongShopError: 'WrongShopError',
52
54
  WrongPasswordError: 'WrongPasswordError',
@@ -83,6 +85,7 @@ module.exports = {
83
85
  ShopAlreadyExistsError,
84
86
  ShopCannotBeUpdatedError,
85
87
  ShopCannotBeDeletedError,
88
+ ShopCannotSellError,
86
89
  ShopNotEnabledError,
87
90
  WrongShopError,
88
91
  WrongPasswordError,
@@ -24,6 +24,7 @@ const {
24
24
  ShopAlreadyExistsError,
25
25
  ShopCannotBeUpdatedError,
26
26
  ShopCannotBeDeletedError,
27
+ ShopCannotSellError,
27
28
  ShopNotEnabledError,
28
29
  WrongPasswordError,
29
30
  ExpeditionDoesNotExistError,
@@ -178,6 +179,8 @@ const {
178
179
  findSalesResponse,
179
180
  checkSalePriceRequest,
180
181
  checkSalePriceResponse,
182
+ updateSaleRequest,
183
+ updateSaleResponse,
181
184
  } = require('../schemas/definitions/sales');
182
185
 
183
186
  const openApiSpec = { openapi: '3.0.2' };
@@ -885,6 +888,7 @@ const errors = {
885
888
  shopAlreadyExists: new ShopAlreadyExistsError(),
886
889
  shopCannotBeUpdated: new ShopCannotBeUpdatedError(),
887
890
  shopCannotBeDeleted: new ShopCannotBeDeletedError(),
891
+ shopCannotSell: new ShopCannotSellError(),
888
892
  shopNotEnabled: new ShopNotEnabledError(),
889
893
  wrongPassword: new WrongPasswordError(),
890
894
  expeditionDoesNotExist: new ExpeditionDoesNotExistError(),
@@ -994,6 +998,10 @@ const responses = {
994
998
  description: 'The shop cannot be deleted.',
995
999
  content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
996
1000
  },
1001
+ shopCannotSell: {
1002
+ description: 'The shop does not have the capability to sell.',
1003
+ content: { 'application/json': { schema: specificHttpError(errors.shopCannotSell) } },
1004
+ },
997
1005
  shopNotEnabled: {
998
1006
  description: 'The shop is not enabled.',
999
1007
  content: { 'application/json': { schema: specificHttpError(errors.shopNotEnabled) } },
@@ -3126,6 +3134,8 @@ The \`price\` field will be calculated from the \`size\` and \`settings\` fields
3126
3134
  If the shop the user belongs to is not enabled the API will return a \`500 ShopNotEnabledError\` and if the shop is readonly it will
3127
3135
  return a \`500 ShopCannotBeUpdatedError\`.
3128
3136
 
3137
+ If the shop does not have the capability to sell the API will return a \`500 ShopCannotSellError\`.
3138
+
3129
3139
  If the destination is invalid the API will return a \`500 InvalidSaleDestinationError\`.
3130
3140
 
3131
3141
  ${securitySchemes.tokens}
@@ -3150,7 +3160,8 @@ ${securitySchemes.shopUserRole}`,
3150
3160
  ' 500 ': responses.saleAlreadyExists,
3151
3161
  ' 500 ': responses.shopNotEnabled,
3152
3162
  ' 500 ': responses.shopCannotBeUpdated,
3153
- ' 500 ': responses.invalidSaleDestination,
3163
+ ' 500 ': responses.shopCannotSell,
3164
+ ' 500 ': responses.invalidSaleDestination,
3154
3165
  },
3155
3166
  },
3156
3167
  },
@@ -3285,6 +3296,36 @@ ${securitySchemes.anyRole}`,
3285
3296
  },
3286
3297
  },
3287
3298
  },
3299
+ '/sales/update': {
3300
+ post: {
3301
+ tags: ['Sales'],
3302
+ summary: '[S] Update',
3303
+ description: `
3304
+ Finds a sale and updates the provided properties.
3305
+
3306
+ ${securitySchemes.tokens}
3307
+ ${securitySchemes.superAdminRole}`,
3308
+ requestBody: {
3309
+ content: { 'application/json': { schema: updateSaleRequest() } },
3310
+ required: true,
3311
+ },
3312
+ responses: {
3313
+ ' 200': {
3314
+ description: 'Contains the updated sale.',
3315
+ content: { 'application/json': { schema: updateSaleResponse() } },
3316
+ },
3317
+ ' 400': responses.badRequest,
3318
+ ' 401': responses.invalidUserInCookieOrHeader,
3319
+ ' 401 ': responses.invalidCookieOrHeader,
3320
+ ' 401 ': responses.missingCookieOrHeader,
3321
+ ' 401 ': responses.unauthorized,
3322
+ ' 403': responses.forbidden,
3323
+ ' 415': responses.unsupportedMediaType,
3324
+ ' 500': responses.internalServerError,
3325
+ ' 500 ': responses.saleDoesNotExist,
3326
+ },
3327
+ },
3328
+ },
3288
3329
  '/historicRecords/find': {
3289
3330
  post: {
3290
3331
  tags: ['Historic records'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.1.1",
3
+ "version": "34.3.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -27,33 +27,33 @@
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
- "@semantic-release/changelog": "^5.0.0",
30
+ "@semantic-release/changelog": "^5.0.1",
31
31
  "@semantic-release/git": "^9.0.0",
32
- "@semantic-release/npm": "^7.0.5",
32
+ "@semantic-release/npm": "^7.0.6",
33
33
  "@semantic-release/release-notes-generator": "^9.0.1",
34
- "@types/jest": "^25.1.4",
35
- "ajv": "^6.12.0",
36
- "commitizen": "^4.0.3",
37
- "cz-conventional-changelog": "^3.1.0",
34
+ "@types/jest": "^25.2.3",
35
+ "ajv": "^6.12.5",
36
+ "commitizen": "^4.2.1",
37
+ "cz-conventional-changelog": "^3.3.0",
38
38
  "eslint": "^6.8.0",
39
- "eslint-config-airbnb-base": "^14.1.0",
40
- "eslint-config-prettier": "^6.10.1",
41
- "eslint-plugin-import": "^2.20.1",
42
- "husky": "^4.2.3",
43
- "jest": "^25.1.0",
39
+ "eslint-config-airbnb-base": "^14.2.0",
40
+ "eslint-config-prettier": "^6.11.0",
41
+ "eslint-plugin-import": "^2.22.0",
42
+ "husky": "^4.3.0",
43
+ "jest": "^25.5.4",
44
44
  "prettier": "^1.19.1",
45
- "redoc-cli": "^0.9.7",
46
- "semantic-release": "^17.0.4"
45
+ "redoc-cli": "^0.9.12",
46
+ "semantic-release": "^17.1.1"
47
47
  },
48
48
  "dependencies": {
49
- "@gls_spain/ajv-options": "^1.1.0",
50
- "@gls_spain/common-errors": "^1.0.0",
51
- "@gls_spain/common-json-schemas": "^1.1.0",
52
- "@gls_spain/mongodb": "^1.1.0",
53
- "@gls_spain/winston-transports": "^1.0.0",
54
- "lodash": "^4.17.15",
55
- "winston": "^3.2.1",
56
- "yargs": "^15.3.1"
49
+ "@gls_spain/ajv-options": "^1.1.2",
50
+ "@gls_spain/common-errors": "^1.1.0",
51
+ "@gls_spain/common-json-schemas": "^1.2.4",
52
+ "@gls_spain/mongodb": "^1.2.0",
53
+ "@gls_spain/winston-transports": "^1.0.2",
54
+ "lodash": "^4.17.20",
55
+ "winston": "^3.3.3",
56
+ "yargs": "^15.4.1"
57
57
  },
58
58
  "scripts": {
59
59
  "commit": "git-cz",
@@ -8,6 +8,8 @@ const {
8
8
  createResponse,
9
9
  findRequest,
10
10
  findResponse,
11
+ updateRequest,
12
+ updateResponse,
11
13
  mergeSchemas,
12
14
  pickProperties,
13
15
  } = require('@gls_spain/common-json-schemas');
@@ -181,6 +183,16 @@ const checkSalePriceResponse = () => ({
181
183
  additionalProperties: false,
182
184
  });
183
185
 
186
+ const updateSaleRequest = () =>
187
+ updateRequest(findById(), {
188
+ type: 'object',
189
+ properties: { ...pickProperties(sale(), ['status']) },
190
+ minProperties: 1,
191
+ additionalProperties: false,
192
+ });
193
+
194
+ const updateSaleResponse = () => updateResponse(sale());
195
+
184
196
  module.exports = {
185
197
  sale,
186
198
  createSaleRequest,
@@ -191,4 +203,6 @@ module.exports = {
191
203
  findSalesResponse,
192
204
  checkSalePriceRequest,
193
205
  checkSalePriceResponse,
206
+ updateSaleRequest,
207
+ updateSaleResponse,
194
208
  };
@@ -187,7 +187,7 @@ const shop = () => ({
187
187
  address: addressWithRequiredLocation(),
188
188
  capabilities: {
189
189
  type: 'array',
190
- items: { type: 'string', enum: ['deliver', 'pickup'] },
190
+ items: { type: 'string', enum: ['deliver', 'pickup', 'sell'] },
191
191
  uniqueItems: true,
192
192
  },
193
193
  openingSchedule: shopSchedule(),
package/schemas/index.js CHANGED
@@ -112,6 +112,8 @@ const {
112
112
  findSalesResponse,
113
113
  checkSalePriceRequest,
114
114
  checkSalePriceResponse,
115
+ updateSaleRequest,
116
+ updateSaleResponse,
115
117
  } = require('./definitions/sales');
116
118
 
117
119
  function request(schema, $id) {
@@ -245,6 +247,8 @@ const salesFindShopUserRequest = request(findSalesShopUserRequest(), 'salesFindS
245
247
  const salesFindResponse = response(findSalesResponse(), 'salesFindResponse');
246
248
  const salesCheckPriceRequest = request(checkSalePriceRequest(), 'salesCheckPriceRequest');
247
249
  const salesCheckPriceResponse = response(checkSalePriceResponse(), 'salesCheckPriceResponse');
250
+ const salesUpdateRequest = request(updateSaleRequest(), 'salesUpdateRequest');
251
+ const salesUpdateResponse = response(updateSaleResponse(), 'salesUpdateResponse');
248
252
 
249
253
  module.exports = {
250
254
  errorResponse,
@@ -367,4 +371,6 @@ module.exports = {
367
371
  salesFindResponse,
368
372
  salesCheckPriceRequest,
369
373
  salesCheckPriceResponse,
374
+ salesUpdateRequest,
375
+ salesUpdateResponse,
370
376
  };