@classytic/revenue 1.0.6 → 1.1.3

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 (81) hide show
  1. package/README.md +582 -633
  2. package/dist/application/services/index.d.mts +4 -0
  3. package/dist/application/services/index.mjs +3 -0
  4. package/dist/base-CsTlVQJe.d.mts +136 -0
  5. package/dist/base-DCoyIUj6.mjs +152 -0
  6. package/dist/category-resolver-DV83N8ok.mjs +284 -0
  7. package/dist/commission-split-BzB8cd39.mjs +485 -0
  8. package/dist/core/events.d.mts +294 -0
  9. package/dist/core/events.mjs +100 -0
  10. package/dist/core/index.d.mts +9 -0
  11. package/dist/core/index.mjs +8 -0
  12. package/dist/enums/index.d.mts +157 -0
  13. package/dist/enums/index.mjs +56 -0
  14. package/dist/errors-CorrWz7A.d.mts +787 -0
  15. package/dist/escrow.enums-CZGrrdg7.mjs +101 -0
  16. package/dist/escrow.enums-DwdLuuve.d.mts +78 -0
  17. package/dist/idempotency-DaYcUGY1.mjs +172 -0
  18. package/dist/index-Dsp7H5Wb.d.mts +471 -0
  19. package/dist/index.d.mts +9 -0
  20. package/dist/index.mjs +38 -0
  21. package/dist/infrastructure/plugins/index.d.mts +239 -0
  22. package/dist/infrastructure/plugins/index.mjs +345 -0
  23. package/dist/money-CvrDOijQ.mjs +271 -0
  24. package/dist/money-DPG8AtJ8.d.mts +112 -0
  25. package/dist/payment.enums-HAuAS9Pp.d.mts +70 -0
  26. package/dist/payment.enums-tEFVa-Xp.mjs +69 -0
  27. package/dist/plugin-BbK0OVHy.d.mts +327 -0
  28. package/dist/plugin-Cd_V04Em.mjs +210 -0
  29. package/dist/providers/index.d.mts +3 -0
  30. package/dist/providers/index.mjs +3 -0
  31. package/dist/reconciliation/index.d.mts +193 -0
  32. package/dist/reconciliation/index.mjs +192 -0
  33. package/dist/retry-HHCOXYdn.d.mts +186 -0
  34. package/dist/revenue-9scqKSef.mjs +553 -0
  35. package/dist/schemas/index.d.mts +2665 -0
  36. package/dist/schemas/index.mjs +717 -0
  37. package/dist/schemas/validation.d.mts +375 -0
  38. package/dist/schemas/validation.mjs +325 -0
  39. package/dist/settlement.enums-DFhkqZEY.d.mts +132 -0
  40. package/dist/settlement.schema-D5uWB5tP.d.mts +344 -0
  41. package/dist/settlement.service-BxuiHpNC.d.mts +594 -0
  42. package/dist/settlement.service-CUxbUTzT.mjs +2510 -0
  43. package/dist/split.enums-BrjabxIX.mjs +86 -0
  44. package/dist/split.enums-DmskfLOM.d.mts +43 -0
  45. package/dist/tax-BoCt5cEd.d.mts +61 -0
  46. package/dist/tax-EQ15DO81.mjs +162 -0
  47. package/dist/transaction.enums-pCyMFT4Z.mjs +96 -0
  48. package/dist/utils/index.d.mts +428 -0
  49. package/dist/utils/index.mjs +346 -0
  50. package/package.json +48 -33
  51. package/dist/actions-Ctf2XUL-.d.ts +0 -519
  52. package/dist/core/index.d.ts +0 -890
  53. package/dist/core/index.js +0 -3005
  54. package/dist/core/index.js.map +0 -1
  55. package/dist/enums/index.d.ts +0 -138
  56. package/dist/enums/index.js +0 -263
  57. package/dist/enums/index.js.map +0 -1
  58. package/dist/index-BnEXsnLJ.d.ts +0 -378
  59. package/dist/index-C5SsOrV0.d.ts +0 -534
  60. package/dist/index.d.ts +0 -43
  61. package/dist/index.js +0 -4498
  62. package/dist/index.js.map +0 -1
  63. package/dist/payment.enums-B_RwB8iR.d.ts +0 -184
  64. package/dist/providers/index.d.ts +0 -132
  65. package/dist/providers/index.js +0 -122
  66. package/dist/providers/index.js.map +0 -1
  67. package/dist/retry-80lBCmSe.d.ts +0 -234
  68. package/dist/schemas/index.d.ts +0 -1051
  69. package/dist/schemas/index.js +0 -627
  70. package/dist/schemas/index.js.map +0 -1
  71. package/dist/schemas/validation.d.ts +0 -384
  72. package/dist/schemas/validation.js +0 -302
  73. package/dist/schemas/validation.js.map +0 -1
  74. package/dist/services/index.d.ts +0 -3
  75. package/dist/services/index.js +0 -1702
  76. package/dist/services/index.js.map +0 -1
  77. package/dist/split.schema-DLVF3XBI.d.ts +0 -1122
  78. package/dist/transaction.enums-7uBnuswI.d.ts +0 -87
  79. package/dist/utils/index.d.ts +0 -24
  80. package/dist/utils/index.js +0 -1140
  81. package/dist/utils/index.js.map +0 -1
