@gls_spain/gps-common 34.9.1 → 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.
- package/.idea/workspace.xml +6 -3
- package/CHANGELOG.md +7 -0
- package/open-api-spec/index.js +45 -45
- package/package.json +1 -1
- package/schemas/definitions/common.js +11 -0
package/.idea/workspace.xml
CHANGED
|
@@ -2,8 +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 beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
|
|
5
6
|
<change beforePath="$PROJECT_DIR$/schemas/definitions/common.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/common.js" afterDir="false" />
|
|
6
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/sales.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/sales.js" afterDir="false" />
|
|
7
7
|
</list>
|
|
8
8
|
<option name="SHOW_DIALOG" value="false" />
|
|
9
9
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
</configuration>
|
|
124
124
|
<recent_temporary>
|
|
125
125
|
<list>
|
|
126
|
-
<item itemvalue="npm.build-documentation" />
|
|
127
126
|
<item itemvalue="JavaScript Debug.documentation.html (1)" />
|
|
127
|
+
<item itemvalue="npm.build-documentation" />
|
|
128
128
|
<item itemvalue="npm.test" />
|
|
129
129
|
<item itemvalue="npm.semantic-release" />
|
|
130
130
|
<item itemvalue="npm.commit" />
|
|
@@ -651,7 +651,10 @@
|
|
|
651
651
|
<workItem from="1610996494321" duration="612000" />
|
|
652
652
|
<workItem from="1611040774303" duration="609000" />
|
|
653
653
|
<workItem from="1611059922357" duration="15000" />
|
|
654
|
-
<workItem from="1611060068624" duration="
|
|
654
|
+
<workItem from="1611060068624" duration="3602000" />
|
|
655
|
+
<workItem from="1611130910707" duration="110000" />
|
|
656
|
+
<workItem from="1611300719061" duration="18000" />
|
|
657
|
+
<workItem from="1611567691754" duration="526000" />
|
|
655
658
|
</task>
|
|
656
659
|
<servers />
|
|
657
660
|
</component>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [34.9.1](https://github.com/GLS-Spain/gps-common/compare/v34.9.0...v34.9.1) (2021-01-19)
|
|
2
9
|
|
|
3
10
|
|
package/open-api-spec/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
InvalidCookieOrHeaderError,
|
|
10
10
|
MissingCookieOrHeaderError,
|
|
11
11
|
} = require('@gls_spain/common-errors');
|
|
12
|
-
const { errorResponse
|
|
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:
|
|
922
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.badRequest) } },
|
|
923
923
|
},
|
|
924
924
|
unauthorized: {
|
|
925
925
|
description: errors.unauthorized.message,
|
|
926
|
-
content: { 'application/json': { schema:
|
|
926
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.unauthorized) } },
|
|
927
927
|
},
|
|
928
928
|
invalidUsernameOrPassword: {
|
|
929
929
|
description: errors.invalidUsernameOrPassword.message,
|
|
930
|
-
content: { 'application/json': { schema:
|
|
930
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.invalidUsernameOrPassword) } },
|
|
931
931
|
},
|
|
932
932
|
invalidUserInCookieOrHeader: {
|
|
933
933
|
description: errors.invalidUserInCookieOrHeader.message,
|
|
934
|
-
content: { 'application/json': { schema:
|
|
934
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.invalidUserInCookieOrHeader) } },
|
|
935
935
|
},
|
|
936
936
|
invalidCookieOrHeader: {
|
|
937
937
|
description: errors.invalidCookieOrHeader.message,
|
|
938
|
-
content: { 'application/json': { schema:
|
|
938
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.invalidCookieOrHeader) } },
|
|
939
939
|
},
|
|
940
940
|
missingCookieOrHeader: {
|
|
941
941
|
description: errors.missingCookieOrHeader.message,
|
|
942
|
-
content: { 'application/json': { schema:
|
|
942
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.missingCookieOrHeader) } },
|
|
943
943
|
},
|
|
944
944
|
forbidden: {
|
|
945
945
|
description: errors.forbidden.message,
|
|
946
|
-
content: { 'application/json': { schema:
|
|
946
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.forbidden) } },
|
|
947
947
|
},
|
|
948
948
|
unsupportedMediaType: {
|
|
949
949
|
description: errors.unsupportedMediaType.message,
|
|
950
|
-
content: { 'application/json': { schema:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
1090
|
+
content: { 'application/json': { schema: specificErrorResponse(errors.labelDoesNotExist) } },
|
|
1091
1091
|
},
|
|
1092
1092
|
};
|
|
1093
1093
|
|
package/package.json
CHANGED
|
@@ -9,9 +9,19 @@ const {
|
|
|
9
9
|
Point,
|
|
10
10
|
Polygon,
|
|
11
11
|
mergeSchemas,
|
|
12
|
+
specificHttpError,
|
|
12
13
|
} = require('@gls_spain/common-json-schemas');
|
|
13
14
|
const { timezones } = require('@gls_spain/ajv-options');
|
|
14
15
|
|
|
16
|
+
const specificErrorResponse = error => ({
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
error: specificHttpError(error),
|
|
20
|
+
},
|
|
21
|
+
required: ['error'],
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
});
|
|
24
|
+
|
|
15
25
|
const date = () => ({ type: 'string', format: 'date' });
|
|
16
26
|
|
|
17
27
|
const country = () => ({
|
|
@@ -416,6 +426,7 @@ const findByFiscal = () => ({
|
|
|
416
426
|
});
|
|
417
427
|
|
|
418
428
|
module.exports = {
|
|
429
|
+
specificErrorResponse,
|
|
419
430
|
date,
|
|
420
431
|
country,
|
|
421
432
|
address,
|