@gls_spain/gps-common 34.8.0 → 34.9.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,12 +2,8 @@
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$/.idea/prettier.xml" afterDir="false" />
6
- <change afterPath="$PROJECT_DIR$/errors/LabelDoesNotExistError.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/.idea/watcherTasks.xml" beforeDir="false" />
8
- <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
9
5
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
6
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/common.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/common.js" afterDir="false" />
11
7
  <change beforePath="$PROJECT_DIR$/schemas/definitions/expeditions.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/expeditions.js" afterDir="false" />
12
8
  <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
13
9
  <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
@@ -130,8 +126,8 @@
130
126
  </configuration>
131
127
  <recent_temporary>
132
128
  <list>
133
- <item itemvalue="npm.build-documentation" />
134
129
  <item itemvalue="npm.test" />
130
+ <item itemvalue="npm.build-documentation" />
135
131
  <item itemvalue="JavaScript Debug.documentation.html (1)" />
136
132
  <item itemvalue="npm.semantic-release" />
137
133
  <item itemvalue="npm.commit" />
@@ -651,7 +647,10 @@
651
647
  <workItem from="1606477130384" duration="74000" />
652
648
  <workItem from="1606835326733" duration="48000" />
653
649
  <workItem from="1607951320583" duration="589000" />
654
- <workItem from="1610108917407" duration="2232000" />
650
+ <workItem from="1610108917407" duration="2502000" />
651
+ <workItem from="1610134729440" duration="18000" />
652
+ <workItem from="1610542075615" duration="660000" />
653
+ <workItem from="1610988300441" duration="4154000" />
655
654
  </task>
656
655
  <servers />
657
656
  </component>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [34.9.0](https://github.com/GLS-Spain/gps-common/compare/v34.8.1...v34.9.0) (2021-01-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * add expire, unexpire, update derivation, add date range to find expeditions and sales ([8290523](https://github.com/GLS-Spain/gps-common/commit/8290523fe0fc0f366cf0a1299a3a2b3484f20d16))
7
+
8
+ ## [34.8.1](https://github.com/GLS-Spain/gps-common/compare/v34.8.0...v34.8.1) (2021-01-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * change expedition and sale download label response to base 64 ([7306949](https://github.com/GLS-Spain/gps-common/commit/73069495d21900dd5e0c93c1c0e02436e109333c))
14
+
1
15
  # [34.8.0](https://github.com/GLS-Spain/gps-common/compare/v34.7.0...v34.8.0) (2021-01-08)
2
16
 
3
17
 
@@ -128,6 +128,10 @@ const {
128
128
  receiveAllExpeditionsFromDriverRequest,
129
129
  receiveAllExpeditionsFromDriverResponse,
130
130
  downloadExpeditionLabelRequest,
131
+ downloadExpeditionLabelResponse,
132
+ expireExpeditionRequest,
133
+ unexpireExpeditionRequest,
134
+ updateExpeditionDerivationRequest,
131
135
  } = require('../schemas/definitions/expeditions');
132
136
  const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
133
137
  const { counters, getCountersResponse } = require('../schemas/definitions/counters');
@@ -186,6 +190,7 @@ const {
186
190
  updateSaleRequest,
187
191
  updateSaleResponse,
188
192
  downloadSaleLabelRequest,
193
+ downloadSaleLabelResponse,
189
194
  } = require('../schemas/definitions/sales');
190
195
 
191
196
  const openApiSpec = { openapi: '3.0.2' };
@@ -234,7 +239,6 @@ openApiSpec['x-tagGroups'] = [
234
239
  'GLS Spain integration',
235
240
  'GLS International integration',
236
241
  'Ingenico integration',
237
- 'GLS SMS integration',
238
242
  ],
239
243
  },
240
244
  {
@@ -538,10 +542,6 @@ Since the URLs of the payment pages at Ingenico are very long, each sale also ha
538
542
  [redirect to ingenico](#tag/Integrations/paths/~1link~1{shortId}/get) endpoint, which is much shorter and redirects to the actual payment
539
543
  page at Ingenico.`,
540
544
  },
541
- {
542
- name: 'GLS SMS integration', // todo
543
- description: `TODO`,
544
- },
545
545
  {
546
546
  name: 'Authentication',
547
547
  description: `
@@ -3135,7 +3135,7 @@ ${securitySchemes.anyRole}`,
3135
3135
  responses: {
3136
3136
  ' 200': {
3137
3137
  description: 'The printable label of the expedition.',
3138
- content: { 'application/pdf': { schema: { type: 'string', format: 'binary' } } },
3138
+ content: { 'application/json': { schema: downloadExpeditionLabelResponse() } },
3139
3139
  },
3140
3140
  ' 400': responses.badRequest,
3141
3141
  ' 401': responses.invalidUserInCookieOrHeader,
@@ -3150,6 +3150,108 @@ ${securitySchemes.anyRole}`,
3150
3150
  },
3151
3151
  },
