@classytic/revenue 1.1.2 → 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 (89) hide show
  1. package/README.md +8 -7
  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-CE0VQsfe.d.ts → escrow.enums-DwdLuuve.d.mts} +30 -28
  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.ts → index.d.mts} +81 -109
  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-C1BiGlRa.d.ts → payment.enums-HAuAS9Pp.d.mts} +14 -13
  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.ts → index.d.mts} +90 -112
  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-ByC1x0ye.d.ts → settlement.enums-DFhkqZEY.d.mts} +31 -29
  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.ts → index.d.mts} +91 -161
  49. package/dist/utils/index.mjs +346 -0
  50. package/package.json +38 -36
  51. package/dist/application/services/index.d.ts +0 -6
  52. package/dist/application/services/index.js +0 -3288
  53. package/dist/application/services/index.js.map +0 -1
  54. package/dist/core/events.d.ts +0 -455
  55. package/dist/core/events.js +0 -122
  56. package/dist/core/events.js.map +0 -1
  57. package/dist/core/index.d.ts +0 -13
  58. package/dist/core/index.js +0 -4591
  59. package/dist/core/index.js.map +0 -1
  60. package/dist/enums/index.d.ts +0 -159
  61. package/dist/enums/index.js +0 -296
  62. package/dist/enums/index.js.map +0 -1
  63. package/dist/index-DxIK0UmZ.d.ts +0 -633
  64. package/dist/index-EnfKzDbs.d.ts +0 -806
  65. package/dist/index-cLJBLUvx.d.ts +0 -478
  66. package/dist/index.d.ts +0 -43
  67. package/dist/index.js +0 -4864
  68. package/dist/index.js.map +0 -1
  69. package/dist/infrastructure/plugins/index.js +0 -292
  70. package/dist/infrastructure/plugins/index.js.map +0 -1
  71. package/dist/money-widWVD7r.d.ts +0 -111
  72. package/dist/plugin-Bb9HOE10.d.ts +0 -336
  73. package/dist/providers/index.d.ts +0 -145
  74. package/dist/providers/index.js +0 -141
  75. package/dist/providers/index.js.map +0 -1
  76. package/dist/reconciliation/index.js +0 -140
  77. package/dist/reconciliation/index.js.map +0 -1
  78. package/dist/retry-D4hFUwVk.d.ts +0 -194
  79. package/dist/schemas/index.d.ts +0 -2655
  80. package/dist/schemas/index.js +0 -841
  81. package/dist/schemas/index.js.map +0 -1
  82. package/dist/schemas/validation.d.ts +0 -384
  83. package/dist/schemas/validation.js +0 -303
  84. package/dist/schemas/validation.js.map +0 -1
  85. package/dist/settlement.schema-CpamV7ZY.d.ts +0 -343
  86. package/dist/split.enums-DG3TxQf9.d.ts +0 -42
  87. package/dist/tax-CV8A0sxl.d.ts +0 -60
  88. package/dist/utils/index.js +0 -1202
  89. package/dist/utils/index.js.map +0 -1
