@gls_spain/gps-common 34.2.0 → 34.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.
@@ -3,9 +3,7 @@
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
5
5
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/representatives.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/representatives.js" afterDir="false" />
9
7
  <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
10
8
  </list>
11
9
  <option name="SHOW_DIALOG" value="false" />
@@ -65,13 +63,6 @@
65
63
  <property name="vue.rearranger.settings.migration" value="true" />
66
64
  </component>
67
65
  <component name="RecentsManager">
68
- <key name="CopyFile.RECENT_KEYS">
69
- <recent name="$PROJECT_DIR$/errors" />
70
- <recent name="$PROJECT_DIR$/schemas/definitions" />
71
- <recent name="$PROJECT_DIR$" />
72
- <recent name="$PROJECT_DIR$/schemas" />
73
- <recent name="$PROJECT_DIR$/lib/scripts" />
74
- </key>
75
66
  <key name="MoveFile.RECENT_KEYS">
76
67
  <recent name="$PROJECT_DIR$/open-api" />
77
68
  <recent name="$PROJECT_DIR$" />
@@ -79,6 +70,13 @@
79
70
  <recent name="$PROJECT_DIR$/open-api-spec" />
80
71
  <recent name="$PROJECT_DIR$/errors" />
81
72
  </key>
73
+ <key name="CopyFile.RECENT_KEYS">
74
+ <recent name="$PROJECT_DIR$/errors" />
75
+ <recent name="$PROJECT_DIR$/schemas/definitions" />
76
+ <recent name="$PROJECT_DIR$" />
77
+ <recent name="$PROJECT_DIR$/schemas" />
78
+ <recent name="$PROJECT_DIR$/lib/scripts" />
79
+ </key>
82
80
  </component>
83
81
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
84
82
  <configuration name="documentation.html (1)" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gps-common/build/documentation/documentation.html" useBuiltInWebServerPort="true">
@@ -126,8 +124,8 @@
126
124
  </configuration>
127
125
  <recent_temporary>
128
126
  <list>
129
- <item itemvalue="JavaScript Debug.documentation.html (1)" />
130
127
  <item itemvalue="npm.build-documentation" />
128
+ <item itemvalue="JavaScript Debug.documentation.html (1)" />
131
129
  <item itemvalue="npm.test" />
132
130
  <item itemvalue="npm.semantic-release" />
133
131
  <item itemvalue="npm.commit" />
@@ -625,7 +623,11 @@
625
623
  <workItem from="1599574256014" duration="436000" />
626
624
  <workItem from="1599675057970" duration="1442000" />
627
625
  <workItem from="1599722212402" duration="763000" />
628
- <workItem from="1600358026541" duration="623000" />
626
+ <workItem from="1600358026541" duration="773000" />
627
+ <workItem from="1600676045368" duration="1246000" />
628
+ <workItem from="1600679037395" duration="238000" />
629
+ <workItem from="1600875504930" duration="94000" />
630
+ <workItem from="1601025758747" duration="856000" />
629
631
  </task>
630
632
  <servers />
631
633
  </component>
@@ -668,22 +670,22 @@
668
670
  <screen x="0" y="23" width="2048" height="1129" />
669
671
  </state>
670
672
  <state x="762" y="341" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1595577705727" />
671
- <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1598188195051">
673
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1601026389150">
672
674
  <screen x="0" y="23" width="2048" height="1129" />
673
675
  </state>
674
- <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195051" />
675
- <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1598188195050">
676
+ <state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1601026389150" />
677
+ <state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1601026389149">
676
678
  <screen x="0" y="23" width="2048" height="1129" />
677
679
  </state>
678
- <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195050" />
679
- <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1598188195050">
680
+ <state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1601026389149" />
681
+ <state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1601026389149">
680
682
  <screen x="0" y="23" width="2048" height="1129" />
681
683
  </state>
682
- <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195050" />
683
- <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1598188195051">
684
+ <state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1601026389149" />
685
+ <state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1601026389149">
684
686
  <screen x="0" y="23" width="2048" height="1129" />