3152
3152
  },
3153
+ '/expeditions/expire': {
3154
+ post: {
3155
+ tags: ['Expeditions'],
3156
+ summary: '[S] Expire',
3157
+ description: `
3158
+ Changes the status of a delivery expedition from \`inShop\` to \`inShopExpired\`.
3159
+
3160
+ If the expedition is not a delivery or is not in shop, the API will return a \`500 ExpeditionCannotBeUpdatedError\`.
3161
+
3162
+ ${securitySchemes.tokens}
3163
+ ${securitySchemes.superAdminRole}`,
3164
+ requestBody: {
3165
+ content: { 'application/json': { schema: expireExpeditionRequest() } },
3166
+ required: true,
3167
+ },
3168
+ responses: {
3169
+ ' 200': {
3170
+ description: 'Contains the updated expedition.',
3171
+ content: { 'application/json': { schema: updateExpeditionResponse() } },
3172
+ },
3173
+ ' 400': responses.badRequest,
3174
+ ' 401': responses.invalidUserInCookieOrHeader,
3175
+ ' 401 ': responses.invalidCookieOrHeader,
3176
+ ' 401 ': responses.missingCookieOrHeader,
3177
+ ' 401 ': responses.unauthorized,
3178
+ ' 403': responses.forbidden,
3179
+ ' 415': responses.unsupportedMediaType,
3180
+ ' 500': responses.internalServerError,
3181
+ ' 500 ': responses.expeditionDoesNotExist,
3182
+ ' 500 ': responses.expeditionCannotBeUpdated,
3183
+ },
3184
+ },
3185
+ },
3186
+ '/expeditions/unexpire': {
3187
+ post: {
3188
+ tags: ['Expeditions'],
3189
+ summary: '[S] Unexpire',
3190
+ description: `
3191
+ Changes the status of a delivery expedition from \`inShopExpired\` to \`inShop\`.
3192
+
3193
+ The \`status.expiration\` fields will be reset using the shop expiration settings, as if the expedition had been received from the driver
3194
+ at this point.
3195
+
3196
+ If the expedition is not a delivery or is not expired, the API will return a \`500 ExpeditionCannotBeUpdatedError\`.
3197
+
3198
+ ${securitySchemes.tokens}
3199
+ ${securitySchemes.superAdminRole}`,
3200
+ requestBody: {
3201
+ content: { 'application/json': { schema: unexpireExpeditionRequest() } },
3202
+ required: true,
3203
+ },
3204
+ responses: {
3205
+ ' 200': {
3206
+ description: 'Contains the updated expedition.',
3207
+ content: { 'application/json': { schema: updateExpeditionResponse() } },
3208
+ },
3209
+ ' 400': responses.badRequest,
3210
+ ' 401': responses.invalidUserInCookieOrHeader,
3211
+ ' 401 ': responses.invalidCookieOrHeader,
3212
+ ' 401 ': responses.missingCookieOrHeader,
3213
+ ' 401 ': responses.unauthorized,
3214
+ ' 403': responses.forbidden,
3215
+ ' 415': responses.unsupportedMediaType,
3216
+ ' 500': responses.internalServerError,
3217
+ ' 500 ': responses.expeditionDoesNotExist,
3218
+ ' 500 ': responses.expeditionCannotBeUpdated,
3219
+ },
3220
+ },
3221
+ },
3222
+ '/expeditions/updateDerivation': {
3223
+ post: {
3224
+ tags: ['Expeditions'],
3225
+ summary: '[S] Update derivation',
3226
+ description: `
3227
+ Updates the derivation price and settings of an expedition using the provided derivation settings.
3228
+
3229
+ If the expedition has not been received yet, the API will return a \`500 ExpeditionCannotBeUpdatedError\`.
3230
+
3231
+ ${securitySchemes.tokens}
3232
+ ${securitySchemes.superAdminRole}`,
3233
+ requestBody: {
3234
+ content: { 'application/json': { schema: updateExpeditionDerivationRequest() } },
3235
+ required: true,
3236
+ },
3237
+ responses: {
3238
+ ' 200': {
3239
+ description: 'Contains the updated expedition.',
3240
+ content: { 'application/json': { schema: updateExpeditionResponse() } },
3241
+ },
3242
+ ' 400': responses.badRequest,
3243
+ ' 401': responses.invalidUserInCookieOrHeader,
3244
+ ' 401 ': responses.invalidCookieOrHeader,
3245
+ ' 401 ': responses.missingCookieOrHeader,
3246
+ ' 401 ': responses.unauthorized,
3247
+ ' 403': responses.forbidden,
3248
+ ' 415': responses.unsupportedMediaType,
3249
+ ' 500': responses.internalServerError,
3250
+ ' 500 ': responses.expeditionDoesNotExist,
3251
+ ' 500 ': responses.expeditionCannotBeUpdated,
3252
+ },
3253
+ },
3254
+ },
3153
3255
  '/pods/find': {
3154
3256
  post: {
3155
3257
  tags: ['Pods'],
@@ -3425,7 +3527,7 @@ ${securitySchemes.anyRole}`,
3425
3527
  responses: {
3426
3528
  ' 200': {
3427
3529
  description: 'The printable label of the expedition associated to the sale.',
3428
- content: { 'application/pdf': { schema: { type: 'string', format: 'binary' } } },
3530
+ content: { 'application/json': { schema: downloadSaleLabelResponse() } },
3429
3531
  },
3430
3532
  ' 400': responses.badRequest,
3431
3533
  ' 401': responses.invalidUserInCookieOrHeader,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.8.0",
3
+ "version": "34.9.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -346,6 +346,12 @@ const findByDateRange = () => ({
346
346
  additionalProperties: false,
347
347
  });
348
348
 
349
+ const findByOptionalDateRange = () => ({
350
+ type: 'object',
351
+ properties: { dateRange: dateRange() },
352
+ additionalProperties: false,
353
+ });
354
+
349
355
  const timezone = () => ({ type: 'string', format: 'timezone' });
350
356
 
351
357
  const timezoneNames = () => ({ type: 'string', enum: timezones });
@@ -416,6 +422,7 @@ module.exports = {
416
422
  findByPolygonalArea,
417
423
  findByDate,
418
424
  findByDateRange,
425
+ findByOptionalDateRange,
419
426
  timezone,
420
427
  timezoneNames,
421
428
  objectWithUuidAndName,
@@ -17,7 +17,7 @@ const {
17
17
  mergeSchemas,
18
18
  pickProperties,
19
19
  } = require('@gls_spain/common-json-schemas');
20
- const { date, findById, findByIds } = require('./common');
20
+ const { date, findById, findByIds, findByOptionalDateRange } = require('./common');
21
21
  const { address } = require('./common');
22
22
  const { network, objectWithNetworkId } = require('./networks');
23
23
  const { shop, objectWithShopId } = require('./shops');
@@ -497,12 +497,12 @@ const findExpeditionsSuperAdminRequest = () =>
497
497
  findRequest({
498
498
  oneOf: [
499
499
  findById(),
500
- findByNetwork(),
501
- findByNetworkAndStatus(),
502
- findByNetworkAndNoShop(),
503
- findByNetworkAndNoShopAndStatus(),
504
- findByShop(),
505
- findByShopAndStatus(),
500
+ mergeSchemas(findByNetwork(), findByOptionalDateRange()),
501
+ mergeSchemas(findByNetworkAndStatus(), findByOptionalDateRange()),
502
+ mergeSchemas(findByNetworkAndNoShop(), findByOptionalDateRange()),
503
+ mergeSchemas(findByNetworkAndNoShopAndStatus(), findByOptionalDateRange()),
504
+ mergeSchemas(findByShop(), findByOptionalDateRange()),
505
+ mergeSchemas(findByShopAndStatus(), findByOptionalDateRange()),
506
506
  findByCode(),
507
507
  findBySale(),
508
508
  ],
@@ -510,18 +510,26 @@ const findExpeditionsSuperAdminRequest = () =>
510
510
 
511
511
  const findExpeditionsNetworkAdminRequest = () =>
512
512
  findRequest({
513
- oneOf: [findById(), findByShop(), findByShopAndStatus(), findByNoShop(), findByNoShopAndStatus(), findByCode(), findBySale()],
513
+ oneOf: [
514
+ findById(),
515
+ mergeSchemas(findByShop(), findByOptionalDateRange()),
516
+ mergeSchemas(findByShopAndStatus(), findByOptionalDateRange()),
517
+ mergeSchemas(findByNoShop(), findByOptionalDateRange()),
518
+ mergeSchemas(findByNoShopAndStatus(), findByOptionalDateRange()),
519
+ findByCode(),
520
+ findBySale(),
521
+ ],
514
522
  });
515
523
 
516
524
  const findExpeditionsShopUserRequest = () =>
517
525
  findRequest({
518
526
  oneOf: [
519
527
  findById(),
520
- findByShop(),
521
- findByShopAndStatus(),
522
- findByShopAndTypesAndStatus(),
523
- findByNoShop(),
524
- findByNoShopAndStatus(),
528
+ mergeSchemas(findByShop(), findByOptionalDateRange()),
529
+ mergeSchemas(findByShopAndStatus(), findByOptionalDateRange()),
530
+ mergeSchemas(findByShopAndTypesAndStatus(), findByOptionalDateRange()),
531
+ mergeSchemas(findByNoShop(), findByOptionalDateRange()),
532
+ mergeSchemas(findByNoShopAndStatus(), findByOptionalDateRange()),
525
533
  findByCode(),
526
534
  findBySale(),
527
535
  ],
@@ -768,6 +776,64 @@ const downloadExpeditionLabelRequest = () => ({
768
776
  additionalProperties: false,
769
777
  });
770
778
 
779
+ const downloadExpeditionLabelResponse = () => ({
780
+ type: 'object',
781
+ properties: {
782
+ download: {
783
+ type: 'object',
784
+ properties: {
785
+ label: { type: 'string', description: 'a PDF file encoded as a Base64 string' },
786
+ },
787
+ required: ['label'],
788
+ additionalProperties: false,
789
+ },
790
+ },
791
+ required: ['download'],
792
+ additionalProperties: false,
793
+ });
794
+
795
+ const expireExpeditionRequest = () => ({
796
+ type: 'object',
797
+ properties: {
798
+ expire: objectWithUuid(),
799
+ },
800
+ required: ['expire'],
801
+ additionalProperties: false,
802
+ });
803
+
804
+ const unexpireExpeditionRequest = () => ({
805
+ type: 'object',
806
+ properties: {
807
+ unexpire: objectWithUuid(),
808
+ },
809
+ required: ['unexpire'],
810
+ additionalProperties: false,
811
+ });
812
+
813
+ const updateExpeditionDerivationRequest = () => ({
814
+ type: 'object',
815
+ properties: {
816
+ find: objectWithUuid(),
817
+ set: {
818
+ type: 'object',
819
+ properties: {
820
+ derivation: {
821
+ type: 'object',
822
+ properties: {
823
+ settings: derivationSettings(),
824
+ },
825
+ required: ['settings'],
826
+ additionalProperties: false,
827
+ },
828
+ },
829
+ required: ['derivation'],
830
+ additionalProperties: false,
831
+ },
832
+ },
833
+ required: ['find', 'set'],
834
+ additionalProperties: false,
835
+ });
836
+
771
837
  module.exports = {
772
838
  processedWithDriver,
773
839
  processedWithCustomer,
@@ -794,4 +860,8 @@ module.exports = {
794
860
  receiveAllExpeditionsFromDriverRequest,
795
861
  receiveAllExpeditionsFromDriverResponse,
796
862
  downloadExpeditionLabelRequest,
863
+ downloadExpeditionLabelResponse,
864
+ expireExpeditionRequest,
865
+ unexpireExpeditionRequest,
866
+ updateExpeditionDerivationRequest,
797
867
  };
@@ -14,7 +14,7 @@ const {
14
14
  pickProperties,
15
15
  objectWithUuid,
16
16
  } = require('@gls_spain/common-json-schemas');
17
- const { country, findAll, findById } = require('./common');
17
+ const { country, findAll, findById, findByOptionalDateRange } = require('./common');
18
18
  const { address } = require('./common');
19
19
  const { saleSize, salesSettings } = require('./defaults');
20
20
  const { network, objectWithNetworkId } = require('./networks');
@@ -154,11 +154,17 @@ const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find b
154
154
 
155
155
  const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
156
156
 
157
- const findSalesSuperAdminRequest = () => findRequest({ oneOf: [findByNetwork(), findByShop(), findById()] });
157
+ const findSalesSuperAdminRequest = () =>
158
+ findRequest({
159
+ oneOf: [mergeSchemas(findByNetwork(), findByOptionalDateRange()), mergeSchemas(findByShop(), findByOptionalDateRange()), findById()],
160
+ });
158
161
 
159
- const findSalesNetworkAdminRequest = () => findRequest({ oneOf: [findAll(), findByShop(), findById()] });
162
+ const findSalesNetworkAdminRequest = () =>
163
+ findRequest({
164
+ oneOf: [mergeSchemas(findAll(), findByOptionalDateRange()), mergeSchemas(findByShop(), findByOptionalDateRange()), findById()],
165
+ });
160
166
 
161
- const findSalesShopUserRequest = () => findRequest({ oneOf: [findAll(), findById()] });
167
+ const findSalesShopUserRequest = () => findRequest({ oneOf: [mergeSchemas(findAll(), findByOptionalDateRange()), findById()] });
162
168
 
163
169
  const findSalesResponse = () => findResponse(sale());
164
170
 
@@ -202,6 +208,22 @@ const downloadSaleLabelRequest = () => ({
202
208
  additionalProperties: false,
203
209
  });
204
210
 
211
+ const downloadSaleLabelResponse = () => ({
212
+ type: 'object',
213
+ properties: {
214
+ download: {
215
+ type: 'object',
216
+ properties: {
217
+ label: { type: 'string', description: 'a PDF file encoded as a Base64 string' },
218
+ },
219
+ required: ['label'],
220
+ additionalProperties: false,
221
+ },
222
+ },
223
+ required: ['download'],
224
+ additionalProperties: false,
225
+ });
226
+
205
227
  module.exports = {
206
228
  sale,
207
229
  createSaleRequest,
@@ -215,4 +237,5 @@ module.exports = {
215
237
  updateSaleRequest,
216
238
  updateSaleResponse,
217
239
  downloadSaleLabelRequest,
240
+ downloadSaleLabelResponse,
218
241
  };
package/schemas/index.js CHANGED
@@ -76,6 +76,10 @@ const {
76
76
  receiveAllExpeditionsFromDriverRequest,
77
77
  receiveAllExpeditionsFromDriverResponse,
78
78
  downloadExpeditionLabelRequest,
79
+ downloadExpeditionLabelResponse,
80
+ expireExpeditionRequest,
81
+ unexpireExpeditionRequest,
82
+ updateExpeditionDerivationRequest,
79
83
  } = require('./definitions/expeditions');
80
84
  const { findPodsRequest, findPodsResponse } = require('./definitions/pods');
81
85
  const {
@@ -117,6 +121,7 @@ const {
117
121
  updateSaleRequest,
118
122
  updateSaleResponse,
119
123
  downloadSaleLabelRequest,
124
+ downloadSaleLabelResponse,
120
125
  } = require('./definitions/sales');
121
126
 
122
127
  function request(schema, $id) {
@@ -211,6 +216,10 @@ const expeditionsReceiveAllFromDriverResponse = response(
211
216
  'expeditionsReceiveAllFromDriverResponse',
212
217
  );
213
218
  const expeditionsDownloadLabelRequest = request(downloadExpeditionLabelRequest(), 'expeditionsDownloadLabelRequest');
219
+ const expeditionsDownloadLabelResponse = response(downloadExpeditionLabelResponse(), 'expeditionsDownloadLabelResponse');
220
+ const expeditionsExpireRequest = request(expireExpeditionRequest(), 'expeditionsExpireRequest');
221
+ const expeditionsUnexpireRequest = request(unexpireExpeditionRequest(), 'expeditionsUnexpireRequest');
222
+ const expeditionsUpdateDerivationRequest = request(updateExpeditionDerivationRequest(), 'expeditionsUpdateDerivationRequest');
214
223
 
215
224
  const podsFindRequest = request(findPodsRequest(), 'podsFindRequest');
216
225
  const podsFindResponse = response(findPodsResponse(), 'podsFindResponse');
@@ -255,6 +264,7 @@ const salesCheckPriceResponse = response(checkSalePriceResponse(), 'salesCheckPr
255
264
  const salesUpdateRequest = request(updateSaleRequest(), 'salesUpdateRequest');
256
265
  const salesUpdateResponse = response(updateSaleResponse(), 'salesUpdateResponse');
257
266
  const salesDownloadLabelRequest = request(downloadSaleLabelRequest(), 'salesDownloadLabelRequest');
267
+ const salesDownloadLabelResponse = request(downloadSaleLabelResponse(), 'salesDownloadLabelResponse');
258
268
 
259
269
  module.exports = {
260
270
  errorResponse,
@@ -338,6 +348,10 @@ module.exports = {
338
348
  expeditionsReceiveAllFromDriverRequest,
339
349
  expeditionsReceiveAllFromDriverResponse,
340
350
  expeditionsDownloadLabelRequest,
351
+ expeditionsDownloadLabelResponse,
352
+ expeditionsExpireRequest,
353
+ expeditionsUnexpireRequest,
354
+ expeditionsUpdateDerivationRequest,
341
355
 
342
356
  podsFindRequest,
343
357
  podsFindResponse,
@@ -382,4 +396,5 @@ module.exports = {
382
396
  salesUpdateRequest,
383
397
  salesUpdateResponse,
384
398
  salesDownloadLabelRequest,
399
+ salesDownloadLabelResponse,
385
400
  };