@gls_spain/gps-common 34.9.0 → 34.9.2

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.
@@ -4,9 +4,6 @@
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
6
  <change beforePath="$PROJECT_DIR$/schemas/definitions/common.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/common.js" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/schemas/definitions/expeditions.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/expeditions.js" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/schemas/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/index.js" afterDir="false" />
10
7
  </list>
11
8
  <option name="SHOW_DIALOG" value="false" />
12
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -60,7 +57,7 @@
60
57
  <property name="nodejs_package_manager_path" value="npm" />
61
58
  <property name="prettier.import.notification.dismissed" value="true" />
62
59
  <property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
63
- <property name="settings.editor.selected.configurable" value="settings.javascript.prettier" />
60
+ <property name="settings.editor.selected.configurable" value="watcher.settings" />
64
61
  <property name="ts.external.directory.path" value="$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external" />
65
62
  <property name="vue.rearranger.settings.migration" value="true" />
66
63
  </component>
@@ -126,9 +123,9 @@
126
123
  </configuration>
127
124
  <recent_temporary>
128
125
  <list>
129
- <item itemvalue="npm.test" />
130
- <item itemvalue="npm.build-documentation" />
131
126
  <item itemvalue="JavaScript Debug.documentation.html (1)" />
127
+ <item itemvalue="npm.build-documentation" />
128
+ <item itemvalue="npm.test" />
132
129
  <item itemvalue="npm.semantic-release" />
133
130
  <item itemvalue="npm.commit" />
134
131
  </list>
@@ -650,7 +647,14 @@
650
647
  <workItem from="1610108917407" duration="2502000" />
651
648
  <workItem from="1610134729440" duration="18000" />
652
649
  <workItem from="1610542075615" duration="660000" />
653
- <workItem from="1610988300441" duration="4154000" />
650
+ <workItem from="1610988300441" duration="4439000" />
651
+ <workItem from="1610996494321" duration="612000" />
652
+ <workItem from="1611040774303" duration="609000" />
653
+ <workItem from="1611059922357" duration="15000" />
654
+ <workItem from="1611060068624" duration="3602000" />
655
+ <workItem from="1611130910707" duration="110000" />
656
+ <workItem from="1611300719061" duration="18000" />
657
+ <workItem from="1611567691754" duration="526000" />
654
658
  </task>
655
659
  <servers />
