@classytic/revenue 0.2.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +498 -501
  2. package/dist/actions-CwG-b7fR.d.ts +519 -0
  3. package/dist/core/index.d.ts +884 -0
  4. package/dist/core/index.js +2941 -0
  5. package/dist/core/index.js.map +1 -0
  6. package/dist/enums/index.d.ts +130 -0
  7. package/dist/enums/index.js +167 -0
  8. package/dist/enums/index.js.map +1 -0
  9. package/dist/index-BnJWVXuw.d.ts +378 -0
  10. package/dist/index-ChVD3P9k.d.ts +504 -0
  11. package/dist/index.d.ts +42 -0
  12. package/dist/index.js +4353 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/providers/index.d.ts +132 -0
  15. package/dist/providers/index.js +122 -0
  16. package/dist/providers/index.js.map +1 -0
  17. package/dist/retry-80lBCmSe.d.ts +234 -0
  18. package/dist/schemas/index.d.ts +894 -0
  19. package/dist/schemas/index.js +524 -0
  20. package/dist/schemas/index.js.map +1 -0
  21. package/dist/schemas/validation.d.ts +309 -0
  22. package/dist/schemas/validation.js +249 -0
  23. package/dist/schemas/validation.js.map +1 -0
  24. package/dist/services/index.d.ts +3 -0
  25. package/dist/services/index.js +1632 -0
  26. package/dist/services/index.js.map +1 -0
  27. package/dist/split.enums-DHdM1YAV.d.ts +255 -0
  28. package/dist/split.schema-BPdFZMbU.d.ts +958 -0
  29. package/dist/utils/index.d.ts +24 -0
  30. package/dist/utils/index.js +1067 -0
  31. package/dist/utils/index.js.map +1 -0
  32. package/package.json +48 -32
  33. package/core/builder.js +0 -219
  34. package/core/container.js +0 -119
  35. package/core/errors.js +0 -262
  36. package/dist/types/core/builder.d.ts +0 -97
  37. package/dist/types/core/container.d.ts +0 -57
  38. package/dist/types/core/errors.d.ts +0 -122
  39. package/dist/types/enums/escrow.enums.d.ts +0 -24
  40. package/dist/types/enums/index.d.ts +0 -69
  41. package/dist/types/enums/monetization.enums.d.ts +0 -6
  42. package/dist/types/enums/payment.enums.d.ts +0 -16
  43. package/dist/types/enums/split.enums.d.ts +0 -25
  44. package/dist/types/enums/subscription.enums.d.ts +0 -15
  45. package/dist/types/enums/transaction.enums.d.ts +0 -24
  46. package/dist/types/index.d.ts +0 -22
  47. package/dist/types/providers/base.d.ts +0 -128
  48. package/dist/types/schemas/escrow/hold.schema.d.ts +0 -54
  49. package/dist/types/schemas/escrow/index.d.ts +0 -6
  50. package/dist/types/schemas/index.d.ts +0 -506
  51. package/dist/types/schemas/split/index.d.ts +0 -8
  52. package/dist/types/schemas/split/split.schema.d.ts +0 -142
  53. package/dist/types/schemas/subscription/index.d.ts +0 -152
  54. package/dist/types/schemas/subscription/info.schema.d.ts +0 -128
  55. package/dist/types/schemas/subscription/plan.schema.d.ts +0 -39
  56. package/dist/types/schemas/transaction/common.schema.d.ts +0 -12
  57. package/dist/types/schemas/transaction/gateway.schema.d.ts +0 -86
  58. package/dist/types/schemas/transaction/index.d.ts +0 -202
  59. package/dist/types/schemas/transaction/payment.schema.d.ts +0 -145
  60. package/dist/types/services/escrow.service.d.ts +0 -51
  61. package/dist/types/services/monetization.service.d.ts +0 -193
  62. package/dist/types/services/payment.service.d.ts +0 -117
  63. package/dist/types/services/transaction.service.d.ts +0 -40
  64. package/dist/types/utils/category-resolver.d.ts +0 -46
  65. package/dist/types/utils/commission-split.d.ts +0 -56
  66. package/dist/types/utils/commission.d.ts +0 -29
  67. package/dist/types/utils/hooks.d.ts +0 -17
  68. package/dist/types/utils/index.d.ts +0 -6
  69. package/dist/types/utils/logger.d.ts +0 -12
  70. package/dist/types/utils/subscription/actions.d.ts +0 -28
  71. package/dist/types/utils/subscription/index.d.ts +0 -2
  72. package/dist/types/utils/subscription/period.d.ts +0 -47
  73. package/dist/types/utils/transaction-type.d.ts +0 -102
  74. package/enums/escrow.enums.js +0 -36
  75. package/enums/index.d.ts +0 -116
  76. package/enums/index.js +0 -110
  77. package/enums/monetization.enums.js +0 -15
  78. package/enums/payment.enums.js +0 -64
  79. package/enums/split.enums.js +0 -37
  80. package/enums/subscription.enums.js +0 -33
  81. package/enums/transaction.enums.js +0 -69
  82. package/index.js +0 -76
  83. package/providers/base.js +0 -162
  84. package/schemas/escrow/hold.schema.js +0 -62
  85. package/schemas/escrow/index.js +0 -15
  86. package/schemas/index.d.ts +0 -33
  87. package/schemas/index.js +0 -27
  88. package/schemas/split/index.js +0 -16
  89. package/schemas/split/split.schema.js +0 -86
  90. package/schemas/subscription/index.js +0 -17
  91. package/schemas/subscription/info.schema.js +0 -115
  92. package/schemas/subscription/plan.schema.js +0 -48
  93. package/schemas/transaction/common.schema.js +0 -22
  94. package/schemas/transaction/gateway.schema.js +0 -69
  95. package/schemas/transaction/index.js +0 -20
  96. package/schemas/transaction/payment.schema.js +0 -110
  97. package/services/escrow.service.js +0 -353
  98. package/services/monetization.service.js +0 -675
  99. package/services/payment.service.js +0 -535
  100. package/services/transaction.service.js +0 -142
  101. package/utils/category-resolver.js +0 -74
  102. package/utils/commission-split.js +0 -180
  103. package/utils/commission.js +0 -83
  104. package/utils/hooks.js +0 -44
  105. package/utils/index.d.ts +0 -164
  106. package/utils/index.js +0 -16
  107. package/utils/logger.js +0 -36
  108. package/utils/subscription/actions.js +0 -68
  109. package/utils/subscription/index.js +0 -20
  110. package/utils/subscription/period.js +0 -123
  111. package/utils/transaction-type.js +0 -254
