@gls_spain/gps-common 27.0.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.
- package/.eslintrc.json +11 -0
- package/.idea/codeStyles/Project.xml +37 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/gps-common.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/watcherTasks.xml +45 -0
- package/.prettierignore +5 -0
- package/.prettierrc.json +13 -0
- package/.releaserc +17 -0
- package/CHANGELOG.md +848 -0
- package/README.md +122 -0
- package/errors/DatabaseNotEmptyError.js +9 -0
- package/errors/DefaultsDoNotExistError.js +9 -0
- package/errors/ExpeditionAlreadyExistsError.js +9 -0
- package/errors/ExpeditionCannotBeDeletedError.js +9 -0
- package/errors/ExpeditionCannotBeUpdatedError.js +9 -0
- package/errors/ExpeditionDoesNotExistError.js +9 -0
- package/errors/JobDoesNotExistError.js +9 -0
- package/errors/NetworkAlreadyExistsError.js +9 -0
- package/errors/NetworkCannotBeDeletedError.js +9 -0
- package/errors/NetworkDoesNotExistError.js +9 -0
- package/errors/RepresentativeAlreadyExistsError.js +9 -0
- package/errors/RepresentativeCannotBeDeletedError.js +9 -0
- package/errors/RepresentativeDoesNotExistError.js +9 -0
- package/errors/ShopAlreadyExistsError.js +9 -0
- package/errors/ShopCannotBeDeletedError.js +9 -0
- package/errors/ShopDoesNotExistError.js +9 -0
- package/errors/ShopNotEnabledError.js +9 -0
- package/errors/UserAlreadyExistsError.js +9 -0
- package/errors/UserCannotBeDeletedError.js +9 -0
- package/errors/UserCannotBeUpdatedError.js +9 -0
- package/errors/UserDoesNotExistError.js +9 -0
- package/errors/WrongNetworkError.js +9 -0
- package/errors/WrongPasswordError.js +9 -0
- package/errors/WrongShopError.js +9 -0
- package/errors/ZoneAlreadyExistsError.js +9 -0
- package/errors/ZoneCannotBeDeletedError.js +9 -0
- package/errors/ZoneDoesNotExistError.js +9 -0
- package/errors/index.js +88 -0
- package/index.js +9 -0
- package/index.test.js +35 -0
- package/jest.config.js +5 -0
- package/open-api-spec/index.js +2920 -0
- package/package.json +68 -0
- package/schemas/definitions/become.js +5 -0
- package/schemas/definitions/common.js +172 -0
- package/schemas/definitions/defaults.js +84 -0
- package/schemas/definitions/expeditions.js +637 -0
- package/schemas/definitions/init.js +37 -0
- package/schemas/definitions/integration-events.js +127 -0
- package/schemas/definitions/jobs.js +124 -0
- package/schemas/definitions/login.js +38 -0
- package/schemas/definitions/logout.js +8 -0
- package/schemas/definitions/networks.js +107 -0
- package/schemas/definitions/pods.js +37 -0
- package/schemas/definitions/representatives.js +178 -0
- package/schemas/definitions/shops.js +352 -0
- package/schemas/definitions/users.js +373 -0
- package/schemas/definitions/zones.js +92 -0
- package/schemas/index.js +335 -0
- package/scripts/build-documentation.js +40 -0
- package/scripts/build-json-schemas.js +35 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
const {
|
|
2
|
+
datetime,
|
|
3
|
+
email,
|
|
4
|
+
phone,
|
|
5
|
+
password,
|
|
6
|
+
uuid,
|
|
7
|
+
createRequest,
|
|
8
|
+
createResponse,
|
|
9
|
+
findRequest,
|
|
10
|
+
findResponse,
|
|
11
|
+
updateRequest,
|
|
12
|
+
updateSelfRequest,
|
|
13
|
+
updateResponse,
|
|
14
|
+
deleteRequest,
|
|
15
|
+
deleteResponse,
|
|
16
|
+
mergeSchemas,
|
|
17
|
+
pickProperties,
|
|
18
|
+
} = require('@gls_spain/common-json-schemas');
|
|
19
|
+
const { address, findAll, findById, findByName, tags } = require('./common');
|
|
20
|
+
const { network, objectWithNetworkId } = require('./networks');
|
|
21
|
+
const { shop, objectWithShopId } = require('./shops');
|
|
22
|
+
|
|
23
|
+
const baseUser = () => ({
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
_id: uuid(),
|
|
27
|
+
createdAt: datetime(),
|
|
28
|
+
updatedAt: datetime(),
|
|
29
|
+
deletable: { type: 'boolean' },
|
|
30
|
+
username: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
pattern: '^[a-zA-Z0-9]+$',
|
|
33
|
+
minLength: 3,
|
|
34
|
+
description: 'a unique username that cannot be changed later',
|
|
35
|
+
},
|
|
36
|
+
loginEnabled: { type: 'boolean' },
|
|
37
|
+
integrations: { type: 'array', items: { type: 'string', enum: ['glsApi', 'canReceiveAllFromDriver'] }, uniqueItems: true },
|
|
38
|
+
role: { type: 'string' },
|
|
39
|
+
name: { type: 'string' },
|
|
40
|
+
emails: { type: 'array', items: email(), uniqueItems: true },
|
|
41
|
+
phones: { type: 'array', items: phone(), uniqueItems: true },
|
|
42
|
+
nif: { type: 'string' },
|
|
43
|
+
address: address(),
|
|
44
|
+
},
|
|
45
|
+
required: ['_id', 'createdAt', 'updatedAt', 'username', 'deletable', 'loginEnabled', 'integrations', 'role', 'name', 'emails', 'phones'],
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const superAdmin = () => mergeSchemas(baseUser(), { title: 'superAdmin', properties: { role: { enum: ['superAdmin'] } } });
|
|
50
|
+
|
|
51
|
+
const networkAdmin = () =>
|
|
52
|
+
mergeSchemas(baseUser(), {
|
|
53
|
+
title: 'networkAdmin',
|
|
54
|
+
properties: {
|
|
55
|
+
role: { enum: ['networkAdmin'] },
|
|
56
|
+
network: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: { ...pickProperties(network(), ['_id', 'name', 'integrations']) },
|
|
59
|
+
required: ['_id', 'name', 'integrations'],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
required: ['network'],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const shopUser = () =>
|
|
67
|
+
mergeSchemas(baseUser(), {
|
|
68
|
+
title: 'shopUser',
|
|
69
|
+
properties: {
|
|
70
|
+
role: { enum: ['shopUser'] },
|
|
71
|
+
network: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: { ...pickProperties(network(), ['_id', 'name', 'integrations']) },
|
|
74
|
+
required: ['_id', 'name', 'integrations'],
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
},
|
|
77
|
+
shop: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: { ...pickProperties(shop(), ['_id', 'name']) },
|
|
80
|
+
required: ['_id', 'name'],
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['network', 'shop'],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const createSuperAdminRequest = () =>
|
|
88
|
+
createRequest({
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
...pickProperties(superAdmin(), [
|
|
92
|
+
'_id',
|
|
93
|
+
'createdAt',
|
|
94
|
+
'username',
|
|
95
|
+
'loginEnabled',
|
|
96
|
+
'integrations',
|
|
97
|
+
'name',
|
|
98
|
+
'emails',
|
|
99
|
+
'phones',
|
|
100
|
+
'nif',
|
|
101
|
+
'address',
|
|
102
|
+
]),
|
|
103
|
+
tags: tags(),
|
|
104
|
+
password: password(),
|
|
105
|
+
},
|
|
106
|
+
required: ['username', 'loginEnabled', 'name', 'password'],
|
|
107
|
+
additionalProperties: false,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const createSuperAdminResponse = () => createResponse(superAdmin());
|
|
111
|
+
|
|
112
|
+
const findSuperAdminsRequest = () => findRequest({ oneOf: [findAll(), findById(), findByName()] });
|
|
113
|
+
|
|
114
|
+
const findSuperAdminsResponse = () => findResponse(superAdmin());
|
|
115
|
+
|
|
116
|
+
const updateSuperAdminRequest = () =>
|
|
117
|
+
updateRequest(
|
|
118
|
+
findById(),
|
|
119
|
+
{
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
...pickProperties(superAdmin(), ['loginEnabled', 'name', 'emails', 'phones'], ['nif', 'address']),
|
|
123
|
+
password: password(),
|
|
124
|
+
},
|
|
125
|
+
minProperties: 1,
|
|
126
|
+
additionalProperties: false,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: { ...pickProperties(superAdmin(), ['emails', 'phones']) },
|
|
131
|
+
minProperties: 1,
|
|
132
|
+
additionalProperties: false,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const updateSuperAdminResponse = () => updateResponse(superAdmin());
|
|
137
|
+
|
|
138
|
+
const deleteSuperAdminRequest = () => deleteRequest(findById());
|
|
139
|
+
|
|
140
|
+
const deleteSuperAdminResponse = () => deleteResponse(superAdmin());
|
|
141
|
+
|
|
142
|
+
const createNetworkAdminRequest = () =>
|
|
143
|
+
createRequest(
|
|
144
|
+
mergeSchemas(
|
|
145
|
+
{
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
...pickProperties(networkAdmin(), [
|
|
149
|
+
'_id',
|
|
150
|
+
'createdAt',
|
|
151
|
+
'username',
|
|
152
|
+
'loginEnabled',
|
|
153
|
+
'integrations',
|
|
154
|
+
'name',
|
|
155
|
+
'emails',
|
|
156
|
+
'phones',
|
|
157
|
+
'nif',
|
|
158
|
+
'address',
|
|
159
|
+
]),
|
|
160
|
+
tags: tags(),
|
|
161
|
+
password: password(),
|
|
162
|
+
},
|
|
163
|
+
required: ['username', 'loginEnabled', 'name', 'password'],
|
|
164
|
+
additionalProperties: false,
|
|
165
|
+
},
|
|
166
|
+
objectWithNetworkId(),
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const createNetworkAdminResponse = () => createResponse(networkAdmin());
|
|
171
|
+
|
|
172
|
+
const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find by network' });
|
|
173
|
+
|
|
174
|
+
const findByNetworkAndName = () => mergeSchemas(findByNetwork(), findByName(), { title: 'find by network and name' });
|
|
175
|
+
|
|
176
|
+
const findNetworkAdminsRequest = () =>
|
|
177
|
+
findRequest({
|
|
178
|
+
oneOf: [findAll(), findById(), findByName(), findByNetwork(), findByNetworkAndName()],
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const findNetworkAdminsResponse = () => findResponse(networkAdmin());
|
|
182
|
+
|
|
183
|
+
const updateNetworkAdminRequest = () =>
|
|
184
|
+
updateRequest(
|
|
185
|
+
findById(),
|
|
186
|
+
{
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
...pickProperties(networkAdmin(), ['loginEnabled', 'name', 'emails', 'phones'], ['nif', 'address']),
|
|
190
|
+
password: password(),
|
|
191
|
+
},
|
|
192
|
+
minProperties: 1,
|
|
193
|
+
additionalProperties: false,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: 'object',
|
|
197
|
+
properties: { ...pickProperties(networkAdmin(), ['emails', 'phones']) },
|
|
198
|
+
minProperties: 1,
|
|
199
|
+
additionalProperties: false,
|
|
200
|
+
},
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const updateSelfNetworkAdminRequest = () =>
|
|
204
|
+
updateSelfRequest(
|
|
205
|
+
{
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
...pickProperties(networkAdmin(), ['name', 'emails', 'phones'], ['nif', 'address']),
|
|
209
|
+
password: {
|
|
210
|
+
type: 'object',
|
|
211
|
+
properties: { old: password(), new: password() },
|
|
212
|
+
required: ['old', 'new'],
|
|
213
|
+
additionalProperties: false,
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
minProperties: 1,
|
|
217
|
+
additionalProperties: false,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: 'object',
|
|
221
|
+
properties: { ...pickProperties(networkAdmin(), ['emails', 'phones']) },
|
|
222
|
+
minProperties: 1,
|
|
223
|
+
additionalProperties: false,
|
|
224
|
+
},
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
const updateNetworkAdminResponse = () => updateResponse(networkAdmin());
|
|
228
|
+
|
|
229
|
+
const deleteNetworkAdminRequest = () => deleteRequest(findById());
|
|
230
|
+
|
|
231
|
+
const deleteNetworkAdminResponse = () => deleteResponse(networkAdmin());
|
|
232
|
+
|
|
233
|
+
const createShopUserRequest = () =>
|
|
234
|
+
createRequest(
|
|
235
|
+
mergeSchemas(
|
|
236
|
+
{
|
|
237
|
+
type: 'object',
|
|
238
|
+
properties: {
|
|
239
|
+
...pickProperties(shopUser(), [
|
|
240
|
+
'_id',
|
|
241
|
+
'createdAt',
|
|
242
|
+
'username',
|
|
243
|
+
'loginEnabled',
|
|
244
|
+
'integrations',
|
|
245
|
+
'name',
|
|
246
|
+
'emails',
|
|
247
|
+
'phones',
|
|
248
|
+
'nif',
|
|
249
|
+
'address',
|
|
250
|
+
]),
|
|
251
|
+
tags: tags(),
|
|
252
|
+
password: password(),
|
|
253
|
+
},
|
|
254
|
+
required: ['username', 'loginEnabled', 'name', 'password'],
|
|
255
|
+
additionalProperties: false,
|
|
256
|
+
},
|
|
257
|
+
objectWithNetworkId(),
|
|
258
|
+
objectWithShopId(),
|
|
259
|
+
),
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const createShopUserResponse = () => createResponse(shopUser());
|
|
263
|
+
|
|
264
|
+
const findByNetworkAndShop = () => mergeSchemas(objectWithNetworkId(), objectWithShopId(), { title: 'find by network and shop' });
|
|
265
|
+
|
|
266
|
+
const findByNetworkAndShopAndName = () =>
|
|
267
|
+
mergeSchemas(findByNetworkAndShop(), findByName(), { title: 'find by network and shop and name' });
|
|
268
|
+
|
|
269
|
+
const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
|
|
270
|
+
|
|
271
|
+
const findByShopAndName = () => mergeSchemas(findByShop(), findByName(), { title: 'find by shop and name' });
|
|
272
|
+
|
|
273
|
+
const findShopUsersSuperAdminRequest = () =>
|
|
274
|
+
findRequest({
|
|
275
|
+
oneOf: [
|
|
276
|
+
findAll(),
|
|
277
|
+
findById(),
|
|
278
|
+
findByName(),
|
|
279
|
+
findByNetwork(),
|
|
280
|
+
findByNetworkAndName(),
|
|
281
|
+
findByNetworkAndShop(),
|
|
282
|
+
findByNetworkAndShopAndName(),
|
|
283
|
+
],
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const findShopUsersNetworkAdminRequest = () =>
|
|
287
|
+
findRequest({ oneOf: [findAll(), findById(), findByName(), findByShop(), findByShopAndName()] });
|
|
288
|
+
|
|
289
|
+
const findShopUsersResponse = () => findResponse(shopUser());
|
|
290
|
+
|
|
291
|
+
const updateShopUserRequest = () =>
|
|
292
|
+
updateRequest(
|
|
293
|
+
findById(),
|
|
294
|
+
{
|
|
295
|
+
type: 'object',
|
|
296
|
+
properties: {
|
|
297
|
+
...pickProperties(shopUser(), ['loginEnabled', 'name', 'emails', 'phones'], ['nif', 'address']),
|
|
298
|
+
password: password(),
|
|
299
|
+
},
|
|
300
|
+
minProperties: 1,
|
|
301
|
+
additionalProperties: false,
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
type: 'object',
|
|
305
|
+
properties: { ...pickProperties(shopUser(), ['emails', 'phones']) },
|
|
306
|
+
minProperties: 1,
|
|
307
|
+
additionalProperties: false,
|
|
308
|
+
},
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const updateSelfShopUserRequest = () =>
|
|
312
|
+
updateSelfRequest(
|
|
313
|
+
{
|
|
314
|
+
type: 'object',
|
|
315
|
+
properties: {
|
|
316
|
+
...pickProperties(shopUser(), ['name', 'emails', 'phones'], ['nif', 'address']),
|
|
317
|
+
password: {
|
|
318
|
+
type: 'object',
|
|
319
|
+
properties: { old: password(), new: password() },
|
|
320
|
+
required: ['old', 'new'],
|
|
321
|
+
additionalProperties: false,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
minProperties: 1,
|
|
325
|
+
additionalProperties: false,
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
type: 'object',
|
|
329
|
+
properties: { ...pickProperties(shopUser(), ['emails', 'phones']) },
|
|
330
|
+
minProperties: 1,
|
|
331
|
+
additionalProperties: false,
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const updateShopUserResponse = () => updateResponse(shopUser());
|
|
336
|
+
|
|
337
|
+
const deleteShopUserRequest = () => deleteRequest(findById());
|
|
338
|
+
|
|
339
|
+
const deleteShopUserResponse = () => deleteResponse(shopUser());
|
|
340
|
+
|
|
341
|
+
module.exports = {
|
|
342
|
+
baseUser,
|
|
343
|
+
superAdmin,
|
|
344
|
+
createSuperAdminRequest,
|
|
345
|
+
createSuperAdminResponse,
|
|
346
|
+
findSuperAdminsRequest,
|
|
347
|
+
findSuperAdminsResponse,
|
|
348
|
+
updateSuperAdminRequest,
|
|
349
|
+
updateSuperAdminResponse,
|
|
350
|
+
deleteSuperAdminRequest,
|
|
351
|
+
deleteSuperAdminResponse,
|
|
352
|
+
networkAdmin,
|
|
353
|
+
createNetworkAdminRequest,
|
|
354
|
+
createNetworkAdminResponse,
|
|
355
|
+
findNetworkAdminsRequest,
|
|
356
|
+
findNetworkAdminsResponse,
|
|
357
|
+
updateNetworkAdminRequest,
|
|
358
|
+
updateSelfNetworkAdminRequest,
|
|
359
|
+
updateNetworkAdminResponse,
|
|
360
|
+
deleteNetworkAdminRequest,
|
|
361
|
+
deleteNetworkAdminResponse,
|
|
362
|
+
shopUser,
|
|
363
|
+
createShopUserRequest,
|
|
364
|
+
createShopUserResponse,
|
|
365
|
+
findShopUsersSuperAdminRequest,
|
|
366
|
+
findShopUsersNetworkAdminRequest,
|
|
367
|
+
findShopUsersResponse,
|
|
368
|
+
updateShopUserRequest,
|
|
369
|
+
updateSelfShopUserRequest,
|
|
370
|
+
updateShopUserResponse,
|
|
371
|
+
deleteShopUserRequest,
|
|
372
|
+
deleteShopUserResponse,
|
|
373
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const {
|
|
2
|
+
uuid,
|
|
3
|
+
datetime,
|
|
4
|
+
money,
|
|
5
|
+
createRequest,
|
|
6
|
+
createResponse,
|
|
7
|
+
findRequest,
|
|
8
|
+
findResponse,
|
|
9
|
+
updateRequest,
|
|
10
|
+
updateResponse,
|
|
11
|
+
deleteRequest,
|
|
12
|
+
deleteResponse,
|
|
13
|
+
pickProperties,
|
|
14
|
+
} = require('@gls_spain/common-json-schemas');
|
|
15
|
+
const { findAll, findById, objectWithUuidAndName } = require('./common');
|
|
16
|
+
|
|
17
|
+
const zone = () => ({
|
|
18
|
+
title: 'zone',
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
_id: uuid(),
|
|
22
|
+
createdAt: datetime(),
|
|
23
|
+
updatedAt: datetime(),
|
|
24
|
+
deletable: { type: 'boolean' },
|
|
25
|
+
name: { type: 'string' },
|
|
26
|
+
commissions: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
eachShopOpening: money(),
|
|
30
|
+
minimumOpeningsPerMonth: { type: 'integer', minimum: 0 },
|
|
31
|
+
eachShopManagement: money(),
|
|
32
|
+
minimumManagementMonths: { type: 'integer', minimum: 0 },
|
|
33
|
+
},
|
|
34
|
+
required: ['eachShopOpening', 'minimumOpeningsPerMonth', 'eachShopManagement', 'minimumManagementMonths'],
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'name', 'commissions'],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const createZoneRequest = () =>
|
|
43
|
+
createRequest({
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
...pickProperties(zone(), ['_id', 'createdAt', 'name', 'commissions']),
|
|
47
|
+
},
|
|
48
|
+
required: ['name', 'commissions'],
|
|
49
|
+
additionalProperties: false,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const createZoneResponse = () => createResponse(zone());
|
|
53
|
+
|
|
54
|
+
const listZonesNamesResponse = () => ({
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: { found: { type: 'array', items: objectWithUuidAndName() } },
|
|
57
|
+
required: ['found'],
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const findZonesRequest = () => findRequest({ oneOf: [findAll(), findById()] });
|
|
62
|
+
|
|
63
|
+
const findZonesResponse = () => findResponse(zone());
|
|
64
|
+
|
|
65
|
+
const updateZoneRequest = () =>
|
|
66
|
+
updateRequest(findById(), {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
...pickProperties(zone(), ['name', 'commissions']),
|
|
70
|
+
},
|
|
71
|
+
minProperties: 1,
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const updateZoneResponse = () => updateResponse(zone());
|
|
76
|
+
|
|
77
|
+
const deleteZoneRequest = () => deleteRequest(findById());
|
|
78
|
+
|
|
79
|
+
const deleteZoneResponse = () => deleteResponse(zone());
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
zone,
|
|
83
|
+
createZoneRequest,
|
|
84
|
+
createZoneResponse,
|
|
85
|
+
listZonesNamesResponse,
|
|
86
|
+
findZonesRequest,
|
|
87
|
+
findZonesResponse,
|
|
88
|
+
updateZoneRequest,
|
|
89
|
+
updateZoneResponse,
|
|
90
|
+
deleteZoneRequest,
|
|
91
|
+
deleteZoneResponse,
|
|
92
|
+
};
|