@@ -1,1202 +0,0 @@
1
- import { nanoid } from 'nanoid';
2
-
3
- // @classytic/revenue - Enterprise Revenue Management System
4
-
5
- // src/core/errors.ts
6
- var RevenueError = class extends Error {
7
- code;
8
- retryable;
9
- metadata;
10
- constructor(message, code, options = {}) {
11
- super(message);
12
- this.name = this.constructor.name;
13
- this.code = code;
14
- this.retryable = options.retryable ?? false;
15
- this.metadata = options.metadata ?? {};
16
- Error.captureStackTrace(this, this.constructor);
17
- }
18
- toJSON() {
19
- return {
20
- name: this.name,
21
- message: this.message,
22
- code: this.code,
23
- retryable: this.retryable,
24
- metadata: this.metadata
25
- };
26
- }
27
- };
28
- var ValidationError = class extends RevenueError {
29
- constructor(message, metadata = {}) {
30
- super(message, "VALIDATION_ERROR", { retryable: false, metadata });
31
- }
32
- };
33
-
34
- // src/shared/utils/calculators/commission.ts
35
- function calculateCommission(amount, commissionRate, gatewayFeeRate = 0) {
36
- if (!commissionRate || commissionRate <= 0) {
37
- return null;
38
- }
39
- if (amount < 0) {
40
- throw new Error("Transaction amount cannot be negative");
41
- }
42
- if (commissionRate < 0 || commissionRate > 1) {
43
- throw new Error("Commission rate must be between 0 and 1");
44
- }
45
- if (gatewayFeeRate < 0 || gatewayFeeRate > 1) {
46
- throw new Error("Gateway fee rate must be between 0 and 1");
47
- }
48
- const grossAmount = Math.round(amount * commissionRate);
49
- const gatewayFeeAmount = Math.round(amount * gatewayFeeRate);
50
- const netAmount = Math.max(0, grossAmount - gatewayFeeAmount);
51
- return {
52
- rate: commissionRate,
53
- grossAmount,
54
- gatewayFeeRate,
55
- gatewayFeeAmount,
56
- netAmount,
57
- status: "pending"
58
- };
59
- }
60
- function reverseCommission(originalCommission, originalAmount, refundAmount) {
61
- if (!originalCommission?.netAmount) {
62
- return null;
63
- }
64
- if (!originalAmount || originalAmount <= 0) {
65
- throw new ValidationError("Original amount must be greater than 0", { originalAmount });
66
- }
67
- if (refundAmount < 0) {
68
- throw new ValidationError("Refund amount cannot be negative", { refundAmount });
69
- }
70
- if (refundAmount > originalAmount) {
71
- throw new ValidationError(
72
- `Refund amount (${refundAmount}) exceeds original amount (${originalAmount})`,
73
- { refundAmount, originalAmount }
74
- );
75
- }
76
- const refundRatio = refundAmount / originalAmount;
77
- const reversedNetAmount = Math.round(originalCommission.netAmount * refundRatio);
78
- const reversedGrossAmount = Math.round(originalCommission.grossAmount * refundRatio);
79
- const reversedGatewayFee = Math.round(originalCommission.gatewayFeeAmount * refundRatio);
80
- return {
81
- rate: originalCommission.rate,
82
- grossAmount: reversedGrossAmount,
83
- gatewayFeeRate: originalCommission.gatewayFeeRate,
84
- gatewayFeeAmount: reversedGatewayFee,
85
- netAmount: reversedNetAmount,
86
- status: "waived"
87
- // Commission waived due to refund
88
- };
89
- }
90
-
91
- // src/shared/utils/calculators/tax.ts
92
- function calculateTax(amount, category, config) {
93
- if (!config?.isRegistered || config.exemptCategories?.includes(category)) {
94
- return {
95
- isApplicable: false,
96
- rate: 0,
97
- baseAmount: amount,
98
- taxAmount: 0,
99
- totalAmount: amount,
100
- pricesIncludeTax: false
101
- };
102
- }
103
- const rate = config.defaultRate;
104
- const [baseAmount, taxAmount, totalAmount] = config.pricesIncludeTax ? [
105
- // Tax-inclusive: extract tax from total
106
- Math.round(amount / (1 + rate)),
107
- // baseAmount
108
- Math.round(amount - amount / (1 + rate)),
109
- // taxAmount
110
- amount
111
- // totalAmount (already integer)
112
- ] : [
113
- // Tax-exclusive: add tax to base
114
- amount,
115
- // baseAmount (already integer)
116
- Math.round(amount * rate),
117
- // taxAmount
118
- Math.round(amount * (1 + rate))
119
- // totalAmount
120
- ];
121
- return {
122
- isApplicable: true,
123
- rate,
124
- baseAmount,
125
- taxAmount,
126
- totalAmount,
127
- pricesIncludeTax: config.pricesIncludeTax
128
- };
129
- }
130
- function getTaxType(transactionFlow, category, exemptCategories = []) {
131
- if (exemptCategories.includes(category)) {
132
- return "exempt";
133
- }
134
- return transactionFlow === "inflow" ? "collected" : "paid";
135
- }
136
- function reverseTax(originalTax, originalAmount, refundAmount) {
137
- if (!originalTax.isApplicable) {
138
- return {
139
- isApplicable: false,
140
- rate: 0,
141
- baseAmount: refundAmount,
142
- taxAmount: 0,
143
- totalAmount: refundAmount,
144
- pricesIncludeTax: false
145
- };
146
- }
147
- if (!originalAmount || originalAmount <= 0) {
148
- throw new ValidationError("Original amount must be greater than 0", { originalAmount });
149
- }
150
- if (refundAmount < 0) {
151
- throw new ValidationError("Refund amount cannot be negative", { refundAmount });
152
- }
153
- if (refundAmount > originalAmount) {
154
- throw new ValidationError(
155
- `Refund amount (${refundAmount}) exceeds original amount (${originalAmount})`,
156
- { refundAmount, originalAmount }
157
- );
158
- }
159
- const refundRatio = refundAmount / originalAmount;
160
- const reversedType = originalTax.type ? originalTax.type === "collected" ? "paid" : originalTax.type === "paid" ? "collected" : "exempt" : void 0;
161
- return {
162
- isApplicable: true,
163
- rate: originalTax.rate,
164
- baseAmount: Math.round(originalTax.baseAmount * refundRatio),
165
- taxAmount: Math.round(originalTax.taxAmount * refundRatio),
166
- totalAmount: Math.round(originalTax.totalAmount * refundRatio),
167
- pricesIncludeTax: originalTax.pricesIncludeTax,
168
- type: reversedType
169
- };
170
- }
171
-
172
- // src/enums/split.enums.ts
173
- var SPLIT_TYPE = {
174
- PLATFORM_COMMISSION: "platform_commission",
175
- AFFILIATE_COMMISSION: "affiliate_commission",
176
- REFERRAL_COMMISSION: "referral_commission",
177
- PARTNER_COMMISSION: "partner_commission",
178
- CUSTOM: "custom"
179
- };
180
- var SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);
181
- var SPLIT_STATUS = {
182
- PENDING: "pending",
183
- DUE: "due",
184
- PAID: "paid",
185
- WAIVED: "waived",
186
- CANCELLED: "cancelled"
187
- };
188
- var SPLIT_STATUS_VALUES = Object.values(
189
- SPLIT_STATUS
190
- );
191
- var PAYOUT_METHOD = {
192
- BANK_TRANSFER: "bank_transfer",
193
- MOBILE_WALLET: "mobile_wallet",
194
- PLATFORM_BALANCE: "platform_balance",
195
- CRYPTO: "crypto",
196
- CHECK: "check",
197
- MANUAL: "manual"
198
- };
199
- var PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);
200
- new Set(SPLIT_TYPE_VALUES);
201
- new Set(SPLIT_STATUS_VALUES);
202
- new Set(PAYOUT_METHOD_VALUES);
203
-
204
- // src/shared/utils/calculators/commission-split.ts
205
- function calculateSplits(amount, splitRules = [], gatewayFeeRate = 0) {
206
- if (!splitRules || splitRules.length === 0) {
207
- return [];
208
- }
209
- if (amount < 0) {
210
- throw new Error("Transaction amount cannot be negative");
211
- }
212
- if (gatewayFeeRate < 0 || gatewayFeeRate > 1) {
213
- throw new Error("Gateway fee rate must be between 0 and 1");
214
- }
215
- const totalRate = splitRules.reduce((sum, rule) => sum + rule.rate, 0);
216
- if (totalRate > 1) {
217
- throw new Error(`Total split rate (${totalRate}) cannot exceed 1.0`);
218
- }
219
- return splitRules.map((rule, index) => {
220
- if (rule.rate < 0 || rule.rate > 1) {
221
- throw new Error(`Split rate must be between 0 and 1 for split ${index}`);
222
- }
223
- const grossAmount = Math.round(amount * rule.rate);
224
- const gatewayFeeAmount = index === 0 && gatewayFeeRate > 0 ? Math.round(amount * gatewayFeeRate) : 0;
225
- const netAmount = Math.max(0, grossAmount - gatewayFeeAmount);
226
- return {
227
- type: rule.type ?? SPLIT_TYPE.CUSTOM,
228
- recipientId: rule.recipientId,
229
- recipientType: rule.recipientType,
230
- rate: rule.rate,
231
- grossAmount,
232
- gatewayFeeRate: gatewayFeeAmount > 0 ? gatewayFeeRate : 0,
233
- gatewayFeeAmount,
234
- netAmount,
235
- status: SPLIT_STATUS.PENDING,
236
- dueDate: rule.dueDate ?? null,
237
- metadata: rule.metadata ?? {}
238
- };
239
- });
240
- }
241
- function calculateOrganizationPayout(amount, splits = []) {
242
- const totalSplitAmount = splits.reduce((sum, split) => sum + split.grossAmount, 0);
243
- return Math.max(0, amount - totalSplitAmount);
244
- }
245
- function reverseSplits(originalSplits, originalAmount, refundAmount) {
246
- if (!originalSplits || originalSplits.length === 0) {
247
- return [];
248
- }
249
- if (!originalAmount || originalAmount <= 0) {
250
- throw new ValidationError("Original amount must be greater than 0", { originalAmount });
251
- }
252
- if (refundAmount < 0) {
253
- throw new ValidationError("Refund amount cannot be negative", { refundAmount });
254
- }
255
- if (refundAmount > originalAmount) {
256
- throw new ValidationError(
257
- `Refund amount (${refundAmount}) exceeds original amount (${originalAmount})`,
258
- { refundAmount, originalAmount }
259
- );
260
- }
261
- const refundRatio = refundAmount / originalAmount;
262
- return originalSplits.map((split) => ({
263
- ...split,
264
- grossAmount: Math.round(split.grossAmount * refundRatio),
265
- gatewayFeeAmount: Math.round(split.gatewayFeeAmount * refundRatio),
266
- netAmount: Math.round(split.netAmount * refundRatio),
267
- status: SPLIT_STATUS.WAIVED
268
- }));
269
- }
270
-
271
- // src/shared/utils/formatters/money.ts
272
- var CURRENCIES = {
273
- USD: { code: "USD", decimals: 2, symbol: "$", name: "US Dollar" },
274
- EUR: { code: "EUR", decimals: 2, symbol: "\u20AC", name: "Euro" },
275
- GBP: { code: "GBP", decimals: 2, symbol: "\xA3", name: "British Pound" },
276
- BDT: { code: "BDT", decimals: 2, symbol: "\u09F3", name: "Bangladeshi Taka" },
277
- INR: { code: "INR", decimals: 2, symbol: "\u20B9", name: "Indian Rupee" },
278
- JPY: { code: "JPY", decimals: 0, symbol: "\xA5", name: "Japanese Yen" },
279
- CNY: { code: "CNY", decimals: 2, symbol: "\xA5", name: "Chinese Yuan" },
280
- AED: { code: "AED", decimals: 2, symbol: "\u062F.\u0625", name: "UAE Dirham" },
281
- SAR: { code: "SAR", decimals: 2, symbol: "\uFDFC", name: "Saudi Riyal" },
282
- SGD: { code: "SGD", decimals: 2, symbol: "S$", name: "Singapore Dollar" },
283
- AUD: { code: "AUD", decimals: 2, symbol: "A$", name: "Australian Dollar" },
284
- CAD: { code: "CAD", decimals: 2, symbol: "C$", name: "Canadian Dollar" }
285
- };
286
- var Money = class _Money {
287
- amount;
288
- currency;
289
- constructor(amount, currency) {
290
- if (!Number.isInteger(amount)) {
291
- throw new Error(`Money amount must be integer (smallest unit). Got: ${amount}`);
292
- }
293
- this.amount = amount;
294
- this.currency = currency.toUpperCase();
295
- }
296
- // ============ FACTORY METHODS ============
297
- /**
298
- * Create money from smallest unit (cents, paisa)
299
- * @example Money.cents(1999, 'USD') // $19.99
300
- */
301
- static cents(amount, currency = "USD") {
302
- return new _Money(Math.round(amount), currency);
303
- }
304
- /**
305
- * Create money from major unit (dollars, taka)
306
- * @example Money.of(19.99, 'USD') // $19.99 (stored as 1999 cents)
307
- */
308
- static of(amount, currency = "USD") {
309
- const config = CURRENCIES[currency.toUpperCase()] ?? { decimals: 2 };
310
- const multiplier = Math.pow(10, config.decimals);
311
- return new _Money(Math.round(amount * multiplier), currency);
312
- }
313
- /**
314
- * Create zero money
315
- */
316
- static zero(currency = "USD") {
317
- return new _Money(0, currency);
318
- }
319
- // ============ SHORTHAND FACTORIES ============
320
- static usd(cents) {
321
- return _Money.cents(cents, "USD");
322
- }
323
- static eur(cents) {
324
- return _Money.cents(cents, "EUR");
325
- }
326
- static gbp(pence) {
327
- return _Money.cents(pence, "GBP");
328
- }
329
- static bdt(paisa) {
330
- return _Money.cents(paisa, "BDT");
331
- }
332
- static inr(paisa) {
333
- return _Money.cents(paisa, "INR");
334
- }
335
- static jpy(yen) {
336
- return _Money.cents(yen, "JPY");
337
- }
338
- // ============ ARITHMETIC ============
339
- /**
340
- * Add two money values (must be same currency)
341
- */
342
- add(other) {
343
- this.assertSameCurrency(other);
344
- return new _Money(this.amount + other.amount, this.currency);
345
- }
346
- /**
347
- * Subtract money (must be same currency)
348
- */
349
- subtract(other) {
350
- this.assertSameCurrency(other);
351
- return new _Money(this.amount - other.amount, this.currency);
352
- }
353
- /**
354
- * Multiply by a factor (rounds to nearest integer)
355
- */
356
- multiply(factor) {
357
- return new _Money(Math.round(this.amount * factor), this.currency);
358
- }
359
- /**
360
- * Divide by a divisor (rounds to nearest integer)
361
- */
362
- divide(divisor) {
363
- if (divisor === 0) throw new Error("Cannot divide by zero");
364
- return new _Money(Math.round(this.amount / divisor), this.currency);
365
- }
366
- /**
367
- * Calculate percentage
368
- * @example money.percentage(10) // 10% of money
369
- */
370
- percentage(percent) {
371
- return this.multiply(percent / 100);
372
- }
373
- /**
374
- * Allocate money among recipients (handles rounding)
375
- * @example Money.usd(100).allocate([1, 1, 1]) // [34, 33, 33] cents
376
- */
377
- allocate(ratios) {
378
- const total = ratios.reduce((a, b) => a + b, 0);
379
- if (total === 0) throw new Error("Ratios must sum to more than 0");
380
- let remainder = this.amount;
381
- const results = [];
382
- for (let i = 0; i < ratios.length; i++) {
383
- const share = Math.floor(this.amount * ratios[i] / total);
384
- results.push(new _Money(share, this.currency));
385
- remainder -= share;
386
- }
387
- for (let i = 0; i < remainder; i++) {
388
- results[i] = new _Money(results[i].amount + 1, this.currency);
389
- }
390
- return results;
391
- }
392
- /**
393
- * Split equally among n recipients
394
- */
395
- split(parts) {
396
- return this.allocate(Array(parts).fill(1));
397
- }
398
- // ============ COMPARISON ============
399
- isZero() {
400
- return this.amount === 0;
401
- }
402
- isPositive() {
403
- return this.amount > 0;
404
- }
405
- isNegative() {
406
- return this.amount < 0;
407
- }
408
- equals(other) {
409
- return this.amount === other.amount && this.currency === other.currency;
410
- }
411
- greaterThan(other) {
412
- this.assertSameCurrency(other);
413
- return this.amount > other.amount;
414
- }
415
- lessThan(other) {
416
- this.assertSameCurrency(other);
417
- return this.amount < other.amount;
418
- }
419
- greaterThanOrEqual(other) {
420
- return this.greaterThan(other) || this.equals(other);
421
- }
422
- lessThanOrEqual(other) {
423
- return this.lessThan(other) || this.equals(other);
424
- }
425
- // ============ FORMATTING ============
426
- /**
427
- * Get amount in major unit (dollars, taka)
428
- */
429
- toUnit() {
430
- const config = CURRENCIES[this.currency] ?? { decimals: 2 };
431
- return this.amount / Math.pow(10, config.decimals);
432
- }
433
- /**
434
- * Format for display
435
- * @example Money.usd(1999).format() // "$19.99"
436
- */
437
- format(locale = "en-US") {
438
- return new Intl.NumberFormat(locale, {
439
- style: "currency",
440
- currency: this.currency
441
- }).format(this.toUnit());
442
- }
443
- /**
444
- * Format without currency symbol
445
- */
446
- formatAmount(locale = "en-US") {
447
- const config = CURRENCIES[this.currency] ?? { decimals: 2 };
448
- return new Intl.NumberFormat(locale, {
449
- minimumFractionDigits: config.decimals,
450
- maximumFractionDigits: config.decimals
451
- }).format(this.toUnit());
452
- }
453
- /**
454
- * Convert to JSON-serializable object
455
- */
456
- toJSON() {
457
- return { amount: this.amount, currency: this.currency };
458
- }
459
- /**
460
- * Create from JSON
461
- */
462
- static fromJSON(json) {
463
- return new _Money(json.amount, json.currency);
464
- }
465
- toString() {
466
- return `${this.currency} ${this.amount}`;
467
- }
468
- // ============ HELPERS ============
469
- assertSameCurrency(other) {
470
- if (this.currency !== other.currency) {
471
- throw new Error(
472
- `Currency mismatch: ${this.currency} vs ${other.currency}. Convert first.`
473
- );
474
- }
475
- }
476
- };
477
- function toSmallestUnit(amount, currency = "USD") {
478
- return Money.of(amount, currency).amount;
479
- }
480
- function fromSmallestUnit(amount, currency = "USD") {
481
- return Money.cents(amount, currency).toUnit();
482
- }
483
-
484
- // src/core/result.ts
485
- function ok(value) {
486
- return { ok: true, value };
487
- }
488
- function err(error) {
489
- return { ok: false, error };
490
- }
491
-
492
- // src/shared/utils/resilience/retry.ts
493
- var DEFAULT_CONFIG = {
494
- maxAttempts: 3,
495
- baseDelay: 1e3,
496
- maxDelay: 3e4,
497
- backoffMultiplier: 2,
498
- jitter: 0.1,
499
- retryIf: isRetryableError
500
- };
501
- function calculateDelay(attempt, config) {
502
- const exponentialDelay = config.baseDelay * Math.pow(config.backoffMultiplier, attempt);
503
- const cappedDelay = Math.min(exponentialDelay, config.maxDelay);
504
- const jitterRange = cappedDelay * config.jitter;
505
- const jitter = Math.random() * jitterRange * 2 - jitterRange;
506
- return Math.round(Math.max(0, cappedDelay + jitter));
507
- }
508
- function sleep(ms) {
509
- return new Promise((resolve) => setTimeout(resolve, ms));
510
- }
511
- function isRetryableError(error) {
512
- if (!(error instanceof Error)) return false;
513
- if (error.message.includes("ECONNREFUSED")) return true;
514
- if (error.message.includes("ETIMEDOUT")) return true;
515
- if (error.message.includes("ENOTFOUND")) return true;
516
- if (error.message.includes("network")) return true;
517
- if (error.message.includes("timeout")) return true;
518
- if (error.message.includes("429")) return true;
519
- if (error.message.includes("rate limit")) return true;
520
- if (error.message.includes("500")) return true;
521
- if (error.message.includes("502")) return true;
522
- if (error.message.includes("503")) return true;
523
- if (error.message.includes("504")) return true;
524
- if ("retryable" in error && error.retryable === true) return true;
525
- return false;
526
- }
527
- async function retry(operation, config = {}) {
528
- const fullConfig = { ...DEFAULT_CONFIG, ...config };
529
- const state = {
530
- attempt: 0,
531
- totalDelay: 0,
532
- errors: []
533
- };
534
- while (state.attempt < fullConfig.maxAttempts) {
535
- try {
536
- return await operation();
537
- } catch (error) {
538
- state.errors.push(error instanceof Error ? error : new Error(String(error)));
539
- state.attempt++;
540
- const shouldRetry = fullConfig.retryIf?.(error) ?? isRetryableError(error);
541
- if (!shouldRetry || state.attempt >= fullConfig.maxAttempts) {
542
- throw new RetryExhaustedError(
543
- `Operation failed after ${state.attempt} attempts`,
544
- state.errors
545
- );
546
- }
547
- const delay = calculateDelay(state.attempt - 1, fullConfig);
548
- state.totalDelay += delay;
549
- fullConfig.onRetry?.(error, state.attempt, delay);
550
- await sleep(delay);
551
- }
552
- }
553
- throw new RetryExhaustedError(
554
- `Operation failed after ${state.attempt} attempts`,
555
- state.errors
556
- );
557
- }
558
- var RetryExhaustedError = class extends Error {
559
- attempts;
560
- errors;
561
- constructor(message, errors) {
562
- super(message);
563
- this.name = "RetryExhaustedError";
564
- this.attempts = errors.length;
565
- this.errors = errors;
566
- }
567
- /**
568
- * Get the last error
569
- */
570
- get lastError() {
571
- return this.errors[this.errors.length - 1];
572
- }
573
- /**
574
- * Get the first error
575
- */
576
- get firstError() {
577
- return this.errors[0];
578
- }
579
- };
580
- var DEFAULT_CIRCUIT_CONFIG = {
581
- failureThreshold: 5,
582
- resetTimeout: 3e4,
583
- successThreshold: 3,
584
- monitorWindow: 6e4
585
- };
586
- var CircuitBreaker = class {
587
- state = "closed";
588
- failures = [];
589
- successes = 0;
590
- lastFailure;
591
- config;
592
- constructor(config = {}) {
593
- this.config = { ...DEFAULT_CIRCUIT_CONFIG, ...config };
594
- }
595
- /**
596
- * Execute operation through circuit breaker
597
- */
598
- async execute(operation) {
599
- if (this.state === "open") {
600
- if (this.shouldAttemptReset()) {
601
- this.state = "half-open";
602
- } else {
603
- throw new CircuitOpenError("Circuit is open, request rejected");
604
- }
605
- }
606
- try {
607
- const result = await operation();
608
- this.onSuccess();
609
- return result;
610
- } catch (error) {
611
- this.onFailure();
612
- throw error;
613
- }
614
- }
615
- /**
616
- * Execute with Result type
617
- */
618
- async executeWithResult(operation) {
619
- try {
620
- const result = await this.execute(operation);
621
- return ok(result);
622
- } catch (error) {
623
- return err(error);
624
- }
625
- }
626
- onSuccess() {
627
- if (this.state === "half-open") {
628
- this.successes++;
629
- if (this.successes >= this.config.successThreshold) {
630
- this.reset();
631
- }
632
- }
633
- this.cleanOldFailures();
634
- }
635
- onFailure() {
636
- this.failures.push(/* @__PURE__ */ new Date());
637
- this.lastFailure = /* @__PURE__ */ new Date();
638
- this.successes = 0;
639
- this.cleanOldFailures();
640
- if (this.failures.length >= this.config.failureThreshold) {
641
- this.state = "open";
642
- }
643
- }
644
- shouldAttemptReset() {
645
- if (!this.lastFailure) return true;
646
- return Date.now() - this.lastFailure.getTime() >= this.config.resetTimeout;
647
- }
648
- cleanOldFailures() {
649
- const cutoff = Date.now() - this.config.monitorWindow;
650
- this.failures = this.failures.filter((f) => f.getTime() > cutoff);
651
- }
652
- reset() {
653
- this.state = "closed";
654
- this.failures = [];
655
- this.successes = 0;
656
- }
657
- /**
658
- * Get current circuit state
659
- */
660
- getState() {
661
- return this.state;
662
- }
663
- /**
664
- * Manually reset circuit
665
- */
666
- forceReset() {
667
- this.reset();
668
- }
669
- /**
670
- * Get circuit statistics
671
- */
672
- getStats() {
673
- return {
674
- state: this.state,
675
- failures: this.failures.length,
676
- successes: this.successes,
677
- lastFailure: this.lastFailure
678
- };
679
- }
680
- };
681
- var CircuitOpenError = class extends Error {
682
- constructor(message) {
683
- super(message);
684
- this.name = "CircuitOpenError";
685
- }
686
- };
687
- function createCircuitBreaker(config) {
688
- return new CircuitBreaker(config);
689
- }
690
- var MemoryIdempotencyStore = class {
691
- records = /* @__PURE__ */ new Map();
692
- cleanupInterval = null;
693
- constructor(cleanupIntervalMs = 6e4) {
694
- this.cleanupInterval = setInterval(() => {
695
- this.cleanup();
696
- }, cleanupIntervalMs);
697
- }
698
- async get(key) {
699
- const record = this.records.get(key);
700
- if (!record) return null;
701
- if (record.expiresAt < /* @__PURE__ */ new Date()) {
702
- this.records.delete(key);
703
- return null;
704
- }
705
- return record;
706
- }
707
- async set(key, record) {
708
- this.records.set(key, record);
709
- }
710
- async delete(key) {
711
- this.records.delete(key);
712
- }
713
- async exists(key) {
714
- const record = await this.get(key);
715
- return record !== null;
716
- }
717
- cleanup() {
718
- const now = /* @__PURE__ */ new Date();
719
- for (const [key, record] of this.records) {
720
- if (record.expiresAt < now) {
721
- this.records.delete(key);
722
- }
723
- }
724
- }
725
- destroy() {
726
- if (this.cleanupInterval) {
727
- clearInterval(this.cleanupInterval);
728
- this.cleanupInterval = null;
729
- }
730
- this.records.clear();
731
- }
732
- };
733
- var IdempotencyError = class extends Error {
734
- constructor(message, code) {
735
- super(message);
736
- this.code = code;
737
- this.name = "IdempotencyError";
738
- }
739
- };
740
- var IdempotencyManager = class {
741
- store;
742
- ttl;
743
- prefix;
744
- constructor(config = {}) {
745
- this.store = config.store ?? new MemoryIdempotencyStore();
746
- this.ttl = config.ttl ?? 24 * 60 * 60 * 1e3;
747
- this.prefix = config.prefix ?? "idem:";
748
- }
749
- /**
750
- * Generate a unique idempotency key
751
- */
752
- generateKey() {
753
- return `${this.prefix}${nanoid(21)}`;
754
- }
755
- /**
756
- * Hash request parameters for validation
757
- * Uses deterministic JSON serialization and simple hash function
758
- */
759
- hashRequest(params) {
760
- let normalized;
761
- if (params === null || params === void 0) {
762
- normalized = null;
763
- } else if (typeof params === "object" && !Array.isArray(params)) {
764
- const sortedKeys = Object.keys(params).sort();
765
- normalized = sortedKeys.reduce((acc, key) => {
766
- acc[key] = params[key];
767
- return acc;
768
- }, {});
769
- } else {
770
- normalized = params;
771
- }
772
- const json = JSON.stringify(normalized);
773
- let hash = 0;
774
- for (let i = 0; i < json.length; i++) {
775
- const char = json.charCodeAt(i);
776
- hash = (hash << 5) - hash + char;
777
- hash = hash & hash;
778
- }
779
- return Math.abs(hash).toString(36);
780
- }
781
- /**
782
- * Execute operation with idempotency protection
783
- */
784
- async execute(key, params, operation) {
785
- const fullKey = key.startsWith(this.prefix) ? key : `${this.prefix}${key}`;
786
- const requestHash = this.hashRequest(params);
787
- const existing = await this.store.get(fullKey);
788
- if (existing) {
789
- if (existing.requestHash !== requestHash) {
790
- return err(new IdempotencyError(
791
- "Idempotency key used with different request parameters",
792
- "REQUEST_MISMATCH"
793
- ));
794
- }
795
- if (existing.status === "completed" && existing.result !== void 0) {
796
- return ok(existing.result);
797
- }
798
- if (existing.status === "pending") {
799
- return err(new IdempotencyError(
800
- "Request with this idempotency key is already in progress",
801
- "REQUEST_IN_PROGRESS"
802
- ));
803
- }
804
- if (existing.status === "failed") {
805
- await this.store.delete(fullKey);
806
- }
807
- }
808
- const record = {
809
- key: fullKey,
810
- status: "pending",
811
- createdAt: /* @__PURE__ */ new Date(),
812
- requestHash,
813
- expiresAt: new Date(Date.now() + this.ttl)
814
- };
815
- await this.store.set(fullKey, record);
816
- try {
817
- const result = await operation();
818
- record.status = "completed";
819
- record.result = result;
820
- record.completedAt = /* @__PURE__ */ new Date();
821
- await this.store.set(fullKey, record);
822
- return ok(result);
823
- } catch (error) {
824
- record.status = "failed";
825
- await this.store.set(fullKey, record);
826
- throw error;
827
- }
828
- }
829
- /**
830
- * Check if operation with key was already completed
831
- */
832
- async wasCompleted(key) {
833
- const fullKey = key.startsWith(this.prefix) ? key : `${this.prefix}${key}`;
834
- const record = await this.store.get(fullKey);
835
- return record?.status === "completed";
836
- }
837
- /**
838
- * Get cached result for key
839
- */
840
- async getCached(key) {
841
- const fullKey = key.startsWith(this.prefix) ? key : `${this.prefix}${key}`;
842
- const record = await this.store.get(fullKey);
843
- return record?.status === "completed" ? record.result ?? null : null;
844
- }
845
- /**
846
- * Invalidate a key (force re-execution on next call)
847
- */
848
- async invalidate(key) {
849
- const fullKey = key.startsWith(this.prefix) ? key : `${this.prefix}${key}`;
850
- await this.store.delete(fullKey);
851
- }
852
- /**
853
- * Destroy the idempotency manager and cleanup resources
854
- * Call this when shutting down to prevent memory leaks
855
- */
856
- destroy() {
857
- if (this.store instanceof MemoryIdempotencyStore) {
858
- this.store.destroy();
859
- }
860
- }
861
- };
862
- function createIdempotencyManager(config) {
863
- return new IdempotencyManager(config);
864
- }
865
-
866
- // src/enums/transaction.enums.ts
867
- var TRANSACTION_FLOW = {
868
- INFLOW: "inflow",
869
- OUTFLOW: "outflow"
870
- };
871
- var TRANSACTION_FLOW_VALUES = Object.values(
872
- TRANSACTION_FLOW
873
- );
874
- var TRANSACTION_STATUS = {
875
- PENDING: "pending",
876
- PAYMENT_INITIATED: "payment_initiated",
877
- PROCESSING: "processing",
878
- REQUIRES_ACTION: "requires_action",
879
- VERIFIED: "verified",
880
- COMPLETED: "completed",
881
- FAILED: "failed",
882
- CANCELLED: "cancelled",
883
- EXPIRED: "expired",
884
- REFUNDED: "refunded",
885
- PARTIALLY_REFUNDED: "partially_refunded"
886
- };
887
- var TRANSACTION_STATUS_VALUES = Object.values(
888
- TRANSACTION_STATUS
889
- );
890
- var LIBRARY_CATEGORIES = {
891
- SUBSCRIPTION: "subscription",
892
- PURCHASE: "purchase"
893
- };
894
- var LIBRARY_CATEGORY_VALUES = Object.values(
895
- LIBRARY_CATEGORIES
896
- );
897
- new Set(TRANSACTION_FLOW_VALUES);
898
- new Set(
899
- TRANSACTION_STATUS_VALUES
900
- );
901
- new Set(LIBRARY_CATEGORY_VALUES);
902
-
903
- // src/shared/utils/validators/category-resolver.ts
904
- function resolveCategory(entity, monetizationType, categoryMappings = {}) {
905
- if (entity && categoryMappings[entity]) {
906
- return categoryMappings[entity];
907
- }
908
- switch (monetizationType) {
909
- case "subscription":
910
- return LIBRARY_CATEGORIES.SUBSCRIPTION;
911
- // 'subscription'
912
- case "purchase":
913
- return LIBRARY_CATEGORIES.PURCHASE;
914
- // 'purchase'
915
- default:
916
- return LIBRARY_CATEGORIES.SUBSCRIPTION;
917
- }
918
- }
919
-
920
- // src/utils/transaction-type.ts
921
- var TRANSACTION_MANAGEMENT_TYPE = {
922
- MONETIZATION: "monetization",
923
- // Library-managed (subscriptions, purchases)
924
- MANUAL: "manual"
925
- // Admin-managed (expenses, income, adjustments)
926
- };
927
- var DEFAULT_MONETIZATION_CATEGORIES = [
928
- "subscription",
929
- "purchase"
930
- ];
931
- function isMonetizationCategory(category, additionalCategories = []) {
932
- const allCategories = [...DEFAULT_MONETIZATION_CATEGORIES, ...additionalCategories];
933
- return allCategories.includes(category);
934
- }
935
- function isMonetizationTransaction(transaction, options = {}) {
936
- const {
937
- targetModels = ["Subscription", "Membership"],
938
- additionalCategories = []
939
- } = options;
940
- if (transaction.sourceModel && targetModels.includes(transaction.sourceModel)) {
941
- return true;
942
- }
943
- if (transaction.category) {
944
- return isMonetizationCategory(transaction.category, additionalCategories);
945
- }
946
- return false;
947
- }
948
- function isManualTransaction(transaction, options = {}) {
949
- return !isMonetizationTransaction(transaction, options);
950
- }
951
- function getTransactionType(transaction, options = {}) {
952
- return isMonetizationTransaction(transaction, options) ? TRANSACTION_MANAGEMENT_TYPE.MONETIZATION : TRANSACTION_MANAGEMENT_TYPE.MANUAL;
953
- }
954
- var PROTECTED_MONETIZATION_FIELDS = [
955
- "status",
956
- "amount",
957
- "platformCommission",
958
- "netAmount",
959
- "verifiedAt",
960
- "verifiedBy",
961
- "gateway",
962
- "webhook",
963
- "metadata.commission",
964
- "metadata.gateway",
965
- "type",
966
- "category",
967
- "sourceModel",
968
- "sourceId"
969
- ];
970
- var EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION = [
971
- "reference",
972
- "paymentDetails",
973
- "notes"
974
- ];
975
- var MANUAL_TRANSACTION_CREATE_FIELDS = [
976
- "organizationId",
977
- "type",
978
- "category",
979
- "amount",
980
- "method",
981
- "reference",
982
- "paymentDetails",
983
- "notes",
984
- "date",
985
- // Transaction date (can be backdated)
986
- "description"
987
- ];
988
- var MANUAL_TRANSACTION_UPDATE_FIELDS = [
989
- "amount",
990
- "method",
991
- "reference",
992
- "paymentDetails",
993
- "notes",
994
- "date",
995
- "description"
996
- ];
997
- function getAllowedUpdateFields(transaction, options = {}) {
998
- const type = getTransactionType(transaction, options);
999
- if (type === TRANSACTION_MANAGEMENT_TYPE.MONETIZATION) {
1000
- if (transaction.status === "pending") {
1001
- return EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION;
1002
- }
1003
- return [];
1004
- }
1005
- if (transaction.status === "verified" || transaction.status === "completed") {
1006
- return ["notes"];
1007
- }
1008
- return MANUAL_TRANSACTION_UPDATE_FIELDS;
1009
- }
1010
- function validateFieldUpdate(transaction, fieldName, options = {}) {
1011
- const allowedFields = getAllowedUpdateFields(transaction, options);
1012
- if (allowedFields.includes(fieldName)) {
1013
- return { allowed: true };
1014
- }
1015
- const type = getTransactionType(transaction, options);
1016
- if (type === TRANSACTION_MANAGEMENT_TYPE.MONETIZATION) {
1017
- if (PROTECTED_MONETIZATION_FIELDS.includes(fieldName)) {
1018
- return {
1019
- allowed: false,
1020
- reason: `Field "${fieldName}" is protected for monetization transactions. Updates must go through payment flow.`
1021
- };
1022
- }
1023
- }
1024
- return {
1025
- allowed: false,
1026
- reason: `Field "${fieldName}" cannot be updated for ${transaction.status} transactions.`
1027
- };
1028
- }
1029
- function canSelfVerify(transaction, options = {}) {
1030
- const type = getTransactionType(transaction, options);
1031
- if (type === TRANSACTION_MANAGEMENT_TYPE.MANUAL) {
1032
- return transaction.status === "pending";
1033
- }
1034
- return false;
1035
- }
1036
-
1037
- // src/utils/logger.ts
1038
- var _logger = console;
1039
- function setLogger(customLogger) {
1040
- _logger = customLogger;
1041
- }
1042
- var logger = {
1043
- info: (...args) => {
1044
- (_logger.info ?? _logger.log)?.call(_logger, ...args);
1045
- },
1046
- warn: (...args) => {
1047
- (_logger.warn ?? _logger.log)?.call(_logger, "WARN:", ...args);
1048
- },
1049
- error: (...args) => {
1050
- (_logger.error ?? _logger.log)?.call(_logger, "ERROR:", ...args);
1051
- },
1052
- debug: (...args) => {
1053
- (_logger.debug ?? _logger.log)?.call(_logger, "DEBUG:", ...args);
1054
- }
1055
- };
1056
- var logger_default = logger;
1057
-
1058
- // src/utils/subscription/period.ts
1059
- function addDuration(startDate, duration, unit = "days") {
1060
- const date = new Date(startDate);
1061
- switch (unit) {
1062
- case "months":
1063
- case "month":
1064
- date.setMonth(date.getMonth() + duration);
1065
- return date;
1066
- case "years":
1067
- case "year":
1068
- date.setFullYear(date.getFullYear() + duration);
1069
- return date;
1070
- case "weeks":
1071
- case "week":
1072
- date.setDate(date.getDate() + duration * 7);
1073
- return date;
1074
- case "days":
1075
- case "day":
1076
- default:
1077
- date.setDate(date.getDate() + duration);
1078
- return date;
1079
- }
1080
- }
1081
- function calculatePeriodRange(params) {
1082
- const {
1083
- currentEndDate = null,
1084
- startDate = null,
1085
- duration,
1086
- unit = "days",
1087
- now = /* @__PURE__ */ new Date()
1088
- } = params;
1089
- let periodStart;
1090
- if (startDate) {
1091
- periodStart = new Date(startDate);
1092
- } else if (currentEndDate) {
1093
- const end = new Date(currentEndDate);
1094
- periodStart = end > now ? end : now;
1095
- } else {
1096
- periodStart = now;
1097
- }
1098
- const periodEnd = addDuration(periodStart, duration, unit);
1099
- return { startDate: periodStart, endDate: periodEnd };
1100
- }
1101
- function calculateProratedAmount(params) {
1102
- const {
1103
- amountPaid,
1104
- startDate,
1105
- endDate,
1106
- asOfDate = /* @__PURE__ */ new Date(),
1107
- precision = 2
1108
- } = params;
1109
- if (!amountPaid || amountPaid <= 0) return 0;
1110
- const start = new Date(startDate);
1111
- const end = new Date(endDate);
1112
- const asOf = new Date(asOfDate);
1113
- const totalMs = end.getTime() - start.getTime();
1114
- if (totalMs <= 0) return 0;
1115
- const remainingMs = Math.max(0, end.getTime() - asOf.getTime());
1116
- if (remainingMs <= 0) return 0;
1117
- const ratio = remainingMs / totalMs;
1118
- const amount = amountPaid * ratio;
1119
- const factor = 10 ** precision;
1120
- return Math.round(amount * factor) / factor;
1121
- }
1122
- function resolveIntervalToDuration(interval = "month", intervalCount = 1) {
1123
- const normalized = (interval || "month").toLowerCase();
1124
- const count = Number(intervalCount) > 0 ? Number(intervalCount) : 1;
1125
- switch (normalized) {
1126
- case "year":
1127
- case "years":
1128
- return { duration: count, unit: "years" };
1129
- case "week":
1130
- case "weeks":
1131
- return { duration: count, unit: "weeks" };
1132
- case "quarter":
1133
- case "quarters":
1134
- return { duration: count * 3, unit: "months" };
1135
- case "day":
1136
- case "days":
1137
- return { duration: count, unit: "days" };
1138
- case "month":
1139
- case "months":
1140
- default:
1141
- return { duration: count, unit: "months" };
1142
- }
1143
- }
1144
-
1145
- // src/enums/subscription.enums.ts
1146
- var SUBSCRIPTION_STATUS = {
1147
- ACTIVE: "active",
1148
- PAUSED: "paused",
1149
- CANCELLED: "cancelled",
1150
- EXPIRED: "expired",
1151
- PENDING: "pending",
1152
- PENDING_RENEWAL: "pending_renewal",
1153
- INACTIVE: "inactive"
1154
- };
1155
- var SUBSCRIPTION_STATUS_VALUES = Object.values(
1156
- SUBSCRIPTION_STATUS
1157
- );
1158
- var PLAN_KEYS = {
1159
- MONTHLY: "monthly",
1160
- QUARTERLY: "quarterly",
1161
- YEARLY: "yearly"
1162
- };
1163
- var PLAN_KEY_VALUES = Object.values(PLAN_KEYS);
1164
- new Set(
1165
- SUBSCRIPTION_STATUS_VALUES
1166
- );
1167
- new Set(PLAN_KEY_VALUES);
1168
-
1169
- // src/utils/subscription/actions.ts
1170
- function isSubscriptionActive(subscription) {
1171
- if (!subscription) return false;
1172
- if (!subscription.isActive) return false;
1173
- if (subscription.endDate) {
1174
- const now = /* @__PURE__ */ new Date();
1175
- const endDate = new Date(subscription.endDate);
1176
- if (endDate < now) return false;
1177
- }
1178
- return true;
1179
- }
1180
- function canRenewSubscription(entity) {
1181
- if (!entity?.subscription) return false;
1182
- return isSubscriptionActive(entity.subscription);
1183
- }
1184
- function canCancelSubscription(entity) {
1185
- if (!entity?.subscription) return false;
1186
- if (!isSubscriptionActive(entity.subscription)) return false;
1187
- return !entity.subscription.canceledAt;
1188
- }
1189
- function canPauseSubscription(entity) {
1190
- if (!entity?.subscription) return false;
1191
- if (entity.status === SUBSCRIPTION_STATUS.PAUSED) return false;
1192
- if (entity.status === SUBSCRIPTION_STATUS.CANCELLED) return false;
1193
- return isSubscriptionActive(entity.subscription);
1194
- }
1195
- function canResumeSubscription(entity) {
1196
- if (!entity?.subscription) return false;
1197
- return entity.status === SUBSCRIPTION_STATUS.PAUSED;
1198
- }
1199
-
1200
- export { CircuitBreaker, EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION, IdempotencyManager, MANUAL_TRANSACTION_CREATE_FIELDS, MANUAL_TRANSACTION_UPDATE_FIELDS, Money, PROTECTED_MONETIZATION_FIELDS, TRANSACTION_MANAGEMENT_TYPE, addDuration, calculateCommission, calculateOrganizationPayout, calculatePeriodRange, calculateProratedAmount, calculateSplits, calculateTax, canCancelSubscription, canPauseSubscription, canRenewSubscription, canResumeSubscription, canSelfVerify, createCircuitBreaker, createIdempotencyManager, fromSmallestUnit, getAllowedUpdateFields, getTaxType, getTransactionType, isManualTransaction, isMonetizationTransaction, isSubscriptionActive, logger, logger_default as loggerDefault, resolveCategory, resolveIntervalToDuration, retry, reverseCommission, reverseSplits, reverseTax, setLogger, toSmallestUnit, validateFieldUpdate };
1201
- //# sourceMappingURL=index.js.map
1202
- //# sourceMappingURL=index.js.map