@classytic/revenue 0.2.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +498 -499
- package/dist/actions-CwG-b7fR.d.ts +519 -0
- package/dist/core/index.d.ts +884 -0
- package/dist/core/index.js +2941 -0
- package/dist/core/index.js.map +1 -0
- package/dist/enums/index.d.ts +130 -0
- package/dist/enums/index.js +167 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/index-BnJWVXuw.d.ts +378 -0
- package/dist/index-ChVD3P9k.d.ts +504 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +4353 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/index.d.ts +132 -0
- package/dist/providers/index.js +122 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/retry-80lBCmSe.d.ts +234 -0
- package/dist/schemas/index.d.ts +894 -0
- package/dist/schemas/index.js +524 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/validation.d.ts +309 -0
- package/dist/schemas/validation.js +249 -0
- package/dist/schemas/validation.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +1632 -0
- package/dist/services/index.js.map +1 -0
- package/dist/split.enums-DHdM1YAV.d.ts +255 -0
- package/dist/split.schema-BPdFZMbU.d.ts +958 -0
- package/dist/utils/index.d.ts +24 -0
- package/dist/utils/index.js +1067 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +48 -32
- package/core/builder.js +0 -219
- package/core/container.js +0 -119
- package/core/errors.js +0 -262
- package/dist/types/core/builder.d.ts +0 -97
- package/dist/types/core/container.d.ts +0 -57
- package/dist/types/core/errors.d.ts +0 -122
- package/dist/types/enums/escrow.enums.d.ts +0 -24
- package/dist/types/enums/index.d.ts +0 -69
- package/dist/types/enums/monetization.enums.d.ts +0 -6
- package/dist/types/enums/payment.enums.d.ts +0 -16
- package/dist/types/enums/split.enums.d.ts +0 -25
- package/dist/types/enums/subscription.enums.d.ts +0 -15
- package/dist/types/enums/transaction.enums.d.ts +0 -24
- package/dist/types/index.d.ts +0 -22
- package/dist/types/providers/base.d.ts +0 -126
- package/dist/types/schemas/escrow/hold.schema.d.ts +0 -54
- package/dist/types/schemas/escrow/index.d.ts +0 -6
- package/dist/types/schemas/index.d.ts +0 -506
- package/dist/types/schemas/split/index.d.ts +0 -8
- package/dist/types/schemas/split/split.schema.d.ts +0 -142
- package/dist/types/schemas/subscription/index.d.ts +0 -152
- package/dist/types/schemas/subscription/info.schema.d.ts +0 -128
- package/dist/types/schemas/subscription/plan.schema.d.ts +0 -39
- package/dist/types/schemas/transaction/common.schema.d.ts +0 -12
- package/dist/types/schemas/transaction/gateway.schema.d.ts +0 -86
- package/dist/types/schemas/transaction/index.d.ts +0 -202
- package/dist/types/schemas/transaction/payment.schema.d.ts +0 -145
- package/dist/types/services/escrow.service.d.ts +0 -51
- package/dist/types/services/monetization.service.d.ts +0 -193
- package/dist/types/services/payment.service.d.ts +0 -112
- package/dist/types/services/transaction.service.d.ts +0 -40
- package/dist/types/utils/category-resolver.d.ts +0 -46
- package/dist/types/utils/commission-split.d.ts +0 -56
- package/dist/types/utils/commission.d.ts +0 -29
- package/dist/types/utils/hooks.d.ts +0 -17
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/logger.d.ts +0 -12
- package/dist/types/utils/subscription/actions.d.ts +0 -28
- package/dist/types/utils/subscription/index.d.ts +0 -2
- package/dist/types/utils/subscription/period.d.ts +0 -47
- package/dist/types/utils/transaction-type.d.ts +0 -102
- package/enums/escrow.enums.js +0 -36
- package/enums/index.d.ts +0 -116
- package/enums/index.js +0 -110
- package/enums/monetization.enums.js +0 -15
- package/enums/payment.enums.js +0 -64
- package/enums/split.enums.js +0 -37
- package/enums/subscription.enums.js +0 -33
- package/enums/transaction.enums.js +0 -69
- package/index.js +0 -76
- package/providers/base.js +0 -162
- package/schemas/escrow/hold.schema.js +0 -62
- package/schemas/escrow/index.js +0 -15
- package/schemas/index.d.ts +0 -33
- package/schemas/index.js +0 -27
- package/schemas/split/index.js +0 -16
- package/schemas/split/split.schema.js +0 -86
- package/schemas/subscription/index.js +0 -17
- package/schemas/subscription/info.schema.js +0 -115
- package/schemas/subscription/plan.schema.js +0 -48
- package/schemas/transaction/common.schema.js +0 -22
- package/schemas/transaction/gateway.schema.js +0 -69
- package/schemas/transaction/index.js +0 -20
- package/schemas/transaction/payment.schema.js +0 -110
- package/services/escrow.service.js +0 -353
- package/services/monetization.service.js +0 -671
- package/services/payment.service.js +0 -517
- package/services/transaction.service.js +0 -142
- package/utils/category-resolver.js +0 -74
- package/utils/commission-split.js +0 -180
- package/utils/commission.js +0 -83
- package/utils/hooks.js +0 -44
- package/utils/index.d.ts +0 -164
- package/utils/index.js +0 -16
- package/utils/logger.js +0 -36
- package/utils/subscription/actions.js +0 -68
- package/utils/subscription/index.js +0 -20
- package/utils/subscription/period.js +0 -123
- package/utils/transaction-type.js +0 -254
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from "./transaction-type.js";
|
|
2
|
-
export * from "./subscription/index.js";
|
|
3
|
-
export { triggerHook } from "./hooks.js";
|
|
4
|
-
export { default as logger, setLogger } from "./logger.js";
|
|
5
|
-
export { calculateCommission, reverseCommission } from "./commission.js";
|
|
6
|
-
export { calculateSplits, calculateOrganizationPayout, reverseSplits, calculateCommissionWithSplits } from "./commission-split.js";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set custom logger implementation
|
|
3
|
-
* @param {Object} customLogger - Logger instance with info, warn, error, debug methods
|
|
4
|
-
*/
|
|
5
|
-
export function setLogger(customLogger: any): void;
|
|
6
|
-
export namespace logger {
|
|
7
|
-
function info(...args: any[]): void;
|
|
8
|
-
function warn(...args: any[]): void;
|
|
9
|
-
function error(...args: any[]): void;
|
|
10
|
-
function debug(...args: any[]): void;
|
|
11
|
-
}
|
|
12
|
-
export default logger;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if subscription is active
|
|
3
|
-
*/
|
|
4
|
-
export function isSubscriptionActive(subscription: any): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Check if can renew
|
|
7
|
-
*/
|
|
8
|
-
export function canRenewSubscription(entity: any): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Check if can cancel
|
|
11
|
-
*/
|
|
12
|
-
export function canCancelSubscription(entity: any): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Check if can pause
|
|
15
|
-
*/
|
|
16
|
-
export function canPauseSubscription(entity: any): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Check if can resume
|
|
19
|
-
*/
|
|
20
|
-
export function canResumeSubscription(entity: any): boolean;
|
|
21
|
-
declare namespace _default {
|
|
22
|
-
export { isSubscriptionActive };
|
|
23
|
-
export { canRenewSubscription };
|
|
24
|
-
export { canCancelSubscription };
|
|
25
|
-
export { canPauseSubscription };
|
|
26
|
-
export { canResumeSubscription };
|
|
27
|
-
}
|
|
28
|
-
export default _default;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscription Period Utilities
|
|
3
|
-
* @classytic/revenue/utils/subscription
|
|
4
|
-
*
|
|
5
|
-
* Universal period calculation, proration, and date utilities
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Add duration to date
|
|
9
|
-
*/
|
|
10
|
-
export function addDuration(startDate: any, duration: any, unit?: string): Date;
|
|
11
|
-
/**
|
|
12
|
-
* Calculate subscription period start/end dates
|
|
13
|
-
*/
|
|
14
|
-
export function calculatePeriodRange({ currentEndDate, startDate, duration, unit, now, }: {
|
|
15
|
-
currentEndDate?: any;
|
|
16
|
-
startDate?: any;
|
|
17
|
-
duration: any;
|
|
18
|
-
unit?: string;
|
|
19
|
-
now?: Date;
|
|
20
|
-
}): {
|
|
21
|
-
startDate: Date;
|
|
22
|
-
endDate: Date;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Calculate prorated refund amount for unused period
|
|
26
|
-
*/
|
|
27
|
-
export function calculateProratedAmount({ amountPaid, startDate, endDate, asOfDate, precision, }: {
|
|
28
|
-
amountPaid: any;
|
|
29
|
-
startDate: any;
|
|
30
|
-
endDate: any;
|
|
31
|
-
asOfDate?: Date;
|
|
32
|
-
precision?: number;
|
|
33
|
-
}): number;
|
|
34
|
-
/**
|
|
35
|
-
* Convert interval + count to duration/unit
|
|
36
|
-
*/
|
|
37
|
-
export function resolveIntervalToDuration(interval?: string, intervalCount?: number): {
|
|
38
|
-
duration: number;
|
|
39
|
-
unit: string;
|
|
40
|
-
};
|
|
41
|
-
declare namespace _default {
|
|
42
|
-
export { addDuration };
|
|
43
|
-
export { calculatePeriodRange };
|
|
44
|
-
export { calculateProratedAmount };
|
|
45
|
-
export { resolveIntervalToDuration };
|
|
46
|
-
}
|
|
47
|
-
export default _default;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if transaction is monetization-managed
|
|
3
|
-
*
|
|
4
|
-
* Monetization-managed means:
|
|
5
|
-
* - Created through subscription/purchase flows via the library
|
|
6
|
-
* - Status controlled by payment webhooks/verification
|
|
7
|
-
* - Amount/commission calculated by library
|
|
8
|
-
* - Protected fields: status, amount, commission, gateway, verifiedAt, verifiedBy
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} transaction - Transaction document or data
|
|
11
|
-
* @param {Object} options - Options
|
|
12
|
-
* @param {Array<string>} options.targetModels - Target models from config (default: ['Subscription', 'Membership'])
|
|
13
|
-
* @param {Array<string>} options.additionalCategories - Additional categories from user config
|
|
14
|
-
* @returns {boolean}
|
|
15
|
-
*/
|
|
16
|
-
export function isMonetizationTransaction(transaction: any, options?: {
|
|
17
|
-
targetModels: Array<string>;
|
|
18
|
-
additionalCategories: Array<string>;
|
|
19
|
-
}): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Check if transaction is manual admin transaction
|
|
22
|
-
*
|
|
23
|
-
* Manual transactions:
|
|
24
|
-
* - Created directly by admins for operational expenses/income
|
|
25
|
-
* - Can be self-verified by admins
|
|
26
|
-
* - More flexible updates allowed
|
|
27
|
-
* - No commission/gateway complexity
|
|
28
|
-
*
|
|
29
|
-
* @param {Object} transaction - Transaction document or data
|
|
30
|
-
* @param {Object} options - Options (same as isMonetizationTransaction)
|
|
31
|
-
* @returns {boolean}
|
|
32
|
-
*/
|
|
33
|
-
export function isManualTransaction(transaction: any, options?: any): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Get transaction type
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} transaction - Transaction document or data
|
|
38
|
-
* @param {Object} options - Options (same as isMonetizationTransaction)
|
|
39
|
-
* @returns {string} TRANSACTION_TYPE.MONETIZATION or TRANSACTION_TYPE.MANUAL
|
|
40
|
-
*/
|
|
41
|
-
export function getTransactionType(transaction: any, options?: any): string;
|
|
42
|
-
/**
|
|
43
|
-
* Get allowed update fields based on transaction type and status
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} transaction - Transaction document
|
|
46
|
-
* @param {Object} options - Options for transaction type detection
|
|
47
|
-
* @returns {Array<string>} Allowed field names
|
|
48
|
-
*/
|
|
49
|
-
export function getAllowedUpdateFields(transaction: any, options?: any): Array<string>;
|
|
50
|
-
/**
|
|
51
|
-
* Validate if field update is allowed
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} transaction - Transaction document
|
|
54
|
-
* @param {string} fieldName - Field being updated
|
|
55
|
-
* @param {Object} options - Options for transaction type detection
|
|
56
|
-
* @returns {Object} { allowed: boolean, reason?: string }
|
|
57
|
-
*/
|
|
58
|
-
export function validateFieldUpdate(transaction: any, fieldName: string, options?: any): any;
|
|
59
|
-
/**
|
|
60
|
-
* Check if transaction can be self-verified by admin
|
|
61
|
-
*
|
|
62
|
-
* @param {Object} transaction - Transaction document
|
|
63
|
-
* @param {Object} options - Options for transaction type detection
|
|
64
|
-
* @returns {boolean}
|
|
65
|
-
*/
|
|
66
|
-
export function canSelfVerify(transaction: any, options?: any): boolean;
|
|
67
|
-
export namespace TRANSACTION_TYPE {
|
|
68
|
-
let MONETIZATION: string;
|
|
69
|
-
let MANUAL: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Protected fields for monetization transactions
|
|
73
|
-
* These fields cannot be updated directly by admins
|
|
74
|
-
*/
|
|
75
|
-
export const PROTECTED_MONETIZATION_FIELDS: string[];
|
|
76
|
-
/**
|
|
77
|
-
* Editable fields for monetization transactions (before verification)
|
|
78
|
-
* These fields can be updated by frontend/customer before payment is verified
|
|
79
|
-
*/
|
|
80
|
-
export const EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION: string[];
|
|
81
|
-
/**
|
|
82
|
-
* Allowed fields for manual transaction creation
|
|
83
|
-
*/
|
|
84
|
-
export const MANUAL_TRANSACTION_CREATE_FIELDS: string[];
|
|
85
|
-
/**
|
|
86
|
-
* Allowed fields for manual transaction updates
|
|
87
|
-
*/
|
|
88
|
-
export const MANUAL_TRANSACTION_UPDATE_FIELDS: string[];
|
|
89
|
-
declare namespace _default {
|
|
90
|
-
export { TRANSACTION_TYPE };
|
|
91
|
-
export { isMonetizationTransaction };
|
|
92
|
-
export { isManualTransaction };
|
|
93
|
-
export { getTransactionType };
|
|
94
|
-
export { PROTECTED_MONETIZATION_FIELDS };
|
|
95
|
-
export { EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION };
|
|
96
|
-
export { MANUAL_TRANSACTION_CREATE_FIELDS };
|
|
97
|
-
export { MANUAL_TRANSACTION_UPDATE_FIELDS };
|
|
98
|
-
export { getAllowedUpdateFields };
|
|
99
|
-
export { validateFieldUpdate };
|
|
100
|
-
export { canSelfVerify };
|
|
101
|
-
}
|
|
102
|
-
export default _default;
|
package/enums/escrow.enums.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escrow/Hold Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* Enums for platform-as-intermediary payment flow
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const HOLD_STATUS = {
|
|
9
|
-
PENDING: 'pending',
|
|
10
|
-
HELD: 'held',
|
|
11
|
-
RELEASED: 'released',
|
|
12
|
-
CANCELLED: 'cancelled',
|
|
13
|
-
EXPIRED: 'expired',
|
|
14
|
-
PARTIALLY_RELEASED: 'partially_released',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const HOLD_STATUS_VALUES = Object.values(HOLD_STATUS);
|
|
18
|
-
|
|
19
|
-
export const RELEASE_REASON = {
|
|
20
|
-
PAYMENT_VERIFIED: 'payment_verified',
|
|
21
|
-
MANUAL_RELEASE: 'manual_release',
|
|
22
|
-
AUTO_RELEASE: 'auto_release',
|
|
23
|
-
DISPUTE_RESOLVED: 'dispute_resolved',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const RELEASE_REASON_VALUES = Object.values(RELEASE_REASON);
|
|
27
|
-
|
|
28
|
-
export const HOLD_REASON = {
|
|
29
|
-
PAYMENT_VERIFICATION: 'payment_verification',
|
|
30
|
-
FRAUD_CHECK: 'fraud_check',
|
|
31
|
-
MANUAL_REVIEW: 'manual_review',
|
|
32
|
-
DISPUTE: 'dispute',
|
|
33
|
-
COMPLIANCE: 'compliance',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const HOLD_REASON_VALUES = Object.values(HOLD_REASON);
|
package/enums/index.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript definitions for @classytic/revenue/enums
|
|
3
|
-
* Centralized Enums
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ============ TRANSACTION ENUMS ============
|
|
7
|
-
|
|
8
|
-
export const TRANSACTION_TYPE: {
|
|
9
|
-
readonly INCOME: 'income';
|
|
10
|
-
readonly EXPENSE: 'expense';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const TRANSACTION_TYPE_VALUES: string[];
|
|
14
|
-
|
|
15
|
-
export const TRANSACTION_STATUS: {
|
|
16
|
-
readonly PENDING: 'pending';
|
|
17
|
-
readonly PAYMENT_INITIATED: 'payment_initiated';
|
|
18
|
-
readonly PROCESSING: 'processing';
|
|
19
|
-
readonly REQUIRES_ACTION: 'requires_action';
|
|
20
|
-
readonly VERIFIED: 'verified';
|
|
21
|
-
readonly COMPLETED: 'completed';
|
|
22
|
-
readonly FAILED: 'failed';
|
|
23
|
-
readonly CANCELLED: 'cancelled';
|
|
24
|
-
readonly EXPIRED: 'expired';
|
|
25
|
-
readonly REFUNDED: 'refunded';
|
|
26
|
-
readonly PARTIALLY_REFUNDED: 'partially_refunded';
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const TRANSACTION_STATUS_VALUES: string[];
|
|
30
|
-
|
|
31
|
-
export const LIBRARY_CATEGORIES: {
|
|
32
|
-
readonly SUBSCRIPTION: 'subscription';
|
|
33
|
-
readonly PURCHASE: 'purchase';
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const LIBRARY_CATEGORY_VALUES: string[];
|
|
37
|
-
|
|
38
|
-
// ============ PAYMENT ENUMS ============
|
|
39
|
-
|
|
40
|
-
export const PAYMENT_STATUS: {
|
|
41
|
-
readonly PENDING: 'pending';
|
|
42
|
-
readonly VERIFIED: 'verified';
|
|
43
|
-
readonly FAILED: 'failed';
|
|
44
|
-
readonly REFUNDED: 'refunded';
|
|
45
|
-
readonly CANCELLED: 'cancelled';
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const PAYMENT_STATUS_VALUES: string[];
|
|
49
|
-
|
|
50
|
-
export const PAYMENT_GATEWAY_TYPE: {
|
|
51
|
-
readonly MANUAL: 'manual';
|
|
52
|
-
readonly STRIPE: 'stripe';
|
|
53
|
-
readonly SSLCOMMERZ: 'sslcommerz';
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const PAYMENT_GATEWAY_TYPE_VALUES: string[];
|
|
57
|
-
|
|
58
|
-
// Backward compatibility aliases
|
|
59
|
-
export const GATEWAY_TYPES: typeof PAYMENT_GATEWAY_TYPE;
|
|
60
|
-
export const GATEWAY_TYPE_VALUES: typeof PAYMENT_GATEWAY_TYPE_VALUES;
|
|
61
|
-
|
|
62
|
-
// ============ SUBSCRIPTION ENUMS ============
|
|
63
|
-
|
|
64
|
-
export const SUBSCRIPTION_STATUS: {
|
|
65
|
-
readonly ACTIVE: 'active';
|
|
66
|
-
readonly PAUSED: 'paused';
|
|
67
|
-
readonly CANCELLED: 'cancelled';
|
|
68
|
-
readonly EXPIRED: 'expired';
|
|
69
|
-
readonly PENDING: 'pending';
|
|
70
|
-
readonly INACTIVE: 'inactive';
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const SUBSCRIPTION_STATUS_VALUES: string[];
|
|
74
|
-
|
|
75
|
-
export const PLAN_KEYS: {
|
|
76
|
-
readonly MONTHLY: 'monthly';
|
|
77
|
-
readonly QUARTERLY: 'quarterly';
|
|
78
|
-
readonly YEARLY: 'yearly';
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const PLAN_KEY_VALUES: string[];
|
|
82
|
-
|
|
83
|
-
// ============ MONETIZATION ENUMS ============
|
|
84
|
-
|
|
85
|
-
export const MONETIZATION_TYPES: {
|
|
86
|
-
readonly FREE: 'free';
|
|
87
|
-
readonly PURCHASE: 'purchase';
|
|
88
|
-
readonly SUBSCRIPTION: 'subscription';
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const MONETIZATION_TYPE_VALUES: string[];
|
|
92
|
-
|
|
93
|
-
// ============ DEFAULT EXPORT ============
|
|
94
|
-
|
|
95
|
-
declare const _default: {
|
|
96
|
-
TRANSACTION_TYPE: typeof TRANSACTION_TYPE;
|
|
97
|
-
TRANSACTION_TYPE_VALUES: typeof TRANSACTION_TYPE_VALUES;
|
|
98
|
-
TRANSACTION_STATUS: typeof TRANSACTION_STATUS;
|
|
99
|
-
TRANSACTION_STATUS_VALUES: typeof TRANSACTION_STATUS_VALUES;
|
|
100
|
-
LIBRARY_CATEGORIES: typeof LIBRARY_CATEGORIES;
|
|
101
|
-
LIBRARY_CATEGORY_VALUES: typeof LIBRARY_CATEGORY_VALUES;
|
|
102
|
-
PAYMENT_STATUS: typeof PAYMENT_STATUS;
|
|
103
|
-
PAYMENT_STATUS_VALUES: typeof PAYMENT_STATUS_VALUES;
|
|
104
|
-
PAYMENT_GATEWAY_TYPE: typeof PAYMENT_GATEWAY_TYPE;
|
|
105
|
-
PAYMENT_GATEWAY_TYPE_VALUES: typeof PAYMENT_GATEWAY_TYPE_VALUES;
|
|
106
|
-
GATEWAY_TYPES: typeof GATEWAY_TYPES;
|
|
107
|
-
GATEWAY_TYPE_VALUES: typeof GATEWAY_TYPE_VALUES;
|
|
108
|
-
SUBSCRIPTION_STATUS: typeof SUBSCRIPTION_STATUS;
|
|
109
|
-
SUBSCRIPTION_STATUS_VALUES: typeof SUBSCRIPTION_STATUS_VALUES;
|
|
110
|
-
PLAN_KEYS: typeof PLAN_KEYS;
|
|
111
|
-
PLAN_KEY_VALUES: typeof PLAN_KEY_VALUES;
|
|
112
|
-
MONETIZATION_TYPES: typeof MONETIZATION_TYPES;
|
|
113
|
-
MONETIZATION_TYPE_VALUES: typeof MONETIZATION_TYPE_VALUES;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default _default;
|
package/enums/index.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @classytic/revenue - Centralized Enums
|
|
3
|
-
* All enums for the revenue management system
|
|
4
|
-
*
|
|
5
|
-
* This file serves as the single source of truth for all enum values
|
|
6
|
-
* used across monetization and payment subsystems.
|
|
7
|
-
*
|
|
8
|
-
* @module @classytic/revenue/enums
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// Re-export all enums
|
|
12
|
-
export * from './transaction.enums.js';
|
|
13
|
-
export * from './payment.enums.js';
|
|
14
|
-
export * from './subscription.enums.js';
|
|
15
|
-
export * from './monetization.enums.js';
|
|
16
|
-
export * from './escrow.enums.js';
|
|
17
|
-
export * from './split.enums.js';
|
|
18
|
-
|
|
19
|
-
// Default export for convenience
|
|
20
|
-
import {
|
|
21
|
-
TRANSACTION_TYPE,
|
|
22
|
-
TRANSACTION_TYPE_VALUES,
|
|
23
|
-
TRANSACTION_STATUS,
|
|
24
|
-
TRANSACTION_STATUS_VALUES,
|
|
25
|
-
LIBRARY_CATEGORIES,
|
|
26
|
-
LIBRARY_CATEGORY_VALUES,
|
|
27
|
-
} from './transaction.enums.js';
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
PAYMENT_STATUS,
|
|
31
|
-
PAYMENT_STATUS_VALUES,
|
|
32
|
-
PAYMENT_GATEWAY_TYPE,
|
|
33
|
-
PAYMENT_GATEWAY_TYPE_VALUES,
|
|
34
|
-
GATEWAY_TYPES,
|
|
35
|
-
GATEWAY_TYPE_VALUES,
|
|
36
|
-
} from './payment.enums.js';
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
SUBSCRIPTION_STATUS,
|
|
40
|
-
SUBSCRIPTION_STATUS_VALUES,
|
|
41
|
-
PLAN_KEYS,
|
|
42
|
-
PLAN_KEY_VALUES,
|
|
43
|
-
} from './subscription.enums.js';
|
|
44
|
-
|
|
45
|
-
import {
|
|
46
|
-
MONETIZATION_TYPES,
|
|
47
|
-
MONETIZATION_TYPE_VALUES,
|
|
48
|
-
} from './monetization.enums.js';
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
HOLD_STATUS,
|
|
52
|
-
HOLD_STATUS_VALUES,
|
|
53
|
-
RELEASE_REASON,
|
|
54
|
-
RELEASE_REASON_VALUES,
|
|
55
|
-
HOLD_REASON,
|
|
56
|
-
HOLD_REASON_VALUES,
|
|
57
|
-
} from './escrow.enums.js';
|
|
58
|
-
|
|
59
|
-
import {
|
|
60
|
-
SPLIT_TYPE,
|
|
61
|
-
SPLIT_TYPE_VALUES,
|
|
62
|
-
SPLIT_STATUS,
|
|
63
|
-
SPLIT_STATUS_VALUES,
|
|
64
|
-
PAYOUT_METHOD,
|
|
65
|
-
PAYOUT_METHOD_VALUES,
|
|
66
|
-
} from './split.enums.js';
|
|
67
|
-
|
|
68
|
-
export default {
|
|
69
|
-
// Transaction enums
|
|
70
|
-
TRANSACTION_TYPE,
|
|
71
|
-
TRANSACTION_TYPE_VALUES,
|
|
72
|
-
TRANSACTION_STATUS,
|
|
73
|
-
TRANSACTION_STATUS_VALUES,
|
|
74
|
-
LIBRARY_CATEGORIES,
|
|
75
|
-
LIBRARY_CATEGORY_VALUES,
|
|
76
|
-
|
|
77
|
-
// Payment enums
|
|
78
|
-
PAYMENT_STATUS,
|
|
79
|
-
PAYMENT_STATUS_VALUES,
|
|
80
|
-
PAYMENT_GATEWAY_TYPE,
|
|
81
|
-
PAYMENT_GATEWAY_TYPE_VALUES,
|
|
82
|
-
GATEWAY_TYPES,
|
|
83
|
-
GATEWAY_TYPE_VALUES,
|
|
84
|
-
|
|
85
|
-
// Subscription enums
|
|
86
|
-
SUBSCRIPTION_STATUS,
|
|
87
|
-
SUBSCRIPTION_STATUS_VALUES,
|
|
88
|
-
PLAN_KEYS,
|
|
89
|
-
PLAN_KEY_VALUES,
|
|
90
|
-
|
|
91
|
-
// Monetization enums
|
|
92
|
-
MONETIZATION_TYPES,
|
|
93
|
-
MONETIZATION_TYPE_VALUES,
|
|
94
|
-
|
|
95
|
-
// Escrow enums
|
|
96
|
-
HOLD_STATUS,
|
|
97
|
-
HOLD_STATUS_VALUES,
|
|
98
|
-
RELEASE_REASON,
|
|
99
|
-
RELEASE_REASON_VALUES,
|
|
100
|
-
HOLD_REASON,
|
|
101
|
-
HOLD_REASON_VALUES,
|
|
102
|
-
|
|
103
|
-
// Split enums
|
|
104
|
-
SPLIT_TYPE,
|
|
105
|
-
SPLIT_TYPE_VALUES,
|
|
106
|
-
SPLIT_STATUS,
|
|
107
|
-
SPLIT_STATUS_VALUES,
|
|
108
|
-
PAYOUT_METHOD,
|
|
109
|
-
PAYOUT_METHOD_VALUES,
|
|
110
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monetization Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* General monetization enums and constants
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// ============ MONETIZATION TYPES ============
|
|
9
|
-
export const MONETIZATION_TYPES = {
|
|
10
|
-
FREE: 'free',
|
|
11
|
-
PURCHASE: 'purchase',
|
|
12
|
-
SUBSCRIPTION: 'subscription',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const MONETIZATION_TYPE_VALUES = Object.values(MONETIZATION_TYPES);
|
package/enums/payment.enums.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Payment Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* Library-managed payment enums only.
|
|
6
|
-
* Users define their own payment methods in their schema.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// ============ PAYMENT STATUS ============
|
|
10
|
-
/**
|
|
11
|
-
* Payment Status - Library-managed states
|
|
12
|
-
*/
|
|
13
|
-
export const PAYMENT_STATUS = {
|
|
14
|
-
PENDING: 'pending',
|
|
15
|
-
VERIFIED: 'verified',
|
|
16
|
-
FAILED: 'failed',
|
|
17
|
-
REFUNDED: 'refunded',
|
|
18
|
-
CANCELLED: 'cancelled',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const PAYMENT_STATUS_VALUES = Object.values(PAYMENT_STATUS);
|
|
22
|
-
|
|
23
|
-
// ============ PAYMENT GATEWAY TYPES ============
|
|
24
|
-
/**
|
|
25
|
-
* Common gateway type constants for convenience
|
|
26
|
-
*
|
|
27
|
-
* ⚠️ IMPORTANT: These are NOT restrictions - just common reference values
|
|
28
|
-
*
|
|
29
|
-
* You can register ANY custom gateway provider by passing it to createRevenue():
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```javascript
|
|
33
|
-
* const revenue = createRevenue({
|
|
34
|
-
* providers: {
|
|
35
|
-
* manual: new ManualProvider(),
|
|
36
|
-
* bkash: new BkashProvider(), // ✅ Custom gateway
|
|
37
|
-
* nagad: new NagadProvider(), // ✅ Custom gateway
|
|
38
|
-
* stripe: new StripeProvider(), // ✅ Custom gateway
|
|
39
|
-
* paypal: new PaypalProvider(), // ✅ Any gateway you want
|
|
40
|
-
* }
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* // Use by name
|
|
44
|
-
* await revenue.monetization.create({ gateway: 'bkash', ... });
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* Reference values:
|
|
48
|
-
* - MANUAL: Built-in manual provider (@classytic/revenue-manual)
|
|
49
|
-
* - STRIPE: Stripe provider (build with @classytic/revenue-stripe)
|
|
50
|
-
* - SSLCOMMERZ: SSLCommerz provider (build with @classytic/revenue-sslcommerz)
|
|
51
|
-
*
|
|
52
|
-
* Add your own: bkash, nagad, rocket, paypal, razorpay, flutterwave, etc.
|
|
53
|
-
*/
|
|
54
|
-
export const PAYMENT_GATEWAY_TYPE = {
|
|
55
|
-
MANUAL: 'manual',
|
|
56
|
-
STRIPE: 'stripe',
|
|
57
|
-
SSLCOMMERZ: 'sslcommerz',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const PAYMENT_GATEWAY_TYPE_VALUES = Object.values(PAYMENT_GATEWAY_TYPE);
|
|
61
|
-
|
|
62
|
-
// Backward compatibility alias
|
|
63
|
-
export const GATEWAY_TYPES = PAYMENT_GATEWAY_TYPE;
|
|
64
|
-
export const GATEWAY_TYPE_VALUES = PAYMENT_GATEWAY_TYPE_VALUES;
|
package/enums/split.enums.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Split Payment Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* Enums for multi-party commission splits
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const SPLIT_TYPE = {
|
|
9
|
-
PLATFORM_COMMISSION: 'platform_commission',
|
|
10
|
-
AFFILIATE_COMMISSION: 'affiliate_commission',
|
|
11
|
-
REFERRAL_COMMISSION: 'referral_commission',
|
|
12
|
-
PARTNER_COMMISSION: 'partner_commission',
|
|
13
|
-
CUSTOM: 'custom',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);
|
|
17
|
-
|
|
18
|
-
export const SPLIT_STATUS = {
|
|
19
|
-
PENDING: 'pending',
|
|
20
|
-
DUE: 'due',
|
|
21
|
-
PAID: 'paid',
|
|
22
|
-
WAIVED: 'waived',
|
|
23
|
-
CANCELLED: 'cancelled',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const SPLIT_STATUS_VALUES = Object.values(SPLIT_STATUS);
|
|
27
|
-
|
|
28
|
-
export const PAYOUT_METHOD = {
|
|
29
|
-
BANK_TRANSFER: 'bank_transfer',
|
|
30
|
-
MOBILE_WALLET: 'mobile_wallet',
|
|
31
|
-
PLATFORM_BALANCE: 'platform_balance',
|
|
32
|
-
CRYPTO: 'crypto',
|
|
33
|
-
CHECK: 'check',
|
|
34
|
-
MANUAL: 'manual',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscription Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* All subscription-related enums and constants
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// ============ SUBSCRIPTION STATUS ============
|
|
9
|
-
/**
|
|
10
|
-
* Subscription Status
|
|
11
|
-
*/
|
|
12
|
-
export const SUBSCRIPTION_STATUS = {
|
|
13
|
-
ACTIVE: 'active',
|
|
14
|
-
PAUSED: 'paused',
|
|
15
|
-
CANCELLED: 'cancelled',
|
|
16
|
-
EXPIRED: 'expired',
|
|
17
|
-
PENDING: 'pending',
|
|
18
|
-
INACTIVE: 'inactive',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const SUBSCRIPTION_STATUS_VALUES = Object.values(SUBSCRIPTION_STATUS);
|
|
22
|
-
|
|
23
|
-
// ============ PLAN KEYS ============
|
|
24
|
-
/**
|
|
25
|
-
* Supported plan intervals
|
|
26
|
-
*/
|
|
27
|
-
export const PLAN_KEYS = {
|
|
28
|
-
MONTHLY: 'monthly',
|
|
29
|
-
QUARTERLY: 'quarterly',
|
|
30
|
-
YEARLY: 'yearly',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const PLAN_KEY_VALUES = Object.values(PLAN_KEYS);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transaction Enums
|
|
3
|
-
* @classytic/revenue
|
|
4
|
-
*
|
|
5
|
-
* Library-managed transaction enums only.
|
|
6
|
-
* Users should define their own categories and merge with these.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// ============ TRANSACTION TYPE ============
|
|
10
|
-
/**
|
|
11
|
-
* Transaction Type - Income vs Expense
|
|
12
|
-
*
|
|
13
|
-
* INCOME: Money coming in (payments, subscriptions, purchases)
|
|
14
|
-
* EXPENSE: Money going out (refunds, payouts)
|
|
15
|
-
*
|
|
16
|
-
* Users can map these in their config via transactionTypeMapping
|
|
17
|
-
*/
|
|
18
|
-
export const TRANSACTION_TYPE = {
|
|
19
|
-
INCOME: 'income',
|
|
20
|
-
EXPENSE: 'expense',
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const TRANSACTION_TYPE_VALUES = Object.values(TRANSACTION_TYPE);
|
|
24
|
-
|
|
25
|
-
// ============ TRANSACTION STATUS ============
|
|
26
|
-
/**
|
|
27
|
-
* Transaction Status - Library-managed states
|
|
28
|
-
*/
|
|
29
|
-
export const TRANSACTION_STATUS = {
|
|
30
|
-
PENDING: 'pending',
|
|
31
|
-
PAYMENT_INITIATED: 'payment_initiated',
|
|
32
|
-
PROCESSING: 'processing',
|
|
33
|
-
REQUIRES_ACTION: 'requires_action',
|
|
34
|
-
VERIFIED: 'verified',
|
|
35
|
-
COMPLETED: 'completed',
|
|
36
|
-
FAILED: 'failed',
|
|
37
|
-
CANCELLED: 'cancelled',
|
|
38
|
-
EXPIRED: 'expired',
|
|
39
|
-
REFUNDED: 'refunded',
|
|
40
|
-
PARTIALLY_REFUNDED: 'partially_refunded',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const TRANSACTION_STATUS_VALUES = Object.values(TRANSACTION_STATUS);
|
|
44
|
-
|
|
45
|
-
// ============ LIBRARY CATEGORIES ============
|
|
46
|
-
/**
|
|
47
|
-
* Categories managed by this library
|
|
48
|
-
*
|
|
49
|
-
* SUBSCRIPTION: Recurring subscription payments
|
|
50
|
-
* PURCHASE: One-time purchases
|
|
51
|
-
*
|
|
52
|
-
* Users should spread these into their own category enums:
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* import { LIBRARY_CATEGORIES } from '@classytic/revenue';
|
|
56
|
-
*
|
|
57
|
-
* export const MY_CATEGORIES = {
|
|
58
|
-
* ...LIBRARY_CATEGORIES,
|
|
59
|
-
* SALARY: 'salary',
|
|
60
|
-
* RENT: 'rent',
|
|
61
|
-
* EQUIPMENT: 'equipment',
|
|
62
|
-
* };
|
|
63
|
-
*/
|
|
64
|
-
export const LIBRARY_CATEGORIES = {
|
|
65
|
-
SUBSCRIPTION: 'subscription',
|
|
66
|
-
PURCHASE: 'purchase',
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const LIBRARY_CATEGORY_VALUES = Object.values(LIBRARY_CATEGORIES);
|