@classytic/revenue 1.0.2 → 1.1.2

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 (53) hide show
  1. package/README.md +603 -486
  2. package/dist/application/services/index.d.ts +6 -0
  3. package/dist/application/services/index.js +3288 -0
  4. package/dist/application/services/index.js.map +1 -0
  5. package/dist/core/events.d.ts +455 -0
  6. package/dist/core/events.js +122 -0
  7. package/dist/core/events.js.map +1 -0
  8. package/dist/core/index.d.ts +12 -889
  9. package/dist/core/index.js +2361 -705
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/enums/index.d.ts +54 -25
  12. package/dist/enums/index.js +143 -14
  13. package/dist/enums/index.js.map +1 -1
  14. package/dist/escrow.enums-CE0VQsfe.d.ts +76 -0
  15. package/dist/{index-BnJWVXuw.d.ts → index-DxIK0UmZ.d.ts} +281 -26
  16. package/dist/index-EnfKzDbs.d.ts +806 -0
  17. package/dist/{index-ChVD3P9k.d.ts → index-cLJBLUvx.d.ts} +55 -81
  18. package/dist/index.d.ts +16 -15
  19. package/dist/index.js +2583 -2066
  20. package/dist/index.js.map +1 -1
  21. package/dist/infrastructure/plugins/index.d.ts +267 -0
  22. package/dist/infrastructure/plugins/index.js +292 -0
  23. package/dist/infrastructure/plugins/index.js.map +1 -0
  24. package/dist/money-widWVD7r.d.ts +111 -0
  25. package/dist/payment.enums-C1BiGlRa.d.ts +69 -0
  26. package/dist/plugin-Bb9HOE10.d.ts +336 -0
  27. package/dist/providers/index.d.ts +19 -6
  28. package/dist/providers/index.js +22 -3
  29. package/dist/providers/index.js.map +1 -1
  30. package/dist/reconciliation/index.d.ts +215 -0
  31. package/dist/reconciliation/index.js +140 -0
  32. package/dist/reconciliation/index.js.map +1 -0
  33. package/dist/{retry-80lBCmSe.d.ts → retry-D4hFUwVk.d.ts} +1 -41
  34. package/dist/schemas/index.d.ts +1927 -166
  35. package/dist/schemas/index.js +357 -40
  36. package/dist/schemas/index.js.map +1 -1
  37. package/dist/schemas/validation.d.ts +87 -12
  38. package/dist/schemas/validation.js +71 -17
  39. package/dist/schemas/validation.js.map +1 -1
  40. package/dist/settlement.enums-ByC1x0ye.d.ts +130 -0
  41. package/dist/settlement.schema-CpamV7ZY.d.ts +343 -0
  42. package/dist/split.enums-DG3TxQf9.d.ts +42 -0
  43. package/dist/tax-CV8A0sxl.d.ts +60 -0
  44. package/dist/utils/index.d.ts +487 -13
  45. package/dist/utils/index.js +370 -235
  46. package/dist/utils/index.js.map +1 -1
  47. package/package.json +27 -13
  48. package/dist/actions-CwG-b7fR.d.ts +0 -519
  49. package/dist/services/index.d.ts +0 -3
  50. package/dist/services/index.js +0 -1632
  51. package/dist/services/index.js.map +0 -1
  52. package/dist/split.enums-Bh24jw8p.d.ts +0 -255
  53. package/dist/split.schema-DYVP7Wu2.d.ts +0 -958