656
660
  </component>
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [34.9.2](https://github.com/GLS-Spain/gps-common/compare/v34.9.1...v34.9.2) (2021-01-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix specific error responses ([874aec1](https://github.com/GLS-Spain/gps-common/commit/874aec1d50dca89eed19c97c31594a89c128f2f9))
7
+
8
+ ## [34.9.1](https://github.com/GLS-Spain/gps-common/compare/v34.9.0...v34.9.1) (2021-01-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * fix find sales by createdAt range instead of date range ([c50f662](https://github.com/GLS-Spain/gps-common/commit/c50f662d9aaafca0ebc4345c0d78e0d9f68cdcff))
14
+
1
15
  # [34.9.0](https://github.com/GLS-Spain/gps-common/compare/v34.8.1...v34.9.0) (2021-01-18)
2
16
 
3
17
 
@@ -9,7 +9,7 @@ const {
9
9
  InvalidCookieOrHeaderError,
10
10
  MissingCookieOrHeaderError,
11
11
  } = require('@gls_spain/common-errors');
12
- const { errorResponse, specificHttpError } = require('@gls_spain/common-json-schemas');
12
+ const { errorResponse } = require('@gls_spain/common-json-schemas');
13
13
  const {
14
14
  DatabaseNotEmptyError,
15
15
  UserDoesNotExistError,
@@ -46,7 +46,7 @@ const {
46
46
  GLSSpainError,
47
47
  LabelDoesNotExistError,
48
48
  } = require('../errors');
49
- const { timezoneNames } = require('../schemas/definitions/common');
49
+ const { timezoneNames, specificErrorResponse } = require('../schemas/definitions/common');
50
50
  const { loginResponse } = require('../schemas/definitions/login');
51
51
  const { logoutResponse } = require('../schemas/definitions/logout');
52
52
  const { becomeRequest } = require('../schemas/definitions/become');
@@ -919,175 +919,175 @@ const errors = {
919
919
  const responses = {
920
920
  badRequest: {
921
921
  description: errors.badRequest.message,
922
- content: { 'application/json': { schema: specificHttpError(errors.badRequest) } },
922
+ content: { 'application/json': { schema: specificErrorResponse(errors.badRequest) } },
923
923
  },
924
924
  unauthorized: {
925
925
  description: errors.unauthorized.message,
926
- content: { 'application/json': { schema: specificHttpError(errors.unauthorized) } },
926
+ content: { 'application/json': { schema: specificErrorResponse(errors.unauthorized) } },
927
927
  },
928
928
  invalidUsernameOrPassword: {
929
929
  description: errors.invalidUsernameOrPassword.message,
930
- content: { 'application/json': { schema: specificHttpError(errors.invalidUsernameOrPassword) } },
930
+ content: { 'application/json': { schema: specificErrorResponse(errors.invalidUsernameOrPassword) } },
931
931
  },
932
932
  invalidUserInCookieOrHeader: {
933
933
  description: errors.invalidUserInCookieOrHeader.message,
934
- content: { 'application/json': { schema: specificHttpError(errors.invalidUserInCookieOrHeader) } },
934
+ content: { 'application/json': { schema: specificErrorResponse(errors.invalidUserInCookieOrHeader) } },
935
935
  },
936
936
  invalidCookieOrHeader: {
937
937
  description: errors.invalidCookieOrHeader.message,
938
- content: { 'application/json': { schema: specificHttpError(errors.invalidCookieOrHeader) } },
938
+ content: { 'application/json': { schema: specificErrorResponse(errors.invalidCookieOrHeader) } },
939
939
  },
940
940
  missingCookieOrHeader: {
941
941
  description: errors.missingCookieOrHeader.message,
942
- content: { 'application/json': { schema: specificHttpError(errors.missingCookieOrHeader) } },
942
+ content: { 'application/json': { schema: specificErrorResponse(errors.missingCookieOrHeader) } },
943
943
  },
944
944
  forbidden: {
945
945
  description: errors.forbidden.message,
946
- content: { 'application/json': { schema: specificHttpError(errors.forbidden) } },
946
+ content: { 'application/json': { schema: specificErrorResponse(errors.forbidden) } },
947
947
  },
948
948
  unsupportedMediaType: {
949
949
  description: errors.unsupportedMediaType.message,
950
- content: { 'application/json': { schema: specificHttpError(errors.unsupportedMediaType) } },
950
+ content: { 'application/json': { schema: specificErrorResponse(errors.unsupportedMediaType) } },
951
951
  },
952
952
  internalServerError: {
953
953
  description: 'A generic error in the server.',
954
- content: { 'application/json': { schema: specificHttpError(errors.internalServerError) } },
954
+ content: { 'application/json': { schema: specificErrorResponse(errors.internalServerError) } },
955
955
  },
956
956
  databaseNotEmpty: {
957
957
  description: 'The database is not empty.',
958
- content: { 'application/json': { schema: specificHttpError(errors.databaseNotEmpty) } },
958
+ content: { 'application/json': { schema: specificErrorResponse(errors.databaseNotEmpty) } },
959
959
  },
960
960
  userDoesNotExist: {
961
961
  description: 'The user does not exist.',
962
- content: { 'application/json': { schema: specificHttpError(errors.userDoesNotExist) } },
962
+ content: { 'application/json': { schema: specificErrorResponse(errors.userDoesNotExist) } },
963
963
  },
964
964
  userAlreadyExists: {
965
965
  description: 'The user already exists.',
966
- content: { 'application/json': { schema: specificHttpError(errors.userAlreadyExists) } },
966
+ content: { 'application/json': { schema: specificErrorResponse(errors.userAlreadyExists) } },
967
967
  },
968
968
  userCannotBeUpdated: {
969
969
  description: 'The user cannot be updated.',
970
- content: { 'application/json': { schema: specificHttpError(errors.userCannotBeUpdated) } },
970
+ content: { 'application/json': { schema: specificErrorResponse(errors.userCannotBeUpdated) } },
971
971
  },
972
972
  userCannotBeDeleted: {
973
973
  description: 'The user cannot be deleted.',
974
- content: { 'application/json': { schema: specificHttpError(errors.userCannotBeDeleted) } },
974
+ content: { 'application/json': { schema: specificErrorResponse(errors.userCannotBeDeleted) } },
975
975
  },
976
976
  networkDoesNotExist: {
977
977
  description: 'The network does not exist.',
978
- content: { 'application/json': { schema: specificHttpError(errors.networkDoesNotExist) } },
978
+ content: { 'application/json': { schema: specificErrorResponse(errors.networkDoesNotExist) } },
979
979
  },
980
980
  networkAlreadyExists: {
981
981
  description: 'The network already exists.',
982
- content: { 'application/json': { schema: specificHttpError(errors.networkAlreadyExists) } },
982
+ content: { 'application/json': { schema: specificErrorResponse(errors.networkAlreadyExists) } },
983
983
  },
984
984
  networkCannotBeUpdated: {
985
985
  description: 'The network cannot be updated.',
986
- content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeUpdated) } },
986
+ content: { 'application/json': { schema: specificErrorResponse(errors.networkCannotBeUpdated) } },
987
987
  },
988
988
  networkCannotBeDeleted: {
989
989
  description: 'The network cannot be deleted.',
990
- content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeDeleted) } },
990
+ content: { 'application/json': { schema: specificErrorResponse(errors.networkCannotBeDeleted) } },
991
991
  },
