@gls_spain/gps-common 34.7.0 → 34.8.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.
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myRunOnSave" value="true" />
5
+ <option name="myRunOnReformat" value="true" />
6
+ </component>
7
+ </project>
@@ -2,13 +2,15 @@
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$/.idea/watcherTasks.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/watcherTasks.xml" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/errors/GLSRecordingError.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/GLSRecordingError.js" afterDir="false" />
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" />
7
8
  <change beforePath="$PROJECT_DIR$/errors/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/errors/index.js" afterDir="false" />
8
9
  <change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
9
10
  <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/schemas/definitions/expeditions.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/expeditions.js" afterDir="false" />
11
12
  <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
13
+ <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
12
14
  </list>
13
15
  <option name="SHOW_DIALOG" value="false" />
14
16
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -31,11 +33,6 @@
31
33
  <other-services-enabled>true</other-services-enabled>
32
34
  <auto-save>true</auto-save>
33
35
  </component>
34
- <component name="NamedScopeManager">
35
- <order>
36
- <scope name="Source files" />
37
- </order>
38
- </component>
39
36
  <component name="ProjectId" id="1ONNcC0Dj8TpB0ikqd9Zaci2JZf" />
40
37
  <component name="ProjectLevelVcsManager">
41
38
  <ConfirmationsSetting value="2" id="Add" />
@@ -48,14 +45,13 @@
48
45
  <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
49
46
  <property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
50
47
  <property name="NewWatcherDialog.advanced.open" value="true" />
51
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
52
48
  <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
53
49
  <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
54
50
  <property name="TERMINAL_CUSTOM_COMMANDS_GOT_IT" value="true" />
55
51
  <property name="WebServerToolWindowFactoryState" value="false" />
56
- <property name="javascript.nodejs.core.library.configured.version" value="12.14.0" />
57
- <property name="javascript.nodejs.core.library.typings.version" value="12.19.9" />
58
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
52
+ <property name="javascript.nodejs.core.library.configured.version" value="14.11.0" />
53
+ <property name="javascript.nodejs.core.library.typings.version" value="14.11.0" />
54
+ <property name="last_opened_file_path" value="$PROJECT_DIR$/errors" />
59
55
  <property name="node.js.detected.package.eslint" value="true" />
60
56
  <property name="node.js.detected.package.standard" value="true" />
61
57
  <property name="node.js.path.for.package.eslint" value="project" />
@@ -68,18 +64,11 @@
68
64
  <property name="nodejs_package_manager_path" value="npm" />
69
65
  <property name="prettier.import.notification.dismissed" value="true" />
70
66
  <property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
71
- <property name="settings.editor.selected.configurable" value="watcher.settings" />
67
+ <property name="settings.editor.selected.configurable" value="settings.javascript.prettier" />
72
68
  <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
73
69
  <property name="vue.rearranger.settings.migration" value="true" />
74
70
  </component>
75
71
  <component name="RecentsManager">
76
- <key name="MoveFile.RECENT_KEYS">
77
- <recent name="$PROJECT_DIR$/open-api" />
78
- <recent name="$PROJECT_DIR$" />
79
- <recent name="$PROJECT_DIR$/schemas" />
80
- <recent name="$PROJECT_DIR$/open-api-spec" />
81
- <recent name="$PROJECT_DIR$/errors" />
82
- </key>
83
72
  <key name="CopyFile.RECENT_KEYS">
84
73
  <recent name="$PROJECT_DIR$/errors" />
85
74
  <recent name="$PROJECT_DIR$/schemas/definitions" />
@@ -87,6 +76,13 @@
87
76
  <recent name="$PROJECT_DIR$/schemas" />
88
77
  <recent name="$PROJECT_DIR$/lib/scripts" />
89
78
  </key>
79
+ <key name="MoveFile.RECENT_KEYS">
80
+ <recent name="$PROJECT_DIR$/open-api" />
81
+ <recent name="$PROJECT_DIR$" />
82
+ <recent name="$PROJECT_DIR$/schemas" />
83
+ <recent name="$PROJECT_DIR$/open-api-spec" />
84
+ <recent name="$PROJECT_DIR$/errors" />
85
+ </key>
90
86
  </component>
