@classytic/revenue 1.1.4 → 2.0.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 (82) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +638 -632
  3. package/dist/audit-B39B0Sdq.mjs +53 -0
  4. package/dist/audit-DZ0eTr9g.d.mts +89 -0
  5. package/dist/bridges/index.d.mts +2 -0
  6. package/dist/bridges/index.mjs +1 -0
  7. package/dist/context-DRqSeTPM.d.mts +35 -0
  8. package/dist/core/state-machines.d.mts +35 -0
  9. package/dist/core/state-machines.mjs +134 -0
  10. package/dist/engine-types-CcjIb4Fy.d.mts +611 -0
  11. package/dist/enums/index.d.mts +3 -157
  12. package/dist/enums/index.mjs +3 -55
  13. package/dist/errors-DHa8JVQ-.mjs +92 -0
  14. package/dist/escrow.schema-BBv9oVEW.mjs +322 -0
  15. package/dist/escrow.schema-CC8XuD46.d.mts +629 -0
  16. package/dist/event-constants-CEMitnIV.mjs +53 -0
  17. package/dist/events/index.d.mts +3 -0
  18. package/dist/events/index.mjs +4 -0
  19. package/dist/index.d.mts +77 -9
  20. package/dist/index.mjs +465 -29
  21. package/dist/monetization.enums-BtiU3t8o.mjs +39 -0
  22. package/dist/monetization.enums-D2xbxXJM.d.mts +34 -0
  23. package/dist/plugins/plugin.interface.d.mts +28 -0
  24. package/dist/plugins/plugin.interface.mjs +26 -0
  25. package/dist/providers/index.d.mts +2 -3
  26. package/dist/providers/index.mjs +2 -2
  27. package/dist/{base-DCoyIUj6.mjs → registry-DhFMsSn5.mjs} +34 -36
  28. package/dist/{base-CsTlVQJe.d.mts → registry-SvIGPAx_.d.mts} +73 -66
  29. package/dist/repositories/create-repositories.d.mts +21 -0
  30. package/dist/repositories/create-repositories.mjs +12 -0
  31. package/dist/revenue-bridges-sdlrR85c.d.mts +145 -0
  32. package/dist/revenue-event-catalog-BX3g7RUi.d.mts +823 -0
  33. package/dist/revenue-event-catalog-LqxPnsU_.mjs +388 -0
  34. package/dist/settlement.repository-Cy3mMWGH.mjs +771 -0
  35. package/dist/shared/index.d.mts +2 -0
  36. package/dist/shared/index.mjs +4 -0
  37. package/dist/split.enums-CQE3ekH1.mjs +172 -0
  38. package/dist/split.enums-Dw4zCrcZ.d.mts +154 -0
  39. package/dist/splits-BAfY-a9P.mjs +123 -0
  40. package/dist/validators/index.d.mts +2 -0
  41. package/dist/validators/index.mjs +3 -0
  42. package/package.json +33 -37
  43. package/dist/application/services/index.d.mts +0 -4
  44. package/dist/application/services/index.mjs +0 -3
  45. package/dist/category-resolver-DV83N8ok.mjs +0 -284
  46. package/dist/commission-split-BzB8cd39.mjs +0 -485
  47. package/dist/core/events.d.mts +0 -294
  48. package/dist/core/events.mjs +0 -100
  49. package/dist/core/index.d.mts +0 -9
  50. package/dist/core/index.mjs +0 -8
  51. package/dist/errors-rRdOqnWx.d.mts +0 -787
  52. package/dist/escrow.enums-CZGrrdg7.mjs +0 -101
  53. package/dist/escrow.enums-DwdLuuve.d.mts +0 -78
  54. package/dist/idempotency-DaYcUGY1.mjs +0 -172
  55. package/dist/index-Dsp7H5Wb.d.mts +0 -471
  56. package/dist/infrastructure/plugins/index.d.mts +0 -239
  57. package/dist/infrastructure/plugins/index.mjs +0 -345
  58. package/dist/money-CvrDOijQ.mjs +0 -271
  59. package/dist/money-DPG8AtJ8.d.mts +0 -112
  60. package/dist/payment.enums-HAuAS9Pp.d.mts +0 -70
  61. package/dist/payment.enums-tEFVa-Xp.mjs +0 -69
  62. package/dist/plugin-BbK0OVHy.d.mts +0 -327
  63. package/dist/plugin-Cd_V04Em.mjs +0 -210
  64. package/dist/reconciliation/index.d.mts +0 -193
  65. package/dist/reconciliation/index.mjs +0 -192
  66. package/dist/retry-HHCOXYdn.d.mts +0 -186
  67. package/dist/revenue-BhdS7nXh.mjs +0 -553
  68. package/dist/schemas/index.d.mts +0 -2665
  69. package/dist/schemas/index.mjs +0 -717
  70. package/dist/schemas/validation.d.mts +0 -375
  71. package/dist/schemas/validation.mjs +0 -325
  72. package/dist/settlement.enums-DFhkqZEY.d.mts +0 -132
  73. package/dist/settlement.schema-DnNSFpGd.d.mts +0 -344
  74. package/dist/settlement.service-DjzAjezU.d.mts +0 -594
  75. package/dist/settlement.service-DmdKv0Zu.mjs +0 -2511
  76. package/dist/split.enums-BrjabxIX.mjs +0 -86
  77. package/dist/split.enums-DmskfLOM.d.mts +0 -43
  78. package/dist/tax-BoCt5cEd.d.mts +0 -61
  79. package/dist/tax-EQ15DO81.mjs +0 -162
  80. package/dist/transaction.enums-pCyMFT4Z.mjs +0 -96
  81. package/dist/utils/index.d.mts +0 -428
  82. package/dist/utils/index.mjs +0 -346