992
992
  shopDoesNotExist: {
993
993
  description: 'The shop does not exist.',
994
- content: { 'application/json': { schema: specificHttpError(errors.shopDoesNotExist) } },
994
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopDoesNotExist) } },
995
995
  },
996
996
  shopAlreadyExists: {
997
997
  description: 'The shop already exists.',
998
- content: { 'application/json': { schema: specificHttpError(errors.shopAlreadyExists) } },
998
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopAlreadyExists) } },
999
999
  },
1000
1000
  shopCannotBeUpdated: {
1001
1001
  description: 'The shop cannot be updated.',
1002
- content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeUpdated) } },
1002
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopCannotBeUpdated) } },
1003
1003
  },
1004
1004
  shopCannotBeDeleted: {
1005
1005
  description: 'The shop cannot be deleted.',
1006
- content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
1006
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopCannotBeDeleted) } },
1007
1007
  },
1008
1008
  shopCannotSell: {
1009
1009
  description: 'The shop does not have the capability to sell.',
1010
- content: { 'application/json': { schema: specificHttpError(errors.shopCannotSell) } },
1010
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopCannotSell) } },
1011
1011
  },
1012
1012
  shopNotEnabled: {
1013
1013
  description: 'The shop is not enabled.',
1014
- content: { 'application/json': { schema: specificHttpError(errors.shopNotEnabled) } },
1014
+ content: { 'application/json': { schema: specificErrorResponse(errors.shopNotEnabled) } },
1015
1015
  },
1016
1016
  wrongPassword: {
1017
1017
  description: 'The provided password is not the right one.',
1018
- content: { 'application/json': { schema: specificHttpError(errors.wrongPassword) } },
1018
+ content: { 'application/json': { schema: specificErrorResponse(errors.wrongPassword) } },
1019
1019
  },
1020
1020
  expeditionDoesNotExist: {
1021
1021
  description: 'The expedition does not exist.',
1022
- content: { 'application/json': { schema: specificHttpError(errors.expeditionDoesNotExist) } },
1022
+ content: { 'application/json': { schema: specificErrorResponse(errors.expeditionDoesNotExist) } },
1023
1023
  },
1024
1024
  expeditionAlreadyExists: {
1025
1025
  description: 'The expedition already exists.',
1026
- content: { 'application/json': { schema: specificHttpError(errors.expeditionAlreadyExists) } },
1026
+ content: { 'application/json': { schema: specificErrorResponse(errors.expeditionAlreadyExists) } },
1027
1027
  },
1028
1028
  expeditionCannotBeUpdated: {
1029
1029
  description: 'The expedition cannot be updated.',
1030
- content: { 'application/json': { schema: specificHttpError(errors.expeditionCannotBeUpdated) } },
1030
+ content: { 'application/json': { schema: specificErrorResponse(errors.expeditionCannotBeUpdated) } },
1031
1031
  },
1032
1032
  expeditionCannotBeDeleted: {
1033
1033
  description: 'The expedition cannot be deleted.',
1034
- content: { 'application/json': { schema: specificHttpError(errors.expeditionCannotBeDeleted) } },
1034
+ content: { 'application/json': { schema: specificErrorResponse(errors.expeditionCannotBeDeleted) } },
1035
1035
  },
