@m5kdev/commons 0.38.8 → 0.38.10
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/dist/src/modules/auth/auth.constants.cjs +2 -0
- package/dist/src/modules/auth/auth.constants.cjs.map +1 -1
- package/dist/src/modules/auth/auth.constants.d.cts +2 -1
- package/dist/src/modules/auth/auth.constants.d.mts +2 -1
- package/dist/src/modules/auth/auth.constants.mjs +2 -1
- package/dist/src/modules/auth/auth.constants.mjs.map +1 -1
- package/dist/src/modules/billing/billing.schema.cjs +34 -0
- package/dist/src/modules/billing/billing.schema.cjs.map +1 -1
- package/dist/src/modules/billing/billing.schema.d.cts +129 -1
- package/dist/src/modules/billing/billing.schema.d.mts +129 -1
- package/dist/src/modules/billing/billing.schema.mjs +28 -1
- package/dist/src/modules/billing/billing.schema.mjs.map +1 -1
- package/dist/src/modules/billing/billing.types.d.cts +19 -9
- package/dist/src/modules/billing/billing.types.d.mts +19 -9
- package/dist/src/modules/billing/billing.utils.cjs +52 -4
- package/dist/src/modules/billing/billing.utils.cjs.map +1 -1
- package/dist/src/modules/billing/billing.utils.d.cts +38 -2
- package/dist/src/modules/billing/billing.utils.d.mts +38 -2
- package/dist/src/modules/billing/billing.utils.mjs +45 -5
- package/dist/src/modules/billing/billing.utils.mjs.map +1 -1
- package/dist/src/modules/schemas/query.schema.d.cts +3 -3
- package/dist/src/modules/schemas/query.schema.d.mts +3 -3
- package/dist/src/modules/tag/tag.schema.d.cts +1 -1
- package/dist/src/modules/tag/tag.schema.d.mts +1 -1
- package/package.json +2 -2
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const ADMIN_CREATE_VERIFIED_USER_HEADER = "Admin-Create-Verified-User";
|
|
4
4
|
const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = "true";
|
|
5
5
|
const USER_LOCALE_HEADER = "User-Locale";
|
|
6
|
+
const USER_CURRENCY_HEADER = "User-Currency";
|
|
6
7
|
//#endregion
|
|
7
8
|
exports.ADMIN_CREATE_VERIFIED_USER_HEADER = ADMIN_CREATE_VERIFIED_USER_HEADER;
|
|
8
9
|
exports.ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE;
|
|
10
|
+
exports.USER_CURRENCY_HEADER = USER_CURRENCY_HEADER;
|
|
9
11
|
exports.USER_LOCALE_HEADER = USER_LOCALE_HEADER;
|
|
10
12
|
|
|
11
13
|
//# sourceMappingURL=auth.constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.constants.cjs","names":[],"sources":["../../../../src/modules/auth/auth.constants.ts"],"sourcesContent":["export const ADMIN_CREATE_VERIFIED_USER_HEADER = \"Admin-Create-Verified-User\" as const;\r\nexport const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = \"true\" as const;\r\nexport const USER_LOCALE_HEADER = \"User-Locale\" as const;\r\n"],"mappings":";;AAAA,MAAa,oCAAoC;AACjD,MAAa,0CAA0C;AACvD,MAAa,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"auth.constants.cjs","names":[],"sources":["../../../../src/modules/auth/auth.constants.ts"],"sourcesContent":["export const ADMIN_CREATE_VERIFIED_USER_HEADER = \"Admin-Create-Verified-User\" as const;\r\nexport const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = \"true\" as const;\r\nexport const USER_LOCALE_HEADER = \"User-Locale\" as const;\r\nexport const USER_CURRENCY_HEADER = \"User-Currency\" as const;\r\n"],"mappings":";;AAAA,MAAa,oCAAoC;AACjD,MAAa,0CAA0C;AACvD,MAAa,qBAAqB;AAClC,MAAa,uBAAuB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
declare const ADMIN_CREATE_VERIFIED_USER_HEADER: "Admin-Create-Verified-User";
|
|
3
3
|
declare const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE: "true";
|
|
4
4
|
declare const USER_LOCALE_HEADER: "User-Locale";
|
|
5
|
+
declare const USER_CURRENCY_HEADER: "User-Currency";
|
|
5
6
|
//#endregion
|
|
6
|
-
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_LOCALE_HEADER };
|
|
7
|
+
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_CURRENCY_HEADER, USER_LOCALE_HEADER };
|
|
7
8
|
//# sourceMappingURL=auth.constants.d.cts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
declare const ADMIN_CREATE_VERIFIED_USER_HEADER: "Admin-Create-Verified-User";
|
|
3
3
|
declare const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE: "true";
|
|
4
4
|
declare const USER_LOCALE_HEADER: "User-Locale";
|
|
5
|
+
declare const USER_CURRENCY_HEADER: "User-Currency";
|
|
5
6
|
//#endregion
|
|
6
|
-
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_LOCALE_HEADER };
|
|
7
|
+
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_CURRENCY_HEADER, USER_LOCALE_HEADER };
|
|
7
8
|
//# sourceMappingURL=auth.constants.d.mts.map
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
const ADMIN_CREATE_VERIFIED_USER_HEADER = "Admin-Create-Verified-User";
|
|
3
3
|
const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = "true";
|
|
4
4
|
const USER_LOCALE_HEADER = "User-Locale";
|
|
5
|
+
const USER_CURRENCY_HEADER = "User-Currency";
|
|
5
6
|
//#endregion
|
|
6
|
-
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_LOCALE_HEADER };
|
|
7
|
+
export { ADMIN_CREATE_VERIFIED_USER_HEADER, ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE, USER_CURRENCY_HEADER, USER_LOCALE_HEADER };
|
|
7
8
|
|
|
8
9
|
//# sourceMappingURL=auth.constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.constants.mjs","names":[],"sources":["../../../../src/modules/auth/auth.constants.ts"],"sourcesContent":["export const ADMIN_CREATE_VERIFIED_USER_HEADER = \"Admin-Create-Verified-User\" as const;\r\nexport const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = \"true\" as const;\r\nexport const USER_LOCALE_HEADER = \"User-Locale\" as const;\r\n"],"mappings":";AAAA,MAAa,oCAAoC;AACjD,MAAa,0CAA0C;AACvD,MAAa,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"auth.constants.mjs","names":[],"sources":["../../../../src/modules/auth/auth.constants.ts"],"sourcesContent":["export const ADMIN_CREATE_VERIFIED_USER_HEADER = \"Admin-Create-Verified-User\" as const;\r\nexport const ADMIN_CREATE_VERIFIED_USER_HEADER_VALUE = \"true\" as const;\r\nexport const USER_LOCALE_HEADER = \"User-Locale\" as const;\r\nexport const USER_CURRENCY_HEADER = \"User-Currency\" as const;\r\n"],"mappings":";AAAA,MAAa,oCAAoC;AACjD,MAAa,0CAA0C;AACvD,MAAa,qBAAqB;AAClC,MAAa,uBAAuB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src_modules_schemas_query_schema = require("../schemas/query.schema.cjs");
|
|
2
3
|
let zod = require("zod");
|
|
3
4
|
//#region src/modules/billing/billing.schema.ts
|
|
4
5
|
const billingSchema = zod.z.object({
|
|
@@ -19,10 +20,43 @@ const billingSchema = zod.z.object({
|
|
|
19
20
|
trialEnd: zod.z.date().nullish(),
|
|
20
21
|
priceId: zod.z.string().nullish(),
|
|
21
22
|
interval: zod.z.string().nullish(),
|
|
23
|
+
intervalCount: zod.z.number().nullish(),
|
|
24
|
+
intervalPicked: zod.z.boolean().nullish(),
|
|
22
25
|
unitAmount: zod.z.number().nullish(),
|
|
23
26
|
discounts: zod.z.array(zod.z.string()).nullish()
|
|
24
27
|
});
|
|
28
|
+
const complimentaryDurationSchema = zod.z.union([
|
|
29
|
+
zod.z.literal("forever"),
|
|
30
|
+
zod.z.literal("once"),
|
|
31
|
+
zod.z.object({ months: zod.z.number().int().positive() })
|
|
32
|
+
]);
|
|
33
|
+
const enrollComplimentaryInputSchema = zod.z.object({
|
|
34
|
+
organizationId: zod.z.string(),
|
|
35
|
+
priceId: zod.z.string(),
|
|
36
|
+
duration: complimentaryDurationSchema
|
|
37
|
+
});
|
|
38
|
+
const organizationIdInputSchema = zod.z.object({ organizationId: zod.z.string() });
|
|
39
|
+
const cancelAdminSubscriptionInputSchema = zod.z.object({
|
|
40
|
+
organizationId: zod.z.string(),
|
|
41
|
+
when: zod.z.enum(["immediate", "period_end"])
|
|
42
|
+
});
|
|
43
|
+
const adminOrganizationBillingRowSchema = zod.z.object({
|
|
44
|
+
id: zod.z.string(),
|
|
45
|
+
organizationId: zod.z.string(),
|
|
46
|
+
organizationName: zod.z.string(),
|
|
47
|
+
currency: zod.z.string().nullable(),
|
|
48
|
+
subscription: billingSchema.nullable()
|
|
49
|
+
});
|
|
50
|
+
const billingAdminListInputSchema = require_src_modules_schemas_query_schema.querySchema;
|
|
51
|
+
const billingAdminListOutputSchema = require_src_modules_schemas_query_schema.queryListOutput(adminOrganizationBillingRowSchema);
|
|
25
52
|
//#endregion
|
|
53
|
+
exports.adminOrganizationBillingRowSchema = adminOrganizationBillingRowSchema;
|
|
54
|
+
exports.billingAdminListInputSchema = billingAdminListInputSchema;
|
|
55
|
+
exports.billingAdminListOutputSchema = billingAdminListOutputSchema;
|
|
26
56
|
exports.billingSchema = billingSchema;
|
|
57
|
+
exports.cancelAdminSubscriptionInputSchema = cancelAdminSubscriptionInputSchema;
|
|
58
|
+
exports.complimentaryDurationSchema = complimentaryDurationSchema;
|
|
59
|
+
exports.enrollComplimentaryInputSchema = enrollComplimentaryInputSchema;
|
|
60
|
+
exports.organizationIdInputSchema = organizationIdInputSchema;
|
|
27
61
|
|
|
28
62
|
//# sourceMappingURL=billing.schema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.schema.cjs","names":["z"],"sources":["../../../../src/modules/billing/billing.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const billingSchema = z.object({\r\n id: z.string(),\r\n plan: z.string(),\r\n referenceId: z.string(),\r\n stripeCustomerId: z.string().nullish(),\r\n stripeSubscriptionId: z.string().nullish(),\r\n status: z.string(),\r\n periodStart: z.date().nullish(),\r\n periodEnd: z.date().nullish(),\r\n cancelAtPeriodEnd: z.boolean().nullish(),\r\n cancelAt: z.date().nullish(),\r\n canceledAt: z.date().nullish(),\r\n seats: z.number().nullish(),\r\n memberId: z.string().nullish(),\r\n trialStart: z.date().nullish(),\r\n trialEnd: z.date().nullish(),\r\n priceId: z.string().nullish(),\r\n interval: z.string().nullish(),\r\n unitAmount: z.number().nullish(),\r\n discounts: z.array(z.string()).nullish(),\r\n});\r\n\r\nexport type BillingSchema = z.infer<typeof billingSchema>;\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"billing.schema.cjs","names":["z","querySchema","queryListOutput"],"sources":["../../../../src/modules/billing/billing.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport { queryListOutput, querySchema } from \"../schemas/query.schema\";\r\n\r\nexport const billingSchema = z.object({\r\n id: z.string(),\r\n plan: z.string(),\r\n referenceId: z.string(),\r\n stripeCustomerId: z.string().nullish(),\r\n stripeSubscriptionId: z.string().nullish(),\r\n status: z.string(),\r\n periodStart: z.date().nullish(),\r\n periodEnd: z.date().nullish(),\r\n cancelAtPeriodEnd: z.boolean().nullish(),\r\n cancelAt: z.date().nullish(),\r\n canceledAt: z.date().nullish(),\r\n seats: z.number().nullish(),\r\n memberId: z.string().nullish(),\r\n trialStart: z.date().nullish(),\r\n trialEnd: z.date().nullish(),\r\n priceId: z.string().nullish(),\r\n interval: z.string().nullish(),\r\n intervalCount: z.number().nullish(),\r\n intervalPicked: z.boolean().nullish(),\r\n unitAmount: z.number().nullish(),\r\n discounts: z.array(z.string()).nullish(),\r\n});\r\n\r\nexport type BillingSchema = z.infer<typeof billingSchema>;\r\n\r\nexport const complimentaryDurationSchema = z.union([\r\n z.literal(\"forever\"),\r\n z.literal(\"once\"),\r\n z.object({ months: z.number().int().positive() }),\r\n]);\r\n\r\nexport const enrollComplimentaryInputSchema = z.object({\r\n organizationId: z.string(),\r\n priceId: z.string(),\r\n duration: complimentaryDurationSchema,\r\n});\r\n\r\nexport const organizationIdInputSchema = z.object({\r\n organizationId: z.string(),\r\n});\r\n\r\nexport const cancelAdminSubscriptionInputSchema = z.object({\r\n organizationId: z.string(),\r\n when: z.enum([\"immediate\", \"period_end\"]),\r\n});\r\n\r\nexport const adminOrganizationBillingRowSchema = z.object({\r\n id: z.string(),\r\n organizationId: z.string(),\r\n organizationName: z.string(),\r\n currency: z.string().nullable(),\r\n subscription: billingSchema.nullable(),\r\n});\r\n\r\nexport const billingAdminListInputSchema = querySchema;\r\nexport const billingAdminListOutputSchema = queryListOutput(adminOrganizationBillingRowSchema);\r\n\r\nexport type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;\r\nexport type EnrollComplimentaryInput = z.infer<typeof enrollComplimentaryInputSchema>;\r\nexport type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;\r\n"],"mappings":";;;;AAGA,MAAa,gBAAgBA,IAAAA,EAAE,OAAO;CACpC,IAAIA,IAAAA,EAAE,QAAQ;CACd,MAAMA,IAAAA,EAAE,QAAQ;CAChB,aAAaA,IAAAA,EAAE,QAAQ;CACvB,kBAAkBA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CACtC,sBAAsBA,IAAAA,EAAE,QAAQ,C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AqCA,IAAAA,EAAE,OAAO;CACzD,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,MAAMA,IAAAA,EAAE,KAAK,CAAC,aAAa,aAAa,CAAC;CAC1C,CAAC;AAEF,MAAa,oCAAoCA,IAAAA,EAAE,OAAO;CACxD,IAAIA,IAAAA,EAAE,QAAQ;CACd,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,kBAAkBA,IAAAA,EAAE,QAAQ;CAC5B,UAAUA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CAC/B,cAAc,cAAc,UAAU;CACvC,CAAC;AAEF,MAAa,8BAA8BC,yCAAAA;AAC3C,MAAa,+BAA+BC,yCAAAA,gBAAgB,kCAAkC"}
|
|
@@ -19,10 +19,138 @@ declare const billingSchema: z.ZodObject<{
|
|
|
19
19
|
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
20
20
|
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
21
|
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
23
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
22
24
|
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
23
25
|
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
24
26
|
}, z.core.$strip>;
|
|
25
27
|
type BillingSchema = z.infer<typeof billingSchema>;
|
|
28
|
+
declare const complimentaryDurationSchema: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
|
|
29
|
+
months: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>]>;
|
|
31
|
+
declare const enrollComplimentaryInputSchema: z.ZodObject<{
|
|
32
|
+
organizationId: z.ZodString;
|
|
33
|
+
priceId: z.ZodString;
|
|
34
|
+
duration: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
|
|
35
|
+
months: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>]>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
declare const organizationIdInputSchema: z.ZodObject<{
|
|
39
|
+
organizationId: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
declare const cancelAdminSubscriptionInputSchema: z.ZodObject<{
|
|
42
|
+
organizationId: z.ZodString;
|
|
43
|
+
when: z.ZodEnum<{
|
|
44
|
+
immediate: "immediate";
|
|
45
|
+
period_end: "period_end";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
declare const adminOrganizationBillingRowSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
organizationId: z.ZodString;
|
|
51
|
+
organizationName: z.ZodString;
|
|
52
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
53
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
plan: z.ZodString;
|
|
56
|
+
referenceId: z.ZodString;
|
|
57
|
+
stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
stripeSubscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
status: z.ZodString;
|
|
60
|
+
periodStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
61
|
+
periodEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
62
|
+
cancelAtPeriodEnd: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
63
|
+
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
64
|
+
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
65
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
66
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
68
|
+
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
69
|
+
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
72
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
73
|
+
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const billingAdminListInputSchema: z.ZodObject<{
|
|
78
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
81
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
82
|
+
asc: "asc";
|
|
83
|
+
desc: "desc";
|
|
84
|
+
}>>;
|
|
85
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
columnId: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<{
|
|
88
|
+
string: "string";
|
|
89
|
+
number: "number";
|
|
90
|
+
boolean: "boolean";
|
|
91
|
+
enum: "enum";
|
|
92
|
+
date: "date";
|
|
93
|
+
jsonArray: "jsonArray";
|
|
94
|
+
}>;
|
|
95
|
+
method: z.ZodEnum<{
|
|
96
|
+
starts_with: "starts_with";
|
|
97
|
+
ends_with: "ends_with";
|
|
98
|
+
contains: "contains";
|
|
99
|
+
equals: "equals";
|
|
100
|
+
greater_than: "greater_than";
|
|
101
|
+
less_than: "less_than";
|
|
102
|
+
on: "on";
|
|
103
|
+
between: "between";
|
|
104
|
+
before: "before";
|
|
105
|
+
after: "after";
|
|
106
|
+
oneOf: "oneOf";
|
|
107
|
+
intersect: "intersect";
|
|
108
|
+
isEmpty: "isEmpty";
|
|
109
|
+
isNotEmpty: "isNotEmpty";
|
|
110
|
+
is_null: "is_null";
|
|
111
|
+
is_not_null: "is_not_null";
|
|
112
|
+
}>;
|
|
113
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
114
|
+
valueTo: z.ZodOptional<z.ZodString>;
|
|
115
|
+
endColumnId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>>;
|
|
117
|
+
q: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
declare const billingAdminListOutputSchema: z.ZodObject<{
|
|
120
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
121
|
+
id: z.ZodString;
|
|
122
|
+
organizationId: z.ZodString;
|
|
123
|
+
organizationName: z.ZodString;
|
|
124
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
125
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
plan: z.ZodString;
|
|
128
|
+
referenceId: z.ZodString;
|
|
129
|
+
stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
stripeSubscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
status: z.ZodString;
|
|
132
|
+
periodStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
133
|
+
periodEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
134
|
+
cancelAtPeriodEnd: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
135
|
+
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
136
|
+
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
137
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
138
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
140
|
+
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
141
|
+
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
143
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
144
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
145
|
+
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
146
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
total: z.ZodNumber;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;
|
|
152
|
+
type EnrollComplimentaryInput = z.infer<typeof enrollComplimentaryInputSchema>;
|
|
153
|
+
type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;
|
|
26
154
|
//#endregion
|
|
27
|
-
export { BillingSchema, billingSchema };
|
|
155
|
+
export { AdminOrganizationBillingRow, BillingSchema, ComplimentaryDuration, EnrollComplimentaryInput, adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
|
|
28
156
|
//# sourceMappingURL=billing.schema.d.cts.map
|
|
@@ -19,10 +19,138 @@ declare const billingSchema: z.ZodObject<{
|
|
|
19
19
|
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
20
20
|
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
21
|
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
23
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
22
24
|
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
23
25
|
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
24
26
|
}, z.core.$strip>;
|
|
25
27
|
type BillingSchema = z.infer<typeof billingSchema>;
|
|
28
|
+
declare const complimentaryDurationSchema: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
|
|
29
|
+
months: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>]>;
|
|
31
|
+
declare const enrollComplimentaryInputSchema: z.ZodObject<{
|
|
32
|
+
organizationId: z.ZodString;
|
|
33
|
+
priceId: z.ZodString;
|
|
34
|
+
duration: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
|
|
35
|
+
months: z.ZodNumber;
|
|
36
|
+
}, z.core.$strip>]>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
declare const organizationIdInputSchema: z.ZodObject<{
|
|
39
|
+
organizationId: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
declare const cancelAdminSubscriptionInputSchema: z.ZodObject<{
|
|
42
|
+
organizationId: z.ZodString;
|
|
43
|
+
when: z.ZodEnum<{
|
|
44
|
+
immediate: "immediate";
|
|
45
|
+
period_end: "period_end";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
declare const adminOrganizationBillingRowSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
organizationId: z.ZodString;
|
|
51
|
+
organizationName: z.ZodString;
|
|
52
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
53
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
plan: z.ZodString;
|
|
56
|
+
referenceId: z.ZodString;
|
|
57
|
+
stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
stripeSubscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
status: z.ZodString;
|
|
60
|
+
periodStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
61
|
+
periodEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
62
|
+
cancelAtPeriodEnd: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
63
|
+
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
64
|
+
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
65
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
66
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
68
|
+
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
69
|
+
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
72
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
73
|
+
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const billingAdminListInputSchema: z.ZodObject<{
|
|
78
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
81
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
82
|
+
asc: "asc";
|
|
83
|
+
desc: "desc";
|
|
84
|
+
}>>;
|
|
85
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
columnId: z.ZodString;
|
|
87
|
+
type: z.ZodEnum<{
|
|
88
|
+
string: "string";
|
|
89
|
+
number: "number";
|
|
90
|
+
boolean: "boolean";
|
|
91
|
+
enum: "enum";
|
|
92
|
+
date: "date";
|
|
93
|
+
jsonArray: "jsonArray";
|
|
94
|
+
}>;
|
|
95
|
+
method: z.ZodEnum<{
|
|
96
|
+
starts_with: "starts_with";
|
|
97
|
+
ends_with: "ends_with";
|
|
98
|
+
contains: "contains";
|
|
99
|
+
equals: "equals";
|
|
100
|
+
greater_than: "greater_than";
|
|
101
|
+
less_than: "less_than";
|
|
102
|
+
on: "on";
|
|
103
|
+
between: "between";
|
|
104
|
+
before: "before";
|
|
105
|
+
after: "after";
|
|
106
|
+
oneOf: "oneOf";
|
|
107
|
+
intersect: "intersect";
|
|
108
|
+
isEmpty: "isEmpty";
|
|
109
|
+
isNotEmpty: "isNotEmpty";
|
|
110
|
+
is_null: "is_null";
|
|
111
|
+
is_not_null: "is_not_null";
|
|
112
|
+
}>;
|
|
113
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>;
|
|
114
|
+
valueTo: z.ZodOptional<z.ZodString>;
|
|
115
|
+
endColumnId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>>>;
|
|
117
|
+
q: z.ZodOptional<z.ZodString>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
declare const billingAdminListOutputSchema: z.ZodObject<{
|
|
120
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
121
|
+
id: z.ZodString;
|
|
122
|
+
organizationId: z.ZodString;
|
|
123
|
+
organizationName: z.ZodString;
|
|
124
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
125
|
+
subscription: z.ZodNullable<z.ZodObject<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
plan: z.ZodString;
|
|
128
|
+
referenceId: z.ZodString;
|
|
129
|
+
stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
stripeSubscriptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
status: z.ZodString;
|
|
132
|
+
periodStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
133
|
+
periodEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
134
|
+
cancelAtPeriodEnd: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
135
|
+
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
136
|
+
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
137
|
+
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
138
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
+
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
140
|
+
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
141
|
+
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
interval: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
143
|
+
intervalCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
144
|
+
intervalPicked: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
145
|
+
unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
146
|
+
discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
total: z.ZodNumber;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;
|
|
152
|
+
type EnrollComplimentaryInput = z.infer<typeof enrollComplimentaryInputSchema>;
|
|
153
|
+
type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;
|
|
26
154
|
//#endregion
|
|
27
|
-
export { BillingSchema, billingSchema };
|
|
155
|
+
export { AdminOrganizationBillingRow, BillingSchema, ComplimentaryDuration, EnrollComplimentaryInput, adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
|
|
28
156
|
//# sourceMappingURL=billing.schema.d.mts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { queryListOutput, querySchema } from "../schemas/query.schema.mjs";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
//#region src/modules/billing/billing.schema.ts
|
|
3
4
|
const billingSchema = z.object({
|
|
@@ -18,10 +19,36 @@ const billingSchema = z.object({
|
|
|
18
19
|
trialEnd: z.date().nullish(),
|
|
19
20
|
priceId: z.string().nullish(),
|
|
20
21
|
interval: z.string().nullish(),
|
|
22
|
+
intervalCount: z.number().nullish(),
|
|
23
|
+
intervalPicked: z.boolean().nullish(),
|
|
21
24
|
unitAmount: z.number().nullish(),
|
|
22
25
|
discounts: z.array(z.string()).nullish()
|
|
23
26
|
});
|
|
27
|
+
const complimentaryDurationSchema = z.union([
|
|
28
|
+
z.literal("forever"),
|
|
29
|
+
z.literal("once"),
|
|
30
|
+
z.object({ months: z.number().int().positive() })
|
|
31
|
+
]);
|
|
32
|
+
const enrollComplimentaryInputSchema = z.object({
|
|
33
|
+
organizationId: z.string(),
|
|
34
|
+
priceId: z.string(),
|
|
35
|
+
duration: complimentaryDurationSchema
|
|
36
|
+
});
|
|
37
|
+
const organizationIdInputSchema = z.object({ organizationId: z.string() });
|
|
38
|
+
const cancelAdminSubscriptionInputSchema = z.object({
|
|
39
|
+
organizationId: z.string(),
|
|
40
|
+
when: z.enum(["immediate", "period_end"])
|
|
41
|
+
});
|
|
42
|
+
const adminOrganizationBillingRowSchema = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
organizationId: z.string(),
|
|
45
|
+
organizationName: z.string(),
|
|
46
|
+
currency: z.string().nullable(),
|
|
47
|
+
subscription: billingSchema.nullable()
|
|
48
|
+
});
|
|
49
|
+
const billingAdminListInputSchema = querySchema;
|
|
50
|
+
const billingAdminListOutputSchema = queryListOutput(adminOrganizationBillingRowSchema);
|
|
24
51
|
//#endregion
|
|
25
|
-
export { billingSchema };
|
|
52
|
+
export { adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
|
|
26
53
|
|
|
27
54
|
//# sourceMappingURL=billing.schema.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.schema.mjs","names":[],"sources":["../../../../src/modules/billing/billing.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\n\r\nexport const billingSchema = z.object({\r\n id: z.string(),\r\n plan: z.string(),\r\n referenceId: z.string(),\r\n stripeCustomerId: z.string().nullish(),\r\n stripeSubscriptionId: z.string().nullish(),\r\n status: z.string(),\r\n periodStart: z.date().nullish(),\r\n periodEnd: z.date().nullish(),\r\n cancelAtPeriodEnd: z.boolean().nullish(),\r\n cancelAt: z.date().nullish(),\r\n canceledAt: z.date().nullish(),\r\n seats: z.number().nullish(),\r\n memberId: z.string().nullish(),\r\n trialStart: z.date().nullish(),\r\n trialEnd: z.date().nullish(),\r\n priceId: z.string().nullish(),\r\n interval: z.string().nullish(),\r\n unitAmount: z.number().nullish(),\r\n discounts: z.array(z.string()).nullish(),\r\n});\r\n\r\nexport type BillingSchema = z.infer<typeof billingSchema>;\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"billing.schema.mjs","names":[],"sources":["../../../../src/modules/billing/billing.schema.ts"],"sourcesContent":["import { z } from \"zod\";\r\nimport { queryListOutput, querySchema } from \"../schemas/query.schema\";\r\n\r\nexport const billingSchema = z.object({\r\n id: z.string(),\r\n plan: z.string(),\r\n referenceId: z.string(),\r\n stripeCustomerId: z.string().nullish(),\r\n stripeSubscriptionId: z.string().nullish(),\r\n status: z.string(),\r\n periodStart: z.date().nullish(),\r\n periodEnd: z.date().nullish(),\r\n cancelAtPeriodEnd: z.boolean().nullish(),\r\n cancelAt: z.date().nullish(),\r\n canceledAt: z.date().nullish(),\r\n seats: z.number().nullish(),\r\n memberId: z.string().nullish(),\r\n trialStart: z.date().nullish(),\r\n trialEnd: z.date().nullish(),\r\n priceId: z.string().nullish(),\r\n interval: z.string().nullish(),\r\n intervalCount: z.number().nullish(),\r\n intervalPicked: z.boolean().nullish(),\r\n unitAmount: z.number().nullish(),\r\n discounts: z.array(z.string()).nullish(),\r\n});\r\n\r\nexport type BillingSchema = z.infer<typeof billingSchema>;\r\n\r\nexport const complimentaryDurationSchema = z.union([\r\n z.literal(\"forever\"),\r\n z.literal(\"once\"),\r\n z.object({ months: z.number().int().positive() }),\r\n]);\r\n\r\nexport const enrollComplimentaryInputSchema = z.object({\r\n organizationId: z.string(),\r\n priceId: z.string(),\r\n duration: complimentaryDurationSchema,\r\n});\r\n\r\nexport const organizationIdInputSchema = z.object({\r\n organizationId: z.string(),\r\n});\r\n\r\nexport const cancelAdminSubscriptionInputSchema = z.object({\r\n organizationId: z.string(),\r\n when: z.enum([\"immediate\", \"period_end\"]),\r\n});\r\n\r\nexport const adminOrganizationBillingRowSchema = z.object({\r\n id: z.string(),\r\n organizationId: z.string(),\r\n organizationName: z.string(),\r\n currency: z.string().nullable(),\r\n subscription: billingSchema.nullable(),\r\n});\r\n\r\nexport const billingAdminListInputSchema = querySchema;\r\nexport const billingAdminListOutputSchema = queryListOutput(adminOrganizationBillingRowSchema);\r\n\r\nexport type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;\r\n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A4B,EAAE,OAAO,EAChD,gBAAgB,EAAE,QAAQ,EAC3B,CAAC;AAEF,MAAa,qCAAqC,EAAE,OAAO;CACzD,gBAAgB,EAAE,QAAQ;CAC1B,MAAM,EAAE,KAAK,CAAC,aAAa,aAAa,CAAC;CAC1C,CAAC;AAEF,MAAa,oCAAoC,EAAE,OAAO;CACxD,IAAI,EAAE,QAAQ;CACd,gBAAgB,EAAE,QAAQ;CAC1B,kBAAkB,EAAE,QAAQ;CAC5B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,cAAc,cAAc,UAAU;CACvC,CAAC;AAEF,MAAa,8BAA8B;AAC3C,MAAa,+BAA+B,gBAAgB,kCAAkC"}
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
//#region src/modules/billing/billing.types.d.ts
|
|
2
|
+
type StripePlanPrice = {
|
|
3
|
+
priceId: string;
|
|
4
|
+
interval: "day" | "week" | "month" | "year";
|
|
5
|
+
intervalCount: number;
|
|
6
|
+
unitAmount?: number;
|
|
7
|
+
};
|
|
8
|
+
type StripePlanProduct = {
|
|
9
|
+
id: string;
|
|
10
|
+
prices: StripePlanPrice[];
|
|
11
|
+
defaultPriceId?: string;
|
|
12
|
+
};
|
|
2
13
|
type StripePlan = {
|
|
3
14
|
name: string;
|
|
4
|
-
|
|
5
|
-
priceUnitAmount?: number;
|
|
6
|
-
annualDiscountPriceId?: string;
|
|
7
|
-
annualPriceUnitAmount?: number;
|
|
15
|
+
products: Record<string, StripePlanProduct>;
|
|
8
16
|
freeTrial?: {
|
|
9
17
|
days: number;
|
|
10
18
|
seats?: number;
|
|
11
19
|
};
|
|
12
20
|
};
|
|
13
21
|
type StripePlansConfig = {
|
|
14
|
-
|
|
22
|
+
defaultCurrency: string;
|
|
23
|
+
trialRequiresPaymentMethod?: boolean;
|
|
24
|
+
trialPlanName?: Record<string, string>;
|
|
15
25
|
seatBilling?: boolean;
|
|
16
26
|
nonBillableRoleKeys?: readonly string[];
|
|
17
27
|
production: StripePlan[];
|
|
18
28
|
sandbox: StripePlan[];
|
|
19
|
-
trialPlanName?: string;
|
|
20
29
|
};
|
|
21
30
|
type ResolvedStripePlans = {
|
|
22
31
|
plans: StripePlan[];
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
trialPlanName: Record<string, string>;
|
|
33
|
+
trialRequiresPaymentMethod: boolean;
|
|
34
|
+
defaultCurrency: string;
|
|
25
35
|
seatBilling: boolean;
|
|
26
36
|
nonBillableRoleKeys: readonly string[];
|
|
27
37
|
};
|
|
28
38
|
//#endregion
|
|
29
|
-
export { ResolvedStripePlans, StripePlan, StripePlansConfig };
|
|
39
|
+
export { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
|
|
30
40
|
//# sourceMappingURL=billing.types.d.cts.map
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
//#region src/modules/billing/billing.types.d.ts
|
|
2
|
+
type StripePlanPrice = {
|
|
3
|
+
priceId: string;
|
|
4
|
+
interval: "day" | "week" | "month" | "year";
|
|
5
|
+
intervalCount: number;
|
|
6
|
+
unitAmount?: number;
|
|
7
|
+
};
|
|
8
|
+
type StripePlanProduct = {
|
|
9
|
+
id: string;
|
|
10
|
+
prices: StripePlanPrice[];
|
|
11
|
+
defaultPriceId?: string;
|
|
12
|
+
};
|
|
2
13
|
type StripePlan = {
|
|
3
14
|
name: string;
|
|
4
|
-
|
|
5
|
-
priceUnitAmount?: number;
|
|
6
|
-
annualDiscountPriceId?: string;
|
|
7
|
-
annualPriceUnitAmount?: number;
|
|
15
|
+
products: Record<string, StripePlanProduct>;
|
|
8
16
|
freeTrial?: {
|
|
9
17
|
days: number;
|
|
10
18
|
seats?: number;
|
|
11
19
|
};
|
|
12
20
|
};
|
|
13
21
|
type StripePlansConfig = {
|
|
14
|
-
|
|
22
|
+
defaultCurrency: string;
|
|
23
|
+
trialRequiresPaymentMethod?: boolean;
|
|
24
|
+
trialPlanName?: Record<string, string>;
|
|
15
25
|
seatBilling?: boolean;
|
|
16
26
|
nonBillableRoleKeys?: readonly string[];
|
|
17
27
|
production: StripePlan[];
|
|
18
28
|
sandbox: StripePlan[];
|
|
19
|
-
trialPlanName?: string;
|
|
20
29
|
};
|
|
21
30
|
type ResolvedStripePlans = {
|
|
22
31
|
plans: StripePlan[];
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
trialPlanName: Record<string, string>;
|
|
33
|
+
trialRequiresPaymentMethod: boolean;
|
|
34
|
+
defaultCurrency: string;
|
|
25
35
|
seatBilling: boolean;
|
|
26
36
|
nonBillableRoleKeys: readonly string[];
|
|
27
37
|
};
|
|
28
38
|
//#endregion
|
|
29
|
-
export { ResolvedStripePlans, StripePlan, StripePlansConfig };
|
|
39
|
+
export { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
|
|
30
40
|
//# sourceMappingURL=billing.types.d.mts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/modules/billing/billing.utils.ts
|
|
3
3
|
const getEnvironmentPlans = (plansConfig, environment = "sandbox") => {
|
|
4
|
-
const plans = environment === "production" ? plansConfig.production : plansConfig.sandbox;
|
|
5
4
|
return {
|
|
6
|
-
plans,
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
plans: environment === "production" ? plansConfig.production : plansConfig.sandbox,
|
|
6
|
+
trialPlanName: plansConfig.trialPlanName ?? {},
|
|
7
|
+
trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,
|
|
8
|
+
defaultCurrency: plansConfig.defaultCurrency,
|
|
9
9
|
seatBilling: plansConfig.seatBilling ?? false,
|
|
10
10
|
nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? []
|
|
11
11
|
};
|
|
@@ -18,8 +18,56 @@ const formatPlanAmount = ({ unitAmount, currency }) => {
|
|
|
18
18
|
maximumFractionDigits: 2
|
|
19
19
|
}).format(unitAmount / 100);
|
|
20
20
|
};
|
|
21
|
+
function listPlanPrices(plan) {
|
|
22
|
+
return Object.values(plan.products).flatMap((product) => product.prices);
|
|
23
|
+
}
|
|
24
|
+
function catalogCurrencyKeys(plans) {
|
|
25
|
+
const keys = /* @__PURE__ */ new Set();
|
|
26
|
+
for (const plan of plans) for (const currency of Object.keys(plan.products)) keys.add(currency);
|
|
27
|
+
return [...keys];
|
|
28
|
+
}
|
|
29
|
+
function findPlanByPriceId(plans, priceId) {
|
|
30
|
+
return plans.find((plan) => listPlanPrices(plan).some((price) => price.priceId === priceId));
|
|
31
|
+
}
|
|
32
|
+
function findPriceCurrency(plan, priceId) {
|
|
33
|
+
for (const [currency, product] of Object.entries(plan.products)) if (product.prices.some((price) => price.priceId === priceId)) return currency;
|
|
34
|
+
}
|
|
35
|
+
function findTrialPlan({ plans, trialPlanName, currency }) {
|
|
36
|
+
const name = trialPlanName[currency];
|
|
37
|
+
if (!name) return void 0;
|
|
38
|
+
return plans.find((plan) => plan.name === name);
|
|
39
|
+
}
|
|
40
|
+
function findDefaultTrialPrice({ plan, currency }) {
|
|
41
|
+
const product = plan.products[currency];
|
|
42
|
+
if (!product?.defaultPriceId) return void 0;
|
|
43
|
+
return product.prices.find((price) => price.priceId === product.defaultPriceId);
|
|
44
|
+
}
|
|
45
|
+
function listPlanSelectPrices({ plan, currency, trialRequiresPaymentMethod }) {
|
|
46
|
+
const product = plan.products[currency];
|
|
47
|
+
if (!product) return [];
|
|
48
|
+
if (trialRequiresPaymentMethod && product.defaultPriceId) return product.prices.filter((price) => price.priceId === product.defaultPriceId);
|
|
49
|
+
return product.prices;
|
|
50
|
+
}
|
|
51
|
+
function formatBillingInterval({ interval, intervalCount }) {
|
|
52
|
+
const count = intervalCount ?? 1;
|
|
53
|
+
if (!interval) return "";
|
|
54
|
+
if (count === 1 && interval === "month") return "Monthly";
|
|
55
|
+
if (count === 1 && interval === "year") return "Yearly";
|
|
56
|
+
if (count === 1 && interval === "week") return "Weekly";
|
|
57
|
+
if (count === 1 && interval === "day") return "Daily";
|
|
58
|
+
if (interval === "month" && count === 3) return "Every 3 months";
|
|
59
|
+
return `Every ${count} ${interval}${count === 1 ? "" : "s"}`;
|
|
60
|
+
}
|
|
21
61
|
//#endregion
|
|
62
|
+
exports.catalogCurrencyKeys = catalogCurrencyKeys;
|
|
63
|
+
exports.findDefaultTrialPrice = findDefaultTrialPrice;
|
|
64
|
+
exports.findPlanByPriceId = findPlanByPriceId;
|
|
65
|
+
exports.findPriceCurrency = findPriceCurrency;
|
|
66
|
+
exports.findTrialPlan = findTrialPlan;
|
|
67
|
+
exports.formatBillingInterval = formatBillingInterval;
|
|
22
68
|
exports.formatPlanAmount = formatPlanAmount;
|
|
23
69
|
exports.getEnvironmentPlans = getEnvironmentPlans;
|
|
70
|
+
exports.listPlanPrices = listPlanPrices;
|
|
71
|
+
exports.listPlanSelectPrices = listPlanSelectPrices;
|
|
24
72
|
|
|
25
73
|
//# sourceMappingURL=billing.utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.utils.cjs","names":[],"sources":["../../../../src/modules/billing/billing.utils.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"billing.utils.cjs","names":[],"sources":["../../../../src/modules/billing/billing.utils.ts"],"sourcesContent":["import type {\r\n ResolvedStripePlans,\r\n StripePlan,\r\n StripePlanPrice,\r\n StripePlansConfig,\r\n} from \"./billing.types\";\r\n\r\nexport const getEnvironmentPlans = (\r\n plansConfig: StripePlansConfig,\r\n environment = \"sandbox\"\r\n): ResolvedStripePlans => {\r\n const isProduction = environment === \"production\";\r\n const plans = isProduction ? plansConfig.production : plansConfig.sandbox;\r\n return {\r\n plans,\r\n trialPlanName: plansConfig.trialPlanName ?? {},\r\n trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,\r\n defaultCurrency: plansConfig.defaultCurrency,\r\n seatBilling: plansConfig.seatBilling ?? false,\r\n nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? [],\r\n };\r\n};\r\n\r\nexport const formatPlanAmount = ({\r\n unitAmount,\r\n currency,\r\n}: {\r\n unitAmount: number;\r\n currency: string;\r\n}): string => {\r\n return new Intl.NumberFormat(\"en-US\", {\r\n style: \"currency\",\r\n currency: currency.toUpperCase(),\r\n minimumFractionDigits: 0,\r\n maximumFractionDigits: 2,\r\n }).format(unitAmount / 100);\r\n};\r\n\r\nexport function listPlanPrices(plan: StripePlan): StripePlanPrice[] {\r\n return Object.values(plan.products).flatMap((product) => product.prices);\r\n}\r\n\r\nexport function catalogCurrencyKeys(plans: readonly StripePlan[]): string[] {\r\n const keys = new Set<string>();\r\n for (const plan of plans) {\r\n for (const currency of Object.keys(plan.products)) {\r\n keys.add(currency);\r\n }\r\n }\r\n return [...keys];\r\n}\r\n\r\nexport function findPlanByPriceId(\r\n plans: readonly StripePlan[],\r\n priceId: string\r\n): StripePlan | undefined {\r\n return plans.find((plan) => listPlanPrices(plan).some((price) => price.priceId === priceId));\r\n}\r\n\r\nexport function findPriceCurrency(plan: StripePlan, priceId: string): string | undefined {\r\n for (const [currency, product] of Object.entries(plan.products)) {\r\n if (product.prices.some((price) => price.priceId === priceId)) return currency;\r\n }\r\n return undefined;\r\n}\r\n\r\nexport function findTrialPlan({\r\n plans,\r\n trialPlanName,\r\n currency,\r\n}: {\r\n plans: readonly StripePlan[];\r\n trialPlanName: Record<string, string>;\r\n currency: string;\r\n}): StripePlan | undefined {\r\n const name = trialPlanName[currency];\r\n if (!name) return undefined;\r\n return plans.find((plan) => plan.name === name);\r\n}\r\n\r\nexport function findDefaultTrialPrice({\r\n plan,\r\n currency,\r\n}: {\r\n plan: StripePlan;\r\n currency: string;\r\n}): StripePlanPrice | undefined {\r\n const product = plan.products[currency];\r\n if (!product?.defaultPriceId) return undefined;\r\n return product.prices.find((price) => price.priceId === product.defaultPriceId);\r\n}\r\n\r\nexport function listPlanSelectPrices({\r\n plan,\r\n currency,\r\n trialRequiresPaymentMethod,\r\n}: {\r\n plan: StripePlan;\r\n currency: string;\r\n trialRequiresPaymentMethod?: boolean;\r\n}): StripePlanPrice[] {\r\n const product = plan.products[currency];\r\n if (!product) return [];\r\n if (trialRequiresPaymentMethod && product.defaultPriceId) {\r\n return product.prices.filter((price) => price.priceId === product.defaultPriceId);\r\n }\r\n return product.prices;\r\n}\r\n\r\nexport function formatBillingInterval({\r\n interval,\r\n intervalCount,\r\n}: {\r\n interval?: string | null;\r\n intervalCount?: number | null;\r\n}): string {\r\n const count = intervalCount ?? 1;\r\n if (!interval) return \"\";\r\n if (count === 1 && interval === \"month\") return \"Monthly\";\r\n if (count === 1 && interval === \"year\") return \"Yearly\";\r\n if (count === 1 && interval === \"week\") return \"Weekly\";\r\n if (count === 1 && interval === \"day\") return \"Daily\";\r\n if (interval === \"month\" && count === 3) return \"Every 3 months\";\r\n return `Every ${count} ${interval}${count === 1 ? \"\" : \"s\"}`;\r\n}\r\n"],"mappings":";;AAOA,MAAa,uBACX,aACA,cAAc,cACU;AAGxB,QAAO;EACL,OAHmB,gBAAgB,eACR,YAAY,aAAa,YAAY;EAGhE,eAAe,YAAY,iBAAiB,EAAE;EAC9C,4BAA4B,YAAY,8BAA8B;EACtE,iBAAiB,YAAY;EAC7B,aAAa,YAAY,eAAe;EACxC,qBAAqB,YAAY,uBAAuB,EAAE;EAC3D;;AAGH,MAAa,oBAAoB,EAC/B,YACA,eAIY;AACZ,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP,UAAU,SAAS,aAAa;EAChC,uBAAuB;EACvB,uBAAuB;EACxB,CAAC,CAAC,OAAO,aAAa,IAAI;;AAG7B,SAAgB,eAAe,MAAqC;AAClE,QAAO,OAAO,OAAO,KAAK,SAAS,CAAC,SAAS,YAAY,QAAQ,OAAO;;AAG1E,SAAgB,oBAAoB,OAAwC;CAC1E,MAAM,uBAAO,IAAI,KAAa;AAC9B,MAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,YAAY,OAAO,KAAK,KAAK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AChD,QAAO,SAAS,MAAM,GAAG,WAAW,UAAU,IAAI,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedStripePlans, StripePlansConfig } from "./billing.types.cjs";
|
|
1
|
+
import { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlansConfig } from "./billing.types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/billing/billing.utils.d.ts
|
|
4
4
|
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) => ResolvedStripePlans;
|
|
@@ -9,6 +9,42 @@ declare const formatPlanAmount: ({
|
|
|
9
9
|
unitAmount: number;
|
|
10
10
|
currency: string;
|
|
11
11
|
}) => string;
|
|
12
|
+
declare function listPlanPrices(plan: StripePlan): StripePlanPrice[];
|
|
13
|
+
declare function catalogCurrencyKeys(plans: readonly StripePlan[]): string[];
|
|
14
|
+
declare function findPlanByPriceId(plans: readonly StripePlan[], priceId: string): StripePlan | undefined;
|
|
15
|
+
declare function findPriceCurrency(plan: StripePlan, priceId: string): string | undefined;
|
|
16
|
+
declare function findTrialPlan({
|
|
17
|
+
plans,
|
|
18
|
+
trialPlanName,
|
|
19
|
+
currency
|
|
20
|
+
}: {
|
|
21
|
+
plans: readonly StripePlan[];
|
|
22
|
+
trialPlanName: Record<string, string>;
|
|
23
|
+
currency: string;
|
|
24
|
+
}): StripePlan | undefined;
|
|
25
|
+
declare function findDefaultTrialPrice({
|
|
26
|
+
plan,
|
|
27
|
+
currency
|
|
28
|
+
}: {
|
|
29
|
+
plan: StripePlan;
|
|
30
|
+
currency: string;
|
|
31
|
+
}): StripePlanPrice | undefined;
|
|
32
|
+
declare function listPlanSelectPrices({
|
|
33
|
+
plan,
|
|
34
|
+
currency,
|
|
35
|
+
trialRequiresPaymentMethod
|
|
36
|
+
}: {
|
|
37
|
+
plan: StripePlan;
|
|
38
|
+
currency: string;
|
|
39
|
+
trialRequiresPaymentMethod?: boolean;
|
|
40
|
+
}): StripePlanPrice[];
|
|
41
|
+
declare function formatBillingInterval({
|
|
42
|
+
interval,
|
|
43
|
+
intervalCount
|
|
44
|
+
}: {
|
|
45
|
+
interval?: string | null;
|
|
46
|
+
intervalCount?: number | null;
|
|
47
|
+
}): string;
|
|
12
48
|
//#endregion
|
|
13
|
-
export { formatPlanAmount, getEnvironmentPlans };
|
|
49
|
+
export { catalogCurrencyKeys, findDefaultTrialPrice, findPlanByPriceId, findPriceCurrency, findTrialPlan, formatBillingInterval, formatPlanAmount, getEnvironmentPlans, listPlanPrices, listPlanSelectPrices };
|
|
14
50
|
//# sourceMappingURL=billing.utils.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedStripePlans, StripePlansConfig } from "./billing.types.mjs";
|
|
1
|
+
import { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlansConfig } from "./billing.types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/billing/billing.utils.d.ts
|
|
4
4
|
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) => ResolvedStripePlans;
|
|
@@ -9,6 +9,42 @@ declare const formatPlanAmount: ({
|
|
|
9
9
|
unitAmount: number;
|
|
10
10
|
currency: string;
|
|
11
11
|
}) => string;
|
|
12
|
+
declare function listPlanPrices(plan: StripePlan): StripePlanPrice[];
|
|
13
|
+
declare function catalogCurrencyKeys(plans: readonly StripePlan[]): string[];
|
|
14
|
+
declare function findPlanByPriceId(plans: readonly StripePlan[], priceId: string): StripePlan | undefined;
|
|
15
|
+
declare function findPriceCurrency(plan: StripePlan, priceId: string): string | undefined;
|
|
16
|
+
declare function findTrialPlan({
|
|
17
|
+
plans,
|
|
18
|
+
trialPlanName,
|
|
19
|
+
currency
|
|
20
|
+
}: {
|
|
21
|
+
plans: readonly StripePlan[];
|
|
22
|
+
trialPlanName: Record<string, string>;
|
|
23
|
+
currency: string;
|
|
24
|
+
}): StripePlan | undefined;
|
|
25
|
+
declare function findDefaultTrialPrice({
|
|
26
|
+
plan,
|
|
27
|
+
currency
|
|
28
|
+
}: {
|
|
29
|
+
plan: StripePlan;
|
|
30
|
+
currency: string;
|
|
31
|
+
}): StripePlanPrice | undefined;
|
|
32
|
+
declare function listPlanSelectPrices({
|
|
33
|
+
plan,
|
|
34
|
+
currency,
|
|
35
|
+
trialRequiresPaymentMethod
|
|
36
|
+
}: {
|
|
37
|
+
plan: StripePlan;
|
|
38
|
+
currency: string;
|
|
39
|
+
trialRequiresPaymentMethod?: boolean;
|
|
40
|
+
}): StripePlanPrice[];
|
|
41
|
+
declare function formatBillingInterval({
|
|
42
|
+
interval,
|
|
43
|
+
intervalCount
|
|
44
|
+
}: {
|
|
45
|
+
interval?: string | null;
|
|
46
|
+
intervalCount?: number | null;
|
|
47
|
+
}): string;
|
|
12
48
|
//#endregion
|
|
13
|
-
export { formatPlanAmount, getEnvironmentPlans };
|
|
49
|
+
export { catalogCurrencyKeys, findDefaultTrialPrice, findPlanByPriceId, findPriceCurrency, findTrialPlan, formatBillingInterval, formatPlanAmount, getEnvironmentPlans, listPlanPrices, listPlanSelectPrices };
|
|
14
50
|
//# sourceMappingURL=billing.utils.d.mts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
//#region src/modules/billing/billing.utils.ts
|
|
2
2
|
const getEnvironmentPlans = (plansConfig, environment = "sandbox") => {
|
|
3
|
-
const plans = environment === "production" ? plansConfig.production : plansConfig.sandbox;
|
|
4
3
|
return {
|
|
5
|
-
plans,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
plans: environment === "production" ? plansConfig.production : plansConfig.sandbox,
|
|
5
|
+
trialPlanName: plansConfig.trialPlanName ?? {},
|
|
6
|
+
trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,
|
|
7
|
+
defaultCurrency: plansConfig.defaultCurrency,
|
|
8
8
|
seatBilling: plansConfig.seatBilling ?? false,
|
|
9
9
|
nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? []
|
|
10
10
|
};
|
|
@@ -17,7 +17,47 @@ const formatPlanAmount = ({ unitAmount, currency }) => {
|
|
|
17
17
|
maximumFractionDigits: 2
|
|
18
18
|
}).format(unitAmount / 100);
|
|
19
19
|
};
|
|
20
|
+
function listPlanPrices(plan) {
|
|
21
|
+
return Object.values(plan.products).flatMap((product) => product.prices);
|
|
22
|
+
}
|
|
23
|
+
function catalogCurrencyKeys(plans) {
|
|
24
|
+
const keys = /* @__PURE__ */ new Set();
|
|
25
|
+
for (const plan of plans) for (const currency of Object.keys(plan.products)) keys.add(currency);
|
|
26
|
+
return [...keys];
|
|
27
|
+
}
|
|
28
|
+
function findPlanByPriceId(plans, priceId) {
|
|
29
|
+
return plans.find((plan) => listPlanPrices(plan).some((price) => price.priceId === priceId));
|
|
30
|
+
}
|
|
31
|
+
function findPriceCurrency(plan, priceId) {
|
|
32
|
+
for (const [currency, product] of Object.entries(plan.products)) if (product.prices.some((price) => price.priceId === priceId)) return currency;
|
|
33
|
+
}
|
|
34
|
+
function findTrialPlan({ plans, trialPlanName, currency }) {
|
|
35
|
+
const name = trialPlanName[currency];
|
|
36
|
+
if (!name) return void 0;
|
|
37
|
+
return plans.find((plan) => plan.name === name);
|
|
38
|
+
}
|
|
39
|
+
function findDefaultTrialPrice({ plan, currency }) {
|
|
40
|
+
const product = plan.products[currency];
|
|
41
|
+
if (!product?.defaultPriceId) return void 0;
|
|
42
|
+
return product.prices.find((price) => price.priceId === product.defaultPriceId);
|
|
43
|
+
}
|
|
44
|
+
function listPlanSelectPrices({ plan, currency, trialRequiresPaymentMethod }) {
|
|
45
|
+
const product = plan.products[currency];
|
|
46
|
+
if (!product) return [];
|
|
47
|
+
if (trialRequiresPaymentMethod && product.defaultPriceId) return product.prices.filter((price) => price.priceId === product.defaultPriceId);
|
|
48
|
+
return product.prices;
|
|
49
|
+
}
|
|
50
|
+
function formatBillingInterval({ interval, intervalCount }) {
|
|
51
|
+
const count = intervalCount ?? 1;
|
|
52
|
+
if (!interval) return "";
|
|
53
|
+
if (count === 1 && interval === "month") return "Monthly";
|
|
54
|
+
if (count === 1 && interval === "year") return "Yearly";
|
|
55
|
+
if (count === 1 && interval === "week") return "Weekly";
|
|
56
|
+
if (count === 1 && interval === "day") return "Daily";
|
|
57
|
+
if (interval === "month" && count === 3) return "Every 3 months";
|
|
58
|
+
return `Every ${count} ${interval}${count === 1 ? "" : "s"}`;
|
|
59
|
+
}
|
|
20
60
|
//#endregion
|
|
21
|
-
export { formatPlanAmount, getEnvironmentPlans };
|
|
61
|
+
export { catalogCurrencyKeys, findDefaultTrialPrice, findPlanByPriceId, findPriceCurrency, findTrialPlan, formatBillingInterval, formatPlanAmount, getEnvironmentPlans, listPlanPrices, listPlanSelectPrices };
|
|
22
62
|
|
|
23
63
|
//# sourceMappingURL=billing.utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.utils.mjs","names":[],"sources":["../../../../src/modules/billing/billing.utils.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"billing.utils.mjs","names":[],"sources":["../../../../src/modules/billing/billing.utils.ts"],"sourcesContent":["import type {\r\n ResolvedStripePlans,\r\n StripePlan,\r\n StripePlanPrice,\r\n StripePlansConfig,\r\n} from \"./billing.types\";\r\n\r\nexport const getEnvironmentPlans = (\r\n plansConfig: StripePlansConfig,\r\n environment = \"sandbox\"\r\n): ResolvedStripePlans => {\r\n const isProduction = environment === \"production\";\r\n const plans = isProduction ? plansConfig.production : plansConfig.sandbox;\r\n return {\r\n plans,\r\n trialPlanName: plansConfig.trialPlanName ?? {},\r\n trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,\r\n defaultCurrency: plansConfig.defaultCurrency,\r\n seatBilling: plansConfig.seatBilling ?? false,\r\n nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? [],\r\n };\r\n};\r\n\r\nexport const formatPlanAmount = ({\r\n unitAmount,\r\n currency,\r\n}: {\r\n unitAmount: number;\r\n currency: string;\r\n}): string => {\r\n return new Intl.NumberFormat(\"en-US\", {\r\n style: \"currency\",\r\n currency: currency.toUpperCase(),\r\n minimumFractionDigits: 0,\r\n maximumFractionDigits: 2,\r\n }).format(unitAmount / 100);\r\n};\r\n\r\nexport function listPlanPrices(plan: StripePlan): StripePlanPrice[] {\r\n return Object.values(plan.products).flatMap((product) => product.prices);\r\n}\r\n\r\nexport function catalogCurrencyKeys(plans: readonly StripePlan[]): string[] {\r\n const keys = new Set<string>();\r\n for (const plan of plans) {\r\n for (const currency of Object.keys(plan.products)) {\r\n keys.add(currency);\r\n }\r\n }\r\n return [...keys];\r\n}\r\n\r\nexport function findPlanByPriceId(\r\n plans: readonly StripePlan[],\r\n priceId: string\r\n): StripePlan | undefined {\r\n return plans.find((plan) => listPlanPrices(plan).some((price) => price.priceId === priceId));\r\n}\r\n\r\nexport function findPriceCurrency(plan: StripePlan, priceId: string): string | undefined {\r\n for (const [currency, product] of Object.entries(plan.products)) {\r\n if (product.prices.some((price) => price.priceId === priceId)) return currency;\r\n }\r\n return undefined;\r\n}\r\n\r\nexport function findTrialPlan({\r\n plans,\r\n trialPlanName,\r\n currency,\r\n}: {\r\n plans: readonly StripePlan[];\r\n trialPlanName: Record<string, string>;\r\n currency: string;\r\n}): StripePlan | undefined {\r\n const name = trialPlanName[currency];\r\n if (!name) return undefined;\r\n return plans.find((plan) => plan.name === name);\r\n}\r\n\r\nexport function findDefaultTrialPrice({\r\n plan,\r\n currency,\r\n}: {\r\n plan: StripePlan;\r\n currency: string;\r\n}): StripePlanPrice | undefined {\r\n const product = plan.products[currency];\r\n if (!product?.defaultPriceId) return undefined;\r\n return product.prices.find((price) => price.priceId === product.defaultPriceId);\r\n}\r\n\r\nexport function listPlanSelectPrices({\r\n plan,\r\n currency,\r\n trialRequiresPaymentMethod,\r\n}: {\r\n plan: StripePlan;\r\n currency: string;\r\n trialRequiresPaymentMethod?: boolean;\r\n}): StripePlanPrice[] {\r\n const product = plan.products[currency];\r\n if (!product) return [];\r\n if (trialRequiresPaymentMethod && product.defaultPriceId) {\r\n return product.prices.filter((price) => price.priceId === product.defaultPriceId);\r\n }\r\n return product.prices;\r\n}\r\n\r\nexport function formatBillingInterval({\r\n interval,\r\n intervalCount,\r\n}: {\r\n interval?: string | null;\r\n intervalCount?: number | null;\r\n}): string {\r\n const count = intervalCount ?? 1;\r\n if (!interval) return \"\";\r\n if (count === 1 && interval === \"month\") return \"Monthly\";\r\n if (count === 1 && interval === \"year\") return \"Yearly\";\r\n if (count === 1 && interval === \"week\") return \"Weekly\";\r\n if (count === 1 && interval === \"day\") return \"Daily\";\r\n if (interval === \"month\" && count === 3) return \"Every 3 months\";\r\n return `Every ${count} ${interval}${count === 1 ? \"\" : \"s\"}`;\r\n}\r\n"],"mappings":";AAOA,MAAa,uBACX,aACA,cAAc,cACU;AAGxB,QAAO;EACL,OAHmB,gBAAgB,eACR,YAAY,aAAa,YAAY;EAGhE,eAAe,YAAY,iBAAiB,EAAE;EAC9C,4BAA4B,YAAY,8BAA8B;EACtE,iBAAiB,YAAY;EAC7B,aAAa,YAAY,eAAe;EACxC,qBAAqB,YAAY,uBAAuB,EAAE;EAC3D;;AAGH,MAAa,oBAAoB,EAC/B,YACA,eAIY;AACZ,QAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP,UAAU,SAAS,aAAa;EAChC,uBAAuB;EACvB,uBAAuB;EACxB,CAAC,CAAC,OAAO,aAAa,IAAI;;AAG7B,SAAgB,eAAe,MAAqC;AAClE,QAAO,OAAO,OAAO,KAAK,SAAS,CAAC,SAAS,YAAY,QAAQ,OAAO;;AAG1E,SAAgB,oBAAoB,OAAwC;CAC1E,MAAM,uBAAO,IAAI,KAAa;AAC9B,MAAK,MAAM,QAAQ,MACjB,MAAK,MAAM,YAAY,OAAO,KAAK,KAAK,SAAS,CAC/C,MAAK,IAAI,SAAS;AAGtB,QAAO,CAAC,GAAG,KAAK;;AAGlB,SAAgB,kBACd,OACA,SACwB;AACxB,QAAO,MAAM,MAAM,SAAS,eAA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
8
|
number: "number";
|
|
9
9
|
boolean: "boolean";
|
|
10
|
-
date: "date";
|
|
11
10
|
enum: "enum";
|
|
11
|
+
date: "date";
|
|
12
12
|
jsonArray: "jsonArray";
|
|
13
13
|
}>;
|
|
14
14
|
method: z.ZodEnum<{
|
|
@@ -39,8 +39,8 @@ declare const filtersSchema: z.ZodArray<z.ZodObject<{
|
|
|
39
39
|
string: "string";
|
|
40
40
|
number: "number";
|
|
41
41
|
boolean: "boolean";
|
|
42
|
-
date: "date";
|
|
43
42
|
enum: "enum";
|
|
43
|
+
date: "date";
|
|
44
44
|
jsonArray: "jsonArray";
|
|
45
45
|
}>;
|
|
46
46
|
method: z.ZodEnum<{
|
|
@@ -79,8 +79,8 @@ declare const querySchema: z.ZodObject<{
|
|
|
79
79
|
string: "string";
|
|
80
80
|
number: "number";
|
|
81
81
|
boolean: "boolean";
|
|
82
|
-
date: "date";
|
|
83
82
|
enum: "enum";
|
|
83
|
+
date: "date";
|
|
84
84
|
jsonArray: "jsonArray";
|
|
85
85
|
}>;
|
|
86
86
|
method: z.ZodEnum<{
|
|
@@ -7,8 +7,8 @@ declare const filterSchema: z.ZodObject<{
|
|
|
7
7
|
string: "string";
|
|
8
8
|
number: "number";
|
|
9
9
|
boolean: "boolean";
|
|
10
|
-
date: "date";
|
|
11
10
|
enum: "enum";
|
|
11
|
+
date: "date";
|
|
12
12
|
jsonArray: "jsonArray";
|
|
13
13
|
}>;
|
|
14
14
|
method: z.ZodEnum<{
|
|
@@ -39,8 +39,8 @@ declare const filtersSchema: z.ZodArray<z.ZodObject<{
|
|
|
39
39
|
string: "string";
|
|
40
40
|
number: "number";
|
|
41
41
|
boolean: "boolean";
|
|
42
|
-
date: "date";
|
|
43
42
|
enum: "enum";
|
|
43
|
+
date: "date";
|
|
44
44
|
jsonArray: "jsonArray";
|
|
45
45
|
}>;
|
|
46
46
|
method: z.ZodEnum<{
|
|
@@ -79,8 +79,8 @@ declare const querySchema: z.ZodObject<{
|
|
|
79
79
|
string: "string";
|
|
80
80
|
number: "number";
|
|
81
81
|
boolean: "boolean";
|
|
82
|
-
date: "date";
|
|
83
82
|
enum: "enum";
|
|
83
|
+
date: "date";
|
|
84
84
|
jsonArray: "jsonArray";
|
|
85
85
|
}>;
|
|
86
86
|
method: z.ZodEnum<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m5kdev/commons",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.10",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tsdown": "0.21.7",
|
|
22
22
|
"typescript": "6.0.3",
|
|
23
23
|
"zod": "4.4.3",
|
|
24
|
-
"@m5kdev/config": "0.38.
|
|
24
|
+
"@m5kdev/config": "0.38.10"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
"./utils/*": {
|