685
687
  </state>
686
- <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1598188195051" />
688
+ <state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1601026389149" />
687
689
  <state x="725" y="342" width="736" height="612" key="find.popup" timestamp="1598206991663">
688
690
  <screen x="0" y="23" width="2048" height="1129" />
689
691
  </state>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [34.4.0](https://github.com/GLS-Spain/gps-common/compare/v34.3.0...v34.4.0) (2020-09-25)
2
+
3
+
4
+ ### Features
5
+
6
+ * add GET representatives/getOwn ([7e3f5bf](https://github.com/GLS-Spain/gps-common/commit/7e3f5bfd3675f328f9b4f080661a92b9a55202b6))
7
+
8
+ # [34.3.0](https://github.com/GLS-Spain/gps-common/compare/v34.2.0...v34.3.0) (2020-09-21)
9
+
10
+
11
+ ### Features
12
+
13
+ * add sell capability to shops and allow only shops with it to create sales ([74f9c41](https://github.com/GLS-Spain/gps-common/commit/74f9c415ed6b8e3c17d891a1c2c25e16193f2328))
14
+
1
15
  # [34.2.0](https://github.com/GLS-Spain/gps-common/compare/v34.1.1...v34.2.0) (2020-09-17)
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,
@@ -147,6 +148,7 @@ const {
147
148
  findRepresentativesRequest,
148
149
  findRepresentativesResponse,
149
150
  listRepresentativesNamesResponse,
151
+ getOwnRepresentativesResponse,
150
152
  updateRepresentativeRequest,
151
153
  updateRepresentativeResponse,
152
154
  getRepresentativeCommissionsRequest,
@@ -887,6 +889,7 @@ const errors = {
887
889
  shopAlreadyExists: new ShopAlreadyExistsError(),
888
890
  shopCannotBeUpdated: new ShopCannotBeUpdatedError(),
889
891
  shopCannotBeDeleted: new ShopCannotBeDeletedError(),
892
+ shopCannotSell: new ShopCannotSellError(),
890
893
  shopNotEnabled: new ShopNotEnabledError(),
891
894
  wrongPassword: new WrongPasswordError(),
892
895
  expeditionDoesNotExist: new ExpeditionDoesNotExistError(),
@@ -996,6 +999,10 @@ const responses = {
996
999
  description: 'The shop cannot be deleted.',
997
1000
  content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
998
1001
  },
1002
+ shopCannotSell: {
1003
+ description: 'The shop does not have the capability to sell.',
1004
+ content: { 'application/json': { schema: specificHttpError(errors.shopCannotSell) } },
1005
+ },
999
1006
  shopNotEnabled: {
1000
1007
  description: 'The shop is not enabled.',
1001
1008
  content: { 'application/json': { schema: specificHttpError(errors.shopNotEnabled) } },
@@ -2060,6 +2067,31 @@ ${securitySchemes.superAdminRole}`,
2060
2067
  },
2061
2068
  },
2062
2069
  },
2070
+ '/representatives/getOwn': {
2071
+ get: {
2072
+ tags: ['Sales representatives'],
2073
+ summary: '[U] Get own',
2074
+ description: `
2075
+ Gets the opening and managing representatives of the user's own shop.
2076
+
2077
+ ${securitySchemes.tokens}
2078
+ ${securitySchemes.shopUserRole}`,
2079
+ responses: {
2080
+ ' 200': {
2081
+ description: 'Contains the opening and managing representative of the shop.',
2082
+ content: { 'application/json': { schema: getOwnRepresentativesResponse() } },
2083
+ },
2084
+ ' 400': responses.badRequest,
2085
+ ' 401': responses.invalidUserInCookieOrHeader,
2086
+ ' 401 ': responses.invalidCookieOrHeader,
2087
+ ' 401 ': responses.missingCookieOrHeader,
2088
+ ' 401 ': responses.unauthorized,
2089
+ ' 403': responses.forbidden,
2090
+ ' 415': responses.unsupportedMediaType,
2091
+ ' 500': responses.internalServerError,
2092
+ },
2093
+ },
2094
+ },
2063
2095
  '/representatives/find': {
2064
2096
  post: {
2065
2097
  tags: ['Sales representatives'],
@@ -3128,6 +3160,8 @@ The \`price\` field will be calculated from the \`size\` and \`settings\` fields
3128
3160
  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
3129
3161
  return a \`500 ShopCannotBeUpdatedError\`.
3130
3162
 
3163
+ If the shop does not have the capability to sell the API will return a \`500 ShopCannotSellError\`.
3164
+
3131
3165
  If the destination is invalid the API will return a \`500 InvalidSaleDestinationError\`.
3132
3166
 
3133
3167
  ${securitySchemes.tokens}
@@ -3152,7 +3186,8 @@ ${securitySchemes.shopUserRole}`,
3152
3186
  ' 500 ': responses.saleAlreadyExists,
3153
3187
  ' 500 ': responses.shopNotEnabled,
3154
3188
  ' 500 ': responses.shopCannotBeUpdated,
3155
- ' 500 ': responses.invalidSaleDestination,
3189
+ ' 500 ': responses.shopCannotSell,
3190
+ ' 500 ': responses.invalidSaleDestination,
3156
3191
  },
3157
3192
  },
3158
3193
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.2.0",
3
+ "version": "34.4.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -76,6 +76,16 @@ const listRepresentativesNamesResponse = () => ({
76
76
  additionalProperties: false,
77
77
  });
78
78
 
79
+ const getOwnRepresentativesResponse = () => ({
80
+ type: 'object',
81
+ properties: {
82
+ openingRepresentative: representative(),
83
+ managingRepresentative: representative(),
84
+ },
85
+ required: ['openingRepresentative', 'managingRepresentative'],
86
+ additionalProperties: false,
87
+ });
88
+
79
89
  const updateRepresentativeRequest = () =>
80
90
  updateRequest(
81
91
  findById(),
@@ -168,6 +178,7 @@ module.exports = {
168
178
  findRepresentativesRequest,
169
179
  findRepresentativesResponse,
170
180
  listRepresentativesNamesResponse,
181
+ getOwnRepresentativesResponse,
171
182
  updateRepresentativeRequest,
172
183
  updateRepresentativeResponse,
173
184
  getRepresentativeCommissionsRequest,
@@ -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
@@ -83,6 +83,7 @@ const {
83
83
  findRepresentativesRequest,
84
84
  findRepresentativesResponse,
85
85
  listRepresentativesNamesResponse,
86
+ getOwnRepresentativesResponse,
86
87
  updateRepresentativeRequest,
87
88
  updateRepresentativeResponse,
88
89
  getRepresentativeCommissionsRequest,
@@ -214,6 +215,7 @@ const podsFindResponse = response(findPodsResponse(), 'podsFindResponse');
214
215
  const representativesCreateRequest = request(createRepresentativeRequest(), 'representativesCreateRequest');
215
216
  const representativesCreateResponse = response(createRepresentativeResponse(), 'representativesCreateResponse');
216
217
  const representativesListNamesResponse = response(listRepresentativesNamesResponse(), 'representativesListNamesResponse');
218
+ const representativesGetOwnResponse = response(getOwnRepresentativesResponse(), 'representativesGetOwnResponse');
217
219
  const representativesFindRequest = request(findRepresentativesRequest(), 'representativesFindRequest');
218
220
  const representativesFindResponse = response(findRepresentativesResponse(), 'representativesFindResponse');
219
221
  const representativesUpdateRequest = request(updateRepresentativeRequest(), 'representativesUpdateRequest');
@@ -338,6 +340,7 @@ module.exports = {
338
340
  representativesCreateRequest,
339
341
  representativesCreateResponse,
340
342
  representativesListNamesResponse,
343
+ representativesGetOwnResponse,
341
344
  representativesFindRequest,
342
345
  representativesFindResponse,
343
346
  representativesUpdateRequest,