@xyo-network/payment-plugin 4.1.0 → 4.2.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.
@@ -1,88 +1,5 @@
1
- import { Address, Hash } from '@xylabs/hex';
2
- import { ArchivistInstance } from '@xyo-network/archivist-model';
3
- import { AbstractDiviner } from '@xyo-network/diviner-abstract';
4
- import { HashLeaseEstimate } from '@xyo-network/diviner-hash-lease';
5
- import { DivinerModuleEventData, DivinerInstance } from '@xyo-network/diviner-model';
6
- import { Payload } from '@xyo-network/payload-model';
7
- import { EscrowTerms, Coupon, PaymentDiscountDivinerParams, Discount, Condition, Invoice, PaymentSubtotalDivinerParams, Subtotal, PaymentTotalDivinerParams, Total, PaymentTotalDivinerConfigSchema } from '@xyo-network/payment-payload-plugins';
8
-
9
- type PaymentDiscountDivinerInputType = EscrowTerms | Coupon | HashLeaseEstimate | Payload;
10
- declare class PaymentDiscountDiviner<TParams extends PaymentDiscountDivinerParams = PaymentDiscountDivinerParams, TIn extends PaymentDiscountDivinerInputType = PaymentDiscountDivinerInputType, TOut extends Discount = Discount, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
11
- static readonly configSchemas: string[];
12
- static readonly defaultConfigSchema = "network.xyo.diviner.payments.discount.config";
13
- protected get couponAuthorities(): Address[];
14
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
15
- /**
16
- * Filters the supplied list of coupons to only those that are signed by
17
- * addresses specified in the couponAuthorities
18
- * @param coupons The list of coupons to filter
19
- * @returns The filtered list of coupons that are signed by the couponAuthorities
20
- */
21
- protected filterToSigned(coupons: Coupon[]): Promise<Coupon[]>;
22
- protected getDiscountsArchivist(): Promise<ArchivistInstance>;
23
- protected getDiscountsBoundWitnessDiviner(): Promise<DivinerInstance>;
24
- /**
25
- * Finds the appraisals specified by the escrow terms from the supplied payloads
26
- * @param terms The escrow terms
27
- * @param payloads The payloads to search for the appraisals
28
- * @returns The appraisals found in the payloads
29
- */
30
- protected getEscrowAppraisals(terms: EscrowTerms, hashMap: Record<Hash, Payload>): HashLeaseEstimate[];
31
- /**
32
- * Finds the discounts specified by the escrow terms from the supplied payloads
33
- * @param terms The escrow terms
34
- * @param hashMap The payloads to search for the discounts
35
- * @returns A tuple containing all the escrow coupons and conditions referenced in those coupons
36
- * that were found in the either the supplied payloads or the archivist
37
- */
38
- protected getEscrowDiscounts(terms: EscrowTerms, hashMap: Record<Hash, Payload>): Promise<[Coupon[], Condition[]]>;
39
- protected isCouponCurrent(coupon: Coupon): boolean;
40
- }
41
-
42
- declare const applyCoupons: (appraisals: HashLeaseEstimate[], coupons: Coupon[]) => Discount;
43
-
44
- /**
45
- * Validates the conditions of a coupon against the provided payloads
46
- * @param coupon The coupon to check
47
- * @param conditions The conditions associated with the coupon
48
- * @param payloads The associated payloads (containing the conditions and data to validate the conditions against)
49
- * @returns True if all conditions are fulfilled, false otherwise
50
- */
51
- declare const areConditionsFulfilled: (coupon: Coupon, conditions?: Condition[], payloads?: Payload[]) => Promise<boolean>;
52
- /**
53
- * Validates the conditions of a coupon against the provided payloads
54
- * @param coupon The coupon to check
55
- * @param conditions The conditions associated with the coupon
56
- * @param payloads The associated payloads (containing the conditions and data to validate the conditions against)
57
- * @returns The unfulfilled condition hashes
58
- */
59
- declare const findUnfulfilledConditions: (coupon: Coupon, conditions?: Condition[], payloads?: Payload[]) => Promise<Hash[]>;
60
-
61
- /**
62
- * Validates the escrow terms to ensure they are valid for a purchase
63
- * @returns A payment if the terms are valid for a purchase, undefined otherwise
64
- */
65
- declare const getInvoiceForEscrow: (terms: EscrowTerms, dataHashMap: Record<Hash, Payload>, paymentTotalDiviner: DivinerInstance) => Promise<Invoice | undefined>;
66
-
67
- /**
68
- * Escrow terms that contain all the valid fields for calculating a subtotal
69
- */
70
- type PaymentSubtotalDivinerInputType = EscrowTerms | HashLeaseEstimate | Payload;
71
- declare class PaymentSubtotalDiviner<TParams extends PaymentSubtotalDivinerParams = PaymentSubtotalDivinerParams, TIn extends PaymentSubtotalDivinerInputType = PaymentSubtotalDivinerInputType, TOut extends Subtotal = Subtotal, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
72
- static readonly configSchemas: string[];
73
- static readonly defaultConfigSchema = "network.xyo.diviner.payments.subtotal.config";
74
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
75
- }
76
-
77
- type InputType = PaymentDiscountDivinerInputType | PaymentSubtotalDivinerInputType;
78
- type OutputType = Subtotal | Discount | Total;
79
- declare class PaymentTotalDiviner<TParams extends PaymentTotalDivinerParams = PaymentTotalDivinerParams, TIn extends InputType = InputType, TOut extends OutputType = OutputType, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
80
- static readonly configSchemas: string[];
81
- static readonly defaultConfigSchema: PaymentTotalDivinerConfigSchema;
82
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
83
- protected getPaymentDiscountsDiviner(): Promise<PaymentDiscountDiviner>;
84
- protected getPaymentSubtotalDiviner(): Promise<PaymentSubtotalDiviner>;
85
- }
86
-
87
- export { PaymentDiscountDiviner, PaymentSubtotalDiviner, PaymentTotalDiviner, applyCoupons, areConditionsFulfilled, findUnfulfilledConditions, getInvoiceForEscrow };
88
- export type { PaymentDiscountDivinerInputType, PaymentSubtotalDivinerInputType };
1
+ export * from './Discount/index.ts';
2
+ export * from './Invoice/index.ts';
3
+ export * from './Subtotal/index.ts';
4
+ export * from './Total/index.ts';
5
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/payment-plugin",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Typescript/Javascript Plugins for XYO Platform",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,35 +29,34 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/array": "^4.13.15",
33
- "@xylabs/assert": "^4.13.15",
34
- "@xylabs/exists": "^4.13.15",
35
- "@xylabs/hex": "^4.13.15",
36
- "@xyo-network/archivist-model": "^4.1.1",
37
- "@xyo-network/diviner-abstract": "^4.1.1",
38
- "@xyo-network/diviner-boundwitness-model": "^4.1.1",
39
- "@xyo-network/diviner-hash-lease": "^4.1.1",
40
- "@xyo-network/diviner-model": "^4.1.1",
41
- "@xyo-network/module-model": "^4.1.1",
42
- "@xyo-network/payload-builder": "^4.1.1",
43
- "@xyo-network/payload-model": "^4.1.1",
44
- "@xyo-network/payment-payload-plugins": "^4.1.0",
45
- "@xyo-network/schema-payload-plugin": "^4.1.1",
46
- "@xyo-network/xns-record-payload-plugins": "^4.1.0",
32
+ "@xylabs/array": "^4.15.1",
33
+ "@xylabs/assert": "^4.15.1",
34
+ "@xylabs/exists": "^4.15.1",
35
+ "@xylabs/hex": "^4.15.1",
36
+ "@xyo-network/archivist-model": "^4.3.0",
37
+ "@xyo-network/diviner-abstract": "^4.3.0",
38
+ "@xyo-network/diviner-boundwitness-model": "^4.3.0",
39
+ "@xyo-network/diviner-hash-lease": "^4.3.0",
40
+ "@xyo-network/diviner-model": "^4.3.0",
41
+ "@xyo-network/module-model": "^4.3.0",
42
+ "@xyo-network/payload-builder": "^4.3.0",
43
+ "@xyo-network/payload-model": "^4.3.0",
44
+ "@xyo-network/payment-payload-plugins": "^4.2.0",
45
+ "@xyo-network/schema-payload-plugin": "^4.3.0",
46
+ "@xyo-network/xns-record-payload-plugins": "^4.2.0",
47
47
  "ajv": "^8.17.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.24",
