@gls_spain/gps-common 34.9.2 → 34.9.4

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.
Files changed (81) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.json +11 -11
  3. package/.idea/codeStyles/Project.xml +36 -36
  4. package/.idea/codeStyles/codeStyleConfig.xml +4 -4
  5. package/.idea/gps-common.iml +11 -11
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -6
  7. package/.idea/jsLibraryMappings.xml +5 -5
  8. package/.idea/misc.xml +5 -5
  9. package/.idea/modules.xml +7 -7
  10. package/.idea/prettier.xml +6 -6
  11. package/.idea/scopes/Source_files.xml +2 -2
  12. package/.idea/vcs.xml +5 -5
  13. package/.prettierignore +4 -4
  14. package/.prettierrc.json +13 -13
  15. package/.releaserc +17 -17
  16. package/CHANGELOG.md +1271 -1257
  17. package/README.md +103 -103
  18. package/errors/CountersDoNotExistError.js +11 -11
  19. package/errors/DatabaseNotEmptyError.js +11 -11
  20. package/errors/DefaultsDoNotExistError.js +11 -11
  21. package/errors/ExpeditionAlreadyExistsError.js +11 -11
  22. package/errors/ExpeditionCannotBeDeletedError.js +11 -11
  23. package/errors/ExpeditionCannotBeUpdatedError.js +11 -11
  24. package/errors/ExpeditionDoesNotExistError.js +11 -11
  25. package/errors/GLSRecordingError.js +11 -11
  26. package/errors/GLSSpainError.js +11 -11
  27. package/errors/InconsistentSalesSettingsError.js +11 -11
  28. package/errors/InvalidSaleDestinationError.js +11 -11
  29. package/errors/LabelDoesNotExistError.js +11 -11
  30. package/errors/NetworkAlreadyExistsError.js +11 -11
  31. package/errors/NetworkCannotBeDeletedError.js +11 -11
  32. package/errors/NetworkCannotBeUpdatedError.js +11 -11
  33. package/errors/NetworkDoesNotExistError.js +11 -11
  34. package/errors/RepresentativeAlreadyExistsError.js +11 -11
  35. package/errors/RepresentativeCannotBeDeletedError.js +11 -11
  36. package/errors/RepresentativeDoesNotExistError.js +11 -11
  37. package/errors/SaleAlreadyExistsError.js +11 -11
  38. package/errors/SaleDoesNotExistError.js +11 -11
  39. package/errors/ShopAlreadyExistsError.js +11 -11
  40. package/errors/ShopCannotBeDeletedError.js +11 -11
  41. package/errors/ShopCannotBeUpdatedError.js +11 -11
  42. package/errors/ShopCannotSellError.js +11 -11
  43. package/errors/ShopDoesNotExistError.js +11 -11
  44. package/errors/ShopNotEnabledError.js +11 -11
  45. package/errors/UserAlreadyExistsError.js +11 -11
  46. package/errors/UserCannotBeDeletedError.js +11 -11
  47. package/errors/UserCannotBeUpdatedError.js +11 -11
  48. package/errors/UserDoesNotExistError.js +11 -11
  49. package/errors/WrongNetworkError.js +11 -11
  50. package/errors/WrongPasswordError.js +11 -11
  51. package/errors/WrongShopError.js +11 -11
  52. package/errors/ZoneAlreadyExistsError.js +11 -11
  53. package/errors/ZoneCannotBeDeletedError.js +11 -11
  54. package/errors/ZoneDoesNotExistError.js +11 -11
  55. package/errors/index.js +118 -118
  56. package/index.js +9 -9
  57. package/index.test.js +36 -36
  58. package/jest.config.js +5 -5
  59. package/open-api-spec/index.js +3715 -3715
  60. package/package.json +65 -69
  61. package/schemas/definitions/become.js +5 -5
  62. package/schemas/definitions/common.js +462 -451
  63. package/schemas/definitions/counters.js +43 -43
  64. package/schemas/definitions/defaults.js +140 -140
  65. package/schemas/definitions/expeditions.js +867 -867
  66. package/schemas/definitions/gls-spain-integration-events.js +139 -139
  67. package/schemas/definitions/historic-records.js +90 -90
  68. package/schemas/definitions/integrations.js +38 -38
  69. package/schemas/definitions/login.js +38 -38
  70. package/schemas/definitions/logout.js +8 -8
  71. package/schemas/definitions/networks.js +123 -123
  72. package/schemas/definitions/pods.js +26 -26
  73. package/schemas/definitions/representatives.js +194 -194
  74. package/schemas/definitions/sales.js +253 -249
  75. package/schemas/definitions/shops.js +413 -404
  76. package/schemas/definitions/users.js +337 -337
  77. package/schemas/definitions/zones.js +92 -92
  78. package/schemas/index.js +400 -400
  79. package/scripts/build-documentation.js +40 -40
  80. package/scripts/build-json-schemas.js +35 -35
  81. package/.idea/workspace.xml +0 -699
