@m5kdev/commons 0.37.4 → 0.38.1
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/billing/billing.schema.cjs +1 -0
- package/dist/src/modules/billing/billing.schema.cjs.map +1 -1
- package/dist/src/modules/billing/billing.schema.d.cts +1 -0
- package/dist/src/modules/billing/billing.schema.d.mts +1 -0
- package/dist/src/modules/billing/billing.schema.mjs +1 -0
- package/dist/src/modules/billing/billing.schema.mjs.map +1 -1
- package/dist/src/modules/billing/billing.types.d.cts +12 -3
- package/dist/src/modules/billing/billing.types.d.mts +12 -3
- package/dist/src/modules/billing/billing.utils.cjs +13 -1
- package/dist/src/modules/billing/billing.utils.cjs.map +1 -1
- package/dist/src/modules/billing/billing.utils.d.cts +10 -6
- package/dist/src/modules/billing/billing.utils.d.mts +10 -6
- package/dist/src/modules/billing/billing.utils.mjs +13 -2
- package/dist/src/modules/billing/billing.utils.mjs.map +1 -1
- package/dist/src/modules/notification/notification.schema.d.cts +3 -3
- package/dist/src/modules/notification/notification.schema.d.mts +3 -3
- package/dist/src/modules/schemas/query.schema.d.cts +9 -9
- package/dist/src/modules/schemas/query.schema.d.mts +9 -9
- package/dist/src/modules/tag/tag.schema.d.cts +3 -3
- package/dist/src/modules/tag/tag.schema.d.mts +3 -3
- package/dist/src/modules/workflow/workflow.schema.d.cts +4 -4
- package/dist/src/modules/workflow/workflow.schema.d.mts +4 -4
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ const billingSchema = zod.z.object({
|
|
|
14
14
|
cancelAt: zod.z.date().nullish(),
|
|
15
15
|
canceledAt: zod.z.date().nullish(),
|
|
16
16
|
seats: zod.z.number().nullish(),
|
|
17
|
+
memberId: zod.z.string().nullish(),
|
|
17
18
|
trialStart: zod.z.date().nullish(),
|
|
18
19
|
trialEnd: zod.z.date().nullish(),
|
|
19
20
|
priceId: zod.z.string().nullish(),
|
|
@@ -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 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":";;;AAEA,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,CAAC,SAAS;CAC1C,QAAQA,IAAAA,EAAE,QAAQ;CAClB,aAAaA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC/B,WAAWA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC7B,mBAAmBA,IAAAA,EAAE,SAAS,CAAC,SAAS;CACxC,UAAUA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC9B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC3B,YAAYA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC9B,UAAUA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC5B,SAASA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC7B,UAAUA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAYA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAWA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC"}
|
|
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":";;;AAEA,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,CAAC,SAAS;CAC1C,QAAQA,IAAAA,EAAE,QAAQ;CAClB,aAAaA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC/B,WAAWA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC7B,mBAAmBA,IAAAA,EAAE,SAAS,CAAC,SAAS;CACxC,UAAUA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC5B,YAAYA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC9B,OAAOA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC3B,UAAUA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAYA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC9B,UAAUA,IAAAA,EAAE,MAAM,CAAC,SAAS;CAC5B,SAASA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC7B,UAAUA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAYA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAWA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC"}
|
|
@@ -14,6 +14,7 @@ declare const billingSchema: z.ZodObject<{
|
|
|
14
14
|
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
15
15
|
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
16
16
|
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
17
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
18
|
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
18
19
|
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
19
20
|
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -14,6 +14,7 @@ declare const billingSchema: z.ZodObject<{
|
|
|
14
14
|
cancelAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
15
15
|
canceledAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
16
16
|
seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
17
|
+
memberId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
18
|
trialStart: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
18
19
|
trialEnd: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
19
20
|
priceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -13,6 +13,7 @@ const billingSchema = z.object({
|
|
|
13
13
|
cancelAt: z.date().nullish(),
|
|
14
14
|
canceledAt: z.date().nullish(),
|
|
15
15
|
seats: z.number().nullish(),
|
|
16
|
+
memberId: z.string().nullish(),
|
|
16
17
|
trialStart: z.date().nullish(),
|
|
17
18
|
trialEnd: z.date().nullish(),
|
|
18
19
|
priceId: z.string().nullish(),
|
|
@@ -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 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":";;AAEA,MAAa,gBAAgB,EAAE,OAAO;CACpC,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ;CACvB,kBAAkB,EAAE,QAAQ,CAAC,SAAS;CACtC,sBAAsB,EAAE,QAAQ,CAAC,SAAS;CAC1C,QAAQ,EAAE,QAAQ;CAClB,aAAa,EAAE,MAAM,CAAC,SAAS;CAC/B,WAAW,EAAE,MAAM,CAAC,SAAS;CAC7B,mBAAmB,EAAE,SAAS,CAAC,SAAS;CACxC,UAAU,EAAE,MAAM,CAAC,SAAS;CAC5B,YAAY,EAAE,MAAM,CAAC,SAAS;CAC9B,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,YAAY,EAAE,MAAM,CAAC,SAAS;CAC9B,UAAU,EAAE,MAAM,CAAC,SAAS;CAC5B,SAAS,EAAE,QAAQ,CAAC,SAAS;CAC7B,UAAU,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC"}
|
|
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":";;AAEA,MAAa,gBAAgB,EAAE,OAAO;CACpC,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ;CAChB,aAAa,EAAE,QAAQ;CACvB,kBAAkB,EAAE,QAAQ,CAAC,SAAS;CACtC,sBAAsB,EAAE,QAAQ,CAAC,SAAS;CAC1C,QAAQ,EAAE,QAAQ;CAClB,aAAa,EAAE,MAAM,CAAC,SAAS;CAC/B,WAAW,EAAE,MAAM,CAAC,SAAS;CAC7B,mBAAmB,EAAE,SAAS,CAAC,SAAS;CACxC,UAAU,EAAE,MAAM,CAAC,SAAS;CAC5B,YAAY,EAAE,MAAM,CAAC,SAAS;CAC9B,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,UAAU,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAY,EAAE,MAAM,CAAC,SAAS;CAC9B,UAAU,EAAE,MAAM,CAAC,SAAS;CAC5B,SAAS,EAAE,QAAQ,CAAC,SAAS;CAC7B,UAAU,EAAE,QAAQ,CAAC,SAAS;CAC9B,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC"}
|
|
@@ -7,15 +7,24 @@ type StripePlan = {
|
|
|
7
7
|
annualPriceUnitAmount?: number;
|
|
8
8
|
freeTrial?: {
|
|
9
9
|
days: number;
|
|
10
|
+
seats?: number;
|
|
10
11
|
};
|
|
11
|
-
limits?: Record<string, number>;
|
|
12
|
-
group?: string;
|
|
13
12
|
};
|
|
14
13
|
type StripePlansConfig = {
|
|
14
|
+
currency: string;
|
|
15
|
+
seatBilling?: boolean;
|
|
16
|
+
nonBillableRoleKeys?: readonly string[];
|
|
15
17
|
production: StripePlan[];
|
|
16
18
|
sandbox: StripePlan[];
|
|
17
19
|
trialPlanName?: string;
|
|
18
20
|
};
|
|
21
|
+
type ResolvedStripePlans = {
|
|
22
|
+
plans: StripePlan[];
|
|
23
|
+
trial?: StripePlan;
|
|
24
|
+
currency: string;
|
|
25
|
+
seatBilling: boolean;
|
|
26
|
+
nonBillableRoleKeys: readonly string[];
|
|
27
|
+
};
|
|
19
28
|
//#endregion
|
|
20
|
-
export { StripePlan, StripePlansConfig };
|
|
29
|
+
export { ResolvedStripePlans, StripePlan, StripePlansConfig };
|
|
21
30
|
//# sourceMappingURL=billing.types.d.cts.map
|
|
@@ -7,15 +7,24 @@ type StripePlan = {
|
|
|
7
7
|
annualPriceUnitAmount?: number;
|
|
8
8
|
freeTrial?: {
|
|
9
9
|
days: number;
|
|
10
|
+
seats?: number;
|
|
10
11
|
};
|
|
11
|
-
limits?: Record<string, number>;
|
|
12
|
-
group?: string;
|
|
13
12
|
};
|
|
14
13
|
type StripePlansConfig = {
|
|
14
|
+
currency: string;
|
|
15
|
+
seatBilling?: boolean;
|
|
16
|
+
nonBillableRoleKeys?: readonly string[];
|
|
15
17
|
production: StripePlan[];
|
|
16
18
|
sandbox: StripePlan[];
|
|
17
19
|
trialPlanName?: string;
|
|
18
20
|
};
|
|
21
|
+
type ResolvedStripePlans = {
|
|
22
|
+
plans: StripePlan[];
|
|
23
|
+
trial?: StripePlan;
|
|
24
|
+
currency: string;
|
|
25
|
+
seatBilling: boolean;
|
|
26
|
+
nonBillableRoleKeys: readonly string[];
|
|
27
|
+
};
|
|
19
28
|
//#endregion
|
|
20
|
-
export { StripePlan, StripePlansConfig };
|
|
29
|
+
export { ResolvedStripePlans, StripePlan, StripePlansConfig };
|
|
21
30
|
//# sourceMappingURL=billing.types.d.mts.map
|
|
@@ -4,10 +4,22 @@ const getEnvironmentPlans = (plansConfig, environment = "sandbox") => {
|
|
|
4
4
|
const plans = environment === "production" ? plansConfig.production : plansConfig.sandbox;
|
|
5
5
|
return {
|
|
6
6
|
plans,
|
|
7
|
-
trial: plansConfig.trialPlanName ? plans.find((plan) => plan.name === plansConfig.trialPlanName) : void 0
|
|
7
|
+
trial: plansConfig.trialPlanName ? plans.find((plan) => plan.name === plansConfig.trialPlanName) : void 0,
|
|
8
|
+
currency: plansConfig.currency,
|
|
9
|
+
seatBilling: plansConfig.seatBilling ?? false,
|
|
10
|
+
nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? []
|
|
8
11
|
};
|
|
9
12
|
};
|
|
13
|
+
const formatPlanAmount = ({ unitAmount, currency }) => {
|
|
14
|
+
return new Intl.NumberFormat("en-US", {
|
|
15
|
+
style: "currency",
|
|
16
|
+
currency: currency.toUpperCase(),
|
|
17
|
+
minimumFractionDigits: 0,
|
|
18
|
+
maximumFractionDigits: 2
|
|
19
|
+
}).format(unitAmount / 100);
|
|
20
|
+
};
|
|
10
21
|
//#endregion
|
|
22
|
+
exports.formatPlanAmount = formatPlanAmount;
|
|
11
23
|
exports.getEnvironmentPlans = getEnvironmentPlans;
|
|
12
24
|
|
|
13
25
|
//# 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 { ResolvedStripePlans, StripePlansConfig } 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 const trial = plansConfig.trialPlanName\r\n ? plans.find((plan) => plan.name === plansConfig.trialPlanName)\r\n : undefined;\r\n return {\r\n plans,\r\n trial,\r\n currency: plansConfig.currency,\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"],"mappings":";;AAEA,MAAa,uBACX,aACA,cAAc,cACU;CAExB,MAAM,QADe,gBAAgB,eACR,YAAY,aAAa,YAAY;AAIlE,QAAO;EACL;EACA,OALY,YAAY,gBACtB,MAAM,MAAM,SAAS,KAAK,SAAS,YAAY,cAAc,GAC7D,KAAA;EAIF,UAAU,YAAY;EACtB,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"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedStripePlans, StripePlansConfig } from "./billing.types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/billing/billing.utils.d.ts
|
|
4
|
-
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) => ResolvedStripePlans;
|
|
5
|
+
declare const formatPlanAmount: ({
|
|
6
|
+
unitAmount,
|
|
7
|
+
currency
|
|
8
|
+
}: {
|
|
9
|
+
unitAmount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
}) => string;
|
|
8
12
|
//#endregion
|
|
9
|
-
export { getEnvironmentPlans };
|
|
13
|
+
export { formatPlanAmount, getEnvironmentPlans };
|
|
10
14
|
//# sourceMappingURL=billing.utils.d.cts.map
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedStripePlans, StripePlansConfig } from "./billing.types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/billing/billing.utils.d.ts
|
|
4
|
-
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
declare const getEnvironmentPlans: (plansConfig: StripePlansConfig, environment?: string) => ResolvedStripePlans;
|
|
5
|
+
declare const formatPlanAmount: ({
|
|
6
|
+
unitAmount,
|
|
7
|
+
currency
|
|
8
|
+
}: {
|
|
9
|
+
unitAmount: number;
|
|
10
|
+
currency: string;
|
|
11
|
+
}) => string;
|
|
8
12
|
//#endregion
|
|
9
|
-
export { getEnvironmentPlans };
|
|
13
|
+
export { formatPlanAmount, getEnvironmentPlans };
|
|
10
14
|
//# sourceMappingURL=billing.utils.d.mts.map
|
|
@@ -3,10 +3,21 @@ const getEnvironmentPlans = (plansConfig, environment = "sandbox") => {
|
|
|
3
3
|
const plans = environment === "production" ? plansConfig.production : plansConfig.sandbox;
|
|
4
4
|
return {
|
|
5
5
|
plans,
|
|
6
|
-
trial: plansConfig.trialPlanName ? plans.find((plan) => plan.name === plansConfig.trialPlanName) : void 0
|
|
6
|
+
trial: plansConfig.trialPlanName ? plans.find((plan) => plan.name === plansConfig.trialPlanName) : void 0,
|
|
7
|
+
currency: plansConfig.currency,
|
|
8
|
+
seatBilling: plansConfig.seatBilling ?? false,
|
|
9
|
+
nonBillableRoleKeys: plansConfig.nonBillableRoleKeys ?? []
|
|
7
10
|
};
|
|
8
11
|
};
|
|
12
|
+
const formatPlanAmount = ({ unitAmount, currency }) => {
|
|
13
|
+
return new Intl.NumberFormat("en-US", {
|
|
14
|
+
style: "currency",
|
|
15
|
+
currency: currency.toUpperCase(),
|
|
16
|
+
minimumFractionDigits: 0,
|
|
17
|
+
maximumFractionDigits: 2
|
|
18
|
+
}).format(unitAmount / 100);
|
|
19
|
+
};
|
|
9
20
|
//#endregion
|
|
10
|
-
export { getEnvironmentPlans };
|
|
21
|
+
export { formatPlanAmount, getEnvironmentPlans };
|
|
11
22
|
|
|
12
23
|
//# 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 { ResolvedStripePlans, StripePlansConfig } 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 const trial = plansConfig.trialPlanName\r\n ? plans.find((plan) => plan.name === plansConfig.trialPlanName)\r\n : undefined;\r\n return {\r\n plans,\r\n trial,\r\n currency: plansConfig.currency,\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"],"mappings":";AAEA,MAAa,uBACX,aACA,cAAc,cACU;CAExB,MAAM,QADe,gBAAgB,eACR,YAAY,aAAa,YAAY;AAIlE,QAAO;EACL;EACA,OALY,YAAY,gBACtB,MAAM,MAAM,SAAS,KAAK,SAAS,YAAY,cAAc,GAC7D,KAAA;EAIF,UAAU,YAAY;EACtB,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"}
|
|
@@ -12,9 +12,9 @@ declare const notificationProviderSchema: z.ZodEnum<{
|
|
|
12
12
|
fcm: "fcm";
|
|
13
13
|
}>;
|
|
14
14
|
declare const notificationSendStatusSchema: z.ZodEnum<{
|
|
15
|
+
failed: "failed";
|
|
15
16
|
pending: "pending";
|
|
16
17
|
sent: "sent";
|
|
17
|
-
failed: "failed";
|
|
18
18
|
}>;
|
|
19
19
|
/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */
|
|
20
20
|
declare const pushSubscriptionJsonSchema: z.ZodObject<{
|
|
@@ -113,9 +113,9 @@ declare const notificationSendLogSelectSchema: z.ZodObject<{
|
|
|
113
113
|
body: z.ZodString;
|
|
114
114
|
data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
115
115
|
status: z.ZodEnum<{
|
|
116
|
+
failed: "failed";
|
|
116
117
|
pending: "pending";
|
|
117
118
|
sent: "sent";
|
|
118
|
-
failed: "failed";
|
|
119
119
|
}>;
|
|
120
120
|
error: z.ZodNullable<z.ZodString>;
|
|
121
121
|
jobId: z.ZodNullable<z.ZodString>;
|
|
@@ -147,9 +147,9 @@ declare const notificationListSendLogsOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
147
147
|
body: z.ZodString;
|
|
148
148
|
data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
149
149
|
status: z.ZodEnum<{
|
|
150
|
+
failed: "failed";
|
|
150
151
|
pending: "pending";
|
|
151
152
|
sent: "sent";
|
|
152
|
-
failed: "failed";
|
|
153
153
|
}>;
|
|
154
154
|
error: z.ZodNullable<z.ZodString>;
|
|
155
155
|
jobId: z.ZodNullable<z.ZodString>;
|
|
@@ -12,9 +12,9 @@ declare const notificationProviderSchema: z.ZodEnum<{
|
|
|
12
12
|
fcm: "fcm";
|
|
13
13
|
}>;
|
|
14
14
|
declare const notificationSendStatusSchema: z.ZodEnum<{
|
|
15
|
+
failed: "failed";
|
|
15
16
|
pending: "pending";
|
|
16
17
|
sent: "sent";
|
|
17
|
-
failed: "failed";
|
|
18
18
|
}>;
|
|
19
19
|
/** Web Push `PushSubscriptionJSON` subset we persist and accept from clients. */
|
|
20
20
|
declare const pushSubscriptionJsonSchema: z.ZodObject<{
|
|
@@ -113,9 +113,9 @@ declare const notificationSendLogSelectSchema: z.ZodObject<{
|
|
|
113
113
|
body: z.ZodString;
|
|
114
114
|
data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
115
115
|
status: z.ZodEnum<{
|
|
116
|
+
failed: "failed";
|
|
116
117
|
pending: "pending";
|
|
117
118
|
sent: "sent";
|
|
118
|
-
failed: "failed";
|
|
119
119
|
}>;
|
|
120
120
|
error: z.ZodNullable<z.ZodString>;
|
|
121
121
|
jobId: z.ZodNullable<z.ZodString>;
|
|
@@ -147,9 +147,9 @@ declare const notificationListSendLogsOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
147
147
|
body: z.ZodString;
|
|
148
148
|
data: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
149
149
|
status: z.ZodEnum<{
|
|
150
|
+
failed: "failed";
|
|
150
151
|
pending: "pending";
|
|
151
152
|
sent: "sent";
|
|
152
|
-
failed: "failed";
|
|
153
153
|
}>;
|
|
154
154
|
error: z.ZodNullable<z.ZodString>;
|
|
155
155
|
jobId: z.ZodNullable<z.ZodString>;
|
|
@@ -7,15 +7,15 @@ 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<{
|
|
15
|
-
contains: "contains";
|
|
16
|
-
equals: "equals";
|
|
17
15
|
starts_with: "starts_with";
|
|
18
16
|
ends_with: "ends_with";
|
|
17
|
+
contains: "contains";
|
|
18
|
+
equals: "equals";
|
|
19
19
|
greater_than: "greater_than";
|
|
20
20
|
less_than: "less_than";
|
|
21
21
|
on: "on";
|
|
@@ -39,15 +39,15 @@ 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<{
|
|
47
|
-
contains: "contains";
|
|
48
|
-
equals: "equals";
|
|
49
47
|
starts_with: "starts_with";
|
|
50
48
|
ends_with: "ends_with";
|
|
49
|
+
contains: "contains";
|
|
50
|
+
equals: "equals";
|
|
51
51
|
greater_than: "greater_than";
|
|
52
52
|
less_than: "less_than";
|
|
53
53
|
on: "on";
|
|
@@ -79,15 +79,15 @@ 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<{
|
|
87
|
-
contains: "contains";
|
|
88
|
-
equals: "equals";
|
|
89
87
|
starts_with: "starts_with";
|
|
90
88
|
ends_with: "ends_with";
|
|
89
|
+
contains: "contains";
|
|
90
|
+
equals: "equals";
|
|
91
91
|
greater_than: "greater_than";
|
|
92
92
|
less_than: "less_than";
|
|
93
93
|
on: "on";
|
|
@@ -7,15 +7,15 @@ 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<{
|
|
15
|
-
contains: "contains";
|
|
16
|
-
equals: "equals";
|
|
17
15
|
starts_with: "starts_with";
|
|
18
16
|
ends_with: "ends_with";
|
|
17
|
+
contains: "contains";
|
|
18
|
+
equals: "equals";
|
|
19
19
|
greater_than: "greater_than";
|
|
20
20
|
less_than: "less_than";
|
|
21
21
|
on: "on";
|
|
@@ -39,15 +39,15 @@ 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<{
|
|
47
|
-
contains: "contains";
|
|
48
|
-
equals: "equals";
|
|
49
47
|
starts_with: "starts_with";
|
|
50
48
|
ends_with: "ends_with";
|
|
49
|
+
contains: "contains";
|
|
50
|
+
equals: "equals";
|
|
51
51
|
greater_than: "greater_than";
|
|
52
52
|
less_than: "less_than";
|
|
53
53
|
on: "on";
|
|
@@ -79,15 +79,15 @@ 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<{
|
|
87
|
-
contains: "contains";
|
|
88
|
-
equals: "equals";
|
|
89
87
|
starts_with: "starts_with";
|
|
90
88
|
ends_with: "ends_with";
|
|
89
|
+
contains: "contains";
|
|
90
|
+
equals: "equals";
|
|
91
91
|
greater_than: "greater_than";
|
|
92
92
|
less_than: "less_than";
|
|
93
93
|
on: "on";
|
|
@@ -37,15 +37,15 @@ declare const tagListInputSchema: z.ZodObject<{
|
|
|
37
37
|
string: "string";
|
|
38
38
|
number: "number";
|
|
39
39
|
boolean: "boolean";
|
|
40
|
-
date: "date";
|
|
41
40
|
enum: "enum";
|
|
41
|
+
date: "date";
|
|
42
42
|
jsonArray: "jsonArray";
|
|
43
43
|
}>;
|
|
44
44
|
method: z.ZodEnum<{
|
|
45
|
-
contains: "contains";
|
|
46
|
-
equals: "equals";
|
|
47
45
|
starts_with: "starts_with";
|
|
48
46
|
ends_with: "ends_with";
|
|
47
|
+
contains: "contains";
|
|
48
|
+
equals: "equals";
|
|
49
49
|
greater_than: "greater_than";
|
|
50
50
|
less_than: "less_than";
|
|
51
51
|
on: "on";
|
|
@@ -37,15 +37,15 @@ declare const tagListInputSchema: z.ZodObject<{
|
|
|
37
37
|
string: "string";
|
|
38
38
|
number: "number";
|
|
39
39
|
boolean: "boolean";
|
|
40
|
-
date: "date";
|
|
41
40
|
enum: "enum";
|
|
41
|
+
date: "date";
|
|
42
42
|
jsonArray: "jsonArray";
|
|
43
43
|
}>;
|
|
44
44
|
method: z.ZodEnum<{
|
|
45
|
-
contains: "contains";
|
|
46
|
-
equals: "equals";
|
|
47
45
|
starts_with: "starts_with";
|
|
48
46
|
ends_with: "ends_with";
|
|
47
|
+
contains: "contains";
|
|
48
|
+
equals: "equals";
|
|
49
49
|
greater_than: "greater_than";
|
|
50
50
|
less_than: "less_than";
|
|
51
51
|
on: "on";
|
|
@@ -11,10 +11,10 @@ declare const workflowSelectSchema: z.ZodObject<{
|
|
|
11
11
|
input: z.ZodUnknown;
|
|
12
12
|
output: z.ZodUnknown;
|
|
13
13
|
status: z.ZodEnum<{
|
|
14
|
-
failed: "failed";
|
|
15
14
|
queued: "queued";
|
|
16
15
|
running: "running";
|
|
17
16
|
completed: "completed";
|
|
17
|
+
failed: "failed";
|
|
18
18
|
}>;
|
|
19
19
|
error: z.ZodNullable<z.ZodString>;
|
|
20
20
|
retries: z.ZodNumber;
|
|
@@ -28,10 +28,10 @@ declare const workflowReadInputSchema: z.ZodObject<{
|
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
declare const workflowListInputSchema: z.ZodObject<{
|
|
30
30
|
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
31
|
-
failed: "failed";
|
|
32
31
|
queued: "queued";
|
|
33
32
|
running: "running";
|
|
34
33
|
completed: "completed";
|
|
34
|
+
failed: "failed";
|
|
35
35
|
}>>>;
|
|
36
36
|
jobName: z.ZodOptional<z.ZodString>;
|
|
37
37
|
}, z.core.$strip>;
|
|
@@ -51,10 +51,10 @@ declare const workflowReadOutputSchema: z.ZodObject<{
|
|
|
51
51
|
input: z.ZodUnknown;
|
|
52
52
|
output: z.ZodUnknown;
|
|
53
53
|
status: z.ZodEnum<{
|
|
54
|
-
failed: "failed";
|
|
55
54
|
queued: "queued";
|
|
56
55
|
running: "running";
|
|
57
56
|
completed: "completed";
|
|
57
|
+
failed: "failed";
|
|
58
58
|
}>;
|
|
59
59
|
error: z.ZodNullable<z.ZodString>;
|
|
60
60
|
retries: z.ZodNumber;
|
|
@@ -73,10 +73,10 @@ declare const workflowListOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
73
73
|
input: z.ZodUnknown;
|
|
74
74
|
output: z.ZodUnknown;
|
|
75
75
|
status: z.ZodEnum<{
|
|
76
|
-
failed: "failed";
|
|
77
76
|
queued: "queued";
|
|
78
77
|
running: "running";
|
|
79
78
|
completed: "completed";
|
|
79
|
+
failed: "failed";
|
|
80
80
|
}>;
|
|
81
81
|
error: z.ZodNullable<z.ZodString>;
|
|
82
82
|
retries: z.ZodNumber;
|
|
@@ -11,10 +11,10 @@ declare const workflowSelectSchema: z.ZodObject<{
|
|
|
11
11
|
input: z.ZodUnknown;
|
|
12
12
|
output: z.ZodUnknown;
|
|
13
13
|
status: z.ZodEnum<{
|
|
14
|
-
failed: "failed";
|
|
15
14
|
queued: "queued";
|
|
16
15
|
running: "running";
|
|
17
16
|
completed: "completed";
|
|
17
|
+
failed: "failed";
|
|
18
18
|
}>;
|
|
19
19
|
error: z.ZodNullable<z.ZodString>;
|
|
20
20
|
retries: z.ZodNumber;
|
|
@@ -28,10 +28,10 @@ declare const workflowReadInputSchema: z.ZodObject<{
|
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
declare const workflowListInputSchema: z.ZodObject<{
|
|
30
30
|
status: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
31
|
-
failed: "failed";
|
|
32
31
|
queued: "queued";
|
|
33
32
|
running: "running";
|
|
34
33
|
completed: "completed";
|
|
34
|
+
failed: "failed";
|
|
35
35
|
}>>>;
|
|
36
36
|
jobName: z.ZodOptional<z.ZodString>;
|
|
37
37
|
}, z.core.$strip>;
|
|
@@ -51,10 +51,10 @@ declare const workflowReadOutputSchema: z.ZodObject<{
|
|
|
51
51
|
input: z.ZodUnknown;
|
|
52
52
|
output: z.ZodUnknown;
|
|
53
53
|
status: z.ZodEnum<{
|
|
54
|
-
failed: "failed";
|
|
55
54
|
queued: "queued";
|
|
56
55
|
running: "running";
|
|
57
56
|
completed: "completed";
|
|
57
|
+
failed: "failed";
|
|
58
58
|
}>;
|
|
59
59
|
error: z.ZodNullable<z.ZodString>;
|
|
60
60
|
retries: z.ZodNumber;
|
|
@@ -73,10 +73,10 @@ declare const workflowListOutputSchema: z.ZodArray<z.ZodObject<{
|
|
|
73
73
|
input: z.ZodUnknown;
|
|
74
74
|
output: z.ZodUnknown;
|
|
75
75
|
status: z.ZodEnum<{
|
|
76
|
-
failed: "failed";
|
|
77
76
|
queued: "queued";
|
|
78
77
|
running: "running";
|
|
79
78
|
completed: "completed";
|
|
79
|
+
failed: "failed";
|
|
80
80
|
}>;
|
|
81
81
|
error: z.ZodNullable<z.ZodString>;
|
|
82
82
|
retries: z.ZodNumber;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m5kdev/commons",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.1",
|
|
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.
|
|
24
|
+
"@m5kdev/config": "0.38.1"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
"./utils/*": {
|