@tillhub/schemas 6.118.0 → 6.121.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/common/address.js +67 -82
  3. package/lib/common/base.js +3 -0
  4. package/lib/common/images.js +63 -0
  5. package/lib/common/query.js +64 -0
  6. package/lib/common/response.js +11 -10
  7. package/lib/v0/audits/index.js +3 -0
  8. package/lib/v0/audits/logs/base.js +81 -0
  9. package/lib/v0/audits/logs/index.js +3 -0
  10. package/lib/v0/audits/logs/read.js +30 -0
  11. package/lib/v0/branches/base.js +55 -63
  12. package/lib/v0/branches/create.js +18 -0
  13. package/lib/v0/branches/index.js +1 -0
  14. package/lib/v0/branches/read.js +119 -0
  15. package/lib/v0/branches/update.js +18 -0
  16. package/lib/v0/category_trees/definitions.js +1 -1
  17. package/lib/v0/customers/base.js +352 -576
  18. package/lib/v0/customers/baseExt.js +35 -0
  19. package/lib/v0/customers/create.js +41 -0
  20. package/lib/v0/customers/ext.js +113 -7
  21. package/lib/v0/customers/index.js +18 -50
  22. package/lib/v0/customers/properties/anaylytics.js +7 -7
  23. package/lib/v0/customers/read.js +42 -0
  24. package/lib/v0/customers/update.js +30 -0
  25. package/lib/v0/deliveries/base.js +3 -3
  26. package/lib/v0/index.js +1 -0
  27. package/lib/v0/orders/create.request.js +3 -3
  28. package/lib/v0/pdfs/templates.deliveries.create.request.js +3 -7
  29. package/lib/v0/pdfs/templates.delivery_notes.create.request.js +3 -7
  30. package/lib/v0/pdfs/templates.full_receipts.create.request.js +3 -7
  31. package/lib/v0/pdfs/templates.invoices.create.request.js +3 -7
  32. package/lib/v0/pdfs/templates.transaction_receipts.create.request.js +3 -7
  33. package/lib/v1/branches/index.js +1 -0
  34. package/lib/v1/branches/read.js +16 -0
  35. package/lib/v1/index.js +6 -5
  36. package/package.json +1 -1
  37. package/test/audits/logs/logs.spec.js +11 -0
  38. package/test/branches/branches.v0.spec.js +50 -11
  39. package/test/branches/branches.v1.spec.js +19 -0
  40. package/test/customers/customers.v0.spec.js +93 -5
  41. package/lib/v0/customers/create.request.js +0 -24
  42. package/lib/v0/customers/update.request.js +0 -14
