@gls_spain/gps-common 34.9.2 → 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 -1257
- 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 -451
- 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 -699
|
@@ -1,451 +1,462 @@
|
|
|
1
|
-
const {
|
|
2
|
-
uuid,
|
|
3
|
-
dateRange,
|
|
4
|
-
datetimeRange,
|
|
5
|
-
address: genericAddress,
|
|
6
|
-
objectWithUuid,
|
|
7
|
-
email,
|
|
8
|
-
phone,
|
|
9
|
-
Point,
|
|
10
|
-
Polygon,
|
|
11
|
-
mergeSchemas,
|
|
12
|
-
specificHttpError,
|
|
13
|
-
} = require('@gls_spain/common-json-schemas');
|
|
14
|
-
const { timezones } = require('@gls_spain/ajv-options');
|
|
15
|
-
|
|
16
|
-
const specificErrorResponse = error => ({
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
error: specificHttpError(error),
|
|
20
|
-
},
|
|
21
|
-
required: ['error'],
|
|
22
|
-
additionalProperties: false,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const date = () => ({ type: 'string', format: 'date' });
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
type: 'string',
|
|
29
|
-
enum: [
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
'
|
|
88
|
-
'
|
|
89
|
-
'
|
|
90
|
-
'
|
|
91
|
-
'
|
|
92
|
-
'
|
|
93
|
-
'
|
|
94
|
-
'
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
'
|
|
109
|
-
'
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
-
'
|
|
115
|
-
'
|
|
116
|
-
'
|
|
117
|
-
'
|
|
118
|
-
'
|
|
119
|
-
'
|
|
120
|
-
'
|
|
121
|
-
'
|
|
122
|
-
'
|
|
123
|
-
'
|
|
124
|
-
'
|
|
125
|
-
'
|
|
126
|
-
'
|
|
127
|
-
'
|
|
128
|
-
'
|
|
129
|
-
'
|
|
130
|
-
'
|
|
131
|
-
'
|
|
132
|
-
'
|
|
133
|
-
'
|
|
134
|
-
'
|
|
135
|
-
'
|
|
136
|
-
'
|
|
137
|
-
'
|
|
138
|
-
'
|
|
139
|
-
'
|
|
140
|
-
'
|
|
141
|
-
'
|
|
142
|
-
'
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'
|
|
148
|
-
'
|
|
149
|
-
'
|
|
150
|
-
'
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
154
|
-
'
|
|
155
|
-
'
|
|
156
|
-
'
|
|
157
|
-
'
|
|
158
|
-
'
|
|
159
|
-
'
|
|
160
|
-
'
|
|
161
|
-
'
|
|
162
|
-
'
|
|
163
|
-
'
|
|
164
|
-
'
|
|
165
|
-
'
|
|
166
|
-
'
|
|
167
|
-
'
|
|
168
|
-
'
|
|
169
|
-
'
|
|
170
|
-
'
|
|
171
|
-
'
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
'
|
|
175
|
-
'
|
|
176
|
-
'
|
|
177
|
-
'
|
|
178
|
-
'
|
|
179
|
-
'
|
|
180
|
-
'
|
|
181
|
-
'
|
|
182
|
-
'
|
|
183
|
-
'
|
|
184
|
-
'
|
|
185
|
-
'
|
|
186
|
-
'
|
|
187
|
-
'
|
|
188
|
-
'
|
|
189
|
-
'
|
|
190
|
-
'
|
|
191
|
-
'
|
|
192
|
-
'
|
|
193
|
-
'
|
|
194
|
-
'
|
|
195
|
-
'
|
|
196
|
-
'
|
|
197
|
-
'
|
|
198
|
-
'
|
|
199
|
-
'
|
|
200
|
-
'
|
|
201
|
-
'
|
|
202
|
-
'
|
|
203
|
-
'
|
|
204
|
-
'
|
|
205
|
-
'
|
|
206
|
-
'
|
|
207
|
-
'
|
|
208
|
-
'
|
|
209
|
-
'
|
|
210
|
-
'
|
|
211
|
-
'
|
|
212
|
-
'
|
|
213
|
-
'
|
|
214
|
-
'
|
|
215
|
-
'
|
|
216
|
-
'
|
|
217
|
-
'
|
|
218
|
-
'
|
|
219
|
-
'
|
|
220
|
-
'
|
|
221
|
-
'
|
|
222
|
-
'
|
|
223
|
-
'
|
|
224
|
-
'
|
|
225
|
-
'
|
|
226
|
-
'
|
|
227
|
-
'
|
|
228
|
-
'
|
|
229
|
-
'
|
|
230
|
-
'
|
|
231
|
-
'
|
|
232
|
-
'
|
|
233
|
-
'
|
|
234
|
-
'
|
|
235
|
-
'
|
|
236
|
-
'
|
|
237
|
-
'
|
|
238
|
-
'
|
|
239
|
-
'
|
|
240
|
-
'
|
|
241
|
-
'
|
|
242
|
-
'
|
|
243
|
-
'
|
|
244
|
-
'
|
|
245
|
-
'
|
|
246
|
-
'
|
|
247
|
-
'
|
|
248
|
-
'
|
|
249
|
-
'
|
|
250
|
-
'
|
|
251
|
-
'
|
|
252
|
-
'
|
|
253
|
-
'
|
|
254
|
-
'
|
|
255
|
-
'
|
|
256
|
-
'
|
|
257
|
-
'
|
|
258
|
-
'
|
|
259
|
-
'
|
|
260
|
-
'
|
|
261
|
-
'
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
'
|
|
265
|
-
'
|
|
266
|
-
'
|
|
267
|
-
'
|
|
268
|
-
'
|
|
269
|
-
'
|
|
270
|
-
'
|
|
271
|
-
'
|
|
272
|
-
'
|
|
273
|
-
'
|
|
274
|
-
'
|
|
275
|
-
'
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'
|
|
279
|
-
'
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
additionalProperties: false,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
},
|
|
321
|
-
required: ['
|
|
322
|
-
additionalProperties: false,
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
title: 'find by
|
|
327
|
-
type: 'object',
|
|
328
|
-
properties: {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
name: { type: 'string'
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
1
|
+
const {
|
|
2
|
+
uuid,
|
|
3
|
+
dateRange,
|
|
4
|
+
datetimeRange,
|
|
5
|
+
address: genericAddress,
|
|
6
|
+
objectWithUuid,
|
|
7
|
+
email,
|
|
8
|
+
phone,
|
|
9
|
+
Point,
|
|
10
|
+
Polygon,
|
|
11
|
+
mergeSchemas,
|
|
12
|
+
specificHttpError,
|
|
13
|
+
} = require('@gls_spain/common-json-schemas');
|
|
14
|
+
const { timezones } = require('@gls_spain/ajv-options');
|
|
15
|
+
|
|
16
|
+
const specificErrorResponse = error => ({
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
error: specificHttpError(error),
|
|
20
|
+
},
|
|
21
|
+
required: ['error'],
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const date = () => ({ type: 'string', format: 'date' });
|
|
26
|
+
|
|
27
|
+
const nifType = () => ({
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: [
|
|
30
|
+
'NIF',
|
|
31
|
+
'CIF',
|
|
32
|
+
'NIE',
|
|
33
|
+
'PASSPORT'
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const country = () => ({
|
|
38
|
+
type: 'string',
|
|
39
|
+
enum: [
|
|
40
|
+
'AD',
|
|
41
|
+
'AE',
|
|
42
|
+
'AF',
|
|
43
|
+
'AG',
|
|
44
|
+
'AI',
|
|
45
|
+
'AL',
|
|
46
|
+
'AM',
|
|
47
|
+
'AO',
|
|
48
|
+
'AQ',
|
|
49
|
+
'AR',
|
|
50
|
+
'AS',
|
|
51
|
+
'AT',
|
|
52
|
+
'AU',
|
|
53
|
+
'AW',
|
|
54
|
+
'AX',
|
|
55
|
+
'AZ',
|
|
56
|
+
'BA',
|
|
57
|
+
'BB',
|
|
58
|
+
'BD',
|
|
59
|
+
'BE',
|
|
60
|
+
'BF',
|
|
61
|
+
'BG',
|
|
62
|
+
'BH',
|
|
63
|
+
'BI',
|
|
64
|
+
'BJ',
|
|
65
|
+
'BL',
|
|
66
|
+
'BM',
|
|
67
|
+
'BN',
|
|
68
|
+
'BO',
|
|
69
|
+
'BQ',
|
|
70
|
+
'BR',
|
|
71
|
+
'BS',
|
|
72
|
+
'BT',
|
|
73
|
+
'BV',
|
|
74
|
+
'BW',
|
|
75
|
+
'BY',
|
|
76
|
+
'BZ',
|
|
77
|
+
'CA',
|
|
78
|
+
'CC',
|
|
79
|
+
'CD',
|
|
80
|
+
'CF',
|
|
81
|
+
'CG',
|
|
82
|
+
'CH',
|
|
83
|
+
'CI',
|
|
84
|
+
'CK',
|
|
85
|
+
'CL',
|
|
86
|
+
'CM',
|
|
87
|
+
'CN',
|
|
88
|
+
'CO',
|
|
89
|
+
'CR',
|
|
90
|
+
'CU',
|
|
91
|
+
'CV',
|
|
92
|
+
'CW',
|
|
93
|
+
'CX',
|
|
94
|
+
'CY',
|
|
95
|
+
'CZ',
|
|
96
|
+
'DE',
|
|
97
|
+
'DJ',
|
|
98
|
+
'DK',
|
|
99
|
+
'DM',
|
|
100
|
+
'DO',
|
|
101
|
+
'DZ',
|
|
102
|
+
'EC',
|
|
103
|
+
'EE',
|
|
104
|
+
'EG',
|
|
105
|
+
'EH',
|
|
106
|
+
'ER',
|
|
107
|
+
'ES',
|
|
108
|
+
'ET',
|
|
109
|
+
'FI',
|
|
110
|
+
'FJ',
|
|
111
|
+
'FK',
|
|
112
|
+
'FM',
|
|
113
|
+
'FO',
|
|
114
|
+
'FR',
|
|
115
|
+
'GA',
|
|
116
|
+
'GB',
|
|
117
|
+
'GD',
|
|
118
|
+
'GE',
|
|
119
|
+
'GF',
|
|
120
|
+
'GG',
|
|
121
|
+
'GH',
|
|
122
|
+
'GI',
|
|
123
|
+
'GL',
|
|
124
|
+
'GM',
|
|
125
|
+
'GN',
|
|
126
|
+
'GP',
|
|
127
|
+
'GQ',
|
|
128
|
+
'GR',
|
|
129
|
+
'GS',
|
|
130
|
+
'GT',
|
|
131
|
+
'GU',
|
|
132
|
+
'GW',
|
|
133
|
+
'GY',
|
|
134
|
+
'HK',
|
|
135
|
+
'HM',
|
|
136
|
+
'HN',
|
|
137
|
+
'HR',
|
|
138
|
+
'HT',
|
|
139
|
+
'HU',
|
|
140
|
+
'ID',
|
|
141
|
+
'IE',
|
|
142
|
+
'IL',
|
|
143
|
+
'IM',
|
|
144
|
+
'IN',
|
|
145
|
+
'IO',
|
|
146
|
+
'IQ',
|
|
147
|
+
'IR',
|
|
148
|
+
'IS',
|
|
149
|
+
'IT',
|
|
150
|
+
'JE',
|
|
151
|
+
'JM',
|
|
152
|
+
'JO',
|
|
153
|
+
'JP',
|
|
154
|
+
'KE',
|
|
155
|
+
'KG',
|
|
156
|
+
'KH',
|
|
157
|
+
'KI',
|
|
158
|
+
'KM',
|
|
159
|
+
'KN',
|
|
160
|
+
'KP',
|
|
161
|
+
'KR',
|
|
162
|
+
'KW',
|
|
163
|
+
'KY',
|
|
164
|
+
'KZ',
|
|
165
|
+
'LA',
|
|
166
|
+
'LB',
|
|
167
|
+
'LC',
|
|
168
|
+
'LI',
|
|
169
|
+
'LK',
|
|
170
|
+
'LR',
|
|
171
|
+
'LS',
|
|
172
|
+
'LT',
|
|
173
|
+
'LU',
|
|
174
|
+
'LV',
|
|
175
|
+
'LY',
|
|
176
|
+
'MA',
|
|
177
|
+
'MC',
|
|
178
|
+
'MD',
|
|
179
|
+
'ME',
|
|
180
|
+
'MF',
|
|
181
|
+
'MG',
|
|
182
|
+
'MH',
|
|
183
|
+
'MK',
|
|
184
|
+
'ML',
|
|
185
|
+
'MM',
|
|
186
|
+
'MN',
|
|
187
|
+
'MO',
|
|
188
|
+
'MP',
|
|
189
|
+
'MQ',
|
|
190
|
+
'MR',
|
|
191
|
+
'MS',
|
|
192
|
+
'MT',
|
|
193
|
+
'MU',
|
|
194
|
+
'MV',
|
|
195
|
+
'MW',
|
|
196
|
+
'MX',
|
|
197
|
+
'MY',
|
|
198
|
+
'MZ',
|
|
199
|
+
'NA',
|
|
200
|
+
'NC',
|
|
201
|
+
'NE',
|
|
202
|
+
'NF',
|
|
203
|
+
'NG',
|
|
204
|
+
'NI',
|
|
205
|
+
'NL',
|
|
206
|
+
'NO',
|
|
207
|
+
'NP',
|
|
208
|
+
'NR',
|
|
209
|
+
'NU',
|
|
210
|
+
'NZ',
|
|
211
|
+
'OM',
|
|
212
|
+
'PA',
|
|
213
|
+
'PE',
|
|
214
|
+
'PF',
|
|
215
|
+
'PG',
|
|
216
|
+
'PH',
|
|
217
|
+
'PK',
|
|
218
|
+
'PL',
|
|
219
|
+
'PM',
|
|
220
|
+
'PN',
|
|
221
|
+
'PR',
|
|
222
|
+
'PS',
|
|
223
|
+
'PT',
|
|
224
|
+
'PW',
|
|
225
|
+
'PY',
|
|
226
|
+
'QA',
|
|
227
|
+
'RE',
|
|
228
|
+
'RO',
|
|
229
|
+
'RS',
|
|
230
|
+
'RU',
|
|
231
|
+
'RW',
|
|
232
|
+
'SA',
|
|
233
|
+
'SB',
|
|
234
|
+
'SC',
|
|
235
|
+
'SD',
|
|
236
|
+
'SE',
|
|
237
|
+
'SG',
|
|
238
|
+
'SH',
|
|
239
|
+
'SI',
|
|
240
|
+
'SJ',
|
|
241
|
+
'SK',
|
|
242
|
+
'SL',
|
|
243
|
+
'SM',
|
|
244
|
+
'SN',
|
|
245
|
+
'SO',
|
|
246
|
+
'SR',
|
|
247
|
+
'SS',
|
|
248
|
+
'ST',
|
|
249
|
+
'SV',
|
|
250
|
+
'SX',
|
|
251
|
+
'SY',
|
|
252
|
+
'SZ',
|
|
253
|
+
'TC',
|
|
254
|
+
'TD',
|
|
255
|
+
'TF',
|
|
256
|
+
'TG',
|
|
257
|
+
'TH',
|
|
258
|
+
'TJ',
|
|
259
|
+
'TK',
|
|
260
|
+
'TL',
|
|
261
|
+
'TM',
|
|
262
|
+
'TN',
|
|
263
|
+
'TO',
|
|
264
|
+
'TR',
|
|
265
|
+
'TT',
|
|
266
|
+
'TV',
|
|
267
|
+
'TW',
|
|
268
|
+
'TZ',
|
|
269
|
+
'UA',
|
|
270
|
+
'UG',
|
|
271
|
+
'UM',
|
|
272
|
+
'US',
|
|
273
|
+
'UY',
|
|
274
|
+
'UZ',
|
|
275
|
+
'VA',
|
|
276
|
+
'VC',
|
|
277
|
+
'VE',
|
|
278
|
+
'VG',
|
|
279
|
+
'VI',
|
|
280
|
+
'VN',
|
|
281
|
+
'VU',
|
|
282
|
+
'WF',
|
|
283
|
+
'WS',
|
|
284
|
+
'XK',
|
|
285
|
+
'YE',
|
|
286
|
+
'YT',
|
|
287
|
+
'ZA',
|
|
288
|
+
'ZM',
|
|
289
|
+
'ZW',
|
|
290
|
+
],
|
|
291
|
+
description: 'ISO 3166-1 alpha 2 country code',
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const address = () =>
|
|
295
|
+
mergeSchemas(genericAddress(), {
|
|
296
|
+
properties: { country: country() },
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const addressWithRequiredLocation = () => mergeSchemas(address(), { required: ['location'] });
|
|
300
|
+
|
|
301
|
+
const findAll = () => ({
|
|
302
|
+
title: 'find all',
|
|
303
|
+
type: 'object',
|
|
304
|
+
additionalProperties: false,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const findById = () => mergeSchemas(objectWithUuid(), { title: 'find by _id' });
|
|
308
|
+
|
|
309
|
+
const findByIds = () => ({
|
|
310
|
+
title: 'find by _ids',
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: { _ids: { type: 'array', items: uuid(), uniqueItems: true } },
|
|
313
|
+
required: ['_ids'],
|
|
314
|
+
additionalProperties: false,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const findByName = () => ({
|
|
318
|
+
title: 'find by name',
|
|
319
|
+
type: 'object',
|
|
320
|
+
properties: { name: { type: 'string', minLength: 3, description: 'search in name' } },
|
|
321
|
+
required: ['name'],
|
|
322
|
+
additionalProperties: false,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const findByAddress = () => ({
|
|
326
|
+
title: 'find by address',
|
|
327
|
+
type: 'object',
|
|
328
|
+
properties: {
|
|
329
|
+
address: { type: 'string', minLength: 3, description: 'search in address street, postal code, locality and administrative area' },
|
|
330
|
+
},
|
|
331
|
+
required: ['address'],
|
|
332
|
+
additionalProperties: false,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const findByCircularArea = () => ({
|
|
336
|
+
title: 'find by circular area',
|
|
337
|
+
type: 'object',
|
|
338
|
+
properties: {
|
|
339
|
+
point: mergeSchemas(Point(), { description: 'center of the circular area to search' }),
|
|
340
|
+
maxDistance: { type: 'number', exclusiveMinimum: 0, description: 'radius of the circular area in meters' },
|
|
341
|
+
},
|
|
342
|
+
required: ['point', 'maxDistance'],
|
|
343
|
+
additionalProperties: false,
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
const findByPolygonalArea = () => ({
|
|
347
|
+
title: 'find by polygonal area',
|
|
348
|
+
type: 'object',
|
|
349
|
+
properties: { polygon: mergeSchemas(Polygon(), { description: 'search inside this polygonal area' }) },
|
|
350
|
+
required: ['polygon'],
|
|
351
|
+
additionalProperties: false,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
const findByDate = () => ({
|
|
355
|
+
title: 'find by date',
|
|
356
|
+
type: 'object',
|
|
357
|
+
properties: { date: date() },
|
|
358
|
+
required: ['date'],
|
|
359
|
+
additionalProperties: false,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const findByDateRange = () => ({
|
|
363
|
+
title: 'find by date range',
|
|
364
|
+
type: 'object',
|
|
365
|
+
properties: { dateRange: dateRange() },
|
|
366
|
+
required: ['dateRange'],
|
|
367
|
+
additionalProperties: false,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
const findByOptionalDateRange = () => ({
|
|
371
|
+
type: 'object',
|
|
372
|
+
properties: { dateRange: dateRange() },
|
|
373
|
+
additionalProperties: false,
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const findByOptionalCreatedAtRange = () => ({
|
|
377
|
+
type: 'object',
|
|
378
|
+
properties: { createdAtRange: datetimeRange() },
|
|
379
|
+
additionalProperties: false,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const timezone = () => ({ type: 'string', format: 'timezone' });
|
|
383
|
+
|
|
384
|
+
const timezoneNames = () => ({ type: 'string', enum: timezones });
|
|
385
|
+
|
|
386
|
+
const objectWithUuidAndName = () => ({
|
|
387
|
+
title: '_id and name',
|
|
388
|
+
type: 'object',
|
|
389
|
+
properties: {
|
|
390
|
+
_id: uuid(),
|
|
391
|
+
name: { type: 'string' },
|
|
392
|
+
},
|
|
393
|
+
required: ['_id', 'name'],
|
|
394
|
+
additionalProperties: false,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
const contact = () => ({
|
|
398
|
+
title: 'contact',
|
|
399
|
+
type: 'object',
|
|
400
|
+
properties: {
|
|
401
|
+
name: { type: 'string', trim: true },
|
|
402
|
+
email: email(),
|
|
403
|
+
phone: phone(),
|
|
404
|
+
},
|
|
405
|
+
required: ['name', 'email', 'phone'],
|
|
406
|
+
additionalProperties: false,
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
const fiscal = () => ({
|
|
410
|
+
title: 'fiscal data',
|
|
411
|
+
type: 'object',
|
|
412
|
+
properties: {
|
|
413
|
+
iban: { type: 'string', trim: true },
|
|
414
|
+
businessName: { type: 'string', trim: true },
|
|
415
|
+
nif: { type: 'string', trim: true },
|
|
416
|
+
contacts: {
|
|
417
|
+
type: 'array',
|
|
418
|
+
items: contact(),
|
|
419
|
+
},
|
|
420
|
+
address: address(),
|
|
421
|
+
paymentMethod: { type: 'string', enum: ['transfer', 'confirming'] },
|
|
422
|
+
dueDays: { type: 'integer', minimum: 0 },
|
|
423
|
+
activity: { type: 'string', trim: true, description: 'IAE' },
|
|
424
|
+
retention: { type: 'integer', description: 'invoice retention percentage' },
|
|
425
|
+
},
|
|
426
|
+
required: ['iban', 'businessName', 'nif', 'contacts', 'address', 'paymentMethod', 'dueDays', 'activity', 'retention'],
|
|
427
|
+
additionalProperties: false,
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
const findByFiscal = () => ({
|
|
431
|
+
title: 'find by fiscal',
|
|
432
|
+
type: 'object',
|
|
433
|
+
properties: { fiscal: { type: 'string', minLength: 3, description: 'search in business name and nif' } },
|
|
434
|
+
required: ['fiscal'],
|
|
435
|
+
additionalProperties: false,
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
module.exports = {
|
|
439
|
+
specificErrorResponse,
|
|
440
|
+
date,
|
|
441
|
+
nifType,
|
|
442
|
+
country,
|
|
443
|
+
address,
|
|
444
|
+
addressWithRequiredLocation,
|
|
445
|
+
findAll,
|
|
446
|
+
findById,
|
|
447
|
+
findByIds,
|
|
448
|
+
findByName,
|
|
449
|
+
findByAddress,
|
|
450
|
+
findByCircularArea,
|
|
451
|
+
findByPolygonalArea,
|
|
452
|
+
findByDate,
|
|
453
|
+
findByDateRange,
|
|
454
|
+
findByOptionalDateRange,
|
|
455
|
+
findByOptionalCreatedAtRange,
|
|
456
|
+
timezone,
|
|
457
|
+
timezoneNames,
|
|
458
|
+
objectWithUuidAndName,
|
|
459
|
+
contact,
|
|
460
|
+
fiscal,
|
|
461
|
+
findByFiscal,
|
|
462
|
+
};
|