@xyo-network/payment-payload-plugins 3.0.17 → 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.
- package/dist/neutral/Amount/Iso4217Currency.d.ts +5 -0
- package/dist/neutral/Amount/Iso4217Currency.d.ts.map +1 -0
- package/dist/neutral/Amount/Payload.d.ts +13 -0
- package/dist/neutral/Amount/Payload.d.ts.map +1 -0
- package/dist/neutral/Amount/index.d.ts +3 -0
- package/dist/neutral/Amount/index.d.ts.map +1 -0
- package/dist/neutral/Discount/Config.d.ts +11 -0
- package/dist/neutral/Discount/Config.d.ts.map +1 -0
- package/dist/neutral/Discount/Params.d.ts +8 -0
- package/dist/neutral/Discount/Params.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedAmount.d.ts +12 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedAmount.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPercentage.d.ts +12 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/FixedPercentage.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/index.d.ts +3 -0
- package/dist/neutral/Discount/Payload/Coupon/Coupons/index.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts +6 -0
- package/dist/neutral/Discount/Payload/Coupon/Payload.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts +3 -0
- package/dist/neutral/Discount/Payload/Coupon/Schema.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/index.d.ts +5 -0
- package/dist/neutral/Discount/Payload/Coupon/index.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts +5 -0
- package/dist/neutral/Discount/Payload/Coupon/types/CouponFields.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts +3 -0
- package/dist/neutral/Discount/Payload/Coupon/types/index.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts +2 -0
- package/dist/neutral/Discount/Payload/Coupon/types/isStackable.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/Discount.d.ts +11 -0
- package/dist/neutral/Discount/Payload/Discount.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/NoDiscount.d.ts +3 -0
- package/dist/neutral/Discount/Payload/NoDiscount.d.ts.map +1 -0
- package/dist/neutral/Discount/Payload/index.d.ts +4 -0
- package/dist/neutral/Discount/Payload/index.d.ts.map +1 -0
- package/dist/neutral/Discount/index.d.ts +4 -0
- package/dist/neutral/Discount/index.d.ts.map +1 -0
- package/dist/neutral/Invoice/Invoice.d.ts +8 -0
- package/dist/neutral/Invoice/Invoice.d.ts.map +1 -0
- package/dist/neutral/Invoice/index.d.ts +2 -0
- package/dist/neutral/Invoice/index.d.ts.map +1 -0
- package/dist/neutral/Subtotal/Diviner/Config.d.ts +5 -0
- package/dist/neutral/Subtotal/Diviner/Config.d.ts.map +1 -0
- package/dist/neutral/Subtotal/Diviner/Params.d.ts +5 -0
- package/dist/neutral/Subtotal/Diviner/Params.d.ts.map +1 -0
- package/dist/neutral/Subtotal/Diviner/Payload.d.ts +11 -0
- package/dist/neutral/Subtotal/Diviner/Payload.d.ts.map +1 -0
- package/dist/neutral/Subtotal/Diviner/index.d.ts +4 -0
- package/dist/neutral/Subtotal/Diviner/index.d.ts.map +1 -0
- package/dist/neutral/Subtotal/index.d.ts +2 -0
- package/dist/neutral/Subtotal/index.d.ts.map +1 -0
- package/dist/neutral/Total/Diviner/Config.d.ts +9 -0
- package/dist/neutral/Total/Diviner/Config.d.ts.map +1 -0
- package/dist/neutral/Total/Diviner/Params.d.ts +5 -0
- package/dist/neutral/Total/Diviner/Params.d.ts.map +1 -0
- package/dist/neutral/Total/Diviner/Payload.d.ts +11 -0
- package/dist/neutral/Total/Diviner/Payload.d.ts.map +1 -0
- package/dist/neutral/Total/Diviner/index.d.ts +4 -0
- package/dist/neutral/Total/Diviner/index.d.ts.map +1 -0
- package/dist/neutral/Total/index.d.ts +2 -0
- package/dist/neutral/Total/index.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +5 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +360 -46
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +4 -2
- package/src/Amount/Iso4217Currency.ts +557 -0
- package/src/Amount/Payload.ts +36 -0
- package/src/Amount/index.ts +2 -0
- package/src/Discount/Config.ts +34 -0
- package/src/Discount/Params.ts +14 -0
- package/src/Discount/Payload/Coupon/Coupons/FixedAmount.ts +37 -0
- package/src/Discount/Payload/Coupon/Coupons/FixedPercentage.ts +37 -0
- package/src/Discount/Payload/Coupon/Coupons/index.ts +2 -0
- package/src/Discount/Payload/Coupon/Payload.ts +25 -0
- package/src/Discount/Payload/Coupon/Schema.ts +2 -0
- package/src/Discount/Payload/Coupon/index.ts +4 -0
- package/src/Discount/Payload/Coupon/types/CouponFields.ts +11 -0
- package/src/Discount/Payload/Coupon/types/index.ts +2 -0
- package/src/Discount/Payload/Coupon/types/isStackable.ts +6 -0
- package/src/Discount/Payload/Discount.ts +33 -0
- package/src/Discount/Payload/NoDiscount.ts +8 -0
- package/src/Discount/Payload/index.ts +3 -0
- package/src/Discount/index.ts +3 -0
- package/src/Invoice/Invoice.ts +19 -0
- package/src/Invoice/index.ts +1 -0
- package/src/Subtotal/Diviner/Config.ts +13 -0
- package/src/Subtotal/Diviner/Params.ts +8 -0
- package/src/Subtotal/Diviner/Payload.ts +33 -0
- package/src/Subtotal/Diviner/index.ts +3 -0
- package/src/Subtotal/index.ts +1 -0
- package/src/Total/Diviner/Config.ts +24 -0
- package/src/Total/Diviner/Params.ts +8 -0
- package/src/Total/Diviner/Payload.ts +33 -0
- package/src/Total/Diviner/index.ts +3 -0
- package/src/Total/index.ts +1 -0
- 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,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,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,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 @@
|
|
|
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 @@
|
|
|
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'
|