@xyo-network/payment-payload-plugins 3.0.17 → 3.0.19

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 (99) hide show
  1. package/dist/neutral/Amount/Iso4217Currency.d.ts +5 -0
  2. package/dist/neutral/Amount/Iso4217Currency.d.ts.map +1 -0
  3. package/dist/neutral/Amount/Payload.d.ts +13 -0
  4. package/dist/neutral/Amount/Payload.d.ts.map +1 -0
  5. package/dist/neutral/Amount/index.d.ts +3 -0
  6. package/dist/neutral/Amount/index.d.ts.map +1 -0
  7. package/dist/neutral/Discount/Config.d.ts +11 -0
  8. package/dist/neutral/Discount/Config.d.ts.map +1 -0
  9. package/dist/neutral/Discount/Params.d.ts +8 -0
  10. package/dist/neutral/Discount/Params.d.ts.map +1 -0
  11. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedAmount.d.ts +12 -0
  12. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedAmount.d.ts.map +1 -0
  13. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPercentage.d.ts +12 -0
  14. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPercentage.d.ts.map +1 -0
  15. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPrice.d.ts +12 -0
  16. package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPrice.d.ts.map +1 -0
  17. package/dist/neutral/Discount/Payload/Coupon/Coupons/index.d.ts +4 -0
  18. package/dist/neutral/Discount/Payload/Coupon/Coupons/index.d.ts.map +1 -0
  19. package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts +6 -0
  20. package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts.map +1 -0
  21. package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts +3 -0
  22. package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts.map +1 -0
  23. package/dist/neutral/Discount/Payload/Coupon/index.d.ts +5 -0
  24. package/dist/neutral/Discount/Payload/Coupon/index.d.ts.map +1 -0
  25. package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts +5 -0
  26. package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts.map +1 -0
  27. package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts +3 -0
  28. package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts.map +1 -0
  29. package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts +2 -0
  30. package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts.map +1 -0
  31. package/dist/neutral/Discount/Payload/Discount.d.ts +11 -0
  32. package/dist/neutral/Discount/Payload/Discount.d.ts.map +1 -0
  33. package/dist/neutral/Discount/Payload/NoDiscount.d.ts +3 -0
  34. package/dist/neutral/Discount/Payload/NoDiscount.d.ts.map +1 -0
  35. package/dist/neutral/Discount/Payload/index.d.ts +4 -0
  36. package/dist/neutral/Discount/Payload/index.d.ts.map +1 -0
  37. package/dist/neutral/Discount/index.d.ts +4 -0
  38. package/dist/neutral/Discount/index.d.ts.map +1 -0
  39. package/dist/neutral/Invoice/Invoice.d.ts +8 -0
  40. package/dist/neutral/Invoice/Invoice.d.ts.map +1 -0
  41. package/dist/neutral/Invoice/index.d.ts +2 -0
  42. package/dist/neutral/Invoice/index.d.ts.map +1 -0
  43. package/dist/neutral/Subtotal/Diviner/Config.d.ts +5 -0
  44. package/dist/neutral/Subtotal/Diviner/Config.d.ts.map +1 -0
  45. package/dist/neutral/Subtotal/Diviner/Params.d.ts +5 -0
  46. package/dist/neutral/Subtotal/Diviner/Params.d.ts.map +1 -0
  47. package/dist/neutral/Subtotal/Diviner/Payload.d.ts +11 -0
  48. package/dist/neutral/Subtotal/Diviner/Payload.d.ts.map +1 -0
  49. package/dist/neutral/Subtotal/Diviner/index.d.ts +4 -0
  50. package/dist/neutral/Subtotal/Diviner/index.d.ts.map +1 -0
  51. package/dist/neutral/Subtotal/index.d.ts +2 -0
  52. package/dist/neutral/Subtotal/index.d.ts.map +1 -0
  53. package/dist/neutral/Total/Diviner/Config.d.ts +9 -0
  54. package/dist/neutral/Total/Diviner/Config.d.ts.map +1 -0
  55. package/dist/neutral/Total/Diviner/Params.d.ts +5 -0
  56. package/dist/neutral/Total/Diviner/Params.d.ts.map +1 -0
  57. package/dist/neutral/Total/Diviner/Payload.d.ts +11 -0
  58. package/dist/neutral/Total/Diviner/Payload.d.ts.map +1 -0
  59. package/dist/neutral/Total/Diviner/index.d.ts +4 -0
  60. package/dist/neutral/Total/Diviner/index.d.ts.map +1 -0
  61. package/dist/neutral/Total/index.d.ts +2 -0
  62. package/dist/neutral/Total/index.d.ts.map +1 -0
  63. package/dist/neutral/index.d.ts +5 -0
  64. package/dist/neutral/index.d.ts.map +1 -1
  65. package/dist/neutral/index.mjs +375 -46
  66. package/dist/neutral/index.mjs.map +1 -1
  67. package/package.json +4 -2
  68. package/src/Amount/Iso4217Currency.ts +557 -0
  69. package/src/Amount/Payload.ts +36 -0
  70. package/src/Amount/index.ts +2 -0
  71. package/src/Discount/Config.ts +34 -0
  72. package/src/Discount/Params.ts +14 -0
  73. package/src/Discount/Payload/Coupon/Coupons/FixedAmount.ts +35 -0
  74. package/src/Discount/Payload/Coupon/Coupons/FixedPercentage.ts +36 -0
  75. package/src/Discount/Payload/Coupon/Coupons/FixedPrice.ts +35 -0
  76. package/src/Discount/Payload/Coupon/Coupons/index.ts +3 -0
  77. package/src/Discount/Payload/Coupon/Payload.ts +39 -0
  78. package/src/Discount/Payload/Coupon/Schema.ts +2 -0
  79. package/src/Discount/Payload/Coupon/index.ts +4 -0
  80. package/src/Discount/Payload/Coupon/types/CouponFields.ts +11 -0
  81. package/src/Discount/Payload/Coupon/types/index.ts +2 -0
  82. package/src/Discount/Payload/Coupon/types/isStackable.ts +6 -0
  83. package/src/Discount/Payload/Discount.ts +33 -0
  84. package/src/Discount/Payload/NoDiscount.ts +8 -0
  85. package/src/Discount/Payload/index.ts +3 -0
  86. package/src/Discount/index.ts +3 -0
  87. package/src/Invoice/Invoice.ts +19 -0
  88. package/src/Invoice/index.ts +1 -0
  89. package/src/Subtotal/Diviner/Config.ts +13 -0
  90. package/src/Subtotal/Diviner/Params.ts +8 -0
  91. package/src/Subtotal/Diviner/Payload.ts +33 -0
  92. package/src/Subtotal/Diviner/index.ts +3 -0
  93. package/src/Subtotal/index.ts +1 -0
  94. package/src/Total/Diviner/Config.ts +24 -0
  95. package/src/Total/Diviner/Params.ts +8 -0
  96. package/src/Total/Diviner/Payload.ts +33 -0
  97. package/src/Total/Diviner/index.ts +3 -0
  98. package/src/Total/index.ts +1 -0
  99. package/src/index.ts +5 -0
