@fantastic.dev/better-stripe 0.79.1 → 0.80.0

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalPriceReplacement.d.ts +131 -0
  4. package/dist/client/billing/renewalPriceReplacement.d.ts.map +1 -0
  5. package/dist/client/billing/renewalPriceReplacement.js +90 -0
  6. package/dist/client/billing/renewalPriceReplacement.js.map +1 -0
  7. package/dist/client/billing/renewalReplacementSchema.d.ts +124 -0
  8. package/dist/client/billing/renewalReplacementSchema.d.ts.map +1 -0
  9. package/dist/client/billing/renewalReplacementSchema.js +121 -0
  10. package/dist/client/billing/renewalReplacementSchema.js.map +1 -0
  11. package/dist/client/billing/renewalReplacementSnapshot.d.ts +3 -0
  12. package/dist/client/billing/renewalReplacementSnapshot.d.ts.map +1 -0
  13. package/dist/client/billing/renewalReplacementSnapshot.js +69 -0
  14. package/dist/client/billing/renewalReplacementSnapshot.js.map +1 -0
  15. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  16. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  17. package/dist/client/index.d.ts +3 -0
  18. package/dist/client/index.d.ts.map +1 -1
  19. package/dist/client/index.js +1 -0
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/usage/observationClient.d.ts +2 -2
  22. package/dist/client/usage/observationClient.d.ts.map +1 -1
  23. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  24. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  25. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  26. package/dist/component/earnings/triggers.d.ts +16 -16
  27. package/docs/client-api.md +5 -0
  28. package/docs/renewal-price-replacements.md +186 -0
  29. package/package.json +1 -1
  30. package/src/client/billing/renewal-price-replacement.test.ts +457 -0
  31. package/src/client/billing/renewalPriceReplacement.ts +127 -0
  32. package/src/client/billing/renewalReplacementSchema.ts +129 -0
  33. package/src/client/billing/renewalReplacementSnapshot.ts +85 -0
  34. package/src/client/index.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -26,6 +26,12 @@
26
26
  - Remove internal tracker references from public documentation and add a
27
27
  regression check that prevents their reintroduction.
28
28
 