@@ -1,648 +1,424 @@
1
+ const { anyOf, oneOf } = require('../../helpers/payload-or-null')
2
+ const { getAddress } = require('../../common/address')
3
+ const { getImages } = require('../../common/images')
4
+
1
5
  module.exports = {
6
+ active: {
7
+ description: 'Customer active',
8
+ example: 'true',
9
+ type: 'boolean'
10
+ },
11
+ deleted: {
12
+ description: 'Customer deleted',
13
+ type: 'boolean'
14
+ },
2
15
  firstname: {
3
- anyOf: [
4
- {
5
- type: 'string',
6
- maxLength: 128
7
- },
8
- {
9
- type: 'null'
10
- }
11
- ]
16
+ description: 'First name',
17
+ example: 'Boba',
18
+ ...anyOf({
19
+ type: 'string',
20
+ maxLength: 128
21
+ })
12
22
  },
13
23
  lastname: {
14
- anyOf: [
15
- {
16
- type: 'string',
17
- maxLength: 128
18
- },
19
- {
20
- type: 'null'
21
- }
22
- ]
24
+ example: 'Fett',
25
+ description: 'Last name',
26
+ ...anyOf({
27
+ type: 'string',
28
+ maxLength: 128
29
+ })
23
30
  },
24
31
  middlename: {
25
- anyOf: [
26
- {
27
- type: 'string',
28
- maxLength: 128
29
- },
30
- {
31
- type: 'null'
32
- }
33
- ]
32
+ description: 'Middle name',
33
+ example: 'Alpha',
34
+ ...anyOf({
35
+ type: 'string',
36
+ maxLength: 128
37
+ })
34
38
  },
35
39
  displayname: {
36
- anyOf: [
37
- {
38
- type: 'string',
39
- maxLength: 32,
40
- minLength: 3
41
- },
42
- {
43
- type: 'null'
44
- }
45
- ]
40
+ description: 'Display name',
41
+ example: 'Boba F.',
42
+ ...anyOf({
43
+ type: 'string',
44
+ maxLength: 32,
45
+ minLength: 3
46
+ })
46
47
  },
47
48
  phonenumbers: {
48
- anyOf: [
49
- {
50
- type: 'object',
51
- additionalProperties: false,
52
- properties: {
53
- main: {
54
- type: 'string'
55
- },
56
- home: {
57
- type: 'string'
58
- },
59
- mobile: {
60
- type: 'string'
61
- },
62
- work: {
63
- type: 'string'
64
- }
49
+ description: 'Phone numbers',
50
+ example: {
51
+ main: '+49-555-123-4567'
52
+ },
53
+ ...anyOf({
54
+ type: 'object',
55
+ additionalProperties: false,
56
+ properties: {
57
+ main: {
58
+ type: 'string'
65
59
  },
66
- anyOf: [
67
- {
68
- required: [
69
- 'main'
70
- ]
71
- },
72
- {
73
- required: [
74
- 'home'
75
- ]
76
- },
77
- {
78
- required: [
79
- 'mobile'
80
- ]
81
- },
82
- {
83
- required: [
84
- 'work'
85
- ]
86
- }
87
- ]
60
+ home: {
61
+ type: 'string'
62
+ },
63
+ mobile: {
64
+ type: 'string'
65
+ },
66
+ work: {
67
+ type: 'string'
68
+ }
88
69
  },
89
- {
90
- type: 'null'
91
- }
92
- ]
70
+ anyOf: [
71
+ {
72
+ required: [
73
+ 'main'
74
+ ]
75
+ },
76
+ {
77
+ required: [
78
+ 'home'
79
+ ]
80
+ },
81
+ {
82
+ required: [
83
+ 'mobile'
84
+ ]
85
+ },
86
+ {
87
+ required: [
88
+ 'work'
89
+ ]
90
+ }
91
+ ]
92
+ })
93
93
  },
94
94
  email: {
95
- 'default': null,
96
- anyOf: [
97
- {
98
- type: 'string',
99
- maxLength: 128,
100
- format: 'email'
101
- },
102
- {
103
- type: 'null'
104
- }
105
- ]
95
+ description: 'Email address',
96
+ example: 'boba@kamino.empire',
97
+ ...anyOf({
98
+ type: 'string',
99
+ maxLength: 128,
100
+ format: 'email'
101
+ }),
102
+ 'default': null
106
103
  },
107
104
  customer_number: {
108
- anyOf: [
109
- {
110
- type: 'string',
111
- maxLength: 128,
112
- minLength: 1
113
- },
114
- {
115
- type: 'null'
116
- }
117
- ]
105
+ description: 'Unique customer number',
106
+ example: 'fett-002',
107
+ ...anyOf({
108
+ type: 'string',
109
+ maxLength: 128,
110
+ minLength: 1
111
+ })
118
112
  },
119
113
  company: {
120
- anyOf: [
121
- {
122
- type: 'object',
123
- additionalProperties: false,
124
- properties: {
125
- name: {
126
- anyOf: [
127
- {
128
- type: 'string',
129
- maxLength: 64
130
- },
131
- {
132
- type: 'null'
133
- }
134
- ]
135
- }
114
+ description: 'Company name',
115
+ example: {
116
+ name: 'Bounty Hunter\'s Guild'
117
+ },
118
+ ...anyOf({
119
+ type: 'object',
120
+ additionalProperties: false,
121
+ properties: {
122
+ name: {
123
+ anyOf: [
124
+ {
125
+ type: 'string',
126
+ maxLength: 64
127
+ },
128
+ {
129
+ type: 'null'
130
+ }
131
+ ]
136
132
  }
137
- },
138
- {
139
- type: 'null'
140
133
  }
141
- ]
134
+ })
142
135
  },
143
136
  description: {
144
- anyOf: [
145
- {
146
- type: 'string'
147
- },
148
- {
149
- type: 'null'
150
- }
151
- ]
137
+ description: 'Description',
138
+ example: 'Bounty hunter',
139
+ ...anyOf({
140
+ type: 'string'
141
+ })
152
142
  },
153
143
  is_b2b: {
154
- anyOf: [
155
- {
156
- type: 'boolean'
157
- },
158
- {
159
- type: 'null'
160
- }
161
- ]
144
+ description: 'Is B2B customer',
145
+ ...anyOf({
146
+ type: 'boolean'
147
+ })
162
148
  },
163
149
  date_of_birth: {
164
- anyOf: [
165
- {
166
- type: 'string',
167
- format: 'date-time'
168
- },
169
- {
170
- type: 'null'
171
- }
172
- ]
173
- },
174
- update_at: {
175
- anyOf: [
176
- {
177
- type: 'string',
178
- format: 'date-time'
179
- },
180
- {
181
- type: 'null'
182
- }
183
- ]
184
- },
185
- images: {
186
- description: 'A Tillhub images object with URLs to display images this for this customer.',
187
- anyOf: [
188
- {
189
- type: 'object',
190
- additionalProperties: true,
191
- properties: {
192
- original: {
193
- type: 'string',
194
- format: 'uri'
195
- },
196
- gallery: {
197
- type: 'string',
198
- format: 'uri'
199
- },
200
- avatar: {
201
- type: 'string',
202
- format: 'uri'
203
- },
204
- '1x': {
205
- type: 'string',
206
- format: 'uri'
207
- },
208
- '2x': {
209
- type: 'string',
210
- format: 'uri'
211
- },
212
- '3x': {
213
- type: 'string',
214
- format: 'uri'
215
- }
216
- }
217
- },
218
- {
219
- type: 'null'
220
- }
221
- ]
150
+ description: 'Birth date',
151
+ ...anyOf({
152
+ type: 'string',
153
+ format: 'date-time'
154
+ })
222
155
  },
156
+ images: getImages(['1x', '2x', '3x', 'avatar', 'gallery']),
223
157
  image: {
224
158
  description: 'DEPRECATED. Omit or set null.',
225
- anyOf: [
226
- {
227
- type: 'object',
228
- additionalProperties: true,
229
- properties: {
230
- '1x': {
231
- type: 'string',
232
- format: 'uri'
233
- },
234
- avatar: {
235
- oneOf: [
236
- {
237
- type: 'string',
238
- format: 'uri'
239
- },
240
- {
241
- type: 'null'
242
- }
243
- ]
244
- }
245
- }
246
- },
247
- {
248
- type: 'null'
159
+ ...anyOf({
160
+ type: 'object',
161
+ additionalProperties: true,
162
+ properties: {
163
+ '1x': {
164
+ type: 'string',
165
+ format: 'uri'
166
+ },
167
+ avatar: oneOf({
168
+ type: 'string',
169
+ format: 'uri'
170
+ })
249
171
  }
250
- ]
251
- },
252
- active: {
253
- type: 'boolean'
254
- },
255
- deleted: {
256
- type: 'boolean'
172
+ })
257
173
  },
258
174
  contacts: {
259
- anyOf: [
260
- {
261
- type: 'object',
262
- additionalProperties: false,
263
- properties: {
264
- email: {
265
- type: 'object',
266
- additionalProperties: false,
267
- properties: {
268
- enabled: {
269
- type: 'boolean'
270
- }
175
+ description: 'Contact info',
176
+ ...anyOf({
177
+ type: 'object',
178
+ additionalProperties: false,
179
+ properties: {
180
+ email: {
181
+ type: 'object',
182
+ additionalProperties: false,
183
+ properties: {
184
+ enabled: {
185
+ type: 'boolean'
271
186
  }
272
- },
273
- newsletter: {
274
- type: 'object',
275
- additionalProperties: false,
276
- properties: {
277
- enabled: {
278
- type: 'boolean'
279
- }
187
+ }
188
+ },
189
+ newsletter: {
190
+ type: 'object',
191
+ additionalProperties: false,
192
+ properties: {
193
+ enabled: {
194
+ type: 'boolean'
280
195
  }
281
- },
282
- phone: {
283
- type: 'object',
284
- additionalProperties: false,
285
- properties: {
286
- enabled: {
287
- type: 'boolean'
288
- }
196
+ }
197
+ },
198
+ phone: {
199
+ type: 'object',
200
+ additionalProperties: false,
201
+ properties: {
202
+ enabled: {
203
+ type: 'boolean'
289
204
  }
290
- },
291
- post: {
292
- type: 'object',
293
- additionalProperties: false,
294
- properties: {
295
- enabled: {
296
- type: 'boolean'
297
- }
205
+ }
206
+ },
207
+ post: {
208
+ type: 'object',
209
+ additionalProperties: false,
210
+ properties: {
211
+ enabled: {
212
+ type: 'boolean'
298
213
  }
299
214
  }
300
215
  }
301
- },
302
- {
303
- type: 'null'
304
216
  }
305
- ]
217
+ })
306
218
  },
307
219
  metadata: {
220
+ description: 'Additional metadata',
308
221
  type: 'object'
309
222
  },
310
223
  addresses: {
311
- anyOf: [
312
- {
313
- type: 'array',
314
- maxItems: 3,
315
- items: {
316
- type: 'object',
317
- additionalProperties: false,
318
- properties: {
319
- lines: {
320
- oneOf: [
321
- {
322
- type: 'array',
323
- minItems: 1,
324
- maxItems: 4,
325
- items: {
326
- type: 'string',
327
- minLength: 1
328
- }
329
- },
330
- {
331
- type: 'null'
332
- }
333
- ]
334
- },
335
- street: {
336
- oneOf: [
337
- {
338
- type: 'string'
339
- },
340
- {
341
- type: 'null'
342
- }
343
- ]
344
- },
345
- street_number: {
346
- oneOf: [
347
- {
348
- type: 'string'
349
- },
350
- {
351
- type: 'null'
352
- }
353
- ]
354
- },
355
- locality: {
356
- oneOf: [
357
- {
358
- type: 'string'
359
- },
360
- {
361
- type: 'null'
362
- }
363
- ]
364
- },
365
- region: {
366
- oneOf: [
367
- {
368
- type: 'string'
369
- },
370
- {
371
- type: 'null'
372
- }
373
- ]
374
- },
375
- postal_code: {
376
- oneOf: [
377
- {
378
- type: 'string',
379
- maxLength: 10
380
- },
381
- {
382
- type: 'null'
383
- }
384
- ]
385
- },
386
- country: {
387
- oneOf: [
388
- {
389
- type: 'string',
390
- minLength: 2,
391
- maxLength: 2,
392
- pattern: '^[A-Z]{2}$'
393
- },
394
- {
395
- type: 'null'
396
- }
397
- ],
398
- 'default': null
399
- },
400
- type: {
401
- oneOf: [
402
- {
403
- type: 'string',
404
- 'enum': [
405
- 'delivery',
406
- 'billing'
407
- ]
408
- },
409
- {
410
- type: 'null'
411
- }
412
- ]
413
- }
414
- },
415
- required: [
416
- 'lines',
417
- 'street',
418
- 'street_number',
419
- 'locality',
420
- 'region',
421
- 'postal_code',
422
- 'country',
423
- 'type'
424
- ]
425
- }
426
- },
427
- {
428
- type: 'null'
429
- }
430
- ]
224
+ description: 'Addresses',
225
+ ...anyOf({
226
+ type: 'array',
227
+ maxItems: 3,
228
+ items: getAddress({
229
+ availableTypes: [
230
+ 'delivery',
231
+ 'billing'
232
+ ],
233
+ required: [
234
+ 'lines',
235
+ 'street',
236
+ 'street_number',
237
+ 'locality',
238
+ 'region',
239
+ 'postal_code',
240
+ 'country',
241
+ 'type'
242
+ ]
243
+ })
244
+ })
431
245
  },
432
246
  custom: {
433
- anyOf: [
434
- {
435
- type: 'object'
436
- },
437
- {
438
- type: 'null'
439
- }
440
- ]
247
+ description: 'Custom data',
248
+ ...anyOf({
249
+ type: 'object'
250
+ })
441
251
  },
442
252
  comment: {
443
- anyOf: [
444
- {
445
- type: 'string',
446
- maxLength: 1024
447
- },
448
- {
449
- type: 'null'
450
- }
451
- ]
253
+ description: 'Comment',
254
+ example: 'Don\'t mess with',
255
+ ...anyOf({
256
+ type: 'string',
257
+ maxLength: 1024
258
+ })
452
259
  },
453
260
  discounts: {
454
- anyOf: [
455
- {
456
- type: 'array',
457
- minItems: 1,
458
- maxItems: 10,
459
- items: {
460
- anyOf: [
461
- {
462
- type: 'object',
463
- additionalProperties: false,
464
- properties: {
465
- id: {
466
- type: 'string',
467
- maxLength: 128
468
- },
469
- amount: {
470
- type: 'number',
471
- minimum: 0
472
- },
473
- type: {
474
- type: 'string',
475
- 'enum': [
476
- 'percentage',
477
- 'value'
478
- ]
479
- },
480
- account: {
481
- anyOf: [
482
- {
483
- type: 'string',
484
- maxLength: 128
485
- },
486
- {
487
- type: 'null'
488
- }
489
- ]
490
- },
491
- name: {
492
- anyOf: [
493
- {
494
- type: 'string',
495
- maxLength: 64
496
- },
497
- {
498
- type: 'null'
499
- }
500
- ]
501
- },
502
- group: {
503
- type: 'string',
504
- 'enum': [
505
- 'cart',
506
- 'customer'
507
- ]
508
- }
261
+ description: 'Available discounts',
262
+ ...anyOf({
263
+ type: 'array',
264
+ minItems: 1,
265
+ maxItems: 10,
266
+ items: {
267
+ anyOf: [
268
+ {
269
+ type: 'object',
270
+ additionalProperties: false,
271
+ properties: {
272
+ id: {
273
+ type: 'string',
274
+ maxLength: 128
275
+ },
276
+ amount: {
277
+ type: 'number',
278
+ minimum: 0
509
279
  },
510
- required: [
511
- 'group',
512
- 'type',
513
- 'name',
514
- 'amount',
515
- 'id'
516
- ]
280
+ type: {
281
+ type: 'string',
282
+ 'enum': [
283
+ 'percentage',
284
+ 'value'
285
+ ]
286
+ },
287
+ account: {
288
+ anyOf: [
289
+ {
290
+ type: 'string',
291
+ maxLength: 128
292
+ },
293
+ {
294
+ type: 'null'
295
+ }
296
+ ]
297
+ },
298
+ name: {
299
+ anyOf: [
300
+ {
301
+ type: 'string',
302
+ maxLength: 64
303
+ },
304
+ {
305
+ type: 'null'
306
+ }
307
+ ]
308
+ },
309
+ group: {
310
+ type: 'string',
311
+ 'enum': [
312
+ 'cart',
313
+ 'customer'
314
+ ]
315
+ }
517
316
  },
518
- {
519
- type: 'object',
520
- additionalProperties: false,
521
- properties: {
522
- amount: {
523
- type: 'number',
524
- minimum: 0
525
- },
526
- type: {
527
- type: 'string',
528
- 'enum': [
529
- 'percent',
530
- 'percentage',
531
- 'value'
532
- ]
533
- },
534
- group: {
535
- type: 'string',
536
- 'enum': [
537
- 'cart',
538
- 'customer'
539
- ]
540
- },
541
- name: {
542
- type: 'string'
543
- }
317
+ required: [
318
+ 'group',
319
+ 'type',
320
+ 'name',
321
+ 'amount',
322
+ 'id'
323
+ ]
324
+ },
325
+ {
326
+ type: 'object',
327
+ additionalProperties: false,
328
+ properties: {
329
+ amount: {
330
+ type: 'number',
331
+ minimum: 0
544
332
  },
545
- required: [
546
- 'amount',
547
- 'type',
548
- 'group'
549
- ]
550
- }
551
- ]
552
- }
553
- },
554
- {
555
- type: 'null'
333
+ type: {
334
+ type: 'string',
335
+ 'enum': [
336
+ 'percent',
337
+ 'percentage',
338
+ 'value'
339
+ ]
340
+ },
341
+ group: {
342
+ type: 'string',
343
+ 'enum': [
344
+ 'cart',
345
+ 'customer'
346
+ ]
347
+ },
348
+ name: {
349
+ type: 'string'
350
+ }
351
+ },
352
+ required: [
353
+ 'amount',
354
+ 'type',
355
+ 'group'
356
+ ]
357
+ }
358
+ ]
556
359
  }
557
- ]
360
+ })
558
361
  },
559
362
  client_id: {
560
- anyOf: [
561
- {
562
- type: 'string',
563
- maxLength: 128
564
- },
565
- {
566
- type: 'null'
567
- }
568
- ]
363
+ description: 'Client ID',
364
+ ...anyOf({
365
+ type: 'string',
366
+ maxLength: 128
367
+ })
569
368
  },
570
369
  external_reference: {
571
- anyOf: [
572
- {
573
- type: 'string',
574
- minLength: 3,
575
- maxLength: 128
576
- },
577
- {
578
- type: 'null'
579
- }
580
- ]
370
+ description: 'External reference',
371
+ ...anyOf({
372
+ type: 'string',
373
+ minLength: 3,
374
+ maxLength: 128
375
+ })
581
376
  },
582
377
  customer_since: {
583
- anyOf: [
584
- {
585
- type: 'string',
586
- format: 'date-time'
587
- },
588
- {
589
- type: 'null'
590
- }
591
- ]
378
+ description: 'Customer since',
379
+ ...anyOf({
380
+ type: 'string',
381
+ format: 'date-time'
382
+ })
592
383
  },
593
384
  locations: {
594
- oneOf: [
595
- {
596
- type: 'array',
597
- items: {
598
- type: 'string',
599
- format: 'uuid'
600
- }
601
- },
602
- {
603
- type: 'null'
385
+ description: 'Locations customer belongs to',
386
+ ...oneOf({
387
+ type: 'array',
388
+ items: {
389
+ type: 'string',
390
+ format: 'uuid'
604
391
  }
605
- ]
392
+ })
606
393
  },
607
394
  branch_groups: {
608
- oneOf: [
609
- {
610
- type: 'array',
611
- items: {
612
- type: 'string',
613
- format: 'uuid'
614
- }
615
- },
616
- {
617
- type: 'null'
395
+ description: 'Branch groups customer belongs to',
396
+ ...oneOf({
397
+ type: 'array',
398
+ items: {
399
+ type: 'string',
400
+ format: 'uuid'
618
401
  }
619
- ]
402
+ })
620
403
  },
621
404
  gender: {
622
- oneOf: [
623
- {
624
- type: 'string',
625
- enum: [
626
- 'male',
627
- 'female',
628
- 'unspecified'
629
- ]
630
- },
631
- {
632
- type: 'null'
633
- }
634
- ]
405
+ description: 'Gender',
406
+ example: 'male',
407
+ ...oneOf({
408
+ type: 'string',
409
+ enum: [
410
+ 'male',
411
+ 'female',
412
+ 'unspecified'
413
+ ]
414
+ })
635
415
  },
636
416
  vat_id: {
637
- oneOf: [
638
- {
639
- type: 'string',
640
- maxLength: 20,
641
- minLength: 5
642
- },
643
- {
644
- type: 'null'
645
- }
646
- ]
417
+ description: 'Customer VAT ID',
418
+ ...oneOf({
419
+ type: 'string',
420
+ maxLength: 20,
421
+ minLength: 5
422
+ })
647
423
  }
648
424
  }