@@ -0,0 +1,504 @@
1
+ import { Types, Document } from 'mongoose';
2
+
3
+ /**
4
+ * @classytic/revenue - Core Type Definitions
5
+ * Enterprise Revenue Management System
6
+ *
7
+ * @module @classytic/revenue/types
8
+ */
9
+
10
+ /** Generic Mongoose document type */
11
+ type MongooseDoc<T = unknown> = Document & T;
12
+ /** ObjectId type from Mongoose */
13
+ type ObjectId = Types.ObjectId;
14
+ /** Generic Mongoose model interface - simplified for compatibility */
15
+ interface MongooseModel<T = unknown> {
16
+ findById(id: string | ObjectId): Promise<T | null>;
17
+ find(filter?: object): unknown;
18
+ findOne(filter?: object): Promise<T | null>;
19
+ create(data: Partial<T> | Record<string, unknown>): Promise<T>;
20
+ countDocuments?(filter?: object): Promise<number>;
21
+ count?(filter?: object): Promise<number>;
22
+ findByIdAndUpdate(id: string | ObjectId, update: object, options?: object): Promise<T | null>;
23
+ update?(id: string, data: object): Promise<T | null>;
24
+ }
25
+ /** Transaction status values */
26
+ type TransactionStatusValue = 'pending' | 'payment_initiated' | 'processing' | 'requires_action' | 'verified' | 'completed' | 'failed' | 'cancelled' | 'expired' | 'refunded' | 'partially_refunded';
27
+ /** Transaction type values */
28
+ type TransactionTypeValue = 'income' | 'expense';
29
+ /** Gateway information stored on transaction */
30
+ interface TransactionGateway {
31
+ type: string;
32
+ sessionId?: string | null;
33
+ paymentIntentId?: string | null;
34
+ provider?: string;
35
+ metadata?: Record<string, unknown>;
36
+ verificationData?: Record<string, unknown>;
37
+ }
38
+ /** Commission information */
39
+ interface CommissionInfo {
40
+ rate: number;
41
+ grossAmount: number;
42
+ gatewayFeeRate: number;
43
+ gatewayFeeAmount: number;
44
+ netAmount: number;
45
+ status: 'pending' | 'paid' | 'waived';
46
+ splits?: SplitInfo[];
47
+ affiliate?: {
48
+ recipientId: string;
49
+ recipientType: string;
50
+ rate: number;
51
+ grossAmount: number;
52
+ netAmount: number;
53
+ };
54
+ }
55
+ /** Webhook information */
56
+ interface WebhookInfo {
57
+ eventId: string;
58
+ eventType: string;
59
+ receivedAt: Date;
60
+ processedAt?: Date;
61
+ data: Record<string, unknown>;
62
+ }
63
+ /** Hold (escrow) information */
64
+ interface HoldInfo {
65
+ status: HoldStatusValue;
66
+ heldAmount: number;
67
+ releasedAmount: number;
68
+ reason?: HoldReasonValue;
69
+ holdUntil?: Date | null;
70
+ heldAt?: Date;
71
+ releasedAt?: Date;
72
+ cancelledAt?: Date;
73
+ releases: ReleaseRecord[];
74
+ metadata: Record<string, unknown>;
75
+ }
76
+ /** Release record for escrow */
77
+ interface ReleaseRecord {
78
+ amount: number;
79
+ recipientId: string;
80
+ recipientType: string;
81
+ releasedAt: Date;
82
+ releasedBy?: string | null;
83
+ reason: string;
84
+ metadata: Record<string, unknown>;
85
+ }
86
+ /** Base transaction document interface */
87
+ interface TransactionDocument {
88
+ _id: ObjectId;
89
+ organizationId?: string | ObjectId;
90
+ customerId?: string | ObjectId | null;
91
+ amount: number;
92
+ currency: string;
93
+ category: string;
94
+ type: TransactionTypeValue;
95
+ method: string;
96
+ status: TransactionStatusValue;
97
+ gateway?: TransactionGateway;
98
+ paymentDetails?: Record<string, unknown>;
99
+ commission?: CommissionInfo | null;
100
+ referenceId?: string | ObjectId;
101
+ referenceModel?: string;
102
+ metadata?: Record<string, unknown>;
103
+ idempotencyKey?: string;
104
+ verifiedAt?: Date;
105
+ verifiedBy?: string | ObjectId | null;
106
+ failureReason?: string;
107
+ refundedAmount?: number;
108
+ refundedAt?: Date;
109
+ webhook?: WebhookInfo;
110
+ hold?: HoldInfo;
111
+ splits?: SplitInfo[];
112
+ createdAt: Date;
113
+ updatedAt: Date;
114
+ save(): Promise<this>;
115
+ }
116
+ /** Subscription status values */
117
+ type SubscriptionStatusValue = 'active' | 'paused' | 'cancelled' | 'expired' | 'pending' | 'inactive' | 'pending_renewal';
118
+ /** Plan key values */
119
+ type PlanKeyValue = 'monthly' | 'quarterly' | 'yearly' | string;
120
+ /** Base subscription document interface */
121
+ interface SubscriptionDocument {
122
+ _id: ObjectId;
123
+ organizationId?: string | ObjectId;
124
+ customerId?: string | ObjectId | null;
125
+ planKey: PlanKeyValue;
126
+ amount: number;
127
+ currency: string;
128
+ status: SubscriptionStatusValue;
129
+ isActive: boolean;
130
+ gateway?: string;
131
+ transactionId?: ObjectId | null;
132
+ paymentIntentId?: string | null;
133
+ startDate?: Date;
134
+ endDate?: Date;
135
+ activatedAt?: Date;
136
+ canceledAt?: Date;
137
+ cancelAt?: Date;
138
+ cancellationReason?: string | null;
139
+ pausedAt?: Date | null;
140
+ pauseReason?: string | null;
141
+ renewalCount?: number;
142
+ renewalTransactionId?: ObjectId;
143
+ metadata?: Record<string, unknown>;
144
+ createdAt: Date;
145
+ updatedAt: Date;
146
+ save(): Promise<this>;
147
+ }
148
+ /** Payment status values */
149
+ type PaymentStatusValue = 'pending' | 'verified' | 'failed' | 'refunded' | 'cancelled';
150
+ /** Payment gateway type values */
151
+ type PaymentGatewayTypeValue = 'manual' | 'stripe' | 'sslcommerz' | string;
152
+ /** Monetization type values */
153
+ type MonetizationTypeValue = 'free' | 'purchase' | 'subscription';
154
+ /** Hold status values */
155
+ type HoldStatusValue = 'pending' | 'held' | 'released' | 'cancelled' | 'expired' | 'partially_released';
156
+ /** Hold reason values */
157
+ type HoldReasonValue = 'payment_verification' | 'fraud_check' | 'manual_review' | 'dispute' | 'compliance';
158
+ /** Release reason values */
159
+ type ReleaseReasonValue = 'payment_verified' | 'manual_release' | 'auto_release' | 'dispute_resolved';
160
+ /** Split type values */
161
+ type SplitTypeValue = 'platform_commission' | 'affiliate_commission' | 'referral_commission' | 'partner_commission' | 'custom';
162
+ /** Split status values */
163
+ type SplitStatusValue = 'pending' | 'due' | 'paid' | 'waived' | 'cancelled';
164
+ /** Payout method values */
165
+ type PayoutMethodValue = 'bank_transfer' | 'mobile_wallet' | 'platform_balance' | 'crypto' | 'check' | 'manual';
166
+ /** Split rule configuration */
167
+ interface SplitRule {
168
+ type?: SplitTypeValue;
169
+ recipientId: string;
170
+ recipientType: string;
171
+ rate: number;
172
+ dueDate?: Date | null;
173
+ metadata?: Record<string, unknown>;
174
+ }
175
+ /** Calculated split info */
176
+ interface SplitInfo {
177
+ type: SplitTypeValue;
178
+ recipientId: string;
179
+ recipientType: string;
180
+ rate: number;
181
+ grossAmount: number;
182
+ gatewayFeeRate: number;
183
+ gatewayFeeAmount: number;
184
+ netAmount: number;
185
+ status: SplitStatusValue;
186
+ dueDate?: Date | null;
187
+ paidDate?: Date;
188
+ payoutTransactionId?: string;
189
+ metadata: Record<string, unknown>;
190
+ }
191
+ /** Payment intent parameters */
192
+ interface CreateIntentParams {
193
+ amount: number;
194
+ currency?: string;
195
+ metadata?: Record<string, unknown>;
196
+ }
197
+ /** Payment intent data */
198
+ interface PaymentIntentData {
199
+ id: string;
200
+ sessionId?: string | null;
201
+ paymentIntentId?: string | null;
202
+ provider: string;
203
+ status: string;
204
+ amount: number;
205
+ currency?: string;
206
+ metadata?: Record<string, unknown>;
207
+ clientSecret?: string;
208
+ paymentUrl?: string;
209
+ instructions?: string;
210
+ raw?: unknown;
211
+ }
212
+ /** Payment result data */
213
+ interface PaymentResultData {
214
+ id: string;
215
+ provider: string;
216
+ status: 'succeeded' | 'failed' | 'processing';
217
+ amount?: number;
218
+ currency?: string;
219
+ paidAt?: Date;
220
+ metadata?: Record<string, unknown>;
221
+ raw?: unknown;
222
+ }
223
+ /** Refund result data */
224
+ interface RefundResultData {
225
+ id: string;
226
+ provider: string;
227
+ status: 'succeeded' | 'failed' | 'processing';
228
+ amount?: number;
229
+ currency?: string;
230
+ refundedAt?: Date;
231
+ reason?: string;
232
+ metadata?: Record<string, unknown>;
233
+ raw?: unknown;
234
+ }
235
+ /** Webhook event data */
236
+ interface WebhookEventData {
237
+ id: string;
238
+ provider: string;
239
+ type: string;
240
+ data: {
241
+ sessionId?: string;
242
+ paymentIntentId?: string;
243
+ [key: string]: unknown;
244
+ };
245
+ createdAt?: Date;
246
+ raw?: unknown;
247
+ }
248
+ /** Provider capabilities */
249
+ interface ProviderCapabilities {
250
+ supportsWebhooks: boolean;
251
+ supportsRefunds: boolean;
252
+ supportsPartialRefunds: boolean;
253
+ requiresManualVerification: boolean;
254
+ }
255
+ /** Models registry */
256
+ interface ModelsRegistry {
257
+ Transaction: MongooseModel<TransactionDocument>;
258
+ Subscription?: MongooseModel<SubscriptionDocument>;
259
+ }
260
+ /** Provider registry */
261
+ interface ProvidersRegistry {
262
+ [name: string]: PaymentProviderInterface;
263
+ }
264
+ /** Hook handlers registry */
265
+ interface HooksRegistry {
266
+ [event: string]: Array<(data: unknown) => void | Promise<void>>;
267
+ }
268
+ /** Logger interface */
269
+ interface Logger {
270
+ info(...args: unknown[]): void;
271
+ warn(...args: unknown[]): void;
272
+ error(...args: unknown[]): void;
273
+ debug(...args: unknown[]): void;
274
+ log?(...args: unknown[]): void;
275
+ }
276
+ /** Revenue configuration */
277
+ interface RevenueConfig {
278
+ targetModels: string[];
279
+ categoryMappings: Record<string, string>;
280
+ commissionRates?: Record<string, number>;
281
+ gatewayFeeRates?: Record<string, number>;
282
+ transactionTypeMapping?: Record<string, TransactionTypeValue>;
283
+ }
284
+ /** Create revenue options */
285
+ interface CreateRevenueOptions {
286
+ models: ModelsRegistry;
287
+ providers?: ProvidersRegistry;
288
+ hooks?: HooksRegistry;
289
+ config?: Partial<RevenueConfig>;
290
+ logger?: Logger;
291
+ }
292
+ /** Payment provider interface */
293
+ interface PaymentProviderInterface {
294
+ name: string;
295
+ config: Record<string, unknown>;
296
+ createIntent(params: CreateIntentParams): Promise<PaymentIntentData>;
297
+ verifyPayment(intentId: string): Promise<PaymentResultData>;
298
+ getStatus(intentId: string): Promise<PaymentResultData>;
299
+ refund(paymentId: string, amount?: number | null, options?: {
300
+ reason?: string;
301
+ }): Promise<RefundResultData>;
302
+ handleWebhook(payload: unknown, headers?: Record<string, string>): Promise<WebhookEventData>;
303
+ verifyWebhookSignature(payload: unknown, signature: string): boolean;
304
+ getCapabilities(): ProviderCapabilities;
305
+ }
306
+ /** Monetization create data */
307
+ interface MonetizationData {
308
+ organizationId?: string | ObjectId;
309
+ customerId?: string | ObjectId;
310
+ referenceId?: string | ObjectId;
311
+ referenceModel?: string;
312
+ }
313
+ /** Monetization create params */
314
+ interface MonetizationCreateParams {
315
+ data: MonetizationData;
316
+ planKey: string;
317
+ amount: number;
318
+ currency?: string;
319
+ gateway?: string;
320
+ entity?: string | null;
321
+ monetizationType?: MonetizationTypeValue;
322
+ paymentData?: Record<string, unknown>;
323
+ metadata?: Record<string, unknown>;
324
+ idempotencyKey?: string | null;
325
+ }
326
+ /** Monetization create result */
327
+ interface MonetizationCreateResult {
328
+ subscription: SubscriptionDocument | null;
329
+ transaction: TransactionDocument | null;
330
+ paymentIntent: PaymentIntentData | null;
331
+ }
332
+ /** Activation options */
333
+ interface ActivateOptions {
334
+ timestamp?: Date;
335
+ }
336
+ /** Renewal params */
337
+ interface RenewalParams {
338
+ gateway?: string;
339
+ entity?: string | null;
340
+ paymentData?: Record<string, unknown>;
341
+ metadata?: Record<string, unknown>;
342
+ idempotencyKey?: string | null;
343
+ }
344
+ /** Cancellation options */
345
+ interface CancelOptions {
346
+ immediate?: boolean;
347
+ reason?: string | null;
348
+ }
349
+ /** Pause options */
350
+ interface PauseOptions {
351
+ reason?: string | null;
352
+ }
353
+ /** Resume options */
354
+ interface ResumeOptions {
355
+ extendPeriod?: boolean;
356
+ }
357
+ /** List options */
358
+ interface ListOptions {
359
+ limit?: number;
360
+ skip?: number;
361
+ page?: number | null;
362
+ sort?: Record<string, 1 | -1>;
363
+ populate?: string[];
364
+ }
365
+ /** Payment verify options */
366
+ interface PaymentVerifyOptions {
367
+ verifiedBy?: string | null;
368
+ }
369
+ /** Payment verify result */
370
+ interface PaymentVerifyResult {
371
+ transaction: TransactionDocument;
372
+ paymentResult: PaymentResultData | null;
373
+ status: TransactionStatusValue;
374
+ }
375
+ /** Payment status result */
376
+ interface PaymentStatusResult {
377
+ transaction: TransactionDocument;
378
+ paymentResult?: PaymentResultData | null;
379
+ status: TransactionStatusValue | string;
380
+ provider?: string;
381
+ }
382
+ /** Refund options */
383
+ interface RefundOptions {
384
+ reason?: string | null;
385
+ }
386
+ /** Payment refund result */
387
+ interface PaymentRefundResult {
388
+ transaction: TransactionDocument;
389
+ refundTransaction: TransactionDocument;
390
+ refundResult: RefundResultData;
391
+ status: TransactionStatusValue;
392
+ }
393
+ /** Webhook result */
394
+ interface WebhookResult {
395
+ event: WebhookEventData;
396
+ transaction: TransactionDocument;
397
+ status: 'processed' | 'already_processed';
398
+ }
399
+ /** Transaction list result */
400
+ interface TransactionListResult {
401
+ transactions: TransactionDocument[];
402
+ total: number;
403
+ page: number;
404
+ limit: number;
405
+ pages: number;
406
+ }
407
+ /** Hold options */
408
+ interface HoldOptions {
409
+ reason?: HoldReasonValue;
410
+ holdUntil?: Date | null;
411
+ metadata?: Record<string, unknown>;
412
+ }
413
+ /** Release options */
414
+ interface ReleaseOptions {
415
+ amount?: number | null;
416
+ recipientId: string;
417
+ recipientType?: string;
418
+ reason?: ReleaseReasonValue;
419
+ releasedBy?: string | null;
420
+ createTransaction?: boolean;
421
+ metadata?: Record<string, unknown>;
422
+ }
423
+ /** Release result */
424
+ interface ReleaseResult {
425
+ transaction: TransactionDocument;
426
+ releaseTransaction: TransactionDocument | null;
427
+ releaseAmount: number;
428
+ isFullRelease: boolean;
429
+ isPartialRelease: boolean;
430
+ }
431
+ /** Cancel hold options */
432
+ interface CancelHoldOptions {
433
+ reason?: string;
434
+ metadata?: Record<string, unknown>;
435
+ }
436
+ /** Split result */
437
+ interface SplitResult {
438
+ transaction: TransactionDocument;
439
+ splits: SplitInfo[];
440
+ splitTransactions: TransactionDocument[];
441
+ organizationTransaction: TransactionDocument | null;
442
+ organizationPayout: number;
443
+ }
444
+ /** Escrow status result */
445
+ interface EscrowStatusResult {
446
+ transaction: TransactionDocument;
447
+ hold: HoldInfo | null;
448
+ splits: SplitInfo[];
449
+ hasHold: boolean;
450
+ hasSplits: boolean;
451
+ }
452
+ /** Period range params */
453
+ interface PeriodRangeParams {
454
+ currentEndDate?: Date | null;
455
+ startDate?: Date | null;
456
+ duration: number;
457
+ unit?: 'days' | 'weeks' | 'months' | 'years';
458
+ now?: Date;
459
+ }
460
+ /** Period range result */
461
+ interface PeriodRangeResult {
462
+ startDate: Date;
463
+ endDate: Date;
464
+ }
465
+ /** Prorated amount params */
466
+ interface ProratedAmountParams {
467
+ amountPaid: number;
468
+ startDate: Date;
469
+ endDate: Date;
470
+ asOfDate?: Date;
471
+ precision?: number;
472
+ }
473
+ /** Duration result */
474
+ interface DurationResult {
475
+ duration: number;
476
+ unit: 'days' | 'weeks' | 'months' | 'years';
477
+ }
478
+ /** Subscription entity for action checks */
479
+ interface SubscriptionEntity {
480
+ subscription?: {
481
+ isActive?: boolean;
482
+ endDate?: Date;
483
+ canceledAt?: Date;
484
+ };
485
+ status?: SubscriptionStatusValue;
486
+ }
487
+ /** Commission with splits options */
488
+ interface CommissionWithSplitsOptions {
489
+ affiliateRate?: number;
490
+ affiliateId?: string | null;
491
+ affiliateType?: string;
492
+ }
493
+ /** Transaction type detection options */
494
+ interface TransactionTypeOptions {
495
+ targetModels?: string[];
496
+ additionalCategories?: string[];
497
+ }
498
+ /** Field update validation result */
499
+ interface FieldUpdateValidationResult {
500
+ allowed: boolean;
501
+ reason?: string;
502
+ }
503
+
504
+ export type { TransactionListResult as $, RevenueConfig as A, CreateRevenueOptions as B, CommissionInfo as C, MonetizationData as D, MonetizationCreateParams as E, MonetizationCreateResult as F, ActivateOptions as G, HoldInfo as H, RenewalParams as I, CancelOptions as J, PauseOptions as K, Logger as L, MongooseDoc as M, ResumeOptions as N, ObjectId as O, PlanKeyValue as P, ListOptions as Q, ReleaseRecord as R, SubscriptionStatusValue as S, TransactionStatusValue as T, PaymentVerifyOptions as U, PaymentVerifyResult as V, WebhookInfo as W, PaymentStatusResult as X, RefundOptions as Y, PaymentRefundResult as Z, WebhookResult as _, MongooseModel as a, HoldOptions as a0, ReleaseOptions as a1, ReleaseResult as a2, CancelHoldOptions as a3, SplitResult as a4, EscrowStatusResult as a5, PeriodRangeParams as a6, PeriodRangeResult as a7, ProratedAmountParams as a8, DurationResult as a9, SubscriptionEntity as aa, CommissionWithSplitsOptions as ab, TransactionTypeOptions as ac, FieldUpdateValidationResult as ad, TransactionTypeValue as b, TransactionGateway as c, TransactionDocument as d, SubscriptionDocument as e, PaymentStatusValue as f, PaymentGatewayTypeValue as g, MonetizationTypeValue as h, HoldStatusValue as i, HoldReasonValue as j, ReleaseReasonValue as k, SplitTypeValue as l, SplitStatusValue as m, PayoutMethodValue as n, SplitRule as o, SplitInfo as p, CreateIntentParams as q, PaymentIntentData as r, PaymentResultData as s, RefundResultData as t, WebhookEventData as u, ProviderCapabilities as v, PaymentProviderInterface as w, ModelsRegistry as x, ProvidersRegistry as y, HooksRegistry as z };
@@ -0,0 +1,42 @@
1
+ import { o as ok, e as err, i as isOk, a as isErr, u as unwrap, b as unwrapOr, m as map, c as mapErr, f as flatMap, t as tryCatch, d as tryCatchSync, g as all, h as match } from './retry-80lBCmSe.js';
2
+ export { C as CircuitBreaker, w as CircuitBreakerConfig, q as CircuitOpenError, v as CircuitState, E as Err, O as Ok, R as Result, n as RetryExhaustedError, k as calculateDelay, p as createCircuitBreaker, l as isRetryableError, s as resilientExecute, r as retry, j as retryWithResult } from './retry-80lBCmSe.js';
3
+ import { Revenue, createRevenue, RevenueError, EventBus } from './core/index.js';
4
+ export { AlreadyVerifiedError, BaseEvent, ConfigurationError, ERROR_CODES, ErrorCode, EscrowHeldEvent, EscrowReleasedEvent, HooksConfig, InvalidAmountError, InvalidStateTransitionError, MissingRequiredFieldError, ModelNotRegisteredError, ModelsConfig, NotFoundError, OperationError, PaymentFailedEvent, PaymentIntentCreationError, PaymentRefundedEvent, PaymentSucceededEvent, PaymentVerificationError, PluginContext, PluginHooks, PluginLogger, PluginManager, ProviderCapabilityError, ProviderError, ProviderNotFoundError, ProvidersConfig, RefundError, RefundNotSupportedError, RevenueBuilder, RevenueErrorOptions, RevenueEvents, RevenueOptions, RevenuePlugin, StateError, SubscriptionActivatedEvent, SubscriptionCancelledEvent, SubscriptionCreatedEvent, SubscriptionNotActiveError, SubscriptionNotFoundError, SubscriptionRenewedEvent, TransactionCreatedEvent, TransactionNotFoundError, TransactionVerifiedEvent, ValidationError, auditPlugin, createEventBus, definePlugin, isRetryable, isRevenueError, loggingPlugin, metricsPlugin } from './core/index.js';
5
+ export { C as Container, E as EscrowService, M as MonetizationService, P as PaymentService, T as TransactionService } from './index-BnJWVXuw.js';
6
+ import { M as Money } from './actions-CwG-b7fR.js';
7
+ export { E as EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION, h as IdempotencyConfig, c as IdempotencyError, I as IdempotencyManager, e as IdempotencyRecord, g as IdempotencyStore, z as MANUAL_TRANSACTION_CREATE_FIELDS, A as MANUAL_TRANSACTION_UPDATE_FIELDS, b as MemoryIdempotencyStore, a as MoneyValue, P as PROTECTED_MONETIZATION_FIELDS, T as TRANSACTION_MANAGEMENT_TYPE, B as addDuration, i as calculateCommission, n as calculateCommissionWithSplits, k as calculateOrganizationPayout, C as calculatePeriodRange, D as calculateProratedAmount, j as calculateSplits, J as canCancelSubscription, K as canPauseSubscription, H as canRenewSubscription, L as canResumeSubscription, y as canSelfVerify, d as createIdempotencyManager, f as fromSmallestUnit, w as getAllowedUpdateFields, v as getTransactionType, p as isCategoryValid, u as isManualTransaction, q as isMonetizationTransaction, G as isSubscriptionActive, l as logger, o as resolveCategory, F as resolveIntervalToDuration, r as reverseCommission, m as reverseSplits, s as setLogger, t as toSmallestUnit, x as validateFieldUpdate } from './actions-CwG-b7fR.js';
8
+ export { CancelSubscriptionInput, CancelSubscriptionSchema, CommissionConfig, CommissionConfigSchema, CreateHoldInput, CreateHoldSchema, CreateMonetizationSchema, CreatePaymentInput, CreatePaymentSchema, CreateSubscriptionInput, CreateSubscriptionSchema, CurrencySchema, EmailSchema, HoldStatus, HoldStatusSchema, IdempotencyKeySchema, Interval, IntervalSchema, MetadataSchema, MonetizationType, MonetizationTypeSchema, MoneyAmountSchema, MoneySchema, ObjectIdSchema, ProviderConfigSchema, RefundInput, RefundSchema, ReleaseHoldInput, ReleaseHoldSchema, RetryConfig, RetryConfigSchema, RevenueConfigInput, RevenueConfigSchema, SplitRecipient, SplitRecipientSchema, SubscriptionStatus, SubscriptionStatusSchema, VerifyPaymentInput, VerifyPaymentSchema, formatZodError, safeValidate, validate } from './schemas/validation.js';
9
+ import { PaymentProvider } from './providers/index.js';
10
+ export { PaymentIntent, PaymentResult, RefundResult, WebhookEvent } from './providers/index.js';
11
+ export { G as GATEWAY_TYPES, n as GATEWAY_TYPE_VALUES, x as HOLD_REASON, z as HOLD_REASON_VALUES, H as HOLD_STATUS, u as HOLD_STATUS_VALUES, y as HoldReason, L as LIBRARY_CATEGORIES, h as LIBRARY_CATEGORY_VALUES, f as LibraryCategories, g as LibraryCategoryValue, M as MONETIZATION_TYPES, t as MONETIZATION_TYPE_VALUES, s as MonetizationTypes, k as PAYMENT_GATEWAY_TYPE, m as PAYMENT_GATEWAY_TYPE_VALUES, P as PAYMENT_STATUS, j as PAYMENT_STATUS_VALUES, I as PAYOUT_METHOD, K as PAYOUT_METHOD_VALUES, p as PLAN_KEYS, r as PLAN_KEY_VALUES, l as PaymentGatewayType, i as PaymentStatus, J as PayoutMethod, q as PlanKeys, R as RELEASE_REASON, w as RELEASE_REASON_VALUES, v as ReleaseReason, D as SPLIT_STATUS, F as SPLIT_STATUS_VALUES, A as SPLIT_TYPE, C as SPLIT_TYPE_VALUES, S as SUBSCRIPTION_STATUS, o as SUBSCRIPTION_STATUS_VALUES, E as SplitStatus, B as SplitType, c as TRANSACTION_STATUS, e as TRANSACTION_STATUS_VALUES, T as TRANSACTION_TYPE, b as TRANSACTION_TYPE_VALUES, d as TransactionStatus, a as TransactionType } from './split.enums-DHdM1YAV.js';
12
+ export { b as baseMetadataSchema, d as commissionSchema, c as currentPaymentSchema, g as gatewaySchema, h as holdSchema, a as paymentDetailsSchema, p as paymentSummarySchema, e as planSchema, r as referenceSchema, f as splitSchema, s as subscriptionInfoSchema, t as tenantSnapshotSchema } from './split.schema-BPdFZMbU.js';
13
+ export { G as ActivateOptions, a3 as CancelHoldOptions, J as CancelOptions, C as CommissionInfo, ab as CommissionWithSplitsOptions, q as CreateIntentParams, B as CreateRevenueOptions, a9 as DurationResult, a5 as EscrowStatusResult, ad as FieldUpdateValidationResult, H as HoldInfo, a0 as HoldOptions, j as HoldReasonValue, i as HoldStatusValue, z as HooksRegistry, Q as ListOptions, L as Logger, x as ModelsRegistry, E as MonetizationCreateParams, F as MonetizationCreateResult, D as MonetizationData, h as MonetizationTypeValue, M as MongooseDoc, a as MongooseModel, O as ObjectId, K as PauseOptions, g as PaymentGatewayTypeValue, r as PaymentIntentData, w as PaymentProviderInterface, Z as PaymentRefundResult, s as PaymentResultData, X as PaymentStatusResult, f as PaymentStatusValue, U as PaymentVerifyOptions, V as PaymentVerifyResult, n as PayoutMethodValue, a6 as PeriodRangeParams, a7 as PeriodRangeResult, P as PlanKeyValue, a8 as ProratedAmountParams, v as ProviderCapabilities, y as ProvidersRegistry, Y as RefundOptions, t as RefundResultData, a1 as ReleaseOptions, k as ReleaseReasonValue, R as ReleaseRecord, a2 as ReleaseResult, I as RenewalParams, N as ResumeOptions, A as RevenueConfig, p as SplitInfo, a4 as SplitResult, o as SplitRule, m as SplitStatusValue, l as SplitTypeValue, e as SubscriptionDocument, aa as SubscriptionEntity, S as SubscriptionStatusValue, d as TransactionDocument, c as TransactionGateway, $ as TransactionListResult, T as TransactionStatusValue, ac as TransactionTypeOptions, b as TransactionTypeValue, u as WebhookEventData, W as WebhookInfo, _ as WebhookResult } from './index-ChVD3P9k.js';
14
+ import * as z from 'zod';
15
+ export { z };
16
+ import 'mongoose';
17
+
18
+ declare const _default: {
19
+ Revenue: typeof Revenue;
20
+ createRevenue: typeof createRevenue;
21
+ PaymentProvider: typeof PaymentProvider;
22
+ RevenueError: typeof RevenueError;
23
+ Money: typeof Money;
24
+ Result: {
25
+ readonly ok: typeof ok;
26
+ readonly err: typeof err;
27
+ readonly isOk: typeof isOk;
28
+ readonly isErr: typeof isErr;
29
+ readonly unwrap: typeof unwrap;
30
+ readonly unwrapOr: typeof unwrapOr;
31
+ readonly map: typeof map;
32
+ readonly mapErr: typeof mapErr;
33
+ readonly flatMap: typeof flatMap;
34
+ readonly tryCatch: typeof tryCatch;
35
+ readonly tryCatchSync: typeof tryCatchSync;
36
+ readonly all: typeof all;
37
+ readonly match: typeof match;
38
+ };
39
+ EventBus: typeof EventBus;
40
+ };
41
+
42
+ export { EventBus, Money, PaymentProvider, Revenue, RevenueError, all, createRevenue, _default as default, err, flatMap, isErr, isOk, map, mapErr, match, ok, tryCatch, tryCatchSync, unwrap, unwrapOr };