29
+ ## [0.80.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.79.1...v0.80.0) (2026-10-27)
30
+
31
+ ### Features
32
+
33
+ - **billing:** prepare bound renewal replacement snapshots ([#394](https://github.com/FantasticDevHQ/better-stripe/issues/394)) ([42514b7](https://github.com/FantasticDevHQ/better-stripe/commit/42514b7c045bc845e4e96549eb5d0af75a762b0b))
34
+
29
35
  ## [0.79.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.79.0...v0.79.1) (2026-10-26)
30
36
 
31
37
  ### Maintenance
package/README.md CHANGED
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
5
5
  syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
6
6
  hooks and headless UI components.
7
7
 
8
- **Version**: `0.79.1` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
8
+ **Version**: `0.80.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
9
9
 
10
10
  Connect platforms use the default GA API version. Non-Connect merchants using
11
11
  customer-only Accounts v2 need preview access and an explicit preview version.
@@ -0,0 +1,131 @@
1
+ import { type RenewalPriceReplacementExpected } from "./renewalReplacementSchema.js";
2
+ export type PrepareRenewalPriceReplacementOptions = {
3
+ subscription: unknown;
4
+ targetPrice: unknown;
5
+ billingCustomer?: unknown;
6
+ expected: RenewalPriceReplacementExpected;
7
+ key: string;
8
+ };
9
+ /**
10
+ * Pure read qualification, not write authorization or proof of preservation.
11
+ * Supply fresh full provider reads on the trusted server. Persist the result
12
+ * under host-owned immutable authorization before any later dispatch.
13
+ */
14
+ export declare function prepareRenewalPriceReplacement(options: PrepareRenewalPriceReplacementOptions): {
15
+ version: 1;
16
+ scope: "platform";
17
+ expected: {
18
+ customerAccountId: string;
19
+ subscriptionId: string;
20
+ itemId: string;
21
+ currentPriceId: string;
22
+ currentProductId: string;
23
+ targetPriceId: string;
24
+ targetProductId: string;
25
+ periodStart: number;
26
+ periodEnd: number;
27
+ livemode: boolean;
28
+ };
29
+ quantity: number;
30
+ providerSnapshot: {
31
+ subscription: {
32
+ [x: string]: unknown;
33
+ id: string;
34
+ object: "subscription";
35
+ customer_account: string;
36
+ status: "active";
37
+ currency: string;
38
+ livemode: boolean;
39
+ schedule: null;
40
+ cancel_at: null;
41
+ cancel_at_period_end: false;
42
+ pause_collection: null;
43
+ pending_update: null;
44
+ default_source: null;
45
+ application_fee_percent: null;
46
+ payment_settings: {
47
+ payment_method_options: null;
48
+ payment_method_types: null;
49
+ save_default_payment_method: "off" | null;
50
+ } | null;
51
+ billing_schedules?: unknown[] | undefined;
52
+ items: {
53
+ [x: string]: unknown;
54
+ has_more: false;
55
+ data: [{
56
+ [x: string]: unknown;
57
+ id: string;
58
+ object: "subscription_item";
59
+ subscription: string;
60
+ current_period_start: number;
61
+ current_period_end: number;
62
+ quantity: number;
63
+ price: {
64
+ [x: string]: unknown;
65
+ id: string;
66
+ object: "price";
67
+ product: string | {
68
+ [x: string]: unknown;
69
+ id: string;
70
+ deleted?: false | undefined;
71
+ };
72
+ active: boolean;
73
+ livemode: boolean;
74
+ type: "recurring";
75
+ currency: string;
76
+ billing_scheme: "per_unit";
77
+ recurring: {
78
+ [x: string]: unknown;
79
+ interval: "day" | "month" | "week" | "year";
80
+ interval_count: number;
81
+ usage_type: "licensed";
82
+ };
83
+ };
84
+ }];
85
+ };
86
+ };
87
+ targetPrice: {
88
+ [x: string]: unknown;
89
+ id: string;
90
+ object: "price";
91
+ product: string | {
92
+ [x: string]: unknown;
93
+ id: string;
94
+ deleted?: false | undefined;
95
+ };
96
+ active: boolean;
97
+ livemode: boolean;
98
+ type: "recurring";
99
+ currency: string;
100
+ billing_scheme: "per_unit";
101
+ recurring: {
102
+ [x: string]: unknown;
103
+ interval: "day" | "month" | "week" | "year";
104
+ interval_count: number;
105
+ usage_type: "licensed";
106
+ };
107
+ };
108
+ billingCustomer?: {
109
+ [x: string]: unknown;
110
+ id: string;
111
+ object: "customer";
112
+ customer_account: string;
113
+ livemode: boolean;
114
+ deleted?: false | undefined;
115
+ discount: {
116
+ [x: string]: unknown;
117
+ id: string;
118
+ object: "discount";
119
+ deleted?: false | undefined;
120
+ } | null;
121
+ } | undefined;
122
+ };
123
+ status: "prepared";
124
+ preservation: "requires_schedule_validation";
125
+ requestIdentity: {
126
+ key: string;
127
+ binding: string;
128
+ };
129
+ };
130
+ export type PreparedRenewalPriceReplacement = ReturnType<typeof prepareRenewalPriceReplacement>;
131
+ //# sourceMappingURL=renewalPriceReplacement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalPriceReplacement.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,+BAA+B,EACrC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,qCAAqC,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,+BAA+B,CAAC;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,qCAAqC;aAkFnC,CAAC;WACH,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAOT,UAAU;kBACJ,8BAA8B;;;;;EAM/C;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,8BAA8B,CACtC,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { idempotencyOptions } from "../core/idempotency.js";
2
+ import { renewalExpected, renewalBillingCustomer, renewalPreparationInput, renewalPrice, renewalSubscription, } from "./renewalReplacementSchema.js";
3
+ import { renewalSnapshot } from "./renewalReplacementSnapshot.js";
4
+ /**
5
+ * Pure read qualification, not write authorization or proof of preservation.
6
+ * Supply fresh full provider reads on the trusted server. Persist the result
7
+ * under host-owned immutable authorization before any later dispatch.
8
+ */
9
+ export function prepareRenewalPriceReplacement(options) {
10
+ const args = renewalPreparationInput.parse(renewalSnapshot(options));
11
+ const key = idempotencyOptions(args.key)?.idempotencyKey;
12
+ if (!key)
13
+ throw new Error("Renewal preparation requires an explicit key.");
14
+ const expected = renewalExpected.parse(args.expected);
15
+ const source = renewalSnapshot({
16
+ subscription: args.subscription,
17
+ targetPrice: args.targetPrice,
18
+ });
19
+ const subscription = renewalSubscription.parse(source.subscription);
20
+ const targetPrice = renewalPrice.parse(source.targetPrice);
21
+ const billingCustomer = args.billingCustomer === undefined
22
+ ? undefined
23
+ : renewalBillingCustomer.parse(args.billingCustomer);
24
+ if (billingCustomer !== undefined) {
25
+ const reference = subscription.customer;
26
+ const referenceId = typeof reference === "string"
27
+ ? reference
28
+ : typeof reference === "object" &&
29
+ reference !== null &&
30
+ "id" in reference &&
31
+ "object" in reference &&
32
+ reference.object === "customer" &&
33
+ !("deleted" in reference && reference.deleted === true)
34
+ ? reference.id
35
+ : undefined;
36
+ if (referenceId !== billingCustomer.id ||
37
+ billingCustomer.customer_account !== expected.customerAccountId ||
38
+ billingCustomer.livemode !== expected.livemode)
39
+ throw new Error("Billing customer evidence does not match the original subscription account.");
40
+ }
41
+ const item = subscription.items.data[0];
42
+ const current = item.price;
43
+ const productId = (p) => typeof p === "string" ? p : p.id;
44
+ if (subscription.id !== expected.subscriptionId ||
45
+ subscription.customer_account !== expected.customerAccountId ||
46
+ item.subscription !== expected.subscriptionId ||
47
+ item.id !== expected.itemId ||
48
+ current.id !== expected.currentPriceId ||
49
+ productId(current.product) !== expected.currentProductId ||
50
+ targetPrice.id !== expected.targetPriceId ||
51
+ productId(targetPrice.product) !== expected.targetProductId ||
52
+ item.current_period_start !== expected.periodStart ||
53
+ item.current_period_end !== expected.periodEnd ||
54
+ [subscription.livemode, current.livemode, targetPrice.livemode].some((mode) => mode !== expected.livemode))
55
+ throw new Error("Renewal replacement does not match the authorized original and target.");
56
+ if (!targetPrice.active ||
57
+ current.id === targetPrice.id ||
58
+ subscription.currency !== current.currency ||
59
+ current.currency !== targetPrice.currency)
60
+ throw new Error("The target must be a different active recurring price in the original subscription currency; alternative currency_options require separate validation.");
61
+ for (const field of [
62
+ "pending_invoice_item_interval",
63
+ "pending_setup_intent",
64
+ "pause_schedules",
65
+ ])
66
+ if (subscription[field] != null)
67
+ throw new Error(`Renewal replacement does not support ${field}.`);
68
+ const providerSnapshot = renewalSnapshot({
69
+ subscription,
70
+ targetPrice,
71
+ ...(billingCustomer === undefined ? {} : { billingCustomer }),
72
+ });
73
+ const bound = {
74
+ version: 1,
75
+ scope: "platform",
76
+ expected,
77
+ quantity: item.quantity,
78
+ providerSnapshot,
79
+ };
80
+ return {
81
+ ...bound,
82
+ status: "prepared",
83
+ preservation: "requires_schedule_validation",
84
+ requestIdentity: {
85
+ key,
86
+ binding: `renewal:v1:${JSON.stringify(renewalSnapshot(bound))}`,
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=renewalPriceReplacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalPriceReplacement.js","sourceRoot":"","sources":["../../../src/client/billing/renewalPriceReplacement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,YAAY,EACZ,mBAAmB,GAEpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAUlE;;;;GAIG;AAC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,CAAC,QAAQ,CACrC;QAED,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;IACJ,IACE,CAAC,WAAW,CAAC,MAAM;QACnB,OAAO,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE;QAC7B,YAAY,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ;QAC1C,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ;QAEzC,MAAM,IAAI,KAAK,CACb,wJAAwJ,CACzJ,CAAC;IACJ,KAAK,MAAM,KAAK,IAAI;QAClB,+BAA+B;QAC/B,sBAAsB;QACtB,iBAAiB;KAClB;QACC,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,IAAI;YAC7B,MAAM,IAAI,KAAK,CAAC,wCAAwC,KAAK,GAAG,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,eAAe,CAAC;QACvC,YAAY;QACZ,WAAW;QACX,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC;KAC9D,CAAC,CAAC;IACH,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE,CAAU;QACnB,KAAK,EAAE,UAAmB;QAC1B,QAAQ;QACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,gBAAgB;KACjB,CAAC;IACF,OAAO;QACL,GAAG,KAAK;QACR,MAAM,EAAE,UAAmB;QAC3B,YAAY,EAAE,8BAAuC;QACrD,eAAe,EAAE;YACf,GAAG;YACH,OAAO,EAAE,cAAc,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;SAChE;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,124 @@
1
+ import { z } from "zod";
2
+ export declare const renewalPrice: z.ZodObject<{
3
+ id: z.ZodString;
4
+ object: z.ZodLiteral<"price">;
5
+ product: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
6
+ id: z.ZodString;
7
+ deleted: z.ZodOptional<z.ZodLiteral<false>>;
8
+ }, z.core.$loose>]>;
9
+ active: z.ZodBoolean;
10
+ livemode: z.ZodBoolean;
11
+ type: z.ZodLiteral<"recurring">;
12
+ currency: z.ZodString;
13
+ billing_scheme: z.ZodLiteral<"per_unit">;
14
+ recurring: z.ZodObject<{
15
+ interval: z.ZodEnum<{
16
+ day: "day";
17
+ month: "month";
18
+ week: "week";
19
+ year: "year";
20
+ }>;
21
+ interval_count: z.ZodNumber;
22
+ usage_type: z.ZodLiteral<"licensed">;
23
+ }, z.core.$loose>;
24
+ }, z.core.$loose>;
25
+ export declare const renewalExpected: z.ZodObject<{
26
+ customerAccountId: z.ZodString;
27
+ subscriptionId: z.ZodString;
28
+ itemId: z.ZodString;
29
+ currentPriceId: z.ZodString;
30
+ currentProductId: z.ZodString;
31
+ targetPriceId: z.ZodString;
32
+ targetProductId: z.ZodString;
33
+ periodStart: z.ZodNumber;
34
+ periodEnd: z.ZodNumber;
35
+ livemode: z.ZodBoolean;
36
+ }, z.core.$strict>;
37
+ export declare const renewalSubscription: z.ZodObject<{
38
+ id: z.ZodString;
39
+ object: z.ZodLiteral<"subscription">;
40
+ customer_account: z.ZodString;
41
+ status: z.ZodLiteral<"active">;
42
+ currency: z.ZodString;
43
+ livemode: z.ZodBoolean;
44
+ schedule: z.ZodNull;
45
+ cancel_at: z.ZodNull;
46
+ cancel_at_period_end: z.ZodLiteral<false>;
47
+ pause_collection: z.ZodNull;
48
+ pending_update: z.ZodNull;
49
+ default_source: z.ZodNull;
50
+ application_fee_percent: z.ZodNull;
51
+ payment_settings: z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
52
+ payment_method_options: z.ZodNull;
53
+ payment_method_types: z.ZodNull;
54
+ save_default_payment_method: z.ZodNullable<z.ZodLiteral<"off">>;
55
+ }, z.core.$strict>]>;
56
+ billing_schedules: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
57
+ items: z.ZodObject<{
58
+ has_more: z.ZodLiteral<false>;
59
+ data: z.ZodTuple<[z.ZodObject<{
60
+ id: z.ZodString;
61
+ object: z.ZodLiteral<"subscription_item">;
62
+ subscription: z.ZodString;
63
+ current_period_start: z.ZodNumber;
64
+ current_period_end: z.ZodNumber;
65
+ quantity: z.ZodNumber;
66
+ price: z.ZodObject<{
67
+ id: z.ZodString;
68
+ object: z.ZodLiteral<"price">;
69
+ product: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
70
+ id: z.ZodString;
71
+ deleted: z.ZodOptional<z.ZodLiteral<false>>;
72
+ }, z.core.$loose>]>;
73
+ active: z.ZodBoolean;
74
+ livemode: z.ZodBoolean;
75
+ type: z.ZodLiteral<"recurring">;
76
+ currency: z.ZodString;
77
+ billing_scheme: z.ZodLiteral<"per_unit">;
78
+ recurring: z.ZodObject<{
79
+ interval: z.ZodEnum<{
80
+ day: "day";
81
+ month: "month";
82
+ week: "week";
83
+ year: "year";
84
+ }>;
85
+ interval_count: z.ZodNumber;
86
+ usage_type: z.ZodLiteral<"licensed">;
87
+ }, z.core.$loose>;
88
+ }, z.core.$loose>;
89
+ }, z.core.$loose>], null>;
90
+ }, z.core.$loose>;
91
+ }, z.core.$loose>;
92
+ /** Trusted host selectors from the original authorized operation, not browser claims. */
93
+ export type RenewalPriceReplacementExpected = z.infer<typeof renewalExpected>;
94
+ export declare const renewalBillingCustomer: z.ZodObject<{
95
+ id: z.ZodString;
96
+ object: z.ZodLiteral<"customer">;
97
+ customer_account: z.ZodString;
98
+ livemode: z.ZodBoolean;
99
+ deleted: z.ZodOptional<z.ZodLiteral<false>>;
100
+ discount: z.ZodUnion<readonly [z.ZodNull, z.ZodObject<{
101
+ id: z.ZodString;
102
+ object: z.ZodLiteral<"discount">;
103
+ deleted: z.ZodOptional<z.ZodLiteral<false>>;
104
+ }, z.core.$loose>]>;
105
+ }, z.core.$loose>;
106
+ export declare const renewalPreparationInput: z.ZodObject<{
107
+ subscription: z.ZodUnknown;
108
+ targetPrice: z.ZodUnknown;
109
+ billingCustomer: z.ZodOptional<z.ZodUnknown>;
110
+ expected: z.ZodObject<{
111
+ customerAccountId: z.ZodString;
112
+ subscriptionId: z.ZodString;
113
+ itemId: z.ZodString;
114
+ currentPriceId: z.ZodString;
115
+ currentProductId: z.ZodString;
116
+ targetPriceId: z.ZodString;
117
+ targetProductId: z.ZodString;
118
+ periodStart: z.ZodNumber;
119
+ periodEnd: z.ZodNumber;
120
+ livemode: z.ZodBoolean;
121
+ }, z.core.$strict>;
122
+ key: z.ZodString;
123
+ }, z.core.$strict>;
124
+ //# sourceMappingURL=renewalReplacementSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalReplacementSchema.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalReplacementSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;iBAkBT,CAAC;AAEjB,eAAO,MAAM,eAAe;;;;;;;;;;;kBAc6C,CAAC;AAE1E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6ChB,CAAC;AAEjB,yFAAyF;AACzF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9E,eAAO,MAAM,sBAAsB;;;;;;;;;;;iBAkBnB,CAAC;AAEjB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;kBAQzB,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { z } from "zod";
2
+ const id = (prefix) => z
3
+ .string()
4
+ .max(255)
5
+ .regex(new RegExp(`^${prefix}_[A-Za-z0-9_]+$`));
6
+ const integer = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
7
+ const product = z.union([
8
+ id("prod"),
9
+ z
10
+ .object({ id: id("prod"), deleted: z.literal(false).optional() })
11
+ .passthrough(),
12
+ ]);
13
+ export const renewalPrice = z
14
+ .object({
15
+ id: id("price"),
16
+ object: z.literal("price"),
17
+ product,
18
+ active: z.boolean(),
19
+ livemode: z.boolean(),
20
+ type: z.literal("recurring"),
21
+ currency: z.string().regex(/^[a-z]{3}$/),
22
+ billing_scheme: z.literal("per_unit"),
23
+ recurring: z
24
+ .object({
25
+ interval: z.enum(["day", "week", "month", "year"]),
26
+ interval_count: integer,
27
+ usage_type: z.literal("licensed"),
28
+ })
29
+ .passthrough(),
30
+ })
31
+ .passthrough();
32
+ export const renewalExpected = z
33
+ .object({
34
+ customerAccountId: id("acct"),
35
+ subscriptionId: id("sub"),
36
+ itemId: id("si"),
37
+ currentPriceId: id("price"),
38
+ currentProductId: id("prod"),
39
+ targetPriceId: id("price"),
40
+ targetProductId: id("prod"),
41
+ periodStart: integer,
42
+ periodEnd: integer,
43
+ livemode: z.boolean(),
44
+ })
45
+ .strict()
46
+ .refine((v) => v.periodEnd > v.periodStart, "Invalid original period.");
47
+ export const renewalSubscription = z
48
+ .object({
49
+ id: id("sub"),
50
+ object: z.literal("subscription"),
51
+ customer_account: id("acct"),
52
+ status: z.literal("active"),
53
+ currency: z.string().regex(/^[a-z]{3}$/),
54
+ livemode: z.boolean(),
55
+ schedule: z.null(),
56
+ cancel_at: z.null(),
57
+ cancel_at_period_end: z.literal(false),
58
+ pause_collection: z.null(),
59
+ pending_update: z.null(),
60
+ default_source: z.null(),
61
+ application_fee_percent: z.null(),
62
+ payment_settings: z.union([
63
+ z.null(),
64
+ z
65
+ .object({
66
+ payment_method_options: z.null(),
67
+ payment_method_types: z.null(),
68
+ save_default_payment_method: z.literal("off").nullable(),
69
+ })
70
+ .strict(),
71
+ ]),
72
+ billing_schedules: z.array(z.unknown()).length(0).optional(),
73
+ items: z
74
+ .object({
75
+ has_more: z.literal(false),
76
+ data: z.tuple([
77
+ z
78
+ .object({
79
+ id: id("si"),
80
+ object: z.literal("subscription_item"),
81
+ subscription: id("sub"),
82
+ current_period_start: integer,
83
+ current_period_end: integer,
84
+ quantity: integer,
85
+ price: renewalPrice,
86
+ })
87
+ .passthrough(),
88
+ ]),
89
+ })
90
+ .passthrough(),
91
+ })
92
+ .passthrough();
93
+ export const renewalBillingCustomer = z
94
+ .object({
95
+ id: id("cus"),
96
+ object: z.literal("customer"),
97
+ customer_account: id("acct"),
98
+ livemode: z.boolean(),
99
+ deleted: z.literal(false).optional(),
100
+ discount: z.union([
101
+ z.null(),
102
+ z
103
+ .object({
104
+ id: id("di"),
105
+ object: z.literal("discount"),
106
+ deleted: z.literal(false).optional(),
107
+ })
108
+ .passthrough(),
109
+ ]),
110
+ })
111
+ .passthrough();
112
+ export const renewalPreparationInput = z
113
+ .object({
114
+ subscription: z.unknown(),
115
+ targetPrice: z.unknown(),
116
+ billingCustomer: z.unknown().optional(),
117
+ expected: renewalExpected,
118
+ key: z.string(),
119
+ })
120
+ .strict();
121
+ //# sourceMappingURL=renewalReplacementSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalReplacementSchema.js","sourceRoot":"","sources":["../../../src/client/billing/renewalReplacementSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,EAAE,GAAG,CAAC,MAAc,EAAE,EAAE,CAC5B,CAAC;KACE,MAAM,EAAE;KACR,GAAG,CAAC,GAAG,CAAC;KACR,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,iBAAiB,CAAC,CAAC,CAAC;AACpD,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACzE,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC;IACtB,EAAE,CAAC,MAAM,CAAC;IACV,CAAC;SACE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,C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CAAC;CACH,CAAC;KACD,WAAW,EAAE,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC;KACrC,MAAM,CAAC;IACN,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;IACzB,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE;IACxB,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,QAAQ,EAAE,eAAe;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** A bounded JSON copy. Reject non-JSON values rather than silently dropping them. */
2
+ export declare function renewalSnapshot<T>(value: T): T;
3
+ //# sourceMappingURL=renewalReplacementSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalReplacementSnapshot.d.ts","sourceRoot":"","sources":["../../../src/client/billing/renewalReplacementSnapshot.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAmF9C"}
@@ -0,0 +1,69 @@
1
+ /** A bounded JSON copy. Reject non-JSON values rather than silently dropping them. */
2
+ export function renewalSnapshot(value) {
3
+ const seen = new Set();
4
+ let nodes = 0;
5
+ let characters = 500_000;
6
+ function charge(size) {
7
+ characters -= size;
8
+ if (characters < 0)
9
+ throw new Error("Renewal snapshot exceeds its JSON size budget.");
10
+ }
11
+ function copy(item, depth) {
12
+ if (++nodes > 10_000 || depth > 40)
13
+ throw new Error("Renewal snapshot exceeds its JSON traversal budget.");
14
+ if (typeof item === "string") {
15
+ charge(item.length);
16
+ return item;
17
+ }
18
+ if (item === null || typeof item === "boolean")
19
+ return item;
20
+ if (typeof item === "number" && Number.isFinite(item))
21
+ return item;
22
+ if (typeof item !== "object" || item === null || seen.has(item))
23
+ throw new Error("Renewal snapshot must contain finite JSON values.");
24
+ if (!Array.isArray(item) &&
25
+ ![Object.prototype, null].includes(Object.getPrototypeOf(item)))
26
+ throw new Error("Renewal snapshot must contain plain JSON objects.");
27
+ if (Array.isArray(item) && item.length > 10_000)
28
+ throw new Error("Renewal snapshot array is too large for its JSON budget.");
29
+ seen.add(item);
30
+ const entries = [];
31
+ for (const key in item) {
32
+ const entry = Object.getOwnPropertyDescriptor(item, key);
33
+ if (!entry)
34
+ continue;
35
+ if (!("value" in entry))
36
+ throw new Error("Renewal snapshot must contain JSON data properties.");
37
+ if (entries.length >= 10_000)
38
+ throw new Error("Renewal snapshot object exceeds its JSON traversal budget.");
39
+ charge(key.length);
40
+ entries.push([key, entry.value]);
41
+ }
42
+ if (Object.getOwnPropertySymbols(item).some((key) => Object.getOwnPropertyDescriptor(item, key)?.enumerable))
43
+ throw new Error("Renewal snapshot must contain JSON data properties.");
44
+ let result;
45
+ if (Array.isArray(item)) {
46
+ if (entries.some(([key]) => !/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= item.length))
47
+ throw new Error("Renewal snapshot arrays must contain only JSON elements.");
48
+ result = Array.from({ length: item.length }, (_, index) => {
49
+ const entry = Object.getOwnPropertyDescriptor(item, String(index));
50
+ if (!entry || !("value" in entry))
51
+ throw new Error("Renewal snapshot must not contain sparse JSON arrays.");
52
+ return copy(entry.value, depth + 1);
53
+ });
54
+ }
55
+ else {
56
+ result = Object.fromEntries(entries
57
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
58
+ .map(([key, entry]) => [key, copy(entry, depth + 1)]));
59
+ }
60
+ seen.delete(item);
61
+ return result;
62
+ }
63
+ const normalized = copy(value, 0);
64
+ const serialized = JSON.stringify(normalized);
65
+ if (serialized.length > 500_000)
66
+ throw new Error("Renewal snapshot is too large.");
67
+ return JSON.parse(serialized);
68
+ }
69
+ //# sourceMappingURL=renewalReplacementSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renewalReplacementSnapshot.js","sourceRoot":"","sources":["../../../src/client/billing/renewalReplac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