@fantastic.dev/better-stripe 0.82.0 → 0.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/couponJoins.d.ts +23 -0
- package/dist/client/billing/renewalAttach/couponJoins.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/couponJoins.js +76 -0
- package/dist/client/billing/renewalAttach/couponJoins.js.map +1 -0
- package/dist/client/billing/renewalAttach/index.d.ts +3 -0
- package/dist/client/billing/renewalAttach/index.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/index.js +3 -0
- package/dist/client/billing/renewalAttach/index.js.map +1 -0
- package/dist/client/billing/renewalAttach/reader.d.ts +141 -0
- package/dist/client/billing/renewalAttach/reader.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/reader.js +77 -0
- package/dist/client/billing/renewalAttach/reader.js.map +1 -0
- package/dist/client/billing/renewalAttach/request.d.ts +30 -0
- package/dist/client/billing/renewalAttach/request.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/request.js +39 -0
- package/dist/client/billing/renewalAttach/request.js.map +1 -0
- package/dist/client/billing/renewalAttach/wireJson.d.ts +24 -0
- package/dist/client/billing/renewalAttach/wireJson.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/wireJson.js +51 -0
- package/dist/client/billing/renewalAttach/wireJson.js.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/helpers.d.ts.map +1 -1
- package/dist/client/helpers.js +2 -2
- package/dist/client/helpers.js.map +1 -1
- package/dist/client/index.d.ts +3 -5
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/renewal.d.ts +8 -0
- package/dist/client/renewal.d.ts.map +1 -0
- package/dist/client/renewal.js +4 -0
- package/dist/client/renewal.js.map +1 -0
- package/dist/client/renewalContextClient.d.ts +130 -0
- package/dist/client/renewalContextClient.d.ts.map +1 -0
- package/dist/client/renewalContextClient.js +10 -0
- package/dist/client/renewalContextClient.js.map +1 -0
- package/dist/client/singleAttemptHttpClient.d.ts +1 -1
- package/dist/client/singleAttemptHttpClient.d.ts.map +1 -1
- package/dist/client/singleAttemptHttpClient.js +1 -1
- package/dist/client/singleAttemptHttpClient.js.map +1 -1
- package/dist/client/strictStripeTransport.d.ts +4 -0
- package/dist/client/strictStripeTransport.d.ts.map +1 -0
- package/dist/client/strictStripeTransport.js +7 -0
- package/dist/client/strictStripeTransport.js.map +1 -0
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +146 -0
- package/docs/renewal-price-replacements.md +55 -16
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/couponEvidence.test.ts +103 -0
- package/src/client/billing/renewalAttach/couponJoins.ts +92 -0
- package/src/client/billing/renewalAttach/index.ts +9 -0
- package/src/client/billing/renewalAttach/reader.test.ts +409 -0
- package/src/client/billing/renewalAttach/reader.ts +125 -0
- package/src/client/billing/renewalAttach/request.ts +49 -0
- package/src/client/billing/renewalAttach/wireJson.test.ts +265 -0
- package/src/client/billing/renewalAttach/wireJson.ts +75 -0
- package/src/client/helpers.ts +2 -4
- package/src/client/index.ts +3 -8
- package/src/client/renewal.ts +13 -0
- package/src/client/renewalContextClient.ts +23 -0
- package/src/client/singleAttemptHttpClient.ts +1 -1
- package/src/client/strictStripeTransport.test.ts +73 -0
- package/src/client/strictStripeTransport.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -26,6 +26,18 @@
|
|
|
26
26
|
- Remove internal tracker references from public documentation and add a
|
|
27
27
|
regression check that prevents their reintroduction.
|
|
28
28
|
|
|
29
|
+
## [0.83.1](https://github.com/FantasticDevHQ/better-stripe/compare/v0.83.0...v0.83.1) (2026-10-27)
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
- preserve renewal wire JSON and prevent redirect replay ([#402](https://github.com/FantasticDevHQ/better-stripe/issues/402)) ([481a902](https://github.com/FantasticDevHQ/better-stripe/commit/481a902a9182edd92f8dc0b01bf9e5c5892cf8f9))
|
|
34
|
+
|
|
35
|
+
## [0.83.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.82.0...v0.83.0) (2026-10-27)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
- read bound renewal context and prepare attach requests ([#400](https://github.com/FantasticDevHQ/better-stripe/issues/400)) ([d0621ec](https://github.com/FantasticDevHQ/better-stripe/commit/d0621ec0e8118b7ad86097c9425e63313b0a3d80))
|
|
40
|
+
|
|
29
41
|
## [0.82.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.81.0...v0.82.0) (2026-10-27)
|
|
30
42
|
|
|
31
43
|
### Features
|
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.
|
|
8
|
+
**Version**: `0.83.1` <!-- 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,23 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
/** Explicit bounded joins, never a fallback for failed or over-depth expansion. */
|
|
3
|
+
export declare function joinRenewalCoupons(stripe: Stripe, subscription: Record<string, unknown>, item: Record<string, unknown>, livemode: boolean): Promise<{
|
|
4
|
+
subscriptionDiscounts: {
|
|
5
|
+
id: string;
|
|
6
|
+
object: "discount";
|
|
7
|
+
deleted?: false | undefined;
|
|
8
|
+
source: {
|
|
9
|
+
type: "coupon";
|
|
10
|
+
coupon: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
}[];
|
|
13
|
+
itemDiscounts: {
|
|
14
|
+
id: string;
|
|
15
|
+
object: "discount";
|
|
16
|
+
deleted?: false | undefined;
|
|
17
|
+
source: {
|
|
18
|
+
type: "coupon";
|
|
19
|
+
coupon: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
}[];
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=couponJoins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couponJoins.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/couponJoins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AA2BjC,mFAAmF;AACnF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,QAAQ,EAAE,OAAO;;;;;;;;;;;;;;;;;;;GA0DlB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { equal, object, unsupported } from "../renewalAggregate/shared.js";
|
|
3
|
+
import { readRenewalWireJSON } from "./wireJson.js";
|
|
4
|
+
const id = z.string().min(1).max(255).regex(/\S/);
|
|
5
|
+
const discount = z
|
|
6
|
+
.object({
|
|
7
|
+
id: z.string().regex(/^di_[A-Za-z0-9_]+$/),
|
|
8
|
+
object: z.literal("discount"),
|
|
9
|
+
deleted: z.literal(false).optional(),
|
|
10
|
+
source: z
|
|
11
|
+
.object({
|
|
12
|
+
type: z.literal("coupon"),
|
|
13
|
+
coupon: z.union([
|
|
14
|
+
id,
|
|
15
|
+
z
|
|
16
|
+
.object({
|
|
17
|
+
id,
|
|
18
|
+
object: z.literal("coupon"),
|
|
19
|
+
deleted: z.literal(false).optional(),
|
|
20
|
+
})
|
|
21
|
+
.passthrough(),
|
|
22
|
+
]),
|
|
23
|
+
})
|
|
24
|
+
.passthrough(),
|
|
25
|
+
})
|
|
26
|
+
.passthrough();
|
|
27
|
+
/** Explicit bounded joins, never a fallback for failed or over-depth expansion. */
|
|
28
|
+
export async function joinRenewalCoupons(stripe, subscription, item, livemode) {
|
|
29
|
+
const lists = [subscription.discounts, item.discounts].map((value) => {
|
|
30
|
+
const parsed = z.array(discount).max(20).safeParse(value);
|
|
31
|
+
if (!parsed.success)
|
|
32
|
+
unsupported("incomplete_or_unsupported_discount_evidence");
|
|
33
|
+
return parsed.data;
|
|
34
|
+
});
|
|
35
|
+
for (const list of lists)
|
|
36
|
+
for (const redemption of list) {
|
|
37
|
+
const ref = redemption.source.coupon;
|
|
38
|
+
if (typeof ref !== "string" &&
|
|
39
|
+
ref.livemode !== undefined &&
|
|
40
|
+
ref.livemode !== livemode)
|
|
41
|
+
unsupported("expanded_coupon_mode_mismatch");
|
|
42
|
+
}
|
|
43
|
+
const coupons = new Map();
|
|
44
|
+
for (const list of lists)
|
|
45
|
+
for (const redemption of list) {
|
|
46
|
+
const couponId = typeof redemption.source.coupon === "string"
|
|
47
|
+
? redemption.source.coupon
|
|
48
|
+
: redemption.source.coupon.id;
|
|
49
|
+
let coupon = coupons.get(couponId);
|
|
50
|
+
if (!coupon) {
|
|
51
|
+
coupon = object(await readRenewalWireJSON(stripe, "coupon", couponId));
|
|
52
|
+
if (coupon.id !== couponId ||
|
|
53
|
+
coupon.object !== "coupon" ||
|
|
54
|
+
coupon.deleted === true ||
|
|
55
|
+
(coupon.livemode !== undefined && coupon.livemode !== livemode))
|
|
56
|
+
unsupported("coupon_join_identity_mismatch");
|
|
57
|
+
coupons.set(couponId, coupon);
|
|
58
|
+
}
|
|
59
|
+
// A join may expand a string reference, but must never replace facts
|
|
60
|
+
// already present in a full read. Shape drift is conservatively rejected.
|
|
61
|
+
if (typeof redemption.source.coupon !== "string" &&
|
|
62
|
+
!equal(redemption.source.coupon, coupon))
|
|
63
|
+
unsupported("expanded_coupon_read_drift");
|
|
64
|
+
}
|
|
65
|
+
const joined = lists.map((list) => list.map((redemption) => {
|
|
66
|
+
const couponId = typeof redemption.source.coupon === "string"
|
|
67
|
+
? redemption.source.coupon
|
|
68
|
+
: redemption.source.coupon.id;
|
|
69
|
+
return {
|
|
70
|
+
...redemption,
|
|
71
|
+
source: { ...redemption.source, coupon: coupons.get(couponId) },
|
|
72
|
+
};
|
|
73
|
+
}));
|
|
74
|
+
return { subscriptionDiscounts: joined[0], itemDiscounts: joined[1] };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=couponJoins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couponJoins.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/couponJoins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,CAAC;KACf,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;IAC1C,MAAM,EA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C,CAAC,IAAI,EAAE,EAAE,CAChC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QACtB,MAAM,QAAQ,GACZ,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ;YAC1C,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM;YAC1B,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,OAAO;YACL,GAAG,UAAU;YACb,MAAM,EAAE,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAE,EAAE;SACjE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IACF,OAAO,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { readRenewalPriceReplacementContext, type ReadRenewalPriceReplacementContextOptions, } from "./reader.js";
|
|
2
|
+
export { prepareRenewalScheduleAttachment, type PrepareRenewalScheduleAttachmentOptions, type PreparedRenewalScheduleAttachment, } from "./request.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,KAAK,yCAAyC,GAC/C,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gCAAgC,EAChC,KAAK,uCAAuC,EAC5C,KAAK,iCAAiC,GACvC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,GAEnC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gCAAgC,GAGjC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type Stripe from "stripe";
|
|
3
|
+
declare const input: z.ZodObject<{
|
|
4
|
+
expected: z.ZodObject<{
|
|
5
|
+
customerAccountId: z.ZodString;
|
|
6
|
+
subscriptionId: z.ZodString;
|
|
7
|
+
itemId: z.ZodString;
|
|
8
|
+
currentPriceId: z.ZodString;
|
|
9
|
+
currentProductId: z.ZodString;
|
|
10
|
+
targetPriceId: z.ZodString;
|
|
11
|
+
targetProductId: z.ZodString;
|
|
12
|
+
periodStart: z.ZodNumber;
|
|
13
|
+
periodEnd: z.ZodNumber;
|
|
14
|
+
livemode: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export type ReadRenewalPriceReplacementContextOptions = z.infer<typeof input>;
|
|
18
|
+
/** Fixed provider read profile. Evidence acquisition is not write qualification. */
|
|
19
|
+
export declare function readRenewalPriceReplacementContext(stripe: Stripe, options: ReadRenewalPriceReplacementContextOptions, apiVersion: string): Promise<{
|
|
20
|
+
version: 1;
|
|
21
|
+
scope: "platform";
|
|
22
|
+
apiVersion: string;
|
|
23
|
+
readProfile: "renewal-context-v1";
|
|
24
|
+
providerQualification: "required";
|
|
25
|
+
observedAt: number;
|
|
26
|
+
subscription: {
|
|
27
|
+
id: string;
|
|
28
|
+
object: "subscription";
|
|
29
|
+
customer_account: string;
|
|
30
|
+
status: "active";
|
|
31
|
+
currency: string;
|
|
32
|
+
livemode: boolean;
|
|
33
|
+
cancel_at: null;
|
|
34
|
+
cancel_at_period_end: false;
|
|
35
|
+
pause_collection: null;
|
|
36
|
+
pending_update: null;
|
|
37
|
+
default_source: null;
|
|
38
|
+
application_fee_percent: null;
|
|
39
|
+
payment_settings: {
|
|
40
|
+
payment_method_options: null;
|
|
41
|
+
payment_method_types: null;
|
|
42
|
+
save_default_payment_method: "off" | null;
|
|
43
|
+
} | null;
|
|
44
|
+
billing_schedules?: unknown[] | undefined;
|
|
45
|
+
schedule: string | {
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
id: string;
|
|
48
|
+
object: "subscription_schedule";
|
|
49
|
+
deleted?: false | undefined;
|
|
50
|
+
} | null;
|
|
51
|
+
discounts: {
|
|
52
|
+
id: string;
|
|
53
|
+
object: "discount";
|
|
54
|
+
deleted?: false | undefined;
|
|
55
|
+
source: {
|
|
56
|
+
type: "coupon";
|
|
57
|
+
coupon: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
}[];
|
|
60
|
+
items: {
|
|
61
|
+
has_more: false;
|
|
62
|
+
data: {
|
|
63
|
+
id: string;
|
|
64
|
+
object: "subscription_item";
|
|
65
|
+
subscription: string;
|
|
66
|
+
current_period_start: number;
|
|
67
|
+
current_period_end: number;
|
|
68
|
+
quantity: number;
|
|
69
|
+
price: {
|
|
70
|
+
[x: string]: unknown;
|
|
71
|
+
id: string;
|
|
72
|
+
object: "price";
|
|
73
|
+
product: string | {
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
id: string;
|
|
76
|
+
object: "product";
|
|
77
|
+
deleted?: false | undefined;
|
|
78
|
+
};
|
|
79
|
+
active: boolean;
|
|
80
|
+
livemode: boolean;
|
|
81
|
+
type: "recurring";
|
|
82
|
+
currency: string;
|
|
83
|
+
billing_scheme: "per_unit";
|
|
84
|
+
recurring: {
|
|
85
|
+
[x: string]: unknown;
|
|
86
|
+
interval: "day" | "month" | "week" | "year";
|
|
87
|
+
interval_count: number;
|
|
88
|
+
usage_type: "licensed";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
discounts: {
|
|
92
|
+
id: string;
|
|
93
|
+
object: "discount";
|
|
94
|
+
deleted?: false | undefined;
|
|
95
|
+
source: {
|
|
96
|
+
type: "coupon";
|
|
97
|
+
coupon: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
}[];
|
|
100
|
+
}[];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
targetPrice: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
id: string;
|
|
106
|
+
object: "price";
|
|
107
|
+
product: string | {
|
|
108
|
+
[x: string]: unknown;
|
|
109
|
+
id: string;
|
|
110
|
+
object: "product";
|
|
111
|
+
deleted?: false | undefined;
|
|
112
|
+
};
|
|
113
|
+
active: boolean;
|
|
114
|
+
livemode: boolean;
|
|
115
|
+
type: "recurring";
|
|
116
|
+
currency: string;
|
|
117
|
+
billing_scheme: "per_unit";
|
|
118
|
+
recurring: {
|
|
119
|
+
[x: string]: unknown;
|
|
120
|
+
interval: "day" | "month" | "week" | "year";
|
|
121
|
+
interval_count: number;
|
|
122
|
+
usage_type: "licensed";
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
billingCustomer: {
|
|
126
|
+
[x: string]: unknown;
|
|
127
|
+
id: string;
|
|
128
|
+
object: "customer";
|
|
129
|
+
customer_account: string;
|
|
130
|
+
livemode: boolean;
|
|
131
|
+
deleted?: false | undefined;
|
|
132
|
+
discount: {
|
|
133
|
+
[x: string]: unknown;
|
|
134
|
+
id: string;
|
|
135
|
+
object: "discount";
|
|
136
|
+
deleted?: false | undefined;
|
|
137
|
+
} | null;
|
|
138
|
+
};
|
|
139
|
+
}>;
|
|
140
|
+
export {};
|
|
141
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAmBjC,QAAA,MAAM,KAAK;;;;;;;;;;;;;kBAAmD,CAAC;AAC/D,MAAM,MAAM,yCAAyC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAe9E,oFAAoF;AACpF,wBAAsB,kCAAkC,CACtD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yCAAyC,EAClD,UAAU,EAAE,MAAM;aA0EP,CAAC;WACH,UAAU;;iBAEJ,oBAAoB;2BACV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAMpC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalExpected, renewalSubscription, renewalPrice, renewalBillingCustomer, } from "../renewalReplacementSchema.js";
|
|
3
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
4
|
+
import { productId, referenceId, resourceId, supportedVersion, unsupported, timestamp, } from "../renewalAggregate/shared.js";
|
|
5
|
+
import { joinRenewalCoupons } from "./couponJoins.js";
|
|
6
|
+
import { readRenewalWireJSON } from "./wireJson.js";
|
|
7
|
+
const input = z.object({ expected: renewalExpected }).strict();
|
|
8
|
+
const observedSchedule = z.union([
|
|
9
|
+
z.null(),
|
|
10
|
+
resourceId("sub_sched"),
|
|
11
|
+
z
|
|
12
|
+
.object({
|
|
13
|
+
id: resourceId("sub_sched"),
|
|
14
|
+
object: z.literal("subscription_schedule"),
|
|
15
|
+
deleted: z.literal(false).optional(),
|
|
16
|
+
})
|
|
17
|
+
.passthrough(),
|
|
18
|
+
]);
|
|
19
|
+
const readSubscription = renewalSubscription.extend({
|
|
20
|
+
schedule: observedSchedule,
|
|
21
|
+
});
|
|
22
|
+
/** Fixed provider read profile. Evidence acquisition is not write qualification. */
|
|
23
|
+
export async function readRenewalPriceReplacementContext(stripe, options, apiVersion) {
|
|
24
|
+
const args = input.parse(renewalSnapshot(options));
|
|
25
|
+
supportedVersion(apiVersion);
|
|
26
|
+
const expected = args.expected;
|
|
27
|
+
const subscription = readSubscription.parse(renewalSnapshot(await readRenewalWireJSON(stripe, "subscription", expected.subscriptionId)));
|
|
28
|
+
const item = subscription.items.data[0];
|
|
29
|
+
const context = {
|
|
30
|
+
customerAccountId: expected.customerAccountId,
|
|
31
|
+
livemode: expected.livemode,
|
|
32
|
+
};
|
|
33
|
+
if (subscription.id !== expected.subscriptionId ||
|
|
34
|
+
subscription.customer_account !== expected.customerAccountId ||
|
|
35
|
+
subscription.livemode !== expected.livemode ||
|
|
36
|
+
item.id !== expected.itemId ||
|
|
37
|
+
item.subscription !== expected.subscriptionId ||
|
|
38
|
+
item.price.id !== expected.currentPriceId ||
|
|
39
|
+
item.price.livemode !== expected.livemode ||
|
|
40
|
+
productId(item.price.product, context) !== expected.currentProductId ||
|
|
41
|
+
item.current_period_start !== expected.periodStart ||
|
|
42
|
+
item.current_period_end !== expected.periodEnd)
|
|
43
|
+
unsupported("original_read_identity_mismatch");
|
|
44
|
+
const targetPrice = renewalPrice.parse(renewalSnapshot(await readRenewalWireJSON(stripe, "price", expected.targetPriceId)));
|
|
45
|
+
if (targetPrice.id !== expected.targetPriceId ||
|
|
46
|
+
targetPrice.livemode !== expected.livemode ||
|
|
47
|
+
productId(targetPrice.product, context) !== expected.targetProductId)
|
|
48
|
+
unsupported("target_read_identity_mismatch");
|
|
49
|
+
const customerId = referenceId(subscription.customer, "cus", "customer", context);
|
|
50
|
+
const billingCustomer = renewalBillingCustomer.parse(renewalSnapshot(await readRenewalWireJSON(stripe, "customer", customerId)));
|
|
51
|
+
if (billingCustomer.id !== customerId ||
|
|
52
|
+
billingCustomer.customer_account !== expected.customerAccountId ||
|
|
53
|
+
billingCustomer.livemode !== expected.livemode)
|
|
54
|
+
unsupported("billing_customer_identity_mismatch");
|
|
55
|
+
const joined = await joinRenewalCoupons(stripe, subscription, item, expected.livemode);
|
|
56
|
+
const normalizedSubscription = {
|
|
57
|
+
...subscription,
|
|
58
|
+
discounts: joined.subscriptionDiscounts,
|
|
59
|
+
items: {
|
|
60
|
+
...subscription.items,
|
|
61
|
+
data: [{ ...item, discounts: joined.itemDiscounts }],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const observedAt = timestamp.parse(Math.floor(Date.now() / 1000));
|
|
65
|
+
return renewalSnapshot({
|
|
66
|
+
version: 1,
|
|
67
|
+
scope: "platform",
|
|
68
|
+
apiVersion,
|
|
69
|
+
readProfile: "renewal-context-v1",
|
|
70
|
+
providerQualification: "required",
|
|
71
|
+
observedAt,
|
|
72
|
+
subscription: normalizedSubscription,
|
|
73
|
+
targetPrice,
|
|
74
|
+
billingCustomer,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,SAAS,GACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAE/D,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC/B,CAAC,CAAC,IAAI,EAAE;IACR,UAAU,CAAC,WAAW,CAAC;IACvB,CAAC;SACE,MAAM,CAAC;QACN,EAAE,EAAE,UAAU,CAAC,WAAW,CAAC;QAC3B,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,EAAE,MAAM,CAAC,qBAAqB;QACvC,KAAK,EAAE;YACL,GAAG,YAAY,CAAC,KAAK;YACrB,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;SACrD;KACF,CAAC;IACF,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IAClE,OAAO,eAAe,CAAC;QACrB,OAAO,EAAE,CAAU;QACnB,KAAK,EAAE,UAAmB;QAC1B,UAAU;QACV,WAAW,EAAE,oBAA6B;QAC1C,qBAAqB,EAAE,UAAmB;QAC1C,UAAU;QACV,YAAY,EAAE,sBAAsB;QACpC,WAAW;QACX,eAAe;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const input: z.ZodObject<{
|
|
3
|
+
prepared: z.ZodUnknown;
|
|
4
|
+
apiVersion: z.ZodString;
|
|
5
|
+
attachKey: z.ZodString;
|
|
6
|
+
firstDispatchedAt: z.ZodNumber;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type PrepareRenewalScheduleAttachmentOptions = z.infer<typeof input>;
|
|
9
|
+
/** Pure retained request only. It neither authorizes nor dispatches attachment. */
|
|
10
|
+
export declare function prepareRenewalScheduleAttachment(options: PrepareRenewalScheduleAttachmentOptions): {
|
|
11
|
+
version: 1;
|
|
12
|
+
stage: "attach";
|
|
13
|
+
scope: "platform";
|
|
14
|
+
apiVersion: string;
|
|
15
|
+
logicalBinding: string;
|
|
16
|
+
method: "POST";
|
|
17
|
+
path: "/v1/subscription_schedules";
|
|
18
|
+
payload: {
|
|
19
|
+
from_subscription: string;
|
|
20
|
+
};
|
|
21
|
+
key: string;
|
|
22
|
+
firstDispatchedAt: number;
|
|
23
|
+
requestIdentity: {
|
|
24
|
+
key: string;
|
|
25
|
+
binding: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type PreparedRenewalScheduleAttachment = ReturnType<typeof prepareRenewalScheduleAttachment>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,QAAA,MAAM,KAAK;;;;;kBAOA,CAAC;AACZ,MAAM,MAAM,uCAAuC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAC5E,mFAAmF;AACnF,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,uCAAuC;aAQrC,CAAC;WACH,QAAQ;WACR,UAAU;;;YAGT,MAAM;UACR,4BAA4B;;QACvB,iBAAiB;;;;;;;;EAQ/B;AACD,MAAM,MAAM,iCAAiC,GAAG,UAAU,CACxD,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { retainedPreparation } from "../renewalAggregate/preflight.js";
|
|
3
|
+
import { binding, supportedVersion, timestamp, unsupported, } from "../renewalAggregate/shared.js";
|
|
4
|
+
import { idempotencyOptions } from "../../core/idempotency.js";
|
|
5
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
6
|
+
const input = z
|
|
7
|
+
.object({
|
|
8
|
+
prepared: z.unknown(),
|
|
9
|
+
apiVersion: z.string(),
|
|
10
|
+
attachKey: z.string(),
|
|
11
|
+
firstDispatchedAt: timestamp,
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
/** Pure retained request only. It neither authorizes nor dispatches attachment. */
|
|
15
|
+
export function prepareRenewalScheduleAttachment(options) {
|
|
16
|
+
const args = input.parse(renewalSnapshot(options));
|
|
17
|
+
supportedVersion(args.apiVersion);
|
|
18
|
+
const prepared = retainedPreparation(args.prepared);
|
|
19
|
+
const key = idempotencyOptions(args.attachKey)?.idempotencyKey;
|
|
20
|
+
if (!key)
|
|
21
|
+
unsupported("missing_explicit_attach_key");
|
|
22
|
+
const request = {
|
|
23
|
+
version: 1,
|
|
24
|
+
stage: "attach",
|
|
25
|
+
scope: "platform",
|
|
26
|
+
apiVersion: args.apiVersion,
|
|
27
|
+
logicalBinding: prepared.requestIdentity.binding,
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/v1/subscription_schedules",
|
|
30
|
+
payload: { from_subscription: prepared.expected.subscriptionId },
|
|
31
|
+
key,
|
|
32
|
+
firstDispatchedAt: args.firstDispatchedAt,
|
|
33
|
+
};
|
|
34
|
+
return renewalSnapshot({
|
|
35
|
+
...request,
|
|
36
|
+
requestIdentity: { key, binding: binding("renewal-attach", request) },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,WAAW,GACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,iBAAiB,EAAE,SAAS;CAC7B,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,mFAAmF;AACnF,MAAM,UAAU,gCAAgC,CAC9C,OAAgD;IAEhD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IAC/D,IAAI,CAAC,GAAG;QAAE,WAAW,CAAC,6BAA6B,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,CAAU;QACnB,KAAK,EAAE,QAAiB;QACxB,KAAK,EAAE,UAAmB;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,cAAc,EAAE,QAAQ,CAAC,eAAe,CAAC,OAAO;QAChD,MAAM,EAAE,MAAe;QACvB,IAAI,EAAE,4BAAqC;QAC3C,OAAO,EAAE,EAAE,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE;QAChE,GAAG;QACH,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;KAC1C,CAAC;IACF,OAAO,eAAe,CAAC;QACrB,GAAG,OAAO;QACV,eAAe,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,EAAE;KACtE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type Stripe from "stripe";
|
|
3
|
+
declare const resources: {
|
|
4
|
+
readonly subscription: {
|
|
5
|
+
readonly path: "subscriptions";
|
|
6
|
+
readonly id: z.ZodString;
|
|
7
|
+
};
|
|
8
|
+
readonly price: {
|
|
9
|
+
readonly path: "prices";
|
|
10
|
+
readonly id: z.ZodString;
|
|
11
|
+
};
|
|
12
|
+
readonly customer: {
|
|
13
|
+
readonly path: "customers";
|
|
14
|
+
readonly id: z.ZodString;
|
|
15
|
+
};
|
|
16
|
+
readonly coupon: {
|
|
17
|
+
readonly path: "coupons";
|
|
18
|
+
readonly id: z.ZodString;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** Fixed renewal GETs only. rawRequest bypasses typed resource Decimal coercion. */
|
|
22
|
+
export declare function readRenewalWireJSON(stripe: Stripe, resource: keyof typeof resources, id: string): Promise<object>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=wireJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wireJson.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/wireJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAIjC,QAAA,MAAM,SAAS;aACb,YAAY;iBAAI,IAAI,EAAE,eAAe;iBAAE,EAAE;;aACzC,KAAK;iBAAI,IAAI,EAAE,QAAQ;iBAAE,EAAE;;aAC3B,QAAQ;iBAAI,IAAI,EAAE,WAAW;iBAAE,EAAE;;aACjC,MAAM;iBACJ,IAAI,EAAE,SAAS;iBACf,EAAE;;CAUI,CAAC;AAGX,oFAAoF;AACpF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,OAAO,SAAS,EAChC,EAAE,EAAE,MAAM,mBA8CX"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
|
|
3
|
+
import { resourceId, unsupported } from "../renewalAggregate/shared.js";
|
|
4
|
+
const resources = {
|
|
5
|
+
subscription: { path: "subscriptions", id: resourceId("sub") },
|
|
6
|
+
price: { path: "prices", id: resourceId("price") },
|
|
7
|
+
customer: { path: "customers", id: resourceId("cus") },
|
|
8
|
+
coupon: {
|
|
9
|
+
path: "coupons",
|
|
10
|
+
id: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.max(255)
|
|
14
|
+
.regex(/\S/)
|
|
15
|
+
.refine((value) => value !== "." && value !== "..", "Coupon ID must not be a URL dot segment."),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const expansions = ["discounts", "items.data.discounts", "items.data.price"];
|
|
19
|
+
/** Fixed renewal GETs only. rawRequest bypasses typed resource Decimal coercion. */
|
|
20
|
+
export async function readRenewalWireJSON(stripe, resource, id) {
|
|
21
|
+
const spec = resources[resource];
|
|
22
|
+
const selectedId = spec.id.parse(id);
|
|
23
|
+
const query = resource === "subscription"
|
|
24
|
+
? `?${new URLSearchParams(expansions.map((value, i) => [`expand[${i}]`, value]))}`
|
|
25
|
+
: "";
|
|
26
|
+
const reply = await stripe.rawRequest("GET", `/v1/${spec.path}/${encodeURIComponent(selectedId)}${query}`, undefined, { apiVersion: "2026-09-30.endive", maxNetworkRetries: 0 });
|
|
27
|
+
if (!reply || typeof reply !== "object")
|
|
28
|
+
unsupported("missing_provider_http_status");
|
|
29
|
+
const descriptor = Object.getOwnPropertyDescriptor(reply, "lastResponse");
|
|
30
|
+
if (!descriptor ||
|
|
31
|
+
descriptor.enumerable ||
|
|
32
|
+
!("value" in descriptor) ||
|
|
33
|
+
!descriptor.value ||
|
|
34
|
+
typeof descriptor.value !== "object")
|
|
35
|
+
unsupported("missing_provider_http_status");
|
|
36
|
+
// Fetch's public Response uses status; Node IncomingMessage uses statusCode.
|
|
37
|
+
// Neither is provider JSON. If both are present they must agree.
|
|
38
|
+
const meta = descriptor.value;
|
|
39
|
+
const codes = [meta.status, meta.statusCode].filter((code) => code !== undefined);
|
|
40
|
+
if (!codes.length ||
|
|
41
|
+
codes.some((code) => typeof code !== "number" ||
|
|
42
|
+
!Number.isInteger(code) ||
|
|
43
|
+
code < 200 ||
|
|
44
|
+
code >= 300) ||
|
|
45
|
+
codes.some((code) => code !== codes[0]))
|
|
46
|
+
unsupported("unverified_provider_http_status");
|
|
47
|
+
// Strict JSON copy remains unchanged. Nonenumerable transport metadata is
|
|
48
|
+
// excluded; every enumerable wire-body fact, including unknown fields, remains.
|
|
49
|
+
return renewalSnapshot(reply);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=wireJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wireJson.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalAttach/wireJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAExE,MAAM,SAAS,GAAG;IAChB,YAAY,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE;IAC9D,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;IAClD,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE;IACtD,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,CAAC;aACF,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,IAAI,EAC1C,0CAA0C,CAC3C;KACJ;CACO,CAAC;AACX,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,sBAAsB,EAAE,kBAAkB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UAAU,CAAC,CAAC,MAAM,CACjD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAC7B,CAAC;IACF,IACE,CAAC,KAAK,CAAC,MAAM;QACb,KAAK,CAAC,IAAI,CACR,CAAC,IAAI,EAAE,EAAE,CACP,OAAO,IAAI,KAAK,QAAQ;YACxB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YACvB,IAAI,GAAG,GAAG;YACV,IAAI,IAAI,GAAG,CACd;QACD,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;QAEvC,WAAW,CAAC,iCAAiC,CAAC,CAAC;IACjD,0EAA0E;IAC1E,gFAAgF;IAChF,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -2361,14 +2361,6 @@ export declare function setup(amounts?: number[]): Promise<{
|
|
|
2361
2361
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
2362
2362
|
requestKey: string;
|
|
2363
2363
|
result?: {
|
|
2364
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2365
|
-
retryable: false;
|
|
2366
|
-
status: "conflict";
|
|
2367
|
-
} | {
|
|
2368
|
-
reason: "policy_invalid";
|
|
2369
|
-
retryable: false;
|
|
2370
|
-
status: "rejected";
|
|
2371
|
-
} | {
|
|
2372
2364
|
operation: {
|
|
2373
2365
|
accountId: string;
|
|
2374
2366
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2379,6 +2371,14 @@ export declare function setup(amounts?: number[]): Promise<{
|
|
|
2379
2371
|
} | {
|
|
2380
2372
|
enabled: boolean;
|
|
2381
2373
|
status: "unchanged";
|
|
2374
|
+
} | {
|
|
2375
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2376
|
+
retryable: false;
|
|
2377
|
+
status: "conflict";
|
|
2378
|
+
} | {
|
|
2379
|
+
reason: "policy_invalid";
|
|
2380
|
+
retryable: false;
|
|
2381
|
+
status: "rejected";
|
|
2382
2382
|
} | {
|
|
2383
2383
|
reason: "provider_pending";
|
|
2384
2384
|
retryable: true;
|
|
@@ -2389,14 +2389,6 @@ export declare function setup(amounts?: number[]): Promise<{
|
|
|
2389
2389
|
payload: import("convex/values").VString<string, "required">;
|
|
2390
2390
|
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
2391
2391
|
result: import("convex/values").VUnion<{
|
|
2392
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2393
|
-
retryable: false;
|
|
2394
|
-
status: "conflict";
|
|
2395
|
-
} | {
|
|
2396
|
-
reason: "policy_invalid";
|
|
2397
|
-
retryable: false;
|
|
2398
|
-
status: "rejected";
|
|
2399
|
-
} | {
|
|
2400
2392
|
operation: {
|
|
2401
2393
|
accountId: string;
|
|
2402
2394
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2407,6 +2399,14 @@ export declare function setup(amounts?: number[]): Promise<{
|
|
|
2407
2399
|
} | {
|
|
2408
2400
|
enabled: boolean;
|
|
2409
2401
|
status: "unchanged";
|
|
2402
|
+
} | {
|
|
2403
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2404
|
+
retryable: false;
|
|
2405
|
+
status: "conflict";
|
|
2406
|
+
} | {
|
|
2407
|
+
reason: "policy_invalid";
|
|
2408
|
+
retryable: false;
|
|
2409
|
+
status: "rejected";
|
|
2410
2410
|
} | {
|
|
2411
2411
|
reason: "provider_pending";
|
|
2412
2412
|
retryable: true;
|