@@ -0,0 +1,557 @@
1
+ /* eslint-disable max-lines */
2
+ /**
3
+ * ISO 4217 currency codes
4
+ */
5
+ export type Iso4217AlphabeticalCode =
6
+ 'AED' |
7
+ 'AFN' |
8
+ 'ALL' |
9
+ 'AMD' |
10
+ 'ANG' |
11
+ 'AOA' |
12
+ 'ARS' |
13
+ 'AUD' |
14
+ 'AWG' |
15
+ 'AZN' |
16
+ 'BAM' |
17
+ 'BBD' |
18
+ 'BDT' |
19
+ 'BGN' |
20
+ 'BHD' |
21
+ 'BIF' |
22
+ 'BMD' |
23
+ 'BND' |
24
+ 'BOB' |
25
+ 'BOV' |
26
+ 'BRL' |
27
+ 'BSD' |
28
+ 'BTN' |
29
+ 'BWP' |
30
+ 'BYN' |
31
+ 'BZD' |
32
+ 'CAD' |
33
+ 'CDF' |
34
+ 'CHE' |
35
+ 'CHF' |
36
+ 'CHW' |
37
+ 'CLF' |
38
+ 'CLP' |
39
+ 'CNY' |
40
+ 'COP' |
41
+ 'COU' |
42
+ 'CRC' |
43
+ 'CUP' |
44
+ 'CVE' |
45
+ 'CZK' |
46
+ 'DJF' |
47
+ 'DKK' |
48
+ 'DOP' |
49
+ 'DZD' |
50
+ 'EGP' |
51
+ 'ERN' |
52
+ 'ETB' |
53
+ 'EUR' |
54
+ 'FJD' |
55
+ 'FKP' |
56
+ 'GBP' |
57
+ 'GEL' |
58
+ 'GHS' |
59
+ 'GIP' |
60
+ 'GMD' |
61
+ 'GNF' |
62
+ 'GTQ' |
63
+ 'GYD' |
64
+ 'HKD' |
65
+ 'HNL' |
66
+ 'HTG' |
67
+ 'HUF' |
68
+ 'IDR' |
69
+ 'ILS' |
70
+ 'INR' |
71
+ 'IQD' |
72
+ 'IRR' |
73
+ 'ISK' |
74
+ 'JMD' |
75
+ 'JOD' |
76
+ 'JPY' |
77
+ 'KES' |
78
+ 'KGS' |
79
+ 'KHR' |
80
+ 'KMF' |
81
+ 'KPW' |
82
+ 'KRW' |
83
+ 'KWD' |
84
+ 'KYD' |
85
+ 'KZT' |
86
+ 'LAK' |
87
+ 'LBP' |
88
+ 'LKR' |
89
+ 'LRD' |
90
+ 'LSL' |
91
+ 'LYD' |
92
+ 'MAD' |
93
+ 'MDL' |
94
+ 'MGA' |
95
+ 'MKD' |
96
+ 'MMK' |
97
+ 'MNT' |
98
+ 'MOP' |
99
+ 'MRU' |
100
+ 'MUR' |
101
+ 'MVR' |
102
+ 'MWK' |
103
+ 'MXN' |
104
+ 'MXV' |
105
+ 'MYR' |
106
+ 'MZN' |
107
+ 'NAD' |
108
+ 'NGN' |
109
+ 'NIO' |
110
+ 'NOK' |
111
+ 'NPR' |
112
+ 'NZD' |
113
+ 'OMR' |
114
+ 'PAB' |
115
+ 'PEN' |
116
+ 'PGK' |
117
+ 'PHP' |
118
+ 'PKR' |
119
+ 'PLN' |
120
+ 'PYG' |
121
+ 'QAR' |
122
+ 'RON' |
123
+ 'RSD' |
124
+ 'RUB' |
125
+ 'RWF' |
126
+ 'SAR' |
127
+ 'SBD' |
128
+ 'SCR' |
129
+ 'SDG' |
130
+ 'SEK' |
131
+ 'SGD' |
132
+ 'SHP' |
133
+ 'SLE' |
134
+ 'SOS' |
135
+ 'SRD' |
136
+ 'SSP' |
137
+ 'STN' |
138
+ 'SVC' |
139
+ 'SYP' |
140
+ 'SZL' |
141
+ 'THB' |
142
+ 'TJS' |
143
+ 'TMT' |
144
+ 'TND' |
145
+ 'TOP' |
146
+ 'TRY' |
147
+ 'TTD' |
148
+ 'TWD' |
149
+ 'TZS' |
150
+ 'UAH' |
151
+ 'UGX' |
152
+ 'USD' |
153
+ 'USN' |
154
+ 'UYI' |
155
+ 'UYU' |
156
+ 'UYW' |
157
+ 'UZS' |
158
+ 'VED' |
159
+ 'VES' |
160
+ 'VND' |
161
+ 'VUV' |
162
+ 'WST' |
163
+ 'XAF' |
164
+ 'XAG' |
165
+ 'XAU' |
166
+ 'XBA' |
167
+ 'XBB' |
168
+ 'XBC' |
169
+ 'XBD' |
170
+ 'XCD' |
171
+ 'XDR' |
172
+ 'XOF' |
173
+ 'XPD' |
174
+ 'XPF' |
175
+ 'XPT' |
176
+ 'XSU' |
177
+ 'XTS' |
178
+ 'XUA' |
179
+ 'XXX' |
180
+ 'YER' |
181
+ 'ZAR' |
182
+ 'ZMW' |
183
+ 'ZWG' |
184
+ 'ZWL'
185
+
186
+ // TODO: Technically, the values should be 3 digit numbers with leading
187
+ // zeros, so we can padStart if we need to be strict
188
+ /**
189
+ * ISO 4217 numeric currency number codes
190
+ */
191
+ export type Iso4217NumericCode =
192
+ 784 |
193
+ 971 |
194
+ 8 |
195
+ 51 |
196
+ 532 |
197
+ 973 |
198
+ 32 |
199
+ 36 |
200
+ 533 |
201
+ 944 |
202
+ 977 |
203
+ 52 |
204
+ 50 |
205
+ 975 |
206
+ 48 |
207
+ 108 |
208
+ 60 |
209
+ 96 |
210
+ 68 |
211
+ 984 |
212
+ 986 |
213
+ 44 |
214
+ 64 |
215
+ 72 |
216
+ 933 |
217
+ 84 |
218
+ 124 |
219
+ 976 |
220
+ 947 |
221
+ 756 |
222
+ 948 |
223
+ 990 |
224
+ 152 |
225
+ 156 |
226
+ 170 |
227
+ 970 |
228
+ 188 |
229
+ 192 |
230
+ 132 |
231
+ 203 |
232
+ 262 |
233
+ 208 |
234
+ 214 |
235
+ 12 |
236
+ 818 |
237
+ 232 |
238
+ 230 |
239
+ 978 |
240
+ 242 |
241
+ 238 |
242
+ 826 |
243
+ 981 |
244
+ 936 |
245
+ 292 |
246
+ 270 |
247
+ 324 |
248
+ 320 |
249
+ 328 |
250
+ 344 |
251
+ 340 |
252
+ 332 |
253
+ 348 |
254
+ 360 |
255
+ 376 |
256
+ 356 |
257
+ 368 |
258
+ 364 |
259
+ 352 |
260
+ 388 |
261
+ 400 |
262
+ 392 |
263
+ 404 |
264
+ 417 |
265
+ 116 |
266
+ 174 |
267
+ 408 |
268
+ 410 |
269
+ 414 |
270
+ 136 |
271
+ 398 |
272
+ 418 |
273
+ 422 |
274
+ 144 |
275
+ 430 |
276
+ 426 |
277
+ 434 |
278
+ 504 |
279
+ 498 |
280
+ 969 |
281
+ 807 |
282
+ 104 |
283
+ 496 |
284
+ 446 |
285
+ 929 |
286
+ 480 |
287
+ 462 |
288
+ 454 |
289
+ 484 |
290
+ 979 |
291
+ 458 |
292
+ 943 |
293
+ 516 |
294
+ 566 |
295
+ 558 |
296
+ 578 |
297
+ 524 |
298
+ 554 |
299
+ 512 |
300
+ 590 |
301
+ 604 |
302
+ 598 |
303
+ 608 |
304
+ 586 |
305
+ 985 |
306
+ 600 |
307
+ 634 |
308
+ 946 |
309
+ 941 |
310
+ 643 |
311
+ 646 |
312
+ 682 |
313
+ 90 |
314
+ 690 |
315
+ 938 |
316
+ 752 |
317
+ 702 |
318
+ 654 |
319
+ 925 |
320
+ 706 |
321
+ 968 |
322
+ 728 |
323
+ 930 |
324
+ 222 |
325
+ 760 |
326
+ 748 |
327
+ 764 |
328
+ 972 |
329
+ 934 |
330
+ 788 |
331
+ 776 |
332
+ 949 |
333
+ 780 |
334
+ 901 |
335
+ 834 |
336
+ 980 |
337
+ 800 |
338
+ 840 |
339
+ 997 |
340
+ 940 |
341
+ 858 |
342
+ 927 |
343
+ 860 |
344
+ 926 |
345
+ 928 |
346
+ 704 |
347
+ 548 |
348
+ 882 |
349
+ 950 |
350
+ 961 |
351
+ 959 |
352
+ 955 |
353
+ 956 |
354
+ 957 |
355
+ 958 |
356
+ 951 |
357
+ 960 |
358
+ 952 |
359
+ 964 |
360
+ 953 |
361
+ 962 |
362
+ 994 |
363
+ 963 |
364
+ 965 |
365
+ 999 |
366
+ 886 |
367
+ 710 |
368
+ 967 |
369
+ 924 |
370
+ 932
371
+
372
+ /**
373
+ * Dictionary of ISO 4217 alphabetical currency codes to numeric currency number codes
374
+ */
375
+ export const Iso4217CurrencyCodes: Record<Iso4217AlphabeticalCode, Iso4217NumericCode> = {
376
+ AED: 784,
377
+ AFN: 971,
378
+ ALL: 8,
379
+ AMD: 51,
380
+ ANG: 532,
381
+ AOA: 973,
382
+ ARS: 32,
383
+ AUD: 36,
384
+ AWG: 533,
385
+ AZN: 944,
386
+ BAM: 977,
387
+ BBD: 52,
388
+ BDT: 50,
389
+ BGN: 975,
390
+ BHD: 48,
391
+ BIF: 108,
392
+ BMD: 60,
393
+ BND: 96,
394
+ BOB: 68,
395
+ BOV: 984,
396
+ BRL: 986,
397
+ BSD: 44,
398
+ BTN: 64,
399
+ BWP: 72,
400
+ BYN: 933,
401
+ BZD: 84,
402
+ CAD: 124,
403
+ CDF: 976,
404
+ CHE: 947,
405
+ CHF: 756,
406
+ CHW: 948,
407
+ CLF: 990,
408
+ CLP: 152,
409
+ CNY: 156,
410
+ COP: 170,
411
+ COU: 970,
412
+ CRC: 188,
413
+ CUP: 192,
414
+ CVE: 132,
415
+ CZK: 203,
416
+ DJF: 262,
417
+ DKK: 208,
418
+ DOP: 214,
419
+ DZD: 12,
420
+ EGP: 818,
421
+ ERN: 232,
422
+ ETB: 230,
423
+ EUR: 978,
424
+ FJD: 242,
425
+ FKP: 238,
426
+ GBP: 826,
427
+ GEL: 981,
428
+ GHS: 936,
429
+ GIP: 292,
430
+ GMD: 270,
431
+ GNF: 324,
432
+ GTQ: 320,
433
+ GYD: 328,
434
+ HKD: 344,
435
+ HNL: 340,
436
+ HTG: 332,
437
+ HUF: 348,
438
+ IDR: 360,
439
+ ILS: 376,
440
+ INR: 356,
441
+ IQD: 368,
442
+ IRR: 364,
443
+ ISK: 352,
444
+ JMD: 388,
445
+ JOD: 400,
446
+ JPY: 392,
447
+ KES: 404,
448
+ KGS: 417,
449
+ KHR: 116,
450
+ KMF: 174,
451
+ KPW: 408,
452
+ KRW: 410,
453
+ KWD: 414,
454
+ KYD: 136,
455
+ KZT: 398,
456
+ LAK: 418,
457
+ LBP: 422,
458
+ LKR: 144,
459
+ LRD: 430,
460
+ LSL: 426,
461
+ LYD: 434,
462
+ MAD: 504,
463
+ MDL: 498,
464
+ MGA: 969,
465
+ MKD: 807,
466
+ MMK: 104,
467
+ MNT: 496,
468
+ MOP: 446,
469
+ MRU: 929,
470
+ MUR: 480,
471
+ MVR: 462,
472
+ MWK: 454,
473
+ MXN: 484,
474
+ MXV: 979,
475
+ MYR: 458,
476
+ MZN: 943,
477
+ NAD: 516,
478
+ NGN: 566,
479
+ NIO: 558,
480
+ NOK: 578,
481
+ NPR: 524,
482
+ NZD: 554,
483
+ OMR: 512,
484
+ PAB: 590,
485
+ PEN: 604,
486
+ PGK: 598,
487
+ PHP: 608,
488
+ PKR: 586,
489
+ PLN: 985,
490
+ PYG: 600,
491
+ QAR: 634,
492
+ RON: 946,
493
+ RSD: 941,
494
+ RUB: 643,
495
+ RWF: 646,
496
+ SAR: 682,
497
+ SBD: 90,
498
+ SCR: 690,
499
+ SDG: 938,
500
+ SEK: 752,
501
+ SGD: 702,
502
+ SHP: 654,
503
+ SLE: 925,
504
+ SOS: 706,
505
+ SRD: 968,
506
+ SSP: 728,
507
+ STN: 930,
508
+ SVC: 222,
509
+ SYP: 760,
510
+ SZL: 748,
511
+ THB: 764,
512
+ TJS: 972,
513
+ TMT: 934,
514
+ TND: 788,
515
+ TOP: 776,
516
+ TRY: 949,
517
+ TTD: 780,
518
+ TWD: 901,
519
+ TZS: 834,
520
+ UAH: 980,
521
+ UGX: 800,
522
+ USD: 840,
523
+ USN: 997,
524
+ UYI: 940,
525
+ UYU: 858,
526
+ UYW: 927,
527
+ UZS: 860,
528
+ VED: 926,
529
+ VES: 928,
530
+ VND: 704,
531
+ VUV: 548,
532
+ WST: 882,
533
+ XAF: 950,
534
+ XAG: 961,
535
+ XAU: 959,
536
+ XBA: 955,
537
+ XBB: 956,
538
+ XBC: 957,
539
+ XBD: 958,
540
+ XCD: 951,
541
+ XDR: 960,
542
+ XOF: 952,
543
+ XPD: 964,
544
+ XPF: 953,
545
+ XPT: 962,
546
+ XSU: 994,
547
+ XTS: 963,
548
+ XUA: 965,
549
+ XXX: 999,
550
+ YER: 886,
551
+ ZAR: 710,
552
+ ZMW: 967,
553
+ ZWG: 924,
554
+ ZWL: 932,
555
+ }
556
+
557
+ export const isIso4217CurrencyCode = (code: string): code is Iso4217AlphabeticalCode => Iso4217CurrencyCodes[code as Iso4217AlphabeticalCode] ? true : false
@@ -0,0 +1,36 @@
1
+ import type { PayloadWithSources } from '@xyo-network/payload-model'
2
+ import {
3
+ isPayloadOfSchemaType,
4
+ isPayloadOfSchemaTypeWithMeta,
5
+ isPayloadOfSchemaTypeWithSources,
6
+ } from '@xyo-network/payload-model'
7
+
8
+ import type { Iso4217AlphabeticalCode } from './Iso4217Currency.ts'
9
+
10
+ export const AmountSchema = 'network.xyo.payments.amount' as const
11
+ export type AmountSchema = typeof AmountSchema
12
+
13
+ export interface AmountFields {
14
+ amount: number
15
+ currency: Iso4217AlphabeticalCode
16
+ }
17
+
18
+ /**
19
+ * The result of a amount
20
+ */
21
+ export type Amount = PayloadWithSources<AmountFields, AmountSchema>
22
+
23
+ /**
24
+ * Identity function for determining if an object is an Amount
25
+ */
26
+ export const isAmount = isPayloadOfSchemaType<Amount>(AmountSchema)
27
+
28
+ /**
29
+ * Identity function for determining if an object is an Amount with sources
30
+ */
31
+ export const isAmountWithSources = isPayloadOfSchemaTypeWithSources<Amount>(AmountSchema)
32
+
33
+ /**
34
+ * Identity function for determining if an object is an Amount with meta
35
+ */
36
+ export const isAmountWithMeta = isPayloadOfSchemaTypeWithMeta<Amount>(AmountSchema)
@@ -0,0 +1,2 @@
1
+ export * from './Iso4217Currency.ts'
2
+ export * from './Payload.ts'
@@ -0,0 +1,34 @@
1
+ // import type { Hash } from '@xylabs/hex'
2
+ import type { Address } from '@xylabs/hex'
3
+ import type { DivinerConfig } from '@xyo-network/diviner-model'
4
+ import type { ModuleIdentifier } from '@xyo-network/module-model'
5
+
6
+ export const PaymentDiscountDivinerConfigSchema = 'network.xyo.diviner.payments.discount.config'
7
+ export type PaymentDiscountDivinerConfigSchema = typeof PaymentDiscountDivinerConfigSchema
8
+
9
+ /**
10
+ * The configuration for the Payment Discount Diviner
11
+ */
12
+ export type PaymentDiscountDivinerConfig = DivinerConfig<
13
+ {
14
+ /**
15
+ * The boundwitness diviner used to query for payloads
16
+ */
17
+ boundWitnessDiviner?: ModuleIdentifier
18
+ /**
19
+ * The list of coupon authorities that can be used to get a discount
20
+ */
21
+ couponAuthorities?: Address[]
22
+
23
+ // /**
24
+ // * The list of coupons that are supported by this diviner
25
+ // */
26
+ // supportedCoupons?: Hash[]
27
+
28
+ /**
29
+ * The Diviner that can be used to determine the subtotal to apply discounts to
30
+ */
31
+ paymentSubtotalDiviner?: ModuleIdentifier
32
+ },
33
+ PaymentDiscountDivinerConfigSchema
34
+ >
@@ -0,0 +1,14 @@
1
+ import type { Address } from '@xylabs/hex'
2
+ import type { DivinerParams } from '@xyo-network/diviner-model'
3
+ import type { AnyConfigSchema } from '@xyo-network/module-model'
4
+
5
+ import type { PaymentDiscountDivinerConfig } from './Config.ts'
6
+
7
+ export type PaymentDiscountDivinerParams<
8
+ TConfig extends AnyConfigSchema<PaymentDiscountDivinerConfig> = AnyConfigSchema<PaymentDiscountDivinerConfig>,
9
+ > = DivinerParams<TConfig, {
10
+ /**
11
+ * The list of coupon authorities that can be used to get a discount
12
+ */
13
+ couponAuthorities?: Address[]
14
+ }>
@@ -0,0 +1,35 @@
1
+ import type { PayloadWithSources } from '@xyo-network/payload-model'
2
+ import {
3
+ isPayloadOfSchemaType,
4
+ isPayloadOfSchemaTypeWithMeta,
5
+ isPayloadOfSchemaTypeWithSources,
6
+ } from '@xyo-network/payload-model'
7
+
8
+ import type { AmountFields } from '../../../../Amount/index.ts'
9
+ import { CouponSchema } from '../Schema.ts'
10
+ import type { CouponFields } from '../types/index.ts'
11
+
12
+ export const FixedAmountCouponSchema = `${CouponSchema}.fixed.amount` as const
13
+ export type FixedAmountCouponSchema = typeof FixedAmountCouponSchema
14
+
15
+ export interface FixedAmountCouponFields extends CouponFields, AmountFields {}
16
+
17
+ /**
18
+ * A coupon that provides a fixed discount amount
19
+ */
20
+ export type FixedAmountCoupon = PayloadWithSources<FixedAmountCouponFields, FixedAmountCouponSchema>
21
+
22
+ /**
23
+ * Identity function for determining if an object is an FixedAmountCoupon
24
+ */
25
+ export const isFixedAmountCoupon = isPayloadOfSchemaType<FixedAmountCoupon>(FixedAmountCouponSchema)
26
+
27
+ /**
28
+ * Identity function for determining if an object is an FixedAmountCoupon with sources
29
+ */
30
+ export const isFixedAmountCouponWithSources = isPayloadOfSchemaTypeWithSources<FixedAmountCoupon>(FixedAmountCouponSchema)
31
+
32
+ /**
33
+ * Identity function for determining if an object is an FixedAmountCoupon with meta
34
+ */
35
+ export const isFixedAmountCouponWithMeta = isPayloadOfSchemaTypeWithMeta<FixedAmountCoupon>(FixedAmountCouponSchema)
@@ -0,0 +1,36 @@
1
+ import type { PayloadWithSources } from '@xyo-network/payload-model'
2
+ import {
3
+ isPayloadOfSchemaType,
4
+ isPayloadOfSchemaTypeWithMeta,
5
+ isPayloadOfSchemaTypeWithSources,
6
+ } from '@xyo-network/payload-model'
7
+
8
+ import { CouponSchema } from '../Schema.ts'
9
+ import type { CouponFields } from '../types/index.ts'
10
+
11
+ export const FixedPercentageCouponSchema = `${CouponSchema}.fixed.percentage` as const
12
+ export type FixedPercentageCouponSchema = typeof FixedPercentageCouponSchema
13
+
14
+ export interface FixedPercentageCouponFields extends CouponFields {
15
+ percentage: number
16
+ }
17
+
18
+ /**
19
+ * A coupon that provides a fixed discount amount
20
+ */
21
+ export type FixedPercentageCoupon = PayloadWithSources<FixedPercentageCouponFields, FixedPercentageCouponSchema>
22
+
23
+ /**
24
+ * Identity function for determining if an object is an FixedPercentageCoupon
25
+ */
26
+ export const isFixedPercentageCoupon = isPayloadOfSchemaType<FixedPercentageCoupon>(FixedPercentageCouponSchema)
27
+
28
+ /**
29
+ * Identity function for determining if an object is an FixedPercentageCoupon with sources
30
+ */
31
+ export const isFixedPercentageCouponWithSources = isPayloadOfSchemaTypeWithSources<FixedPercentageCoupon>(FixedPercentageCouponSchema)
32
+
33
+ /**
34
+ * Identity function for determining if an object is an FixedPercentageCoupon with meta
35
+ */
36
+ export const isFixedPercentageCouponWithMeta = isPayloadOfSchemaTypeWithMeta<FixedPercentageCoupon>(FixedPercentageCouponSchema)