91
87
  <component name="RunManager" selected="JavaScript Debug.documentation.html (1)">
92
88
  <configuration name="documentation.html (1)" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gps-common/build/documentation/documentation.html" useBuiltInWebServerPort="true">
@@ -134,9 +130,9 @@
134
130
  </configuration>
135
131
  <recent_temporary>
136
132
  <list>
133
+ <item itemvalue="npm.build-documentation" />
137
134
  <item itemvalue="npm.test" />
138
135
  <item itemvalue="JavaScript Debug.documentation.html (1)" />
139
- <item itemvalue="npm.build-documentation" />
140
136
  <item itemvalue="npm.semantic-release" />
141
137
  <item itemvalue="npm.commit" />
142
138
  </list>
@@ -655,8 +651,7 @@
655
651
  <workItem from="1606477130384" duration="74000" />
656
652
  <workItem from="1606835326733" duration="48000" />
657
653
  <workItem from="1607951320583" duration="589000" />
658
- <workItem from="1608286770164" duration="53000" />
659
- <workItem from="1608574754236" duration="463000" />
654
+ <workItem from="1610108917407" duration="2232000" />
660
655
  </task>
661
656
  <servers />
662
657
  </component>
@@ -694,4 +689,8 @@
694
689
  </option>
695
690
  <option name="oldMeFiltersMigrated" value="true" />
696
691
  </component>