1036
1036
  defaultsDoNotExist: {
1037
1037
  description: 'The defaults do not exist.',
1038
- content: { 'application/json': { schema: specificHttpError(errors.defaultsDoNotExist) } },
1038
+ content: { 'application/json': { schema: specificErrorResponse(errors.defaultsDoNotExist) } },
1039
1039
  },
1040
1040
  countersDoNotExist: {
1041
1041
  description: 'The counters do not exist.',
1042
- content: { 'application/json': { schema: specificHttpError(errors.countersDoNotExist) } },
1042
+ content: { 'application/json': { schema: specificErrorResponse(errors.countersDoNotExist) } },
1043
1043
  },
1044
1044
  representativeDoesNotExist: {
1045
1045
  description: 'The representative does not exist.',
1046
- content: { 'application/json': { schema: specificHttpError(errors.representativeDoesNotExist) } },
1046
+ content: { 'application/json': { schema: specificErrorResponse(errors.representativeDoesNotExist) } },
1047
1047
  },
1048
1048
  representativeAlreadyExists: {
1049
1049
  description: 'The representative already exists.',
1050
- content: { 'application/json': { schema: specificHttpError(errors.representativeAlreadyExists) } },
1050
+ content: { 'application/json': { schema: specificErrorResponse(errors.representativeAlreadyExists) } },
1051
1051
  },
1052
1052
  representativeCannotBeDeleted: {
1053
1053
  description: 'The representative cannot be deleted.',
1054
- content: { 'application/json': { schema: specificHttpError(errors.representativeCannotBeDeleted) } },
1054
+ content: { 'application/json': { schema: specificErrorResponse(errors.representativeCannotBeDeleted) } },
1055
1055
  },
1056
1056
  zoneDoesNotExist: {
1057
1057
  description: 'The zone does not exist.',
1058
- content: { 'application/json': { schema: specificHttpError(errors.zoneDoesNotExist) } },
1058
+ content: { 'application/json': { schema: specificErrorResponse(errors.zoneDoesNotExist) } },
1059
1059
  },
1060
1060
  zoneAlreadyExists: {
1061
1061
  description: 'The zone already exists.',
1062
- content: { 'application/json': { schema: specificHttpError(errors.zoneAlreadyExists) } },
1062
+ content: { 'application/json': { schema: specificErrorResponse(errors.zoneAlreadyExists) } },
1063
1063
  },
1064
1064
  zoneCannotBeDeleted: {
1065
1065
  description: 'The zone cannot be deleted.',
1066
- content: { 'application/json': { schema: specificHttpError(errors.zoneCannotBeDeleted) } },
1066
+ content: { 'application/json': { schema: specificErrorResponse(errors.zoneCannotBeDeleted) } },
1067
1067
  },
1068
1068
  saleDoesNotExist: {
1069
1069
  description: 'The sale does not exist.',
1070
- content: { 'application/json': { schema: specificHttpError(errors.saleDoesNotExist) } },
1070
+ content: { 'application/json': { schema: specificErrorResponse(errors.saleDoesNotExist) } },
1071
1071
  },
1072
1072
  saleAlreadyExists: {
1073
1073
  description: 'The sale already exists.',
1074
- content: { 'application/json': { schema: specificHttpError(errors.saleAlreadyExists) } },
1074
+ content: { 'application/json': { schema: specificErrorResponse(errors.saleAlreadyExists) } },
1075
1075
  },
1076
1076
  inconsistentSalesSettings: {
1077
1077
  description: 'The sales settings are inconsistent.',
1078
- content: { 'application/json': { schema: specificHttpError(errors.inconsistentSalesSettings) } },
1078
+ content: { 'application/json': { schema: specificErrorResponse(errors.inconsistentSalesSettings) } },
1079
1079
  },
1080
1080
  invalidSaleDestination: {
1081
1081
  description: 'The sale destination is invalid.',
1082
- content: { 'application/json': { schema: specificHttpError(errors.invalidSaleDestination) } },
1082
+ content: { 'application/json': { schema: specificErrorResponse(errors.invalidSaleDestination) } },
1083
1083
  },
1084
1084
  glsSpainError: {
1085
1085
  description: 'Cannot create the sale due to an error from the GLS Spain integration.',
1086
- content: { 'application/json': { schema: specificHttpError(errors.glsSpainError) } },
1086
+ content: { 'application/json': { schema: specificErrorResponse(errors.glsSpainError) } },
1087
1087
  },
