@gls_spain/gps-common 34.9.1 → 34.9.3
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/.eslintignore +1 -1
- package/.eslintrc.json +11 -11
- package/.idea/codeStyles/Project.xml +36 -36
- package/.idea/codeStyles/codeStyleConfig.xml +4 -4
- package/.idea/gps-common.iml +11 -11
- package/.idea/inspectionProfiles/Project_Default.xml +6 -6
- package/.idea/jsLibraryMappings.xml +5 -5
- package/.idea/misc.xml +5 -5
- package/.idea/modules.xml +7 -7
- package/.idea/prettier.xml +6 -6
- package/.idea/scopes/Source_files.xml +2 -2
- package/.idea/vcs.xml +5 -5
- package/.prettierignore +4 -4
- package/.prettierrc.json +13 -13
- package/.releaserc +17 -17
- package/CHANGELOG.md +1264 -1250
- package/README.md +103 -103
- package/errors/CountersDoNotExistError.js +11 -11
- package/errors/DatabaseNotEmptyError.js +11 -11
- package/errors/DefaultsDoNotExistError.js +11 -11
- package/errors/ExpeditionAlreadyExistsError.js +11 -11
- package/errors/ExpeditionCannotBeDeletedError.js +11 -11
- package/errors/ExpeditionCannotBeUpdatedError.js +11 -11
- package/errors/ExpeditionDoesNotExistError.js +11 -11
- package/errors/GLSRecordingError.js +11 -11
- package/errors/GLSSpainError.js +11 -11
- package/errors/InconsistentSalesSettingsError.js +11 -11
- package/errors/InvalidSaleDestinationError.js +11 -11
- package/errors/LabelDoesNotExistError.js +11 -11
- package/errors/NetworkAlreadyExistsError.js +11 -11
- package/errors/NetworkCannotBeDeletedError.js +11 -11
- package/errors/NetworkCannotBeUpdatedError.js +11 -11
- package/errors/NetworkDoesNotExistError.js +11 -11
- package/errors/RepresentativeAlreadyExistsError.js +11 -11
- package/errors/RepresentativeCannotBeDeletedError.js +11 -11
- package/errors/RepresentativeDoesNotExistError.js +11 -11
- package/errors/SaleAlreadyExistsError.js +11 -11
- package/errors/SaleDoesNotExistError.js +11 -11
- package/errors/ShopAlreadyExistsError.js +11 -11
- package/errors/ShopCannotBeDeletedError.js +11 -11
- package/errors/ShopCannotBeUpdatedError.js +11 -11
- package/errors/ShopCannotSellError.js +11 -11
- package/errors/ShopDoesNotExistError.js +11 -11
- package/errors/ShopNotEnabledError.js +11 -11
- package/errors/UserAlreadyExistsError.js +11 -11
- package/errors/UserCannotBeDeletedError.js +11 -11
- package/errors/UserCannotBeUpdatedError.js +11 -11
- package/errors/UserDoesNotExistError.js +11 -11
- package/errors/WrongNetworkError.js +11 -11
- package/errors/WrongPasswordError.js +11 -11
- package/errors/WrongShopError.js +11 -11
- package/errors/ZoneAlreadyExistsError.js +11 -11
- package/errors/ZoneCannotBeDeletedError.js +11 -11
- package/errors/ZoneDoesNotExistError.js +11 -11
- package/errors/index.js +118 -118
- package/index.js +9 -9
- package/index.test.js +36 -36
- package/jest.config.js +5 -5
- package/open-api-spec/index.js +3715 -3715
- package/package.json +65 -69
- package/schemas/definitions/become.js +5 -5
- package/schemas/definitions/common.js +462 -440
- package/schemas/definitions/counters.js +43 -43
- package/schemas/definitions/defaults.js +140 -140
- package/schemas/definitions/expeditions.js +867 -867
- package/schemas/definitions/gls-spain-integration-events.js +139 -139
- package/schemas/definitions/historic-records.js +90 -90
- package/schemas/definitions/integrations.js +38 -38
- package/schemas/definitions/login.js +38 -38
- package/schemas/definitions/logout.js +8 -8
- package/schemas/definitions/networks.js +123 -123
- package/schemas/definitions/pods.js +26 -26
- package/schemas/definitions/representatives.js +194 -194
- package/schemas/definitions/sales.js +253 -249
- package/schemas/definitions/shops.js +404 -404
- package/schemas/definitions/users.js +337 -337
- package/schemas/definitions/zones.js +92 -92
- package/schemas/index.js +400 -400
- package/scripts/build-documentation.js +40 -40
- package/scripts/build-json-schemas.js +35 -35
- package/.idea/workspace.xml +0 -696
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
const {
|
|
2
|
-
uuid,
|
|
3
|
-
datetime,
|
|
4
|
-
datetimeRange,
|
|
5
|
-
email,
|
|
6
|
-
phone,
|
|
7
|
-
money,
|
|
8
|
-
objectWithUuid,
|
|
9
|
-
createRequest,
|
|
10
|
-
createResponse,
|
|
11
|
-
findRequest,
|
|
12
|
-
findResponse,
|
|
13
|
-
updateRequest,
|
|
14
|
-
updateResponse,
|
|
15
|
-
deleteRequest,
|
|
16
|
-
deleteResponse,
|
|
17
|
-
pickProperties,
|
|
18
|
-
} = require('@gls_spain/common-json-schemas');
|
|
19
|
-
const { findAll, findById, findByName, objectWithUuidAndName } = require('./common');
|
|
20
|
-
const { zone } = require('./zones');
|
|
21
|
-
|
|
22
|
-
const representative = () => ({
|
|
23
|
-
title: 'representative',
|
|
24
|
-
type: 'object',
|
|
25
|
-
properties: {
|
|
26
|
-
_id: uuid(),
|
|
27
|
-
createdAt: datetime(),
|
|
28
|
-
updatedAt: datetime(),
|
|
29
|
-
deletable: { type: 'boolean' },
|
|
30
|
-
name: { type: 'string', trim: true },
|
|
31
|
-
emails: { type: 'array', items: email(), uniqueItems: true },
|
|
32
|
-
phones: { type: 'array', items: phone(), uniqueItems: true },
|
|
33
|
-
nif: { type: 'string', trim: true },
|
|
34
|
-
zones: {
|
|
35
|
-
type: 'array',
|
|
36
|
-
items: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
properties: { ...pickProperties(zone(), ['_id', 'name']) },
|
|
39
|
-
required: ['_id', 'name'],
|
|
40
|
-
additionalProperties: false,
|
|
41
|
-
},
|
|
42
|
-
uniqueItems: true,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'name', 'emails', 'phones', 'nif', 'zones'],
|
|
46
|
-
additionalProperties: false,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const setRepresentativesZones = () => ({
|
|
50
|
-
type: 'array',
|
|
51
|
-
items: objectWithUuid(),
|
|
52
|
-
uniqueItems: true,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const createRepresentativeRequest = () =>
|
|
56
|
-
createRequest({
|
|
57
|
-
type: 'object',
|
|
58
|
-
properties: {
|
|
59
|
-
...pickProperties(representative(), ['_id', 'createdAt', 'name', 'emails', 'phones', 'nif']),
|
|
60
|
-
zones: setRepresentativesZones(),
|
|
61
|
-
},
|
|
62
|
-
required: ['name', 'nif'],
|
|
63
|
-
additionalProperties: false,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const createRepresentativeResponse = () => createResponse(representative());
|
|
67
|
-
|
|
68
|
-
const findRepresentativesRequest = () => findRequest({ oneOf: [findAll(), findById(), findByName()] });
|
|
69
|
-
|
|
70
|
-
const findRepresentativesResponse = () => findResponse(representative());
|
|
71
|
-
|
|
72
|
-
const listRepresentativesNamesResponse = () => ({
|
|
73
|
-
type: 'object',
|
|
74
|
-
properties: { found: { type: 'array', items: objectWithUuidAndName() } },
|
|
75
|
-
required: ['found'],
|
|
76
|
-
additionalProperties: false,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const getOwnRepresentativesResponse = () => ({
|
|
80
|
-
type: 'object',
|
|
81
|
-
properties: {
|
|
82
|
-
get: {
|
|
83
|
-
type: 'object',
|
|
84
|
-
properties: {
|
|
85
|
-
openingRepresentative: representative(),
|
|
86
|
-
managingRepresentative: representative(),
|
|
87
|
-
},
|
|
88
|
-
additionalProperties: false,
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
required: ['get'],
|
|
92
|
-
additionalProperties: false,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const updateRepresentativeRequest = () =>
|
|
96
|
-
updateRequest(
|
|
97
|
-
findById(),
|
|
98
|
-
{
|
|
99
|
-
type: 'object',
|
|
100
|
-
properties: {
|
|
101
|
-
zones: setRepresentativesZones(),
|
|
102
|
-
...pickProperties(representative(), ['name', 'emails', 'phones', 'nif']),
|
|
103
|
-
},
|
|
104
|
-
minProperties: 1,
|
|
105
|
-
additionalProperties: false,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
type: 'object',
|
|
109
|
-
properties: {
|
|
110
|
-
zones: setRepresentativesZones(),
|
|
111
|
-
...pickProperties(representative(), ['emails', 'phones']),
|
|
112
|
-
},
|
|
113
|
-
minProperties: 1,
|
|
114
|
-
additionalProperties: false,
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
const updateRepresentativeResponse = () => updateResponse(representative());
|
|
119
|
-
|
|
120
|
-
const shopCommissions = () => ({
|
|
121
|
-
type: 'object',
|
|
122
|
-
properties: {
|
|
123
|
-
name: { type: 'string' },
|
|
124
|
-
since: datetime(),
|
|
125
|
-
},
|
|
126
|
-
required: ['name', 'since'],
|
|
127
|
-
additionalProperties: false,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const zoneCommissions = () => ({
|
|
131
|
-
type: 'object',
|
|
132
|
-
properties: {
|
|
133
|
-
name: { type: 'string' },
|
|
134
|
-
total: money(),
|
|
135
|
-
openedShops: { type: 'array', items: shopCommissions() },
|
|
136
|
-
managedShops: { type: 'array', items: shopCommissions() },
|
|
137
|
-
},
|
|
138
|
-
required: ['name', 'total', 'openedShops', 'managedShops'],
|
|
139
|
-
additionalProperties: false,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const getRepresentativeCommissionsRequest = () => ({
|
|
143
|
-
type: 'object',
|
|
144
|
-
properties: {
|
|
145
|
-
get: {
|
|
146
|
-
type: 'object',
|
|
147
|
-
properties: {
|
|
148
|
-
representative: objectWithUuid(),
|
|
149
|
-
datetimeRange: datetimeRange(),
|
|
150
|
-
},
|
|
151
|
-
required: ['representative', 'datetimeRange'],
|
|
152
|
-
additionalProperties: false,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
required: ['get'],
|
|
156
|
-
additionalProperties: false,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const getRepresentativeCommissionsResponse = () => ({
|
|
160
|
-
type: 'object',
|
|
161
|
-
properties: {
|
|
162
|
-
get: {
|
|
163
|
-
type: 'object',
|
|
164
|
-
properties: {
|
|
165
|
-
total: money(),
|
|
166
|
-
zones: { type: 'array', items: zoneCommissions() },
|
|
167
|
-
},
|
|
168
|
-
required: ['total', 'zones'],
|
|
169
|
-
additionalProperties: false,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
required: ['get'],
|
|
173
|
-
additionalProperties: false,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const deleteRepresentativeRequest = () => deleteRequest(findById());
|
|
177
|
-
|
|
178
|
-
const deleteRepresentativeResponse = () => deleteResponse(representative());
|
|
179
|
-
|
|
180
|
-
module.exports = {
|
|
181
|
-
representative,
|
|
182
|
-
createRepresentativeRequest,
|
|
183
|
-
createRepresentativeResponse,
|
|
184
|
-
findRepresentativesRequest,
|
|
185
|
-
findRepresentativesResponse,
|
|
186
|
-
listRepresentativesNamesResponse,
|
|
187
|
-
getOwnRepresentativesResponse,
|
|
188
|
-
updateRepresentativeRequest,
|
|
189
|
-
updateRepresentativeResponse,
|
|
190
|
-
getRepresentativeCommissionsRequest,
|
|
191
|
-
getRepresentativeCommissionsResponse,
|
|
192
|
-
deleteRepresentativeRequest,
|
|
193
|
-
deleteRepresentativeResponse,
|
|
194
|
-
};
|
|
1
|
+
const {
|
|
2
|
+
uuid,
|
|
3
|
+
datetime,
|
|
4
|
+
datetimeRange,
|
|
5
|
+
email,
|
|
6
|
+
phone,
|
|
7
|
+
money,
|
|
8
|
+
objectWithUuid,
|
|
9
|
+
createRequest,
|
|
10
|
+
createResponse,
|
|
11
|
+
findRequest,
|
|
12
|
+
findResponse,
|
|
13
|
+
updateRequest,
|
|
14
|
+
updateResponse,
|
|
15
|
+
deleteRequest,
|
|
16
|
+
deleteResponse,
|
|
17
|
+
pickProperties,
|
|
18
|
+
} = require('@gls_spain/common-json-schemas');
|
|
19
|
+
const { findAll, findById, findByName, objectWithUuidAndName } = require('./common');
|
|
20
|
+
const { zone } = require('./zones');
|
|
21
|
+
|
|
22
|
+
const representative = () => ({
|
|
23
|
+
title: 'representative',
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
_id: uuid(),
|
|
27
|
+
createdAt: datetime(),
|
|
28
|
+
updatedAt: datetime(),
|
|
29
|
+
deletable: { type: 'boolean' },
|
|
30
|
+
name: { type: 'string', trim: true },
|
|
31
|
+
emails: { type: 'array', items: email(), uniqueItems: true },
|
|
32
|
+
phones: { type: 'array', items: phone(), uniqueItems: true },
|
|
33
|
+
nif: { type: 'string', trim: true },
|
|
34
|
+
zones: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
items: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: { ...pickProperties(zone(), ['_id', 'name']) },
|
|
39
|
+
required: ['_id', 'name'],
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
},
|
|
42
|
+
uniqueItems: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'name', 'emails', 'phones', 'nif', 'zones'],
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const setRepresentativesZones = () => ({
|
|
50
|
+
type: 'array',
|
|
51
|
+
items: objectWithUuid(),
|
|
52
|
+
uniqueItems: true,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const createRepresentativeRequest = () =>
|
|
56
|
+
createRequest({
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
...pickProperties(representative(), ['_id', 'createdAt', 'name', 'emails', 'phones', 'nif']),
|
|
60
|
+
zones: setRepresentativesZones(),
|
|
61
|
+
},
|
|
62
|
+
required: ['name', 'nif'],
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const createRepresentativeResponse = () => createResponse(representative());
|
|
67
|
+
|
|
68
|
+
const findRepresentativesRequest = () => findRequest({ oneOf: [findAll(), findById(), findByName()] });
|
|
69
|
+
|
|
70
|
+
const findRepresentativesResponse = () => findResponse(representative());
|
|
71
|
+
|
|
72
|
+
const listRepresentativesNamesResponse = () => ({
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: { found: { type: 'array', items: objectWithUuidAndName() } },
|
|
75
|
+
required: ['found'],
|
|
76
|
+
additionalProperties: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const getOwnRepresentativesResponse = () => ({
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
get: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
openingRepresentative: representative(),
|
|
86
|
+
managingRepresentative: representative(),
|
|
87
|
+
},
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
required: ['get'],
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const updateRepresentativeRequest = () =>
|
|
96
|
+
updateRequest(
|
|
97
|
+
findById(),
|
|
98
|
+
{
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
zones: setRepresentativesZones(),
|
|
102
|
+
...pickProperties(representative(), ['name', 'emails', 'phones', 'nif']),
|
|
103
|
+
},
|
|
104
|
+
minProperties: 1,
|
|
105
|
+
additionalProperties: false,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
zones: setRepresentativesZones(),
|
|
111
|
+
...pickProperties(representative(), ['emails', 'phones']),
|
|
112
|
+
},
|
|
113
|
+
minProperties: 1,
|
|
114
|
+
additionalProperties: false,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const updateRepresentativeResponse = () => updateResponse(representative());
|
|
119
|
+
|
|
120
|
+
const shopCommissions = () => ({
|
|
121
|
+
type: 'object',
|
|
122
|
+
properties: {
|
|
123
|
+
name: { type: 'string' },
|
|
124
|
+
since: datetime(),
|
|
125
|
+
},
|
|
126
|
+
required: ['name', 'since'],
|
|
127
|
+
additionalProperties: false,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const zoneCommissions = () => ({
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
name: { type: 'string' },
|
|
134
|
+
total: money(),
|
|
135
|
+
openedShops: { type: 'array', items: shopCommissions() },
|
|
136
|
+
managedShops: { type: 'array', items: shopCommissions() },
|
|
137
|
+
},
|
|
138
|
+
required: ['name', 'total', 'openedShops', 'managedShops'],
|
|
139
|
+
additionalProperties: false,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const getRepresentativeCommissionsRequest = () => ({
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
get: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
representative: objectWithUuid(),
|
|
149
|
+
datetimeRange: datetimeRange(),
|
|
150
|
+
},
|
|
151
|
+
required: ['representative', 'datetimeRange'],
|
|
152
|
+
additionalProperties: false,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
required: ['get'],
|
|
156
|
+
additionalProperties: false,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const getRepresentativeCommissionsResponse = () => ({
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
get: {
|
|
163
|
+
type: 'object',
|
|
164
|
+
properties: {
|
|
165
|
+
total: money(),
|
|
166
|
+
zones: { type: 'array', items: zoneCommissions() },
|
|
167
|
+
},
|
|
168
|
+
required: ['total', 'zones'],
|
|
169
|
+
additionalProperties: false,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
required: ['get'],
|
|
173
|
+
additionalProperties: false,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const deleteRepresentativeRequest = () => deleteRequest(findById());
|
|
177
|
+
|
|
178
|
+
const deleteRepresentativeResponse = () => deleteResponse(representative());
|
|
179
|
+
|
|
180
|
+
module.exports = {
|
|
181
|
+
representative,
|
|
182
|
+
createRepresentativeRequest,
|
|
183
|
+
createRepresentativeResponse,
|
|
184
|
+
findRepresentativesRequest,
|
|
185
|
+
findRepresentativesResponse,
|
|
186
|
+
listRepresentativesNamesResponse,
|
|
187
|
+
getOwnRepresentativesResponse,
|
|
188
|
+
updateRepresentativeRequest,
|
|
189
|
+
updateRepresentativeResponse,
|
|
190
|
+
getRepresentativeCommissionsRequest,
|
|
191
|
+
getRepresentativeCommissionsResponse,
|
|
192
|
+
deleteRepresentativeRequest,
|
|
193
|
+
deleteRepresentativeResponse,
|
|
194
|
+
};
|