@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.
- package/README.md +582 -633
- package/dist/application/services/index.d.mts +4 -0
- package/dist/application/services/index.mjs +3 -0
- package/dist/base-CsTlVQJe.d.mts +136 -0
- package/dist/base-DCoyIUj6.mjs +152 -0
- package/dist/category-resolver-DV83N8ok.mjs +284 -0
- package/dist/commission-split-BzB8cd39.mjs +485 -0
- package/dist/core/events.d.mts +294 -0
- package/dist/core/events.mjs +100 -0
- package/dist/core/index.d.mts +9 -0
- package/dist/core/index.mjs +8 -0
- package/dist/enums/index.d.mts +157 -0
- package/dist/enums/index.mjs +56 -0
- package/dist/errors-CorrWz7A.d.mts +787 -0
- package/dist/escrow.enums-CZGrrdg7.mjs +101 -0
- package/dist/escrow.enums-DwdLuuve.d.mts +78 -0
- package/dist/idempotency-DaYcUGY1.mjs +172 -0
- package/dist/index-Dsp7H5Wb.d.mts +471 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.mjs +38 -0
- package/dist/infrastructure/plugins/index.d.mts +239 -0
- package/dist/infrastructure/plugins/index.mjs +345 -0
- package/dist/money-CvrDOijQ.mjs +271 -0
- package/dist/money-DPG8AtJ8.d.mts +112 -0
- package/dist/payment.enums-HAuAS9Pp.d.mts +70 -0
- package/dist/payment.enums-tEFVa-Xp.mjs +69 -0
- package/dist/plugin-BbK0OVHy.d.mts +327 -0
- package/dist/plugin-Cd_V04Em.mjs +210 -0
- package/dist/providers/index.d.mts +3 -0
- package/dist/providers/index.mjs +3 -0
- package/dist/reconciliation/index.d.mts +193 -0
- package/dist/reconciliation/index.mjs +192 -0
- package/dist/retry-HHCOXYdn.d.mts +186 -0
- package/dist/revenue-9scqKSef.mjs +553 -0
- package/dist/schemas/index.d.mts +2665 -0
- package/dist/schemas/index.mjs +717 -0
- package/dist/schemas/validation.d.mts +375 -0
- package/dist/schemas/validation.mjs +325 -0
- package/dist/settlement.enums-DFhkqZEY.d.mts +132 -0
- package/dist/settlement.schema-D5uWB5tP.d.mts +344 -0
- package/dist/settlement.service-BxuiHpNC.d.mts +594 -0
- package/dist/settlement.service-CUxbUTzT.mjs +2510 -0
- package/dist/split.enums-BrjabxIX.mjs +86 -0
- package/dist/split.enums-DmskfLOM.d.mts +43 -0
- package/dist/tax-BoCt5cEd.d.mts +61 -0
- package/dist/tax-EQ15DO81.mjs +162 -0
- package/dist/transaction.enums-pCyMFT4Z.mjs +96 -0
- package/dist/utils/index.d.mts +428 -0
- package/dist/utils/index.mjs +346 -0
- package/package.json +48 -33
- package/dist/actions-Ctf2XUL-.d.ts +0 -519
- package/dist/core/index.d.ts +0 -890
- package/dist/core/index.js +0 -3005
- package/dist/core/index.js.map +0 -1
- package/dist/enums/index.d.ts +0 -138
- package/dist/enums/index.js +0 -263
- package/dist/enums/index.js.map +0 -1
- package/dist/index-BnEXsnLJ.d.ts +0 -378
- package/dist/index-C5SsOrV0.d.ts +0 -534
- package/dist/index.d.ts +0 -43
- package/dist/index.js +0 -4498
- package/dist/index.js.map +0 -1
- package/dist/payment.enums-B_RwB8iR.d.ts +0 -184
- package/dist/providers/index.d.ts +0 -132
- package/dist/providers/index.js +0 -122
- package/dist/providers/index.js.map +0 -1
- package/dist/retry-80lBCmSe.d.ts +0 -234
- package/dist/schemas/index.d.ts +0 -1051
- package/dist/schemas/index.js +0 -627
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/validation.d.ts +0 -384
- package/dist/schemas/validation.js +0 -302
- package/dist/schemas/validation.js.map +0 -1
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.js +0 -1702
- package/dist/services/index.js.map +0 -1
- package/dist/split.schema-DLVF3XBI.d.ts +0 -1122
- package/dist/transaction.enums-7uBnuswI.d.ts +0 -87
- package/dist/utils/index.d.ts +0 -24
- package/dist/utils/index.js +0 -1140
- package/dist/utils/index.js.map +0 -1
package/dist/index-C5SsOrV0.d.ts
DELETED
|
@@ -1,534 +0,0 @@
|
|
|
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
|
-
/** Individual payment entry for split/multi-payment scenarios */
|
|
153
|
-
interface PaymentEntry {
|
|
154
|
-
/** Payment method (e.g., 'cash', 'bank_transfer', 'bkash') */
|
|
155
|
-
method: string;
|
|
156
|
-
/** Amount in smallest currency unit */
|
|
157
|
-
amount: number;
|
|
158
|
-
/** Reference/transaction ID for this payment */
|
|
159
|
-
reference?: string;
|
|
160
|
-
/** Method-specific details (walletNumber, bankName, trxId, etc.) */
|
|
161
|
-
details?: Record<string, unknown>;
|
|
162
|
-
}
|
|
163
|
-
/** Current payment with split payment support */
|
|
164
|
-
interface CurrentPayment {
|
|
165
|
-
/** Reference to the transaction */
|
|
166
|
-
transactionId?: ObjectId;
|
|
167
|
-
/** Total amount (sum of all payments for split payments) */
|
|
168
|
-
amount: number;
|
|
169
|
-
/** Payment status */
|
|
170
|
-
status: PaymentStatusValue;
|
|
171
|
-
/** Primary method for single payments, or 'split' when multiple methods */
|
|
172
|
-
method: string;
|
|
173
|
-
/** Reference/transaction ID for single payment */
|
|
174
|
-
reference?: string;
|
|
175
|
-
/** Array of individual payments for split payment scenarios */
|
|
176
|
-
payments?: PaymentEntry[];
|
|
177
|
-
/** Verification timestamp */
|
|
178
|
-
verifiedAt?: Date;
|
|
179
|
-
/** User who verified the payment */
|
|
180
|
-
verifiedBy?: ObjectId;
|
|
181
|
-
}
|
|
182
|
-
/** Monetization type values */
|
|
183
|
-
type MonetizationTypeValue = 'free' | 'purchase' | 'subscription';
|
|
184
|
-
/** Hold status values */
|
|
185
|
-
type HoldStatusValue = 'pending' | 'held' | 'released' | 'cancelled' | 'expired' | 'partially_released';
|
|
186
|
-
/** Hold reason values */
|
|
187
|
-
type HoldReasonValue = 'payment_verification' | 'fraud_check' | 'manual_review' | 'dispute' | 'compliance';
|
|
188
|
-
/** Release reason values */
|
|
189
|
-
type ReleaseReasonValue = 'payment_verified' | 'manual_release' | 'auto_release' | 'dispute_resolved';
|
|
190
|
-
/** Split type values */
|
|
191
|
-
type SplitTypeValue = 'platform_commission' | 'affiliate_commission' | 'referral_commission' | 'partner_commission' | 'custom';
|
|
192
|
-
/** Split status values */
|
|
193
|
-
type SplitStatusValue = 'pending' | 'due' | 'paid' | 'waived' | 'cancelled';
|
|
194
|
-
/** Payout method values */
|
|
195
|
-
type PayoutMethodValue = 'bank_transfer' | 'mobile_wallet' | 'platform_balance' | 'crypto' | 'check' | 'manual';
|
|
196
|
-
/** Split rule configuration */
|
|
197
|
-
interface SplitRule {
|
|
198
|
-
type?: SplitTypeValue;
|
|
199
|
-
recipientId: string;
|
|
200
|
-
recipientType: string;
|
|
201
|
-
rate: number;
|
|
202
|
-
dueDate?: Date | null;
|
|
203
|
-
metadata?: Record<string, unknown>;
|
|
204
|
-
}
|
|
205
|
-
/** Calculated split info */
|
|
206
|
-
interface SplitInfo {
|
|
207
|
-
type: SplitTypeValue;
|
|
208
|
-
recipientId: string;
|
|
209
|
-
recipientType: string;
|
|
210
|
-
rate: number;
|
|
211
|
-
grossAmount: number;
|
|
212
|
-
gatewayFeeRate: number;
|
|
213
|
-
gatewayFeeAmount: number;
|
|
214
|
-
netAmount: number;
|
|
215
|
-
status: SplitStatusValue;
|
|
216
|
-
dueDate?: Date | null;
|
|
217
|
-
paidDate?: Date;
|
|
218
|
-
payoutTransactionId?: string;
|
|
219
|
-
metadata: Record<string, unknown>;
|
|
220
|
-
}
|
|
221
|
-
/** Payment intent parameters */
|
|
222
|
-
interface CreateIntentParams {
|
|
223
|
-
amount: number;
|
|
224
|
-
currency?: string;
|
|
225
|
-
metadata?: Record<string, unknown>;
|
|
226
|
-
}
|
|
227
|
-
/** Payment intent data */
|
|
228
|
-
interface PaymentIntentData {
|
|
229
|
-
id: string;
|
|
230
|
-
sessionId?: string | null;
|
|
231
|
-
paymentIntentId?: string | null;
|
|
232
|
-
provider: string;
|
|
233
|
-
status: string;
|
|
234
|
-
amount: number;
|
|
235
|
-
currency?: string;
|
|
236
|
-
metadata?: Record<string, unknown>;
|
|
237
|
-
clientSecret?: string;
|
|
238
|
-
paymentUrl?: string;
|
|
239
|
-
instructions?: string;
|
|
240
|
-
raw?: unknown;
|
|
241
|
-
}
|
|
242
|
-
/** Payment result data */
|
|
243
|
-
interface PaymentResultData {
|
|
244
|
-
id: string;
|
|
245
|
-
provider: string;
|
|
246
|
-
status: 'succeeded' | 'failed' | 'processing';
|
|
247
|
-
amount?: number;
|
|
248
|
-
currency?: string;
|
|
249
|
-
paidAt?: Date;
|
|
250
|
-
metadata?: Record<string, unknown>;
|
|
251
|
-
raw?: unknown;
|
|
252
|
-
}
|
|
253
|
-
/** Refund result data */
|
|
254
|
-
interface RefundResultData {
|
|
255
|
-
id: string;
|
|
256
|
-
provider: string;
|
|
257
|
-
status: 'succeeded' | 'failed' | 'processing';
|
|
258
|
-
amount?: number;
|
|
259
|
-
currency?: string;
|
|
260
|
-
refundedAt?: Date;
|
|
261
|
-
reason?: string;
|
|
262
|
-
metadata?: Record<string, unknown>;
|
|
263
|
-
raw?: unknown;
|
|
264
|
-
}
|
|
265
|
-
/** Webhook event data */
|
|
266
|
-
interface WebhookEventData {
|
|
267
|
-
id: string;
|
|
268
|
-
provider: string;
|
|
269
|
-
type: string;
|
|
270
|
-
data: {
|
|
271
|
-
sessionId?: string;
|
|
272
|
-
paymentIntentId?: string;
|
|
273
|
-
[key: string]: unknown;
|
|
274
|
-
};
|
|
275
|
-
createdAt?: Date;
|
|
276
|
-
raw?: unknown;
|
|
277
|
-
}
|
|
278
|
-
/** Provider capabilities */
|
|
279
|
-
interface ProviderCapabilities {
|
|
280
|
-
supportsWebhooks: boolean;
|
|
281
|
-
supportsRefunds: boolean;
|
|
282
|
-
supportsPartialRefunds: boolean;
|
|
283
|
-
requiresManualVerification: boolean;
|
|
284
|
-
}
|
|
285
|
-
/** Models registry */
|
|
286
|
-
interface ModelsRegistry {
|
|
287
|
-
Transaction: MongooseModel<TransactionDocument>;
|
|
288
|
-
Subscription?: MongooseModel<SubscriptionDocument>;
|
|
289
|
-
}
|
|
290
|
-
/** Provider registry */
|
|
291
|
-
interface ProvidersRegistry {
|
|
292
|
-
[name: string]: PaymentProviderInterface;
|
|
293
|
-
}
|
|
294
|
-
/** Hook handlers registry */
|
|
295
|
-
interface HooksRegistry {
|
|
296
|
-
[event: string]: Array<(data: unknown) => void | Promise<void>>;
|
|
297
|
-
}
|
|
298
|
-
/** Logger interface */
|
|
299
|
-
interface Logger {
|
|
300
|
-
info(...args: unknown[]): void;
|
|
301
|
-
warn(...args: unknown[]): void;
|
|
302
|
-
error(...args: unknown[]): void;
|
|
303
|
-
debug(...args: unknown[]): void;
|
|
304
|
-
log?(...args: unknown[]): void;
|
|
305
|
-
}
|
|
306
|
-
/** Revenue configuration */
|
|
307
|
-
interface RevenueConfig {
|
|
308
|
-
targetModels: string[];
|
|
309
|
-
categoryMappings: Record<string, string>;
|
|
310
|
-
commissionRates?: Record<string, number>;
|
|
311
|
-
gatewayFeeRates?: Record<string, number>;
|
|
312
|
-
transactionTypeMapping?: Record<string, TransactionTypeValue>;
|
|
313
|
-
}
|
|
314
|
-
/** Create revenue options */
|
|
315
|
-
interface CreateRevenueOptions {
|
|
316
|
-
models: ModelsRegistry;
|
|
317
|
-
providers?: ProvidersRegistry;
|
|
318
|
-
hooks?: HooksRegistry;
|
|
319
|
-
config?: Partial<RevenueConfig>;
|
|
320
|
-
logger?: Logger;
|
|
321
|
-
}
|
|
322
|
-
/** Payment provider interface */
|
|
323
|
-
interface PaymentProviderInterface {
|
|
324
|
-
name: string;
|
|
325
|
-
config: Record<string, unknown>;
|
|
326
|
-
createIntent(params: CreateIntentParams): Promise<PaymentIntentData>;
|
|
327
|
-
verifyPayment(intentId: string): Promise<PaymentResultData>;
|
|
328
|
-
getStatus(intentId: string): Promise<PaymentResultData>;
|
|
329
|
-
refund(paymentId: string, amount?: number | null, options?: {
|
|
330
|
-
reason?: string;
|
|
331
|
-
}): Promise<RefundResultData>;
|
|
332
|
-
handleWebhook(payload: unknown, headers?: Record<string, string>): Promise<WebhookEventData>;
|
|
333
|
-
verifyWebhookSignature(payload: unknown, signature: string): boolean;
|
|
334
|
-
getCapabilities(): ProviderCapabilities;
|
|
335
|
-
}
|
|
336
|
-
/** Monetization create data */
|
|
337
|
-
interface MonetizationData {
|
|
338
|
-
organizationId?: string | ObjectId;
|
|
339
|
-
customerId?: string | ObjectId;
|
|
340
|
-
referenceId?: string | ObjectId;
|
|
341
|
-
referenceModel?: string;
|
|
342
|
-
}
|
|
343
|
-
/** Monetization create params */
|
|
344
|
-
interface MonetizationCreateParams {
|
|
345
|
-
data: MonetizationData;
|
|
346
|
-
planKey: string;
|
|
347
|
-
amount: number;
|
|
348
|
-
currency?: string;
|
|
349
|
-
gateway?: string;
|
|
350
|
-
entity?: string | null;
|
|
351
|
-
monetizationType?: MonetizationTypeValue;
|
|
352
|
-
paymentData?: Record<string, unknown>;
|
|
353
|
-
metadata?: Record<string, unknown>;
|
|
354
|
-
idempotencyKey?: string | null;
|
|
355
|
-
}
|
|
356
|
-
/** Monetization create result */
|
|
357
|
-
interface MonetizationCreateResult {
|
|
358
|
-
subscription: SubscriptionDocument | null;
|
|
359
|
-
transaction: TransactionDocument | null;
|
|
360
|
-
paymentIntent: PaymentIntentData | null;
|
|
361
|
-
}
|
|
362
|
-
/** Activation options */
|
|
363
|
-
interface ActivateOptions {
|
|
364
|
-
timestamp?: Date;
|
|
365
|
-
}
|
|
366
|
-
/** Renewal params */
|
|
367
|
-
interface RenewalParams {
|
|
368
|
-
gateway?: string;
|
|
369
|
-
entity?: string | null;
|
|
370
|
-
paymentData?: Record<string, unknown>;
|
|
371
|
-
metadata?: Record<string, unknown>;
|
|
372
|
-
idempotencyKey?: string | null;
|
|
373
|
-
}
|
|
374
|
-
/** Cancellation options */
|
|
375
|
-
interface CancelOptions {
|
|
376
|
-
immediate?: boolean;
|
|
377
|
-
reason?: string | null;
|
|
378
|
-
}
|
|
379
|
-
/** Pause options */
|
|
380
|
-
interface PauseOptions {
|
|
381
|
-
reason?: string | null;
|
|
382
|
-
}
|
|
383
|
-
/** Resume options */
|
|
384
|
-
interface ResumeOptions {
|
|
385
|
-
extendPeriod?: boolean;
|
|
386
|
-
}
|
|
387
|
-
/** List options */
|
|
388
|
-
interface ListOptions {
|
|
389
|
-
limit?: number;
|
|
390
|
-
skip?: number;
|
|
391
|
-
page?: number | null;
|
|
392
|
-
sort?: Record<string, 1 | -1>;
|
|
393
|
-
populate?: string[];
|
|
394
|
-
}
|
|
395
|
-
/** Payment verify options */
|
|
396
|
-
interface PaymentVerifyOptions {
|
|
397
|
-
verifiedBy?: string | null;
|
|
398
|
-
}
|
|
399
|
-
/** Payment verify result */
|
|
400
|
-
interface PaymentVerifyResult {
|
|
401
|
-
transaction: TransactionDocument;
|
|
402
|
-
paymentResult: PaymentResultData | null;
|
|
403
|
-
status: TransactionStatusValue;
|
|
404
|
-
}
|
|
405
|
-
/** Payment status result */
|
|
406
|
-
interface PaymentStatusResult {
|
|
407
|
-
transaction: TransactionDocument;
|
|
408
|
-
paymentResult?: PaymentResultData | null;
|
|
409
|
-
status: TransactionStatusValue | string;
|
|
410
|
-
provider?: string;
|
|
411
|
-
}
|
|
412
|
-
/** Refund options */
|
|
413
|
-
interface RefundOptions {
|
|
414
|
-
reason?: string | null;
|
|
415
|
-
}
|
|
416
|
-
/** Payment refund result */
|
|
417
|
-
interface PaymentRefundResult {
|
|
418
|
-
transaction: TransactionDocument;
|
|
419
|
-
refundTransaction: TransactionDocument;
|
|
420
|
-
refundResult: RefundResultData;
|
|
421
|
-
status: TransactionStatusValue;
|
|
422
|
-
}
|
|
423
|
-
/** Webhook result */
|
|
424
|
-
interface WebhookResult {
|
|
425
|
-
event: WebhookEventData;
|
|
426
|
-
transaction: TransactionDocument;
|
|
427
|
-
status: 'processed' | 'already_processed';
|
|
428
|
-
}
|
|
429
|
-
/** Transaction list result */
|
|
430
|
-
interface TransactionListResult {
|
|
431
|
-
transactions: TransactionDocument[];
|
|
432
|
-
total: number;
|
|
433
|
-
page: number;
|
|
434
|
-
limit: number;
|
|
435
|
-
pages: number;
|
|
436
|
-
}
|
|
437
|
-
/** Hold options */
|
|
438
|
-
interface HoldOptions {
|
|
439
|
-
reason?: HoldReasonValue;
|
|
440
|
-
holdUntil?: Date | null;
|
|
441
|
-
metadata?: Record<string, unknown>;
|
|
442
|
-
}
|
|
443
|
-
/** Release options */
|
|
444
|
-
interface ReleaseOptions {
|
|
445
|
-
amount?: number | null;
|
|
446
|
-
recipientId: string;
|
|
447
|
-
recipientType?: string;
|
|
448
|
-
reason?: ReleaseReasonValue;
|
|
449
|
-
releasedBy?: string | null;
|
|
450
|
-
createTransaction?: boolean;
|
|
451
|
-
metadata?: Record<string, unknown>;
|
|
452
|
-
}
|
|
453
|
-
/** Release result */
|
|
454
|
-
interface ReleaseResult {
|
|
455
|
-
transaction: TransactionDocument;
|
|
456
|
-
releaseTransaction: TransactionDocument | null;
|
|
457
|
-
releaseAmount: number;
|
|
458
|
-
isFullRelease: boolean;
|
|
459
|
-
isPartialRelease: boolean;
|
|
460
|
-
}
|
|
461
|
-
/** Cancel hold options */
|
|
462
|
-
interface CancelHoldOptions {
|
|
463
|
-
reason?: string;
|
|
464
|
-
metadata?: Record<string, unknown>;
|
|
465
|
-
}
|
|
466
|
-
/** Split result */
|
|
467
|
-
interface SplitResult {
|
|
468
|
-
transaction: TransactionDocument;
|
|
469
|
-
splits: SplitInfo[];
|
|
470
|
-
splitTransactions: TransactionDocument[];
|
|
471
|
-
organizationTransaction: TransactionDocument | null;
|
|
472
|
-
organizationPayout: number;
|
|
473
|
-
}
|
|
474
|
-
/** Escrow status result */
|
|
475
|
-
interface EscrowStatusResult {
|
|
476
|
-
transaction: TransactionDocument;
|
|
477
|
-
hold: HoldInfo | null;
|
|
478
|
-
splits: SplitInfo[];
|
|
479
|
-
hasHold: boolean;
|
|
480
|
-
hasSplits: boolean;
|
|
481
|
-
}
|
|
482
|
-
/** Period range params */
|
|
483
|
-
interface PeriodRangeParams {
|
|
484
|
-
currentEndDate?: Date | null;
|
|
485
|
-
startDate?: Date | null;
|
|
486
|
-
duration: number;
|
|
487
|
-
unit?: 'days' | 'weeks' | 'months' | 'years';
|
|
488
|
-
now?: Date;
|
|
489
|
-
}
|
|
490
|
-
/** Period range result */
|
|
491
|
-
interface PeriodRangeResult {
|
|
492
|
-
startDate: Date;
|
|
493
|
-
endDate: Date;
|
|
494
|
-
}
|
|
495
|
-
/** Prorated amount params */
|
|
496
|
-
interface ProratedAmountParams {
|
|
497
|
-
amountPaid: number;
|
|
498
|
-
startDate: Date;
|
|
499
|
-
endDate: Date;
|
|
500
|
-
asOfDate?: Date;
|
|
501
|
-
precision?: number;
|
|
502
|
-
}
|
|
503
|
-
/** Duration result */
|
|
504
|
-
interface DurationResult {
|
|
505
|
-
duration: number;
|
|
506
|
-
unit: 'days' | 'weeks' | 'months' | 'years';
|
|
507
|
-
}
|
|
508
|
-
/** Subscription entity for action checks */
|
|
509
|
-
interface SubscriptionEntity {
|
|
510
|
-
subscription?: {
|
|
511
|
-
isActive?: boolean;
|
|
512
|
-
endDate?: Date;
|
|
513
|
-
canceledAt?: Date;
|
|
514
|
-
};
|
|
515
|
-
status?: SubscriptionStatusValue;
|
|
516
|
-
}
|
|
517
|
-
/** Commission with splits options */
|
|
518
|
-
interface CommissionWithSplitsOptions {
|
|
519
|
-
affiliateRate?: number;
|
|
520
|
-
affiliateId?: string | null;
|
|
521
|
-
affiliateType?: string;
|
|
522
|
-
}
|
|
523
|
-
/** Transaction type detection options */
|
|
524
|
-
interface TransactionTypeOptions {
|
|
525
|
-
targetModels?: string[];
|
|
526
|
-
additionalCategories?: string[];
|
|
527
|
-
}
|
|
528
|
-
/** Field update validation result */
|
|
529
|
-
interface FieldUpdateValidationResult {
|
|
530
|
-
allowed: boolean;
|
|
531
|
-
reason?: string;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
export type { PaymentRefundResult as $, ProvidersRegistry as A, HooksRegistry as B, CommissionInfo as C, RevenueConfig as D, CreateRevenueOptions as E, MonetizationData as F, MonetizationCreateParams as G, HoldInfo as H, MonetizationCreateResult as I, ActivateOptions as J, RenewalParams as K, Logger as L, MongooseDoc as M, CancelOptions as N, ObjectId as O, PlanKeyValue as P, PauseOptions as Q, ReleaseRecord as R, SubscriptionStatusValue as S, TransactionStatusValue as T, ResumeOptions as U, ListOptions as V, WebhookInfo as W, PaymentVerifyOptions as X, PaymentVerifyResult as Y, PaymentStatusResult as Z, RefundOptions as _, MongooseModel as a, WebhookResult as a0, TransactionListResult as a1, HoldOptions as a2, ReleaseOptions as a3, ReleaseResult as a4, CancelHoldOptions as a5, SplitResult as a6, EscrowStatusResult as a7, PeriodRangeParams as a8, PeriodRangeResult as a9, ProratedAmountParams as aa, DurationResult as ab, SubscriptionEntity as ac, CommissionWithSplitsOptions as ad, TransactionTypeOptions as ae, FieldUpdateValidationResult as af, TransactionTypeValue as b, TransactionGateway as c, TransactionDocument as d, SubscriptionDocument as e, PaymentStatusValue as f, PaymentGatewayTypeValue as g, PaymentEntry as h, CurrentPayment as i, MonetizationTypeValue as j, HoldStatusValue as k, HoldReasonValue as l, ReleaseReasonValue as m, SplitTypeValue as n, SplitStatusValue as o, PayoutMethodValue as p, SplitRule as q, SplitInfo as r, CreateIntentParams as s, PaymentIntentData as t, PaymentResultData as u, RefundResultData as v, WebhookEventData as w, ProviderCapabilities as x, PaymentProviderInterface as y, ModelsRegistry as z };
|
package/dist/index.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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-BnEXsnLJ.js';
|
|
6
|
-
import { M as Money } from './actions-Ctf2XUL-.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-Ctf2XUL-.js';
|
|
8
|
-
export { CancelSubscriptionInput, CancelSubscriptionSchema, CommissionConfig, CommissionConfigSchema, CreateHoldInput, CreateHoldSchema, CreateMonetizationSchema, CreatePaymentInput, CreatePaymentSchema, CreateSubscriptionInput, CreateSubscriptionSchema, CurrencySchema, CurrentPaymentInput, CurrentPaymentInputSchema, EmailSchema, HoldStatus, HoldStatusSchema, IdempotencyKeySchema, Interval, IntervalSchema, MetadataSchema, MonetizationType, MonetizationTypeSchema, MoneyAmountSchema, MoneySchema, ObjectIdSchema, PaymentEntryInput, PaymentEntrySchema, PaymentStatusEnum, PaymentStatusEnumSchema, ProviderConfigSchema, RefundInput, RefundSchema, ReleaseHoldInput, ReleaseHoldSchema, RetryConfig, RetryConfigSchema, RevenueConfigInput, RevenueConfigSchema, SplitRecipient, SplitRecipientSchema, SubscriptionStatus, SubscriptionStatusSchema, VerifyPaymentInput, VerifyPaymentSchema, formatZodError, safeValidate, validate, validateSplitPayments } 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, f as GATEWAY_TYPE_VALUES, s as HOLD_REASON, u as HOLD_REASON_VALUES, H as HOLD_STATUS, p as HOLD_STATUS_VALUES, t as HoldReason, c as PAYMENT_GATEWAY_TYPE, e as PAYMENT_GATEWAY_TYPE_VALUES, P as PAYMENT_STATUS, b as PAYMENT_STATUS_VALUES, E as PAYOUT_METHOD, I as PAYOUT_METHOD_VALUES, k as PLAN_KEYS, m as PLAN_KEY_VALUES, d as PaymentGatewayType, a as PaymentStatus, F as PayoutMethod, l as PlanKeys, R as RELEASE_REASON, r as RELEASE_REASON_VALUES, q as ReleaseReason, B as SPLIT_STATUS, D as SPLIT_STATUS_VALUES, y as SPLIT_TYPE, A as SPLIT_TYPE_VALUES, S as SUBSCRIPTION_STATUS, j as SUBSCRIPTION_STATUS_VALUES, C as SplitStatus, z as SplitType, h as isGatewayType, x as isHoldReason, v as isHoldStatus, g as isPaymentGatewayType, i as isPaymentStatus, L as isPayoutMethod, o as isPlanKey, w as isReleaseReason, K as isSplitStatus, J as isSplitType, n as isSubscriptionStatus } from './payment.enums-B_RwB8iR.js';
|
|
12
|
-
export { L as LIBRARY_CATEGORIES, h as LIBRARY_CATEGORY_VALUES, f as LibraryCategories, g as LibraryCategoryValue, M as MONETIZATION_TYPES, m as MONETIZATION_TYPE_VALUES, l as MonetizationTypes, c as TRANSACTION_STATUS, e as TRANSACTION_STATUS_VALUES, T as TRANSACTION_TYPE, b as TRANSACTION_TYPE_VALUES, d as TransactionStatus, a as TransactionType, i as isLibraryCategory, n as isMonetizationType, k as isTransactionStatus, j as isTransactionType } from './transaction.enums-7uBnuswI.js';
|
|
13
|
-
export { b as baseMetadataSchema, e as commissionSchema, c as currentPaymentSchema, g as gatewaySchema, h as holdSchema, d as paymentDetailsSchema, p as paymentEntrySchema, a as paymentSummarySchema, f as planSchema, r as referenceSchema, i as splitSchema, s as subscriptionInfoSchema, t as tenantSnapshotSchema } from './split.schema-DLVF3XBI.js';
|
|
14
|
-
export { J as ActivateOptions, a5 as CancelHoldOptions, N as CancelOptions, C as CommissionInfo, ad as CommissionWithSplitsOptions, s as CreateIntentParams, E as CreateRevenueOptions, i as CurrentPayment, ab as DurationResult, a7 as EscrowStatusResult, af as FieldUpdateValidationResult, H as HoldInfo, a2 as HoldOptions, l as HoldReasonValue, k as HoldStatusValue, B as HooksRegistry, V as ListOptions, L as Logger, z as ModelsRegistry, G as MonetizationCreateParams, I as MonetizationCreateResult, F as MonetizationData, j as MonetizationTypeValue, M as MongooseDoc, a as MongooseModel, O as ObjectId, Q as PauseOptions, h as PaymentEntry, g as PaymentGatewayTypeValue, t as PaymentIntentData, y as PaymentProviderInterface, $ as PaymentRefundResult, u as PaymentResultData, Z as PaymentStatusResult, f as PaymentStatusValue, X as PaymentVerifyOptions, Y as PaymentVerifyResult, p as PayoutMethodValue, a8 as PeriodRangeParams, a9 as PeriodRangeResult, P as PlanKeyValue, aa as ProratedAmountParams, x as ProviderCapabilities, A as ProvidersRegistry, _ as RefundOptions, v as RefundResultData, a3 as ReleaseOptions, m as ReleaseReasonValue, R as ReleaseRecord, a4 as ReleaseResult, K as RenewalParams, U as ResumeOptions, D as RevenueConfig, r as SplitInfo, a6 as SplitResult, q as SplitRule, o as SplitStatusValue, n as SplitTypeValue, e as SubscriptionDocument, ac as SubscriptionEntity, S as SubscriptionStatusValue, d as TransactionDocument, c as TransactionGateway, a1 as TransactionListResult, T as TransactionStatusValue, ae as TransactionTypeOptions, b as TransactionTypeValue, w as WebhookEventData, W as WebhookInfo, a0 as WebhookResult } from './index-C5SsOrV0.js';
|
|
15
|
-
import 'zod';
|
|
16
|
-
import 'mongoose';
|
|
17
|
-
import 'bson';
|
|
18
|
-
|
|
19
|
-
declare const _default: {
|
|
20
|
-
Revenue: typeof Revenue;
|
|
21
|
-
createRevenue: typeof createRevenue;
|
|
22
|
-
PaymentProvider: typeof PaymentProvider;
|
|
23
|
-
RevenueError: typeof RevenueError;
|
|
24
|
-
Money: typeof Money;
|
|
25
|
-
Result: {
|
|
26
|
-
readonly ok: typeof ok;
|
|
27
|
-
readonly err: typeof err;
|
|
28
|
-
readonly isOk: typeof isOk;
|
|
29
|
-
readonly isErr: typeof isErr;
|
|
30
|
-
readonly unwrap: typeof unwrap;
|
|
31
|
-
readonly unwrapOr: typeof unwrapOr;
|
|
32
|
-
readonly map: typeof map;
|
|
33
|
-
readonly mapErr: typeof mapErr;
|
|
34
|
-
readonly flatMap: typeof flatMap;
|
|
35
|
-
readonly tryCatch: typeof tryCatch;
|
|
36
|
-
readonly tryCatchSync: typeof tryCatchSync;
|
|
37
|
-
readonly all: typeof all;
|
|
38
|
-
readonly match: typeof match;
|
|
39
|
-
};
|
|
40
|
-
EventBus: typeof EventBus;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { EventBus, Money, PaymentProvider, Revenue, RevenueError, all, createRevenue, _default as default, err, flatMap, isErr, isOk, map, mapErr, match, ok, tryCatch, tryCatchSync, unwrap, unwrapOr };
|