@classytic/revenue 1.0.2 → 1.0.6
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 +171 -2
- package/dist/{actions-CwG-b7fR.d.ts → actions-Ctf2XUL-.d.ts} +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +74 -4
- package/dist/core/index.js.map +1 -1
- package/dist/enums/index.d.ts +35 -27
- package/dist/enums/index.js +107 -11
- package/dist/enums/index.js.map +1 -1
- package/dist/{index-BnJWVXuw.d.ts → index-BnEXsnLJ.d.ts} +1 -1
- package/dist/{index-ChVD3P9k.d.ts → index-C5SsOrV0.d.ts} +31 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +187 -36
- package/dist/index.js.map +1 -1
- package/dist/payment.enums-B_RwB8iR.d.ts +184 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/schemas/index.d.ts +294 -137
- package/dist/schemas/index.js +132 -29
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/validation.d.ts +83 -8
- package/dist/schemas/validation.js +55 -2
- package/dist/schemas/validation.js.map +1 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +74 -4
- package/dist/services/index.js.map +1 -1
- package/dist/{split.schema-DYVP7Wu2.d.ts → split.schema-DLVF3XBI.d.ts} +301 -137
- package/dist/transaction.enums-7uBnuswI.d.ts +87 -0
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +75 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/split.enums-Bh24jw8p.d.ts +0 -255
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monetization Enums
|
|
3
|
+
* @classytic/revenue
|
|
4
|
+
*
|
|
5
|
+
* General monetization enums and constants
|
|
6
|
+
*/
|
|
7
|
+
declare const MONETIZATION_TYPES: {
|
|
8
|
+
readonly FREE: "free";
|
|
9
|
+
readonly PURCHASE: "purchase";
|
|
10
|
+
readonly SUBSCRIPTION: "subscription";
|
|
11
|
+
};
|
|
12
|
+
type MonetizationTypes = typeof MONETIZATION_TYPES;
|
|
13
|
+
type MonetizationTypeValue = MonetizationTypes[keyof MonetizationTypes];
|
|
14
|
+
declare const MONETIZATION_TYPE_VALUES: MonetizationTypeValue[];
|
|
15
|
+
declare function isMonetizationType(value: unknown): value is MonetizationTypeValue;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transaction Enums
|
|
19
|
+
* @classytic/revenue
|
|
20
|
+
*
|
|
21
|
+
* Library-managed transaction enums only.
|
|
22
|
+
* Users should define their own categories and merge with these.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Transaction Type - Income vs Expense
|
|
26
|
+
*
|
|
27
|
+
* INCOME: Money coming in (payments, subscriptions, purchases)
|
|
28
|
+
* EXPENSE: Money going out (refunds, payouts)
|
|
29
|
+
*
|
|
30
|
+
* Users can map these in their config via transactionTypeMapping
|
|
31
|
+
*/
|
|
32
|
+
declare const TRANSACTION_TYPE: {
|
|
33
|
+
readonly INCOME: "income";
|
|
34
|
+
readonly EXPENSE: "expense";
|
|
35
|
+
};
|
|
36
|
+
type TransactionType = typeof TRANSACTION_TYPE;
|
|
37
|
+
type TransactionTypeValue = TransactionType[keyof TransactionType];
|
|
38
|
+
declare const TRANSACTION_TYPE_VALUES: TransactionTypeValue[];
|
|
39
|
+
/**
|
|
40
|
+
* Transaction Status - Library-managed states
|
|
41
|
+
*/
|
|
42
|
+
declare const TRANSACTION_STATUS: {
|
|
43
|
+
readonly PENDING: "pending";
|
|
44
|
+
readonly PAYMENT_INITIATED: "payment_initiated";
|
|
45
|
+
readonly PROCESSING: "processing";
|
|
46
|
+
readonly REQUIRES_ACTION: "requires_action";
|
|
47
|
+
readonly VERIFIED: "verified";
|
|
48
|
+
readonly COMPLETED: "completed";
|
|
49
|
+
readonly FAILED: "failed";
|
|
50
|
+
readonly CANCELLED: "cancelled";
|
|
51
|
+
readonly EXPIRED: "expired";
|
|
52
|
+
readonly REFUNDED: "refunded";
|
|
53
|
+
readonly PARTIALLY_REFUNDED: "partially_refunded";
|
|
54
|
+
};
|
|
55
|
+
type TransactionStatus = typeof TRANSACTION_STATUS;
|
|
56
|
+
type TransactionStatusValue = TransactionStatus[keyof TransactionStatus];
|
|
57
|
+
declare const TRANSACTION_STATUS_VALUES: TransactionStatusValue[];
|
|
58
|
+
/**
|
|
59
|
+
* Categories managed by this library
|
|
60
|
+
*
|
|
61
|
+
* SUBSCRIPTION: Recurring subscription payments
|
|
62
|
+
* PURCHASE: One-time purchases
|
|
63
|
+
*
|
|
64
|
+
* Users should spread these into their own category enums:
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* import { LIBRARY_CATEGORIES } from '@classytic/revenue';
|
|
68
|
+
*
|
|
69
|
+
* export const MY_CATEGORIES = {
|
|
70
|
+
* ...LIBRARY_CATEGORIES,
|
|
71
|
+
* SALARY: 'salary',
|
|
72
|
+
* RENT: 'rent',
|
|
73
|
+
* EQUIPMENT: 'equipment',
|
|
74
|
+
* } as const;
|
|
75
|
+
*/
|
|
76
|
+
declare const LIBRARY_CATEGORIES: {
|
|
77
|
+
readonly SUBSCRIPTION: "subscription";
|
|
78
|
+
readonly PURCHASE: "purchase";
|
|
79
|
+
};
|
|
80
|
+
type LibraryCategories = typeof LIBRARY_CATEGORIES;
|
|
81
|
+
type LibraryCategoryValue = LibraryCategories[keyof LibraryCategories];
|
|
82
|
+
declare const LIBRARY_CATEGORY_VALUES: LibraryCategoryValue[];
|
|
83
|
+
declare function isLibraryCategory(value: unknown): value is LibraryCategoryValue;
|
|
84
|
+
declare function isTransactionType(value: unknown): value is TransactionTypeValue;
|
|
85
|
+
declare function isTransactionStatus(value: unknown): value is TransactionStatusValue;
|
|
86
|
+
|
|
87
|
+
export { LIBRARY_CATEGORIES as L, MONETIZATION_TYPES as M, TRANSACTION_TYPE as T, type TransactionType as a, TRANSACTION_TYPE_VALUES as b, TRANSACTION_STATUS as c, type TransactionStatus as d, TRANSACTION_STATUS_VALUES as e, type LibraryCategories as f, type LibraryCategoryValue as g, LIBRARY_CATEGORY_VALUES as h, isLibraryCategory as i, isTransactionType as j, isTransactionStatus as k, type MonetizationTypes as l, MONETIZATION_TYPE_VALUES as m, isMonetizationType as n, type TransactionTypeValue as o, type TransactionStatusValue as p, type MonetizationTypeValue as q };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { O as DurationUnit, E as EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION, h as IdempotencyConfig, c as IdempotencyError, I as IdempotencyManager, e as IdempotencyRecord, g as IdempotencyStore, z as MANUAL_TRANSACTION_CREATE_FIELDS, A as MANUAL_TRANSACTION_UPDATE_FIELDS, b as MemoryIdempotencyStore, M as Money, a as MoneyValue, P as PROTECTED_MONETIZATION_FIELDS, T as TRANSACTION_MANAGEMENT_TYPE, N as TransactionManagementType, B as addDuration, i as calculateCommission, n as calculateCommissionWithSplits, k as calculateOrganizationPayout, C as calculatePeriodRange, D as calculateProratedAmount, j as calculateSplits, J as canCancelSubscription, K as canPauseSubscription, H as canRenewSubscription, L as canResumeSubscription, y as canSelfVerify, d as createIdempotencyManager, f as fromSmallestUnit, w as getAllowedUpdateFields, v as getTransactionType, p as isCategoryValid, u as isManualTransaction, q as isMonetizationTransaction, G as isSubscriptionActive, l as logger, l as loggerDefault, o as resolveCategory, F as resolveIntervalToDuration, r as reverseCommission, m as reverseSplits, s as setLogger, t as toSmallestUnit, x as validateFieldUpdate } from '../actions-
|
|
1
|
+
export { O as DurationUnit, E as EDITABLE_MONETIZATION_FIELDS_PRE_VERIFICATION, h as IdempotencyConfig, c as IdempotencyError, I as IdempotencyManager, e as IdempotencyRecord, g as IdempotencyStore, z as MANUAL_TRANSACTION_CREATE_FIELDS, A as MANUAL_TRANSACTION_UPDATE_FIELDS, b as MemoryIdempotencyStore, M as Money, a as MoneyValue, P as PROTECTED_MONETIZATION_FIELDS, T as TRANSACTION_MANAGEMENT_TYPE, N as TransactionManagementType, B as addDuration, i as calculateCommission, n as calculateCommissionWithSplits, k as calculateOrganizationPayout, C as calculatePeriodRange, D as calculateProratedAmount, j as calculateSplits, J as canCancelSubscription, K as canPauseSubscription, H as canRenewSubscription, L as canResumeSubscription, y as canSelfVerify, d as createIdempotencyManager, f as fromSmallestUnit, w as getAllowedUpdateFields, v as getTransactionType, p as isCategoryValid, u as isManualTransaction, q as isMonetizationTransaction, G as isSubscriptionActive, l as logger, l as loggerDefault, o as resolveCategory, F as resolveIntervalToDuration, r as reverseCommission, m as reverseSplits, s as setLogger, t as toSmallestUnit, x as validateFieldUpdate } from '../actions-Ctf2XUL-.js';
|
|
2
2
|
export { C as CircuitBreaker, w as CircuitBreakerConfig, q as CircuitOpenError, v as CircuitState, x as RetryConfig, n as RetryExhaustedError, y as RetryState, k as calculateDelay, p as createCircuitBreaker, l as isRetryableError, s as resilientExecute, r as retry, j as retryWithResult } from '../retry-80lBCmSe.js';
|
|
3
|
-
import {
|
|
3
|
+
import { B as HooksRegistry, L as Logger } from '../index-C5SsOrV0.js';
|
|
4
4
|
import 'mongoose';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/utils/index.js
CHANGED
|
@@ -810,11 +810,33 @@ function reverseCommission(originalCommission, originalAmount, refundAmount) {
|
|
|
810
810
|
var SPLIT_TYPE = {
|
|
811
811
|
PLATFORM_COMMISSION: "platform_commission",
|
|
812
812
|
AFFILIATE_COMMISSION: "affiliate_commission",
|
|
813
|
+
REFERRAL_COMMISSION: "referral_commission",
|
|
814
|
+
PARTNER_COMMISSION: "partner_commission",
|
|
813
815
|
CUSTOM: "custom"
|
|
814
816
|
};
|
|
817
|
+
var SPLIT_TYPE_VALUES = Object.values(SPLIT_TYPE);
|
|
815
818
|
var SPLIT_STATUS = {
|
|
816
819
|
PENDING: "pending",
|
|
817
|
-
|
|
820
|
+
DUE: "due",
|
|
821
|
+
PAID: "paid",
|
|
822
|
+
WAIVED: "waived",
|
|
823
|
+
CANCELLED: "cancelled"
|
|
824
|
+
};
|
|
825
|
+
var SPLIT_STATUS_VALUES = Object.values(
|
|
826
|
+
SPLIT_STATUS
|
|
827
|
+
);
|
|
828
|
+
var PAYOUT_METHOD = {
|
|
829
|
+
BANK_TRANSFER: "bank_transfer",
|
|
830
|
+
MOBILE_WALLET: "mobile_wallet",
|
|
831
|
+
PLATFORM_BALANCE: "platform_balance",
|
|
832
|
+
CRYPTO: "crypto",
|
|
833
|
+
CHECK: "check",
|
|
834
|
+
MANUAL: "manual"
|
|
835
|
+
};
|
|
836
|
+
var PAYOUT_METHOD_VALUES = Object.values(PAYOUT_METHOD);
|
|
837
|
+
new Set(SPLIT_TYPE_VALUES);
|
|
838
|
+
new Set(SPLIT_STATUS_VALUES);
|
|
839
|
+
new Set(PAYOUT_METHOD_VALUES);
|
|
818
840
|
|
|
819
841
|
// src/utils/commission-split.ts
|
|
820
842
|
function calculateSplits(amount, splitRules = [], gatewayFeeRate = 0) {
|
|
@@ -914,10 +936,43 @@ function calculateCommissionWithSplits(amount, commissionRate, gatewayFeeRate =
|
|
|
914
936
|
}
|
|
915
937
|
};
|
|
916
938
|
}
|
|
939
|
+
|
|
940
|
+
// src/enums/transaction.enums.ts
|
|
941
|
+
var TRANSACTION_TYPE = {
|
|
942
|
+
INCOME: "income",
|
|
943
|
+
EXPENSE: "expense"
|
|
944
|
+
};
|
|
945
|
+
var TRANSACTION_TYPE_VALUES = Object.values(
|
|
946
|
+
TRANSACTION_TYPE
|
|
947
|
+
);
|
|
948
|
+
var TRANSACTION_STATUS = {
|
|
949
|
+
PENDING: "pending",
|
|
950
|
+
PAYMENT_INITIATED: "payment_initiated",
|
|
951
|
+
PROCESSING: "processing",
|
|
952
|
+
REQUIRES_ACTION: "requires_action",
|
|
953
|
+
VERIFIED: "verified",
|
|
954
|
+
COMPLETED: "completed",
|
|
955
|
+
FAILED: "failed",
|
|
956
|
+
CANCELLED: "cancelled",
|
|
957
|
+
EXPIRED: "expired",
|
|
958
|
+
REFUNDED: "refunded",
|
|
959
|
+
PARTIALLY_REFUNDED: "partially_refunded"
|
|
960
|
+
};
|
|
961
|
+
var TRANSACTION_STATUS_VALUES = Object.values(
|
|
962
|
+
TRANSACTION_STATUS
|
|
963
|
+
);
|
|
917
964
|
var LIBRARY_CATEGORIES = {
|
|
918
965
|
SUBSCRIPTION: "subscription",
|
|
919
966
|
PURCHASE: "purchase"
|
|
920
967
|
};
|
|
968
|
+
var LIBRARY_CATEGORY_VALUES = Object.values(
|
|
969
|
+
LIBRARY_CATEGORIES
|
|
970
|
+
);
|
|
971
|
+
new Set(TRANSACTION_TYPE_VALUES);
|
|
972
|
+
new Set(
|
|
973
|
+
TRANSACTION_STATUS_VALUES
|
|
974
|
+
);
|
|
975
|
+
new Set(LIBRARY_CATEGORY_VALUES);
|
|
921
976
|
|
|
922
977
|
// src/utils/category-resolver.ts
|
|
923
978
|
function resolveCategory(entity, monetizationType, categoryMappings = {}) {
|
|
@@ -1028,8 +1083,26 @@ function resolveIntervalToDuration(interval = "month", intervalCount = 1) {
|
|
|
1028
1083
|
|
|
1029
1084
|
// src/enums/subscription.enums.ts
|
|
1030
1085
|
var SUBSCRIPTION_STATUS = {
|
|
1086
|
+
ACTIVE: "active",
|
|
1031
1087
|
PAUSED: "paused",
|
|
1032
|
-
CANCELLED: "cancelled"
|
|
1088
|
+
CANCELLED: "cancelled",
|
|
1089
|
+
EXPIRED: "expired",
|
|
1090
|
+
PENDING: "pending",
|
|
1091
|
+
INACTIVE: "inactive"
|
|
1092
|
+
};
|
|
1093
|
+
var SUBSCRIPTION_STATUS_VALUES = Object.values(
|
|
1094
|
+
SUBSCRIPTION_STATUS
|
|
1095
|
+
);
|
|
1096
|
+
var PLAN_KEYS = {
|
|
1097
|
+
MONTHLY: "monthly",
|
|
1098
|
+
QUARTERLY: "quarterly",
|
|
1099
|
+
YEARLY: "yearly"
|
|
1100
|
+
};
|
|
1101
|
+
var PLAN_KEY_VALUES = Object.values(PLAN_KEYS);
|
|
1102
|
+
new Set(
|
|
1103
|
+
SUBSCRIPTION_STATUS_VALUES
|
|
1104
|
+
);
|
|
1105
|
+
new Set(PLAN_KEY_VALUES);
|
|
1033
1106
|
|
|
1034
1107
|
// src/utils/subscription/actions.ts
|
|
1035
1108
|
function isSubscriptionActive(subscription) {
|