@@ -1,24 +1,498 @@
1
- export { O as DurationUnit, 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, M as Money, a as MoneyValue, P as PROTECTED_MONETIZATION_FIELDS, T as TRANSACTION_MANAGEMENT_TYPE, N as TransactionManagementType, 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, l as loggerDefault, 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';
2
- export { C as CircuitBreaker, w as CircuitBreakerConfig, q as CircuitOpenError, v as CircuitState, x as RetryConfig, n as RetryExhaustedError, y as RetryState, k as calculateDelay, p as createCircuitBreaker, l as isRetryableError, s as resilientExecute, r as retry, j as retryWithResult } from '../retry-80lBCmSe.js';
3
- import { z as HooksRegistry, L as Logger } from '../index-ChVD3P9k.js';
1
+ import { C as CommissionInfo, c as SplitRule, a as SplitInfo, d as MonetizationTypeValue, T as TransactionDocument, e as TransactionTypeOptions, F as FieldUpdateValidationResult, L as Logger, f as PeriodRangeParams, g as PeriodRangeResult, h as ProratedAmountParams, D as DurationResult, S as SubscriptionDocument, i as SubscriptionEntity } from '../index-cLJBLUvx.js';
2
+ import { T as TaxConfig, a as TaxCalculation, b as TaxType } from '../tax-CV8A0sxl.js';
3
+ export { M as Money, a as MoneyValue, f as fromSmallestUnit, t as toSmallestUnit } from '../money-widWVD7r.js';
4
+ import { R as Result } from '../retry-D4hFUwVk.js';
5
+ export { C as CircuitBreaker, l as CircuitBreakerConfig, n as CircuitState, k as RetryConfig, j as createCircuitBreaker, r as retry } from '../retry-D4hFUwVk.js';
4
6
  import 'mongoose';
7
+ import '@classytic/shared-types';
5
8
 
6
9
  /**
7
- * Hook Utilities
10
+ * Commission Calculation Utility
8
11
  * @classytic/revenue
9
12
  *
10
- * Fire-and-forget hook execution - never blocks main flow
13
+ * Handles platform commission calculation with gateway fee deduction
11
14
  */
12
15
 
13
16
  /**
14
- * Trigger hooks asynchronously without waiting
15
- * Errors are logged but never thrown
17
+ * Build commission object for transaction
16
18
  *
17
- * @param hooks - Hooks object
18
- * @param event - Event name
19
- * @param data - Event data
20
- * @param logger - Logger instance
19
+ * @param amount - Transaction amount
20
+ * @param commissionRate - Commission rate (0 to 1, e.g., 0.10 for 10%)
21
+ * @param gatewayFeeRate - Gateway fee rate (0 to 1, e.g., 0.018 for 1.8%)
22
+ * @returns Commission object or null
21
23
  */
22
- declare function triggerHook(hooks: HooksRegistry, event: string, data: unknown, logger: Logger): void;
24
+ declare function calculateCommission(amount: number, commissionRate: number, gatewayFeeRate?: number): CommissionInfo | null;
25
+ /**
26
+ * Reverse commission on refund (proportional)
27
+ *
28
+ * @param originalCommission - Original commission object
29
+ * @param originalAmount - Original transaction amount
30
+ * @param refundAmount - Amount being refunded
31
+ * @returns Reversed commission or null
32
+ */
33
+ declare function reverseCommission(originalCommission: CommissionInfo | null | undefined, originalAmount: number, refundAmount: number): CommissionInfo | null;
34
+
35
+ /**
36
+ * Tax Utilities
37
+ * @classytic/revenue
38
+ *
39
+ * Tax calculation utilities
40
+ * Philosophy: Apps provide rates, library does math (like Stripe)
41
+ */
42
+
43
+ /**
44
+ * Calculate tax for a transaction
45
+ *
46
+ * Handles both tax-inclusive and tax-exclusive pricing:
47
+ * - Tax-exclusive: Customer pays baseAmount + tax
48
+ * - Tax-inclusive: Customer pays totalAmount (which includes tax)
49
+ *
50
+ * @param amount - Transaction amount (in smallest currency unit, e.g., cents)
51
+ * @param category - Transaction category (for exemption check)
52
+ * @param config - Tax configuration from app
53
+ * @returns Tax calculation result
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Tax-exclusive pricing (customer pays base + tax)
58
+ * const result = calculateTax(10000, 'subscription', {
59
+ * isRegistered: true,
60
+ * defaultRate: 0.15,
61
+ * pricesIncludeTax: false,
62
+ * });
63
+ * // result = {
64
+ * // isApplicable: true,
65
+ * // rate: 0.15,
66
+ * // baseAmount: 10000,
67
+ * // taxAmount: 1500,
68
+ * // totalAmount: 11500,
69
+ * // pricesIncludeTax: false
70
+ * // }
71
+ *
72
+ * // Tax-inclusive pricing (price already includes tax)
73
+ * const result2 = calculateTax(11500, 'subscription', {
74
+ * isRegistered: true,
75
+ * defaultRate: 0.15,
76
+ * pricesIncludeTax: true,
77
+ * });
78
+ * // result2 = {
79
+ * // isApplicable: true,
80
+ * // rate: 0.15,
81
+ * // baseAmount: 10000,
82
+ * // taxAmount: 1500,
83
+ * // totalAmount: 11500,
84
+ * // pricesIncludeTax: true
85
+ * // }
86
+ * ```
87
+ */
88
+ declare function calculateTax(amount: number, category: string, config: TaxConfig | null): TaxCalculation;
89
+ /**
90
+ * Get tax type based on transaction flow
91
+ *
92
+ * - Inflow transactions → tax is "collected" (you collect from customer)
93
+ * - Outflow transactions → tax is "paid" (you pay to supplier)
94
+ * - Exempt categories → "exempt"
95
+ *
96
+ * @param transactionFlow - 'inflow' or 'outflow'
97
+ * @param category - Transaction category
98
+ * @param exemptCategories - List of exempt categories
99
+ * @returns Tax type
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * getTaxType('inflow', 'subscription', []) // 'collected'
104
+ * getTaxType('outflow', 'refund', []) // 'paid'
105
+ * getTaxType('inflow', 'education', ['education']) // 'exempt'
106
+ * ```
107
+ */
108
+ declare function getTaxType(transactionFlow: 'inflow' | 'outflow', category: string, exemptCategories?: string[]): TaxType;
109
+ /**
110
+ * Reverse tax calculation for refunds
111
+ * When refunding a transaction, tax must be reversed proportionally
112
+ *
113
+ * @param originalTax - Tax from original transaction
114
+ * @param originalAmount - Original transaction amount
115
+ * @param refundAmount - Amount being refunded
116
+ * @returns Reversed tax calculation
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // Original: $100 + $15 tax = $115
121
+ * const originalTax = {
122
+ * isApplicable: true,
123
+ * rate: 0.15,
124
+ * baseAmount: 10000,
125
+ * taxAmount: 1500,
126
+ * totalAmount: 11500,
127
+ * type: 'collected',
128
+ * };
129
+ *
130
+ * // Refund 50% ($57.50)
131
+ * const refundTax = reverseTax(originalTax, 11500, 5750);
132
+ * // refundTax = {
133
+ * // isApplicable: true,
134
+ * // rate: 0.15,
135
+ * // baseAmount: 5000,
136
+ * // taxAmount: 750,
137
+ * // totalAmount: 5750,
138
+ * // type: 'paid', // Reversed!
139
+ * // }
140
+ * ```
141
+ */
142
+ declare function reverseTax(originalTax: TaxCalculation & {
143
+ type?: TaxType;
144
+ }, originalAmount: number, refundAmount: number): TaxCalculation & {
145
+ type?: TaxType;
146
+ };
147
+
148
+ /**
149
+ * Commission Split Utilities
150
+ * @classytic/revenue
151
+ *
152
+ * Multi-party commission split calculation for affiliate/referral systems
153
+ */
154
+
155
+ /**
156
+ * Calculate multi-party commission splits
157
+ *
158
+ * @param amount - Transaction amount
159
+ * @param splitRules - Split configuration
160
+ * @param gatewayFeeRate - Gateway fee rate (optional)
161
+ * @returns Split objects
162
+ *
163
+ * @example
164
+ * calculateSplits(1000, [
165
+ * { type: 'platform_commission', recipientId: 'platform', recipientType: 'platform', rate: 0.10 },
166
+ * { type: 'affiliate_commission', recipientId: 'affiliate-123', recipientType: 'user', rate: 0.02 },
167
+ * ], 0.018);
168
+ *
169
+ * Returns:
170
+ * [
171
+ * { type: 'platform_commission', recipientId: 'platform', grossAmount: 100, gatewayFeeAmount: 18, netAmount: 82, ... },
172
+ * { type: 'affiliate_commission', recipientId: 'affiliate-123', grossAmount: 20, gatewayFeeAmount: 0, netAmount: 20, ... },
173
+ * ]
174
+ */
175
+ declare function calculateSplits(amount: number, splitRules?: SplitRule[], gatewayFeeRate?: number): SplitInfo[];
176
+ /**
177
+ * Calculate organization payout after splits
178
+ *
179
+ * @param amount - Total transaction amount
180
+ * @param splits - Calculated splits
181
+ * @returns Amount organization receives
182
+ */
183
+ declare function calculateOrganizationPayout(amount: number, splits?: SplitInfo[]): number;
184
+ /**
185
+ * Reverse splits proportionally on refund
186
+ *
187
+ * @param originalSplits - Original split objects
188
+ * @param originalAmount - Original transaction amount
189
+ * @param refundAmount - Amount being refunded
190
+ * @returns Reversed splits
191
+ */
192
+ declare function reverseSplits(originalSplits: SplitInfo[] | undefined | null, originalAmount: number, refundAmount: number): SplitInfo[];
193
+
194
+ /**
195
+ * Idempotency Utilities
196
+ * @classytic/revenue
197
+ *
198
+ * Prevent duplicate operations with idempotency keys
199
+ * Inspired by: Stripe, Amazon SQS deduplication
200
+ */
201
+
202
+ interface IdempotencyRecord<T = unknown> {
203
+ /** Idempotency key */
204
+ key: string;
205
+ /** Operation result (if completed) */
206
+ result?: T;
207
+ /** Operation status */
208
+ status: 'pending' | 'completed' | 'failed';
209
+ /** Creation timestamp */
210
+ createdAt: Date;
211
+ /** Completion timestamp */
212
+ completedAt?: Date;
213
+ /** Request hash for validation */
214
+ requestHash: string;
215
+ /** TTL - when record expires */
216
+ expiresAt: Date;
217
+ }
218
+ interface IdempotencyStore {
219
+ /** Get record by key */
220
+ get<T>(key: string): Promise<IdempotencyRecord<T> | null>;
221
+ /** Set or update record */
222
+ set<T>(key: string, record: IdempotencyRecord<T>): Promise<void>;
223
+ /** Delete record */
224
+ delete(key: string): Promise<void>;
225
+ /** Check if key exists */
226
+ exists(key: string): Promise<boolean>;
227
+ }
228
+ interface IdempotencyConfig {
229
+ /** TTL in milliseconds (default: 24 hours) */
230
+ ttl?: number;
231
+ /** Custom store implementation */
232
+ store?: IdempotencyStore;
233
+ /** Key prefix */
234
+ prefix?: string;
235
+ }
236
+ declare class IdempotencyError extends Error {
237
+ readonly code: 'DUPLICATE_REQUEST' | 'REQUEST_IN_PROGRESS' | 'REQUEST_MISMATCH';
238
+ constructor(message: string, code: 'DUPLICATE_REQUEST' | 'REQUEST_IN_PROGRESS' | 'REQUEST_MISMATCH');
239
+ }
240
+ /**
241
+ * Idempotency manager
242
+ */
243
+ declare class IdempotencyManager {
244
+ private store;
245
+ private ttl;
246
+ private prefix;
247
+ constructor(config?: IdempotencyConfig);
248
+ /**
249
+ * Generate a unique idempotency key
250
+ */
251
+ generateKey(): string;
252
+ /**
253
+ * Hash request parameters for validation
254
+ * Uses deterministic JSON serialization and simple hash function
255
+ */
256
+ private hashRequest;
257
+ /**
258
+ * Execute operation with idempotency protection
259
+ */
260
+ execute<T>(key: string, params: unknown, operation: () => Promise<T>): Promise<Result<T, IdempotencyError>>;
261
+ /**
262
+ * Check if operation with key was already completed
263
+ */
264
+ wasCompleted(key: string): Promise<boolean>;
265
+ /**
266
+ * Get cached result for key
267
+ */
268
+ getCached<T>(key: string): Promise<T | null>;
269
+ /**
270
+ * Invalidate a key (force re-execution on next call)
271
+ */
272
+ invalidate(key: string): Promise<void>;
273
+ /**
274
+ * Destroy the idempotency manager and cleanup resources
275
+ * Call this when shutting down to prevent memory leaks
276
+ */
277
+ destroy(): void;
278
+ }
279
+ /**
280
+ * Create idempotency manager
281
+ */
282
+ declare function createIdempotencyManager(config?: IdempotencyConfig): IdempotencyManager;
283
+
284
+ /**
285
+ * Category Resolver Utility
286
+ * @classytic/revenue
287
+ *
288
+ * Resolves transaction category based on categoryMappings
289
+ */
290
+
291
+ /**
292
+ * Resolve category for a transaction based on entity and monetizationType
293
+ *
294
+ * Resolution Logic:
295
+ * 1. If categoryMappings[entity] exists → use it
296
+ * 2. Otherwise → fall back to default library category
297
+ *
298
+ * @param entity - The logical entity/identifier (e.g., 'Order', 'PlatformSubscription', 'Membership')
299
+ * NOTE: This is NOT a database model name - it's just a logical identifier
300
+ * @param monetizationType - The monetization type ('subscription', 'purchase', 'free')
301
+ * @param categoryMappings - User-defined category mappings from config
302
+ * @returns Category name for the transaction
303
+ *
304
+ * @example
305
+ * // With mapping defined
306
+ * resolveCategory('Order', 'subscription', { Order: 'order_subscription' })
307
+ * // Returns: 'order_subscription'
308
+ *
309
+ * @example
310
+ * // Without mapping, falls back to library default
311
+ * resolveCategory('Order', 'subscription', {})
312
+ * // Returns: 'subscription'
313
+ *
314
+ * @example
315
+ * // Different entities with different mappings
316
+ * const mappings = {
317
+ * Order: 'order_subscription',
318
+ * PlatformSubscription: 'platform_subscription',
319
+ * TenantUpgrade: 'tenant_upgrade',
320
+ * Membership: 'gym_membership',
321
+ * Enrollment: 'course_enrollment',
322
+ * };
323
+ * resolveCategory('PlatformSubscription', 'subscription', mappings)
324
+ * // Returns: 'platform_subscription'
325
+ */
326
+ declare function resolveCategory(entity: string | null | undefined, monetizationType: MonetizationTypeValue, categoryMappings?: Record<string, string>): string;
327
+
328
+ /**
329
+ * Transaction Type Detection & Classification
330
+ *
331
+ * Distinguishes between:
332
+ * - Monetization-managed transactions (library-controlled, strict rules)
333
+ * - Manual admin transactions (flexible, admin-controlled)
334
+ *
335
+ * @module @classytic/revenue/utils/transaction-type
336
+ */
337
+
338
+ /**
339
+ * Transaction types with different protection rules
340
+ */
341
+ declare const TRANSACTION_MANAGEMENT_TYPE: {
342
+ readonly MONETIZATION: "monetization";
343
+ readonly MANUAL: "manual";
344
+ };
345
+ type TransactionManagementType = typeof TRANSACTION_MANAGEMENT_TYPE[keyof typeof TRANSACTION_MANAGEMENT_TYPE];
346
+ /**
347
+ * Check if transaction is monetization-managed
348
+ *
349
+ * Monetization-managed means:
350
+ * - Created through subscription/purchase flows via the library
351
+ * - Status controlled by payment webhooks/verification
352
+ * - Amount/commission calculated by library
353
+ * - Protected fields: status, amount, commission, gateway, verifiedAt, verifiedBy
354
+ *
355
+ * @param transaction - Transaction document or data
356
+ * @param options - Options
357
+ */
358
+ declare function isMonetizationTransaction(transaction: Partial<TransactionDocument>, options?: TransactionTypeOptions): boolean;
359
+ /**
360
+ * Check if transaction is manual admin transaction
361
+ *
362
+ * Manual transactions:
363
+ * - Created directly by admins for operational expenses/income
364
+ * - Can be self-verified by admins
365
+ * - More flexible updates allowed
366
+ * - No commission/gateway complexity
367
+ *
368
+ * @param transaction - Transaction document or data
369
+ * @param options - Options (same as isMonetizationTransaction)
370
+ */
371
+ declare function isManualTransaction(transaction: Partial<TransactionDocument>, options?: TransactionTypeOptions): boolean;
372
+ /**
373
+ * Get transaction type
374
+ *
375
+ * @param transaction - Transaction document or data
376
+ * @param options - Options (same as isMonetizationTransaction)
377
+ */
378
+ declare function getTransactionType(transaction: Partial<TransactionDocument>, options?: TransactionTypeOptions): TransactionManagementType;
379
+ /**
380
+ * Protected fields for monetization transactions
381
+ * These fields cannot be updated directly by admins
382
+ */
383
+ declare const PROTECTED_MONETIZATION_FIELDS: readonly ["status", "amount", "platformCommission", "netAmount", "verifiedAt", "verifiedBy", "gateway", "webhook", "metadata.commission", "metadata.gateway", "type", "category", "sourceModel", "sourceId"];
384
+ /**
385
+ * Editable fields for monetization transactions (before verification)
386
+ * These fields can be updated by frontend/customer before payment is verified
387
+ */
388
+ declare const EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION: readonly ["reference", "paymentDetails", "notes"];
389
+ /**
390
+ * Allowed fields for manual transaction creation
391
+ */
392
+ declare const MANUAL_TRANSACTION_CREATE_FIELDS: readonly ["organizationId", "type", "category", "amount", "method", "reference", "paymentDetails", "notes", "date", "description"];
393
+ /**
394
+ * Allowed fields for manual transaction updates
395
+ */
396
+ declare const MANUAL_TRANSACTION_UPDATE_FIELDS: readonly ["amount", "method", "reference", "paymentDetails", "notes", "date", "description"];
397
+ /**
398
+ * Get allowed update fields based on transaction type and status
399
+ *
400
+ * @param transaction - Transaction document
401
+ * @param options - Options for transaction type detection
402
+ */
403
+ declare function getAllowedUpdateFields(transaction: Partial<TransactionDocument>, options?: TransactionTypeOptions): readonly string[];
404
+ /**
405
+ * Validate if field update is allowed
406
+ *
407
+ * @param transaction - Transaction document
408
+ * @param fieldName - Field being updated
409
+ * @param options - Options for transaction type detection
410
+ */
411
+ declare function validateFieldUpdate(transaction: Partial<TransactionDocument>, fieldName: string, options?: TransactionTypeOptions): FieldUpdateValidationResult;
412
+ /**
413
+ * Check if transaction can be self-verified by admin
414
+ *
415
+ * @param transaction - Transaction document
416
+ * @param options - Options for transaction type detection
417
+ */
418
+ declare function canSelfVerify(transaction: Partial<TransactionDocument>, options?: TransactionTypeOptions): boolean;
419
+
420
+ /**
421
+ * Logger Abstraction for Monetization Library
422
+ *
423
+ * Defaults to console for standalone usage
424
+ * Can be overridden with custom logger (pino, winston, etc)
425
+ *
426
+ * Usage:
427
+ * ```typescript
428
+ * import { setLogger } from '@classytic/revenue';
429
+ *
430
+ * // Optional: Use your own logger
431
+ * setLogger(myPinoLogger);
432
+ * ```
433
+ */
434
+
435
+ /**
436
+ * Set custom logger implementation
437
+ * @param customLogger - Logger instance with info, warn, error, debug methods
438
+ */
439
+ declare function setLogger(customLogger: Logger): void;
440
+ /**
441
+ * Logger proxy - delegates to current logger implementation
442
+ */
443
+ declare const logger: Logger;
444
+
445
+ /**
446
+ * Subscription Period Utilities
447
+ * @classytic/revenue/utils/subscription
448
+ *
449
+ * Universal period calculation, proration, and date utilities
450
+ */
451
+
452
+ type DurationUnit = 'days' | 'day' | 'weeks' | 'week' | 'months' | 'month' | 'years' | 'year';
453
+ /**
454
+ * Add duration to date
455
+ */
456
+ declare function addDuration(startDate: Date, duration: number, unit?: DurationUnit): Date;
457
+ /**
458
+ * Calculate subscription period start/end dates
459
+ */
460
+ declare function calculatePeriodRange(params: PeriodRangeParams): PeriodRangeResult;
461
+ /**
462
+ * Calculate prorated refund amount for unused period
463
+ */
464
+ declare function calculateProratedAmount(params: ProratedAmountParams): number;
465
+ /**
466
+ * Convert interval + count to duration/unit
467
+ */
468
+ declare function resolveIntervalToDuration(interval?: string, intervalCount?: number): DurationResult;
469
+
470
+ /**
471
+ * Subscription Action Utilities
472
+ * @classytic/revenue/utils/subscription
473
+ *
474
+ * Eligibility checks for subscription actions
475
+ */
476
+
477
+ /**
478
+ * Check if subscription is active
479
+ */
480
+ declare function isSubscriptionActive(subscription: Partial<SubscriptionDocument> | null | undefined): boolean;
481
+ /**
482
+ * Check if can renew
483
+ */
484
+ declare function canRenewSubscription(entity: SubscriptionEntity | null | undefined): boolean;
485
+ /**
486
+ * Check if can cancel
487
+ */
488
+ declare function canCancelSubscription(entity: SubscriptionEntity | null | undefined): boolean;
489
+ /**
490
+ * Check if can pause
491
+ */
492
+ declare function canPauseSubscription(entity: SubscriptionEntity | null | undefined): boolean;
493
+ /**
494
+ * Check if can resume
495
+ */
496
+ declare function canResumeSubscription(entity: SubscriptionEntity | null | undefined): boolean;
23
497
 
24
- export { triggerHook };
498
+ export { type DurationUnit, EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION, IdempotencyManager, MANUAL_TRANSACTION_CREATE_FIELDS, MANUAL_TRANSACTION_UPDATE_FIELDS, PROTECTED_MONETIZATION_FIELDS, TRANSACTION_MANAGEMENT_TYPE, type TransactionManagementType, addDuration, calculateCommission, calculateOrganizationPayout, calculatePeriodRange, calculateProratedAmount, calculateSplits, calculateTax, canCancelSubscription, canPauseSubscription, canRenewSubscription, canResumeSubscription, canSelfVerify, createIdempotencyManager, getAllowedUpdateFields, getTaxType, getTransactionType, isManualTransaction, isMonetizationTransaction, isSubscriptionActive, logger, logger as loggerDefault, resolveCategory, resolveIntervalToDuration, reverseCommission, reverseSplits, reverseTax, setLogger, validateFieldUpdate };