@xyo-network/payment-payload-plugins 3.0.16 → 3.0.18

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 (96) 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/index.d.ts +3 -0
  16. package/dist/neutral/Discount/Payload/Coupon/Coupons/index.d.ts.map +1 -0
  17. package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts +6 -0
  18. package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts.map +1 -0
  19. package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts +3 -0
  20. package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts.map +1 -0
  21. package/dist/neutral/Discount/Payload/Coupon/index.d.ts +5 -0
  22. package/dist/neutral/Discount/Payload/Coupon/index.d.ts.map +1 -0
  23. package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts +5 -0
  24. package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts.map +1 -0
  25. package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts +3 -0
  26. package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts.map +1 -0
  27. package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts +2 -0
  28. package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts.map +1 -0
  29. package/dist/neutral/Discount/Payload/Discount.d.ts +11 -0
  30. package/dist/neutral/Discount/Payload/Discount.d.ts.map +1 -0
  31. package/dist/neutral/Discount/Payload/NoDiscount.d.ts +3 -0
  32. package/dist/neutral/Discount/Payload/NoDiscount.d.ts.map +1 -0
  33. package/dist/neutral/Discount/Payload/index.d.ts +4 -0
  34. package/dist/neutral/Discount/Payload/index.d.ts.map +1 -0
  35. package/dist/neutral/Discount/index.d.ts +4 -0
  36. package/dist/neutral/Discount/index.d.ts.map +1 -0
  37. package/dist/neutral/Invoice/Invoice.d.ts +8 -0
  38. package/dist/neutral/Invoice/Invoice.d.ts.map +1 -0
  39. package/dist/neutral/Invoice/index.d.ts +2 -0
  40. package/dist/neutral/Invoice/index.d.ts.map +1 -0
  41. package/dist/neutral/Subtotal/Diviner/Config.d.ts +5 -0
  42. package/dist/neutral/Subtotal/Diviner/Config.d.ts.map +1 -0
  43. package/dist/neutral/Subtotal/Diviner/Params.d.ts +5 -0
  44. package/dist/neutral/Subtotal/Diviner/Params.d.ts.map +1 -0
  45. package/dist/neutral/Subtotal/Diviner/Payload.d.ts +11 -0
  46. package/dist/neutral/Subtotal/Diviner/Payload.d.ts.map +1 -0
  47. package/dist/neutral/Subtotal/Diviner/index.d.ts +4 -0
  48. package/dist/neutral/Subtotal/Diviner/index.d.ts.map +1 -0
  49. package/dist/neutral/Subtotal/index.d.ts +2 -0
  50. package/dist/neutral/Subtotal/index.d.ts.map +1 -0
  51. package/dist/neutral/Total/Diviner/Config.d.ts +9 -0
  52. package/dist/neutral/Total/Diviner/Config.d.ts.map +1 -0
  53. package/dist/neutral/Total/Diviner/Params.d.ts +5 -0
  54. package/dist/neutral/Total/Diviner/Params.d.ts.map +1 -0
  55. package/dist/neutral/Total/Diviner/Payload.d.ts +11 -0
  56. package/dist/neutral/Total/Diviner/Payload.d.ts.map +1 -0
  57. package/dist/neutral/Total/Diviner/index.d.ts +4 -0
  58. package/dist/neutral/Total/Diviner/index.d.ts.map +1 -0
  59. package/dist/neutral/Total/index.d.ts +2 -0
  60. package/dist/neutral/Total/index.d.ts.map +1 -0
  61. package/dist/neutral/index.d.ts +5 -0
  62. package/dist/neutral/index.d.ts.map +1 -1
  63. package/dist/neutral/index.mjs +360 -46
  64. package/dist/neutral/index.mjs.map +1 -1
  65. package/package.json +11 -9
  66. package/src/Amount/Iso4217Currency.ts +557 -0
  67. package/src/Amount/Payload.ts +36 -0
  68. package/src/Amount/index.ts +2 -0
  69. package/src/Discount/Config.ts +34 -0
  70. package/src/Discount/Params.ts +14 -0
  71. package/src/Discount/Payload/Coupon/Coupons/FixedAmount.ts +37 -0
  72. package/src/Discount/Payload/Coupon/Coupons/FixedPercentage.ts +37 -0
  73. package/src/Discount/Payload/Coupon/Coupons/index.ts +2 -0
  74. package/src/Discount/Payload/Coupon/Payload.ts +25 -0
  75. package/src/Discount/Payload/Coupon/Schema.ts +2 -0
  76. package/src/Discount/Payload/Coupon/index.ts +4 -0
  77. package/src/Discount/Payload/Coupon/types/CouponFields.ts +11 -0
  78. package/src/Discount/Payload/Coupon/types/index.ts +2 -0
  79. package/src/Discount/Payload/Coupon/types/isStackable.ts +6 -0
  80. package/src/Discount/Payload/Discount.ts +33 -0
  81. package/src/Discount/Payload/NoDiscount.ts +8 -0
  82. package/src/Discount/Payload/index.ts +3 -0
  83. package/src/Discount/index.ts +3 -0
  84. package/src/Invoice/Invoice.ts +19 -0
  85. package/src/Invoice/index.ts +1 -0
  86. package/src/Subtotal/Diviner/Config.ts +13 -0
  87. package/src/Subtotal/Diviner/Params.ts +8 -0
  88. package/src/Subtotal/Diviner/Payload.ts +33 -0
  89. package/src/Subtotal/Diviner/index.ts +3 -0
  90. package/src/Subtotal/index.ts +1 -0
  91. package/src/Total/Diviner/Config.ts +24 -0
  92. package/src/Total/Diviner/Params.ts +8 -0
  93. package/src/Total/Diviner/Payload.ts +33 -0
  94. package/src/Total/Diviner/index.ts +3 -0
  95. package/src/Total/index.ts +1 -0
  96. package/src/index.ts +5 -0