51
- "@xylabs/tsconfig": "^7.0.0-rc.24",
52
- "@xylabs/vitest-extended": "^4.13.15",
53
- "@xyo-network/archivist-memory": "^4.1.1",
54
- "@xyo-network/boundwitness-builder": "^4.1.1",
55
- "@xyo-network/diviner-boundwitness-memory": "^4.1.1",
56
- "@xyo-network/id-payload-plugin": "^4.1.1",
57
- "@xyo-network/node-memory": "^4.1.1",
58
- "@xyo-network/wallet": "^4.1.1",
59
- "@xyo-network/wallet-model": "^4.1.1",
60
- "knip": "^5.61.3",
50
+ "@xylabs/ts-scripts-yarn3": "^7.0.1",
51
+ "@xylabs/tsconfig": "^7.0.1",
52
+ "@xylabs/vitest-extended": "^4.15.1",
53
+ "@xyo-network/archivist-memory": "^4.3.0",
54
+ "@xyo-network/boundwitness-builder": "^4.3.0",
55
+ "@xyo-network/diviner-boundwitness-memory": "^4.3.0",
56
+ "@xyo-network/id-payload-plugin": "^4.3.0",
57
+ "@xyo-network/node-memory": "^4.3.0",
58
+ "@xyo-network/wallet": "^4.3.0",
59
+ "@xyo-network/wallet-model": "^4.3.0",
61
60
  "typescript": "^5.8.3",
62
61
  "vitest": "^3.2.4"
63
62
  },