@@ -1,43 +1,43 @@
1
- const { uuid, datetime } = require('@gls_spain/common-json-schemas');
2
-
3
- const counters = () => ({
4
- title: 'counters',
5
- type: 'object',
6
- properties: {
7
- _id: uuid(),
8
- createdAt: datetime(),
9
- updatedAt: datetime(),
10
- deletable: { type: 'boolean' },
11
- shops: {
12
- type: 'object',
13
- properties: {
14
- international: {
15
- type: 'object',
16
- properties: {
17
- parcelShopId: { type: 'integer', minimum: 0, description: 'last id used, auto increments itself as shops are created' },
18
- },
19
- required: ['parcelShopId'],
20
- additionalProperties: false,
21
- },
22
- },
23
- required: ['international'],
24
- additionalProperties: false,
25
- },
26
- },
27
- required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'shops'],
28
- additionalProperties: false,
29
- });
30
-
31
- const getCountersResponse = () => ({
32
- type: 'object',
33
- properties: {
34
- get: counters(),
35
- },
36
- required: ['get'],
37
- additionalProperties: false,
38
- });
39
-
40
- module.exports = {
41
- counters,
42
- getCountersResponse,
43
- };
1
+ const { uuid, datetime } = require('@gls_spain/common-json-schemas');
2
+
3
+ const counters = () => ({
4
+ title: 'counters',
5
+ type: 'object',
6
+ properties: {
7
+ _id: uuid(),
8
+ createdAt: datetime(),
9
+ updatedAt: datetime(),
10
+ deletable: { type: 'boolean' },
11
+ shops: {
12
+ type: 'object',
13
+ properties: {
14
+ international: {
15
+ type: 'object',
16
+ properties: {
17
+ parcelShopId: { type: 'integer', minimum: 0, description: 'last id used, auto increments itself as shops are created' },
18
+ },
19
+ required: ['parcelShopId'],
20
+ additionalProperties: false,
21
+ },
22
+ },
23
+ required: ['international'],
24
+ additionalProperties: false,
25
+ },
26
+ },
27
+ required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'shops'],
28
+ additionalProperties: false,
29
+ });
30
+
31
+ const getCountersResponse = () => ({
32
+ type: 'object',
33
+ properties: {
34
+ get: counters(),
35
+ },
36
+ required: ['get'],
37
+ additionalProperties: false,
38
+ });
39
+
40
+ module.exports = {
41
+ counters,
42
+ getCountersResponse,
43
+ };
@@ -1,140 +1,140 @@
1
- const { uuid, datetime, money, updateSelfRequest, updateResponse, pickProperties } = require('@gls_spain/common-json-schemas');
2
- const { country } = require('./common');
3
-
4
- const derivationRate = () => ({
5
- title: 'derivation rate',
6
- type: 'object',
7
- properties: {
8
- constant: { ...money(), description: 'fixed amount paid in cents, per package' },
9
- variableStart: { type: 'number', description: 'weight threshold in kg to start paying the variable, per package' },
10
- variable: { ...money(), description: 'amount paid in cents for each additional kg beyond the weight threshold, per package' },
11
- },
12
- required: ['constant', 'variableStart', 'variable'],
13
- additionalProperties: false,
14
- description: 'pricePerPackage = constant + max(0, weight - variableStart) * variable',
15
- });
16
-
17
- const derivationSettings = () => ({
18
- title: 'derivation settings',
19
- type: 'object',
20
- properties: {
21
- networkRate: derivationRate(),
22
- shopRate: derivationRate(),
23
- },
24
- required: ['networkRate', 'shopRate'],
25
- additionalProperties: false,
26
- });
27
-
28
- const expirationSettings = () => ({
29
- title: 'expiration settings',
30
- type: 'object',
31
- properties: {
32
- expirationDays: {
33
- type: 'integer',
34
- minimum: 1,
35
- description: 'how many natural days it takes for the expedition to expire after arrival, e.g. 10 days',
36
- },
37
- reminderDays: {
38
- type: 'array',
39
- items: { type: 'integer', minimum: 1 },
40
- uniqueItems: true,
41
- description: 'on which days after arrival should a pickup reminder be sent, e.g. on days 3, 6 and 9',
42
- },
43
- },
44
- required: ['expirationDays', 'reminderDays'],
45
- additionalProperties: false,
46
- });
47
-
48
- const saleSize = () => ({
49
- type: 'string',
50
- enum: ['xs', 's', 'm', 'l', 'xl'],
51
- });
52
-
53
- const saleZoneRegion = () => ({
54
- type: 'object',
55
- properties: {
56
- country: country(),
57
- postalCodePrefix: { type: 'string', minLength: 1 },
58
- },
59
- required: ['country'],
60
- additionalProperties: false,
61
- });
62
-
63
- const saleZone = () => ({
64
- type: 'object',
65
- properties: {
66
- name: { type: 'string', trim: true, minLength: 1 },
67
- prices: {
68
- type: 'object',
69
- properties: {
70
- xs: money(),
71
- s: money(),
72
- m: money(),
73
- l: money(),
74
- xl: money(),
75
- },
76
- required: ['xs', 's', 'm', 'l', 'xl'],
77
- additionalProperties: false,
78
- },
79
- includes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
80
- excludes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
81
- },
82
- required: ['name', 'prices', 'includes', 'excludes'],
83
- additionalProperties: false,
84
- });
85
-
86
- const salesSettings = () => ({
87
- title: 'sales settings',
88
- type: 'object',
89
- properties: {
90
- zones: { type: 'array', items: saleZone(), uniqueItems: true, minItems: 1 },
91
- },
92
- required: ['zones'],
93
- additionalProperties: false,
94
- });
95
-
96
- const defaults = () => ({
97
- title: 'defaults',
98
- type: 'object',
99
- properties: {
100
- _id: uuid(),
101
- createdAt: datetime(),
102
- updatedAt: datetime(),
103
- deletable: { type: 'boolean' },
104
- derivationSettings: derivationSettings(),
105
- expirationSettings: expirationSettings(),
106
- salesSettings: salesSettings(),
107
- },
108
- required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'derivationSettings', 'expirationSettings', 'salesSettings'],
109
- additionalProperties: false,
110
- });
111
-
112
- const getDefaultsResponse = () => ({
113
- type: 'object',
114
- properties: {
115
- get: defaults(),
116
- },
117
- required: ['get'],
118
- additionalProperties: false,
119
- });
120
-
121
- const updateDefaultsRequest = () =>
122
- updateSelfRequest({
123
- type: 'object',
124
- properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings', 'salesSettings']) },
125
- minProperties: 1,
126
- additionalProperties: false,
127
- });
128
-
129
- const updateDefaultsResponse = () => updateResponse(defaults());
130
-
131
- module.exports = {
132
- derivationSettings,
133
- expirationSettings,
134
- saleSize,
135
- salesSettings,
136
- defaults,
137
- getDefaultsResponse,
138
- updateDefaultsRequest,
139
- updateDefaultsResponse,
140
- };
1
+ const { uuid, datetime, money, updateSelfRequest, updateResponse, pickProperties } = require('@gls_spain/common-json-schemas');
2
+ const { country } = require('./common');
3
+
4
+ const derivationRate = () => ({
5
+ title: 'derivation rate',
6
+ type: 'object',
7
+ properties: {
8
+ constant: { ...money(), description: 'fixed amount paid in cents, per package' },
9
+ variableStart: { type: 'number', description: 'weight threshold in kg to start paying the variable, per package' },
10
+ variable: { ...money(), description: 'amount paid in cents for each additional kg beyond the weight threshold, per package' },
11
+ },
12
+ required: ['constant', 'variableStart', 'variable'],
13
+ additionalProperties: false,
14
+ description: 'pricePerPackage = constant + max(0, weight - variableStart) * variable',
15
+ });
16
+
17
+ const derivationSettings = () => ({
18
+ title: 'derivation settings',
19
+ type: 'object',
20
+ properties: {
21
+ networkRate: derivationRate(),
22
+ shopRate: derivationRate(),
23
+ },
24
+ required: ['networkRate', 'shopRate'],
25
+ additionalProperties: false,
26
+ });
27
+
28
+ const expirationSettings = () => ({
29
+ title: 'expiration settings',
30
+ type: 'object',
31
+ properties: {
32
+ expirationDays: {
33
+ type: 'integer',
34
+ minimum: 1,
35
+ description: 'how many natural days it takes for the expedition to expire after arrival, e.g. 10 days',
36
+ },
37
+ reminderDays: {
38
+ type: 'array',
39
+ items: { type: 'integer', minimum: 1 },
40
+ uniqueItems: true,
41
+ description: 'on which days after arrival should a pickup reminder be sent, e.g. on days 3, 6 and 9',
42
+ },
43
+ },
44
+ required: ['expirationDays', 'reminderDays'],
45
+ additionalProperties: false,
46
+ });
47
+
48
+ const saleSize = () => ({
49
+ type: 'string',
50
+ enum: ['xs', 's', 'm', 'l', 'xl'],
51
+ });
52
+
53
+ const saleZoneRegion = () => ({
54
+ type: 'object',
55
+ properties: {
56
+ country: country(),
57
+ postalCodePrefix: { type: 'string', minLength: 1 },
58
+ },
59
+ required: ['country'],
60
+ additionalProperties: false,
61
+ });
62
+
63
+ const saleZone = () => ({
64
+ type: 'object',
65
+ properties: {
66
+ name: { type: 'string', trim: true, minLength: 1 },
67
+ prices: {
68
+ type: 'object',
69
+ properties: {
70
+ xs: money(),
71
+ s: money(),
72
+ m: money(),
73
+ l: money(),
74
+ xl: money(),
75
+ },
76
+ required: ['xs', 's', 'm', 'l', 'xl'],
77
+ additionalProperties: false,
78
+ },
79
+ includes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
80
+ excludes: { type: 'array', items: saleZoneRegion(), uniqueItems: true },
81
+ },
82
+ required: ['name', 'prices', 'includes', 'excludes'],
83
+ additionalProperties: false,
84
+ });
85
+
86
+ const salesSettings = () => ({
87
+ title: 'sales settings',
88
+ type: 'object',
89
+ properties: {
90
+ zones: { type: 'array', items: saleZone(), uniqueItems: true, minItems: 1 },
91
+ },
92
+ required: ['zones'],
93
+ additionalProperties: false,
94
+ });
95
+
96
+ const defaults = () => ({
97
+ title: 'defaults',
98
+ type: 'object',
99
+ properties: {
100
+ _id: uuid(),
101
+ createdAt: datetime(),
102
+ updatedAt: datetime(),
103
+ deletable: { type: 'boolean' },
104
+ derivationSettings: derivationSettings(),
105
+ expirationSettings: expirationSettings(),
106
+ salesSettings: salesSettings(),
107
+ },
108
+ required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'derivationSettings', 'expirationSettings', 'salesSettings'],
109
+ additionalProperties: false,
110
+ });
111
+
112
+ const getDefaultsResponse = () => ({
113
+ type: 'object',
114
+ properties: {
115
+ get: defaults(),
116
+ },
117
+ required: ['get'],
118
+ additionalProperties: false,
119
+ });
120
+
121
+ const updateDefaultsRequest = () =>
122
+ updateSelfRequest({
123
+ type: 'object',
124
+ properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings', 'salesSettings']) },
125
+ minProperties: 1,
126
+ additionalProperties: false,
127
+ });
128
+
129
+ const updateDefaultsResponse = () => updateResponse(defaults());
130
+
131
+ module.exports = {
132
+ derivationSettings,
133
+ expirationSettings,
134
+ saleSize,
135
+ salesSettings,
136
+ defaults,
137
+ getDefaultsResponse,
138
+ updateDefaultsRequest,
139
+ updateDefaultsResponse,
140
+ };