@classytic/revenue 1.1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +638 -632
- package/dist/audit-B39B0Sdq.mjs +53 -0
- package/dist/audit-DZ0eTr9g.d.mts +89 -0
- package/dist/bridges/index.d.mts +2 -0
- package/dist/bridges/index.mjs +1 -0
- package/dist/context-DRqSeTPM.d.mts +35 -0
- package/dist/core/state-machines.d.mts +35 -0
- package/dist/core/state-machines.mjs +134 -0
- package/dist/engine-types-CcjIb4Fy.d.mts +611 -0
- package/dist/enums/index.d.mts +3 -157
- package/dist/enums/index.mjs +3 -55
- package/dist/errors-DHa8JVQ-.mjs +92 -0
- package/dist/escrow.schema-BBv9oVEW.mjs +322 -0
- package/dist/escrow.schema-CC8XuD46.d.mts +629 -0
- package/dist/event-constants-CEMitnIV.mjs +53 -0
- package/dist/events/index.d.mts +3 -0
- package/dist/events/index.mjs +4 -0
- package/dist/index.d.mts +77 -9
- package/dist/index.mjs +465 -29
- package/dist/monetization.enums-BtiU3t8o.mjs +39 -0
- package/dist/monetization.enums-D2xbxXJM.d.mts +34 -0
- package/dist/plugins/plugin.interface.d.mts +28 -0
- package/dist/plugins/plugin.interface.mjs +26 -0
- package/dist/providers/index.d.mts +2 -3
- package/dist/providers/index.mjs +2 -2
- package/dist/{base-DCoyIUj6.mjs → registry-DhFMsSn5.mjs} +34 -36
- package/dist/{base-CsTlVQJe.d.mts → registry-SvIGPAx_.d.mts} +73 -66
- package/dist/repositories/create-repositories.d.mts +21 -0
- package/dist/repositories/create-repositories.mjs +12 -0
- package/dist/revenue-bridges-sdlrR85c.d.mts +145 -0
- package/dist/revenue-event-catalog-BX3g7RUi.d.mts +823 -0
- package/dist/revenue-event-catalog-LqxPnsU_.mjs +388 -0
- package/dist/settlement.repository-Cy3mMWGH.mjs +771 -0
- package/dist/shared/index.d.mts +2 -0
- package/dist/shared/index.mjs +4 -0
- package/dist/split.enums-CQE3ekH1.mjs +172 -0
- package/dist/split.enums-Dw4zCrcZ.d.mts +154 -0
- package/dist/splits-BAfY-a9P.mjs +123 -0
- package/dist/validators/index.d.mts +2 -0
- package/dist/validators/index.mjs +3 -0
- package/package.json +33 -37
- package/dist/application/services/index.d.mts +0 -4
- package/dist/application/services/index.mjs +0 -3
- package/dist/category-resolver-DV83N8ok.mjs +0 -284
- package/dist/commission-split-BzB8cd39.mjs +0 -485
- package/dist/core/events.d.mts +0 -294
- package/dist/core/events.mjs +0 -100
- package/dist/core/index.d.mts +0 -9
- package/dist/core/index.mjs +0 -8
- package/dist/errors-rRdOqnWx.d.mts +0 -787
- package/dist/escrow.enums-CZGrrdg7.mjs +0 -101
- package/dist/escrow.enums-DwdLuuve.d.mts +0 -78
- package/dist/idempotency-DaYcUGY1.mjs +0 -172
- package/dist/index-Dsp7H5Wb.d.mts +0 -471
- package/dist/infrastructure/plugins/index.d.mts +0 -239
- package/dist/infrastructure/plugins/index.mjs +0 -345
- package/dist/money-CvrDOijQ.mjs +0 -271
- package/dist/money-DPG8AtJ8.d.mts +0 -112
- package/dist/payment.enums-HAuAS9Pp.d.mts +0 -70
- package/dist/payment.enums-tEFVa-Xp.mjs +0 -69
- package/dist/plugin-BbK0OVHy.d.mts +0 -327
- package/dist/plugin-Cd_V04Em.mjs +0 -210
- package/dist/reconciliation/index.d.mts +0 -193
- package/dist/reconciliation/index.mjs +0 -192
- package/dist/retry-HHCOXYdn.d.mts +0 -186
- package/dist/revenue-BhdS7nXh.mjs +0 -553
- package/dist/schemas/index.d.mts +0 -2665
- package/dist/schemas/index.mjs +0 -717
- package/dist/schemas/validation.d.mts +0 -375
- package/dist/schemas/validation.mjs +0 -325
- package/dist/settlement.enums-DFhkqZEY.d.mts +0 -132
- package/dist/settlement.schema-DnNSFpGd.d.mts +0 -344
- package/dist/settlement.service-DjzAjezU.d.mts +0 -594
- package/dist/settlement.service-DmdKv0Zu.mjs +0 -2511
- package/dist/split.enums-BrjabxIX.mjs +0 -86
- package/dist/split.enums-DmskfLOM.d.mts +0 -43
- package/dist/tax-BoCt5cEd.d.mts +0 -61
- package/dist/tax-EQ15DO81.mjs +0 -162
- package/dist/transaction.enums-pCyMFT4Z.mjs +0 -96
- package/dist/utils/index.d.mts +0 -428
- package/dist/utils/index.mjs +0 -346
package/dist/core/events.d.mts
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { B as TransactionDocument, F as SplitInfo, R as SubscriptionDocument, W as WebhookEventData, _ as PaymentIntentData, b as PaymentResultData } from "../index-Dsp7H5Wb.mjs";
|
|
2
|
-
import { t as SettlementDocument } from "../settlement.schema-DnNSFpGd.mjs";
|
|
3
|
-
import { i as RefundResult, r as PaymentResult } from "../base-CsTlVQJe.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/core/events.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* All revenue events with their payload types
|
|
8
|
-
*/
|
|
9
|
-
interface RevenueEvents {
|
|
10
|
-
'payment.verified': PaymentVerifiedEvent;
|
|
11
|
-
'payment.failed': PaymentFailedEvent;
|
|
12
|
-
'payment.refunded': PaymentRefundedEvent;
|
|
13
|
-
'payment.requires_action': PaymentRequiresActionEvent;
|
|
14
|
-
'payment.processing': PaymentProcessingEvent;
|
|
15
|
-
'monetization.created': MonetizationCreatedEvent;
|
|
16
|
-
'purchase.created': PurchaseCreatedEvent;
|
|
17
|
-
'free.created': FreeCreatedEvent;
|
|
18
|
-
'subscription.created': SubscriptionCreatedEvent;
|
|
19
|
-
'subscription.activated': SubscriptionActivatedEvent;
|
|
20
|
-
'subscription.renewed': SubscriptionRenewedEvent;
|
|
21
|
-
'subscription.cancelled': SubscriptionCancelledEvent;
|
|
22
|
-
'subscription.paused': SubscriptionPausedEvent;
|
|
23
|
-
'subscription.resumed': SubscriptionResumedEvent;
|
|
24
|
-
'transaction.updated': TransactionUpdatedEvent;
|
|
25
|
-
'escrow.held': EscrowHeldEvent;
|
|
26
|
-
'escrow.released': EscrowReleasedEvent;
|
|
27
|
-
'escrow.cancelled': EscrowCancelledEvent;
|
|
28
|
-
'escrow.split': EscrowSplitEvent;
|
|
29
|
-
'settlement.created': SettlementCreatedEvent;
|
|
30
|
-
'settlement.scheduled': SettlementScheduledEvent;
|
|
31
|
-
'settlement.processing': SettlementProcessingEvent;
|
|
32
|
-
'settlement.completed': SettlementCompletedEvent;
|
|
33
|
-
'settlement.failed': SettlementFailedEvent;
|
|
34
|
-
'webhook.processed': WebhookProcessedEvent;
|
|
35
|
-
'*': BaseEvent;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Base event with auto-injected fields (type + timestamp added by EventBus)
|
|
39
|
-
*/
|
|
40
|
-
interface BaseEvent {
|
|
41
|
-
readonly type: string;
|
|
42
|
-
readonly timestamp: Date;
|
|
43
|
-
readonly metadata?: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
/** Derive a full event type from its data type */
|
|
46
|
-
type EventOf<K extends string, D> = D & BaseEvent & {
|
|
47
|
-
readonly type: K;
|
|
48
|
-
};
|
|
49
|
-
interface PaymentVerifiedEventData {
|
|
50
|
-
transaction: TransactionDocument;
|
|
51
|
-
paymentResult: PaymentResult | PaymentResultData;
|
|
52
|
-
verifiedBy?: string | null;
|
|
53
|
-
}
|
|
54
|
-
interface PaymentFailedEventData {
|
|
55
|
-
transaction: TransactionDocument;
|
|
56
|
-
error: string;
|
|
57
|
-
provider: string;
|
|
58
|
-
paymentIntentId: string;
|
|
59
|
-
}
|
|
60
|
-
interface PaymentRefundedEventData {
|
|
61
|
-
transaction: TransactionDocument;
|
|
62
|
-
refundTransaction: TransactionDocument;
|
|
63
|
-
refundResult: RefundResult;
|
|
64
|
-
refundAmount: number;
|
|
65
|
-
reason?: string;
|
|
66
|
-
isPartialRefund: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface PaymentRequiresActionEventData {
|
|
69
|
-
transaction: TransactionDocument;
|
|
70
|
-
paymentResult: PaymentResult | PaymentResultData;
|
|
71
|
-
action?: string | Record<string, unknown>;
|
|
72
|
-
}
|
|
73
|
-
interface PaymentProcessingEventData {
|
|
74
|
-
transaction: TransactionDocument;
|
|
75
|
-
paymentResult: PaymentResult | PaymentResultData;
|
|
76
|
-
}
|
|
77
|
-
interface MonetizationCreatedEventData {
|
|
78
|
-
monetizationType: string;
|
|
79
|
-
subscription?: SubscriptionDocument;
|
|
80
|
-
transaction?: TransactionDocument;
|
|
81
|
-
paymentIntent?: PaymentIntentData;
|
|
82
|
-
}
|
|
83
|
-
interface PurchaseCreatedEventData {
|
|
84
|
-
monetizationType: string;
|
|
85
|
-
subscription?: SubscriptionDocument;
|
|
86
|
-
transaction: TransactionDocument;
|
|
87
|
-
paymentIntent?: PaymentIntentData;
|
|
88
|
-
}
|
|
89
|
-
interface FreeCreatedEventData {
|
|
90
|
-
monetizationType: string;
|
|
91
|
-
subscription?: SubscriptionDocument;
|
|
92
|
-
transaction?: TransactionDocument;
|
|
93
|
-
paymentIntent?: PaymentIntentData;
|
|
94
|
-
}
|
|
95
|
-
interface SubscriptionCreatedEventData {
|
|
96
|
-
subscriptionId: string;
|
|
97
|
-
subscription: SubscriptionDocument;
|
|
98
|
-
transactionId?: string;
|
|
99
|
-
}
|
|
100
|
-
interface SubscriptionActivatedEventData {
|
|
101
|
-
subscription: SubscriptionDocument;
|
|
102
|
-
activatedAt: Date;
|
|
103
|
-
}
|
|
104
|
-
interface SubscriptionRenewedEventData {
|
|
105
|
-
subscription: SubscriptionDocument;
|
|
106
|
-
transaction: TransactionDocument;
|
|
107
|
-
paymentIntent?: PaymentIntentData;
|
|
108
|
-
renewalCount: number;
|
|
109
|
-
}
|
|
110
|
-
interface SubscriptionCancelledEventData {
|
|
111
|
-
subscription: SubscriptionDocument;
|
|
112
|
-
immediate: boolean;
|
|
113
|
-
reason?: string;
|
|
114
|
-
canceledAt: Date;
|
|
115
|
-
}
|
|
116
|
-
interface SubscriptionPausedEventData {
|
|
117
|
-
subscription: SubscriptionDocument;
|
|
118
|
-
reason?: string;
|
|
119
|
-
pausedAt: Date;
|
|
120
|
-
}
|
|
121
|
-
interface SubscriptionResumedEventData {
|
|
122
|
-
subscription: SubscriptionDocument;
|
|
123
|
-
extendPeriod: boolean;
|
|
124
|
-
pauseDuration: number;
|
|
125
|
-
resumedAt: Date;
|
|
126
|
-
}
|
|
127
|
-
interface TransactionUpdatedEventData {
|
|
128
|
-
transaction: TransactionDocument;
|
|
129
|
-
updates: Partial<TransactionDocument>;
|
|
130
|
-
}
|
|
131
|
-
interface EscrowHeldEventData {
|
|
132
|
-
transaction: TransactionDocument;
|
|
133
|
-
heldAmount: number;
|
|
134
|
-
reason: string;
|
|
135
|
-
}
|
|
136
|
-
interface EscrowReleasedEventData {
|
|
137
|
-
transaction: TransactionDocument;
|
|
138
|
-
releaseTransaction: TransactionDocument | null;
|
|
139
|
-
releaseAmount: number;
|
|
140
|
-
recipientId: string;
|
|
141
|
-
recipientType: string;
|
|
142
|
-
reason: string;
|
|
143
|
-
isFullRelease: boolean;
|
|
144
|
-
isPartialRelease: boolean;
|
|
145
|
-
}
|
|
146
|
-
interface EscrowCancelledEventData {
|
|
147
|
-
transaction: TransactionDocument;
|
|
148
|
-
reason: string;
|
|
149
|
-
}
|
|
150
|
-
interface EscrowSplitEventData {
|
|
151
|
-
transaction: TransactionDocument;
|
|
152
|
-
splits: SplitInfo[];
|
|
153
|
-
splitTransactions: TransactionDocument[];
|
|
154
|
-
organizationTransaction: TransactionDocument | null;
|
|
155
|
-
organizationPayout: number;
|
|
156
|
-
}
|
|
157
|
-
interface SettlementCreatedEventData {
|
|
158
|
-
settlements: SettlementDocument[];
|
|
159
|
-
transactionId: string;
|
|
160
|
-
count: number;
|
|
161
|
-
}
|
|
162
|
-
interface SettlementScheduledEventData {
|
|
163
|
-
settlement: SettlementDocument;
|
|
164
|
-
scheduledAt: Date;
|
|
165
|
-
}
|
|
166
|
-
interface SettlementProcessingEventData {
|
|
167
|
-
settlement: SettlementDocument;
|
|
168
|
-
processedAt?: Date;
|
|
169
|
-
}
|
|
170
|
-
interface SettlementCompletedEventData {
|
|
171
|
-
settlement: SettlementDocument;
|
|
172
|
-
completedAt?: Date;
|
|
173
|
-
}
|
|
174
|
-
interface SettlementFailedEventData {
|
|
175
|
-
settlement: SettlementDocument;
|
|
176
|
-
reason: string;
|
|
177
|
-
code?: string;
|
|
178
|
-
retry: boolean;
|
|
179
|
-
}
|
|
180
|
-
interface WebhookProcessedEventData {
|
|
181
|
-
webhookType: string;
|
|
182
|
-
provider: string;
|
|
183
|
-
event: WebhookEventData;
|
|
184
|
-
transaction: TransactionDocument;
|
|
185
|
-
processedAt: Date;
|
|
186
|
-
}
|
|
187
|
-
type PaymentVerifiedEvent = EventOf<'payment.verified', PaymentVerifiedEventData>;
|
|
188
|
-
type PaymentFailedEvent = EventOf<'payment.failed', PaymentFailedEventData>;
|
|
189
|
-
type PaymentRefundedEvent = EventOf<'payment.refunded', PaymentRefundedEventData>;
|
|
190
|
-
type PaymentRequiresActionEvent = EventOf<'payment.requires_action', PaymentRequiresActionEventData>;
|
|
191
|
-
type PaymentProcessingEvent = EventOf<'payment.processing', PaymentProcessingEventData>;
|
|
192
|
-
type MonetizationCreatedEvent = EventOf<'monetization.created', MonetizationCreatedEventData>;
|
|
193
|
-
type PurchaseCreatedEvent = EventOf<'purchase.created', PurchaseCreatedEventData>;
|
|
194
|
-
type FreeCreatedEvent = EventOf<'free.created', FreeCreatedEventData>;
|
|
195
|
-
type SubscriptionCreatedEvent = EventOf<'subscription.created', SubscriptionCreatedEventData>;
|
|
196
|
-
type SubscriptionActivatedEvent = EventOf<'subscription.activated', SubscriptionActivatedEventData>;
|
|
197
|
-
type SubscriptionRenewedEvent = EventOf<'subscription.renewed', SubscriptionRenewedEventData>;
|
|
198
|
-
type SubscriptionCancelledEvent = EventOf<'subscription.cancelled', SubscriptionCancelledEventData>;
|
|
199
|
-
type SubscriptionPausedEvent = EventOf<'subscription.paused', SubscriptionPausedEventData>;
|
|
200
|
-
type SubscriptionResumedEvent = EventOf<'subscription.resumed', SubscriptionResumedEventData>;
|
|
201
|
-
type TransactionUpdatedEvent = EventOf<'transaction.updated', TransactionUpdatedEventData>;
|
|
202
|
-
type EscrowHeldEvent = EventOf<'escrow.held', EscrowHeldEventData>;
|
|
203
|
-
type EscrowReleasedEvent = EventOf<'escrow.released', EscrowReleasedEventData>;
|
|
204
|
-
type EscrowCancelledEvent = EventOf<'escrow.cancelled', EscrowCancelledEventData>;
|
|
205
|
-
type EscrowSplitEvent = EventOf<'escrow.split', EscrowSplitEventData>;
|
|
206
|
-
type SettlementCreatedEvent = EventOf<'settlement.created', SettlementCreatedEventData>;
|
|
207
|
-
type SettlementScheduledEvent = EventOf<'settlement.scheduled', SettlementScheduledEventData>;
|
|
208
|
-
type SettlementProcessingEvent = EventOf<'settlement.processing', SettlementProcessingEventData>;
|
|
209
|
-
type SettlementCompletedEvent = EventOf<'settlement.completed', SettlementCompletedEventData>;
|
|
210
|
-
type SettlementFailedEvent = EventOf<'settlement.failed', SettlementFailedEventData>;
|
|
211
|
-
type WebhookProcessedEvent = EventOf<'webhook.processed', WebhookProcessedEventData>;
|
|
212
|
-
/**
|
|
213
|
-
* Maps event names to their data types (what you pass to emit).
|
|
214
|
-
* EventBus auto-injects type + timestamp.
|
|
215
|
-
*/
|
|
216
|
-
interface EventDataMap {
|
|
217
|
-
'payment.verified': PaymentVerifiedEventData;
|
|
218
|
-
'payment.failed': PaymentFailedEventData;
|
|
219
|
-
'payment.refunded': PaymentRefundedEventData;
|
|
220
|
-
'payment.requires_action': PaymentRequiresActionEventData;
|
|
221
|
-
'payment.processing': PaymentProcessingEventData;
|
|
222
|
-
'monetization.created': MonetizationCreatedEventData;
|
|
223
|
-
'purchase.created': PurchaseCreatedEventData;
|
|
224
|
-
'free.created': FreeCreatedEventData;
|
|
225
|
-
'subscription.created': SubscriptionCreatedEventData;
|
|
226
|
-
'subscription.activated': SubscriptionActivatedEventData;
|
|
227
|
-
'subscription.renewed': SubscriptionRenewedEventData;
|
|
228
|
-
'subscription.cancelled': SubscriptionCancelledEventData;
|
|
229
|
-
'subscription.paused': SubscriptionPausedEventData;
|
|
230
|
-
'subscription.resumed': SubscriptionResumedEventData;
|
|
231
|
-
'transaction.updated': TransactionUpdatedEventData;
|
|
232
|
-
'escrow.held': EscrowHeldEventData;
|
|
233
|
-
'escrow.released': EscrowReleasedEventData;
|
|
234
|
-
'escrow.cancelled': EscrowCancelledEventData;
|
|
235
|
-
'escrow.split': EscrowSplitEventData;
|
|
236
|
-
'settlement.created': SettlementCreatedEventData;
|
|
237
|
-
'settlement.scheduled': SettlementScheduledEventData;
|
|
238
|
-
'settlement.processing': SettlementProcessingEventData;
|
|
239
|
-
'settlement.completed': SettlementCompletedEventData;
|
|
240
|
-
'settlement.failed': SettlementFailedEventData;
|
|
241
|
-
'webhook.processed': WebhookProcessedEventData;
|
|
242
|
-
}
|
|
243
|
-
type EventHandler<T> = (event: T) => void | Promise<void>;
|
|
244
|
-
type EventKey = keyof RevenueEvents;
|
|
245
|
-
/**
|
|
246
|
-
* Type-safe event bus with clean, simple API
|
|
247
|
-
*/
|
|
248
|
-
declare class EventBus {
|
|
249
|
-
private handlers;
|
|
250
|
-
private onceHandlers;
|
|
251
|
-
/**
|
|
252
|
-
* Subscribe to an event
|
|
253
|
-
*/
|
|
254
|
-
on<K extends EventKey>(event: K, handler: EventHandler<RevenueEvents[K]>): () => void;
|
|
255
|
-
/**
|
|
256
|
-
* Subscribe to an event once
|
|
257
|
-
*/
|
|
258
|
-
once<K extends EventKey>(event: K, handler: EventHandler<RevenueEvents[K]>): () => void;
|
|
259
|
-
/**
|
|
260
|
-
* Unsubscribe from an event
|
|
261
|
-
*/
|
|
262
|
-
off<K extends EventKey>(event: K, handler: EventHandler<RevenueEvents[K]>): void;
|
|
263
|
-
/**
|
|
264
|
-
* Emit an event (fire and forget, non-blocking)
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* events.emit('payment.verified', {
|
|
269
|
-
* transaction: txDoc,
|
|
270
|
-
* paymentResult: result,
|
|
271
|
-
* verifiedBy: 'admin_123'
|
|
272
|
-
* });
|
|
273
|
-
* ```
|
|
274
|
-
*/
|
|
275
|
-
emit<K extends keyof EventDataMap>(event: K, data: EventDataMap[K]): void;
|
|
276
|
-
/**
|
|
277
|
-
* Emit and wait for all handlers to complete
|
|
278
|
-
*/
|
|
279
|
-
emitAsync<K extends EventKey>(event: K, payload: Omit<RevenueEvents[K], 'timestamp' | 'type'>): Promise<void>;
|
|
280
|
-
/**
|
|
281
|
-
* Remove all handlers
|
|
282
|
-
*/
|
|
283
|
-
clear(): void;
|
|
284
|
-
/**
|
|
285
|
-
* Get handler count for an event
|
|
286
|
-
*/
|
|
287
|
-
listenerCount(event: EventKey): number;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Create a new event bus
|
|
291
|
-
*/
|
|
292
|
-
declare function createEventBus(): EventBus;
|
|
293
|
-
//#endregion
|
|
294
|
-
export { BaseEvent, EscrowCancelledEvent, EscrowCancelledEventData, EscrowHeldEvent, EscrowHeldEventData, EscrowReleasedEvent, EscrowReleasedEventData, EscrowSplitEvent, EscrowSplitEventData, EventBus, EventBus as default, EventDataMap, FreeCreatedEvent, FreeCreatedEventData, MonetizationCreatedEvent, MonetizationCreatedEventData, PaymentFailedEvent, PaymentFailedEventData, PaymentProcessingEvent, PaymentProcessingEventData, PaymentRefundedEvent, PaymentRefundedEventData, PaymentRequiresActionEvent, PaymentRequiresActionEventData, PaymentVerifiedEvent, PaymentVerifiedEventData, PurchaseCreatedEvent, PurchaseCreatedEventData, RevenueEvents, SettlementCompletedEvent, SettlementCompletedEventData, SettlementCreatedEvent, SettlementCreatedEventData, SettlementFailedEvent, SettlementFailedEventData, SettlementProcessingEvent, SettlementProcessingEventData, SettlementScheduledEvent, SettlementScheduledEventData, SubscriptionActivatedEvent, SubscriptionActivatedEventData, SubscriptionCancelledEvent, SubscriptionCancelledEventData, SubscriptionCreatedEvent, SubscriptionCreatedEventData, SubscriptionPausedEvent, SubscriptionPausedEventData, SubscriptionRenewedEvent, SubscriptionRenewedEventData, SubscriptionResumedEvent, SubscriptionResumedEventData, TransactionUpdatedEvent, TransactionUpdatedEventData, WebhookProcessedEvent, WebhookProcessedEventData, createEventBus };
|
package/dist/core/events.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
//#region src/core/events.ts
|
|
2
|
-
/**
|
|
3
|
-
* Type-safe event bus with clean, simple API
|
|
4
|
-
*/
|
|
5
|
-
var EventBus = class {
|
|
6
|
-
handlers = /* @__PURE__ */ new Map();
|
|
7
|
-
onceHandlers = /* @__PURE__ */ new Map();
|
|
8
|
-
/**
|
|
9
|
-
* Subscribe to an event
|
|
10
|
-
*/
|
|
11
|
-
on(event, handler) {
|
|
12
|
-
if (!this.handlers.has(event)) this.handlers.set(event, /* @__PURE__ */ new Set());
|
|
13
|
-
this.handlers.get(event).add(handler);
|
|
14
|
-
return () => this.off(event, handler);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Subscribe to an event once
|
|
18
|
-
*/
|
|
19
|
-
once(event, handler) {
|
|
20
|
-
if (!this.onceHandlers.has(event)) this.onceHandlers.set(event, /* @__PURE__ */ new Set());
|
|
21
|
-
this.onceHandlers.get(event).add(handler);
|
|
22
|
-
return () => this.onceHandlers.get(event)?.delete(handler);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Unsubscribe from an event
|
|
26
|
-
*/
|
|
27
|
-
off(event, handler) {
|
|
28
|
-
this.handlers.get(event)?.delete(handler);
|
|
29
|
-
this.onceHandlers.get(event)?.delete(handler);
|
|
30
|
-
}
|
|
31
|
-
emit(event, data) {
|
|
32
|
-
const fullPayload = {
|
|
33
|
-
...data,
|
|
34
|
-
type: event,
|
|
35
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
36
|
-
};
|
|
37
|
-
const handlers = this.handlers.get(event);
|
|
38
|
-
if (handlers) for (const handler of handlers) Promise.resolve(handler(fullPayload)).catch((err) => {
|
|
39
|
-
console.error(`[Revenue] Event handler error for "${event}":`, err);
|
|
40
|
-
});
|
|
41
|
-
const onceHandlers = this.onceHandlers.get(event);
|
|
42
|
-
if (onceHandlers) {
|
|
43
|
-
for (const handler of onceHandlers) Promise.resolve(handler(fullPayload)).catch((err) => {
|
|
44
|
-
console.error(`[Revenue] Once handler error for "${event}":`, err);
|
|
45
|
-
});
|
|
46
|
-
this.onceHandlers.delete(event);
|
|
47
|
-
}
|
|
48
|
-
if (event !== "*") {
|
|
49
|
-
const wildcardHandlers = this.handlers.get("*");
|
|
50
|
-
if (wildcardHandlers) for (const handler of wildcardHandlers) Promise.resolve(handler(fullPayload)).catch((err) => {
|
|
51
|
-
console.error(`[Revenue] Wildcard handler error:`, err);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Emit and wait for all handlers to complete
|
|
57
|
-
*/
|
|
58
|
-
async emitAsync(event, payload) {
|
|
59
|
-
const fullPayload = {
|
|
60
|
-
...payload,
|
|
61
|
-
type: event,
|
|
62
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
63
|
-
};
|
|
64
|
-
const promises = [];
|
|
65
|
-
const handlers = this.handlers.get(event);
|
|
66
|
-
if (handlers) for (const handler of handlers) promises.push(Promise.resolve(handler(fullPayload)));
|
|
67
|
-
const onceHandlers = this.onceHandlers.get(event);
|
|
68
|
-
if (onceHandlers) {
|
|
69
|
-
for (const handler of onceHandlers) promises.push(Promise.resolve(handler(fullPayload)));
|
|
70
|
-
this.onceHandlers.delete(event);
|
|
71
|
-
}
|
|
72
|
-
if (event !== "*") {
|
|
73
|
-
const wildcardHandlers = this.handlers.get("*");
|
|
74
|
-
if (wildcardHandlers) for (const handler of wildcardHandlers) promises.push(Promise.resolve(handler(fullPayload)));
|
|
75
|
-
}
|
|
76
|
-
await Promise.all(promises);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Remove all handlers
|
|
80
|
-
*/
|
|
81
|
-
clear() {
|
|
82
|
-
this.handlers.clear();
|
|
83
|
-
this.onceHandlers.clear();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Get handler count for an event
|
|
87
|
-
*/
|
|
88
|
-
listenerCount(event) {
|
|
89
|
-
return (this.handlers.get(event)?.size ?? 0) + (this.onceHandlers.get(event)?.size ?? 0);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Create a new event bus
|
|
94
|
-
*/
|
|
95
|
-
function createEventBus() {
|
|
96
|
-
return new EventBus();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//#endregion
|
|
100
|
-
export { EventBus, EventBus as default, createEventBus };
|
package/dist/core/index.d.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { o as Container } from "../settlement.service-DjzAjezU.mjs";
|
|
2
|
-
import "../index-Dsp7H5Wb.mjs";
|
|
3
|
-
import "../settlement.schema-DnNSFpGd.mjs";
|
|
4
|
-
import "../base-CsTlVQJe.mjs";
|
|
5
|
-
import { BaseEvent, EscrowCancelledEvent, EscrowHeldEvent, EscrowReleasedEvent, EscrowSplitEvent, EventBus, FreeCreatedEvent, MonetizationCreatedEvent, PaymentFailedEvent, PaymentRefundedEvent, PaymentVerifiedEvent, PurchaseCreatedEvent, RevenueEvents, SettlementCompletedEvent, SettlementCreatedEvent, SettlementFailedEvent, SettlementProcessingEvent, SettlementScheduledEvent, SubscriptionActivatedEvent, SubscriptionCancelledEvent, SubscriptionCreatedEvent, SubscriptionPausedEvent, SubscriptionRenewedEvent, SubscriptionResumedEvent, TransactionUpdatedEvent, WebhookProcessedEvent, createEventBus } from "./events.mjs";
|
|
6
|
-
import { a as PluginManager, c as definePlugin, i as PluginLogger, l as loggingPlugin, n as PluginContext, o as RevenuePlugin, r as PluginHooks, s as auditPlugin, t as HookFn, u as metricsPlugin } from "../plugin-BbK0OVHy.mjs";
|
|
7
|
-
import { S as unwrapOr, _ as match, b as tryCatchSync, c as Ok, d as err, f as flatMap, g as mapErr, h as map, l as Result, m as isOk, p as isErr, s as Err, u as all, v as ok, x as unwrap, y as tryCatch } from "../retry-HHCOXYdn.mjs";
|
|
8
|
-
import { A as SUBSCRIPTION_STATE_MACHINE, B as Revenue, C as TransactionNotFoundError, D as HOLD_STATE_MACHINE, E as isRevenueError, H as RevenueOptions, M as StateMachine, O as SETTLEMENT_STATE_MACHINE, R as ModelsConfig, S as SubscriptionNotFoundError, T as isRetryable, U as createRevenue, V as RevenueBuilder, _ as RefundNotSupportedError, a as InvalidAmountError, b as StateError, c as ModelNotRegisteredError, d as PaymentIntentCreationError, f as PaymentVerificationError, g as RefundError, h as ProviderNotFoundError, i as ErrorCode, j as TRANSACTION_STATE_MACHINE, k as SPLIT_STATE_MACHINE, l as NotFoundError, m as ProviderError, n as ConfigurationError, o as InvalidStateTransitionError, p as ProviderCapabilityError, r as ERROR_CODES, s as MissingRequiredFieldError, t as AlreadyVerifiedError, u as OperationError, v as RevenueError, w as ValidationError, x as SubscriptionNotActiveError, y as RevenueErrorOptions, z as ProvidersConfig } from "../errors-rRdOqnWx.mjs";
|
|
9
|
-
export { AlreadyVerifiedError, type BaseEvent, ConfigurationError, Container, ERROR_CODES, type Err, ErrorCode, type EscrowCancelledEvent, type EscrowHeldEvent, type EscrowReleasedEvent, type EscrowSplitEvent, EventBus, type FreeCreatedEvent, HOLD_STATE_MACHINE, type HookFn, InvalidAmountError, InvalidStateTransitionError, MissingRequiredFieldError, ModelNotRegisteredError, type ModelsConfig, type MonetizationCreatedEvent, NotFoundError, type Ok, OperationError, type PaymentFailedEvent, PaymentIntentCreationError, type PaymentRefundedEvent, PaymentVerificationError, type PaymentVerifiedEvent, type PluginContext, type PluginHooks, type PluginLogger, PluginManager, ProviderCapabilityError, ProviderError, ProviderNotFoundError, type ProvidersConfig, type PurchaseCreatedEvent, RefundError, RefundNotSupportedError, Result, Revenue, RevenueBuilder, RevenueError, RevenueErrorOptions, type RevenueEvents, type RevenueOptions, type RevenuePlugin, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, type SettlementCompletedEvent, type SettlementCreatedEvent, type SettlementFailedEvent, type SettlementProcessingEvent, type SettlementScheduledEvent, StateError, StateMachine, type SubscriptionActivatedEvent, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, SubscriptionNotActiveError, SubscriptionNotFoundError, type SubscriptionPausedEvent, type SubscriptionRenewedEvent, type SubscriptionResumedEvent, TRANSACTION_STATE_MACHINE, TransactionNotFoundError, type TransactionUpdatedEvent, ValidationError, type WebhookProcessedEvent, all, auditPlugin, createEventBus, createRevenue, definePlugin, err, flatMap, isErr, isOk, isRetryable, isRevenueError, loggingPlugin, map, mapErr, match, metricsPlugin, ok, tryCatch, tryCatchSync, unwrap, unwrapOr };
|
package/dist/core/index.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { i as Container, n as RevenueBuilder, r as createRevenue, t as Revenue } from "../revenue-BhdS7nXh.mjs";
|
|
2
|
-
import { EventBus, createEventBus } from "./events.mjs";
|
|
3
|
-
import { a as metricsPlugin, i as loggingPlugin, n as auditPlugin, r as definePlugin, t as PluginManager } from "../plugin-Cd_V04Em.mjs";
|
|
4
|
-
import { S as unwrapOr, _ as match, b as tryCatchSync, d as err, f as flatMap, g as mapErr, h as map, l as Result, m as isOk, p as isErr, u as all, v as ok, x as unwrap, y as tryCatch } from "../commission-split-BzB8cd39.mjs";
|
|
5
|
-
import { C as ValidationError, S as TransactionNotFoundError, T as isRevenueError, _ as RefundNotSupportedError, a as InvalidAmountError, b as SubscriptionNotActiveError, c as ModelNotRegisteredError, d as PaymentIntentCreationError, f as PaymentVerificationError, g as RefundError, h as ProviderNotFoundError, i as ERROR_CODES, l as NotFoundError, m as ProviderError, n as AlreadyVerifiedError, o as InvalidStateTransitionError, p as ProviderCapabilityError, r as ConfigurationError, s as MissingRequiredFieldError, u as OperationError, v as RevenueError, w as isRetryable, x as SubscriptionNotFoundError, y as StateError } from "../category-resolver-DV83N8ok.mjs";
|
|
6
|
-
import { d as SETTLEMENT_STATE_MACHINE, f as SPLIT_STATE_MACHINE, h as StateMachine, m as TRANSACTION_STATE_MACHINE, p as SUBSCRIPTION_STATE_MACHINE, u as HOLD_STATE_MACHINE } from "../settlement.service-DmdKv0Zu.mjs";
|
|
7
|
-
|
|
8
|
-
export { AlreadyVerifiedError, ConfigurationError, Container, ERROR_CODES, EventBus, HOLD_STATE_MACHINE, InvalidAmountError, InvalidStateTransitionError, MissingRequiredFieldError, ModelNotRegisteredError, NotFoundError, OperationError, PaymentIntentCreationError, PaymentVerificationError, PluginManager, ProviderCapabilityError, ProviderError, ProviderNotFoundError, RefundError, RefundNotSupportedError, Result, Revenue, RevenueBuilder, RevenueError, SETTLEMENT_STATE_MACHINE, SPLIT_STATE_MACHINE, SUBSCRIPTION_STATE_MACHINE, StateError, StateMachine, SubscriptionNotActiveError, SubscriptionNotFoundError, TRANSACTION_STATE_MACHINE, TransactionNotFoundError, ValidationError, all, auditPlugin, createEventBus, createRevenue, definePlugin, err, flatMap, isErr, isOk, isRetryable, isRevenueError, loggingPlugin, map, mapErr, match, metricsPlugin, ok, tryCatch, tryCatchSync, unwrap, unwrapOr };
|