@classytic/revenue 2.0.1 → 2.1.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/dist/bank-feed-DJtLvz_7.mjs +133 -0
- package/dist/bank-feed.enums-BadqNJTC.d.mts +118 -0
- package/dist/bank-feed.enums-kYTLTTbe.mjs +165 -0
- package/dist/bridges/index.d.mts +1 -1
- package/dist/core/state-machines.d.mts +25 -2
- package/dist/core/state-machines.mjs +43 -3
- package/dist/{engine-types-CcjIb4Fy.d.mts → engine-types-txFXOiQS.d.mts} +451 -14
- package/dist/enums/index.d.mts +4 -3
- package/dist/enums/index.mjs +4 -3
- package/dist/{errors-DHa8JVQ-.mjs → errors-Dt46UZL_.mjs} +23 -1
- package/dist/{escrow.schema-D5X32LwX.d.mts → escrow.schema-9yh4Q-aQ.d.mts} +23 -23
- package/dist/{event-constants-CEMitnIV.mjs → event-constants-CTiDNWzc.mjs} +6 -0
- package/dist/events/index.d.mts +2 -2
- package/dist/events/index.mjs +3 -3
- package/dist/index.d.mts +21 -11
- package/dist/index.mjs +120 -19
- package/dist/providers/index.d.mts +2 -2
- package/dist/providers/index.mjs +2 -2
- package/dist/registry-h8sasoLh.d.mts +145 -0
- package/dist/repositories/create-repositories.d.mts +1 -1
- package/dist/repositories/create-repositories.mjs +1 -1
- package/dist/{revenue-bridges-sdlrR85c.d.mts → revenue-bridges-BtkWFsJu.d.mts} +107 -1
- package/dist/{revenue-event-catalog-LqxPnsU_.mjs → revenue-event-catalog-CgZ57M-f.mjs} +77 -3
- package/dist/{revenue-event-catalog-BX3g7RUi.d.mts → revenue-event-catalog-JpJcyK1E.d.mts} +198 -2
- package/dist/{settlement.repository-DHIPx5S4.mjs → settlement.repository-Ba2U17zY.mjs} +559 -17
- package/dist/shared/index.d.mts +1 -1
- package/dist/shared/index.mjs +2 -2
- package/dist/{subscription.enums-tfoAgsTv.mjs → subscription.enums-DoIr56O6.mjs} +1 -40
- package/dist/{transaction.enums-u4MshXcL.d.mts → subscription.enums-k24kLpF7.d.mts} +1 -36
- package/dist/validators/index.d.mts +158 -2
- package/dist/validators/index.mjs +95 -2
- package/package.json +7 -7
- package/dist/registry-DhFMsSn5.mjs +0 -150
- package/dist/registry-SvIGPAx_.d.mts +0 -143
- /package/dist/{audit-B39B0Sdq.mjs → audit-Ba2XB2C4.mjs} +0 -0
- /package/dist/{audit-DZ0eTr9g.d.mts → audit-DRKuLBFO.d.mts} +0 -0
- /package/dist/{context-DRqSeTPM.d.mts → context-pjP1QeE3.d.mts} +0 -0
- /package/dist/{escrow.schema-BBv9oVEW.mjs → escrow.schema-C-b41z_G.mjs} +0 -0
- /package/dist/{monetization.enums-BtiU3t8o.mjs → monetization.enums-B9HBOecd.mjs} +0 -0
- /package/dist/{monetization.enums-D2xbxXJM.d.mts → monetization.enums-DzAI4sT7.d.mts} +0 -0
- /package/dist/{splits-BAfY-a9P.mjs → splits-D8XkNWgX.mjs} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { a as BankFeedSourceValue } from "./bank-feed.enums-BadqNJTC.mjs";
|
|
2
|
+
import { CreateIntentParams, PaymentIntent, PaymentResult, ProviderCapabilities, RefundResult, WebhookEvent } from "@classytic/primitives/payment-gateway";
|
|
3
|
+
import { BankStatement, BankTransaction } from "@classytic/primitives/bank-transaction";
|
|
4
|
+
|
|
5
|
+
//#region src/providers/base.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Abstract `PaymentProvider` — the contract revenue's repositories
|
|
8
|
+
* consume. Provider implementations may extend this for the default
|
|
9
|
+
* config plumbing, or just satisfy the structural shape.
|
|
10
|
+
*/
|
|
11
|
+
declare abstract class PaymentProvider {
|
|
12
|
+
readonly config: Record<string, unknown>;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
private _defaultCurrency;
|
|
15
|
+
constructor(config?: Record<string, unknown>);
|
|
16
|
+
get defaultCurrency(): string;
|
|
17
|
+
setDefaultCurrency(currency: string): void;
|
|
18
|
+
abstract createIntent(params: CreateIntentParams): Promise<PaymentIntent>;
|
|
19
|
+
abstract verifyPayment(intentId: string): Promise<PaymentResult>;
|
|
20
|
+
abstract getStatus(intentId: string): Promise<PaymentResult>;
|
|
21
|
+
abstract refund(paymentId: string, amount?: number | null, options?: {
|
|
22
|
+
reason?: string;
|
|
23
|
+
}): Promise<RefundResult>;
|
|
24
|
+
abstract handleWebhook(payload: unknown, headers?: Record<string, string>): Promise<WebhookEvent>;
|
|
25
|
+
/**
|
|
26
|
+
* Default: accept all signatures (manual / dev provider). Real
|
|
27
|
+
* gateways MUST override with HMAC / timing-safe verification.
|
|
28
|
+
*/
|
|
29
|
+
verifyWebhookSignature(_payload: unknown, _signature: string): boolean;
|
|
30
|
+
getCapabilities(): ProviderCapabilities;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/providers/bank-feed.d.ts
|
|
34
|
+
interface BankFeedProviderCapabilities {
|
|
35
|
+
/** Supports continuous sync (Plaid, QBO CDC, Xero CDC). */
|
|
36
|
+
supportsSync: boolean;
|
|
37
|
+
/** Supports file upload parsing (OFX, CAMT.053, MT940, CSV, IIF). */
|
|
38
|
+
supportsUpload: boolean;
|
|
39
|
+
/** Provider may report retracted entries (Plaid `removed[]`, OFX correction). */
|
|
40
|
+
supportsRemovals: boolean;
|
|
41
|
+
/** Cursor-resumable — `fetchTransactions` returns a `nextCursor`. */
|
|
42
|
+
cursorBased: boolean;
|
|
43
|
+
/** Multi-account in a single sync call. */
|
|
44
|
+
multiAccount: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface FetchTransactionsParams {
|
|
47
|
+
/** Resumption token from a previous call (Plaid cursor, QBO `LastUpdatedTime`, …). */
|
|
48
|
+
cursor?: string | undefined;
|
|
49
|
+
/** Account scope. May be undefined for providers that fetch all accounts. */
|
|
50
|
+
bankAccountId?: string | undefined;
|
|
51
|
+
/** Optional date floor — supplements cursor-based drains. */
|
|
52
|
+
from?: Date | undefined;
|
|
53
|
+
/** Optional date ceiling. */
|
|
54
|
+
to?: Date | undefined;
|
|
55
|
+
/** Provider-specific knobs. */
|
|
56
|
+
options?: Record<string, unknown> | undefined;
|
|
57
|
+
}
|
|
58
|
+
interface FetchTransactionsResult {
|
|
59
|
+
/** Newly added or updated rows. */
|
|
60
|
+
transactions: BankTransaction[];
|
|
61
|
+
/** Vendor-stable IDs of rows the upstream feed has retracted. */
|
|
62
|
+
removed?: Array<{
|
|
63
|
+
externalId: string;
|
|
64
|
+
bankAccountId?: string;
|
|
65
|
+
}>;
|
|
66
|
+
/** Resumption cursor for the next call. */
|
|
67
|
+
nextCursor?: string;
|
|
68
|
+
/** True when more pages are available — driver may stop calling when false. */
|
|
69
|
+
hasMore?: boolean;
|
|
70
|
+
/** Provider raw response for audit. Optional. */
|
|
71
|
+
raw?: unknown;
|
|
72
|
+
}
|
|
73
|
+
interface ParseUploadParams {
|
|
74
|
+
/** Raw upload bytes / string. */
|
|
75
|
+
buffer: Buffer | string | Uint8Array;
|
|
76
|
+
/** Format hint — providers MAY auto-detect when absent. */
|
|
77
|
+
format?: BankFeedSourceValue;
|
|
78
|
+
/** Account scope to stamp on every parsed row (when the file omits it). */
|
|
79
|
+
bankAccountId?: string;
|
|
80
|
+
/** Format-specific quirks (e.g. `'chase' | 'boa' | 'lenient'`). */
|
|
81
|
+
options?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
interface ParseUploadResult {
|
|
84
|
+
/** Statement-level metadata (account, period, balances). */
|
|
85
|
+
statements: BankStatement[];
|
|
86
|
+
/** Flat list of all rows across all statements — convenience for `import()`. */
|
|
87
|
+
transactions: BankTransaction[];
|
|
88
|
+
/** Per-row parse errors that didn't abort the file. */
|
|
89
|
+
warnings: Array<{
|
|
90
|
+
line?: number;
|
|
91
|
+
reason: string;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Bank-feed provider — implement one method or both depending on the
|
|
96
|
+
* upstream's capabilities. Mirrors the optional-method pattern that
|
|
97
|
+
* works well across PaymentProvider's gateway plurality.
|
|
98
|
+
*/
|
|
99
|
+
declare abstract class BankFeedProvider {
|
|
100
|
+
readonly config: Record<string, unknown>;
|
|
101
|
+
readonly name: string;
|
|
102
|
+
constructor(name: string, config?: Record<string, unknown>);
|
|
103
|
+
/**
|
|
104
|
+
* Fetch a batch of transactions. Cursor-based providers (Plaid)
|
|
105
|
+
* return `nextCursor` for the next call; date-range providers
|
|
106
|
+
* (older QBO Reports API) ignore cursor and use `from` / `to`.
|
|
107
|
+
* Throws if the provider does not support sync.
|
|
108
|
+
*/
|
|
109
|
+
fetchTransactions?(_params: FetchTransactionsParams): Promise<FetchTransactionsResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Parse a file upload (OFX / CAMT.053 / MT940 / CSV / IIF). The
|
|
112
|
+
* canonical implementation delegates to `@classytic/fin-io`. Throws
|
|
113
|
+
* if the provider does not support uploads.
|
|
114
|
+
*/
|
|
115
|
+
parseUpload?(_params: ParseUploadParams): Promise<ParseUploadResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Async drain — yields one batch per call until the upstream is
|
|
118
|
+
* caught up. Default implementation pulls `fetchTransactions` in a
|
|
119
|
+
* loop; providers can override for more efficient pagination
|
|
120
|
+
* (e.g. SSE / long-poll) or to interleave `removed[]` correctly.
|
|
121
|
+
*/
|
|
122
|
+
drain(params?: FetchTransactionsParams): AsyncGenerator<FetchTransactionsResult>;
|
|
123
|
+
abstract getCapabilities(): BankFeedProviderCapabilities;
|
|
124
|
+
}
|
|
125
|
+
declare class BankFeedProviderRegistry {
|
|
126
|
+
private providers;
|
|
127
|
+
register(name: string, provider: BankFeedProvider): void;
|
|
128
|
+
get(name: string): BankFeedProvider;
|
|
129
|
+
has(name: string): boolean;
|
|
130
|
+
list(): string[];
|
|
131
|
+
}
|
|
132
|
+
declare function createBankFeedProviderRegistry(providers?: Record<string, BankFeedProvider>): BankFeedProviderRegistry;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/providers/registry.d.ts
|
|
135
|
+
declare class ProviderRegistry {
|
|
136
|
+
private providers;
|
|
137
|
+
register(name: string, provider: PaymentProvider): void;
|
|
138
|
+
get(name: string): PaymentProvider;
|
|
139
|
+
has(name: string): boolean;
|
|
140
|
+
list(): string[];
|
|
141
|
+
setDefaultCurrency(currency: string): void;
|
|
142
|
+
}
|
|
143
|
+
declare function createProviderRegistry(providers?: Record<string, PaymentProvider>, defaultCurrency?: string): ProviderRegistry;
|
|
144
|
+
//#endregion
|
|
145
|
+
export { BankFeedProviderRegistry as a, ParseUploadParams as c, PaymentProvider as d, BankFeedProviderCapabilities as i, ParseUploadResult as l, createProviderRegistry as n, FetchTransactionsParams as o, BankFeedProvider as r, FetchTransactionsResult as s, ProviderRegistry as t, createBankFeedProviderRegistry as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as SubscriptionRepository, l as TransactionRepository, s as SettlementRepository, u as RevenueModels } from "../engine-types-txFXOiQS.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-Ba2U17zY.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/repositories/create-repositories.ts
|
|
4
4
|
function createRevenueRepositories(models, builtInPlugins, hostPlugins = {}) {
|
|
@@ -1,10 +1,116 @@
|
|
|
1
|
-
import { t as RevenueContext } from "./context-
|
|
1
|
+
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/bridges/ledger.bridge.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* LedgerBridge — host-implemented contract for posting revenue events
|
|
6
|
+
* into a general-ledger / accounting system.
|
|
7
|
+
*
|
|
8
|
+
* Revenue does NOT import any ledger package directly (PACKAGE_RULES §23).
|
|
9
|
+
* The host wires this bridge once at engine creation time; revenue's repo
|
|
10
|
+
* verbs call the relevant hook after each state transition. Every method
|
|
11
|
+
* is optional — features degrade gracefully when omitted.
|
|
12
|
+
*
|
|
13
|
+
* Two phases of hooks:
|
|
14
|
+
*
|
|
15
|
+
* 1. **Payment-flow hooks** (`onPaymentVerified`, `onRefundProcessed`,
|
|
16
|
+
* `onSettlementCompleted`) — the original Stripe-style integration.
|
|
17
|
+
* Fired when a gateway transaction reaches a terminal accounting
|
|
18
|
+
* moment.
|
|
19
|
+
*
|
|
20
|
+
* 2. **Bank-feed hooks** (`onTransactionImported`, `onTransactionMatched`,
|
|
21
|
+
* `onTransactionJournalized`, `onTransactionRejected`,
|
|
22
|
+
* `onTransactionUnmatched`, `onTransactionRemovedByFeed`) — added
|
|
23
|
+
* in 3.0. Fired during the bank-feed lifecycle so the host can post
|
|
24
|
+
* JEs at match time, recall them on un-match, and chain
|
|
25
|
+
* `journalize()` after a successful JE post.
|
|
26
|
+
*
|
|
27
|
+
* The canonical wiring for `onTransactionMatched` is:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const ledgerBridge: LedgerBridge = {
|
|
31
|
+
* async onTransactionMatched(txn, mapping, ctx) {
|
|
32
|
+
* const report = await wireImport({
|
|
33
|
+
* source: [{ txn, mapping }],
|
|
34
|
+
* mapper: bankToJournalEntryMapper(mapping),
|
|
35
|
+
* journalEntries: ledger.repositories.journalEntry,
|
|
36
|
+
* context: { organizationId: ctx.organizationId },
|
|
37
|
+
* }).run();
|
|
38
|
+
* if (report.ok && report.entries[0]) {
|
|
39
|
+
* await revenue.repositories.transaction.journalize(
|
|
40
|
+
* String(txn._id),
|
|
41
|
+
* { journalEntryRef: { type: 'JournalEntry', id: report.entries[0].id } },
|
|
42
|
+
* ctx,
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* },
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
4
49
|
interface LedgerBridge {
|
|
50
|
+
/** Fired when a gateway transaction reaches `verified` status. */
|
|
5
51
|
onPaymentVerified?(transaction: Record<string, unknown>, ctx: RevenueContext): Promise<void>;
|
|
52
|
+
/** Fired after a refund posts (the new outflow row + the updated original). */
|
|
6
53
|
onRefundProcessed?(original: Record<string, unknown>, refund: Record<string, unknown>, ctx: RevenueContext): Promise<void>;
|
|
54
|
+
/** Fired when a settlement record reaches `completed`. */
|
|
7
55
|
onSettlementCompleted?(settlement: Record<string, unknown>, ctx: RevenueContext): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Fired once per row inserted by `import()`. Use this for live preview
|
|
58
|
+
* dashboards or downstream materialized views — most production hosts
|
|
59
|
+
* leave this unimplemented and act on the per-batch `events.publish`
|
|
60
|
+
* stream instead.
|
|
61
|
+
*/
|
|
62
|
+
onTransactionImported?(transaction: Record<string, unknown>, ctx: RevenueContext): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Fired after `match()` succeeds. The host's typical implementation
|
|
65
|
+
* posts a journal entry via the host's ledger package (e.g. arc's
|
|
66
|
+
* `wireImport` over `@classytic/ledger`'s `journalEntry` repository),
|
|
67
|
+
* then calls `revenue.repositories.transaction.journalize(id, …)` so
|
|
68
|
+
* the row transitions `matched → journalized`.
|
|
69
|
+
*/
|
|
70
|
+
onTransactionMatched?(transaction: Record<string, unknown>, mapping: {
|
|
71
|
+
debitAccount?: string;
|
|
72
|
+
creditAccount?: string;
|
|
73
|
+
notes?: string;
|
|
74
|
+
}, ctx: RevenueContext): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Fired after `unmatch()` succeeds. Hosts can void / reverse the
|
|
77
|
+
* journal entry created at match time. Pass the prior
|
|
78
|
+
* `journalEntryRef` so reversal is keyed correctly.
|
|
79
|
+
*/
|
|
80
|
+
onTransactionUnmatched?(transaction: Record<string, unknown>, priorJournalEntryRef: {
|
|
81
|
+
type: string;
|
|
82
|
+
id: string;
|
|
83
|
+
} | undefined, ctx: RevenueContext): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Fired after `journalize()` stamps `journalEntryRef` on the row.
|
|
86
|
+
* Most hosts are passive on this hook (the JE was created in
|
|
87
|
+
* `onTransactionMatched`); useful for audit logs and analytics.
|
|
88
|
+
*/
|
|
89
|
+
onTransactionJournalized?(transaction: Record<string, unknown>, journalEntryRef: {
|
|
90
|
+
type: string;
|
|
91
|
+
id: string;
|
|
92
|
+
}, ctx: RevenueContext): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Fired after `reject()` — operator skip on a duplicate / non-cash
|
|
95
|
+
* import. Hosts typically log for audit.
|
|
96
|
+
*
|
|
97
|
+
* **JE reversal contract.** `reject()` is legal from `'matched'` as
|
|
98
|
+
* well as `'imported'`. If your `onTransactionMatched` posted a JE
|
|
99
|
+
* synchronously (the typical bridge implementation), the JE must be
|
|
100
|
+
* reversed here — revenue itself never calls into ledger and has no
|
|
101
|
+
* way to know one exists. Idempotency is the bridge's responsibility:
|
|
102
|
+
* a reject on a never-journalized row should be a no-op for ledger,
|
|
103
|
+
* a reject after journalize should void the JE keyed off
|
|
104
|
+
* `transaction.matching` or whatever the host stamped at match time.
|
|
105
|
+
*/
|
|
106
|
+
onTransactionRejected?(transaction: Record<string, unknown>, reason: string, ctx: RevenueContext): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Fired when the upstream feed retracts a row (Plaid `removed[]`,
|
|
109
|
+
* OFX correction, QBO CDC delete). The transaction is soft-deleted
|
|
110
|
+
* before this hook runs. If a JE was already posted, the host
|
|
111
|
+
* should reverse it.
|
|
112
|
+
*/
|
|
113
|
+
onTransactionRemovedByFeed?(transaction: Record<string, unknown>, ctx: RevenueContext): Promise<void>;
|
|
8
114
|
}
|
|
9
115
|
//#endregion
|
|
10
116
|
//#region src/bridges/tax.bridge.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as REVENUE_EVENTS } from "./event-constants-
|
|
1
|
+
import { t as REVENUE_EVENTS } from "./event-constants-CTiDNWzc.mjs";
|
|
2
2
|
import { createEvent, matchEventPattern } from "@classytic/primitives/events";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
@@ -225,6 +225,44 @@ const webhookProcessedSchema = z.object({
|
|
|
225
225
|
event: z.record(z.string(), z.unknown()),
|
|
226
226
|
transaction: transactionRef.optional()
|
|
227
227
|
});
|
|
228
|
+
const transactionImportedSchema = z.object({
|
|
229
|
+
transaction: transactionRef,
|
|
230
|
+
source: z.string(),
|
|
231
|
+
bankAccountId: z.string(),
|
|
232
|
+
externalId: z.string()
|
|
233
|
+
});
|
|
234
|
+
const transactionMatchedSchema = z.object({
|
|
235
|
+
transaction: transactionRef,
|
|
236
|
+
mapping: z.object({
|
|
237
|
+
debitAccount: z.string().optional(),
|
|
238
|
+
creditAccount: z.string().optional(),
|
|
239
|
+
notes: z.string().optional()
|
|
240
|
+
}).passthrough(),
|
|
241
|
+
relatedTransactionId: z.string().optional(),
|
|
242
|
+
matchedBy: z.string().optional()
|
|
243
|
+
});
|
|
244
|
+
const transactionUnmatchedSchema = z.object({
|
|
245
|
+
transaction: transactionRef,
|
|
246
|
+
unmatchedBy: z.string().optional()
|
|
247
|
+
});
|
|
248
|
+
const transactionJournalizedSchema = z.object({
|
|
249
|
+
transaction: transactionRef,
|
|
250
|
+
journalEntryRef: z.object({
|
|
251
|
+
type: z.string(),
|
|
252
|
+
id: z.string()
|
|
253
|
+
}),
|
|
254
|
+
journalizedBy: z.string().optional()
|
|
255
|
+
});
|
|
256
|
+
const transactionRejectedSchema = z.object({
|
|
257
|
+
transaction: transactionRef,
|
|
258
|
+
reason: z.string().min(1),
|
|
259
|
+
rejectedBy: z.string().optional()
|
|
260
|
+
});
|
|
261
|
+
const transactionRemovedByFeedSchema = z.object({
|
|
262
|
+
transaction: transactionRef,
|
|
263
|
+
source: z.string(),
|
|
264
|
+
externalId: z.string()
|
|
265
|
+
});
|
|
228
266
|
const PaymentVerified = defineRevenueEvent({
|
|
229
267
|
name: REVENUE_EVENTS.PAYMENT_VERIFIED,
|
|
230
268
|
description: "A payment transaction was verified by its provider.",
|
|
@@ -350,6 +388,36 @@ const WebhookProcessed = defineRevenueEvent({
|
|
|
350
388
|
description: "A provider webhook was processed by the revenue engine.",
|
|
351
389
|
zodSchema: webhookProcessedSchema
|
|
352
390
|
});
|
|
391
|
+
const TransactionImported = defineRevenueEvent({
|
|
392
|
+
name: REVENUE_EVENTS.TRANSACTION_IMPORTED,
|
|
393
|
+
description: "A bank-feed / accounting-feed row was imported.",
|
|
394
|
+
zodSchema: transactionImportedSchema
|
|
395
|
+
});
|
|
396
|
+
const TransactionMatched = defineRevenueEvent({
|
|
397
|
+
name: REVENUE_EVENTS.TRANSACTION_MATCHED,
|
|
398
|
+
description: "A bank-feed / manual transaction was matched to GL accounts (and optionally to an upstream payment-flow row).",
|
|
399
|
+
zodSchema: transactionMatchedSchema
|
|
400
|
+
});
|
|
401
|
+
const TransactionUnmatched = defineRevenueEvent({
|
|
402
|
+
name: REVENUE_EVENTS.TRANSACTION_UNMATCHED,
|
|
403
|
+
description: "A previously-matched bank-feed transaction was reverted to the imported state.",
|
|
404
|
+
zodSchema: transactionUnmatchedSchema
|
|
405
|
+
});
|
|
406
|
+
const TransactionJournalized = defineRevenueEvent({
|
|
407
|
+
name: REVENUE_EVENTS.TRANSACTION_JOURNALIZED,
|
|
408
|
+
description: "A bank-feed / manual transaction was journalized — the host LedgerBridge produced a journal entry.",
|
|
409
|
+
zodSchema: transactionJournalizedSchema
|
|
410
|
+
});
|
|
411
|
+
const TransactionRejected = defineRevenueEvent({
|
|
412
|
+
name: REVENUE_EVENTS.TRANSACTION_REJECTED,
|
|
413
|
+
description: "A bank-feed / manual transaction was rejected (operator skip — typically a duplicate / non-cash entry).",
|
|
414
|
+
zodSchema: transactionRejectedSchema
|
|
415
|
+
});
|
|
416
|
+
const TransactionRemovedByFeed = defineRevenueEvent({
|
|
417
|
+
name: REVENUE_EVENTS.TRANSACTION_REMOVED_BY_FEED,
|
|
418
|
+
description: "The upstream feed retracted a previously-imported row (Plaid `removed[]`, OFX correction). The row is soft-deleted.",
|
|
419
|
+
zodSchema: transactionRemovedByFeedSchema
|
|
420
|
+
});
|
|
353
421
|
/**
|
|
354
422
|
* Every revenue event defined in the package — pass to Arc's
|
|
355
423
|
* `EventRegistry`. Hosts wire ONE array; the whole `revenue:*` namespace
|
|
@@ -381,8 +449,14 @@ const revenueEventDefinitions = [
|
|
|
381
449
|
SettlementProcessing,
|
|
382
450
|
SettlementCompleted,
|
|
383
451
|
SettlementFailed,
|
|
384
|
-
WebhookProcessed
|
|
452
|
+
WebhookProcessed,
|
|
453
|
+
TransactionImported,
|
|
454
|
+
TransactionMatched,
|
|
455
|
+
TransactionUnmatched,
|
|
456
|
+
TransactionJournalized,
|
|
457
|
+
TransactionRejected,
|
|
458
|
+
TransactionRemovedByFeed
|
|
385
459
|
];
|
|
386
460
|
|
|
387
461
|
//#endregion
|
|
388
|
-
export { SubscriptionResumed as C,
|
|
462
|
+
export { TransactionUpdated as A, SubscriptionResumed as C, TransactionRejected as D, TransactionMatched as E, revenueEventDefinitions as M, InProcessRevenueBus as N, TransactionRemovedByFeed as O, SubscriptionRenewed as S, TransactionJournalized as T, SettlementScheduled as _, FreeCreated as a, SubscriptionCreated as b, PaymentProcessing as c, PaymentVerified as d, PurchaseCreated as f, SettlementProcessing as g, SettlementFailed as h, EscrowSplit as i, WebhookProcessed as j, TransactionUnmatched as k, PaymentRefunded as l, SettlementCreated as m, EscrowHeld as n, MonetizationCreated as o, SettlementCompleted as p, EscrowReleased as r, PaymentFailed as s, EscrowCancelled as t, PaymentRequiresAction as u, SubscriptionActivated as v, TransactionImported as w, SubscriptionPaused as x, SubscriptionCancelled as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RevenueContext } from "./context-
|
|
1
|
+
import { t as RevenueContext } from "./context-pjP1QeE3.mjs";
|
|
2
2
|
import { DomainEvent, EventHandler, EventMeta, EventTransport } from "@classytic/primitives/events";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
@@ -39,6 +39,12 @@ declare const REVENUE_EVENTS: {
|
|
|
39
39
|
readonly SUBSCRIPTION_PAUSED: "revenue:subscription.paused";
|
|
40
40
|
readonly SUBSCRIPTION_RESUMED: "revenue:subscription.resumed";
|
|
41
41
|
readonly TRANSACTION_UPDATED: "revenue:transaction.updated";
|
|
42
|
+
readonly TRANSACTION_IMPORTED: "revenue:transaction.imported";
|
|
43
|
+
readonly TRANSACTION_MATCHED: "revenue:transaction.matched";
|
|
44
|
+
readonly TRANSACTION_UNMATCHED: "revenue:transaction.unmatched";
|
|
45
|
+
readonly TRANSACTION_JOURNALIZED: "revenue:transaction.journalized";
|
|
46
|
+
readonly TRANSACTION_REJECTED: "revenue:transaction.rejected";
|
|
47
|
+
readonly TRANSACTION_REMOVED_BY_FEED: "revenue:transaction.removed_by_feed";
|
|
42
48
|
readonly ESCROW_HELD: "revenue:escrow.held";
|
|
43
49
|
readonly ESCROW_RELEASED: "revenue:escrow.released";
|
|
44
50
|
readonly ESCROW_CANCELLED: "revenue:escrow.cancelled";
|
|
@@ -430,6 +436,98 @@ declare const webhookProcessedSchema: z.ZodObject<{
|
|
|
430
436
|
}, z.core.$strip>>;
|
|
431
437
|
}, z.core.$loose>>;
|
|
432
438
|
}, z.core.$strip>;
|
|
439
|
+
declare const transactionImportedSchema: z.ZodObject<{
|
|
440
|
+
transaction: z.ZodObject<{
|
|
441
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
442
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
443
|
+
status: z.ZodOptional<z.ZodString>;
|
|
444
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
445
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
446
|
+
amount: z.ZodNumber;
|
|
447
|
+
currency: z.ZodString;
|
|
448
|
+
}, z.core.$strip>>;
|
|
449
|
+
}, z.core.$loose>;
|
|
450
|
+
source: z.ZodString;
|
|
451
|
+
bankAccountId: z.ZodString;
|
|
452
|
+
externalId: z.ZodString;
|
|
453
|
+
}, z.core.$strip>;
|
|
454
|
+
declare const transactionMatchedSchema: z.ZodObject<{
|
|
455
|
+
transaction: z.ZodObject<{
|
|
456
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
457
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
458
|
+
status: z.ZodOptional<z.ZodString>;
|
|
459
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
460
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
461
|
+
amount: z.ZodNumber;
|
|
462
|
+
currency: z.ZodString;
|
|
463
|
+
}, z.core.$strip>>;
|
|
464
|
+
}, z.core.$loose>;
|
|
465
|
+
mapping: z.ZodObject<{
|
|
466
|
+
debitAccount: z.ZodOptional<z.ZodString>;
|
|
467
|
+
creditAccount: z.ZodOptional<z.ZodString>;
|
|
468
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
469
|
+
}, z.core.$loose>;
|
|
470
|
+
relatedTransactionId: z.ZodOptional<z.ZodString>;
|
|
471
|
+
matchedBy: z.ZodOptional<z.ZodString>;
|
|
472
|
+
}, z.core.$strip>;
|
|
473
|
+
declare const transactionUnmatchedSchema: z.ZodObject<{
|
|
474
|
+
transaction: z.ZodObject<{
|
|
475
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
476
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
477
|
+
status: z.ZodOptional<z.ZodString>;
|
|
478
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
479
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
480
|
+
amount: z.ZodNumber;
|
|
481
|
+
currency: z.ZodString;
|
|
482
|
+
}, z.core.$strip>>;
|
|
483
|
+
}, z.core.$loose>;
|
|
484
|
+
unmatchedBy: z.ZodOptional<z.ZodString>;
|
|
485
|
+
}, z.core.$strip>;
|
|
486
|
+
declare const transactionJournalizedSchema: z.ZodObject<{
|
|
487
|
+
transaction: z.ZodObject<{
|
|
488
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
489
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
490
|
+
status: z.ZodOptional<z.ZodString>;
|
|
491
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
492
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
493
|
+
amount: z.ZodNumber;
|
|
494
|
+
currency: z.ZodString;
|
|
495
|
+
}, z.core.$strip>>;
|
|
496
|
+
}, z.core.$loose>;
|
|
497
|
+
journalEntryRef: z.ZodObject<{
|
|
498
|
+
type: z.ZodString;
|
|
499
|
+
id: z.ZodString;
|
|
500
|
+
}, z.core.$strip>;
|
|
501
|
+
journalizedBy: z.ZodOptional<z.ZodString>;
|
|
502
|
+
}, z.core.$strip>;
|
|
503
|
+
declare const transactionRejectedSchema: z.ZodObject<{
|
|
504
|
+
transaction: z.ZodObject<{
|
|
505
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
506
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
507
|
+
status: z.ZodOptional<z.ZodString>;
|
|
508
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
509
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
510
|
+
amount: z.ZodNumber;
|
|
511
|
+
currency: z.ZodString;
|
|
512
|
+
}, z.core.$strip>>;
|
|
513
|
+
}, z.core.$loose>;
|
|
514
|
+
reason: z.ZodString;
|
|
515
|
+
rejectedBy: z.ZodOptional<z.ZodString>;
|
|
516
|
+
}, z.core.$strip>;
|
|
517
|
+
declare const transactionRemovedByFeedSchema: z.ZodObject<{
|
|
518
|
+
transaction: z.ZodObject<{
|
|
519
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
520
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
521
|
+
status: z.ZodOptional<z.ZodString>;
|
|
522
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
523
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
524
|
+
amount: z.ZodNumber;
|
|
525
|
+
currency: z.ZodString;
|
|
526
|
+
}, z.core.$strip>>;
|
|
527
|
+
}, z.core.$loose>;
|
|
528
|
+
source: z.ZodString;
|
|
529
|
+
externalId: z.ZodString;
|
|
530
|
+
}, z.core.$strip>;
|
|
433
531
|
type PaymentVerifiedPayload = z.infer<typeof paymentVerifiedSchema>;
|
|
434
532
|
type PaymentFailedPayload = z.infer<typeof paymentFailedSchema>;
|
|
435
533
|
type PaymentProcessingPayload = z.infer<typeof paymentProcessingSchema>;
|
|
@@ -455,6 +553,12 @@ type SettlementProcessingPayload = z.infer<typeof settlementProcessingSchema>;
|
|
|
455
553
|
type SettlementCompletedPayload = z.infer<typeof settlementCompletedSchema>;
|
|
456
554
|
type SettlementFailedPayload = z.infer<typeof settlementFailedSchema>;
|
|
457
555
|
type WebhookProcessedPayload = z.infer<typeof webhookProcessedSchema>;
|
|
556
|
+
type TransactionImportedPayload = z.infer<typeof transactionImportedSchema>;
|
|
557
|
+
type TransactionMatchedPayload = z.infer<typeof transactionMatchedSchema>;
|
|
558
|
+
type TransactionUnmatchedPayload = z.infer<typeof transactionUnmatchedSchema>;
|
|
559
|
+
type TransactionJournalizedPayload = z.infer<typeof transactionJournalizedSchema>;
|
|
560
|
+
type TransactionRejectedPayload = z.infer<typeof transactionRejectedSchema>;
|
|
561
|
+
type TransactionRemovedByFeedPayload = z.infer<typeof transactionRemovedByFeedSchema>;
|
|
458
562
|
declare const PaymentVerified: RevenueEventDefinition<z.ZodObject<{
|
|
459
563
|
transaction: z.ZodObject<{
|
|
460
564
|
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
@@ -812,6 +916,98 @@ declare const WebhookProcessed: RevenueEventDefinition<z.ZodObject<{
|
|
|
812
916
|
}, z.core.$strip>>;
|
|
813
917
|
}, z.core.$loose>>;
|
|
814
918
|
}, z.core.$strip>>;
|
|
919
|
+
declare const TransactionImported: RevenueEventDefinition<z.ZodObject<{
|
|
920
|
+
transaction: z.ZodObject<{
|
|
921
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
922
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
923
|
+
status: z.ZodOptional<z.ZodString>;
|
|
924
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
925
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
926
|
+
amount: z.ZodNumber;
|
|
927
|
+
currency: z.ZodString;
|
|
928
|
+
}, z.core.$strip>>;
|
|
929
|
+
}, z.core.$loose>;
|
|
930
|
+
source: z.ZodString;
|
|
931
|
+
bankAccountId: z.ZodString;
|
|
932
|
+
externalId: z.ZodString;
|
|
933
|
+
}, z.core.$strip>>;
|
|
934
|
+
declare const TransactionMatched: RevenueEventDefinition<z.ZodObject<{
|
|
935
|
+
transaction: z.ZodObject<{
|
|
936
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
937
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
938
|
+
status: z.ZodOptional<z.ZodString>;
|
|
939
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
940
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
941
|
+
amount: z.ZodNumber;
|
|
942
|
+
currency: z.ZodString;
|
|
943
|
+
}, z.core.$strip>>;
|
|
944
|
+
}, z.core.$loose>;
|
|
945
|
+
mapping: z.ZodObject<{
|
|
946
|
+
debitAccount: z.ZodOptional<z.ZodString>;
|
|
947
|
+
creditAccount: z.ZodOptional<z.ZodString>;
|
|
948
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
949
|
+
}, z.core.$loose>;
|
|
950
|
+
relatedTransactionId: z.ZodOptional<z.ZodString>;
|
|
951
|
+
matchedBy: z.ZodOptional<z.ZodString>;
|
|
952
|
+
}, z.core.$strip>>;
|
|
953
|
+
declare const TransactionUnmatched: RevenueEventDefinition<z.ZodObject<{
|
|
954
|
+
transaction: z.ZodObject<{
|
|
955
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
956
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
957
|
+
status: z.ZodOptional<z.ZodString>;
|
|
958
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
959
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
960
|
+
amount: z.ZodNumber;
|
|
961
|
+
currency: z.ZodString;
|
|
962
|
+
}, z.core.$strip>>;
|
|
963
|
+
}, z.core.$loose>;
|
|
964
|
+
unmatchedBy: z.ZodOptional<z.ZodString>;
|
|
965
|
+
}, z.core.$strip>>;
|
|
966
|
+
declare const TransactionJournalized: RevenueEventDefinition<z.ZodObject<{
|
|
967
|
+
transaction: z.ZodObject<{
|
|
968
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
969
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
970
|
+
status: z.ZodOptional<z.ZodString>;
|
|
971
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
972
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
973
|
+
amount: z.ZodNumber;
|
|
974
|
+
currency: z.ZodString;
|
|
975
|
+
}, z.core.$strip>>;
|
|
976
|
+
}, z.core.$loose>;
|
|
977
|
+
journalEntryRef: z.ZodObject<{
|
|
978
|
+
type: z.ZodString;
|
|
979
|
+
id: z.ZodString;
|
|
980
|
+
}, z.core.$strip>;
|
|
981
|
+
journalizedBy: z.ZodOptional<z.ZodString>;
|
|
982
|
+
}, z.core.$strip>>;
|
|
983
|
+
declare const TransactionRejected: RevenueEventDefinition<z.ZodObject<{
|
|
984
|
+
transaction: z.ZodObject<{
|
|
985
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
986
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
987
|
+
status: z.ZodOptional<z.ZodString>;
|
|
988
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
989
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
990
|
+
amount: z.ZodNumber;
|
|
991
|
+
currency: z.ZodString;
|
|
992
|
+
}, z.core.$strip>>;
|
|
993
|
+
}, z.core.$loose>;
|
|
994
|
+
reason: z.ZodString;
|
|
995
|
+
rejectedBy: z.ZodOptional<z.ZodString>;
|
|
996
|
+
}, z.core.$strip>>;
|
|
997
|
+
declare const TransactionRemovedByFeed: RevenueEventDefinition<z.ZodObject<{
|
|
998
|
+
transaction: z.ZodObject<{
|
|
999
|
+
_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodAny]>>;
|
|
1000
|
+
publicId: z.ZodOptional<z.ZodString>;
|
|
1001
|
+
status: z.ZodOptional<z.ZodString>;
|
|
1002
|
+
monetizationType: z.ZodOptional<z.ZodString>;
|
|
1003
|
+
amount: z.ZodOptional<z.ZodObject<{
|
|
1004
|
+
amount: z.ZodNumber;
|
|
1005
|
+
currency: z.ZodString;
|
|
1006
|
+
}, z.core.$strip>>;
|
|
1007
|
+
}, z.core.$loose>;
|
|
1008
|
+
source: z.ZodString;
|
|
1009
|
+
externalId: z.ZodString;
|
|
1010
|
+
}, z.core.$strip>>;
|
|
815
1011
|
/**
|
|
816
1012
|
* Every revenue event defined in the package — pass to Arc's
|
|
817
1013
|
* `EventRegistry`. Hosts wire ONE array; the whole `revenue:*` namespace
|
|
@@ -820,4 +1016,4 @@ declare const WebhookProcessed: RevenueEventDefinition<z.ZodObject<{
|
|
|
820
1016
|
*/
|
|
821
1017
|
declare const revenueEventDefinitions: ReadonlyArray<RevenueEventDefinition>;
|
|
822
1018
|
//#endregion
|
|
823
|
-
export {
|
|
1019
|
+
export { TransactionJournalizedPayload as $, SettlementCreated as A, SubscriptionCancelled as B, PurchaseCreated as C, RevenueEventSchema as D, RevenueEventPayloadOf as E, SettlementProcessingPayload as F, SubscriptionPausedPayload as G, SubscriptionCreated as H, SettlementScheduled as I, SubscriptionResumed as J, SubscriptionRenewed as K, SettlementScheduledPayload as L, SettlementFailed as M, SettlementFailedPayload as N, SettlementCompleted as O, SettlementProcessing as P, TransactionJournalized as Q, SubscriptionActivated as R, PaymentVerifiedPayload as S, RevenueEventDefinition as T, SubscriptionCreatedPayload as U, SubscriptionCancelledPayload as V, SubscriptionPaused as W, TransactionImported as X, SubscriptionResumedPayload as Y, TransactionImportedPayload as Z, PaymentRefunded as _, InProcessRevenueBusOptions as _t, EscrowReleased as a, TransactionRemovedByFeedPayload as at, PaymentRequiresActionPayload as b, EscrowSplitPayload as c, TransactionUpdated as ct, MonetizationCreated as d, WebhookProcessedPayload as dt, TransactionMatched as et, MonetizationCreatedPayload as f, revenueEventDefinitions as ft, PaymentProcessingPayload as g, InProcessRevenueBus as gt, PaymentProcessing as h, createEvent$1 as ht, EscrowHeldPayload as i, TransactionRemovedByFeed as it, SettlementCreatedPayload as j, SettlementCompletedPayload as k, FreeCreated as l, TransactionUpdatedPayload as lt, PaymentFailedPayload as m, RevenueEventName as mt, EscrowCancelledPayload as n, TransactionRejected as nt, EscrowReleasedPayload as o, TransactionUnmatched as ot, PaymentFailed as p, REVENUE_EVENTS as pt, SubscriptionRenewedPayload as q, EscrowHeld as r, TransactionRejectedPayload as rt, EscrowSplit as s, TransactionUnmatchedPayload as st, EscrowCancelled as t, TransactionMatchedPayload as tt, FreeCreatedPayload as u, WebhookProcessed as ut, PaymentRefundedPayload as v, PurchaseCreatedPayload as w, PaymentVerified as x, PaymentRequiresAction as y, SubscriptionActivatedPayload as z };
|