@@ -0,0 +1,53 @@
1
+ import { CurrencyMismatchError, absMoney, addMoney, compareMoney, equalsMoney, fromMajor, fromMajor as fromMajor$1, isMoney, isNegativeMoney, isPositiveMoney, isZeroMoney, money, money as money$1, multiplyMoney, negateMoney, subtractMoney, sumMoney, toMajor, toMajor as toMajor$1 } from "@classytic/primitives/money";
2
+ import { CURRENCIES, MINOR_UNIT_FACTOR, isCurrencyCode, minorUnitFactor, toCurrencyCode } from "@classytic/primitives/currency";
3
+
4
+ //#region src/shared/formatters/money.ts
5
+ /**
6
+ * Money — re-export from `@classytic/primitives/money`.
7
+ *
8
+ * Per PACKAGE_RULES P1/P12: `Money`, arithmetic, and currency metadata all
9
+ * live in primitives. Revenue does NOT redefine them. This file re-exports
10
+ * the canonical surface so hosts can still do
11
+ * `import { Money, money, addMoney } from '@classytic/revenue'` without
12
+ * adding primitives as a direct dependency.
13
+ *
14
+ * `toSmallestUnit` / `fromSmallestUnit` are thin wrappers over
15
+ * `fromMajor` / `toMajor` kept for downstream compatibility (be-prod's
16
+ * `operational-transactions.ts` imports them).
17
+ */
18
+ /**
19
+ * Convert a major-unit amount (e.g. 19.99 dollars) into the currency's
20
+ * minor unit integer (e.g. 1999 cents). Wrapper over primitives' `fromMajor`.
21
+ */
22
+ function toSmallestUnit(amount, currency = "USD") {
23
+ return fromMajor(amount, currency).amount;
24
+ }
25
+ /**
26
+ * Convert a minor-unit integer (e.g. 1999 cents) back to its major-unit
27
+ * representation (e.g. 19.99). Wrapper over primitives' `toMajor`.
28
+ */
29
+ function fromSmallestUnit(amount, currency = "USD") {
30
+ return toMajor(money(amount, currency));
31
+ }
32
+
33
+ //#endregion
34
+ //#region src/shared/audit.ts
35
+ function appendAuditEvent(doc, event) {
36
+ const metadata = doc.metadata ?? {};
37
+ const auditTrail = metadata.auditTrail ?? [];
38
+ auditTrail.push(event);
39
+ return { metadata: {
40
+ ...metadata,
41
+ auditTrail
42
+ } };
43
+ }
44
+ function getAuditTrail(doc) {
45
+ return doc.metadata?.auditTrail ?? [];
46
+ }
47
+ function getLastStateChange(doc) {
48
+ const trail = getAuditTrail(doc);
49
+ return trail[trail.length - 1];
50
+ }
51
+
52
+ //#endregion
53
+ export { sumMoney as C, toSmallestUnit as E, subtractMoney as S, toMajor$1 as T, isZeroMoney as _, CurrencyMismatchError as a, multiplyMoney as b, addMoney as c, fromMajor$1 as d, fromSmallestUnit as f, isPositiveMoney as g, isNegativeMoney as h, CURRENCIES as i, compareMoney as l, isMoney as m, getAuditTrail as n, MINOR_UNIT_FACTOR as o, isCurrencyCode as p, getLastStateChange as r, absMoney as s, appendAuditEvent as t, equalsMoney as u, minorUnitFactor as v, toCurrencyCode as w, negateMoney as x, money$1 as y };
@@ -0,0 +1,89 @@
1
+ import { StateChangeEvent } from "./core/state-machines.mjs";
2
+ import { CurrencyMismatchError, Money, Money as MoneyValue, absMoney, addMoney, compareMoney, equalsMoney, fromMajor as fromMajor$1, isMoney, isNegativeMoney, isPositiveMoney, isZeroMoney, money as money$1, multiplyMoney, negateMoney, subtractMoney, sumMoney, toMajor as toMajor$1 } from "@classytic/primitives/money";
3
+ import { CURRENCIES, CurrencyCode, MINOR_UNIT_FACTOR, isCurrencyCode, minorUnitFactor, toCurrencyCode } from "@classytic/primitives/currency";
4
+
5
+ //#region src/shared/calculators/commission.d.ts
6
+ interface CommissionInfo {
7
+ rate: number;
8
+ grossAmount: number;
9
+ gatewayFeeRate: number;
10
+ gatewayFeeAmount: number;
11
+ netAmount: number;
12
+ status: string;
13
+ }
14
+ declare function calculateCommission(amount: number, commissionRate: number, gatewayFeeRate?: number): CommissionInfo | null;
15
+ declare function reverseCommission(originalCommission: CommissionInfo | null | undefined, originalAmount: number, refundAmount: number): CommissionInfo | null;
16
+ //#endregion
17
+ //#region src/shared/calculators/tax.d.ts
18
+ interface TaxConfig {
19
+ isRegistered: boolean;
20
+ defaultRate: number;
21
+ pricesIncludeTax: boolean;
22
+ exemptCategories?: string[];
23
+ }
24
+ interface TaxCalculation {
25
+ isApplicable: boolean;
26
+ rate: number;
27
+ baseAmount: number;
28
+ taxAmount: number;
29
+ totalAmount: number;
30
+ pricesIncludeTax: boolean;
31
+ type?: TaxType;
32
+ }
33
+ type TaxType = 'collected' | 'paid' | 'exempt';
34
+ declare function calculateTax(amount: number, category: string, config: TaxConfig | null): TaxCalculation;
35
+ declare function getTaxType(transactionFlow: 'inflow' | 'outflow', category: string, exemptCategories?: string[]): TaxType;
36
+ declare function reverseTax(originalTax: TaxCalculation & {
37
+ type?: TaxType;
38
+ }, originalAmount: number, refundAmount: number): TaxCalculation & {
39
+ type?: TaxType;
40
+ };
41
+ declare function validateTaxCalculation(tax: TaxCalculation): boolean;
42
+ //#endregion
43
+ //#region src/shared/calculators/splits.d.ts
44
+ interface SplitRule {
45
+ type: string;
46
+ recipientId: string;
47
+ recipientType: string;
48
+ rate: number;
49
+ }
50
+ interface SplitInfo {
51
+ type: string;
52
+ recipientId: string;
53
+ recipientType: string;
54
+ rate: number;
55
+ grossAmount: number;
56
+ gatewayFeeRate: number;
57
+ gatewayFeeAmount: number;
58
+ netAmount: number;
59
+ status: string;
60
+ }
61
+ declare function calculateSplits(amount: number, rules: SplitRule[], gatewayFeeRate?: number): SplitInfo[];
62
+ declare function calculateOrganizationPayout(amount: number, splits: SplitInfo[]): number;
63
+ //#endregion
64
+ //#region src/shared/formatters/money.d.ts
65
+ /**
66
+ * Convert a major-unit amount (e.g. 19.99 dollars) into the currency's
67
+ * minor unit integer (e.g. 1999 cents). Wrapper over primitives' `fromMajor`.
68
+ */
69
+ declare function toSmallestUnit(amount: number, currency?: string): number;
70
+ /**
71
+ * Convert a minor-unit integer (e.g. 1999 cents) back to its major-unit
72
+ * representation (e.g. 19.99). Wrapper over primitives' `toMajor`.
73
+ */
74
+ declare function fromSmallestUnit(amount: number, currency?: string): number;
75
+ //#endregion
76
+ //#region src/shared/audit.d.ts
77
+ declare function appendAuditEvent<T extends {
78
+ metadata?: Record<string, unknown>;
79
+ }>(doc: T, event: StateChangeEvent): {
80
+ metadata: Record<string, unknown>;
81
+ };
82
+ declare function getAuditTrail(doc: {
83
+ metadata?: Record<string, unknown>;
84
+ }): StateChangeEvent[];
85
+ declare function getLastStateChange(doc: {
86
+ metadata?: Record<string, unknown>;
87
+ }): StateChangeEvent | undefined;
88
+ //#endregion
89
+ export { SplitInfo as A, validateTaxCalculation as B, multiplyMoney as C, toCurrencyCode as D, sumMoney as E, TaxConfig as F, calculateCommission as H, TaxType as I, calculateTax as L, calculateOrganizationPayout as M, calculateSplits as N, toMajor$1 as O, TaxCalculation as P, getTaxType as R, money$1 as S, subtractMoney as T, reverseCommission as U, CommissionInfo as V, isMoney as _, CurrencyCode as a, isZeroMoney as b, Money as c, addMoney as d, compareMoney as f, isCurrencyCode as g, fromSmallestUnit as h, CURRENCIES as i, SplitRule as j, toSmallestUnit as k, MoneyValue as l, fromMajor$1 as m, getAuditTrail as n, CurrencyMismatchError as o, equalsMoney as p, getLastStateChange as r, MINOR_UNIT_FACTOR as s, appendAuditEvent as t, absMoney as u, isNegativeMoney as v, negateMoney as w, minorUnitFactor as x, isPositiveMoney as y, reverseTax as z };
@@ -0,0 +1,2 @@
1
+ import { a as CurrencyBridge, c as LedgerBridge, i as CustomerBridge, n as SourceBridge, o as NotificationBridge, r as AnalyticsBridge, s as TaxBridge, t as RevenueBridges } from "../revenue-bridges-sdlrR85c.mjs";
2
+ export { type AnalyticsBridge, type CurrencyBridge, type CustomerBridge, type LedgerBridge, type NotificationBridge, type RevenueBridges, type SourceBridge, type TaxBridge };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,35 @@
1
+ import { OperationContext } from "@classytic/primitives/context";
2
+
3
+ //#region src/core/context.d.ts
4
+ interface RevenueContext extends OperationContext {
5
+ /** Narrowed from primitives' `IdLike` to string. */
6
+ organizationId?: string;
7
+ /** Narrowed from primitives' `IdLike` to string. */
8
+ actorId?: string;
9
+ /** Actor roles for permission checks at the consumer level. */
10
+ roles?: string[];
11
+ /** Override currency for this operation. */
12
+ currency?: string;
13
+ /** Bridge-specific free-form context. */
14
+ custom?: Record<string, unknown>;
15
+ /**
16
+ * Platform-admin bypass for tenant scoping.
17
+ *
18
+ * When `true`, the `multiTenantPlugin` wired by `createRevenue` skips
19
+ * injecting the tenant filter/data field for this single call — so
20
+ * `repo.getAll({}, { _bypassTenant: true })` can span organizations for
21
+ * superadmin dashboards, audits, and cross-branch reports.
22
+ *
23
+ * **The repo does NOT authorize this flag.** Setting it is the caller's
24
+ * responsibility and MUST be gated behind a platform-role check at the
25
+ * route/service layer. Never forward this flag from untrusted input.
26
+ *
27
+ * Events, validation, soft-delete, and pagination all continue to fire —
28
+ * only the tenant policy is bypassed. Write paths (create/update/delete)
29
+ * still pick up `organizationId` from `ctx.organizationId` if provided,
30
+ * so cross-org mutations require an explicit per-doc tenant in `data`.
31
+ */
32
+ _bypassTenant?: boolean;
33
+ }
34
+ //#endregion
35
+ export { RevenueContext as t };
@@ -0,0 +1,35 @@
1
+ import { C as HoldStatusValue, I as SettlementStatusValue, J as SubscriptionStatusValue, ct as TransactionStatusValue, u as SplitStatusValue } from "../split.enums-Dw4zCrcZ.mjs";
2
+
3
+ //#region src/core/state-machines.d.ts
4
+ interface StateChangeEvent<TState extends string = string> {
5
+ resourceType: string;
6
+ resourceId: string;
7
+ fromState: TState;
8
+ toState: TState;
9
+ changedAt: Date;
10
+ changedBy?: string;
11
+ reason?: string;
12
+ metadata?: Record<string, unknown>;
13
+ }
14
+ declare class StateMachine<TState extends string> {
15
+ private readonly transitions;
16
+ private readonly resourceType;
17
+ constructor(transitions: Map<TState, Set<TState>>, resourceType: string);
18
+ validate(from: TState, to: TState, resourceId: string): void;
19
+ canTransition(from: TState, to: TState): boolean;
20
+ getAllowedTransitions(from: TState): TState[];
21
+ isTerminalState(state: TState): boolean;
22
+ getResourceType(): string;
23
+ validateAndCreateAuditEvent(from: TState, to: TState, resourceId: string, context?: {
24
+ changedBy?: string;
25
+ reason?: string;
26
+ metadata?: Record<string, unknown>;
27
+ }): StateChangeEvent<TState>;
28
+ }
29
+ declare const TRANSACTION_STATE_MACHINE: StateMachine<TransactionStatusValue>;
30
+ declare const SUBSCRIPTION_STATE_MACHINE: StateMachine<SubscriptionStatusValue>;
31
+ declare const SETTLEMENT_STATE_MACHINE: StateMachine<SettlementStatusValue>;
32
+ declare const HOLD_STATE_MACHINE: StateMachine<HoldStatusValue>;
33
+ declare const SPLIT_STATE_MACHINE: StateMachine<SplitStatusValue>;
34
+ //#endregion
35
+ export { HOLD_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateChangeEvent, StateMachine, TRANSACTION_STATE_MACHINE };
@@ -0,0 +1,134 @@
1
+ import { F as TRANSACTION_STATUS, r as SPLIT_STATUS, u as SETTLEMENT_STATUS, v as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "../split.enums-CQE3ekH1.mjs";
2
+ import { r as InvalidStateTransitionError } from "../errors-DHa8JVQ-.mjs";
3
+
4
+ //#region src/core/state-machines.ts
5
+ var StateMachine = class {
6
+ constructor(transitions, resourceType) {
7
+ this.transitions = transitions;
8
+ this.resourceType = resourceType;
9
+ }
10
+ validate(from, to, resourceId) {
11
+ if (!this.transitions.get(from)?.has(to)) throw new InvalidStateTransitionError(this.resourceType, resourceId, from, to);
12
+ }
13
+ canTransition(from, to) {
14
+ return this.transitions.get(from)?.has(to) ?? false;
15
+ }
16
+ getAllowedTransitions(from) {
17
+ return Array.from(this.transitions.get(from) ?? []);
18
+ }
19
+ isTerminalState(state) {
20
+ const t = this.transitions.get(state);
21
+ return !t || t.size === 0;
22
+ }
23
+ getResourceType() {
24
+ return this.resourceType;
25
+ }
26
+ validateAndCreateAuditEvent(from, to, resourceId, context) {
27
+ this.validate(from, to, resourceId);
28
+ return {
29
+ resourceType: this.resourceType,
30
+ resourceId,
31
+ fromState: from,
32
+ toState: to,
33
+ changedAt: /* @__PURE__ */ new Date(),
34
+ changedBy: context?.changedBy,
35
+ reason: context?.reason,
36
+ metadata: context?.metadata
37
+ };
38
+ }
39
+ };
40
+ const TRANSACTION_STATE_MACHINE = new StateMachine(new Map([
41
+ [TRANSACTION_STATUS.PENDING, new Set([
42
+ TRANSACTION_STATUS.PAYMENT_INITIATED,
43
+ TRANSACTION_STATUS.PROCESSING,
44
+ TRANSACTION_STATUS.VERIFIED,
45
+ TRANSACTION_STATUS.FAILED,
46
+ TRANSACTION_STATUS.CANCELLED
47
+ ])],
48
+ [TRANSACTION_STATUS.PAYMENT_INITIATED, new Set([
49
+ TRANSACTION_STATUS.PROCESSING,
50
+ TRANSACTION_STATUS.VERIFIED,
51
+ TRANSACTION_STATUS.REQUIRES_ACTION,
52
+ TRANSACTION_STATUS.FAILED,
53
+ TRANSACTION_STATUS.CANCELLED
54
+ ])],
55
+ [TRANSACTION_STATUS.PROCESSING, new Set([
56
+ TRANSACTION_STATUS.VERIFIED,
57
+ TRANSACTION_STATUS.REQUIRES_ACTION,
58
+ TRANSACTION_STATUS.FAILED
59
+ ])],
60
+ [TRANSACTION_STATUS.REQUIRES_ACTION, new Set([
61
+ TRANSACTION_STATUS.VERIFIED,
62
+ TRANSACTION_STATUS.FAILED,
63
+ TRANSACTION_STATUS.CANCELLED,
64
+ TRANSACTION_STATUS.EXPIRED
65
+ ])],
66
+ [TRANSACTION_STATUS.VERIFIED, new Set([
67
+ TRANSACTION_STATUS.COMPLETED,
68
+ TRANSACTION_STATUS.REFUNDED,
69
+ TRANSACTION_STATUS.PARTIALLY_REFUNDED,
70
+ TRANSACTION_STATUS.CANCELLED
71
+ ])],
72
+ [TRANSACTION_STATUS.COMPLETED, new Set([TRANSACTION_STATUS.REFUNDED, TRANSACTION_STATUS.PARTIALLY_REFUNDED])],
73
+ [TRANSACTION_STATUS.PARTIALLY_REFUNDED, new Set([TRANSACTION_STATUS.REFUNDED])],
74
+ [TRANSACTION_STATUS.FAILED, /* @__PURE__ */ new Set([])],
75
+ [TRANSACTION_STATUS.REFUNDED, /* @__PURE__ */ new Set([])],
76
+ [TRANSACTION_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
77
+ [TRANSACTION_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
78
+ ]), "transaction");
79
+ const SUBSCRIPTION_STATE_MACHINE = new StateMachine(new Map([
80
+ [SUBSCRIPTION_STATUS.PENDING, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
81
+ [SUBSCRIPTION_STATUS.ACTIVE, new Set([
82
+ SUBSCRIPTION_STATUS.PAUSED,
83
+ SUBSCRIPTION_STATUS.PENDING_RENEWAL,
84
+ SUBSCRIPTION_STATUS.CANCELLED,
85
+ SUBSCRIPTION_STATUS.EXPIRED
86
+ ])],
87
+ [SUBSCRIPTION_STATUS.PENDING_RENEWAL, new Set([
88
+ SUBSCRIPTION_STATUS.ACTIVE,
89
+ SUBSCRIPTION_STATUS.CANCELLED,
90
+ SUBSCRIPTION_STATUS.EXPIRED
91
+ ])],
92
+ [SUBSCRIPTION_STATUS.PAUSED, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
93
+ [SUBSCRIPTION_STATUS.INACTIVE, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
94
+ [SUBSCRIPTION_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
95
+ [SUBSCRIPTION_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
96
+ ]), "subscription");
97
+ const SETTLEMENT_STATE_MACHINE = new StateMachine(new Map([
98
+ [SETTLEMENT_STATUS.PENDING, new Set([SETTLEMENT_STATUS.PROCESSING, SETTLEMENT_STATUS.CANCELLED])],
99
+ [SETTLEMENT_STATUS.PROCESSING, new Set([SETTLEMENT_STATUS.COMPLETED, SETTLEMENT_STATUS.FAILED])],
100
+ [SETTLEMENT_STATUS.FAILED, new Set([SETTLEMENT_STATUS.PENDING, SETTLEMENT_STATUS.CANCELLED])],
101
+ [SETTLEMENT_STATUS.COMPLETED, /* @__PURE__ */ new Set([])],
102
+ [SETTLEMENT_STATUS.CANCELLED, /* @__PURE__ */ new Set([])]
103
+ ]), "settlement");
104
+ const HOLD_STATE_MACHINE = new StateMachine(new Map([
105
+ [HOLD_STATUS.HELD, new Set([
106
+ HOLD_STATUS.RELEASED,
107
+ HOLD_STATUS.PARTIALLY_RELEASED,
108
+ HOLD_STATUS.CANCELLED,
109
+ HOLD_STATUS.EXPIRED
110
+ ])],
111
+ [HOLD_STATUS.PARTIALLY_RELEASED, new Set([HOLD_STATUS.RELEASED, HOLD_STATUS.CANCELLED])],
112
+ [HOLD_STATUS.RELEASED, /* @__PURE__ */ new Set([])],
113
+ [HOLD_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
114
+ [HOLD_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
115
+ ]), "escrow_hold");
116
+ const SPLIT_STATE_MACHINE = new StateMachine(new Map([
117
+ [SPLIT_STATUS.PENDING, new Set([
118
+ SPLIT_STATUS.DUE,
119
+ SPLIT_STATUS.PAID,
120
+ SPLIT_STATUS.WAIVED,
121
+ SPLIT_STATUS.CANCELLED
122
+ ])],
123
+ [SPLIT_STATUS.DUE, new Set([
124
+ SPLIT_STATUS.PAID,
125
+ SPLIT_STATUS.WAIVED,
126
+ SPLIT_STATUS.CANCELLED
127
+ ])],
128
+ [SPLIT_STATUS.PAID, /* @__PURE__ */ new Set([])],
129
+ [SPLIT_STATUS.WAIVED, /* @__PURE__ */ new Set([])],
130
+ [SPLIT_STATUS.CANCELLED, /* @__PURE__ */ new Set([])]
131
+ ]), "split");
132
+
133
+ //#endregion
134
+ export { HOLD_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateMachine, TRANSACTION_STATE_MACHINE };