@@ -1,378 +0,0 @@
1
- import { G as MonetizationCreateParams, I as MonetizationCreateResult, J as ActivateOptions, e as SubscriptionDocument, K as RenewalParams, N as CancelOptions, Q as PauseOptions, U as ResumeOptions, V as ListOptions, X as PaymentVerifyOptions, Y as PaymentVerifyResult, Z as PaymentStatusResult, _ as RefundOptions, $ as PaymentRefundResult, a0 as WebhookResult, d as TransactionDocument, y as PaymentProviderInterface, a1 as TransactionListResult, a2 as HoldOptions, a3 as ReleaseOptions, a4 as ReleaseResult, a5 as CancelHoldOptions, q as SplitRule, a6 as SplitResult, a7 as EscrowStatusResult } from './index-C5SsOrV0.js';
2
-
3
- /**
4
- * Dependency Injection Container
5
- * @classytic/revenue
6
- *
7
- * Lightweight DI container for managing dependencies
8
- * Inspired by: Awilix, InversifyJS but much simpler
9
- */
10
- declare class Container {
11
- private _services;
12
- private _singletons;
13
- constructor();
14
- /**
15
- * Register a service
16
- * @param name - Service name
17
- * @param implementation - Service implementation or factory
18
- * @param options - Registration options
19
- */
20
- register<T>(name: string, implementation: T | ((container: Container) => T), options?: {
21
- singleton?: boolean;
22
- factory?: boolean;
23
- }): this;
24
- /**
25
- * Register a singleton service
26
- * @param name - Service name
27
- * @param implementation - Service implementation
28
- */
29
- singleton<T>(name: string, implementation: T): this;
30
- /**
31
- * Register a transient service (new instance each time)
32
- * @param name - Service name
33
- * @param factory - Factory function
34
- */
35
- transient<T>(name: string, factory: (container: Container) => T): this;
36
- /**
37
- * Get a service from the container
38
- * @param name - Service name
39
- * @returns Service instance
40
- */
41
- get<T>(name: string): T;
42
- /**
43
- * Check if service is registered
44
- * @param name - Service name
45
- */
46
- has(name: string): boolean;
47
- /**
48
- * Get all registered service names
49
- */
50
- keys(): string[];
51
- /**
52
- * Clear all services (useful for testing)
53
- */
54
- clear(): void;
55
- /**
56
- * Create a child container (for scoped dependencies)
57
- */
58
- createScope(): Container;
59
- }
60
-
61
- /**
62
- * Monetization Service
63
- * @classytic/revenue
64
- *
65
- * Framework-agnostic monetization management service with DI
66
- * Handles purchases, subscriptions, and free items using provider system
67
- */
68
-
69
- /**
70
- * Monetization Service
71
- * Uses DI container for all dependencies
72
- */
73
- declare class MonetizationService {
74
- private readonly models;
75
- private readonly providers;
76
- private readonly config;
77
- private readonly hooks;
78
- private readonly logger;
79
- constructor(container: Container);
80
- /**
81
- * Create a new monetization (purchase, subscription, or free item)
82
- *
83
- * @param params - Monetization parameters
84
- *
85
- * @example
86
- * // One-time purchase
87
- * await revenue.monetization.create({
88
- * data: {
89
- * organizationId: '...',
90
- * customerId: '...',
91
- * referenceId: order._id,
92
- * referenceModel: 'Order',
93
- * },
94
- * planKey: 'one_time',
95
- * monetizationType: 'purchase',
96
- * gateway: 'bkash',
97
- * amount: 1500,
98
- * });
99
- *
100
- * // Recurring subscription
101
- * await revenue.monetization.create({
102
- * data: {
103
- * organizationId: '...',
104
- * customerId: '...',
105
- * referenceId: subscription._id,
106
- * referenceModel: 'Subscription',
107
- * },
108
- * planKey: 'monthly',
109
- * monetizationType: 'subscription',
110
- * gateway: 'stripe',
111
- * amount: 2000,
112
- * });
113
- *
114
- * @returns Result with subscription, transaction, and paymentIntent
115
- */
116
- create(params: MonetizationCreateParams): Promise<MonetizationCreateResult>;
117
- /**
118
- * Activate subscription after payment verification
119
- *
120
- * @param subscriptionId - Subscription ID or transaction ID
121
- * @param options - Activation options
122
- * @returns Updated subscription
123
- */
124
- activate(subscriptionId: string, options?: ActivateOptions): Promise<SubscriptionDocument>;
125
- /**
126
- * Renew subscription
127
- *
128
- * @param subscriptionId - Subscription ID
129
- * @param params - Renewal parameters
130
- * @returns { subscription, transaction, paymentIntent }
131
- */
132
- renew(subscriptionId: string, params?: RenewalParams): Promise<MonetizationCreateResult>;
133
- /**
134
- * Cancel subscription
135
- *
136
- * @param subscriptionId - Subscription ID
137
- * @param options - Cancellation options
138
- * @returns Updated subscription
139
- */
140
- cancel(subscriptionId: string, options?: CancelOptions): Promise<SubscriptionDocument>;
141
- /**
142
- * Pause subscription
143
- *
144
- * @param subscriptionId - Subscription ID
145
- * @param options - Pause options
146
- * @returns Updated subscription
147
- */
148
- pause(subscriptionId: string, options?: PauseOptions): Promise<SubscriptionDocument>;
149
- /**
150
- * Resume subscription
151
- *
152
- * @param subscriptionId - Subscription ID
153
- * @param options - Resume options
154
- * @returns Updated subscription
155
- */
156
- resume(subscriptionId: string, options?: ResumeOptions): Promise<SubscriptionDocument>;
157
- /**
158
- * List subscriptions with filters
159
- *
160
- * @param filters - Query filters
161
- * @param options - Query options (limit, skip, sort)
162
- * @returns Subscriptions
163
- */
164
- list(filters?: Record<string, unknown>, options?: ListOptions): Promise<SubscriptionDocument[]>;
165
- /**
166
- * Get subscription by ID
167
- *
168
- * @param subscriptionId - Subscription ID
169
- * @returns Subscription
170
- */
171
- get(subscriptionId: string): Promise<SubscriptionDocument>;
172
- /**
173
- * Calculate period end date based on plan key
174
- * @private
175
- */
176
- private _calculatePeriodEnd;
177
- /**
178
- * Trigger event hook (fire-and-forget, non-blocking)
179
- * @private
180
- */
181
- private _triggerHook;
182
- }
183
-
184
- /**
185
- * Payment Service
186
- * @classytic/revenue
187
- *
188
- * Framework-agnostic payment verification and management service with DI
189
- * Handles payment verification, refunds, and status updates
190
- */
191
-
192
- /**
193
- * Payment Service
194
- * Uses DI container for all dependencies
195
- */
196
- declare class PaymentService {
197
- private readonly models;
198
- private readonly providers;
199
- private readonly config;
200
- private readonly hooks;
201
- private readonly logger;
202
- constructor(container: Container);
203
- /**
204
- * Verify a payment
205
- *
206
- * @param paymentIntentId - Payment intent ID, session ID, or transaction ID
207
- * @param options - Verification options
208
- * @returns { transaction, status }
209
- */
210
- verify(paymentIntentId: string, options?: PaymentVerifyOptions): Promise<PaymentVerifyResult>;
211
- /**
212
- * Get payment status
213
- *
214
- * @param paymentIntentId - Payment intent ID, session ID, or transaction ID
215
- * @returns { transaction, status }
216
- */
217
- getStatus(paymentIntentId: string): Promise<PaymentStatusResult>;
218
- /**
219
- * Refund a payment
220
- *
221
- * @param paymentId - Payment intent ID, session ID, or transaction ID
222
- * @param amount - Amount to refund (optional, full refund if not provided)
223
- * @param options - Refund options
224
- * @returns { transaction, refundResult }
225
- */
226
- refund(paymentId: string, amount?: number | null, options?: RefundOptions): Promise<PaymentRefundResult>;
227
- /**
228
- * Handle webhook from payment provider
229
- *
230
- * @param provider - Provider name
231
- * @param payload - Webhook payload
232
- * @param headers - Request headers
233
- * @returns { event, transaction }
234
- */
235
- handleWebhook(providerName: string, payload: unknown, headers?: Record<string, string>): Promise<WebhookResult>;
236
- /**
237
- * List payments/transactions with filters
238
- *
239
- * @param filters - Query filters
240
- * @param options - Query options (limit, skip, sort)
241
- * @returns Transactions
242
- */
243
- list(filters?: Record<string, unknown>, options?: ListOptions): Promise<TransactionDocument[]>;
244
- /**
245
- * Get payment/transaction by ID
246
- *
247
- * @param transactionId - Transaction ID
248
- * @returns Transaction
249
- */
250
- get(transactionId: string): Promise<TransactionDocument>;
251
- /**
252
- * Get provider instance
253
- *
254
- * @param providerName - Provider name
255
- * @returns Provider instance
256
- */
257
- getProvider(providerName: string): PaymentProviderInterface;
258
- /**
259
- * Trigger event hook (fire-and-forget, non-blocking)
260
- * @private
261
- */
262
- private _triggerHook;
263
- /**
264
- * Find transaction by sessionId, paymentIntentId, or transaction ID
265
- * @private
266
- */
267
- private _findTransaction;
268
- }
269
-
270
- /**
271
- * Transaction Service
272
- * @classytic/revenue
273
- *
274
- * Thin, focused transaction service for core operations
275
- * Users handle their own analytics, exports, and complex queries
276
- *
277
- * Works with ANY model implementation:
278
- * - Plain Mongoose models
279
- * - @classytic/mongokit Repository instances
280
- * - Any other abstraction with compatible interface
281
- */
282
-
283
- /**
284
- * Transaction Service
285
- * Focused on core transaction lifecycle operations
286
- */
287
- declare class TransactionService {
288
- private readonly models;
289
- private readonly hooks;
290
- private readonly logger;
291
- constructor(container: Container);
292
- /**
293
- * Get transaction by ID
294
- *
295
- * @param transactionId - Transaction ID
296
- * @returns Transaction
297
- */
298
- get(transactionId: string): Promise<TransactionDocument>;
299
- /**
300
- * List transactions with filters
301
- *
302
- * @param filters - Query filters
303
- * @param options - Query options (limit, skip, sort, populate)
304
- * @returns { transactions, total, page, limit }
305
- */
306
- list(filters?: Record<string, unknown>, options?: ListOptions): Promise<TransactionListResult>;
307
- /**
308
- * Update transaction
309
- *
310
- * @param transactionId - Transaction ID
311
- * @param updates - Fields to update
312
- * @returns Updated transaction
313
- */
314
- update(transactionId: string, updates: Partial<TransactionDocument>): Promise<TransactionDocument>;
315
- /**
316
- * Trigger event hook (fire-and-forget, non-blocking)
317
- * @private
318
- */
319
- private _triggerHook;
320
- }
321
-
322
- /**
323
- * Escrow Service
324
- * @classytic/revenue
325
- *
326
- * Platform-as-intermediary payment flow
327
- * Hold funds → Verify → Split/Deduct → Release to organization
328
- */
329
-
330
- declare class EscrowService {
331
- private readonly models;
332
- private readonly hooks;
333
- private readonly logger;
334
- constructor(container: Container);
335
- /**
336
- * Hold funds in escrow
337
- *
338
- * @param transactionId - Transaction to hold
339
- * @param options - Hold options
340
- * @returns Updated transaction
341
- */
342
- hold(transactionId: string, options?: HoldOptions): Promise<TransactionDocument>;
343
- /**
344
- * Release funds from escrow to recipient
345
- *
346
- * @param transactionId - Transaction to release
347
- * @param options - Release options
348
- * @returns { transaction, releaseTransaction }
349
- */
350
- release(transactionId: string, options: ReleaseOptions): Promise<ReleaseResult>;
351
- /**
352
- * Cancel hold and release back to customer
353
- *
354
- * @param transactionId - Transaction to cancel hold
355
- * @param options - Cancel options
356
- * @returns Updated transaction
357
- */
358
- cancel(transactionId: string, options?: CancelHoldOptions): Promise<TransactionDocument>;
359
- /**
360
- * Split payment to multiple recipients
361
- * Deducts splits from held amount and releases remainder to organization
362
- *
363
- * @param transactionId - Transaction to split
364
- * @param splitRules - Split configuration
365
- * @returns { transaction, splitTransactions, organizationTransaction }
366
- */
367
- split(transactionId: string, splitRules?: SplitRule[]): Promise<SplitResult>;
368
- /**
369
- * Get escrow status
370
- *
371
- * @param transactionId - Transaction ID
372
- * @returns Escrow status
373
- */
374
- getStatus(transactionId: string): Promise<EscrowStatusResult>;
375
- private _triggerHook;
376
- }
377
-
378
- export { Container as C, EscrowService as E, MonetizationService as M, PaymentService as P, TransactionService as T };