@m5kdev/commons 0.38.10 → 0.38.12

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.
@@ -25,17 +25,38 @@ const billingSchema = zod.z.object({
25
25
  unitAmount: zod.z.number().nullish(),
26
26
  discounts: zod.z.array(zod.z.string()).nullish()
27
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({
28
+ const billingCouponSchema = zod.z.object({
29
+ id: zod.z.string(),
30
+ name: zod.z.string().nullable(),
31
+ percentOff: zod.z.number().nullable(),
32
+ amountOff: zod.z.number().nullable(),
33
+ currency: zod.z.string().nullable(),
34
+ duration: zod.z.enum([
35
+ "forever",
36
+ "once",
37
+ "repeating"
38
+ ]).nullable(),
39
+ durationInMonths: zod.z.number().nullable(),
40
+ valid: zod.z.boolean()
41
+ });
42
+ const billingCouponListOutputSchema = zod.z.array(billingCouponSchema);
43
+ const organizationIdInputSchema = zod.z.object({ organizationId: zod.z.string() });
44
+ const MAX_TRIAL_DAYS = 730;
45
+ const stripeEnvironmentSchema = zod.z.enum(["production", "sandbox"]);
46
+ const createAdminSubscriptionInputSchema = zod.z.object({
34
47
  organizationId: zod.z.string(),
35
48
  priceId: zod.z.string(),
36
- duration: complimentaryDurationSchema
49
+ couponId: zod.z.string().optional(),
50
+ trialDays: zod.z.number().int().min(1).max(730).optional()
51
+ });
52
+ const applyAdminCouponInputSchema = zod.z.object({
53
+ organizationId: zod.z.string(),
54
+ couponId: zod.z.string()
55
+ });
56
+ const setOrganizationCurrencyInputSchema = zod.z.object({
57
+ organizationId: zod.z.string(),
58
+ currency: zod.z.string()
37
59
  });
38
- const organizationIdInputSchema = zod.z.object({ organizationId: zod.z.string() });
39
60
  const cancelAdminSubscriptionInputSchema = zod.z.object({
40
61
  organizationId: zod.z.string(),
41
62
  when: zod.z.enum(["immediate", "period_end"])
@@ -45,18 +66,27 @@ const adminOrganizationBillingRowSchema = zod.z.object({
45
66
  organizationId: zod.z.string(),
46
67
  organizationName: zod.z.string(),
47
68
  currency: zod.z.string().nullable(),
48
- subscription: billingSchema.nullable()
69
+ stripeCustomerId: zod.z.string().nullable(),
70
+ defaultTrialDays: zod.z.number().nullable(),
71
+ openSubscription: zod.z.boolean(),
72
+ subscription: billingSchema.nullable(),
73
+ coupon: billingCouponSchema.nullable()
49
74
  });
50
75
  const billingAdminListInputSchema = require_src_modules_schemas_query_schema.querySchema;
51
- const billingAdminListOutputSchema = require_src_modules_schemas_query_schema.queryListOutput(adminOrganizationBillingRowSchema);
76
+ const billingAdminListOutputSchema = require_src_modules_schemas_query_schema.queryListOutput(adminOrganizationBillingRowSchema).extend({ environment: stripeEnvironmentSchema });
52
77
  //#endregion
78
+ exports.MAX_TRIAL_DAYS = MAX_TRIAL_DAYS;
53
79
  exports.adminOrganizationBillingRowSchema = adminOrganizationBillingRowSchema;
80
+ exports.applyAdminCouponInputSchema = applyAdminCouponInputSchema;
54
81
  exports.billingAdminListInputSchema = billingAdminListInputSchema;
55
82
  exports.billingAdminListOutputSchema = billingAdminListOutputSchema;
83
+ exports.billingCouponListOutputSchema = billingCouponListOutputSchema;
84
+ exports.billingCouponSchema = billingCouponSchema;
56
85
  exports.billingSchema = billingSchema;
57
86
  exports.cancelAdminSubscriptionInputSchema = cancelAdminSubscriptionInputSchema;
58
- exports.complimentaryDurationSchema = complimentaryDurationSchema;
59
- exports.enrollComplimentaryInputSchema = enrollComplimentaryInputSchema;
87
+ exports.createAdminSubscriptionInputSchema = createAdminSubscriptionInputSchema;
60
88
  exports.organizationIdInputSchema = organizationIdInputSchema;
89
+ exports.setOrganizationCurrencyInputSchema = setOrganizationCurrencyInputSchema;
90
+ exports.stripeEnvironmentSchema = stripeEnvironmentSchema;
61
91
 
62
92
  //# sourceMappingURL=billing.schema.cjs.map
@@ -1 +1 @@
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,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,eAAeA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CACnC,gBAAgBA,IAAAA,EAAE,SAAS,CAAC,SAAS;CACrC,YAAYA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAWA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC;AAIF,MAAa,8BAA8BA,IAAAA,EAAE,MAAM;CACjDA,IAAAA,EAAE,QAAQ,UAAU;CACpBA,IAAAA,EAAE,QAAQ,OAAO;CACjBA,IAAAA,EAAE,OAAO,EAAE,QAAQA,IAAAA,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;CAClD,CAAC;AAEF,MAAa,iCAAiCA,IAAAA,EAAE,OAAO;CACrD,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,SAASA,IAAAA,EAAE,QAAQ;CACnB,UAAU;CACX,CAAC;AAEF,MAAa,4BAA4BA,IAAAA,EAAE,OAAO,EAChD,gBAAgBA,IAAAA,EAAE,QAAQ,EAC3B,CAAC;AAEF,MAAa,qCAAqCA,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"}
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 billingCouponSchema = z.object({\r\n id: z.string(),\r\n name: z.string().nullable(),\r\n percentOff: z.number().nullable(),\r\n amountOff: z.number().nullable(),\r\n currency: z.string().nullable(),\r\n duration: z.enum([\"forever\", \"once\", \"repeating\"]).nullable(),\r\n durationInMonths: z.number().nullable(),\r\n valid: z.boolean(),\r\n});\r\n\r\nexport const billingCouponListOutputSchema = z.array(billingCouponSchema);\r\n\r\nexport const organizationIdInputSchema = z.object({\r\n organizationId: z.string(),\r\n});\r\n\r\nexport const MAX_TRIAL_DAYS = 730;\r\n\r\nexport const stripeEnvironmentSchema = z.enum([\"production\", \"sandbox\"]);\r\n\r\nexport const createAdminSubscriptionInputSchema = z.object({\r\n organizationId: z.string(),\r\n priceId: z.string(),\r\n couponId: z.string().optional(),\r\n trialDays: z.number().int().min(1).max(MAX_TRIAL_DAYS).optional(),\r\n});\r\n\r\nexport const applyAdminCouponInputSchema = z.object({\r\n organizationId: z.string(),\r\n couponId: z.string(),\r\n});\r\n\r\nexport const setOrganizationCurrencyInputSchema = z.object({\r\n organizationId: z.string(),\r\n currency: 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 stripeCustomerId: z.string().nullable(),\r\n defaultTrialDays: z.number().nullable(),\r\n openSubscription: z.boolean(),\r\n subscription: billingSchema.nullable(),\r\n coupon: billingCouponSchema.nullable(),\r\n});\r\n\r\nexport const billingAdminListInputSchema = querySchema;\r\nexport const billingAdminListOutputSchema = queryListOutput(\r\n adminOrganizationBillingRowSchema\r\n).extend({\r\n environment: stripeEnvironmentSchema,\r\n});\r\n\r\nexport type BillingCoupon = z.infer<typeof billingCouponSchema>;\r\nexport type CreateAdminSubscriptionInput = z.infer<typeof createAdminSubscriptionInputSchema>;\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,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,eAAeA,IAAAA,EAAE,QAAQ,CAAC,SAAS;CACnC,gBAAg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IAAAA,EAAE,OAAO;CACzD,gBAAgBA,IAAAA,EAAE,QAAQ;CAC1B,UAAUA,IAAAA,EAAE,QAAQ;CACrB,CAAC;AAEF,MAAa,qCAAqCA,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,kBAAkBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACvC,kBAAkBA,IAAAA,EAAE,QAAQ,CAAC,UAAU;CACvC,kBAAkBA,IAAAA,EAAE,SAAS;CAC7B,cAAc,cAAc,UAAU;CACtC,QAAQ,oBAAoB,UAAU;CACvC,CAAC;AAEF,MAAa,8BAA8BC,yCAAAA;AAC3C,MAAa,+BAA+BC,yCAAAA,gBAC1C,kCACD,CAAC,OAAO,EACP,aAAa,yBACd,CAAC"}
@@ -25,18 +25,55 @@ declare const billingSchema: z.ZodObject<{
25
25
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
26
26
  }, z.core.$strip>;
27
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<{
28
+ declare const billingCouponSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ name: z.ZodNullable<z.ZodString>;
31
+ percentOff: z.ZodNullable<z.ZodNumber>;
32
+ amountOff: z.ZodNullable<z.ZodNumber>;
33
+ currency: z.ZodNullable<z.ZodString>;
34
+ duration: z.ZodNullable<z.ZodEnum<{
35
+ forever: "forever";
36
+ once: "once";
37
+ repeating: "repeating";
38
+ }>>;
39
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
40
+ valid: z.ZodBoolean;
41
+ }, z.core.$strip>;
42
+ declare const billingCouponListOutputSchema: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ name: z.ZodNullable<z.ZodString>;
45
+ percentOff: z.ZodNullable<z.ZodNumber>;
46
+ amountOff: z.ZodNullable<z.ZodNumber>;
47
+ currency: z.ZodNullable<z.ZodString>;
48
+ duration: z.ZodNullable<z.ZodEnum<{
49
+ forever: "forever";
50
+ once: "once";
51
+ repeating: "repeating";
52
+ }>>;
53
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
54
+ valid: z.ZodBoolean;
55
+ }, z.core.$strip>>;
56
+ declare const organizationIdInputSchema: z.ZodObject<{
57
+ organizationId: z.ZodString;
58
+ }, z.core.$strip>;
59
+ declare const MAX_TRIAL_DAYS = 730;
60
+ declare const stripeEnvironmentSchema: z.ZodEnum<{
61
+ production: "production";
62
+ sandbox: "sandbox";
63
+ }>;
64
+ declare const createAdminSubscriptionInputSchema: z.ZodObject<{
32
65
  organizationId: z.ZodString;
33
66
  priceId: z.ZodString;
34
- duration: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
35
- months: z.ZodNumber;
36
- }, z.core.$strip>]>;
67
+ couponId: z.ZodOptional<z.ZodString>;
68
+ trialDays: z.ZodOptional<z.ZodNumber>;
37
69
  }, z.core.$strip>;
38
- declare const organizationIdInputSchema: z.ZodObject<{
70
+ declare const applyAdminCouponInputSchema: z.ZodObject<{
71
+ organizationId: z.ZodString;
72
+ couponId: z.ZodString;
73
+ }, z.core.$strip>;
74
+ declare const setOrganizationCurrencyInputSchema: z.ZodObject<{
39
75
  organizationId: z.ZodString;
76
+ currency: z.ZodString;
40
77
  }, z.core.$strip>;
41
78
  declare const cancelAdminSubscriptionInputSchema: z.ZodObject<{
42
79
  organizationId: z.ZodString;
@@ -50,6 +87,9 @@ declare const adminOrganizationBillingRowSchema: z.ZodObject<{
50
87
  organizationId: z.ZodString;
51
88
  organizationName: z.ZodString;
52
89
  currency: z.ZodNullable<z.ZodString>;
90
+ stripeCustomerId: z.ZodNullable<z.ZodString>;
91
+ defaultTrialDays: z.ZodNullable<z.ZodNumber>;
92
+ openSubscription: z.ZodBoolean;
53
93
  subscription: z.ZodNullable<z.ZodObject<{
54
94
  id: z.ZodString;
55
95
  plan: z.ZodString;
@@ -73,6 +113,20 @@ declare const adminOrganizationBillingRowSchema: z.ZodObject<{
73
113
  unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
114
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
75
115
  }, z.core.$strip>>;
116
+ coupon: z.ZodNullable<z.ZodObject<{
117
+ id: z.ZodString;
118
+ name: z.ZodNullable<z.ZodString>;
119
+ percentOff: z.ZodNullable<z.ZodNumber>;
120
+ amountOff: z.ZodNullable<z.ZodNumber>;
121
+ currency: z.ZodNullable<z.ZodString>;
122
+ duration: z.ZodNullable<z.ZodEnum<{
123
+ forever: "forever";
124
+ once: "once";
125
+ repeating: "repeating";
126
+ }>>;
127
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
128
+ valid: z.ZodBoolean;
129
+ }, z.core.$strip>>;
76
130
  }, z.core.$strip>;
77
131
  declare const billingAdminListInputSchema: z.ZodObject<{
78
132
  page: z.ZodOptional<z.ZodNumber>;
@@ -122,6 +176,9 @@ declare const billingAdminListOutputSchema: z.ZodObject<{
122
176
  organizationId: z.ZodString;
123
177
  organizationName: z.ZodString;
124
178
  currency: z.ZodNullable<z.ZodString>;
179
+ stripeCustomerId: z.ZodNullable<z.ZodString>;
180
+ defaultTrialDays: z.ZodNullable<z.ZodNumber>;
181
+ openSubscription: z.ZodBoolean;
125
182
  subscription: z.ZodNullable<z.ZodObject<{
126
183
  id: z.ZodString;
127
184
  plan: z.ZodString;
@@ -145,12 +202,30 @@ declare const billingAdminListOutputSchema: z.ZodObject<{
145
202
  unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
146
203
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
147
204
  }, z.core.$strip>>;
205
+ coupon: z.ZodNullable<z.ZodObject<{
206
+ id: z.ZodString;
207
+ name: z.ZodNullable<z.ZodString>;
208
+ percentOff: z.ZodNullable<z.ZodNumber>;
209
+ amountOff: z.ZodNullable<z.ZodNumber>;
210
+ currency: z.ZodNullable<z.ZodString>;
211
+ duration: z.ZodNullable<z.ZodEnum<{
212
+ forever: "forever";
213
+ once: "once";
214
+ repeating: "repeating";
215
+ }>>;
216
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
217
+ valid: z.ZodBoolean;
218
+ }, z.core.$strip>>;
148
219
  }, z.core.$strip>>;
149
220
  total: z.ZodNumber;
221
+ environment: z.ZodEnum<{
222
+ production: "production";
223
+ sandbox: "sandbox";
224
+ }>;
150
225
  }, z.core.$strip>;
151
- type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;
152
- type EnrollComplimentaryInput = z.infer<typeof enrollComplimentaryInputSchema>;
226
+ type BillingCoupon = z.infer<typeof billingCouponSchema>;
227
+ type CreateAdminSubscriptionInput = z.infer<typeof createAdminSubscriptionInputSchema>;
153
228
  type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;
154
229
  //#endregion
155
- export { AdminOrganizationBillingRow, BillingSchema, ComplimentaryDuration, EnrollComplimentaryInput, adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
230
+ export { AdminOrganizationBillingRow, BillingCoupon, BillingSchema, CreateAdminSubscriptionInput, MAX_TRIAL_DAYS, adminOrganizationBillingRowSchema, applyAdminCouponInputSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingCouponListOutputSchema, billingCouponSchema, billingSchema, cancelAdminSubscriptionInputSchema, createAdminSubscriptionInputSchema, organizationIdInputSchema, setOrganizationCurrencyInputSchema, stripeEnvironmentSchema };
156
231
  //# sourceMappingURL=billing.schema.d.cts.map
@@ -25,18 +25,55 @@ declare const billingSchema: z.ZodObject<{
25
25
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
26
26
  }, z.core.$strip>;
27
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<{
28
+ declare const billingCouponSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ name: z.ZodNullable<z.ZodString>;
31
+ percentOff: z.ZodNullable<z.ZodNumber>;
32
+ amountOff: z.ZodNullable<z.ZodNumber>;
33
+ currency: z.ZodNullable<z.ZodString>;
34
+ duration: z.ZodNullable<z.ZodEnum<{
35
+ forever: "forever";
36
+ once: "once";
37
+ repeating: "repeating";
38
+ }>>;
39
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
40
+ valid: z.ZodBoolean;
41
+ }, z.core.$strip>;
42
+ declare const billingCouponListOutputSchema: z.ZodArray<z.ZodObject<{
43
+ id: z.ZodString;
44
+ name: z.ZodNullable<z.ZodString>;
45
+ percentOff: z.ZodNullable<z.ZodNumber>;
46
+ amountOff: z.ZodNullable<z.ZodNumber>;
47
+ currency: z.ZodNullable<z.ZodString>;
48
+ duration: z.ZodNullable<z.ZodEnum<{
49
+ forever: "forever";
50
+ once: "once";
51
+ repeating: "repeating";
52
+ }>>;
53
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
54
+ valid: z.ZodBoolean;
55
+ }, z.core.$strip>>;
56
+ declare const organizationIdInputSchema: z.ZodObject<{
57
+ organizationId: z.ZodString;
58
+ }, z.core.$strip>;
59
+ declare const MAX_TRIAL_DAYS = 730;
60
+ declare const stripeEnvironmentSchema: z.ZodEnum<{
61
+ production: "production";
62
+ sandbox: "sandbox";
63
+ }>;
64
+ declare const createAdminSubscriptionInputSchema: z.ZodObject<{
32
65
  organizationId: z.ZodString;
33
66
  priceId: z.ZodString;
34
- duration: z.ZodUnion<readonly [z.ZodLiteral<"forever">, z.ZodLiteral<"once">, z.ZodObject<{
35
- months: z.ZodNumber;
36
- }, z.core.$strip>]>;
67
+ couponId: z.ZodOptional<z.ZodString>;
68
+ trialDays: z.ZodOptional<z.ZodNumber>;
37
69
  }, z.core.$strip>;
38
- declare const organizationIdInputSchema: z.ZodObject<{
70
+ declare const applyAdminCouponInputSchema: z.ZodObject<{
71
+ organizationId: z.ZodString;
72
+ couponId: z.ZodString;
73
+ }, z.core.$strip>;
74
+ declare const setOrganizationCurrencyInputSchema: z.ZodObject<{
39
75
  organizationId: z.ZodString;
76
+ currency: z.ZodString;
40
77
  }, z.core.$strip>;
41
78
  declare const cancelAdminSubscriptionInputSchema: z.ZodObject<{
42
79
  organizationId: z.ZodString;
@@ -50,6 +87,9 @@ declare const adminOrganizationBillingRowSchema: z.ZodObject<{
50
87
  organizationId: z.ZodString;
51
88
  organizationName: z.ZodString;
52
89
  currency: z.ZodNullable<z.ZodString>;
90
+ stripeCustomerId: z.ZodNullable<z.ZodString>;
91
+ defaultTrialDays: z.ZodNullable<z.ZodNumber>;
92
+ openSubscription: z.ZodBoolean;
53
93
  subscription: z.ZodNullable<z.ZodObject<{
54
94
  id: z.ZodString;
55
95
  plan: z.ZodString;
@@ -73,6 +113,20 @@ declare const adminOrganizationBillingRowSchema: z.ZodObject<{
73
113
  unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
114
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
75
115
  }, z.core.$strip>>;
116
+ coupon: z.ZodNullable<z.ZodObject<{
117
+ id: z.ZodString;
118
+ name: z.ZodNullable<z.ZodString>;
119
+ percentOff: z.ZodNullable<z.ZodNumber>;
120
+ amountOff: z.ZodNullable<z.ZodNumber>;
121
+ currency: z.ZodNullable<z.ZodString>;
122
+ duration: z.ZodNullable<z.ZodEnum<{
123
+ forever: "forever";
124
+ once: "once";
125
+ repeating: "repeating";
126
+ }>>;
127
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
128
+ valid: z.ZodBoolean;
129
+ }, z.core.$strip>>;
76
130
  }, z.core.$strip>;
77
131
  declare const billingAdminListInputSchema: z.ZodObject<{
78
132
  page: z.ZodOptional<z.ZodNumber>;
@@ -122,6 +176,9 @@ declare const billingAdminListOutputSchema: z.ZodObject<{
122
176
  organizationId: z.ZodString;
123
177
  organizationName: z.ZodString;
124
178
  currency: z.ZodNullable<z.ZodString>;
179
+ stripeCustomerId: z.ZodNullable<z.ZodString>;
180
+ defaultTrialDays: z.ZodNullable<z.ZodNumber>;
181
+ openSubscription: z.ZodBoolean;
125
182
  subscription: z.ZodNullable<z.ZodObject<{
126
183
  id: z.ZodString;
127
184
  plan: z.ZodString;
@@ -145,12 +202,30 @@ declare const billingAdminListOutputSchema: z.ZodObject<{
145
202
  unitAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
146
203
  discounts: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
147
204
  }, z.core.$strip>>;
205
+ coupon: z.ZodNullable<z.ZodObject<{
206
+ id: z.ZodString;
207
+ name: z.ZodNullable<z.ZodString>;
208
+ percentOff: z.ZodNullable<z.ZodNumber>;
209
+ amountOff: z.ZodNullable<z.ZodNumber>;
210
+ currency: z.ZodNullable<z.ZodString>;
211
+ duration: z.ZodNullable<z.ZodEnum<{
212
+ forever: "forever";
213
+ once: "once";
214
+ repeating: "repeating";
215
+ }>>;
216
+ durationInMonths: z.ZodNullable<z.ZodNumber>;
217
+ valid: z.ZodBoolean;
218
+ }, z.core.$strip>>;
148
219
  }, z.core.$strip>>;
149
220
  total: z.ZodNumber;
221
+ environment: z.ZodEnum<{
222
+ production: "production";
223
+ sandbox: "sandbox";
224
+ }>;
150
225
  }, z.core.$strip>;
151
- type ComplimentaryDuration = z.infer<typeof complimentaryDurationSchema>;
152
- type EnrollComplimentaryInput = z.infer<typeof enrollComplimentaryInputSchema>;
226
+ type BillingCoupon = z.infer<typeof billingCouponSchema>;
227
+ type CreateAdminSubscriptionInput = z.infer<typeof createAdminSubscriptionInputSchema>;
153
228
  type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;
154
229
  //#endregion
155
- export { AdminOrganizationBillingRow, BillingSchema, ComplimentaryDuration, EnrollComplimentaryInput, adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
230
+ export { AdminOrganizationBillingRow, BillingCoupon, BillingSchema, CreateAdminSubscriptionInput, MAX_TRIAL_DAYS, adminOrganizationBillingRowSchema, applyAdminCouponInputSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingCouponListOutputSchema, billingCouponSchema, billingSchema, cancelAdminSubscriptionInputSchema, createAdminSubscriptionInputSchema, organizationIdInputSchema, setOrganizationCurrencyInputSchema, stripeEnvironmentSchema };
156
231
  //# sourceMappingURL=billing.schema.d.mts.map
@@ -24,17 +24,38 @@ const billingSchema = z.object({
24
24
  unitAmount: z.number().nullish(),
25
25
  discounts: z.array(z.string()).nullish()
26
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({
27
+ const billingCouponSchema = z.object({
28
+ id: z.string(),
29
+ name: z.string().nullable(),
30
+ percentOff: z.number().nullable(),
31
+ amountOff: z.number().nullable(),
32
+ currency: z.string().nullable(),
33
+ duration: z.enum([
34
+ "forever",
35
+ "once",
36
+ "repeating"
37
+ ]).nullable(),
38
+ durationInMonths: z.number().nullable(),
39
+ valid: z.boolean()
40
+ });
41
+ const billingCouponListOutputSchema = z.array(billingCouponSchema);
42
+ const organizationIdInputSchema = z.object({ organizationId: z.string() });
43
+ const MAX_TRIAL_DAYS = 730;
44
+ const stripeEnvironmentSchema = z.enum(["production", "sandbox"]);
45
+ const createAdminSubscriptionInputSchema = z.object({
33
46
  organizationId: z.string(),
34
47
  priceId: z.string(),
35
- duration: complimentaryDurationSchema
48
+ couponId: z.string().optional(),
49
+ trialDays: z.number().int().min(1).max(730).optional()
50
+ });
51
+ const applyAdminCouponInputSchema = z.object({
52
+ organizationId: z.string(),
53
+ couponId: z.string()
54
+ });
55
+ const setOrganizationCurrencyInputSchema = z.object({
56
+ organizationId: z.string(),
57
+ currency: z.string()
36
58
  });
37
- const organizationIdInputSchema = z.object({ organizationId: z.string() });
38
59
  const cancelAdminSubscriptionInputSchema = z.object({
39
60
  organizationId: z.string(),
40
61
  when: z.enum(["immediate", "period_end"])
@@ -44,11 +65,15 @@ const adminOrganizationBillingRowSchema = z.object({
44
65
  organizationId: z.string(),
45
66
  organizationName: z.string(),
46
67
  currency: z.string().nullable(),
47
- subscription: billingSchema.nullable()
68
+ stripeCustomerId: z.string().nullable(),
69
+ defaultTrialDays: z.number().nullable(),
70
+ openSubscription: z.boolean(),
71
+ subscription: billingSchema.nullable(),
72
+ coupon: billingCouponSchema.nullable()
48
73
  });
49
74
  const billingAdminListInputSchema = querySchema;
50
- const billingAdminListOutputSchema = queryListOutput(adminOrganizationBillingRowSchema);
75
+ const billingAdminListOutputSchema = queryListOutput(adminOrganizationBillingRowSchema).extend({ environment: stripeEnvironmentSchema });
51
76
  //#endregion
52
- export { adminOrganizationBillingRowSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingSchema, cancelAdminSubscriptionInputSchema, complimentaryDurationSchema, enrollComplimentaryInputSchema, organizationIdInputSchema };
77
+ export { MAX_TRIAL_DAYS, adminOrganizationBillingRowSchema, applyAdminCouponInputSchema, billingAdminListInputSchema, billingAdminListOutputSchema, billingCouponListOutputSchema, billingCouponSchema, billingSchema, cancelAdminSubscriptionInputSchema, createAdminSubscriptionInputSchema, organizationIdInputSchema, setOrganizationCurrencyInputSchema, stripeEnvironmentSchema };
53
78
 
54
79
  //# 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\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,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,eAAe,EAAE,QAAQ,CAAC,SAAS;CACnC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CACrC,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC;AAIF,MAAa,8BAA8B,EAAE,MAAM;CACjD,EAAE,QAAQ,UAAU;CACpB,EAAE,QAAQ,OAAO;CACjB,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;CAClD,CAAC;AAEF,MAAa,iCAAiC,EAAE,OAAO;CACrD,gBAAgB,EAAE,QAAQ;CAC1B,SAAS,EAAE,QAAQ;CACnB,UAAU;CACX,CAAC;AAEF,MAAa,4BAA4B,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
+ {"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 billingCouponSchema = z.object({\r\n id: z.string(),\r\n name: z.string().nullable(),\r\n percentOff: z.number().nullable(),\r\n amountOff: z.number().nullable(),\r\n currency: z.string().nullable(),\r\n duration: z.enum([\"forever\", \"once\", \"repeating\"]).nullable(),\r\n durationInMonths: z.number().nullable(),\r\n valid: z.boolean(),\r\n});\r\n\r\nexport const billingCouponListOutputSchema = z.array(billingCouponSchema);\r\n\r\nexport const organizationIdInputSchema = z.object({\r\n organizationId: z.string(),\r\n});\r\n\r\nexport const MAX_TRIAL_DAYS = 730;\r\n\r\nexport const stripeEnvironmentSchema = z.enum([\"production\", \"sandbox\"]);\r\n\r\nexport const createAdminSubscriptionInputSchema = z.object({\r\n organizationId: z.string(),\r\n priceId: z.string(),\r\n couponId: z.string().optional(),\r\n trialDays: z.number().int().min(1).max(MAX_TRIAL_DAYS).optional(),\r\n});\r\n\r\nexport const applyAdminCouponInputSchema = z.object({\r\n organizationId: z.string(),\r\n couponId: z.string(),\r\n});\r\n\r\nexport const setOrganizationCurrencyInputSchema = z.object({\r\n organizationId: z.string(),\r\n currency: 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 stripeCustomerId: z.string().nullable(),\r\n defaultTrialDays: z.number().nullable(),\r\n openSubscription: z.boolean(),\r\n subscription: billingSchema.nullable(),\r\n coupon: billingCouponSchema.nullable(),\r\n});\r\n\r\nexport const billingAdminListInputSchema = querySchema;\r\nexport const billingAdminListOutputSchema = queryListOutput(\r\n adminOrganizationBillingRowSchema\r\n).extend({\r\n environment: stripeEnvironmentSchema,\r\n});\r\n\r\nexport type BillingCoupon = z.infer<typeof billingCouponSchema>;\r\nexport type CreateAdminSubscriptionInput = z.infer<typeof createAdminSubscriptionInputSchema>;\r\nexport type AdminOrganizationBillingRow = z.infer<typeof adminOrganizationBillingRowSchema>;\r\n"],"mappings":";;;AAGA,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,eAAe,EAAE,QAAQ,CAAC,SAAS;CACnC,gBAAgB,EAAE,SAAS,CAAC,SAAS;CACrC,YAAY,EAAE,QAAQ,CAAC,SAAS;CAChC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS;CACzC,CAAC;AAIF,MAAa,sBAAsB,EAAE,OAAO;CAC1C,IAAI,EAAE,QAAQ;CACd,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,WAAW,EAAE,QAAQ,CAAC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,UAAU;CACvC,CAAC;AAEF,MAAa,8BAA8B;AAC3C,MAAa,+BAA+B,gBAC1C,kCACD,CAAC,OAAO,EACP,aAAa,yBACd,CAAC"}
@@ -1,3 +1,6 @@
1
+ import { stripeEnvironmentSchema } from "./billing.schema.cjs";
2
+ import { z } from "zod";
3
+
1
4
  //#region src/modules/billing/billing.types.d.ts
2
5
  type StripePlanPrice = {
3
6
  priceId: string;
@@ -27,7 +30,9 @@ type StripePlansConfig = {
27
30
  production: StripePlan[];
28
31
  sandbox: StripePlan[];
29
32
  };
33
+ type StripeEnvironment = z.infer<typeof stripeEnvironmentSchema>;
30
34
  type ResolvedStripePlans = {
35
+ environment: StripeEnvironment;
31
36
  plans: StripePlan[];
32
37
  trialPlanName: Record<string, string>;
33
38
  trialRequiresPaymentMethod: boolean;
@@ -36,5 +41,5 @@ type ResolvedStripePlans = {
36
41
  nonBillableRoleKeys: readonly string[];
37
42
  };
38
43
  //#endregion
39
- export { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
44
+ export { ResolvedStripePlans, StripeEnvironment, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
40
45
  //# sourceMappingURL=billing.types.d.cts.map
@@ -1,3 +1,6 @@
1
+ import { stripeEnvironmentSchema } from "./billing.schema.mjs";
2
+ import { z } from "zod";
3
+
1
4
  //#region src/modules/billing/billing.types.d.ts
2
5
  type StripePlanPrice = {
3
6
  priceId: string;
@@ -27,7 +30,9 @@ type StripePlansConfig = {
27
30
  production: StripePlan[];
28
31
  sandbox: StripePlan[];
29
32
  };
33
+ type StripeEnvironment = z.infer<typeof stripeEnvironmentSchema>;
30
34
  type ResolvedStripePlans = {
35
+ environment: StripeEnvironment;
31
36
  plans: StripePlan[];
32
37
  trialPlanName: Record<string, string>;
33
38
  trialRequiresPaymentMethod: boolean;
@@ -36,5 +41,5 @@ type ResolvedStripePlans = {
36
41
  nonBillableRoleKeys: readonly string[];
37
42
  };
38
43
  //#endregion
39
- export { ResolvedStripePlans, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
44
+ export { ResolvedStripePlans, StripeEnvironment, StripePlan, StripePlanPrice, StripePlanProduct, StripePlansConfig };
40
45
  //# sourceMappingURL=billing.types.d.mts.map
@@ -1,8 +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 isProduction = environment === "production";
5
+ const plans = isProduction ? plansConfig.production : plansConfig.sandbox;
4
6
  return {
5
- plans: environment === "production" ? plansConfig.production : plansConfig.sandbox,
7
+ environment: isProduction ? "production" : "sandbox",
8
+ plans,
6
9
  trialPlanName: plansConfig.trialPlanName ?? {},
7
10
  trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,
8
11
  defaultCurrency: plansConfig.defaultCurrency,
@@ -1 +1 @@
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,SAAS,CAC/C,MAAK,IAAI,SAAS;AAGtB,QAAO,CAAC,GAAG,KAAK;;AAGlB,SAAgB,kBACd,OACA,SACwB;AACxB,QAAO,MAAM,MAAM,SAAS,eAAe,KAAK,C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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 environment: isProduction ? \"production\" : \"sandbox\",\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;CACxB,MAAM,eAAe,gBAAgB;CACrC,MAAM,QAAQ,eAAe,YAAY,aAAa,YAAY;AAClE,QAAO;EACL,aAAa,eAAe,eAAe;EAC3C;EACA,eAAe,YAAY,iBAAiB,EAAE;EAC9C,4BAA4B,Y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BAKoB;CACpB,MAAM,UAAU,KAAK,SAAS;AAC9B,KAAI,CAAC,QAAS,QAAO,EAAE;AACvB,KAAI,8BAA8B,QAAQ,eACxC,QAAO,QAAQ,OAAO,QAAQ,UAAU,MAAM,YAAY,QAAQ,eAAe;AAEnF,QAAO,QAAQ;;AAGjB,SAAgB,sBAAsB,EACpC,UACA,iBAIS;CACT,MAAM,QAAQ,iBAAiB;AAC/B,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI,UAAU,KAAK,aAAa,QAAS,QAAO;AAChD,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,MAAO,QAAO;AAC9C,KAAI,aAAa,WAAW,UAAU,EAAG,QAAO;AAChD,QAAO,SAAS,MAAM,GAAG,WAAW,UAAU,IAAI,KAAK"}
@@ -1,7 +1,10 @@
1
1
  //#region src/modules/billing/billing.utils.ts
2
2
  const getEnvironmentPlans = (plansConfig, environment = "sandbox") => {
3
+ const isProduction = environment === "production";
4
+ const plans = isProduction ? plansConfig.production : plansConfig.sandbox;
3
5
  return {
4
- plans: environment === "production" ? plansConfig.production : plansConfig.sandbox,
6
+ environment: isProduction ? "production" : "sandbox",
7
+ plans,
5
8
  trialPlanName: plansConfig.trialPlanName ?? {},
6
9
  trialRequiresPaymentMethod: plansConfig.trialRequiresPaymentMethod ?? false,
7
10
  defaultCurrency: plansConfig.defaultCurrency,
@@ -1 +1 @@
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,eAA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I,UAAU,KAAK,aAAa,QAAS,QAAO;AAChD,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,MAAO,QAAO;AAC9C,KAAI,aAAa,WAAW,UAAU,EAAG,QAAO;AAChD,QAAO,SAAS,MAAM,GAAG,WAAW,UAAU,IAAI,KAAK"}
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 environment: isProduction ? \"production\" : \"sandbox\",\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;CACxB,MAAM,eAAe,gBAAgB;CACrC,MAAM,QAAQ,eAAe,YAAY,aAAa,YAAY;AAClE,QAAO;EACL,aAAa,eAAe,eAAe;EAC3C;EACA,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,eAAe,KAAK,CAAC,MAAM,UAAU,MAAM,YAAY,QAAQ,CAAC;;AAG9F,SAAgB,kBAAkB,MAAkB,SAAqC;AACvF,MAAK,MAAM,CAAC,UAAU,YAAY,OAAO,QAAQ,KAAK,SAAS,CAC7D,KAAI,QAAQ,OAAO,MAAM,UAAU,MAAM,YAAY,QAAQ,CAAE,QAAO;;AAK1E,SAAgB,cAAc,EAC5B,OACA,eACA,YAKyB;CACzB,MAAM,OAAO,cAAc;AAC3B,KAAI,CAAC,KAAM,QAAO,KAAA;AAClB,QAAO,MAAM,MAAM,SAAS,KAAK,SAAS,KAAK;;AAGjD,SAAgB,sBAAsB,EACpC,MACA,YAI8B;CAC9B,MAAM,UAAU,KAAK,SAAS;AAC9B,KAAI,CAAC,SAAS,eAAgB,QAAO,KAAA;AACrC,QAAO,QAAQ,OAAO,MAAM,UAAU,MAAM,YAAY,QAAQ,eAAe;;AAGjF,SAAgB,qBAAqB,EACnC,MACA,UACA,8BAKoB;CACpB,MAAM,UAAU,KAAK,SAAS;AAC9B,KAAI,CAAC,QAAS,QAAO,EAAE;AACvB,KAAI,8BAA8B,QAAQ,eACxC,QAAO,QAAQ,OAAO,QAAQ,UAAU,MAAM,YAAY,QAAQ,eAAe;AAEnF,QAAO,QAAQ;;AAGjB,SAAgB,sBAAsB,EACpC,UACA,iBAIS;CACT,MAAM,QAAQ,iBAAiB;AAC/B,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI,UAAU,KAAK,aAAa,QAAS,QAAO;AAChD,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,OAAQ,QAAO;AAC/C,KAAI,UAAU,KAAK,aAAa,MAAO,QAAO;AAC9C,KAAI,aAAa,WAAW,UAAU,EAAG,QAAO;AAChD,QAAO,SAAS,MAAM,GAAG,WAAW,UAAU,IAAI,KAAK"}
@@ -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";
16
15
  pending: "pending";
17
16
  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";
117
116
  pending: "pending";
118
117
  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";
151
150
  pending: "pending";
152
151
  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";
16
15
  pending: "pending";
17
16
  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";
117
116
  pending: "pending";
118
117
  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";
151
150
  pending: "pending";
152
151
  sent: "sent";
152
+ failed: "failed";
153
153
  }>;
154
154
  error: z.ZodNullable<z.ZodString>;
155
155
  jobId: z.ZodNullable<z.ZodString>;
@@ -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";
14
15
  queued: "queued";
15
16
  running: "running";
16
17
  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";
31
32
  queued: "queued";
32
33
  running: "running";
33
34
  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";
54
55
  queued: "queued";
55
56
  running: "running";
56
57
  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";
76
77
  queued: "queued";
77
78
  running: "running";
78
79
  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";
14
15
  queued: "queued";
15
16
  running: "running";
16
17
  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";
31
32
  queued: "queued";
32
33
  running: "running";
33
34
  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";
54
55
  queued: "queued";
55
56
  running: "running";
56
57
  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";
76
77
  queued: "queued";
77
78
  running: "running";
78
79
  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.38.10",
3
+ "version": "0.38.12",
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.10"
24
+ "@m5kdev/config": "0.38.12"
25
25
  },
26
26
  "exports": {
27
27
  "./utils/*": {