1088
1088
  labelDoesNotExist: {
1089
1089
  description: 'The label does not exist.',
1090
- content: { 'application/json': { schema: specificHttpError(errors.labelDoesNotExist) } },
1090
+ content: { 'application/json': { schema: specificErrorResponse(errors.labelDoesNotExist) } },
1091
1091
  },
1092
1092
  };
1093
1093
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.9.0",
3
+ "version": "34.9.2",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -1,6 +1,7 @@
1
1
  const {
2
2
  uuid,
3
3
  dateRange,
4
+ datetimeRange,
4
5
  address: genericAddress,
5
6
  objectWithUuid,
6
7
  email,
@@ -8,9 +9,19 @@ const {
8
9
  Point,
9
10
  Polygon,
10
11
  mergeSchemas,
12
+ specificHttpError,
11
13
  } = require('@gls_spain/common-json-schemas');
12
14
  const { timezones } = require('@gls_spain/ajv-options');
13
15
 
16
+ const specificErrorResponse = error => ({
17
+ type: 'object',
18
+ properties: {
19
+ error: specificHttpError(error),
20
+ },
21
+ required: ['error'],
22
+ additionalProperties: false,
23
+ });
24
+
14
25
  const date = () => ({ type: 'string', format: 'date' });
15
26
 
16
27
  const country = () => ({
@@ -352,6 +363,12 @@ const findByOptionalDateRange = () => ({
352
363
  additionalProperties: false,
353
364
  });
354
365
 
366
+ const findByOptionalCreatedAtRange = () => ({
367
+ type: 'object',
368
+ properties: { createdAtRange: datetimeRange() },
369
+ additionalProperties: false,
370
+ });
371
+
355
372
  const timezone = () => ({ type: 'string', format: 'timezone' });
356
373
 
357
374
  const timezoneNames = () => ({ type: 'string', enum: timezones });
@@ -409,6 +426,7 @@ const findByFiscal = () => ({
409
426
  });
410
427
 
411
428
  module.exports = {
429
+ specificErrorResponse,
412
430
  date,
413
431
  country,
414
432
  address,
@@ -423,6 +441,7 @@ module.exports = {
423
441
  findByDate,
424
442
  findByDateRange,
425
443
  findByOptionalDateRange,
444
+ findByOptionalCreatedAtRange,
426
445
  timezone,
427
446
  timezoneNames,
428
447
  objectWithUuidAndName,
@@ -14,7 +14,7 @@ const {
14
14
  pickProperties,
15
15
  objectWithUuid,
16
16
  } = require('@gls_spain/common-json-schemas');
17
- const { country, findAll, findById, findByOptionalDateRange } = require('./common');
17
+ const { country, findAll, findById, findByOptionalCreatedAtRange } = require('./common');
18
18
  const { address } = require('./common');
19
19
  const { saleSize, salesSettings } = require('./defaults');
20
20
  const { network, objectWithNetworkId } = require('./networks');
@@ -156,15 +156,23 @@ const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop
156
156
 
157
157
  const findSalesSuperAdminRequest = () =>
158
158
  findRequest({
159
- oneOf: [mergeSchemas(findByNetwork(), findByOptionalDateRange()), mergeSchemas(findByShop(), findByOptionalDateRange()), findById()],
159
+ oneOf: [
160
+ mergeSchemas(findByNetwork(), findByOptionalCreatedAtRange()),
161
+ mergeSchemas(findByShop(), findByOptionalCreatedAtRange()),
162
+ findById(),
163
+ ],
160
164
  });
161
165
 
162
166
  const findSalesNetworkAdminRequest = () =>
163
167
  findRequest({
164
- oneOf: [mergeSchemas(findAll(), findByOptionalDateRange()), mergeSchemas(findByShop(), findByOptionalDateRange()), findById()],
168
+ oneOf: [
169
+ mergeSchemas(findAll(), findByOptionalCreatedAtRange()),
170
+ mergeSchemas(findByShop(), findByOptionalCreatedAtRange()),
171
+ findById(),
172
+ ],
165
173
  });
166
174
 
167
- const findSalesShopUserRequest = () => findRequest({ oneOf: [mergeSchemas(findAll(), findByOptionalDateRange()), findById()] });
175
+ const findSalesShopUserRequest = () => findRequest({ oneOf: [mergeSchemas(findAll(), findByOptionalCreatedAtRange()), findById()] });
168
176
 
169
177
  const findSalesResponse = () => findResponse(sale());
170
178