@classytic/revenue 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/enums/index.d.ts +107 -0
- package/package.json +17 -5
- package/schemas/index.d.ts +54 -0
- package/utils/index.d.ts +99 -0
package/enums/index.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for @classytic/revenue/enums
|
|
3
|
+
* Centralized Enums
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============ TRANSACTION ENUMS ============
|
|
7
|
+
|
|
8
|
+
export const TRANSACTION_STATUS: {
|
|
9
|
+
readonly PENDING: 'pending';
|
|
10
|
+
readonly PAYMENT_INITIATED: 'payment_initiated';
|
|
11
|
+
readonly PROCESSING: 'processing';
|
|
12
|
+
readonly REQUIRES_ACTION: 'requires_action';
|
|
13
|
+
readonly VERIFIED: 'verified';
|
|
14
|
+
readonly COMPLETED: 'completed';
|
|
15
|
+
readonly FAILED: 'failed';
|
|
16
|
+
readonly CANCELLED: 'cancelled';
|
|
17
|
+
readonly EXPIRED: 'expired';
|
|
18
|
+
readonly REFUNDED: 'refunded';
|
|
19
|
+
readonly PARTIALLY_REFUNDED: 'partially_refunded';
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const TRANSACTION_STATUS_VALUES: string[];
|
|
23
|
+
|
|
24
|
+
export const LIBRARY_CATEGORIES: {
|
|
25
|
+
readonly SUBSCRIPTION: 'subscription';
|
|
26
|
+
readonly PURCHASE: 'purchase';
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const LIBRARY_CATEGORY_VALUES: string[];
|
|
30
|
+
|
|
31
|
+
// ============ PAYMENT ENUMS ============
|
|
32
|
+
|
|
33
|
+
export const PAYMENT_STATUS: {
|
|
34
|
+
readonly PENDING: 'pending';
|
|
35
|
+
readonly VERIFIED: 'verified';
|
|
36
|
+
readonly FAILED: 'failed';
|
|
37
|
+
readonly REFUNDED: 'refunded';
|
|
38
|
+
readonly CANCELLED: 'cancelled';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const PAYMENT_STATUS_VALUES: string[];
|
|
42
|
+
|
|
43
|
+
export const PAYMENT_GATEWAY_TYPE: {
|
|
44
|
+
readonly MANUAL: 'manual';
|
|
45
|
+
readonly STRIPE: 'stripe';
|
|
46
|
+
readonly SSLCOMMERZ: 'sslcommerz';
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const PAYMENT_GATEWAY_TYPE_VALUES: string[];
|
|
50
|
+
|
|
51
|
+
// Backward compatibility aliases
|
|
52
|
+
export const GATEWAY_TYPES: typeof PAYMENT_GATEWAY_TYPE;
|
|
53
|
+
export const GATEWAY_TYPE_VALUES: typeof PAYMENT_GATEWAY_TYPE_VALUES;
|
|
54
|
+
|
|
55
|
+
// ============ SUBSCRIPTION ENUMS ============
|
|
56
|
+
|
|
57
|
+
export const SUBSCRIPTION_STATUS: {
|
|
58
|
+
readonly ACTIVE: 'active';
|
|
59
|
+
readonly PAUSED: 'paused';
|
|
60
|
+
readonly CANCELLED: 'cancelled';
|
|
61
|
+
readonly EXPIRED: 'expired';
|
|
62
|
+
readonly PENDING: 'pending';
|
|
63
|
+
readonly INACTIVE: 'inactive';
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const SUBSCRIPTION_STATUS_VALUES: string[];
|
|
67
|
+
|
|
68
|
+
export const PLAN_KEYS: {
|
|
69
|
+
readonly MONTHLY: 'monthly';
|
|
70
|
+
readonly QUARTERLY: 'quarterly';
|
|
71
|
+
readonly YEARLY: 'yearly';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const PLAN_KEY_VALUES: string[];
|
|
75
|
+
|
|
76
|
+
// ============ MONETIZATION ENUMS ============
|
|
77
|
+
|
|
78
|
+
export const MONETIZATION_TYPES: {
|
|
79
|
+
readonly FREE: 'free';
|
|
80
|
+
readonly PURCHASE: 'purchase';
|
|
81
|
+
readonly SUBSCRIPTION: 'subscription';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const MONETIZATION_TYPE_VALUES: string[];
|
|
85
|
+
|
|
86
|
+
// ============ DEFAULT EXPORT ============
|
|
87
|
+
|
|
88
|
+
declare const _default: {
|
|
89
|
+
TRANSACTION_STATUS: typeof TRANSACTION_STATUS;
|
|
90
|
+
TRANSACTION_STATUS_VALUES: typeof TRANSACTION_STATUS_VALUES;
|
|
91
|
+
LIBRARY_CATEGORIES: typeof LIBRARY_CATEGORIES;
|
|
92
|
+
LIBRARY_CATEGORY_VALUES: typeof LIBRARY_CATEGORY_VALUES;
|
|
93
|
+
PAYMENT_STATUS: typeof PAYMENT_STATUS;
|
|
94
|
+
PAYMENT_STATUS_VALUES: typeof PAYMENT_STATUS_VALUES;
|
|
95
|
+
PAYMENT_GATEWAY_TYPE: typeof PAYMENT_GATEWAY_TYPE;
|
|
96
|
+
PAYMENT_GATEWAY_TYPE_VALUES: typeof PAYMENT_GATEWAY_TYPE_VALUES;
|
|
97
|
+
GATEWAY_TYPES: typeof GATEWAY_TYPES;
|
|
98
|
+
GATEWAY_TYPE_VALUES: typeof GATEWAY_TYPE_VALUES;
|
|
99
|
+
SUBSCRIPTION_STATUS: typeof SUBSCRIPTION_STATUS;
|
|
100
|
+
SUBSCRIPTION_STATUS_VALUES: typeof SUBSCRIPTION_STATUS_VALUES;
|
|
101
|
+
PLAN_KEYS: typeof PLAN_KEYS;
|
|
102
|
+
PLAN_KEY_VALUES: typeof PLAN_KEY_VALUES;
|
|
103
|
+
MONETIZATION_TYPES: typeof MONETIZATION_TYPES;
|
|
104
|
+
MONETIZATION_TYPE_VALUES: typeof MONETIZATION_TYPE_VALUES;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/revenue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Enterprise revenue management system with subscriptions, purchases, proration, and payment processing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "revenue.d.ts",
|
|
@@ -39,10 +39,22 @@
|
|
|
39
39
|
"node": ">=18.0.0"
|
|
40
40
|
},
|
|
41
41
|
"exports": {
|
|
42
|
-
".":
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./revenue.d.ts",
|
|
44
|
+
"default": "./index.js"
|
|
45
|
+
},
|
|
46
|
+
"./enums": {
|
|
47
|
+
"types": "./enums/index.d.ts",
|
|
48
|
+
"default": "./enums/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./schemas": {
|
|
51
|
+
"types": "./schemas/index.d.ts",
|
|
52
|
+
"default": "./schemas/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./utils": {
|
|
55
|
+
"types": "./utils/index.d.ts",
|
|
56
|
+
"default": "./utils/index.js"
|
|
57
|
+
}
|
|
46
58
|
},
|
|
47
59
|
"files": [
|
|
48
60
|
"index.js",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for @classytic/revenue/schemas
|
|
3
|
+
* Core schemas for injection into your models
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Schema } from 'mongoose';
|
|
7
|
+
|
|
8
|
+
// ============ TRANSACTION SCHEMAS ============
|
|
9
|
+
|
|
10
|
+
export const currentPaymentSchema: Schema;
|
|
11
|
+
export const paymentSummarySchema: Schema;
|
|
12
|
+
export const paymentDetailsSchema: Schema;
|
|
13
|
+
export const gatewaySchema: Schema;
|
|
14
|
+
export const commissionSchema: Schema;
|
|
15
|
+
export const tenantSnapshotSchema: Schema;
|
|
16
|
+
export const timelineEventSchema: Schema;
|
|
17
|
+
export const customerInfoSchema: Schema;
|
|
18
|
+
|
|
19
|
+
// ============ SUBSCRIPTION SCHEMAS ============
|
|
20
|
+
|
|
21
|
+
export const subscriptionInfoSchema: Schema;
|
|
22
|
+
export const subscriptionPlanSchema: Schema;
|
|
23
|
+
export const customDiscountSchema: Schema;
|
|
24
|
+
|
|
25
|
+
// ============ GATEWAY ACCOUNT SCHEMAS ============
|
|
26
|
+
|
|
27
|
+
export const stripeAccountSchema: Schema;
|
|
28
|
+
export const sslcommerzAccountSchema: Schema;
|
|
29
|
+
export const bkashMerchantSchema: Schema;
|
|
30
|
+
export const bankAccountSchema: Schema;
|
|
31
|
+
export const walletSchema: Schema;
|
|
32
|
+
|
|
33
|
+
// ============ DEFAULT EXPORT ============
|
|
34
|
+
|
|
35
|
+
declare const _default: {
|
|
36
|
+
currentPaymentSchema: Schema;
|
|
37
|
+
paymentSummarySchema: Schema;
|
|
38
|
+
paymentDetailsSchema: Schema;
|
|
39
|
+
gatewaySchema: Schema;
|
|
40
|
+
commissionSchema: Schema;
|
|
41
|
+
tenantSnapshotSchema: Schema;
|
|
42
|
+
timelineEventSchema: Schema;
|
|
43
|
+
customerInfoSchema: Schema;
|
|
44
|
+
subscriptionInfoSchema: Schema;
|
|
45
|
+
subscriptionPlanSchema: Schema;
|
|
46
|
+
customDiscountSchema: Schema;
|
|
47
|
+
stripeAccountSchema: Schema;
|
|
48
|
+
sslcommerzAccountSchema: Schema;
|
|
49
|
+
bkashMerchantSchema: Schema;
|
|
50
|
+
bankAccountSchema: Schema;
|
|
51
|
+
walletSchema: Schema;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default _default;
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for @classytic/revenue/utils
|
|
3
|
+
* Core utilities
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============ TRANSACTION TYPE UTILITIES ============
|
|
7
|
+
|
|
8
|
+
export const TRANSACTION_TYPE: {
|
|
9
|
+
readonly MONETIZATION: 'monetization';
|
|
10
|
+
readonly MANUAL: 'manual';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const PROTECTED_MONETIZATION_FIELDS: readonly string[];
|
|
14
|
+
export const EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION: readonly string[];
|
|
15
|
+
export const MANUAL_TRANSACTION_CREATE_FIELDS: readonly string[];
|
|
16
|
+
export const MANUAL_TRANSACTION_UPDATE_FIELDS: readonly string[];
|
|
17
|
+
|
|
18
|
+
export interface TransactionTypeOptions {
|
|
19
|
+
targetModels?: string[];
|
|
20
|
+
additionalCategories?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isMonetizationTransaction(
|
|
24
|
+
transaction: any,
|
|
25
|
+
options?: TransactionTypeOptions
|
|
26
|
+
): boolean;
|
|
27
|
+
|
|
28
|
+
export function isManualTransaction(
|
|
29
|
+
transaction: any,
|
|
30
|
+
options?: TransactionTypeOptions
|
|
31
|
+
): boolean;
|
|
32
|
+
|
|
33
|
+
export function getTransactionType(
|
|
34
|
+
transaction: any,
|
|
35
|
+
options?: TransactionTypeOptions
|
|
36
|
+
): 'monetization' | 'manual';
|
|
37
|
+
|
|
38
|
+
export function getAllowedUpdateFields(
|
|
39
|
+
transaction: any,
|
|
40
|
+
options?: TransactionTypeOptions
|
|
41
|
+
): string[];
|
|
42
|
+
|
|
43
|
+
export interface FieldValidationResult {
|
|
44
|
+
allowed: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function validateFieldUpdate(
|
|
49
|
+
transaction: any,
|
|
50
|
+
fieldName: string,
|
|
51
|
+
options?: TransactionTypeOptions
|
|
52
|
+
): FieldValidationResult;
|
|
53
|
+
|
|
54
|
+
export function canSelfVerify(
|
|
55
|
+
transaction: any,
|
|
56
|
+
options?: TransactionTypeOptions
|
|
57
|
+
): boolean;
|
|
58
|
+
|
|
59
|
+
// ============ LOGGER UTILITIES ============
|
|
60
|
+
|
|
61
|
+
export interface Logger {
|
|
62
|
+
info(...args: any[]): void;
|
|
63
|
+
warn(...args: any[]): void;
|
|
64
|
+
error(...args: any[]): void;
|
|
65
|
+
debug(...args: any[]): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const logger: Logger;
|
|
69
|
+
export function setLogger(logger: Logger | Console): void;
|
|
70
|
+
|
|
71
|
+
// ============ HOOK UTILITIES ============
|
|
72
|
+
|
|
73
|
+
export function triggerHook(
|
|
74
|
+
hooks: Record<string, Function[]>,
|
|
75
|
+
event: string,
|
|
76
|
+
data: any,
|
|
77
|
+
logger: Logger
|
|
78
|
+
): void;
|
|
79
|
+
|
|
80
|
+
// ============ DEFAULT EXPORT ============
|
|
81
|
+
|
|
82
|
+
declare const _default: {
|
|
83
|
+
TRANSACTION_TYPE: typeof TRANSACTION_TYPE;
|
|
84
|
+
isMonetizationTransaction: typeof isMonetizationTransaction;
|
|
85
|
+
isManualTransaction: typeof isManualTransaction;
|
|
86
|
+
getTransactionType: typeof getTransactionType;
|
|
87
|
+
PROTECTED_MONETIZATION_FIELDS: typeof PROTECTED_MONETIZATION_FIELDS;
|
|
88
|
+
EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION: typeof EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION;
|
|
89
|
+
MANUAL_TRANSACTION_CREATE_FIELDS: typeof MANUAL_TRANSACTION_CREATE_FIELDS;
|
|
90
|
+
MANUAL_TRANSACTION_UPDATE_FIELDS: typeof MANUAL_TRANSACTION_UPDATE_FIELDS;
|
|
91
|
+
getAllowedUpdateFields: typeof getAllowedUpdateFields;
|
|
92
|
+
validateFieldUpdate: typeof validateFieldUpdate;
|
|
93
|
+
canSelfVerify: typeof canSelfVerify;
|
|
94
|
+
logger: typeof logger;
|
|
95
|
+
setLogger: typeof setLogger;
|
|
96
|
+
triggerHook: typeof triggerHook;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default _default;
|