@classytic/revenue 1.1.4 → 2.0.1

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 +53 -0
  9. package/dist/core/state-machines.mjs +153 -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-D5X32LwX.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-DHIPx5S4.mjs +771 -0
  35. package/dist/shared/index.d.mts +2 -0
  36. package/dist/shared/index.mjs +4 -0
  37. package/dist/splits-BAfY-a9P.mjs +123 -0
  38. package/dist/subscription.enums-tfoAgsTv.mjs +172 -0
  39. package/dist/transaction.enums-u4MshXcL.d.mts +154 -0
  40. package/dist/validators/index.d.mts +2 -0
  41. package/dist/validators/index.mjs +3 -0
  42. package/package.json +37 -38
  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,53 @@
1
+ import { C as SubscriptionStatusValue, F as SplitStatusValue, K as SettlementStatusValue, f as TransactionStatusValue, it as HoldStatusValue } from "../transaction.enums-u4MshXcL.mjs";
2
+
3
+ //#region src/core/state-machines.d.ts
4
+ /**
5
+ * Audit-trail event emitted by `validateAndCreateAuditEvent`.
6
+ *
7
+ * Revenue-specific shape — primitives' state-machine is intentionally
8
+ * ledger-agnostic, so the audit envelope stays here next to the consumers.
9
+ */
10
+ interface StateChangeEvent<TState extends string = string> {
11
+ resourceType: string;
12
+ resourceId: string;
13
+ fromState: TState;
14
+ toState: TState;
15
+ changedAt: Date;
16
+ changedBy?: string;
17
+ reason?: string;
18
+ metadata?: Record<string, unknown>;
19
+ }
20
+ /**
21
+ * Revenue's typed state machine.
22
+ *
23
+ * Thin facade over `@classytic/primitives/state-machine`'s
24
+ * `defineStateMachine` — primitives owns the transition logic, revenue
25
+ * owns the API shape (`validate`, `getAllowedTransitions`,
26
+ * `validateAndCreateAuditEvent`) that the existing repos and tests
27
+ * depend on. Wires `InvalidStateTransitionError` through the primitive's
28
+ * `errorFactory` so thrown types are unchanged.
29
+ *
30
+ * The constructor still accepts `Map<TState, Set<TState>>` so existing
31
+ * instance definitions don't need to be rewritten.
32
+ */
33
+ declare class StateMachine<TState extends string> {
34
+ private readonly inner;
35
+ constructor(transitions: Map<TState, Set<TState>>, resourceType: string);
36
+ validate(from: TState, to: TState, resourceId: string): void;
37
+ canTransition(from: TState, to: TState): boolean;
38
+ getAllowedTransitions(from: TState): TState[];
39
+ isTerminalState(state: TState): boolean;
40
+ getResourceType(): string;
41
+ validateAndCreateAuditEvent(from: TState, to: TState, resourceId: string, context?: {
42
+ changedBy?: string;
43
+ reason?: string;
44
+ metadata?: Record<string, unknown>;
45
+ }): StateChangeEvent<TState>;
46
+ }
47
+ declare const TRANSACTION_STATE_MACHINE: StateMachine<TransactionStatusValue>;
48
+ declare const SUBSCRIPTION_STATE_MACHINE: StateMachine<SubscriptionStatusValue>;
49
+ declare const SETTLEMENT_STATE_MACHINE: StateMachine<SettlementStatusValue>;
50
+ declare const HOLD_STATE_MACHINE: StateMachine<HoldStatusValue>;
51
+ declare const SPLIT_STATE_MACHINE: StateMachine<SplitStatusValue>;
52
+ //#endregion
53
+ export { HOLD_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateChangeEvent, StateMachine, TRANSACTION_STATE_MACHINE };
@@ -0,0 +1,153 @@
1
+ import { F as TRANSACTION_STATUS, g as SETTLEMENT_STATUS, l as SPLIT_STATUS, r as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "../subscription.enums-tfoAgsTv.mjs";
2
+ import { r as InvalidStateTransitionError } from "../errors-DHa8JVQ-.mjs";
3
+ import { defineStateMachine } from "@classytic/primitives/state-machine";
4
+
5
+ //#region src/core/state-machines.ts
6
+ /**
7
+ * Revenue's typed state machine.
8
+ *
9
+ * Thin facade over `@classytic/primitives/state-machine`'s
10
+ * `defineStateMachine` — primitives owns the transition logic, revenue
11
+ * owns the API shape (`validate`, `getAllowedTransitions`,
12
+ * `validateAndCreateAuditEvent`) that the existing repos and tests
13
+ * depend on. Wires `InvalidStateTransitionError` through the primitive's
14
+ * `errorFactory` so thrown types are unchanged.
15
+ *
16
+ * The constructor still accepts `Map<TState, Set<TState>>` so existing
17
+ * instance definitions don't need to be rewritten.
18
+ */
19
+ var StateMachine = class {
20
+ inner;
21
+ constructor(transitions, resourceType) {
22
+ const record = {};
23
+ for (const [from, toSet] of transitions.entries()) record[from] = Array.from(toSet);
24
+ this.inner = defineStateMachine({
25
+ name: resourceType,
26
+ transitions: record,
27
+ errorFactory: ({ entityId, from, to }) => new InvalidStateTransitionError(resourceType, entityId, from, to)
28
+ });
29
+ }
30
+ validate(from, to, resourceId) {
31
+ this.inner.assertTransition(resourceId, from, to);
32
+ }
33
+ canTransition(from, to) {
34
+ return this.inner.canTransition(from, to);
35
+ }
36
+ getAllowedTransitions(from) {
37
+ return [...this.inner.transitions[from] ?? []];
38
+ }
39
+ isTerminalState(state) {
40
+ return this.inner.isTerminal(state);
41
+ }
42
+ getResourceType() {
43
+ return this.inner.name;
44
+ }
45
+ validateAndCreateAuditEvent(from, to, resourceId, context) {
46
+ this.validate(from, to, resourceId);
47
+ return {
48
+ resourceType: this.inner.name,
49
+ resourceId,
50
+ fromState: from,
51
+ toState: to,
52
+ changedAt: /* @__PURE__ */ new Date(),
53
+ changedBy: context?.changedBy,
54
+ reason: context?.reason,
55
+ metadata: context?.metadata
56
+ };
57
+ }
58
+ };
59
+ const TRANSACTION_STATE_MACHINE = new StateMachine(new Map([
60
+ [TRANSACTION_STATUS.PENDING, new Set([
61
+ TRANSACTION_STATUS.PAYMENT_INITIATED,
62
+ TRANSACTION_STATUS.PROCESSING,
63
+ TRANSACTION_STATUS.VERIFIED,
64
+ TRANSACTION_STATUS.FAILED,
65
+ TRANSACTION_STATUS.CANCELLED
66
+ ])],
67
+ [TRANSACTION_STATUS.PAYMENT_INITIATED, new Set([
68
+ TRANSACTION_STATUS.PROCESSING,
69
+ TRANSACTION_STATUS.VERIFIED,
70
+ TRANSACTION_STATUS.REQUIRES_ACTION,
71
+ TRANSACTION_STATUS.FAILED,
72
+ TRANSACTION_STATUS.CANCELLED
73
+ ])],
74
+ [TRANSACTION_STATUS.PROCESSING, new Set([
75
+ TRANSACTION_STATUS.VERIFIED,
76
+ TRANSACTION_STATUS.REQUIRES_ACTION,
77
+ TRANSACTION_STATUS.FAILED
78
+ ])],
79
+ [TRANSACTION_STATUS.REQUIRES_ACTION, new Set([
80
+ TRANSACTION_STATUS.VERIFIED,
81
+ TRANSACTION_STATUS.FAILED,
82
+ TRANSACTION_STATUS.CANCELLED,
83
+ TRANSACTION_STATUS.EXPIRED
84
+ ])],
85
+ [TRANSACTION_STATUS.VERIFIED, new Set([
86
+ TRANSACTION_STATUS.COMPLETED,
87
+ TRANSACTION_STATUS.REFUNDED,
88
+ TRANSACTION_STATUS.PARTIALLY_REFUNDED,
89
+ TRANSACTION_STATUS.CANCELLED
90
+ ])],
91
+ [TRANSACTION_STATUS.COMPLETED, new Set([TRANSACTION_STATUS.REFUNDED, TRANSACTION_STATUS.PARTIALLY_REFUNDED])],
92
+ [TRANSACTION_STATUS.PARTIALLY_REFUNDED, new Set([TRANSACTION_STATUS.REFUNDED])],
93
+ [TRANSACTION_STATUS.FAILED, /* @__PURE__ */ new Set([])],
94
+ [TRANSACTION_STATUS.REFUNDED, /* @__PURE__ */ new Set([])],
95
+ [TRANSACTION_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
96
+ [TRANSACTION_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
97
+ ]), "transaction");
98
+ const SUBSCRIPTION_STATE_MACHINE = new StateMachine(new Map([
99
+ [SUBSCRIPTION_STATUS.PENDING, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
100
+ [SUBSCRIPTION_STATUS.ACTIVE, new Set([
101
+ SUBSCRIPTION_STATUS.PAUSED,
102
+ SUBSCRIPTION_STATUS.PENDING_RENEWAL,
103
+ SUBSCRIPTION_STATUS.CANCELLED,
104
+ SUBSCRIPTION_STATUS.EXPIRED
105
+ ])],
106
+ [SUBSCRIPTION_STATUS.PENDING_RENEWAL, new Set([
107
+ SUBSCRIPTION_STATUS.ACTIVE,
108
+ SUBSCRIPTION_STATUS.CANCELLED,
109
+ SUBSCRIPTION_STATUS.EXPIRED
110
+ ])],
111
+ [SUBSCRIPTION_STATUS.PAUSED, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
112
+ [SUBSCRIPTION_STATUS.INACTIVE, new Set([SUBSCRIPTION_STATUS.ACTIVE, SUBSCRIPTION_STATUS.CANCELLED])],
113
+ [SUBSCRIPTION_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
114
+ [SUBSCRIPTION_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
115
+ ]), "subscription");
116
+ const SETTLEMENT_STATE_MACHINE = new StateMachine(new Map([
117
+ [SETTLEMENT_STATUS.PENDING, new Set([SETTLEMENT_STATUS.PROCESSING, SETTLEMENT_STATUS.CANCELLED])],
118
+ [SETTLEMENT_STATUS.PROCESSING, new Set([SETTLEMENT_STATUS.COMPLETED, SETTLEMENT_STATUS.FAILED])],
119
+ [SETTLEMENT_STATUS.FAILED, new Set([SETTLEMENT_STATUS.PENDING, SETTLEMENT_STATUS.CANCELLED])],
120
+ [SETTLEMENT_STATUS.COMPLETED, /* @__PURE__ */ new Set([])],
121
+ [SETTLEMENT_STATUS.CANCELLED, /* @__PURE__ */ new Set([])]
122
+ ]), "settlement");
123
+ const HOLD_STATE_MACHINE = new StateMachine(new Map([
124
+ [HOLD_STATUS.HELD, new Set([
125
+ HOLD_STATUS.RELEASED,
126
+ HOLD_STATUS.PARTIALLY_RELEASED,
127
+ HOLD_STATUS.CANCELLED,
128
+ HOLD_STATUS.EXPIRED
129
+ ])],
130
+ [HOLD_STATUS.PARTIALLY_RELEASED, new Set([HOLD_STATUS.RELEASED, HOLD_STATUS.CANCELLED])],
131
+ [HOLD_STATUS.RELEASED, /* @__PURE__ */ new Set([])],
132
+ [HOLD_STATUS.CANCELLED, /* @__PURE__ */ new Set([])],
133
+ [HOLD_STATUS.EXPIRED, /* @__PURE__ */ new Set([])]
134
+ ]), "escrow_hold");
135
+ const SPLIT_STATE_MACHINE = new StateMachine(new Map([
136
+ [SPLIT_STATUS.PENDING, new Set([
137
+ SPLIT_STATUS.DUE,
138
+ SPLIT_STATUS.PAID,
139
+ SPLIT_STATUS.WAIVED,
140
+ SPLIT_STATUS.CANCELLED
141
+ ])],
142
+ [SPLIT_STATUS.DUE, new Set([
143
+ SPLIT_STATUS.PAID,
144
+ SPLIT_STATUS.WAIVED,
145
+ SPLIT_STATUS.CANCELLED
146
+ ])],
147
+ [SPLIT_STATUS.PAID, /* @__PURE__ */ new Set([])],
148
+ [SPLIT_STATUS.WAIVED, /* @__PURE__ */ new Set([])],
149
+ [SPLIT_STATUS.CANCELLED, /* @__PURE__ */ new Set([])]
150
+ ]), "split");
151
+
152
+ //#endregion
153
+ export { HOLD_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateMachine, TRANSACTION_STATE_MACHINE };