@fantastic.dev/better-stripe 0.67.1 → 0.68.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.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/products/catalogClient.d.ts +7 -0
- package/dist/client/products/catalogClient.d.ts.map +1 -1
- package/dist/client/products/catalogClient.js +7 -0
- package/dist/client/products/catalogClient.js.map +1 -1
- package/dist/client/products/identity.d.ts +26 -0
- package/dist/client/products/identity.d.ts.map +1 -0
- package/dist/client/products/identity.js +8 -0
- package/dist/client/products/identity.js.map +1 -0
- package/dist/client/usage/observationClient.d.ts +2 -2
- package/dist/client/usage/observationClient.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +43 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/products/queries.d.ts +49 -0
- package/dist/component/products/queries.d.ts.map +1 -1
- package/dist/component/products/queries.js +32 -0
- package/dist/component/products/queries.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/client-api.md +10 -0
- package/docs/read-contracts.md +34 -0
- package/package.json +1 -1
- package/src/client/index.ts +4 -0
- package/src/client/products/catalogClient.ts +15 -0
- package/src/client/products/identity.test.ts +91 -0
- package/src/client/products/identity.ts +36 -0
- package/src/component/_generated/component.ts +47 -0
- package/src/component/products/identity.test.ts +217 -0
- package/src/component/products/queries.ts +42 -0
|
@@ -9,6 +9,17 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
|
|
|
9
9
|
stripeSubscriptionId: string;
|
|
10
10
|
version: number;
|
|
11
11
|
}, Promise<{
|
|
12
|
+
status: "ready";
|
|
13
|
+
value: {
|
|
14
|
+
customerAccount: string;
|
|
15
|
+
enabled?: boolean | undefined;
|
|
16
|
+
paymentMethodId: string | null;
|
|
17
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
18
|
+
phase: "apply" | "attach" | "create";
|
|
19
|
+
providerApiVersion: string;
|
|
20
|
+
stripeSubscriptionId: string;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
12
23
|
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
13
24
|
retryable: false;
|
|
14
25
|
status: "unknown";
|
|
@@ -24,16 +35,5 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
|
|
|
24
35
|
reason: "provider_pending";
|
|
25
36
|
retryable: true;
|
|
26
37
|
status: "not_ready";
|
|
27
|
-
} | {
|
|
28
|
-
status: "ready";
|
|
29
|
-
value: {
|
|
30
|
-
customerAccount: string;
|
|
31
|
-
enabled?: boolean | undefined;
|
|
32
|
-
paymentMethodId: string | null;
|
|
33
|
-
paymentMethodTypes?: string[] | null | undefined;
|
|
34
|
-
phase: "apply" | "attach" | "create";
|
|
35
|
-
providerApiVersion: string;
|
|
36
|
-
stripeSubscriptionId: string;
|
|
37
|
-
};
|
|
38
38
|
}>>;
|
|
39
39
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -22,6 +22,14 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
22
22
|
requestKey: string;
|
|
23
23
|
scopeKey: string;
|
|
24
24
|
}, Promise<{
|
|
25
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
26
|
+
retryable: false;
|
|
27
|
+
status: "conflict";
|
|
28
|
+
} | {
|
|
29
|
+
reason: "policy_invalid";
|
|
30
|
+
retryable: false;
|
|
31
|
+
status: "rejected";
|
|
32
|
+
} | {
|
|
25
33
|
operation: {
|
|
26
34
|
accountId: string;
|
|
27
35
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -32,14 +40,6 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
32
40
|
} | {
|
|
33
41
|
enabled: boolean;
|
|
34
42
|
status: "unchanged";
|
|
35
|
-
} | {
|
|
36
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
37
|
-
retryable: false;
|
|
38
|
-
status: "conflict";
|
|
39
|
-
} | {
|
|
40
|
-
reason: "policy_invalid";
|
|
41
|
-
retryable: false;
|
|
42
|
-
status: "rejected";
|
|
43
43
|
} | {
|
|
44
44
|
reason: "provider_pending";
|
|
45
45
|
retryable: true;
|
|
@@ -395,6 +395,14 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
395
395
|
requestKey: string;
|
|
396
396
|
scopeKey: string;
|
|
397
397
|
}, Promise<{
|
|
398
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
399
|
+
retryable: false;
|
|
400
|
+
status: "conflict";
|
|
401
|
+
} | {
|
|
402
|
+
reason: "policy_invalid";
|
|
403
|
+
retryable: false;
|
|
404
|
+
status: "rejected";
|
|
405
|
+
} | {
|
|
398
406
|
operation: {
|
|
399
407
|
accountId: string;
|
|
400
408
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -405,14 +413,6 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
405
413
|
} | {
|
|
406
414
|
enabled: boolean;
|
|
407
415
|
status: "unchanged";
|
|
408
|
-
} | {
|
|
409
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
410
|
-
retryable: false;
|
|
411
|
-
status: "conflict";
|
|
412
|
-
} | {
|
|
413
|
-
reason: "policy_invalid";
|
|
414
|
-
retryable: false;
|
|
415
|
-
status: "rejected";
|
|
416
416
|
} | {
|
|
417
417
|
reason: "provider_pending";
|
|
418
418
|
retryable: true;
|
|
@@ -2,6 +2,14 @@ import type { Infer } from "convex/values";
|
|
|
2
2
|
import type { MutationCtx } from "../_generated/server.js";
|
|
3
3
|
import { prepareArgs, finishPreparationArgs } from "./mutationValidators.js";
|
|
4
4
|
export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prepareArgs>): Promise<{
|
|
5
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
6
|
+
retryable: false;
|
|
7
|
+
status: "conflict";
|
|
8
|
+
} | {
|
|
9
|
+
reason: "policy_invalid";
|
|
10
|
+
retryable: false;
|
|
11
|
+
status: "rejected";
|
|
12
|
+
} | {
|
|
5
13
|
operation: {
|
|
6
14
|
accountId: string;
|
|
7
15
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -12,14 +20,6 @@ export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prep
|
|
|
12
20
|
} | {
|
|
13
21
|
enabled: boolean;
|
|
14
22
|
status: "unchanged";
|
|
15
|
-
} | {
|
|
16
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
17
|
-
retryable: false;
|
|
18
|
-
status: "conflict";
|
|
19
|
-
} | {
|
|
20
|
-
reason: "policy_invalid";
|
|
21
|
-
retryable: false;
|
|
22
|
-
status: "rejected";
|
|
23
23
|
} | {
|
|
24
24
|
reason: "provider_pending";
|
|
25
25
|
retryable: true;
|
|
@@ -60,6 +60,22 @@ export declare const phaseRef: import("convex/values").VObject<{
|
|
|
60
60
|
}, "required", "accountId" | "definitionVersion" | "operationId" | "phase" | "providerApiVersion" | "providerKey" | "scopeKey" | "stripeSubscriptionId" | "version">;
|
|
61
61
|
export type FundingPhaseRef = Infer<typeof phaseRef>;
|
|
62
62
|
export declare const workflowStartResult: import("convex/values").VUnion<{
|
|
63
|
+
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
64
|
+
retryable: false;
|
|
65
|
+
status: "unknown";
|
|
66
|
+
} | {
|
|
67
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
68
|
+
retryable: false;
|
|
69
|
+
status: "conflict";
|
|
70
|
+
} | {
|
|
71
|
+
reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
|
|
72
|
+
retryable: false;
|
|
73
|
+
status: "rejected";
|
|
74
|
+
} | {
|
|
75
|
+
reason: "provider_pending";
|
|
76
|
+
retryable: true;
|
|
77
|
+
status: "not_ready";
|
|
78
|
+
} | {
|
|
63
79
|
operation: {
|
|
64
80
|
accountId: string;
|
|
65
81
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -76,22 +92,6 @@ export declare const workflowStartResult: import("convex/values").VUnion<{
|
|
|
76
92
|
version: number;
|
|
77
93
|
};
|
|
78
94
|
status: "canceled";
|
|
79
|
-
} | {
|
|
80
|
-
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
81
|
-
retryable: false;
|
|
82
|
-
status: "unknown";
|
|
83
|
-
} | {
|
|
84
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
85
|
-
retryable: false;
|
|
86
|
-
status: "conflict";
|
|
87
|
-
} | {
|
|
88
|
-
reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
|
|
89
|
-
retryable: false;
|
|
90
|
-
status: "rejected";
|
|
91
|
-
} | {
|
|
92
|
-
reason: "provider_pending";
|
|
93
|
-
retryable: true;
|
|
94
|
-
status: "not_ready";
|
|
95
95
|
}, [import("convex/values").VObject<{
|
|
96
96
|
operation: {
|
|
97
97
|
accountId: string;
|
|
@@ -153,4 +153,53 @@ export declare const paginatePrices: import("convex/server").RegisteredQuery<"pu
|
|
|
153
153
|
type: "one_time" | "recurring";
|
|
154
154
|
unitAmount: number;
|
|
155
155
|
}>>>;
|
|
156
|
+
/** Resolve a provider ID without selecting an arbitrary duplicate. */
|
|
157
|
+
export declare const getProductIdentity: import("convex/server").RegisteredQuery<"public", {
|
|
158
|
+
stripeProductId: string;
|
|
159
|
+
}, Promise<{
|
|
160
|
+
status: "missing";
|
|
161
|
+
product?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
status: "ambiguous";
|
|
164
|
+
product?: undefined;
|
|
165
|
+
} | {
|
|
166
|
+
status: "unique";
|
|
167
|
+
product: {
|
|
168
|
+
_creationTime: number;
|
|
169
|
+
_id: import("convex/values").GenericId<"products">;
|
|
170
|
+
accountId?: string | undefined;
|
|
171
|
+
active: boolean;
|
|
172
|
+
description?: string | undefined;
|
|
173
|
+
metadata?: any;
|
|
174
|
+
name: string;
|
|
175
|
+
stripeProductId: string;
|
|
176
|
+
};
|
|
177
|
+
}>>;
|
|
178
|
+
/** Resolve a provider ID without selecting an arbitrary duplicate. */
|
|
179
|
+
export declare const getPriceIdentity: import("convex/server").RegisteredQuery<"public", {
|
|
180
|
+
stripePriceId: string;
|
|
181
|
+
}, Promise<{
|
|
182
|
+
status: "missing";
|
|
183
|
+
price?: undefined;
|
|
184
|
+
} | {
|
|
185
|
+
status: "ambiguous";
|
|
186
|
+
price?: undefined;
|
|
187
|
+
} | {
|
|
188
|
+
status: "unique";
|
|
189
|
+
price: {
|
|
190
|
+
_creationTime: number;
|
|
191
|
+
_id: import("convex/values").GenericId<"prices">;
|
|
192
|
+
active: boolean;
|
|
193
|
+
currency: string;
|
|
194
|
+
interval?: "day" | "month" | "week" | "year" | undefined;
|
|
195
|
+
intervalCount?: number | undefined;
|
|
196
|
+
metadata?: any;
|
|
197
|
+
nickname?: string | undefined;
|
|
198
|
+
productId: string;
|
|
199
|
+
stripePriceId: string;
|
|
200
|
+
stripeProductId: string;
|
|
201
|
+
type: "one_time" | "recurring";
|
|
202
|
+
unitAmount: number;
|
|
203
|
+
};
|
|
204
|
+
}>>;
|
|
156
205
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/products/queries.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,UAAU;;;;;;;;;;;UAMrB,CAAC;AAEH,eAAO,MAAM,oBAAo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;;;;;;;;;;;;;;;;GAE3B,CAAC"}
|
|
@@ -178,4 +178,36 @@ export const paginatePrices = query({
|
|
|
178
178
|
});
|
|
179
179
|
},
|
|
180
180
|
});
|
|
181
|
+
/** Resolve a provider ID without selecting an arbitrary duplicate. */
|
|
182
|
+
export const getProductIdentity = query({
|
|
183
|
+
args: { stripeProductId: v.string() },
|
|
184
|
+
returns: v.union(v.object({ status: v.literal("missing") }), v.object({ status: v.literal("unique"), product: productDocValidator }), v.object({ status: v.literal("ambiguous") })),
|
|
185
|
+
handler: async (ctx, args) => {
|
|
186
|
+
const rows = await ctx.db
|
|
187
|
+
.query("products")
|
|
188
|
+
.withIndex("by_stripe_product_id", (q) => q.eq("stripeProductId", args.stripeProductId))
|
|
189
|
+
.take(2);
|
|
190
|
+
if (rows.length === 0)
|
|
191
|
+
return { status: "missing" };
|
|
192
|
+
if (rows.length > 1)
|
|
193
|
+
return { status: "ambiguous" };
|
|
194
|
+
return { status: "unique", product: rows[0] };
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
/** Resolve a provider ID without selecting an arbitrary duplicate. */
|
|
198
|
+
export const getPriceIdentity = query({
|
|
199
|
+
args: { stripePriceId: v.string() },
|
|
200
|
+
returns: v.union(v.object({ status: v.literal("missing") }), v.object({ status: v.literal("unique"), price: priceDocValidator }), v.object({ status: v.literal("ambiguous") })),
|
|
201
|
+
handler: async (ctx, args) => {
|
|
202
|
+
const rows = await ctx.db
|
|
203
|
+
.query("prices")
|
|
204
|
+
.withIndex("by_stripe_price_id", (q) => q.eq("stripePriceId", args.stripePriceId))
|
|
205
|
+
.take(2);
|
|
206
|
+
if (rows.length === 0)
|
|
207
|
+
return { status: "missing" };
|
|
208
|
+
if (rows.length > 1)
|
|
209
|
+
return { status: "ambiguous" };
|
|
210
|
+
return { status: "unique", price: rows[0] };
|
|
211
|
+
},
|
|
212
|
+
});
|
|
181
213
|
//# sourceMappingURL=queries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-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ationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
2181
2181
|
requestKey: string;
|
|
2182
2182
|
result?: {
|
|
2183
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2184
|
-
retryable: false;
|
|
2185
|
-
status: "conflict";
|
|
2186
|
-
} | {
|
|
2187
|
-
reason: "policy_invalid";
|
|
2188
|
-
retryable: false;
|
|
2189
|
-
status: "rejected";
|
|
2190
|
-
} | {
|
|
2191
2183
|
operation: {
|
|
2192
2184
|
accountId: string;
|
|
2193
2185
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2198,6 +2190,14 @@ export declare function setupAllowance(): Promise<{
|
|
|
2198
2190
|
} | {
|
|
2199
2191
|
enabled: boolean;
|
|
2200
2192
|
status: "unchanged";
|
|
2193
|
+
} | {
|
|
2194
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2195
|
+
retryable: false;
|
|
2196
|
+
status: "conflict";
|
|
2197
|
+
} | {
|
|
2198
|
+
reason: "policy_invalid";
|
|
2199
|
+
retryable: false;
|
|
2200
|
+
status: "rejected";
|
|
2201
2201
|
} | {
|
|
2202
2202
|
reason: "provider_pending";
|
|
2203
2203
|
retryable: true;
|
|
@@ -2208,14 +2208,6 @@ export declare function setupAllowance(): Promise<{
|
|
|
2208
2208
|
payload: import("convex/values").VString<string, "required">;
|
|
2209
2209
|
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
2210
2210
|
result: import("convex/values").VUnion<{
|
|
2211
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2212
|
-
retryable: false;
|
|
2213
|
-
status: "conflict";
|
|
2214
|
-
} | {
|
|
2215
|
-
reason: "policy_invalid";
|
|
2216
|
-
retryable: false;
|
|
2217
|
-
status: "rejected";
|
|
2218
|
-
} | {
|
|
2219
2211
|
operation: {
|
|
2220
2212
|
accountId: string;
|
|
2221
2213
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2226,6 +2218,14 @@ export declare function setupAllowance(): Promise<{
|
|
|
2226
2218
|
} | {
|
|
2227
2219
|
enabled: boolean;
|
|
2228
2220
|
status: "unchanged";
|
|
2221
|
+
} | {
|
|
2222
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2223
|
+
retryable: false;
|
|
2224
|
+
status: "conflict";
|
|
2225
|
+
} | {
|
|
2226
|
+
reason: "policy_invalid";
|
|
2227
|
+
retryable: false;
|
|
2228
|
+
status: "rejected";
|
|
2229
2229
|
} | {
|
|
2230
2230
|
reason: "provider_pending";
|
|
2231
2231
|
retryable: true;
|
package/docs/client-api.md
CHANGED
|
@@ -590,3 +590,13 @@ and [uploaded screenshots and provider records](https://github.com/FantasticDevH
|
|
|
590
590
|
`stripe.reversalObservations` reads original claimed-slice history and maintains a bounded diagnostic index. Its physical operation references survive release/deletion and distinguish reuse of a business operation ID. Exact bucket/owner pages, original/latest payloads and generation-aware continuation remain unknown coverage. These methods do not execute reversals, certify current ownership or authorize closure. See [financial observations](financial-observations.md#claimed-reversal-history).
|
|
591
591
|
|
|
592
592
|
`stripe.payoutRevisionMigration` exposes trusted-host `activateAccount`, `begin`, `resume`, `get` and `results`. Existing destinations keep legacy revision authority until explicitly activated. Activation and inventory are bounded storage maintenance, with held outcomes for ambiguous or unrepresentable legacy authority. Installing the package does not run a migration. See the [migration guide](payout-revision-migration.md) before relying on the tested large-operation path or changing component versions.
|
|
593
|
+
|
|
594
|
+
### Strict catalog identity
|
|
595
|
+
|
|
596
|
+
`getProductIdentity(ctx, { stripeProductId })` and
|
|
597
|
+
`getPriceIdentity(ctx, { stripePriceId })` return the public discriminated types
|
|
598
|
+
`ProductIdentityResult` and `PriceIdentityResult`. They distinguish `missing`,
|
|
599
|
+
`unique` with the actual cached row, and `ambiguous`, using at most two indexed
|
|
600
|
+
row reads and no Stripe request. The [read contract](read-contracts.md#bounded-product-and-price-identity)
|
|
601
|
+
explains duplicate handling and the host authorization boundary. Existing
|
|
602
|
+
provider-ID getters keep their first-row semantics.
|
package/docs/read-contracts.md
CHANGED
|
@@ -400,3 +400,37 @@ Omitting the flag or passing `false` retains the legacy first-row behavior and
|
|
|
400
400
|
are unchanged. The query performs no provider calls, writes or financial work.
|
|
401
401
|
Native-generated component references carry the optional boolean; hosts must
|
|
402
402
|
adopt a normally published, independently verified artifact before using it.
|
|
403
|
+
|
|
404
|
+
## Bounded product and price identity
|
|
405
|
+
|
|
406
|
+
Use `stripe.getProductIdentity(ctx, { stripeProductId })` and
|
|
407
|
+
`stripe.getPriceIdentity(ctx, { stripePriceId })` when the host needs to reject
|
|
408
|
+
an ambiguous provider-ID mapping. Each reads the existing exact provider-ID
|
|
409
|
+
index with `take(2)` and returns one of:
|
|
410
|
+
|
|
411
|
+
- `{ status: "missing" }` when no cached row matches.
|
|
412
|
+
- `{ status: "unique", product }` or `{ status: "unique", price }` with the
|
|
413
|
+
complete cached row and its actual component `_id`.
|
|
414
|
+
- `{ status: "ambiguous" }` when at least two rows match.
|
|
415
|
+
|
|
416
|
+
These readers never filter active status, account, parent product or metadata
|
|
417
|
+
before counting matches. An inactive or foreign-associated duplicate remains
|
|
418
|
+
ambiguous. They make no provider request and do not repair the cache. An unrelated
|
|
419
|
+
provider ID does not affect the queried identity. Existing
|
|
420
|
+
`getProductByStripeId` and `getPriceByStripeId` retain their first-row behavior
|
|
421
|
+
and return types.
|
|
422
|
+
|
|
423
|
+
The public `ProductIdentityResult` and `PriceIdentityResult` types narrow on
|
|
424
|
+
`status`. A host that requires an exact identity must reject both missing and
|
|
425
|
+
ambiguous results. Unique cache data does not grant permission. Authenticate the
|
|
426
|
+
current actor and validate original source, account ownership, recipient and
|
|
427
|
+
product/price relationships before exposing a reader or authorizing money writes.
|
|
428
|
+
For example, compare the unique price's `productId` with the unique product's
|
|
429
|
+
component `_id`, in addition to the expected provider IDs and currency.
|
|
430
|
+
|
|
431
|
+
The Vite reference's authorized server adapters can use these methods when they
|
|
432
|
+
need strict identity proof. This addition does not migrate its existing catalog
|
|
433
|
+
CRUD or replace its authorization. Dojo's plan-policy consumer must still prove
|
|
434
|
+
the original creator, current paid coverage and registered catalog version,
|
|
435
|
+
using the creator's platform-plan currency. This API does not implement Dojo
|
|
436
|
+
settlement or recurring affiliate terms.
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
ProductIdentityResult,
|
|
3
|
+
PriceIdentityResult,
|
|
4
|
+
} from "./products/identity.js";
|
|
1
5
|
export type { SettlementPolicyContext } from "../shared/settlementPolicyContext.js";
|
|
2
6
|
export { UsageSubscriptionError } from "./usage/subscriptionErrors.js";
|
|
3
7
|
export { UsageCatalogError } from "./usage/catalogTypes.js";
|
|
@@ -9,6 +9,7 @@ import type { StripeComponentProduct, StripeComponentPrice } from "../types.js";
|
|
|
9
9
|
import * as productsImpl from "./products.js";
|
|
10
10
|
import * as pricesImpl from "./prices.js";
|
|
11
11
|
import * as catalog from "./catalog.js";
|
|
12
|
+
import * as identity from "./identity.js";
|
|
12
13
|
|
|
13
14
|
/** Catalog APIs inherited by BetterStripe. Host authorization remains required. */
|
|
14
15
|
export abstract class CatalogClient extends BillingPortalClient {
|
|
@@ -137,6 +138,13 @@ export abstract class CatalogClient extends BillingPortalClient {
|
|
|
137
138
|
return productsImpl.getProduct(this.component, ctx, opts);
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
async getProductIdentity(
|
|
142
|
+
ctx: RunCtx,
|
|
143
|
+
opts: { stripeProductId: string },
|
|
144
|
+
): Promise<identity.ProductIdentityResult> {
|
|
145
|
+
return identity.getProductIdentity(this.component, ctx, opts);
|
|
146
|
+
}
|
|
147
|
+
|
|
140
148
|
async getProductByStripeId(
|
|
141
149
|
ctx: RunCtx,
|
|
142
150
|
opts: { stripeProductId: string },
|
|
@@ -208,6 +216,13 @@ export abstract class CatalogClient extends BillingPortalClient {
|
|
|
208
216
|
return pricesImpl.getPrice(this.component, ctx, opts);
|
|
209
217
|
}
|
|
210
218
|
|
|
219
|
+
async getPriceIdentity(
|
|
220
|
+
ctx: RunCtx,
|
|
221
|
+
opts: { stripePriceId: string },
|
|
222
|
+
): Promise<identity.PriceIdentityResult> {
|
|
223
|
+
return identity.getPriceIdentity(this.component, ctx, opts);
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
async getPriceByStripeId(
|
|
212
227
|
ctx: RunCtx,
|
|
213
228
|
opts: { stripePriceId: string },
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { BetterStripe } from "../index.js";
|
|
3
|
+
import { components, initConvexTest } from "../setup.test.js";
|
|
4
|
+
import schema from "../../component/schema.js";
|
|
5
|
+
import type { RunCtx } from "../helpers.js";
|
|
6
|
+
class ReadOnlyCatalog extends BetterStripe {
|
|
7
|
+
providerAccesses = 0;
|
|
8
|
+
protected override stripe(): never {
|
|
9
|
+
this.providerAccesses += 1;
|
|
10
|
+
throw new Error("Provider access forbidden for identity reads");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const modules = import.meta.glob("../../component/**/*.{ts,js,tsx,jsx}");
|
|
14
|
+
|
|
15
|
+
describe("public strict catalog identity facade", () => {
|
|
16
|
+
it("exposes a public strict product reader", () => {
|
|
17
|
+
const client = new ReadOnlyCatalog(components.betterStripe, {
|
|
18
|
+
STRIPE_SECRET_KEY: "sk_test_identity",
|
|
19
|
+
});
|
|
20
|
+
expect(Reflect.get(client, "getProductIdentity")).toBeTypeOf("function");
|
|
21
|
+
});
|
|
22
|
+
it("exposes a public strict price reader", () => {
|
|
23
|
+
const client = new ReadOnlyCatalog(components.betterStripe, {
|
|
24
|
+
STRIPE_SECRET_KEY: "sk_test_identity",
|
|
25
|
+
});
|
|
26
|
+
expect(Reflect.get(client, "getPriceIdentity")).toBeTypeOf("function");
|
|
27
|
+
});
|
|
28
|
+
it("forwards exact selectors through the actual component and preserves every result", async () => {
|
|
29
|
+
const t = initConvexTest();
|
|
30
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
31
|
+
const client = new ReadOnlyCatalog(components.betterStripe, {
|
|
32
|
+
STRIPE_SECRET_KEY: "sk_test_identity",
|
|
33
|
+
});
|
|
34
|
+
await t.action(async (realCtx) => {
|
|
35
|
+
const ctx: RunCtx = realCtx;
|
|
36
|
+
const query = vi.spyOn(ctx, "runQuery");
|
|
37
|
+
const productOpts = { stripeProductId: "prod_facade" };
|
|
38
|
+
const priceOpts = { stripePriceId: "price_facade" };
|
|
39
|
+
expect(await client.getProductIdentity(ctx, productOpts)).toEqual({
|
|
40
|
+
status: "missing",
|
|
41
|
+
});
|
|
42
|
+
expect(await client.getPriceIdentity(ctx, priceOpts)).toEqual({
|
|
43
|
+
status: "missing",
|
|
44
|
+
});
|
|
45
|
+
expect(query.mock.calls[0]?.[1]).toEqual(productOpts);
|
|
46
|
+
expect(query.mock.calls[1]?.[1]).toEqual(priceOpts);
|
|
47
|
+
await client.upsertProduct(ctx, {
|
|
48
|
+
...productOpts,
|
|
49
|
+
name: "Facade",
|
|
50
|
+
active: true,
|
|
51
|
+
});
|
|
52
|
+
const original = await client.getProductIdentity(ctx, productOpts);
|
|
53
|
+
expect(original.status).toBe("unique");
|
|
54
|
+
if (original.status !== "unique")
|
|
55
|
+
throw new Error("Expected original product fixture");
|
|
56
|
+
const productId = original.product._id;
|
|
57
|
+
await client.upsertPrice(ctx, {
|
|
58
|
+
...priceOpts,
|
|
59
|
+
productId,
|
|
60
|
+
stripeProductId: productOpts.stripeProductId,
|
|
61
|
+
unitAmount: 1200,
|
|
62
|
+
currency: "usd",
|
|
63
|
+
active: true,
|
|
64
|
+
type: "one_time",
|
|
65
|
+
});
|
|
66
|
+
const product = await client.getProductIdentity(ctx, productOpts);
|
|
67
|
+
const price = await client.getPriceIdentity(ctx, priceOpts);
|
|
68
|
+
expect(product).toMatchObject({
|
|
69
|
+
status: "unique",
|
|
70
|
+
product: {
|
|
71
|
+
_id: productId,
|
|
72
|
+
stripeProductId: productOpts.stripeProductId,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
expect(price).toMatchObject({
|
|
76
|
+
status: "unique",
|
|
77
|
+
price: { stripePriceId: priceOpts.stripePriceId, productId },
|
|
78
|
+
});
|
|
79
|
+
// Cardinality itself is exercised against actual duplicate rows in component tests.
|
|
80
|
+
// The facade must preserve an ambiguous result rather than reinterpret it as missing.
|
|
81
|
+
query.mockResolvedValue({ status: "ambiguous" });
|
|
82
|
+
expect(await client.getProductIdentity(ctx, productOpts)).toEqual({
|
|
83
|
+
status: "ambiguous",
|
|
84
|
+
});
|
|
85
|
+
expect(await client.getPriceIdentity(ctx, priceOpts)).toEqual({
|
|
86
|
+
status: "ambiguous",
|
|
87
|
+
});
|
|
88
|
+
expect(client.providerAccesses).toBe(0);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
2
|
+
import type { StripeComponentProduct, StripeComponentPrice } from "../types.js";
|
|
3
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
4
|
+
|
|
5
|
+
/** Cache cardinality is data, not permission or provider reconciliation. */
|
|
6
|
+
export type ProductIdentityResult =
|
|
7
|
+
| { status: "missing" }
|
|
8
|
+
| { status: "unique"; product: StripeComponentProduct }
|
|
9
|
+
| { status: "ambiguous" };
|
|
10
|
+
|
|
11
|
+
export type PriceIdentityResult =
|
|
12
|
+
| { status: "missing" }
|
|
13
|
+
| { status: "unique"; price: StripeComponentPrice }
|
|
14
|
+
| { status: "ambiguous" };
|
|
15
|
+
|
|
16
|
+
export async function getProductIdentity(
|
|
17
|
+
component: Component,
|
|
18
|
+
ctx: RunCtx,
|
|
19
|
+
opts: { stripeProductId: string },
|
|
20
|
+
): Promise<ProductIdentityResult> {
|
|
21
|
+
return ctx.runQuery(
|
|
22
|
+
componentRef(component, "products/queries/getProductIdentity"),
|
|
23
|
+
opts,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function getPriceIdentity(
|
|
28
|
+
component: Component,
|
|
29
|
+
ctx: RunCtx,
|
|
30
|
+
opts: { stripePriceId: string },
|
|
31
|
+
): Promise<PriceIdentityResult> {
|
|
32
|
+
return ctx.runQuery(
|
|
33
|
+
componentRef(component, "products/queries/getPriceIdentity"),
|
|
34
|
+
opts,
|
|
35
|
+
);
|
|
36
|
+
}
|