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