@classytic/revenue 2.3.0 → 2.5.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.
- package/CHANGELOG.md +43 -0
- package/dist/{bank-feed.enums-CU38W8dv.mjs → bank-feed.enums-ByS3mjX0.mjs} +8 -4
- package/dist/{bank-feed.enums-BwJbImM6.d.mts → bank-feed.enums-CqTW2Blz.d.mts} +2 -0
- package/dist/core/state-machines.d.mts +1 -1
- package/dist/core/state-machines.mjs +13 -3
- package/dist/{engine-types-34VmC7t6.d.mts → engine-types-F3f1lWNG.d.mts} +65 -4
- package/dist/enums/index.d.mts +1 -1
- package/dist/enums/index.mjs +1 -1
- package/dist/{escrow.schema-C_UeLtsC.d.mts → escrow.schema-o4qhjOca.d.mts} +40 -40
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -2
- package/dist/providers/index.d.mts +1 -1
- package/dist/{registry-BpEeN8eW.d.mts → registry-DSG7x-Cl.d.mts} +1 -1
- package/dist/repositories/create-repositories.d.mts +1 -1
- package/dist/repositories/create-repositories.mjs +1 -1
- package/dist/{settlement.repository-CdM3myTI.mjs → settlement.repository-BDrJQc27.mjs} +112 -1
- package/dist/validators/index.d.mts +1 -1
- package/dist/validators/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,49 @@
|
|
|
3
3
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
5
|
|
|
6
|
+
## [2.5.0]
|
|
7
|
+
|
|
8
|
+
### Added — `SettlementRepository.recipientBalance()` (the seller/creator "wallet")
|
|
9
|
+
|
|
10
|
+
`recipientBalance(recipientId, { recipientType?, currency? }, ctx)` returns a
|
|
11
|
+
recipient's payout balance bucketed by settlement status —
|
|
12
|
+
`{ pending, held, available, processing, paidOut, failed, lifetime, currency }`
|
|
13
|
+
in minor units. `pending` splits into `held` (escrowed — `scheduledAt` in the
|
|
14
|
+
future) and `available` (cleared — due now), so a marketplace can show "in
|
|
15
|
+
clearance" vs "ready to pay". One tenant-scoped `aggregatePipeline` over the
|
|
16
|
+
`{ recipientId, status }` index, so hosts stop hand-rolling a raw
|
|
17
|
+
`Model.aggregate` (which bypasses multi-tenant scope).
|
|
18
|
+
|
|
19
|
+
### Added — `processPending({ recipientId })` filter
|
|
20
|
+
|
|
21
|
+
`processPending` now accepts an optional `recipientId` so a host can pay out a
|
|
22
|
+
single seller/participant (gating each via their own KYC/eligibility check)
|
|
23
|
+
instead of only by organization.
|
|
24
|
+
|
|
25
|
+
## [2.4.0] - 2026-06-14
|
|
26
|
+
|
|
27
|
+
### Added — `settled` bank-feed/manual status + `settle()` / `unsettle()` verbs
|
|
28
|
+
|
|
29
|
+
New `BANK_FEED_STATUS.SETTLED` (`'settled'`) for a bank line that was reconciled
|
|
30
|
+
by a **linked document** (an invoice/bill whose payment already posted the cash
|
|
31
|
+
JE, `Dr Bank / Cr AR`). The line itself posts **no second journal entry**.
|
|
32
|
+
|
|
33
|
+
- `transaction.settle(id, { settledBy?, metadata? })` — `imported → settled`
|
|
34
|
+
(bank_feed) / `pending → settled` (manual). Does **not** call the ledger
|
|
35
|
+
bridge (no JE). Idempotent (re-running on a `settled` row is a no-op).
|
|
36
|
+
`metadata` is shallow-merged (dotted `$set`) so the host can stamp the link
|
|
37
|
+
back to the settling document.
|
|
38
|
+
- `transaction.unsettle(id, { unsettledBy?, clearMetadata? })` — reverses to the
|
|
39
|
+
birth status (`settled → imported` bank_feed / `settled → pending` manual) and
|
|
40
|
+
clears the named metadata keys.
|
|
41
|
+
|
|
42
|
+
Unlike `reconciled_external` (vendor-owned, born terminal, no edges), `settled`
|
|
43
|
+
is **reachable and reversible** but never enters the JE bridge. This replaces the
|
|
44
|
+
host-side pattern of a raw `updateOne` parking invoice-settled rows at `matched`
|
|
45
|
+
(which overloaded `matched` and forced every consumer to sniff
|
|
46
|
+
`metadata.matchedVia` to tell "done" from "needs a JE"). `status` is now the
|
|
47
|
+
single source of truth.
|
|
48
|
+
|
|
6
49
|
## [2.3.0] - 2026-06-02
|
|
7
50
|
|
|
8
51
|
### Added — `reconciled_external` terminal bank-feed status
|
|
@@ -20,7 +20,8 @@ const TRANSACTION_STATUS = {
|
|
|
20
20
|
MATCHED: "matched",
|
|
21
21
|
JOURNALIZED: "journalized",
|
|
22
22
|
REJECTED: "rejected",
|
|
23
|
-
RECONCILED_EXTERNAL: "reconciled_external"
|
|
23
|
+
RECONCILED_EXTERNAL: "reconciled_external",
|
|
24
|
+
SETTLED: "settled"
|
|
24
25
|
};
|
|
25
26
|
const TRANSACTION_STATUS_VALUES = Object.values(TRANSACTION_STATUS);
|
|
26
27
|
const LIBRARY_CATEGORIES = {
|
|
@@ -73,7 +74,8 @@ const BANK_FEED_STATUS = {
|
|
|
73
74
|
MATCHED: "matched",
|
|
74
75
|
JOURNALIZED: "journalized",
|
|
75
76
|
REJECTED: "rejected",
|
|
76
|
-
RECONCILED_EXTERNAL: "reconciled_external"
|
|
77
|
+
RECONCILED_EXTERNAL: "reconciled_external",
|
|
78
|
+
SETTLED: "settled"
|
|
77
79
|
};
|
|
78
80
|
const BANK_FEED_STATUS_VALUES = Object.values(BANK_FEED_STATUS);
|
|
79
81
|
const bankFeedStatusSet = new Set(BANK_FEED_STATUS_VALUES);
|
|
@@ -132,13 +134,15 @@ const STATUSES_BY_KIND = {
|
|
|
132
134
|
TRANSACTION_STATUS.MATCHED,
|
|
133
135
|
TRANSACTION_STATUS.JOURNALIZED,
|
|
134
136
|
TRANSACTION_STATUS.REJECTED,
|
|
135
|
-
TRANSACTION_STATUS.RECONCILED_EXTERNAL
|
|
137
|
+
TRANSACTION_STATUS.RECONCILED_EXTERNAL,
|
|
138
|
+
TRANSACTION_STATUS.SETTLED
|
|
136
139
|
]),
|
|
137
140
|
[TRANSACTION_KIND.MANUAL]: new Set([
|
|
138
141
|
TRANSACTION_STATUS.PENDING,
|
|
139
142
|
TRANSACTION_STATUS.MATCHED,
|
|
140
143
|
TRANSACTION_STATUS.JOURNALIZED,
|
|
141
|
-
TRANSACTION_STATUS.REJECTED
|
|
144
|
+
TRANSACTION_STATUS.REJECTED,
|
|
145
|
+
TRANSACTION_STATUS.SETTLED
|
|
142
146
|
])
|
|
143
147
|
};
|
|
144
148
|
/**
|
|
@@ -23,6 +23,7 @@ declare const TRANSACTION_STATUS: {
|
|
|
23
23
|
readonly JOURNALIZED: "journalized";
|
|
24
24
|
readonly REJECTED: "rejected";
|
|
25
25
|
readonly RECONCILED_EXTERNAL: "reconciled_external";
|
|
26
|
+
readonly SETTLED: "settled";
|
|
26
27
|
};
|
|
27
28
|
type TransactionStatus = typeof TRANSACTION_STATUS;
|
|
28
29
|
type TransactionStatusValue = TransactionStatus[keyof TransactionStatus];
|
|
@@ -71,6 +72,7 @@ declare const BANK_FEED_STATUS: {
|
|
|
71
72
|
readonly JOURNALIZED: "journalized";
|
|
72
73
|
readonly REJECTED: "rejected";
|
|
73
74
|
readonly RECONCILED_EXTERNAL: "reconciled_external";
|
|
75
|
+
readonly SETTLED: "settled";
|
|
74
76
|
};
|
|
75
77
|
type BankFeedStatusValue = (typeof BANK_FEED_STATUS)[keyof typeof BANK_FEED_STATUS];
|
|
76
78
|
declare const BANK_FEED_STATUS_VALUES: BankFeedStatusValue[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { U as HoldStatusValue, b as SplitStatusValue, c as SubscriptionStatusValue, j as SettlementStatusValue } from "../subscription.enums-k24kLpF7.mjs";
|
|
2
|
-
import { O as TransactionStatusValue, u as TransactionKindValue } from "../bank-feed.enums-
|
|
2
|
+
import { O as TransactionStatusValue, u as TransactionKindValue } from "../bank-feed.enums-CqTW2Blz.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/core/state-machines.d.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND } from "../bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { g as SETTLEMENT_STATUS, l as SPLIT_STATUS, r as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "../subscription.enums-95othr0i.mjs";
|
|
3
3
|
import { a as InvalidStateTransitionError } from "../errors-Bt5NRVMq.mjs";
|
|
4
4
|
import { defineStateMachine } from "@classytic/primitives/state-machine";
|
|
@@ -151,15 +151,25 @@ const SPLIT_STATE_MACHINE = new StateMachine(new Map([
|
|
|
151
151
|
]), "split");
|
|
152
152
|
const PAYMENT_FLOW_STATE_MACHINE = TRANSACTION_STATE_MACHINE;
|
|
153
153
|
const BANK_FEED_STATE_MACHINE = new StateMachine(new Map([
|
|
154
|
-
[TRANSACTION_STATUS.IMPORTED, new Set([
|
|
154
|
+
[TRANSACTION_STATUS.IMPORTED, new Set([
|
|
155
|
+
TRANSACTION_STATUS.MATCHED,
|
|
156
|
+
TRANSACTION_STATUS.REJECTED,
|
|
157
|
+
TRANSACTION_STATUS.SETTLED
|
|
158
|
+
])],
|
|
155
159
|
[TRANSACTION_STATUS.MATCHED, new Set([TRANSACTION_STATUS.IMPORTED, TRANSACTION_STATUS.JOURNALIZED])],
|
|
160
|
+
[TRANSACTION_STATUS.SETTLED, new Set([TRANSACTION_STATUS.IMPORTED])],
|
|
156
161
|
[TRANSACTION_STATUS.JOURNALIZED, /* @__PURE__ */ new Set([])],
|
|
157
162
|
[TRANSACTION_STATUS.REJECTED, /* @__PURE__ */ new Set([])],
|
|
158
163
|
[TRANSACTION_STATUS.RECONCILED_EXTERNAL, /* @__PURE__ */ new Set([])]
|
|
159
164
|
]), "transaction.bank_feed");
|
|
160
165
|
const MANUAL_STATE_MACHINE = new StateMachine(new Map([
|
|
161
|
-
[TRANSACTION_STATUS.PENDING, new Set([
|
|
166
|
+
[TRANSACTION_STATUS.PENDING, new Set([
|
|
167
|
+
TRANSACTION_STATUS.MATCHED,
|
|
168
|
+
TRANSACTION_STATUS.REJECTED,
|
|
169
|
+
TRANSACTION_STATUS.SETTLED
|
|
170
|
+
])],
|
|
162
171
|
[TRANSACTION_STATUS.MATCHED, new Set([TRANSACTION_STATUS.JOURNALIZED])],
|
|
172
|
+
[TRANSACTION_STATUS.SETTLED, new Set([TRANSACTION_STATUS.PENDING])],
|
|
163
173
|
[TRANSACTION_STATUS.JOURNALIZED, /* @__PURE__ */ new Set([])],
|
|
164
174
|
[TRANSACTION_STATUS.REJECTED, /* @__PURE__ */ new Set([])]
|
|
165
175
|
]), "transaction.manual");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
import { t as RevenueBridges } from "./revenue-bridges-BtkWFsJu.mjs";
|
|
3
|
-
import { O as TransactionStatusValue, u as TransactionKindValue } from "./bank-feed.enums-
|
|
4
|
-
import { a as BankFeedProviderRegistry, d as PaymentProvider, o as FetchTransactionsParams, r as BankFeedProvider, t as ProviderRegistry } from "./registry-
|
|
3
|
+
import { O as TransactionStatusValue, u as TransactionKindValue } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
4
|
+
import { a as BankFeedProviderRegistry, d as PaymentProvider, o as FetchTransactionsParams, r as BankFeedProvider, t as ProviderRegistry } from "./registry-DSG7x-Cl.mjs";
|
|
5
5
|
import { RepositoryPluginBundle, RevenueRepositories } from "./repositories/create-repositories.mjs";
|
|
6
6
|
import { PluginType, Repository } from "@classytic/mongokit";
|
|
7
7
|
import { TenantConfig } from "@classytic/repo-core/tenant";
|
|
@@ -724,6 +724,38 @@ declare class TransactionRepository extends RevenueRepositoryBase<TransactionDoc
|
|
|
724
724
|
unmatch(id: string, options?: {
|
|
725
725
|
unmatchedBy?: string;
|
|
726
726
|
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
727
|
+
/**
|
|
728
|
+
* Reconcile a bank-feed / manual row that settled a linked document
|
|
729
|
+
* (invoice/bill) WITHOUT posting a journal entry. The document's payment
|
|
730
|
+
* already owns the cash JE (`Dr Bank / Cr AR`), so the bank line only needs
|
|
731
|
+
* its status moved to `settled` — calling `match()` here would fire
|
|
732
|
+
* `LedgerBridge.onTransactionMatched` and double-count the cash. This is the
|
|
733
|
+
* package's intended path when the JE lives elsewhere (the reachable sibling
|
|
734
|
+
* of the born-`reconciled_external` import).
|
|
735
|
+
*
|
|
736
|
+
* `imported → settled` (bank_feed) / `pending → settled` (manual). Idempotent:
|
|
737
|
+
* a row already `settled` is returned unchanged, so a best-effort caller can
|
|
738
|
+
* safely re-run. The optional `metadata` is shallow-merged onto the document's
|
|
739
|
+
* `metadata` (dotted `$set`, so sibling keys survive) — hosts stamp the link
|
|
740
|
+
* back to the settling document there. No JE bridge call, no domain event:
|
|
741
|
+
* settlement is host-initiated and the host owns the reconcile audit trail.
|
|
742
|
+
*/
|
|
743
|
+
settle(id: string, data?: {
|
|
744
|
+
settledBy?: string;
|
|
745
|
+
metadata?: Record<string, unknown>;
|
|
746
|
+
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
747
|
+
/**
|
|
748
|
+
* Reverse a `settle()` — the linked document's payment was undone, so the
|
|
749
|
+
* bank line returns to its birth status to re-enter the reconcile queue.
|
|
750
|
+
* `settled → imported` (bank_feed) / `settled → pending` (manual). Clears
|
|
751
|
+
* `verifiedAt`/`verifiedBy` plus any metadata keys named in `clearMetadata`
|
|
752
|
+
* (the host-stamped link back to the now-reversed document). Idempotent: a
|
|
753
|
+
* row not currently `settled` is returned unchanged.
|
|
754
|
+
*/
|
|
755
|
+
unsettle(id: string, data?: {
|
|
756
|
+
unsettledBy?: string;
|
|
757
|
+
clearMetadata?: string[];
|
|
758
|
+
}, ctx?: RevenueContext): Promise<TransactionDocument>;
|
|
727
759
|
/**
|
|
728
760
|
* Stamp the journal entry reference and transition `matched →
|
|
729
761
|
* journalized`. Typical caller is the `LedgerBridge.onTransactionMatched`
|
|
@@ -890,6 +922,30 @@ interface SettlementProcessingError {
|
|
|
890
922
|
settlementId: SettlementDocument['_id'];
|
|
891
923
|
error: unknown;
|
|
892
924
|
}
|
|
925
|
+
/**
|
|
926
|
+
* A recipient's payout balance — the amounts the platform has scheduled,
|
|
927
|
+
* is processing, has paid, or failed to pay, in minor units. The "wallet"
|
|
928
|
+
* view a marketplace shows a seller/creator. Derived from settlement status;
|
|
929
|
+
* tenant-scoped.
|
|
930
|
+
*/
|
|
931
|
+
interface RecipientBalance {
|
|
932
|
+
recipientId: string;
|
|
933
|
+
currency: string | null;
|
|
934
|
+
/** Scheduled, awaiting payout (status: pending) = held + available. */
|
|
935
|
+
pending: number;
|
|
936
|
+
/** Pending but still in the clearance window (`scheduledAt` in the future) — escrowed, not yet payable. */
|
|
937
|
+
held: number;
|
|
938
|
+
/** Pending and due (`scheduledAt <= now`) — cleared, ready to pay out. */
|
|
939
|
+
available: number;
|
|
940
|
+
/** Payout in flight (status: processing). */
|
|
941
|
+
processing: number;
|
|
942
|
+
/** Paid out, lifetime (status: completed). */
|
|
943
|
+
paidOut: number;
|
|
944
|
+
/** Failed payouts (status: failed). */
|
|
945
|
+
failed: number;
|
|
946
|
+
/** pending + processing + paidOut — the total the platform has committed to this recipient. */
|
|
947
|
+
lifetime: number;
|
|
948
|
+
}
|
|
893
949
|
/**
|
|
894
950
|
* SettlementRepository — payouts to recipients (organizations, vendors,
|
|
895
951
|
* affiliates).
|
|
@@ -930,7 +986,8 @@ declare class SettlementRepository extends RevenueRepositoryBase<SettlementDocum
|
|
|
930
986
|
processPending(options?: {
|
|
931
987
|
limit?: number;
|
|
932
988
|
organizationId?: string;
|
|
933
|
-
payoutMethod?: string;
|
|
989
|
+
payoutMethod?: string; /** Restrict the sweep to a single recipient — pay one seller/participant. */
|
|
990
|
+
recipientId?: string;
|
|
934
991
|
dryRun?: boolean;
|
|
935
992
|
}, ctx?: RevenueContext): Promise<{
|
|
936
993
|
processed: number;
|
|
@@ -950,6 +1007,10 @@ declare class SettlementRepository extends RevenueRepositoryBase<SettlementDocum
|
|
|
950
1007
|
code?: string;
|
|
951
1008
|
retry?: boolean;
|
|
952
1009
|
}, ctx?: RevenueContext): Promise<SettlementDocument>;
|
|
1010
|
+
recipientBalance(recipientId: string, options?: {
|
|
1011
|
+
recipientType?: string;
|
|
1012
|
+
currency?: string;
|
|
1013
|
+
}, ctx?: RevenueContext): Promise<RecipientBalance>;
|
|
953
1014
|
}
|
|
954
1015
|
//#endregion
|
|
955
1016
|
//#region src/engine/engine-types.d.ts
|
|
@@ -1204,4 +1265,4 @@ interface RevenueEngine {
|
|
|
1204
1265
|
destroy(): Promise<void>;
|
|
1205
1266
|
}
|
|
1206
1267
|
//#endregion
|
|
1207
|
-
export { RevenueConfig as a,
|
|
1268
|
+
export { RevenueConfig as a, SettlementRepository as c, RevenueModels as d, RevenueSchemaOptions as f, TransactionDocument as h, RetryConfig as i, SubscriptionRepository as l, SubscriptionDocument as m, BankFeedModuleConfig as n, RevenueEngine as o, SettlementDocument as p, CommissionConfig as r, RecipientBalance as s, BankFeedIndexConfig as t, TransactionRepository as u };
|
package/dist/enums/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { A as SettlementStatus, B as HoldReason, C as isPayoutMethod, D as SETTLEMENT_STATUS_VALUES, E as SETTLEMENT_STATUS, F as isSettlementType, G as RELEASE_REASON_VALUES, H as HoldStatus, I as HOLD_REASON, J as isHoldReason, K as ReleaseReason, L as HOLD_REASON_VALUES, M as SettlementType, N as SettlementTypeValue, O as SETTLEMENT_TYPE, P as isSettlementStatus, R as HOLD_STATUS, S as SplitTypeValue, T as isSplitType, U as HoldStatusValue, V as HoldReasonValue, W as RELEASE_REASON, X as isReleaseReason, Y as isHoldStatus, _ as SPLIT_TYPE, a as SUBSCRIPTION_STATUS, b as SplitStatusValue, c as SubscriptionStatusValue, d as PAYOUT_METHOD, f as PAYOUT_METHOD_VALUES, g as SPLIT_STATUS_VALUES, h as SPLIT_STATUS, i as PlanKeys, j as SettlementStatusValue, k as SETTLEMENT_TYPE_VALUES, l as isPlanKey, m as PayoutMethodValue, n as PLAN_KEY_VALUES, o as SUBSCRIPTION_STATUS_VALUES, p as PayoutMethod, q as ReleaseReasonValue, r as PlanKeyValue, s as SubscriptionStatus, t as PLAN_KEYS, u as isSubscriptionStatus, v as SPLIT_TYPE_VALUES, w as isSplitStatus, x as SplitType, y as SplitStatus, z as HOLD_STATUS_VALUES } from "../subscription.enums-k24kLpF7.mjs";
|
|
2
|
-
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "../bank-feed.enums-
|
|
2
|
+
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "../bank-feed.enums-CqTW2Blz.mjs";
|
|
3
3
|
import { a as isMonetizationType, c as PAYMENT_STATUS, d as PaymentGatewayTypeValue, f as PaymentStatus, h as isPaymentStatus, i as MonetizationTypes, l as PAYMENT_STATUS_VALUES, m as isPaymentGatewayType, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_GATEWAY_TYPE, p as PaymentStatusValue, r as MonetizationTypeValue, s as PAYMENT_GATEWAY_TYPE_VALUES, t as MONETIZATION_TYPES, u as PaymentGatewayType } from "../monetization.enums-DzAI4sT7.mjs";
|
|
4
4
|
export { BANK_FEED_SOURCE, BANK_FEED_SOURCE_VALUES, BANK_FEED_STATUS, BANK_FEED_STATUS_VALUES, BankFeedSourceValue, BankFeedStatusValue, HOLD_REASON, HOLD_REASON_VALUES, HOLD_STATUS, HOLD_STATUS_VALUES, HoldReason, HoldReasonValue, HoldStatus, HoldStatusValue, LIBRARY_CATEGORIES, LIBRARY_CATEGORY_VALUES, LibraryCategories, LibraryCategoryValue, MONETIZATION_TYPES, MONETIZATION_TYPE_VALUES, MonetizationTypeValue, MonetizationTypes, PAYMENT_GATEWAY_TYPE, PAYMENT_GATEWAY_TYPE_VALUES, PAYMENT_STATUS, PAYMENT_STATUS_VALUES, PAYOUT_METHOD, PAYOUT_METHOD_VALUES, PLAN_KEYS, PLAN_KEY_VALUES, PaymentGatewayType, PaymentGatewayTypeValue, PaymentStatus, PaymentStatusValue, PayoutMethod, PayoutMethodValue, PlanKeyValue, PlanKeys, RELEASE_REASON, RELEASE_REASON_VALUES, ReleaseReason, ReleaseReasonValue, SETTLEMENT_STATUS, SETTLEMENT_STATUS_VALUES, SETTLEMENT_TYPE, SETTLEMENT_TYPE_VALUES, SPLIT_STATUS, SPLIT_STATUS_VALUES, SPLIT_TYPE, SPLIT_TYPE_VALUES, SUBSCRIPTION_STATUS, SUBSCRIPTION_STATUS_VALUES, SettlementStatus, SettlementStatusValue, SettlementType, SettlementTypeValue, SplitStatus, SplitStatusValue, SplitType, SplitTypeValue, SubscriptionStatus, SubscriptionStatusValue, TRANSACTION_FLOW, TRANSACTION_FLOW_VALUES, TRANSACTION_KIND, TRANSACTION_KIND_VALUES, TRANSACTION_STATUS, TRANSACTION_STATUS_VALUES, TransactionFlow, TransactionFlowValue, TransactionKind, TransactionKindValue, TransactionStatus, TransactionStatusValue, initialStatusFor, isBankFeedSource, isBankFeedStatus, isHoldReason, isHoldStatus, isLibraryCategory, isMonetizationType, isPaymentGatewayType, isPaymentStatus, isPayoutMethod, isPlanKey, isReleaseReason, isSettlementStatus, isSettlementType, isSplitStatus, isSplitType, isStatusValidForKind, isSubscriptionStatus, isTransactionFlow, isTransactionKind, isTransactionStatus, statusesForKind };
|
package/dist/enums/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "../bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { A as isReleaseReason, C as HOLD_REASON_VALUES, D as RELEASE_REASON_VALUES, E as RELEASE_REASON, O as isHoldReason, S as HOLD_REASON, T as HOLD_STATUS_VALUES, _ as SETTLEMENT_STATUS_VALUES, a as isPlanKey, b as isSettlementStatus, c as PAYOUT_METHOD_VALUES, d as SPLIT_TYPE, f as SPLIT_TYPE_VALUES, g as SETTLEMENT_STATUS, h as isSplitType, i as SUBSCRIPTION_STATUS_VALUES, k as isHoldStatus, l as SPLIT_STATUS, m as isSplitStatus, n as PLAN_KEY_VALUES, o as isSubscriptionStatus, p as isPayoutMethod, r as SUBSCRIPTION_STATUS, s as PAYOUT_METHOD, t as PLAN_KEYS, u as SPLIT_STATUS_VALUES, v as SETTLEMENT_TYPE, w as HOLD_STATUS, x as isSettlementType, y as SETTLEMENT_TYPE_VALUES } from "../subscription.enums-95othr0i.mjs";
|
|
3
3
|
import { a as PAYMENT_GATEWAY_TYPE_VALUES, c as isPaymentGatewayType, i as PAYMENT_GATEWAY_TYPE, l as isPaymentStatus, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_STATUS, r as isMonetizationType, s as PAYMENT_STATUS_VALUES, t as MONETIZATION_TYPES } from "../monetization.enums-B9HBOecd.mjs";
|
|
4
4
|
|
|
@@ -110,29 +110,10 @@ declare const transactionBaseSchema: z.ZodObject<{
|
|
|
110
110
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
111
111
|
}, z.core.$strip>;
|
|
112
112
|
declare const transactionCreateSchema: z.ZodObject<{
|
|
113
|
-
|
|
114
|
-
customerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
113
|
+
status: z.ZodDefault<z.ZodString>;
|
|
115
114
|
type: z.ZodString;
|
|
116
|
-
flow: z.ZodEnum<{
|
|
117
|
-
inflow: "inflow";
|
|
118
|
-
outflow: "outflow";
|
|
119
|
-
}>;
|
|
120
|
-
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
121
115
|
amount: z.ZodNumber;
|
|
122
116
|
currency: z.ZodString;
|
|
123
|
-
fee: z.ZodDefault<z.ZodNumber>;
|
|
124
|
-
tax: z.ZodDefault<z.ZodNumber>;
|
|
125
|
-
net: z.ZodDefault<z.ZodNumber>;
|
|
126
|
-
taxDetails: z.ZodOptional<z.ZodObject<{
|
|
127
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
128
|
-
sales_tax: "sales_tax";
|
|
129
|
-
vat: "vat";
|
|
130
|
-
none: "none";
|
|
131
|
-
}>>;
|
|
132
|
-
rate: z.ZodOptional<z.ZodNumber>;
|
|
133
|
-
isInclusive: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
-
}, z.core.$strip>>;
|
|
135
|
-
method: z.ZodString;
|
|
136
117
|
methodKind: z.ZodEnum<{
|
|
137
118
|
card: "card";
|
|
138
119
|
bank_transfer: "bank_transfer";
|
|
@@ -148,8 +129,39 @@ declare const transactionCreateSchema: z.ZodObject<{
|
|
|
148
129
|
manual: "manual";
|
|
149
130
|
other: "other";
|
|
150
131
|
}>;
|
|
151
|
-
status: z.ZodDefault<z.ZodString>;
|
|
152
132
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
133
|
+
customerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
134
|
+
splits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
135
|
+
type: z.ZodString;
|
|
136
|
+
recipientId: z.ZodString;
|
|
137
|
+
recipientType: z.ZodString;
|
|
138
|
+
rate: z.ZodNumber;
|
|
139
|
+
grossAmount: z.ZodNumber;
|
|
140
|
+
gatewayFeeRate: z.ZodNumber;
|
|
141
|
+
gatewayFeeAmount: z.ZodNumber;
|
|
142
|
+
netAmount: z.ZodNumber;
|
|
143
|
+
status: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>>;
|
|
145
|
+
relatedTransactionId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
147
|
+
flow: z.ZodEnum<{
|
|
148
|
+
inflow: "inflow";
|
|
149
|
+
outflow: "outflow";
|
|
150
|
+
}>;
|
|
151
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
152
|
+
fee: z.ZodDefault<z.ZodNumber>;
|
|
153
|
+
tax: z.ZodDefault<z.ZodNumber>;
|
|
154
|
+
net: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
taxDetails: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
157
|
+
sales_tax: "sales_tax";
|
|
158
|
+
vat: "vat";
|
|
159
|
+
none: "none";
|
|
160
|
+
}>>;
|
|
161
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
isInclusive: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
}, z.core.$strip>>;
|
|
164
|
+
method: z.ZodString;
|
|
153
165
|
gateway: z.ZodOptional<z.ZodObject<{
|
|
154
166
|
type: z.ZodString;
|
|
155
167
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
@@ -167,17 +179,6 @@ declare const transactionCreateSchema: z.ZodObject<{
|
|
|
167
179
|
netAmount: z.ZodNumber;
|
|
168
180
|
status: z.ZodString;
|
|
169
181
|
}, z.core.$strip>>;
|
|
170
|
-
splits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
171
|
-
type: z.ZodString;
|
|
172
|
-
recipientId: z.ZodString;
|
|
173
|
-
recipientType: z.ZodString;
|
|
174
|
-
rate: z.ZodNumber;
|
|
175
|
-
grossAmount: z.ZodNumber;
|
|
176
|
-
gatewayFeeRate: z.ZodNumber;
|
|
177
|
-
gatewayFeeAmount: z.ZodNumber;
|
|
178
|
-
netAmount: z.ZodNumber;
|
|
179
|
-
status: z.ZodString;
|
|
180
|
-
}, z.core.$strip>>>;
|
|
181
182
|
hold: z.ZodOptional<z.ZodObject<{
|
|
182
183
|
status: z.ZodString;
|
|
183
184
|
heldAmount: z.ZodNumber;
|
|
@@ -200,7 +201,6 @@ declare const transactionCreateSchema: z.ZodObject<{
|
|
|
200
201
|
}, z.core.$strip>>;
|
|
201
202
|
sourceId: z.ZodOptional<z.ZodString>;
|
|
202
203
|
sourceModel: z.ZodOptional<z.ZodString>;
|
|
203
|
-
relatedTransactionId: z.ZodOptional<z.ZodString>;
|
|
204
204
|
idempotencyKey: z.ZodOptional<z.ZodString>;
|
|
205
205
|
}, z.core.$strip>;
|
|
206
206
|
declare const transactionUpdateSchema: z.ZodObject<{
|
|
@@ -360,14 +360,14 @@ declare const subscriptionBaseSchema: z.ZodObject<{
|
|
|
360
360
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
361
361
|
}, z.core.$strip>;
|
|
362
362
|
declare const subscriptionCreateSchema: z.ZodObject<{
|
|
363
|
-
organizationId: z.ZodOptional<z.ZodString>;
|
|
364
|
-
customerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
365
363
|
amount: z.ZodNumber;
|
|
366
364
|
currency: z.ZodOptional<z.ZodString>;
|
|
367
|
-
paymentIntentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
368
365
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
369
|
-
|
|
366
|
+
customerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
367
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
368
|
+
paymentIntentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
370
369
|
planKey: z.ZodString;
|
|
370
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
371
371
|
startDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
372
372
|
endDate: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
373
373
|
pauseReason: z.ZodOptional<z.ZodString>;
|
|
@@ -478,7 +478,6 @@ declare const settlementBaseSchema: z.ZodObject<{
|
|
|
478
478
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
479
479
|
}, z.core.$strip>;
|
|
480
480
|
declare const settlementCreateSchema: z.ZodObject<{
|
|
481
|
-
organizationId: z.ZodString;
|
|
482
481
|
type: z.ZodEnum<{
|
|
483
482
|
split_payout: "split_payout";
|
|
484
483
|
platform_withdrawal: "platform_withdrawal";
|
|
@@ -504,6 +503,9 @@ declare const settlementCreateSchema: z.ZodObject<{
|
|
|
504
503
|
platform_balance: "platform_balance";
|
|
505
504
|
crypto: "crypto";
|
|
506
505
|
}>;
|
|
506
|
+
scheduledAt: z.ZodDefault<z.ZodCoercedDate<unknown>>;
|
|
507
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
508
|
+
organizationId: z.ZodString;
|
|
507
509
|
sourceTransactionIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
508
510
|
sourceSplitIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
509
511
|
bankTransferDetails: z.ZodOptional<z.ZodObject<{
|
|
@@ -529,8 +531,6 @@ declare const settlementCreateSchema: z.ZodObject<{
|
|
|
529
531
|
transactionHash: z.ZodOptional<z.ZodString>;
|
|
530
532
|
transferredAt: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
531
533
|
}, z.core.$strip>>;
|
|
532
|
-
scheduledAt: z.ZodDefault<z.ZodCoercedDate<unknown>>;
|
|
533
|
-
notes: z.ZodOptional<z.ZodString>;
|
|
534
534
|
}, z.core.$strip>;
|
|
535
535
|
declare const settlementUpdateSchema: z.ZodObject<{
|
|
536
536
|
publicId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
import { a as CurrencyBridge, c as LedgerBridge, i as CustomerBridge, o as NotificationBridge, r as AnalyticsBridge, s as TaxBridge, t as RevenueBridges } from "./revenue-bridges-BtkWFsJu.mjs";
|
|
3
3
|
import { A as SettlementStatus, B as HoldReason, C as isPayoutMethod, D as SETTLEMENT_STATUS_VALUES, E as SETTLEMENT_STATUS, F as isSettlementType, G as RELEASE_REASON_VALUES, H as HoldStatus, I as HOLD_REASON, J as isHoldReason, K as ReleaseReason, L as HOLD_REASON_VALUES, M as SettlementType, N as SettlementTypeValue, O as SETTLEMENT_TYPE, P as isSettlementStatus, R as HOLD_STATUS, S as SplitTypeValue, T as isSplitType, U as HoldStatusValue, V as HoldReasonValue, W as RELEASE_REASON, X as isReleaseReason, Y as isHoldStatus, _ as SPLIT_TYPE, a as SUBSCRIPTION_STATUS, b as SplitStatusValue, c as SubscriptionStatusValue, d as PAYOUT_METHOD, f as PAYOUT_METHOD_VALUES, g as SPLIT_STATUS_VALUES, h as SPLIT_STATUS, i as PlanKeys, j as SettlementStatusValue, k as SETTLEMENT_TYPE_VALUES, l as isPlanKey, m as PayoutMethodValue, n as PLAN_KEY_VALUES, o as SUBSCRIPTION_STATUS_VALUES, p as PayoutMethod, q as ReleaseReasonValue, r as PlanKeyValue, s as SubscriptionStatus, t as PLAN_KEYS, u as isSubscriptionStatus, v as SPLIT_TYPE_VALUES, w as isSplitStatus, x as SplitType, y as SplitStatus, z as HOLD_STATUS_VALUES } from "./subscription.enums-k24kLpF7.mjs";
|
|
4
|
-
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "./bank-feed.enums-
|
|
4
|
+
import { A as isTransactionFlow, C as TRANSACTION_STATUS, D as TransactionStatus, E as TransactionFlowValue, O as TransactionStatusValue, S as TRANSACTION_FLOW_VALUES, T as TransactionFlow, _ as LIBRARY_CATEGORIES, a as BankFeedSourceValue, b as LibraryCategoryValue, c as TRANSACTION_KIND_VALUES, d as initialStatusFor, f as isBankFeedSource, g as statusesForKind, h as isTransactionKind, i as BANK_FEED_STATUS_VALUES, j as isTransactionStatus, k as isLibraryCategory, l as TransactionKind, m as isStatusValidForKind, n as BANK_FEED_SOURCE_VALUES, o as BankFeedStatusValue, p as isBankFeedStatus, r as BANK_FEED_STATUS, s as TRANSACTION_KIND, t as BANK_FEED_SOURCE, u as TransactionKindValue, v as LIBRARY_CATEGORY_VALUES, w as TRANSACTION_STATUS_VALUES, x as TRANSACTION_FLOW, y as LibraryCategories } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
5
5
|
import { BANK_FEED_STATE_MACHINE, HOLD_STATE_MACHINE, MANUAL_STATE_MACHINE, PAYMENT_FLOW_STATE_MACHINE, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateChangeEvent, StateMachine, TRANSACTION_STATE_MACHINE, smFor } from "./core/state-machines.mjs";
|
|
6
6
|
import { a as isMonetizationType, c as PAYMENT_STATUS, d as PaymentGatewayTypeValue, f as PaymentStatus, h as isPaymentStatus, i as MonetizationTypes, l as PAYMENT_STATUS_VALUES, m as isPaymentGatewayType, n as MONETIZATION_TYPE_VALUES, o as PAYMENT_GATEWAY_TYPE, p as PaymentStatusValue, r as MonetizationTypeValue, s as PAYMENT_GATEWAY_TYPE_VALUES, t as MONETIZATION_TYPES, u as PaymentGatewayType } from "./monetization.enums-DzAI4sT7.mjs";
|
|
7
7
|
import { D as RevenueEventSchema, E as RevenueEventPayloadOf, T as RevenueEventDefinition, _t as InProcessRevenueBusOptions, ft as revenueEventDefinitions, gt as InProcessRevenueBus, ht as createEvent, mt as RevenueEventName, pt as REVENUE_EVENTS } from "./revenue-event-catalog-j8Fh7Yag.mjs";
|
|
8
|
-
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "./registry-
|
|
9
|
-
import { a as RevenueConfig, c as
|
|
8
|
+
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "./registry-DSG7x-Cl.mjs";
|
|
9
|
+
import { a as RevenueConfig, c as SettlementRepository, d as RevenueModels, f as RevenueSchemaOptions, h as TransactionDocument, i as RetryConfig, l as SubscriptionRepository, m as SubscriptionDocument, n as BankFeedModuleConfig, o as RevenueEngine, p as SettlementDocument, r as CommissionConfig, s as RecipientBalance, t as BankFeedIndexConfig, u as TransactionRepository } from "./engine-types-F3f1lWNG.mjs";
|
|
10
10
|
import { RepositoryPluginBundle, RevenueRepositories } from "./repositories/create-repositories.mjs";
|
|
11
|
-
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "./escrow.schema-
|
|
11
|
+
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "./escrow.schema-o4qhjOca.mjs";
|
|
12
12
|
import { A as SplitInfo, B as validateTaxCalculation, C as multiplyMoney, D as toCurrencyCode, E as sumMoney, F as TaxConfig, H as calculateCommission, I as TaxType, L as calculateTax, M as calculateOrganizationPayout, N as calculateSplits, O as toMajor, P as TaxCalculation, R as getTaxType, S as money, T as subtractMoney, U as reverseCommission, V as CommissionInfo, _ as isMoney, a as CurrencyCode, b as isZeroMoney, c as Money, d as addMoney, f as compareMoney, g as isCurrencyCode, h as fromSmallestUnit, i as CURRENCIES, j as SplitRule, k as toSmallestUnit, l as MoneyValue, m as fromMajor, n as getAuditTrail, o as CurrencyMismatchError, p as equalsMoney, r as getLastStateChange, s as MINOR_UNIT_FACTOR, t as appendAuditEvent, u as absMoney, v as isNegativeMoney, w as negateMoney, x as minorUnitFactor, y as isPositiveMoney, z as reverseTax } from "./audit-DRKuLBFO.mjs";
|
|
13
13
|
import { HookHandler, PluginContext, PluginManager, RevenuePluginDefinition } from "./plugins/plugin.interface.mjs";
|
|
14
14
|
import { DomainEvent, DomainEvent as DomainEvent$1, EventHandler, EventTransport } from "@classytic/primitives/events";
|
|
@@ -115,4 +115,4 @@ declare class BankFeedProviderNotFoundError extends RevenueError {
|
|
|
115
115
|
constructor(providerName: string);
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
|
-
export { AlreadyVerifiedError, type AnalyticsBridge, BANK_FEED_SOURCE, BANK_FEED_SOURCE_VALUES, BANK_FEED_STATE_MACHINE, BANK_FEED_STATUS, BANK_FEED_STATUS_VALUES, BankFeedImportError, type BankFeedIndexConfig, type BankFeedModuleConfig, BankFeedProvider, type BankFeedProviderCapabilities, BankFeedProviderNotFoundError, BankFeedProviderRegistry, BankFeedSourceValue, BankFeedStatusValue, CURRENCIES, type CommissionConfig, type CommissionInfo, ConfigurationError, type CurrencyBridge, type CurrencyCode, CurrencyMismatchError, type CustomerBridge, type DomainEvent, EscrowHoldInput, EscrowReleaseInput, type EventHandler, type EventTransport, type FetchTransactionsParams, type FetchTransactionsResult, HOLD_REASON, HOLD_REASON_VALUES, HOLD_STATE_MACHINE, HOLD_STATUS, HOLD_STATUS_VALUES, HoldReason, HoldReasonValue, HoldStatus, HoldStatusValue, type HookHandler, InProcessRevenueBus, type InProcessRevenueBusOptions, InvalidOutboxEventError, InvalidStateTransitionError, LIBRARY_CATEGORIES, LIBRARY_CATEGORY_VALUES, type LedgerBridge, LibraryCategories, LibraryCategoryValue, MANUAL_STATE_MACHINE, MINOR_UNIT_FACTOR, MONETIZATION_TYPES, MONETIZATION_TYPE_VALUES, MemoryOutboxStore, MethodKindLockedError, MonetizationTypeValue, MonetizationTypes, type Money, type MoneyValue, type NotificationBridge, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, PAYMENT_FLOW_STATE_MACHINE, PAYMENT_GATEWAY_TYPE, PAYMENT_GATEWAY_TYPE_VALUES, PAYMENT_STATUS, PAYMENT_STATUS_VALUES, PAYOUT_METHOD, PAYOUT_METHOD_VALUES, PLAN_KEYS, PLAN_KEY_VALUES, type ParseUploadParams, type ParseUploadResult, PaymentGatewayType, PaymentGatewayTypeValue, PaymentIntentCreationError, PaymentIntentInput, PaymentProvider, PaymentStatus, PaymentStatusValue, PaymentVerificationError, PaymentVerifyInput, PayoutMethod, PayoutMethodValue, PlanKeyValue, PlanKeys, type PluginContext, PluginManager, ProviderCapabilityError, ProviderNotFoundError, ProviderRegistry, RELEASE_REASON, RELEASE_REASON_VALUES, REVENUE_EVENTS, RefundInput, RefundNotSupportedError, ReleaseReason, ReleaseReasonValue, type RepositoryPluginBundle, type Result, type RetryConfig, type RevenueBridges, type RevenueConfig, type RevenueContext, type RevenueEngine, RevenueError, type RevenueEventDefinition, type RevenueEventName, type RevenueEventPayloadOf, type RevenueEventSchema, type RevenueModels, type RevenuePluginDefinition, type RevenueRepositories, type RevenueSchemaOptions, SETTLEMENT_STATE_MACHINE, SETTLEMENT_STATUS, SETTLEMENT_STATUS_VALUES, SETTLEMENT_TYPE, SETTLEMENT_TYPE_VALUES, SPLIT_STATE_MACHINE, SPLIT_STATUS, SPLIT_STATUS_VALUES, SPLIT_TYPE, SPLIT_TYPE_VALUES, SUBSCRIPTION_STATE_MACHINE, SUBSCRIPTION_STATUS, SUBSCRIPTION_STATUS_VALUES, SettlementCreateInput, type SettlementDocument, SettlementListFilter, SettlementNotFoundError, SettlementRepository, SettlementStatus, SettlementStatusValue, SettlementType, SettlementTypeValue, SettlementUpdateInput, type SplitInfo, type SplitRule, SplitRuleInput, SplitStatus, SplitStatusValue, SplitType, SplitTypeValue, type StateChangeEvent, StateMachine, SubscriptionCreateInput, type SubscriptionDocument, SubscriptionListFilter, SubscriptionNotFoundError, SubscriptionRepository, SubscriptionStatus, SubscriptionStatusValue, SubscriptionUpdateInput, TRANSACTION_FLOW, TRANSACTION_FLOW_VALUES, TRANSACTION_KIND, TRANSACTION_KIND_VALUES, TRANSACTION_STATE_MACHINE, TRANSACTION_STATUS, TRANSACTION_STATUS_VALUES, type TaxBridge, type TaxCalculation, type TaxConfig, type TaxType, TransactionCreateInput, type TransactionDocument, TransactionFlow, TransactionFlowValue, TransactionKind, TransactionKindValue, TransactionListFilter, TransactionNotFoundError, TransactionRepository, TransactionStatus, TransactionStatusValue, TransactionUpdateInput, ValidationError, WrongTransactionKindError, absMoney, addMoney, appendAuditEvent, calculateCommission, calculateOrganizationPayout, calculateSplits, calculateTax, compareMoney, createBankFeedProviderRegistry, createEvent, createProviderRegistry, createRevenue, equalsMoney, err, escrowHoldSchema, escrowReleaseSchema, fromMajor, fromSmallestUnit, getAuditTrail, getLastStateChange, getTaxType, initialStatusFor, isBankFeedSource, isBankFeedStatus, isCurrencyCode, isErr, isHoldReason, isHoldStatus, isLibraryCategory, isMonetizationType, isMoney, isNegativeMoney, isOk, isPaymentGatewayType, isPaymentStatus, isPayoutMethod, isPlanKey, isPositiveMoney, isReleaseReason, isSettlementStatus, isSettlementType, isSplitStatus, isSplitType, isStatusValidForKind, isSubscriptionStatus, isTransactionFlow, isTransactionKind, isTransactionStatus, isZeroMoney, minorUnitFactor, money, multiplyMoney, negateMoney, ok, paymentIntentSchema, paymentVerifySchema, refundSchema, revenueEventDefinitions, reverseCommission, reverseTax, settlementBaseSchema, settlementCreateSchema, settlementListFilterSchema, settlementUpdateSchema, smFor, splitRuleSchema, statusesForKind, subscriptionBaseSchema, subscriptionCreateSchema, subscriptionListFilterSchema, subscriptionUpdateSchema, subtractMoney, sumMoney, toCurrencyCode, toMajor, toSmallestUnit, transactionBaseSchema, transactionCreateSchema, transactionListFilterSchema, transactionUpdateSchema, validateTaxCalculation };
|
|
118
|
+
export { AlreadyVerifiedError, type AnalyticsBridge, BANK_FEED_SOURCE, BANK_FEED_SOURCE_VALUES, BANK_FEED_STATE_MACHINE, BANK_FEED_STATUS, BANK_FEED_STATUS_VALUES, BankFeedImportError, type BankFeedIndexConfig, type BankFeedModuleConfig, BankFeedProvider, type BankFeedProviderCapabilities, BankFeedProviderNotFoundError, BankFeedProviderRegistry, BankFeedSourceValue, BankFeedStatusValue, CURRENCIES, type CommissionConfig, type CommissionInfo, ConfigurationError, type CurrencyBridge, type CurrencyCode, CurrencyMismatchError, type CustomerBridge, type DomainEvent, EscrowHoldInput, EscrowReleaseInput, type EventHandler, type EventTransport, type FetchTransactionsParams, type FetchTransactionsResult, HOLD_REASON, HOLD_REASON_VALUES, HOLD_STATE_MACHINE, HOLD_STATUS, HOLD_STATUS_VALUES, HoldReason, HoldReasonValue, HoldStatus, HoldStatusValue, type HookHandler, InProcessRevenueBus, type InProcessRevenueBusOptions, InvalidOutboxEventError, InvalidStateTransitionError, LIBRARY_CATEGORIES, LIBRARY_CATEGORY_VALUES, type LedgerBridge, LibraryCategories, LibraryCategoryValue, MANUAL_STATE_MACHINE, MINOR_UNIT_FACTOR, MONETIZATION_TYPES, MONETIZATION_TYPE_VALUES, MemoryOutboxStore, MethodKindLockedError, MonetizationTypeValue, MonetizationTypes, type Money, type MoneyValue, type NotificationBridge, type OutboxAcknowledgeOptions, type OutboxClaimOptions, type OutboxErrorInfo, type OutboxFailOptions, type OutboxFailureContext, type OutboxFailureDecision, type OutboxFailurePolicy, OutboxOwnershipError, type OutboxStore, type OutboxWriteOptions, PAYMENT_FLOW_STATE_MACHINE, PAYMENT_GATEWAY_TYPE, PAYMENT_GATEWAY_TYPE_VALUES, PAYMENT_STATUS, PAYMENT_STATUS_VALUES, PAYOUT_METHOD, PAYOUT_METHOD_VALUES, PLAN_KEYS, PLAN_KEY_VALUES, type ParseUploadParams, type ParseUploadResult, PaymentGatewayType, PaymentGatewayTypeValue, PaymentIntentCreationError, PaymentIntentInput, PaymentProvider, PaymentStatus, PaymentStatusValue, PaymentVerificationError, PaymentVerifyInput, PayoutMethod, PayoutMethodValue, PlanKeyValue, PlanKeys, type PluginContext, PluginManager, ProviderCapabilityError, ProviderNotFoundError, ProviderRegistry, RELEASE_REASON, RELEASE_REASON_VALUES, REVENUE_EVENTS, type RecipientBalance, RefundInput, RefundNotSupportedError, ReleaseReason, ReleaseReasonValue, type RepositoryPluginBundle, type Result, type RetryConfig, type RevenueBridges, type RevenueConfig, type RevenueContext, type RevenueEngine, RevenueError, type RevenueEventDefinition, type RevenueEventName, type RevenueEventPayloadOf, type RevenueEventSchema, type RevenueModels, type RevenuePluginDefinition, type RevenueRepositories, type RevenueSchemaOptions, SETTLEMENT_STATE_MACHINE, SETTLEMENT_STATUS, SETTLEMENT_STATUS_VALUES, SETTLEMENT_TYPE, SETTLEMENT_TYPE_VALUES, SPLIT_STATE_MACHINE, SPLIT_STATUS, SPLIT_STATUS_VALUES, SPLIT_TYPE, SPLIT_TYPE_VALUES, SUBSCRIPTION_STATE_MACHINE, SUBSCRIPTION_STATUS, SUBSCRIPTION_STATUS_VALUES, SettlementCreateInput, type SettlementDocument, SettlementListFilter, SettlementNotFoundError, SettlementRepository, SettlementStatus, SettlementStatusValue, SettlementType, SettlementTypeValue, SettlementUpdateInput, type SplitInfo, type SplitRule, SplitRuleInput, SplitStatus, SplitStatusValue, SplitType, SplitTypeValue, type StateChangeEvent, StateMachine, SubscriptionCreateInput, type SubscriptionDocument, SubscriptionListFilter, SubscriptionNotFoundError, SubscriptionRepository, SubscriptionStatus, SubscriptionStatusValue, SubscriptionUpdateInput, TRANSACTION_FLOW, TRANSACTION_FLOW_VALUES, TRANSACTION_KIND, TRANSACTION_KIND_VALUES, TRANSACTION_STATE_MACHINE, TRANSACTION_STATUS, TRANSACTION_STATUS_VALUES, type TaxBridge, type TaxCalculation, type TaxConfig, type TaxType, TransactionCreateInput, type TransactionDocument, TransactionFlow, TransactionFlowValue, TransactionKind, TransactionKindValue, TransactionListFilter, TransactionNotFoundError, TransactionRepository, TransactionStatus, TransactionStatusValue, TransactionUpdateInput, ValidationError, WrongTransactionKindError, absMoney, addMoney, appendAuditEvent, calculateCommission, calculateOrganizationPayout, calculateSplits, calculateTax, compareMoney, createBankFeedProviderRegistry, createEvent, createProviderRegistry, createRevenue, equalsMoney, err, escrowHoldSchema, escrowReleaseSchema, fromMajor, fromSmallestUnit, getAuditTrail, getLastStateChange, getTaxType, initialStatusFor, isBankFeedSource, isBankFeedStatus, isCurrencyCode, isErr, isHoldReason, isHoldStatus, isLibraryCategory, isMonetizationType, isMoney, isNegativeMoney, isOk, isPaymentGatewayType, isPaymentStatus, isPayoutMethod, isPlanKey, isPositiveMoney, isReleaseReason, isSettlementStatus, isSettlementType, isSplitStatus, isSplitType, isStatusValidForKind, isSubscriptionStatus, isTransactionFlow, isTransactionKind, isTransactionStatus, isZeroMoney, minorUnitFactor, money, multiplyMoney, negateMoney, ok, paymentIntentSchema, paymentVerifySchema, refundSchema, revenueEventDefinitions, reverseCommission, reverseTax, settlementBaseSchema, settlementCreateSchema, settlementListFilterSchema, settlementUpdateSchema, smFor, splitRuleSchema, statusesForKind, subscriptionBaseSchema, subscriptionCreateSchema, subscriptionListFilterSchema, subscriptionUpdateSchema, subtractMoney, sumMoney, toCurrencyCode, toMajor, toSmallestUnit, transactionBaseSchema, transactionCreateSchema, transactionListFilterSchema, transactionUpdateSchema, validateTaxCalculation };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "./bank-feed.enums-
|
|
2
|
-
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "./settlement.repository-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, b as isTransactionFlow, c as isBankFeedSource, d as isTransactionKind, f as statusesForKind, g as TRANSACTION_FLOW_VALUES, h as TRANSACTION_FLOW, i as BANK_FEED_STATUS_VALUES, l as isBankFeedStatus, m as LIBRARY_CATEGORY_VALUES, n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES, p as LIBRARY_CATEGORIES, r as BANK_FEED_STATUS, s as initialStatusFor, t as BANK_FEED_SOURCE, u as isStatusValidForKind, v as TRANSACTION_STATUS_VALUES, x as isTransactionStatus, y as isLibraryCategory } from "./bank-feed.enums-ByS3mjX0.mjs";
|
|
2
|
+
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "./settlement.repository-BDrJQc27.mjs";
|
|
3
3
|
import { n as createEvent, t as REVENUE_EVENTS } from "./event-constants-DM_-A57b.mjs";
|
|
4
4
|
import { A as isReleaseReason, C as HOLD_REASON_VALUES, D as RELEASE_REASON_VALUES, E as RELEASE_REASON, O as isHoldReason, S as HOLD_REASON, T as HOLD_STATUS_VALUES, _ as SETTLEMENT_STATUS_VALUES, a as isPlanKey, b as isSettlementStatus, c as PAYOUT_METHOD_VALUES, d as SPLIT_TYPE, f as SPLIT_TYPE_VALUES, g as SETTLEMENT_STATUS, h as isSplitType, i as SUBSCRIPTION_STATUS_VALUES, k as isHoldStatus, l as SPLIT_STATUS, m as isSplitStatus, n as PLAN_KEY_VALUES, o as isSubscriptionStatus, p as isPayoutMethod, r as SUBSCRIPTION_STATUS, s as PAYOUT_METHOD, t as PLAN_KEYS, u as SPLIT_STATUS_VALUES, v as SETTLEMENT_TYPE, w as HOLD_STATUS, x as isSettlementType, y as SETTLEMENT_TYPE_VALUES } from "./subscription.enums-95othr0i.mjs";
|
|
5
5
|
import { _ as WrongTransactionKindError, a as InvalidStateTransitionError, c as PaymentVerificationError, d as RefundNotSupportedError, f as RevenueError, g as ValidationError, h as TransactionNotFoundError, i as ConfigurationError, l as ProviderCapabilityError, m as SubscriptionNotFoundError, n as BankFeedImportError, o as MethodKindLockedError, p as SettlementNotFoundError, r as BankFeedProviderNotFoundError, s as PaymentIntentCreationError, t as AlreadyVerifiedError, u as ProviderNotFoundError } from "./errors-Bt5NRVMq.mjs";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "../registry-
|
|
1
|
+
import { a as BankFeedProviderRegistry, c as ParseUploadParams, d as PaymentProvider, i as BankFeedProviderCapabilities, l as ParseUploadResult, n as createProviderRegistry, o as FetchTransactionsParams, r as BankFeedProvider, s as FetchTransactionsResult, t as ProviderRegistry, u as createBankFeedProviderRegistry } from "../registry-DSG7x-Cl.mjs";
|
|
2
2
|
export { BankFeedProvider, type BankFeedProviderCapabilities, BankFeedProviderRegistry, type FetchTransactionsParams, type FetchTransactionsResult, type ParseUploadParams, type ParseUploadResult, PaymentProvider, ProviderRegistry, createBankFeedProviderRegistry, createProviderRegistry };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BankFeedSourceValue } from "./bank-feed.enums-
|
|
1
|
+
import { a as BankFeedSourceValue } from "./bank-feed.enums-CqTW2Blz.mjs";
|
|
2
2
|
import { CreateIntentParams, PaymentIntent, PaymentResult, ProviderCapabilities, RefundResult, WebhookEvent } from "@classytic/primitives/payment-gateway";
|
|
3
3
|
import { BankStatement, BankTransaction } from "@classytic/primitives/bank-transaction";
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as SettlementRepository, d as RevenueModels, l as SubscriptionRepository, u as TransactionRepository } from "../engine-types-F3f1lWNG.mjs";
|
|
2
2
|
import { PluginType } from "@classytic/mongokit";
|
|
3
3
|
|
|
4
4
|
//#region src/repositories/create-repositories.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "../settlement.repository-
|
|
1
|
+
import { n as SubscriptionRepository, r as TransactionRepository, t as SettlementRepository } from "../settlement.repository-BDrJQc27.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/repositories/create-repositories.ts
|
|
4
4
|
function createRevenueRepositories(models, builtInPlugins, hostPlugins = {}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, s as initialStatusFor } from "./bank-feed.enums-
|
|
1
|
+
import { _ as TRANSACTION_STATUS, a as TRANSACTION_KIND, s as initialStatusFor } from "./bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { n as createEvent, t as REVENUE_EVENTS } from "./event-constants-DM_-A57b.mjs";
|
|
3
3
|
import { g as SETTLEMENT_STATUS, r as SUBSCRIPTION_STATUS, w as HOLD_STATUS } from "./subscription.enums-95othr0i.mjs";
|
|
4
4
|
import { _ as WrongTransactionKindError, g as ValidationError, h as TransactionNotFoundError, m as SubscriptionNotFoundError, n as BankFeedImportError, o as MethodKindLockedError, p as SettlementNotFoundError } from "./errors-Bt5NRVMq.mjs";
|
|
@@ -979,6 +979,69 @@ var TransactionRepository = class extends RevenueRepositoryBase {
|
|
|
979
979
|
return claimed;
|
|
980
980
|
}
|
|
981
981
|
/**
|
|
982
|
+
* Reconcile a bank-feed / manual row that settled a linked document
|
|
983
|
+
* (invoice/bill) WITHOUT posting a journal entry. The document's payment
|
|
984
|
+
* already owns the cash JE (`Dr Bank / Cr AR`), so the bank line only needs
|
|
985
|
+
* its status moved to `settled` — calling `match()` here would fire
|
|
986
|
+
* `LedgerBridge.onTransactionMatched` and double-count the cash. This is the
|
|
987
|
+
* package's intended path when the JE lives elsewhere (the reachable sibling
|
|
988
|
+
* of the born-`reconciled_external` import).
|
|
989
|
+
*
|
|
990
|
+
* `imported → settled` (bank_feed) / `pending → settled` (manual). Idempotent:
|
|
991
|
+
* a row already `settled` is returned unchanged, so a best-effort caller can
|
|
992
|
+
* safely re-run. The optional `metadata` is shallow-merged onto the document's
|
|
993
|
+
* `metadata` (dotted `$set`, so sibling keys survive) — hosts stamp the link
|
|
994
|
+
* back to the settling document there. No JE bridge call, no domain event:
|
|
995
|
+
* settlement is host-initiated and the host owns the reconcile audit trail.
|
|
996
|
+
*/
|
|
997
|
+
async settle(id, data = {}, ctx = {}) {
|
|
998
|
+
const existing = await this.getById(id, this.optsFromCtx(ctx));
|
|
999
|
+
if (!existing) throw new TransactionNotFoundError(id);
|
|
1000
|
+
if (existing.kind !== TRANSACTION_KIND.BANK_FEED && existing.kind !== TRANSACTION_KIND.MANUAL) throw new WrongTransactionKindError(id, "bank_feed | manual", existing.kind);
|
|
1001
|
+
if (existing.status === TRANSACTION_STATUS.SETTLED) return existing;
|
|
1002
|
+
smFor(existing.kind).validate(existing.status, TRANSACTION_STATUS.SETTLED, id);
|
|
1003
|
+
const set = {
|
|
1004
|
+
verifiedAt: /* @__PURE__ */ new Date(),
|
|
1005
|
+
...data.settledBy !== void 0 ? { verifiedBy: data.settledBy } : {}
|
|
1006
|
+
};
|
|
1007
|
+
if (data.metadata) for (const [k, v] of Object.entries(data.metadata)) set[`metadata.${k}`] = v;
|
|
1008
|
+
const claimed = await this.claim(existing._id, {
|
|
1009
|
+
from: [TRANSACTION_STATUS.IMPORTED, TRANSACTION_STATUS.PENDING],
|
|
1010
|
+
to: TRANSACTION_STATUS.SETTLED,
|
|
1011
|
+
where: { kind: existing.kind }
|
|
1012
|
+
}, { $set: set }, this.optsFromCtx(ctx));
|
|
1013
|
+
if (!claimed) throw new ValidationError(`Transaction ${id} could not be settled (race-loss or illegal state)`);
|
|
1014
|
+
return claimed;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Reverse a `settle()` — the linked document's payment was undone, so the
|
|
1018
|
+
* bank line returns to its birth status to re-enter the reconcile queue.
|
|
1019
|
+
* `settled → imported` (bank_feed) / `settled → pending` (manual). Clears
|
|
1020
|
+
* `verifiedAt`/`verifiedBy` plus any metadata keys named in `clearMetadata`
|
|
1021
|
+
* (the host-stamped link back to the now-reversed document). Idempotent: a
|
|
1022
|
+
* row not currently `settled` is returned unchanged.
|
|
1023
|
+
*/
|
|
1024
|
+
async unsettle(id, data = {}, ctx = {}) {
|
|
1025
|
+
const existing = await this.getById(id, this.optsFromCtx(ctx));
|
|
1026
|
+
if (!existing) throw new TransactionNotFoundError(id);
|
|
1027
|
+
if (existing.kind !== TRANSACTION_KIND.BANK_FEED && existing.kind !== TRANSACTION_KIND.MANUAL) throw new WrongTransactionKindError(id, "bank_feed | manual", existing.kind);
|
|
1028
|
+
if (existing.status !== TRANSACTION_STATUS.SETTLED) return existing;
|
|
1029
|
+
const target = existing.kind === TRANSACTION_KIND.MANUAL ? TRANSACTION_STATUS.PENDING : TRANSACTION_STATUS.IMPORTED;
|
|
1030
|
+
smFor(existing.kind).validate(TRANSACTION_STATUS.SETTLED, target, id);
|
|
1031
|
+
const unset = {
|
|
1032
|
+
verifiedBy: 1,
|
|
1033
|
+
verifiedAt: 1
|
|
1034
|
+
};
|
|
1035
|
+
for (const k of data.clearMetadata ?? []) unset[`metadata.${k}`] = 1;
|
|
1036
|
+
const claimed = await this.claim(existing._id, {
|
|
1037
|
+
from: TRANSACTION_STATUS.SETTLED,
|
|
1038
|
+
to: target,
|
|
1039
|
+
where: { kind: existing.kind }
|
|
1040
|
+
}, { $unset: unset }, this.optsFromCtx(ctx));
|
|
1041
|
+
if (!claimed) throw new ValidationError(`Transaction ${id} could not be un-settled (current state is not 'settled')`);
|
|
1042
|
+
return claimed;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
982
1045
|
* Stamp the journal entry reference and transition `matched →
|
|
983
1046
|
* journalized`. Typical caller is the `LedgerBridge.onTransactionMatched`
|
|
984
1047
|
* implementation — after creating a JE, it calls this verb so the row
|
|
@@ -1384,6 +1447,7 @@ var SettlementRepository = class extends RevenueRepositoryBase {
|
|
|
1384
1447
|
};
|
|
1385
1448
|
if (options.organizationId) query.organizationId = options.organizationId;
|
|
1386
1449
|
if (options.payoutMethod) query.payoutMethod = options.payoutMethod;
|
|
1450
|
+
if (options.recipientId) query.recipientId = options.recipientId;
|
|
1387
1451
|
const pending = (await this.getAll({
|
|
1388
1452
|
filters: query,
|
|
1389
1453
|
limit: options.limit ?? 50,
|
|
@@ -1499,6 +1563,53 @@ var SettlementRepository = class extends RevenueRepositoryBase {
|
|
|
1499
1563
|
}), ctx);
|
|
1500
1564
|
return updated;
|
|
1501
1565
|
}
|
|
1566
|
+
async recipientBalance(recipientId, options = {}, ctx = {}) {
|
|
1567
|
+
const match = { recipientId };
|
|
1568
|
+
if (options.recipientType !== void 0) match.recipientType = options.recipientType;
|
|
1569
|
+
if (options.currency !== void 0) match.currency = options.currency;
|
|
1570
|
+
const now = /* @__PURE__ */ new Date();
|
|
1571
|
+
const rows = await this.aggregatePipeline([{ $match: match }, { $group: {
|
|
1572
|
+
_id: {
|
|
1573
|
+
status: "$status",
|
|
1574
|
+
due: { $lte: ["$scheduledAt", now] }
|
|
1575
|
+
},
|
|
1576
|
+
total: { $sum: "$amount" },
|
|
1577
|
+
currency: { $first: "$currency" }
|
|
1578
|
+
} }], this.optsFromCtx(ctx));
|
|
1579
|
+
const balance = {
|
|
1580
|
+
recipientId,
|
|
1581
|
+
currency: options.currency ?? null,
|
|
1582
|
+
pending: 0,
|
|
1583
|
+
held: 0,
|
|
1584
|
+
available: 0,
|
|
1585
|
+
processing: 0,
|
|
1586
|
+
paidOut: 0,
|
|
1587
|
+
failed: 0,
|
|
1588
|
+
lifetime: 0
|
|
1589
|
+
};
|
|
1590
|
+
for (const row of rows) {
|
|
1591
|
+
switch (row._id.status) {
|
|
1592
|
+
case SETTLEMENT_STATUS.PENDING:
|
|
1593
|
+
balance.pending += row.total;
|
|
1594
|
+
if (row._id.due) balance.available += row.total;
|
|
1595
|
+
else balance.held += row.total;
|
|
1596
|
+
break;
|
|
1597
|
+
case SETTLEMENT_STATUS.PROCESSING:
|
|
1598
|
+
balance.processing += row.total;
|
|
1599
|
+
break;
|
|
1600
|
+
case SETTLEMENT_STATUS.COMPLETED:
|
|
1601
|
+
balance.paidOut += row.total;
|
|
1602
|
+
break;
|
|
1603
|
+
case SETTLEMENT_STATUS.FAILED:
|
|
1604
|
+
balance.failed += row.total;
|
|
1605
|
+
break;
|
|
1606
|
+
default: break;
|
|
1607
|
+
}
|
|
1608
|
+
if (row.currency && !balance.currency) balance.currency = row.currency;
|
|
1609
|
+
}
|
|
1610
|
+
balance.lifetime = balance.pending + balance.processing + balance.paidOut;
|
|
1611
|
+
return balance;
|
|
1612
|
+
}
|
|
1502
1613
|
};
|
|
1503
1614
|
|
|
1504
1615
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "../escrow.schema-
|
|
1
|
+
import { A as transactionBaseSchema, C as subscriptionBaseSchema, D as TransactionCreateInput, E as subscriptionUpdateSchema, M as transactionListFilterSchema, N as transactionUpdateSchema, O as TransactionListFilter, S as SubscriptionUpdateInput, T as subscriptionListFilterSchema, _ as settlementCreateSchema, a as escrowReleaseSchema, b as SubscriptionCreateInput, c as PaymentVerifyInput, d as paymentVerifySchema, f as refundSchema, g as settlementBaseSchema, h as SettlementUpdateInput, i as escrowHoldSchema, j as transactionCreateSchema, k as TransactionUpdateInput, l as RefundInput, m as SettlementListFilter, n as EscrowReleaseInput, o as splitRuleSchema, p as SettlementCreateInput, r as SplitRuleInput, s as PaymentIntentInput, t as EscrowHoldInput, u as paymentIntentSchema, v as settlementListFilterSchema, w as subscriptionCreateSchema, x as SubscriptionListFilter, y as settlementUpdateSchema } from "../escrow.schema-o4qhjOca.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/validators/bank-feed.schema.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES } from "../bank-feed.enums-
|
|
1
|
+
import { n as BANK_FEED_SOURCE_VALUES, o as TRANSACTION_KIND_VALUES } from "../bank-feed.enums-ByS3mjX0.mjs";
|
|
2
2
|
import { _ as transactionListFilterSchema, a as paymentVerifySchema, c as settlementCreateSchema, d as subscriptionBaseSchema, f as subscriptionCreateSchema, g as transactionCreateSchema, h as transactionBaseSchema, i as paymentIntentSchema, l as settlementListFilterSchema, m as subscriptionUpdateSchema, n as escrowReleaseSchema, o as refundSchema, p as subscriptionListFilterSchema, r as splitRuleSchema, s as settlementBaseSchema, t as escrowHoldSchema, u as settlementUpdateSchema, v as transactionUpdateSchema } from "../escrow.schema-BcKdzrJ7.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/revenue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Payment lifecycle engine — transactions, subscriptions, escrow, settlements, commissions. MongoKit-powered, Arc-compatible, framework-agnostic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|