@@ -0,0 +1,25 @@
1
+ import {
2
+ type FixedAmountCoupon, type FixedPercentageCoupon, isFixedAmountCoupon, isFixedAmountCouponWithMeta, isFixedAmountCouponWithSources, isFixedPercentageCoupon,
3
+ isFixedPercentageCouponWithMeta,
4
+ isFixedPercentageCouponWithSources,
5
+ } from './Coupons/index.ts'
6
+
7
+ /**
8
+ * The result of a discount
9
+ */
10
+ export type Coupon = FixedAmountCoupon | FixedPercentageCoupon
11
+
12
+ /**
13
+ * Identity function for determining if an object is an Coupon
14
+ */
15
+ export const isCoupon = (x?: unknown | null) => isFixedAmountCoupon(x) || isFixedPercentageCoupon(x)
16
+
17
+ /**
18
+ * Identity function for determining if an object is an Coupon with sources
19
+ */
20
+ export const isCouponWithSources = (x?: unknown | null) => isFixedAmountCouponWithSources(x) || isFixedPercentageCouponWithSources(x)
21
+
22
+ /**
23
+ * Identity function for determining if an object is an Coupon with meta
24
+ */
25
+ export const isCouponWithMeta = (x?: unknown | null) => isFixedAmountCouponWithMeta(x) || isFixedPercentageCouponWithMeta(x)
@@ -0,0 +1,2 @@
1
+ export const CouponSchema = 'network.xyo.payments.coupon' as const
2
+ export type CouponSchema = typeof CouponSchema
@@ -0,0 +1,4 @@
1
+ export * from './Coupons/index.ts'
2
+ export * from './Payload.ts'
3
+ export * from './Schema.ts'
4
+ export * from './types/index.ts'
@@ -0,0 +1,11 @@
1
+ import type { DurationFields } from '@xyo-network/xns-record-payload-plugins'
2
+
3
+ /**
4
+ * The fields that are common across all coupons
5
+ */
6
+ export interface CouponFields extends DurationFields {
7
+ /**
8
+ * Whether or not this discount can be stacked with other discounts
9
+ */
10
+ stackable?: boolean
11
+ }
@@ -0,0 +1,2 @@
1
+ export * from './CouponFields.ts'
2
+ export * from './isStackable.ts'
@@ -0,0 +1,6 @@
1
+ import type { CouponFields } from './CouponFields.ts'
2
+
3
+ /**
4
+ * Identity function for determining if coupon is stackable
5
+ */
6
+ export const isStackable = (x?: unknown | null) => (x as CouponFields ?? { stackable: false })?.stackable
@@ -0,0 +1,33 @@
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
+
10
+ export const DiscountSchema = 'network.xyo.payments.discount' as const
11
+ export type DiscountSchema = typeof DiscountSchema
12
+
13
+ export interface DiscountFields extends AmountFields { }
14
+
15
+ /**
16
+ * The result of a discount
17
+ */
18
+ export type Discount = PayloadWithSources<DiscountFields, DiscountSchema>
19
+
20
+ /**
21
+ * Identity function for determining if an object is an Discount
22
+ */
23
+ export const isDiscount = isPayloadOfSchemaType<Discount>(DiscountSchema)
24
+
25
+ /**
26
+ * Identity function for determining if an object is an Discount with sources
27
+ */
28
+ export const isDiscountWithSources = isPayloadOfSchemaTypeWithSources<Discount>(DiscountSchema)
29
+
30
+ /**
31
+ * Identity function for determining if an object is an Discount with meta
32
+ */
33
+ export const isDiscountWithMeta = isPayloadOfSchemaTypeWithMeta<Discount>(DiscountSchema)
@@ -0,0 +1,8 @@
1
+ import type { Discount } from './Discount.ts'
2
+ import { DiscountSchema } from './Discount.ts'
3
+
4
+ export const NO_DISCOUNT: Discount = {
5
+ schema: DiscountSchema,
6
+ amount: 0,
7
+ currency: 'USD',
8
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Coupon/index.ts'
2
+ export * from './Discount.ts'
3
+ export * from './NoDiscount.ts'
@@ -0,0 +1,3 @@
1
+ export * from './Config.ts'
2
+ export * from './Params.ts'
3
+ export * from './Payload/index.ts'
@@ -0,0 +1,19 @@
1
+ import type { Discount } from '../Discount/index.ts'
2
+ import type { Payment } from '../Payment/index.ts'
3
+ import type { Subtotal } from '../Subtotal/index.ts'
4
+ import type { Total } from '../Total/index.ts'
5
+
6
+ /**
7
+ * A tuple containing the subtotal, total, and payment for an invoice.
8
+ */
9
+ export type StandardInvoice = [Subtotal, Total, Payment]
10
+
11
+ /**
12
+ * A tuple containing the subtotal, total, payment, and discount for an invoice.
13
+ */
14
+ export type DiscountedInvoice = [...StandardInvoice, Discount]
15
+
16
+ /**
17
+ * An invoice.
18
+ */
19
+ export type Invoice = StandardInvoice | DiscountedInvoice
@@ -0,0 +1 @@
1
+ export * from './Invoice.ts'
@@ -0,0 +1,13 @@
1
+ // import type { Hash } from '@xylabs/hex'
2
+ import type { DivinerConfig } from '@xyo-network/diviner-model'
3
+
4
+ export const PaymentSubtotalDivinerConfigSchema = 'network.xyo.diviner.payments.subtotal.config'
5
+ export type PaymentSubtotalDivinerConfigSchema = typeof PaymentSubtotalDivinerConfigSchema
6
+
7
+ /**
8
+ * The configuration for the Coupon Subtotal Diviner
9
+ */
10
+ export type PaymentSubtotalDivinerConfig = DivinerConfig<
11
+ {},
12
+ PaymentSubtotalDivinerConfigSchema
13
+ >
@@ -0,0 +1,8 @@
1
+ import type { DivinerParams } from '@xyo-network/diviner-model'
2
+ import type { AnyConfigSchema } from '@xyo-network/module-model'
3
+
4
+ import type { PaymentSubtotalDivinerConfig } from './Config.ts'
5
+
6
+ export type PaymentSubtotalDivinerParams<
7
+ TConfig extends AnyConfigSchema<PaymentSubtotalDivinerConfig> = AnyConfigSchema<PaymentSubtotalDivinerConfig>,
8
+ > = DivinerParams<TConfig>
@@ -0,0 +1,33 @@
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
+
10
+ export const SubtotalSchema = 'network.xyo.payments.subtotal' as const
11
+ export type SubtotalSchema = typeof SubtotalSchema
12
+
13
+ export interface SubtotalFields extends AmountFields {}
14
+
15
+ /**
16
+ * The result of a subtotal
17
+ */
18
+ export type Subtotal = PayloadWithSources<SubtotalFields, SubtotalSchema>
19
+
20
+ /**
21
+ * Identity function for determining if an object is an Subtotal
22
+ */
23
+ export const isSubtotal = isPayloadOfSchemaType<Subtotal>(SubtotalSchema)
24
+
25
+ /**
26
+ * Identity function for determining if an object is an Subtotal with sources
27
+ */
28
+ export const isSubtotalWithSources = isPayloadOfSchemaTypeWithSources<Subtotal>(SubtotalSchema)
29
+
30
+ /**
31
+ * Identity function for determining if an object is an Subtotal with meta
32
+ */
33
+ export const isSubtotalWithMeta = isPayloadOfSchemaTypeWithMeta<Subtotal>(SubtotalSchema)
@@ -0,0 +1,3 @@
1
+ export * from './Config.ts'
2
+ export * from './Params.ts'
3
+ export * from './Payload.ts'
@@ -0,0 +1 @@
1
+ export * from './Diviner/index.ts'
@@ -0,0 +1,24 @@
1
+ // import type { Hash } from '@xylabs/hex'
2
+ import type { DivinerConfig } from '@xyo-network/diviner-model'
3
+ import type { ModuleIdentifier } from '@xyo-network/module-model'
4
+
5
+ export const PaymentTotalDivinerConfigSchema = 'network.xyo.diviner.payments.total.config'
6
+ export type PaymentTotalDivinerConfigSchema = typeof PaymentTotalDivinerConfigSchema
7
+
8
+ /**
9
+ * The configuration for the Total Diviner
10
+ */
11
+ export type PaymentTotalDivinerConfig = DivinerConfig<
12
+ {
13
+ /**
14
+ * The Diviner that will be used to determine the discount
15
+ */
16
+ paymentDiscountDiviner?: ModuleIdentifier
17
+
18
+ /**
19
+ * The Diviner that will be used to determine the subtotal
20
+ */
21
+ paymentSubtotalDiviner?: ModuleIdentifier
22
+ },
23
+ PaymentTotalDivinerConfigSchema
24
+ >
@@ -0,0 +1,8 @@
1
+ import type { DivinerParams } from '@xyo-network/diviner-model'
2
+ import type { AnyConfigSchema } from '@xyo-network/module-model'
3
+
4
+ import type { PaymentTotalDivinerConfig } from './Config.ts'
5
+
6
+ export type PaymentTotalDivinerParams<
7
+ TConfig extends AnyConfigSchema<PaymentTotalDivinerConfig> = AnyConfigSchema<PaymentTotalDivinerConfig>,
8
+ > = DivinerParams<TConfig>
@@ -0,0 +1,33 @@
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
+
10
+ export const TotalSchema = 'network.xyo.payments.total' as const
11
+ export type TotalSchema = typeof TotalSchema
12
+
13
+ export interface TotalFields extends AmountFields {}
14
+
15
+ /**
16
+ * The result of a total
17
+ */
18
+ export type Total = PayloadWithSources<TotalFields, TotalSchema>
19
+
20
+ /**
21
+ * Identity function for determining if an object is an Total
22
+ */
23
+ export const isTotal = isPayloadOfSchemaType<Total>(TotalSchema)
24
+
25
+ /**
26
+ * Identity function for determining if an object is an Total with sources
27
+ */
28
+ export const isTotalWithSources = isPayloadOfSchemaTypeWithSources<Total>(TotalSchema)
29
+
30
+ /**
31
+ * Identity function for determining if an object is an Total with meta
32
+ */
33
+ export const isTotalWithMeta = isPayloadOfSchemaTypeWithMeta<Total>(TotalSchema)
@@ -0,0 +1,3 @@
1
+ export * from './Config.ts'
2
+ export * from './Params.ts'
3
+ export * from './Payload.ts'
@@ -0,0 +1 @@
1
+ export * from './Diviner/index.ts'
package/src/index.ts CHANGED
@@ -1,6 +1,11 @@
1
+ export * from './Amount/index.ts'
1
2
  export * from './Billing/index.ts'
2
3
  export * from './Currency.ts'
4
+ export * from './Discount/index.ts'
3
5
  export * from './Escrow/index.ts'
6
+ export * from './Invoice/index.ts'
4
7
  export * from './Payment/index.ts'
5
8
  export * from './Purchase/index.ts'
6
9
  export * from './Receipt/index.ts'
10
+ export * from './Subtotal/index.ts'
11
+ export * from './Total/index.ts'