692
+ <component name="XSLT-Support.FileAssociations.UIState">
693
+ <expand />
694
+ <select />
695
+ </component>
697
696
  </project>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [34.8.0](https://github.com/GLS-Spain/gps-common/compare/v34.7.0...v34.8.0) (2021-01-08)
2
+
3
+
4
+ ### Features
5
+
6
+ * add download label to expeditions and sales ([68c49db](https://github.com/GLS-Spain/gps-common/commit/68c49dbc306caa24f28d07fb72dfc9f19cbf3c10))
7
+
1
8
  # [34.7.0](https://github.com/GLS-Spain/gps-common/compare/v34.6.0...v34.7.0) (2020-12-21)
2
9
 
3
10
 
@@ -0,0 +1,11 @@
1
+ const { DatabaseError } = require('@gls_spain/mongodb');
2
+
3
+ class LabelDoesNotExistError extends DatabaseError {
4
+ constructor(message = 'Label does not exist.') {
5
+ // noinspection JSCheckFunctionSignatures
6
+ super(message);
7
+ this.name = 'LabelDoesNotExistError';
8
+ }
9
+ }
10
+
11
+ module.exports = LabelDoesNotExistError;
package/errors/index.js CHANGED
@@ -34,6 +34,7 @@ const InconsistentSalesSettingsError = require('./InconsistentSalesSettingsError
34
34
  const InvalidSaleDestinationError = require('./InvalidSaleDestinationError');
35
35
  const GLSSpainError = require('./GLSSpainError');
36
36
  const GLSRecordingError = require('./GLSRecordingError');
37
+ const LabelDoesNotExistError = require('./LabelDoesNotExistError');
37
38
 
38
39
  const errorsNames = {
39
40
  DatabaseNotEmptyError: 'DatabaseNotEmptyError',
@@ -72,6 +73,7 @@ const errorsNames = {
72
73
  InvalidSaleDestinationError: 'InvalidSaleDestinationError',
73
74
  GLSSpainError: 'GLSSpainError',
74
75
  GLSRecordingError: 'GLSRecordingError',
76
+ LabelDoesNotExistError: 'LabelDoesNotExistError',
75
77
  };
76
78
 
77
79
  module.exports = {
@@ -111,5 +113,6 @@ module.exports = {
111
113
  InvalidSaleDestinationError,
112
114
  GLSSpainError,
113
115
  GLSRecordingError,
116
+ LabelDoesNotExistError,
114
117
  errorsNames,
115
118
  };
@@ -44,6 +44,7 @@ const {
44
44
  InconsistentSalesSettingsError,
45
45
  InvalidSaleDestinationError,
46
46
  GLSSpainError,
47
+ LabelDoesNotExistError,
47
48
  } = require('../errors');
48
49
  const { timezoneNames } = require('../schemas/definitions/common');
49
50
  const { loginResponse } = require('../schemas/definitions/login');
@@ -126,6 +127,7 @@ const {
126
127
  processExpeditionsResponse,
127
128
  receiveAllExpeditionsFromDriverRequest,
128
129
  receiveAllExpeditionsFromDriverResponse,
130
+ downloadExpeditionLabelRequest,
129
131
  } = require('../schemas/definitions/expeditions');
130
132
  const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
131
133
  const { counters, getCountersResponse } = require('../schemas/definitions/counters');
@@ -183,6 +185,7 @@ const {
183
185
  checkSalePriceResponse,
184
186
  updateSaleRequest,
185
187
  updateSaleResponse,
188
+ downloadSaleLabelRequest,
186
189
  } = require('../schemas/definitions/sales');
187
190
 
188
191
  const openApiSpec = { openapi: '3.0.2' };
@@ -910,6 +913,7 @@ const errors = {
910
913
  inconsistentSalesSettings: new InconsistentSalesSettingsError(),
911
914
  invalidSaleDestination: new InvalidSaleDestinationError(),
912
915
  glsSpainError: new GLSSpainError(),
916
+ labelDoesNotExist: new LabelDoesNotExistError(),
913
917
  };
914
918
 
915
919
  const responses = {
@@ -1081,6 +1085,10 @@ const responses = {
1081
1085
  description: 'Cannot create the sale due to an error from the GLS Spain integration.',
1082
1086
  content: { 'application/json': { schema: specificHttpError(errors.glsSpainError) } },
1083
1087
  },
1088
+ labelDoesNotExist: {
1089
+ description: 'The label does not exist.',
1090
+ content: { 'application/json': { schema: specificHttpError(errors.labelDoesNotExist) } },
1091
+ },
1084
1092
  };
1085
1093
 
1086
1094
  const securitySchemes = {
@@ -3109,6 +3117,39 @@ ${securitySchemes.superAdminRole}`,
3109
3117
  },
3110
3118
  },
3111
3119
  },
3120
+ '/expeditions/downloadLabel': {
3121
+ post: {
3122
+ tags: ['Expeditions'],
3123
+ summary: '[SNU] Download label',
3124
+ description: `
3125
+ Downloads the PDF label of the expedition.
3126
+
3127
+ Once the expedition has been delivered to its destination the label becomes unavailable and the API will return a \`500 LabelDoesNotExistError\`.
3128
+
3129
+ ${securitySchemes.tokens}
3130
+ ${securitySchemes.anyRole}`,
3131
+ requestBody: {
3132
+ content: { 'application/json': { schema: downloadExpeditionLabelRequest() } },
3133
+ required: true,
3134
+ },
3135
+ responses: {
3136
+ ' 200': {
3137
+ description: 'The printable label of the expedition.',
3138
+ content: { 'application/pdf': { schema: { type: 'string', format: 'binary' } } },
3139
+ },
3140
+ ' 400': responses.badRequest,
3141
+ ' 401': responses.invalidUserInCookieOrHeader,
3142
+ ' 401 ': responses.invalidCookieOrHeader,
3143
+ ' 401 ': responses.missingCookieOrHeader,
3144
+ ' 401 ': responses.unauthorized,
3145
+ ' 403': responses.forbidden,
3146
+ ' 415': responses.unsupportedMediaType,
3147
+ ' 500': responses.internalServerError,
3148
+ ' 500 ': responses.expeditionDoesNotExist,
3149
+ ' 500 ': responses.labelDoesNotExist,
3150
+ },
3151
+ },
3152
+ },
3112
3153
  '/pods/find': {
3113
3154
  post: {
3114
3155
  tags: ['Pods'],
@@ -3364,6 +3405,42 @@ ${securitySchemes.superAdminRole}`,
3364
3405
  },
3365
3406
  },
3366
3407
  },
3408
+ '/sales/downloadLabel': {
3409
+ post: {
3410
+ tags: ['Sales'],
3411
+ summary: '[SNU] Download label',
3412
+ description: `
3413
+ Downloads the PDF label of the expedition associated to the sale.
3414
+
3415
+ If the sale has no expedition yet because it has not been paid then the API will return a \`500 ExpeditionDoesNotExistError\`.
3416
+
3417
+ Once the expedition has been delivered to its destination the label becomes unavailable and the API will return a \`500 LabelDoesNotExistError\`.
3418
+
3419
+ ${securitySchemes.tokens}
3420
+ ${securitySchemes.anyRole}`,
3421
+ requestBody: {
3422
+ content: { 'application/json': { schema: downloadSaleLabelRequest() } },
3423
+ required: true,
3424
+ },
3425
+ responses: {
3426
+ ' 200': {
3427
+ description: 'The printable label of the expedition associated to the sale.',
3428
+ content: { 'application/pdf': { schema: { type: 'string', format: 'binary' } } },
3429
+ },
3430
+ ' 400': responses.badRequest,
3431
+ ' 401': responses.invalidUserInCookieOrHeader,
3432
+ ' 401 ': responses.invalidCookieOrHeader,
3433
+ ' 401 ': responses.missingCookieOrHeader,
3434
+ ' 401 ': responses.unauthorized,
3435
+ ' 403': responses.forbidden,
3436
+ ' 415': responses.unsupportedMediaType,
3437
+ ' 500': responses.internalServerError,
3438
+ ' 500 ': responses.saleDoesNotExist,
3439
+ ' 500 ': responses.expeditionDoesNotExist,
3440
+ ' 500 ': responses.labelDoesNotExist,
3441
+ },
3442
+ },
3443
+ },
3367
3444
  '/historicRecords/find': {
3368
3445
  post: {
3369
3446
  tags: ['Historic records'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.7.0",
3
+ "version": "34.8.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -759,6 +759,15 @@ const receiveAllExpeditionsFromDriverResponse = () => ({
759
759
  additionalProperties: false,
760
760
  });
761
761
 
762
+ const downloadExpeditionLabelRequest = () => ({
763
+ type: 'object',
764
+ properties: {
765
+ download: objectWithUuid(),
766
+ },
767
+ required: ['download'],
768
+ additionalProperties: false,
769
+ });
770
+
762
771
  module.exports = {
763
772
  processedWithDriver,
764
773
  processedWithCustomer,
@@ -784,4 +793,5 @@ module.exports = {
784
793
  processExpeditionsResponse,
785
794
  receiveAllExpeditionsFromDriverRequest,
786
795
  receiveAllExpeditionsFromDriverResponse,
796
+ downloadExpeditionLabelRequest,
787
797
  };
@@ -12,6 +12,7 @@ const {
12
12
  updateResponse,
13
13
  mergeSchemas,
14
14
  pickProperties,
15
+ objectWithUuid,
15
16
  } = require('@gls_spain/common-json-schemas');
16
17
  const { country, findAll, findById } = require('./common');
17
18
  const { address } = require('./common');
@@ -192,6 +193,15 @@ const updateSaleRequest = () =>
192
193
 
193
194
  const updateSaleResponse = () => updateResponse(sale());
194
195
 
196
+ const downloadSaleLabelRequest = () => ({
197
+ type: 'object',
198
+ properties: {
199
+ download: objectWithUuid(),
200
+ },
201
+ required: ['download'],
202
+ additionalProperties: false,
203
+ });
204
+
195
205
  module.exports = {
196
206
  sale,
197
207
  createSaleRequest,
@@ -204,4 +214,5 @@ module.exports = {
204
214
  checkSalePriceResponse,
205
215
  updateSaleRequest,
206
216
  updateSaleResponse,
217
+ downloadSaleLabelRequest,
207
218
  };
package/schemas/index.js CHANGED
@@ -75,6 +75,7 @@ const {
75
75
  processExpeditionsResponse,
76
76
  receiveAllExpeditionsFromDriverRequest,
77
77
  receiveAllExpeditionsFromDriverResponse,
78
+ downloadExpeditionLabelRequest,
78
79
  } = require('./definitions/expeditions');
79
80
  const { findPodsRequest, findPodsResponse } = require('./definitions/pods');
80
81
  const {
@@ -115,6 +116,7 @@ const {
115
116
  checkSalePriceResponse,
116
117
  updateSaleRequest,
117
118
  updateSaleResponse,
119
+ downloadSaleLabelRequest,
118
120
  } = require('./definitions/sales');
119
121
 
120
122
  function request(schema, $id) {
@@ -208,6 +210,7 @@ const expeditionsReceiveAllFromDriverResponse = response(
208
210
  receiveAllExpeditionsFromDriverResponse(),
209
211
  'expeditionsReceiveAllFromDriverResponse',
210
212
  );
213
+ const expeditionsDownloadLabelRequest = request(downloadExpeditionLabelRequest(), 'expeditionsDownloadLabelRequest');
211
214
 
212
215
  const podsFindRequest = request(findPodsRequest(), 'podsFindRequest');
213
216
  const podsFindResponse = response(findPodsResponse(), 'podsFindResponse');
@@ -251,6 +254,7 @@ const salesCheckPriceRequest = request(checkSalePriceRequest(), 'salesCheckPrice
251
254
  const salesCheckPriceResponse = response(checkSalePriceResponse(), 'salesCheckPriceResponse');
252
255
  const salesUpdateRequest = request(updateSaleRequest(), 'salesUpdateRequest');
253
256
  const salesUpdateResponse = response(updateSaleResponse(), 'salesUpdateResponse');
257
+ const salesDownloadLabelRequest = request(downloadSaleLabelRequest(), 'salesDownloadLabelRequest');
254
258
 
255
259
  module.exports = {
256
260
  errorResponse,
@@ -333,6 +337,7 @@ module.exports = {
333
337
  expeditionsProcessResponse,
334
338
  expeditionsReceiveAllFromDriverRequest,
335
339
  expeditionsReceiveAllFromDriverResponse,
340
+ expeditionsDownloadLabelRequest,
336
341
 
337
342
  podsFindRequest,
338
343
  podsFindResponse,
@@ -376,4 +381,5 @@ module.exports = {
376
381
  salesCheckPriceResponse,
377
382
  salesUpdateRequest,
378
383
  salesUpdateResponse,
384
+ salesDownloadLabelRequest,
379
385
  };
@@ -1,45 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectTasksOptions">
4
- <TaskOptions isEnabled="true">
5
- <option name="arguments" value="--write $FilePathRelativeToProjectRoot$" />
6
- <option name="checkSyntaxErrors" value="true" />
7
- <option name="description" />
8
- <option name="exitCodeBehavior" value="ERROR" />
9
- <option name="fileExtension" value="js" />
10
- <option name="immediateSync" value="false" />
11
- <option name="name" value="Prettier Javascript" />
12
- <option name="output" value="$FilePathRelativeToProjectRoot$" />
13
- <option name="outputFilters">
14
- <array />
15
- </option>
16
- <option name="outputFromStdout" value="false" />
17
- <option name="program" value="$ProjectFileDir$/node_modules/.bin/prettier" />
18
- <option name="runOnExternalChanges" value="true" />
19
- <option name="scopeName" value="Source files" />
20
- <option name="trackOnlyRoot" value="false" />
21
- <option name="workingDir" value="$ProjectFileDir$" />
22
- <envs />
23
- </TaskOptions>
24
- <TaskOptions isEnabled="true">
25
- <option name="arguments" value="--write $FilePathRelativeToProjectRoot$" />
26
- <option name="checkSyntaxErrors" value="true" />
27
- <option name="description" />
28
- <option name="exitCodeBehavior" value="ERROR" />
29
- <option name="fileExtension" value="json" />
30
- <option name="immediateSync" value="false" />
31
- <option name="name" value="Prettier JSON" />
32
- <option name="output" value="$FilePathRelativeToProjectRoot$" />
33
- <option name="outputFilters">
34
- <array />
35
- </option>
36
- <option name="outputFromStdout" value="false" />
37
- <option name="program" value="$ProjectFileDir$/node_modules/.bin/prettier" />
38
- <option name="runOnExternalChanges" value="true" />
39
- <option name="scopeName" value="Source files" />
40
- <option name="trackOnlyRoot" value="false" />
41
- <option name="workingDir" value="$ProjectFileDir$" />
42
- <envs />
43
- </TaskOptions>
44
- </component>
45
- </project>