@fantastic.dev/better-stripe 0.34.0 → 0.37.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 +260 -0
- package/README.md +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +664 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +332 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +664 -2
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +332 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/refundCommandEvidence.d.ts +14 -0
- package/dist/client/connect/refundCommandEvidence.d.ts.map +1 -0
- package/dist/client/connect/refundCommandEvidence.js +20 -0
- package/dist/client/connect/refundCommandEvidence.js.map +1 -0
- package/dist/client/connect/refundCommandNormalization.d.ts +11 -0
- package/dist/client/connect/refundCommandNormalization.d.ts.map +1 -0
- package/dist/client/connect/refundCommandNormalization.js +12 -0
- package/dist/client/connect/refundCommandNormalization.js.map +1 -0
- package/dist/client/financialObservations.d.ts +42 -0
- package/dist/client/financialObservations.d.ts.map +1 -0
- package/dist/client/financialObservations.js +58 -0
- package/dist/client/financialObservations.js.map +1 -0
- package/dist/client/financialOwnership.d.ts +52 -0
- package/dist/client/financialOwnership.d.ts.map +1 -0
- package/dist/client/financialOwnership.js +72 -0
- package/dist/client/financialOwnership.js.map +1 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/observationPagination.d.ts +10 -0
- package/dist/client/observationPagination.d.ts.map +1 -0
- package/dist/client/observationPagination.js +12 -0
- package/dist/client/observationPagination.js.map +1 -0
- package/dist/client/operationEvidence.d.ts +37 -0
- package/dist/client/operationEvidence.d.ts.map +1 -0
- package/dist/client/operationEvidence.js +44 -0
- package/dist/client/operationEvidence.js.map +1 -0
- package/dist/client/publicTypes.d.ts +6 -0
- package/dist/client/publicTypes.d.ts.map +1 -1
- package/dist/client/readContracts.d.ts +31 -0
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +14 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/client/transferObservations.d.ts +59 -0
- package/dist/client/transferObservations.d.ts.map +1 -0
- package/dist/client/transferObservations.js +82 -0
- package/dist/client/transferObservations.js.map +1 -0
- package/dist/component/_generated/component.d.ts +687 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -1
- package/dist/component/affiliateRecovery/mutations.js +4 -1
- package/dist/component/affiliateRecovery/mutations.js.map +1 -1
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +18 -2
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/queries.d.ts +8 -0
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.js +7 -1
- package/dist/component/connect/reversalClaims.js.map +1 -1
- package/dist/component/connect/reversalReceipts.d.ts.map +1 -1
- package/dist/component/connect/reversalReceipts.js +2 -0
- package/dist/component/connect/reversalReceipts.js.map +1 -1
- package/dist/component/connect/schema.d.ts +11 -1
- package/dist/component/connect/schema.d.ts.map +1 -1
- package/dist/component/connect/schema.js +9 -1
- package/dist/component/connect/schema.js.map +1 -1
- package/dist/component/connect/validators.d.ts +9 -1
- package/dist/component/connect/validators.d.ts.map +1 -1
- package/dist/component/connect/validators.js +2 -0
- package/dist/component/connect/validators.js.map +1 -1
- package/dist/component/earnings/pairedAdjustment.d.ts +12 -0
- package/dist/component/earnings/pairedAdjustment.d.ts.map +1 -0
- package/dist/component/earnings/pairedAdjustment.js +46 -0
- package/dist/component/earnings/pairedAdjustment.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +546 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/earnings/triggers.js +17 -3
- package/dist/component/earnings/triggers.js.map +1 -1
- package/dist/component/financialObservations/continuation.d.ts +7 -0
- package/dist/component/financialObservations/continuation.d.ts.map +1 -0
- package/dist/component/financialObservations/continuation.js +131 -0
- package/dist/component/financialObservations/continuation.js.map +1 -0
- package/dist/component/financialObservations/generations.d.ts +6 -0
- package/dist/component/financialObservations/generations.d.ts.map +1 -0
- package/dist/component/financialObservations/generations.js +46 -0
- package/dist/component/financialObservations/generations.js.map +1 -0
- package/dist/component/financialObservations/mutations.d.ts +62 -0
- package/dist/component/financialObservations/mutations.d.ts.map +1 -0
- package/dist/component/financialObservations/mutations.js +69 -0
- package/dist/component/financialObservations/mutations.js.map +1 -0
- package/dist/component/financialObservations/queries.d.ts +307 -0
- package/dist/component/financialObservations/queries.d.ts.map +1 -0
- package/dist/component/financialObservations/queries.js +219 -0
- package/dist/component/financialObservations/queries.js.map +1 -0
- package/dist/component/financialObservations/schema.d.ts +182 -0
- package/dist/component/financialObservations/schema.d.ts.map +1 -0
- package/dist/component/financialObservations/schema.js +53 -0
- package/dist/component/financialObservations/schema.js.map +1 -0
- package/dist/component/financialObservations/settlement.d.ts +7 -0
- package/dist/component/financialObservations/settlement.d.ts.map +1 -0
- package/dist/component/financialObservations/settlement.js +118 -0
- package/dist/component/financialObservations/settlement.js.map +1 -0
- package/dist/component/financialObservations/settlementHelpers.d.ts +46 -0
- package/dist/component/financialObservations/settlementHelpers.d.ts.map +1 -0
- package/dist/component/financialObservations/settlementHelpers.js +70 -0
- package/dist/component/financialObservations/settlementHelpers.js.map +1 -0
- package/dist/component/financialObservations/transferBatches.d.ts +12 -0
- package/dist/component/financialObservations/transferBatches.d.ts.map +1 -0
- package/dist/component/financialObservations/transferBatches.js +76 -0
- package/dist/component/financialObservations/transferBatches.js.map +1 -0
- package/dist/component/financialObservations/transferContinuation.d.ts +5 -0
- package/dist/component/financialObservations/transferContinuation.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuation.js +35 -0
- package/dist/component/financialObservations/transferContinuation.js.map +1 -0
- package/dist/component/financialObservations/transferContinuationState.d.ts +8 -0
- package/dist/component/financialObservations/transferContinuationState.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuationState.js +69 -0
- package/dist/component/financialObservations/transferContinuationState.js.map +1 -0
- package/dist/component/financialObservations/transferContinuationSteps.d.ts +5 -0
- package/dist/component/financialObservations/transferContinuationSteps.d.ts.map +1 -0
- package/dist/component/financialObservations/transferContinuationSteps.js +174 -0
- package/dist/component/financialObservations/transferContinuationSteps.js.map +1 -0
- package/dist/component/financialObservations/transferHelpers.d.ts +18 -0
- package/dist/component/financialObservations/transferHelpers.d.ts.map +1 -0
- package/dist/component/financialObservations/transferHelpers.js +37 -0
- package/dist/component/financialObservations/transferHelpers.js.map +1 -0
- package/dist/component/financialObservations/transferReferenceSchema.d.ts +56 -0
- package/dist/component/financialObservations/transferReferenceSchema.d.ts.map +1 -0
- package/dist/component/financialObservations/transferReferenceSchema.js +21 -0
- package/dist/component/financialObservations/transferReferenceSchema.js.map +1 -0
- package/dist/component/financialObservations/transferSchema.d.ts +237 -0
- package/dist/component/financialObservations/transferSchema.d.ts.map +1 -0
- package/dist/component/financialObservations/transferSchema.js +65 -0
- package/dist/component/financialObservations/transferSchema.js.map +1 -0
- package/dist/component/financialObservations/transfers.d.ts +7 -0
- package/dist/component/financialObservations/transfers.d.ts.map +1 -0
- package/dist/component/financialObservations/transfers.js +79 -0
- package/dist/component/financialObservations/transfers.js.map +1 -0
- package/dist/component/financialOwnership/helpers.d.ts +37 -0
- package/dist/component/financialOwnership/helpers.d.ts.map +1 -0
- package/dist/component/financialOwnership/helpers.js +76 -0
- package/dist/component/financialOwnership/helpers.js.map +1 -0
- package/dist/component/financialOwnership/mutations.d.ts +28 -0
- package/dist/component/financialOwnership/mutations.d.ts.map +1 -0
- package/dist/component/financialOwnership/mutations.js +74 -0
- package/dist/component/financialOwnership/mutations.js.map +1 -0
- package/dist/component/financialOwnership/queries.d.ts +57 -0
- package/dist/component/financialOwnership/queries.d.ts.map +1 -0
- package/dist/component/financialOwnership/queries.js +50 -0
- package/dist/component/financialOwnership/queries.js.map +1 -0
- package/dist/component/financialOwnership/schema.d.ts +140 -0
- package/dist/component/financialOwnership/schema.d.ts.map +1 -0
- package/dist/component/financialOwnership/schema.js +35 -0
- package/dist/component/financialOwnership/schema.js.map +1 -0
- package/dist/component/operationEvidence/canonical.d.ts +4 -0
- package/dist/component/operationEvidence/canonical.d.ts.map +1 -0
- package/dist/component/operationEvidence/canonical.js +8 -0
- package/dist/component/operationEvidence/canonical.js.map +1 -0
- package/dist/component/operationEvidence/helpers.d.ts +87 -0
- package/dist/component/operationEvidence/helpers.d.ts.map +1 -0
- package/dist/component/operationEvidence/helpers.js +49 -0
- package/dist/component/operationEvidence/helpers.js.map +1 -0
- package/dist/component/operationEvidence/maintenance.d.ts +88 -0
- package/dist/component/operationEvidence/maintenance.d.ts.map +1 -0
- package/dist/component/operationEvidence/maintenance.js +59 -0
- package/dist/component/operationEvidence/maintenance.js.map +1 -0
- package/dist/component/operationEvidence/mutations.d.ts +97 -0
- package/dist/component/operationEvidence/mutations.d.ts.map +1 -0
- package/dist/component/operationEvidence/mutations.js +14 -0
- package/dist/component/operationEvidence/mutations.js.map +1 -0
- package/dist/component/operationEvidence/queries.d.ts +205 -0
- package/dist/component/operationEvidence/queries.d.ts.map +1 -0
- package/dist/component/operationEvidence/queries.js +75 -0
- package/dist/component/operationEvidence/queries.js.map +1 -0
- package/dist/component/operationEvidence/schema.d.ts +536 -0
- package/dist/component/operationEvidence/schema.d.ts.map +1 -0
- package/dist/component/operationEvidence/schema.js +53 -0
- package/dist/component/operationEvidence/schema.js.map +1 -0
- package/dist/component/refundHistory/commandBinding.d.ts +17 -0
- package/dist/component/refundHistory/commandBinding.d.ts.map +1 -0
- package/dist/component/refundHistory/commandBinding.js +41 -0
- package/dist/component/refundHistory/commandBinding.js.map +1 -0
- package/dist/component/refundHistory/commandEvidence.d.ts +50 -0
- package/dist/component/refundHistory/commandEvidence.d.ts.map +1 -0
- package/dist/component/refundHistory/commandEvidence.js +58 -0
- package/dist/component/refundHistory/commandEvidence.js.map +1 -0
- package/dist/component/refundHistory/commandEvidenceValidator.d.ts +89 -0
- package/dist/component/refundHistory/commandEvidenceValidator.d.ts.map +1 -0
- package/dist/component/refundHistory/commandEvidenceValidator.js +8 -0
- package/dist/component/refundHistory/commandEvidenceValidator.js.map +1 -0
- package/dist/component/refundHistory/commandFields.d.ts +8 -0
- package/dist/component/refundHistory/commandFields.d.ts.map +1 -0
- package/dist/component/refundHistory/commandFields.js +9 -0
- package/dist/component/refundHistory/commandFields.js.map +1 -0
- package/dist/component/refundHistory/mutations.d.ts +8 -0
- package/dist/component/refundHistory/mutations.d.ts.map +1 -0
- package/dist/component/refundHistory/mutations.js +25 -0
- package/dist/component/refundHistory/mutations.js.map +1 -0
- package/dist/component/refundHistory/originalSeller.d.ts +5 -0
- package/dist/component/refundHistory/originalSeller.d.ts.map +1 -0
- package/dist/component/refundHistory/originalSeller.js +35 -0
- package/dist/component/refundHistory/originalSeller.js.map +1 -0
- package/dist/component/refundHistory/queries.d.ts +51 -0
- package/dist/component/refundHistory/queries.d.ts.map +1 -1
- package/dist/component/refundHistory/queries.js +14 -0
- package/dist/component/refundHistory/queries.js.map +1 -1
- package/dist/component/schema.d.ts +332 -1
- package/dist/component/schema.js +15 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/settlement/mutations.d.ts.map +1 -1
- package/dist/component/settlement/mutations.js +5 -1
- package/dist/component/settlement/mutations.js.map +1 -1
- package/dist/shared/refundCommandScope.d.ts +10 -0
- package/dist/shared/refundCommandScope.d.ts.map +1 -0
- package/dist/shared/refundCommandScope.js +9 -0
- package/dist/shared/refundCommandScope.js.map +1 -0
- package/docs/financial-observations.md +244 -0
- package/docs/financial-ownership.md +54 -0
- package/docs/refund-command-evidence.md +55 -0
- package/package.json +5 -2
- package/src/client/connect/refundCommandEvidence.ts +41 -0
- package/src/client/connect/refundCommandNormalization.ts +28 -0
- package/src/client/financialObservations.test.ts +109 -0
- package/src/client/financialObservations.ts +106 -0
- package/src/client/financialOwnership.test.ts +80 -0
- package/src/client/financialOwnership.ts +116 -0
- package/src/client/index.ts +2 -2
- package/src/client/observationPagination.ts +11 -0
- package/src/client/operationEvidence.test.ts +110 -0
- package/src/client/operationEvidence.ts +92 -0
- package/src/client/publicTypes.ts +45 -0
- package/src/client/readContracts.ts +25 -0
- package/src/client/refund-command-evidence.test.ts +68 -0
- package/src/client/refund-command-normalization.test.ts +61 -0
- package/src/client/transferContinuation.test.ts +94 -0
- package/src/client/transferObservations.test.ts +98 -0
- package/src/client/transferObservations.ts +180 -0
- package/src/component/_generated/api.ts +54 -0
- package/src/component/_generated/component.ts +797 -0
- package/src/component/affiliateRecovery/mutations.ts +10 -1
- package/src/component/connect/mutations.ts +29 -2
- package/src/component/connect/reversalClaims.ts +19 -1
- package/src/component/connect/reversalReceipts.ts +2 -0
- package/src/component/connect/schema.ts +9 -1
- package/src/component/connect/validators.ts +2 -0
- package/src/component/core/reset.test.ts +8 -1
- package/src/component/earnings/earnings-totals.test.ts +14 -10
- package/src/component/earnings/paired-adjustment.test.ts +258 -0
- package/src/component/earnings/pairedAdjustment.ts +77 -0
- package/src/component/earnings/triggers.ts +23 -11
- package/src/component/financialObservations/continuation.test.ts +445 -0
- package/src/component/financialObservations/continuation.ts +159 -0
- package/src/component/financialObservations/generations.ts +53 -0
- package/src/component/financialObservations/mutations.ts +75 -0
- package/src/component/financialObservations/observation-boundaries.test.ts +466 -0
- package/src/component/financialObservations/queries.ts +246 -0
- package/src/component/financialObservations/schema.ts +68 -0
- package/src/component/financialObservations/settlement-observations.test.ts +86 -0
- package/src/component/financialObservations/settlement.ts +142 -0
- package/src/component/financialObservations/settlementHelpers.ts +92 -0
- package/src/component/financialObservations/transfer-batches.test.ts +61 -0
- package/src/component/financialObservations/transfer-boundaries.test.ts +116 -0
- package/src/component/financialObservations/transfer-continuation-guards.test.ts +428 -0
- package/src/component/financialObservations/transfer-continuation.test.ts +154 -0
- package/src/component/financialObservations/transfer-observations.test.ts +212 -0
- package/src/component/financialObservations/transfer-overflow.test.ts +181 -0
- package/src/component/financialObservations/transfer-writers.test.ts +162 -0
- package/src/component/financialObservations/transferBatches.ts +96 -0
- package/src/component/financialObservations/transferContinuation.ts +53 -0
- package/src/component/financialObservations/transferContinuationState.ts +85 -0
- package/src/component/financialObservations/transferContinuationSteps.ts +232 -0
- package/src/component/financialObservations/transferHelpers.ts +38 -0
- package/src/component/financialObservations/transferReferenceSchema.ts +20 -0
- package/src/component/financialObservations/transferSchema.ts +74 -0
- package/src/component/financialObservations/transfers.ts +99 -0
- package/src/component/financialOwnership/financial-ownership.test.ts +102 -0
- package/src/component/financialOwnership/helpers.ts +98 -0
- package/src/component/financialOwnership/mutations.ts +83 -0
- package/src/component/financialOwnership/ownership-boundaries.test.ts +308 -0
- package/src/component/financialOwnership/queries.ts +65 -0
- package/src/component/financialOwnership/schema.ts +35 -0
- package/src/component/operationEvidence/canonical.ts +10 -0
- package/src/component/operationEvidence/helpers.ts +65 -0
- package/src/component/operationEvidence/integrity.test.ts +257 -0
- package/src/component/operationEvidence/maintenance.test.ts +152 -0
- package/src/component/operationEvidence/maintenance.ts +89 -0
- package/src/component/operationEvidence/mutations.ts +14 -0
- package/src/component/operationEvidence/queries.ts +108 -0
- package/src/component/operationEvidence/reads.test.ts +140 -0
- package/src/component/operationEvidence/schema.ts +62 -0
- package/src/component/refundHistory/command-evidence.test.ts +288 -0
- package/src/component/refundHistory/command-normalization-resource.test.ts +77 -0
- package/src/component/refundHistory/command-normalization.test.ts +229 -0
- package/src/component/refundHistory/command-provenance.test.ts +59 -0
- package/src/component/refundHistory/commandBinding.ts +54 -0
- package/src/component/refundHistory/commandEvidence.ts +76 -0
- package/src/component/refundHistory/commandEvidenceValidator.ts +18 -0
- package/src/component/refundHistory/commandFields.ts +9 -0
- package/src/component/refundHistory/mutations.ts +33 -0
- package/src/component/refundHistory/original-seller-boundaries.test.ts +138 -0
- package/src/component/refundHistory/original-seller.test.ts +175 -0
- package/src/component/refundHistory/originalSeller.ts +48 -0
- package/src/component/refundHistory/queries.ts +15 -0
- package/src/component/schema.ts +28 -0
- package/src/component/settlement/mutations.ts +5 -1
- package/src/shared/refundCommandScope.ts +19 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { TransferObservationsClient } from "./transferObservations.js";
|
|
2
|
+
import { observationPagination } from "./observationPagination.js";
|
|
3
|
+
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
4
|
+
import type { Infer } from "convex/values";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import {
|
|
7
|
+
assertOwner,
|
|
8
|
+
assertSelector,
|
|
9
|
+
} from "../component/financialOwnership/helpers.js";
|
|
10
|
+
import type {
|
|
11
|
+
legDoc,
|
|
12
|
+
sourceDoc,
|
|
13
|
+
} from "../component/financialObservations/schema.js";
|
|
14
|
+
import { InvoiceReadClient } from "./invoiceReads.js";
|
|
15
|
+
import type { Component, RunCtx } from "./helpers.js";
|
|
16
|
+
import { runMutationOrThrow } from "./helpers.js";
|
|
17
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
18
|
+
|
|
19
|
+
export type FinancialSourceObservation = Infer<typeof sourceDoc>;
|
|
20
|
+
export type FinancialSourceLeg = Infer<typeof legDoc>;
|
|
21
|
+
export type FinancialSourceResult = {
|
|
22
|
+
coverage: "unknown";
|
|
23
|
+
observation: FinancialSourceObservation | null;
|
|
24
|
+
};
|
|
25
|
+
export type FinancialObservationPage = PaginationResult<FinancialSourceLeg> & {
|
|
26
|
+
coverage: "unknown";
|
|
27
|
+
generation: number | null;
|
|
28
|
+
};
|
|
29
|
+
export type FinancialObservationOwner = { userId: string; orgId?: string };
|
|
30
|
+
/** Trusted host diagnostics only; neither caller selectors nor exhausted pages authorize closure. */
|
|
31
|
+
export class FinancialObservationsClient extends TransferObservationsClient {
|
|
32
|
+
constructor(component: Component) {
|
|
33
|
+
super(component);
|
|
34
|
+
}
|
|
35
|
+
async source(
|
|
36
|
+
ctx: RunCtx,
|
|
37
|
+
input: { allocationId: string },
|
|
38
|
+
): Promise<FinancialSourceResult> {
|
|
39
|
+
const args = z
|
|
40
|
+
.object({ allocationId: z.string().min(1).max(256) })
|
|
41
|
+
.strict()
|
|
42
|
+
.parse(input);
|
|
43
|
+
return ctx.runQuery(
|
|
44
|
+
componentRef(this.component, "financialObservations/queries/source"),
|
|
45
|
+
args,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
async resume(
|
|
49
|
+
ctx: RunCtx,
|
|
50
|
+
input: { allocationId: string; expectedGeneration: number },
|
|
51
|
+
): Promise<FinancialSourceResult> {
|
|
52
|
+
const args = z
|
|
53
|
+
.object({
|
|
54
|
+
allocationId: z.string().min(1).max(256),
|
|
55
|
+
expectedGeneration: z
|
|
56
|
+
.number()
|
|
57
|
+
.int()
|
|
58
|
+
.min(1)
|
|
59
|
+
.max(Number.MAX_SAFE_INTEGER),
|
|
60
|
+
})
|
|
61
|
+
.strict()
|
|
62
|
+
.parse(input);
|
|
63
|
+
return runMutationOrThrow(
|
|
64
|
+
ctx,
|
|
65
|
+
componentRef(this.component, "financialObservations/mutations/resume"),
|
|
66
|
+
args,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
async bucket(
|
|
70
|
+
ctx: RunCtx,
|
|
71
|
+
input: { bucketKey: string; paginationOpts: PaginationOptions },
|
|
72
|
+
): Promise<FinancialObservationPage> {
|
|
73
|
+
const args = z
|
|
74
|
+
.object({ bucketKey: z.string(), paginationOpts: observationPagination })
|
|
75
|
+
.strict()
|
|
76
|
+
.parse(input);
|
|
77
|
+
assertSelector(args.bucketKey);
|
|
78
|
+
return ctx.runQuery(
|
|
79
|
+
componentRef(this.component, "financialObservations/queries/bucket"),
|
|
80
|
+
args,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
async owner(
|
|
84
|
+
ctx: RunCtx,
|
|
85
|
+
input: FinancialObservationOwner & { paginationOpts: PaginationOptions },
|
|
86
|
+
): Promise<FinancialObservationPage> {
|
|
87
|
+
const args = z
|
|
88
|
+
.object({
|
|
89
|
+
userId: z.string(),
|
|
90
|
+
orgId: z.string().optional(),
|
|
91
|
+
paginationOpts: observationPagination,
|
|
92
|
+
})
|
|
93
|
+
.strict()
|
|
94
|
+
.parse(input);
|
|
95
|
+
assertOwner(args);
|
|
96
|
+
return ctx.runQuery(
|
|
97
|
+
componentRef(this.component, "financialObservations/queries/owner"),
|
|
98
|
+
args,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export abstract class FinancialObservationsHost extends InvoiceReadClient {
|
|
103
|
+
readonly financialObservations = new FinancialObservationsClient(
|
|
104
|
+
this.component,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
import { BetterStripe } from "./index.js";
|
|
5
|
+
import type { RunCtx } from "./helpers.js";
|
|
6
|
+
import { components, initConvexTest } from "./setup.test.js";
|
|
7
|
+
|
|
8
|
+
const modules = import.meta.glob("../component/**/*.ts");
|
|
9
|
+
function fixture() {
|
|
10
|
+
const t = initConvexTest();
|
|
11
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
12
|
+
return {
|
|
13
|
+
client: new BetterStripe(components.betterStripe),
|
|
14
|
+
ctx: { runQuery: t.query, runMutation: t.mutation } as RunCtx,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
describe("public financial ownership client", () => {
|
|
18
|
+
it("registers and reads actual component provenance without configuring Stripe", async () => {
|
|
19
|
+
const { client, ctx } = fixture();
|
|
20
|
+
expect(
|
|
21
|
+
await client.financialOwnership.lookup(ctx, { bucketKey: "opaque" }),
|
|
22
|
+
).toEqual({ status: "unknown", coverage: "unknown" });
|
|
23
|
+
const registered = await client.financialOwnership.register(ctx, {
|
|
24
|
+
bucketKey: "opaque",
|
|
25
|
+
kind: "logical",
|
|
26
|
+
userId: "user_one",
|
|
27
|
+
source: { integration: "trusted-host", recordId: "award_42" },
|
|
28
|
+
});
|
|
29
|
+
expect(
|
|
30
|
+
await client.financialOwnership.lookup(ctx, { bucketKey: "opaque" }),
|
|
31
|
+
).toEqual(registered);
|
|
32
|
+
expect(
|
|
33
|
+
await client.financialOwnership.discover(ctx, {
|
|
34
|
+
userId: "user_one",
|
|
35
|
+
paginationOpts: { numItems: 10, cursor: null },
|
|
36
|
+
}),
|
|
37
|
+
).toMatchObject({
|
|
38
|
+
coverage: "unknown",
|
|
39
|
+
generation: 1,
|
|
40
|
+
isDone: true,
|
|
41
|
+
page: [registered.registration],
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it("preserves native pagination identity on trusted discovery callbacks", async () => {
|
|
45
|
+
const { client, ctx } = fixture();
|
|
46
|
+
const paginationOpts = { numItems: 10, cursor: null, id: 7 };
|
|
47
|
+
expect(
|
|
48
|
+
await client.financialOwnership.discover(ctx, {
|
|
49
|
+
userId: "user_one",
|
|
50
|
+
paginationOpts,
|
|
51
|
+
}),
|
|
52
|
+
).toMatchObject({ coverage: "unknown", page: [] });
|
|
53
|
+
});
|
|
54
|
+
it.each(["", " leading", "x".repeat(257)])(
|
|
55
|
+
"rejects invalid selector %j before dispatch",
|
|
56
|
+
async (bucketKey) => {
|
|
57
|
+
const { client } = fixture();
|
|
58
|
+
const ctx = { runQuery: vi.fn(), runMutation: vi.fn() };
|
|
59
|
+
await expect(
|
|
60
|
+
client.financialOwnership.lookup(ctx, { bucketKey }),
|
|
61
|
+
).rejects.toThrow();
|
|
62
|
+
expect(ctx.runQuery).not.toHaveBeenCalled();
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
it("rejects caller complete flags and physical proof fields before dispatch", async () => {
|
|
66
|
+
const { client } = fixture();
|
|
67
|
+
const ctx = { runQuery: vi.fn(), runMutation: vi.fn() };
|
|
68
|
+
const input = {
|
|
69
|
+
bucketKey: "acct_one",
|
|
70
|
+
kind: "stripe_account" as const,
|
|
71
|
+
userId: "user_one",
|
|
72
|
+
source: { integration: "forged", recordId: "forged" },
|
|
73
|
+
complete: true,
|
|
74
|
+
};
|
|
75
|
+
await expect(
|
|
76
|
+
client.financialOwnership.register(ctx, input),
|
|
77
|
+
).rejects.toThrow();
|
|
78
|
+
expect(ctx.runMutation).not.toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
2
|
+
import type { Infer } from "convex/values";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import {
|
|
5
|
+
assertOwner,
|
|
6
|
+
assertSelector,
|
|
7
|
+
} from "../component/financialOwnership/helpers.js";
|
|
8
|
+
import type { registrationDoc } from "../component/financialOwnership/schema.js";
|
|
9
|
+
import { FinancialObservationsHost } from "./financialObservations.js";
|
|
10
|
+
import type { Component, RunCtx } from "./helpers.js";
|
|
11
|
+
import { runMutationOrThrow } from "./helpers.js";
|
|
12
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
13
|
+
|
|
14
|
+
export type FinancialOwnershipRegistration = Infer<typeof registrationDoc>;
|
|
15
|
+
export type FinancialOwnershipResult =
|
|
16
|
+
| {
|
|
17
|
+
status: "registered";
|
|
18
|
+
coverage: "unknown";
|
|
19
|
+
registration: FinancialOwnershipRegistration;
|
|
20
|
+
}
|
|
21
|
+
| { status: "unknown"; coverage: "unknown" };
|
|
22
|
+
export type FinancialOwnershipOwner = { userId: string; orgId?: string };
|
|
23
|
+
export type RegisterFinancialOwnershipOptions = FinancialOwnershipOwner & {
|
|
24
|
+
bucketKey: string;
|
|
25
|
+
} & (
|
|
26
|
+
| { kind: "stripe_account" }
|
|
27
|
+
| { kind: "logical"; source: { integration: string; recordId: string } }
|
|
28
|
+
);
|
|
29
|
+
export type FinancialOwnershipPage =
|
|
30
|
+
PaginationResult<FinancialOwnershipRegistration> & {
|
|
31
|
+
coverage: "unknown";
|
|
32
|
+
generation: number;
|
|
33
|
+
};
|
|
34
|
+
const owner = { userId: z.string(), orgId: z.string().optional() };
|
|
35
|
+
const registrationInput = z.discriminatedUnion("kind", [
|
|
36
|
+
z
|
|
37
|
+
.object({
|
|
38
|
+
...owner,
|
|
39
|
+
bucketKey: z.string(),
|
|
40
|
+
kind: z.literal("stripe_account"),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
z
|
|
44
|
+
.object({
|
|
45
|
+
...owner,
|
|
46
|
+
bucketKey: z.string(),
|
|
47
|
+
kind: z.literal("logical"),
|
|
48
|
+
source: z
|
|
49
|
+
.object({ integration: z.string(), recordId: z.string() })
|
|
50
|
+
.strict(),
|
|
51
|
+
})
|
|
52
|
+
.strict(),
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
/** Trusted host-server provenance only. Authenticate the actor and verify logical source ownership first. */
|
|
56
|
+
export class FinancialOwnershipClient {
|
|
57
|
+
constructor(private component: Component) {}
|
|
58
|
+
async register(
|
|
59
|
+
ctx: RunCtx,
|
|
60
|
+
input: RegisterFinancialOwnershipOptions,
|
|
61
|
+
): Promise<Extract<FinancialOwnershipResult, { status: "registered" }>> {
|
|
62
|
+
const args = registrationInput.parse(input);
|
|
63
|
+
assertOwner(args);
|
|
64
|
+
assertSelector(args.bucketKey);
|
|
65
|
+
if (args.kind === "logical") {
|
|
66
|
+
assertSelector(args.source.integration);
|
|
67
|
+
assertSelector(args.source.recordId);
|
|
68
|
+
}
|
|
69
|
+
return runMutationOrThrow(
|
|
70
|
+
ctx,
|
|
71
|
+
componentRef(this.component, "financialOwnership/mutations/register"),
|
|
72
|
+
args,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
async lookup(
|
|
76
|
+
ctx: RunCtx,
|
|
77
|
+
input: { bucketKey: string },
|
|
78
|
+
): Promise<FinancialOwnershipResult> {
|
|
79
|
+
const args = z.object({ bucketKey: z.string() }).strict().parse(input);
|
|
80
|
+
assertSelector(args.bucketKey);
|
|
81
|
+
return ctx.runQuery(
|
|
82
|
+
componentRef(this.component, "financialOwnership/queries/lookup"),
|
|
83
|
+
args,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
async discover(
|
|
87
|
+
ctx: RunCtx,
|
|
88
|
+
input: FinancialOwnershipOwner & { paginationOpts: PaginationOptions },
|
|
89
|
+
): Promise<FinancialOwnershipPage> {
|
|
90
|
+
const args = z
|
|
91
|
+
.object({
|
|
92
|
+
...owner,
|
|
93
|
+
paginationOpts: z
|
|
94
|
+
.object({
|
|
95
|
+
numItems: z.number().int().min(1).max(100),
|
|
96
|
+
cursor: z.string().nullable(),
|
|
97
|
+
id: z.number().optional(),
|
|
98
|
+
endCursor: z.string().nullable().optional(),
|
|
99
|
+
maximumRowsRead: z.number().optional(),
|
|
100
|
+
maximumBytesRead: z.number().optional(),
|
|
101
|
+
})
|
|
102
|
+
.strict(),
|
|
103
|
+
})
|
|
104
|
+
.strict()
|
|
105
|
+
.parse(input);
|
|
106
|
+
assertOwner(args);
|
|
107
|
+
return ctx.runQuery(
|
|
108
|
+
componentRef(this.component, "financialOwnership/queries/discover"),
|
|
109
|
+
args,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Extends the existing facade without expanding its frozen entry-file budget. */
|
|
114
|
+
export abstract class FinancialOwnershipHost extends FinancialObservationsHost {
|
|
115
|
+
readonly financialOwnership = new FinancialOwnershipClient(this.component);
|
|
116
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type { CreateCheckoutSessionOptions } from "./billing/checkoutOptions.js"
|
|
|
18
18
|
export type { CreateCheckoutSessionOptions } from "./billing/checkoutOptions.js";
|
|
19
19
|
import * as intentsImpl from "./billing/intents.js";
|
|
20
20
|
export type * from "./billing/intents.js";
|
|
21
|
-
import {
|
|
21
|
+
import { FinancialOwnershipHost } from "./financialOwnership.js";
|
|
22
22
|
import { CostRecoveryClient } from "./costRecovery.js";
|
|
23
23
|
export * from "./charge-currency.js";
|
|
24
24
|
export * from "./costRecovery.js";
|
|
@@ -202,7 +202,7 @@ export type BetterStripeComponent = ComponentApi;
|
|
|
202
202
|
|
|
203
203
|
// BETTER STRIPE CLIENT
|
|
204
204
|
|
|
205
|
-
export class BetterStripe extends
|
|
205
|
+
export class BetterStripe extends FinancialOwnershipHost {
|
|
206
206
|
readonly stripeApiVersion: SupportedStripeApiVersion;
|
|
207
207
|
private _apiKey?: string;
|
|
208
208
|
private _triggers?: SyncTriggers;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const observationPagination = z
|
|
3
|
+
.object({
|
|
4
|
+
numItems: z.number().int().min(1).max(100),
|
|
5
|
+
cursor: z.string().nullable(),
|
|
6
|
+
id: z.number().optional(),
|
|
7
|
+
endCursor: z.string().nullable().optional(),
|
|
8
|
+
maximumRowsRead: z.number().optional(),
|
|
9
|
+
maximumBytesRead: z.number().optional(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { expect, it, vi } from "vitest";
|
|
3
|
+
import schema from "../component/schema.js";
|
|
4
|
+
import { BetterStripe } from "./index.js";
|
|
5
|
+
import type { RunCtx } from "./helpers.js";
|
|
6
|
+
import { components, initConvexTest } from "./setup.test.js";
|
|
7
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
8
|
+
|
|
9
|
+
it("captures and reads lossless evidence through the actual public SDK and component", async () => {
|
|
10
|
+
const t = initConvexTest();
|
|
11
|
+
t.registerComponent(
|
|
12
|
+
"betterStripe",
|
|
13
|
+
schema,
|
|
14
|
+
import.meta.glob("../component/**/*.ts"),
|
|
15
|
+
);
|
|
16
|
+
const client = new BetterStripe(components.betterStripe);
|
|
17
|
+
const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
|
|
18
|
+
const operationId = "\u0000".repeat(5000);
|
|
19
|
+
await t.mutation(
|
|
20
|
+
componentRef(
|
|
21
|
+
components.betterStripe,
|
|
22
|
+
"connect/mutations/claimReversalSlices",
|
|
23
|
+
),
|
|
24
|
+
{ operationId, sourceChargeId: "charge", mode: { kind: "full" } },
|
|
25
|
+
);
|
|
26
|
+
const source = await t.query(
|
|
27
|
+
componentRef(components.betterStripe, "connect/queries/getReversalOp"),
|
|
28
|
+
{ operationId },
|
|
29
|
+
);
|
|
30
|
+
const saved = await client.operationEvidence.capture(ctx, {
|
|
31
|
+
sourceId: source._id,
|
|
32
|
+
});
|
|
33
|
+
expect(saved).toMatchObject({
|
|
34
|
+
coverage: "unknown",
|
|
35
|
+
status: "captured",
|
|
36
|
+
evidenceGeneration: 1,
|
|
37
|
+
});
|
|
38
|
+
expect(
|
|
39
|
+
(
|
|
40
|
+
await client.operationEvidence.original(ctx, {
|
|
41
|
+
headerId: saved.header!._id,
|
|
42
|
+
})
|
|
43
|
+
).payload?.operationId,
|
|
44
|
+
).toBe(operationId);
|
|
45
|
+
expect(
|
|
46
|
+
(
|
|
47
|
+
await client.operationEvidence.latest(ctx, {
|
|
48
|
+
headerId: saved.header!._id,
|
|
49
|
+
})
|
|
50
|
+
).payload?.slices,
|
|
51
|
+
).toEqual([]);
|
|
52
|
+
expect(
|
|
53
|
+
(
|
|
54
|
+
await client.operationEvidence.resolve(ctx, {
|
|
55
|
+
selector: "operationId",
|
|
56
|
+
value: operationId,
|
|
57
|
+
})
|
|
58
|
+
).header?._id,
|
|
59
|
+
).toBe(saved.header!._id);
|
|
60
|
+
expect(
|
|
61
|
+
(
|
|
62
|
+
await client.operationEvidence.headers(ctx, {
|
|
63
|
+
paginationOpts: { numItems: 1, cursor: null, id: 9 },
|
|
64
|
+
})
|
|
65
|
+
).page,
|
|
66
|
+
).toHaveLength(1);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("rejects invented source bytes and page expansion before dispatch while retaining admitted selectors", async () => {
|
|
70
|
+
const client = new BetterStripe(components.betterStripe);
|
|
71
|
+
const ctx = {
|
|
72
|
+
runQuery: vi.fn().mockResolvedValue({
|
|
73
|
+
coverage: "unknown",
|
|
74
|
+
evidenceGeneration: 0,
|
|
75
|
+
header: null,
|
|
76
|
+
}),
|
|
77
|
+
runMutation: vi.fn(),
|
|
78
|
+
};
|
|
79
|
+
await expect(
|
|
80
|
+
client.operationEvidence.capture(ctx, {
|
|
81
|
+
sourceId: "source",
|
|
82
|
+
payload: { operationId: "invented" },
|
|
83
|
+
} as never),
|
|
84
|
+
).rejects.toThrow();
|
|
85
|
+
await expect(
|
|
86
|
+
client.operationEvidence.capture(ctx, { sourceId: "" }),
|
|
87
|
+
).rejects.toThrow();
|
|
88
|
+
await expect(
|
|
89
|
+
client.operationEvidence.original(ctx, {
|
|
90
|
+
headerId: "",
|
|
91
|
+
payloadIds: ["one", "two"],
|
|
92
|
+
} as never),
|
|
93
|
+
).rejects.toThrow();
|
|
94
|
+
await expect(
|
|
95
|
+
client.operationEvidence.headers(ctx, {
|
|
96
|
+
paginationOpts: { numItems: 101, cursor: null },
|
|
97
|
+
}),
|
|
98
|
+
).rejects.toThrow();
|
|
99
|
+
expect(ctx.runMutation).not.toHaveBeenCalled();
|
|
100
|
+
expect(ctx.runQuery).not.toHaveBeenCalled();
|
|
101
|
+
await client.operationEvidence.resolve(ctx, {
|
|
102
|
+
selector: "operationId",
|
|
103
|
+
value: "",
|
|
104
|
+
});
|
|
105
|
+
await client.operationEvidence.resolve(ctx, {
|
|
106
|
+
selector: "operationId",
|
|
107
|
+
value: "\u0000".repeat(5000),
|
|
108
|
+
});
|
|
109
|
+
expect(ctx.runQuery).toHaveBeenCalledTimes(2);
|
|
110
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Infer } from "convex/values";
|
|
2
|
+
import type { PaginationOptions, PaginationResult } from "convex/server";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import type {
|
|
5
|
+
captureResult,
|
|
6
|
+
headerDoc,
|
|
7
|
+
headerResult,
|
|
8
|
+
payloadDoc,
|
|
9
|
+
payloadResult,
|
|
10
|
+
} from "../component/operationEvidence/schema.js";
|
|
11
|
+
import { runMutationOrThrow, type Component, type RunCtx } from "./helpers.js";
|
|
12
|
+
import { observationPagination } from "./observationPagination.js";
|
|
13
|
+
import { componentRef } from "./webhooks/helpers.js";
|
|
14
|
+
|
|
15
|
+
export type OperationEvidenceHeader = Infer<typeof headerDoc>;
|
|
16
|
+
export type OperationEvidencePayload = Infer<typeof payloadDoc>;
|
|
17
|
+
export type OperationEvidenceHeaderResult = Infer<typeof headerResult>;
|
|
18
|
+
export type OperationEvidencePayloadResult = Infer<typeof payloadResult>;
|
|
19
|
+
export type OperationEvidenceCaptureResult = Infer<typeof captureResult>;
|
|
20
|
+
export type OperationEvidencePage =
|
|
21
|
+
PaginationResult<OperationEvidenceHeader> & {
|
|
22
|
+
coverage: "unknown";
|
|
23
|
+
evidenceGeneration: number | null;
|
|
24
|
+
};
|
|
25
|
+
const headerInput = z.object({ headerId: z.string().min(1).max(256) }).strict();
|
|
26
|
+
|
|
27
|
+
/** Trusted-host evidence maintenance/readers. No financial or provider operation. */
|
|
28
|
+
export class OperationEvidenceClient {
|
|
29
|
+
constructor(private component: Component) {}
|
|
30
|
+
async capture(
|
|
31
|
+
ctx: RunCtx,
|
|
32
|
+
input: { sourceId: string },
|
|
33
|
+
): Promise<OperationEvidenceCaptureResult> {
|
|
34
|
+
const args = z
|
|
35
|
+
.object({ sourceId: z.string().min(1).max(256) })
|
|
36
|
+
.strict()
|
|
37
|
+
.parse(input);
|
|
38
|
+
return runMutationOrThrow(
|
|
39
|
+
ctx,
|
|
40
|
+
componentRef(this.component, "operationEvidence/mutations/capture"),
|
|
41
|
+
args,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
async headers(
|
|
45
|
+
ctx: RunCtx,
|
|
46
|
+
input: { paginationOpts: PaginationOptions & { id?: number } },
|
|
47
|
+
): Promise<OperationEvidencePage> {
|
|
48
|
+
const args = z
|
|
49
|
+
.object({ paginationOpts: observationPagination })
|
|
50
|
+
.strict()
|
|
51
|
+
.parse(input);
|
|
52
|
+
return ctx.runQuery(
|
|
53
|
+
componentRef(this.component, "operationEvidence/queries/headers"),
|
|
54
|
+
args,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
async original(
|
|
58
|
+
ctx: RunCtx,
|
|
59
|
+
input: { headerId: string },
|
|
60
|
+
): Promise<OperationEvidencePayloadResult> {
|
|
61
|
+
return ctx.runQuery(
|
|
62
|
+
componentRef(this.component, "operationEvidence/queries/original"),
|
|
63
|
+
headerInput.parse(input),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
async latest(
|
|
67
|
+
ctx: RunCtx,
|
|
68
|
+
input: { headerId: string },
|
|
69
|
+
): Promise<OperationEvidencePayloadResult> {
|
|
70
|
+
return ctx.runQuery(
|
|
71
|
+
componentRef(this.component, "operationEvidence/queries/latest"),
|
|
72
|
+
headerInput.parse(input),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
async resolve(
|
|
76
|
+
ctx: RunCtx,
|
|
77
|
+
input: { selector: "operationId" | "sourceChargeId"; value: string },
|
|
78
|
+
): Promise<OperationEvidenceHeaderResult> {
|
|
79
|
+
// Financial selectors are schema-admitted strings, not bounded account/user IDs.
|
|
80
|
+
const args = z
|
|
81
|
+
.object({
|
|
82
|
+
selector: z.enum(["operationId", "sourceChargeId"]),
|
|
83
|
+
value: z.string(),
|
|
84
|
+
})
|
|
85
|
+
.strict()
|
|
86
|
+
.parse(input);
|
|
87
|
+
return ctx.runQuery(
|
|
88
|
+
componentRef(this.component, "operationEvidence/queries/resolve"),
|
|
89
|
+
args,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -33,3 +33,48 @@ export type {
|
|
|
33
33
|
WebhookActionCtx,
|
|
34
34
|
} from "./types.js";
|
|
35
35
|
export type { PersonalAccountMapping } from "./core/personalAccountMapping.js";
|
|
36
|
+
|
|
37
|
+
export type {
|
|
38
|
+
FinancialOwnershipOwner,
|
|
39
|
+
FinancialOwnershipRegistration,
|
|
40
|
+
FinancialOwnershipResult,
|
|
41
|
+
FinancialOwnershipPage,
|
|
42
|
+
RegisterFinancialOwnershipOptions,
|
|
43
|
+
} from "./financialOwnership.js";
|
|
44
|
+
|
|
45
|
+
export type {
|
|
46
|
+
FinancialSourceObservation,
|
|
47
|
+
FinancialSourceLeg,
|
|
48
|
+
FinancialSourceResult,
|
|
49
|
+
FinancialObservationPage,
|
|
50
|
+
FinancialObservationOwner,
|
|
51
|
+
} from "./financialObservations.js";
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
RefundCommandEvidence,
|
|
55
|
+
RefundCommandEvidenceOptions,
|
|
56
|
+
} from "./connect/refundCommandEvidence.js";
|
|
57
|
+
export type {
|
|
58
|
+
FinancialTransferObservation,
|
|
59
|
+
FinancialTransferBatch,
|
|
60
|
+
FinancialTransferReadState,
|
|
61
|
+
FinancialTransferResult,
|
|
62
|
+
FinancialTransferPage,
|
|
63
|
+
FinancialTransferBatchPage,
|
|
64
|
+
FinancialTransferReference,
|
|
65
|
+
FinancialTransferBatchResult,
|
|
66
|
+
FinancialTransferReferencePage,
|
|
67
|
+
} from "./transferObservations.js";
|
|
68
|
+
|
|
69
|
+
export type {
|
|
70
|
+
RefundCommandNormalizationOptions,
|
|
71
|
+
RefundCommandNormalizationResult,
|
|
72
|
+
} from "./connect/refundCommandNormalization.js";
|
|
73
|
+
export type {
|
|
74
|
+
OperationEvidenceHeader,
|
|
75
|
+
OperationEvidencePayload,
|
|
76
|
+
OperationEvidenceHeaderResult,
|
|
77
|
+
OperationEvidencePayloadResult,
|
|
78
|
+
OperationEvidenceCaptureResult,
|
|
79
|
+
OperationEvidencePage,
|
|
80
|
+
} from "./operationEvidence.js";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { OperationEvidenceClient } from "./operationEvidence.js";
|
|
2
|
+
import {
|
|
3
|
+
normalizeRefundCommandBindings,
|
|
4
|
+
type RefundCommandNormalizationOptions,
|
|
5
|
+
} from "./connect/refundCommandNormalization.js";
|
|
6
|
+
import {
|
|
7
|
+
getRefundCommandEvidence,
|
|
8
|
+
type RefundCommandEvidenceOptions,
|
|
9
|
+
} from "./connect/refundCommandEvidence.js";
|
|
1
10
|
import * as checkoutImpl from "./billing/checkout.js";
|
|
2
11
|
import * as subscriptionsImpl from "./billing/subscriptions.js";
|
|
3
12
|
import * as payoutsImpl from "./connect/payouts.js";
|
|
@@ -15,6 +24,22 @@ import { componentRef } from "./webhooks/helpers.js";
|
|
|
15
24
|
/** Shared component readers inherited by BetterStripe. */
|
|
16
25
|
export class ReadContractClient {
|
|
17
26
|
constructor(public component: Component) {}
|
|
27
|
+
get operationEvidence() {
|
|
28
|
+
return new OperationEvidenceClient(this.component);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Trusted-host projection maintenance; never a financial or provider operation. */
|
|
32
|
+
normalizeRefundCommandBindings(
|
|
33
|
+
ctx: RunCtx,
|
|
34
|
+
opts: RefundCommandNormalizationOptions,
|
|
35
|
+
) {
|
|
36
|
+
return normalizeRefundCommandBindings(this.component, ctx, opts);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Exact component observation only; callers authorize and bind original commands. */
|
|
40
|
+
getRefundCommandEvidence(ctx: RunCtx, opts: RefundCommandEvidenceOptions) {
|
|
41
|
+
return getRefundCommandEvidence(this.component, ctx, opts);
|
|
42
|
+
}
|
|
18
43
|
async paginateProducts(
|
|
19
44
|
ctx: RunCtx,
|
|
20
45
|
opts: {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import { expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import schema from "../component/schema.js";
|
|
5
|
+
import { BetterStripe, type RefundCommandEvidenceOptions } from "./index.js";
|
|
6
|
+
import type { RunCtx } from "./helpers.js";
|
|
7
|
+
import { components, initConvexTest } from "./setup.test.js";
|
|
8
|
+
|
|
9
|
+
const modules = import.meta.glob("../component/**/*.ts");
|
|
10
|
+
const opts: RefundCommandEvidenceOptions = {
|
|
11
|
+
commandKey: "dojo-refund:original_command:v1",
|
|
12
|
+
stripeAccountId: "acct_original",
|
|
13
|
+
stripePaymentIntentId: "pi_original",
|
|
14
|
+
stripeChargeId: "ch_original",
|
|
15
|
+
currency: "jpy",
|
|
16
|
+
};
|
|
17
|
+
function fixture() {
|
|
18
|
+
const t = initConvexTest();
|
|
19
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
20
|
+
const ctx = { runQuery: t.query, runMutation: t.mutation } as RunCtx;
|
|
21
|
+
const client = new BetterStripe(components.betterStripe, {});
|
|
22
|
+
return { t, ctx, client };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
it("exposes actual component correlation through public BetterStripe without Stripe credentials", async () => {
|
|
26
|
+
const f = fixture();
|
|
27
|
+
await f.t.mutation(components.betterStripe.connect.mutations.upsertRefund, {
|
|
28
|
+
stripeRefundId: "re_original",
|
|
29
|
+
accountId: opts.stripeAccountId,
|
|
30
|
+
stripePaymentIntentId: opts.stripePaymentIntentId,
|
|
31
|
+
stripeChargeId: opts.stripeChargeId,
|
|
32
|
+
amount: 500,
|
|
33
|
+
currency: "jpy",
|
|
34
|
+
status: "succeeded",
|
|
35
|
+
metadata: { betterStripeRefundCommand: opts.commandKey },
|
|
36
|
+
});
|
|
37
|
+
expect(await f.client.getRefundCommandEvidence(f.ctx, opts)).toMatchObject({
|
|
38
|
+
status: "observed",
|
|
39
|
+
refund: { stripeRefundId: "re_original", amount: 500, currency: "jpy" },
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it.each([
|
|
44
|
+
undefined,
|
|
45
|
+
null,
|
|
46
|
+
{},
|
|
47
|
+
{ ...opts, commandKey: "" },
|
|
48
|
+
{ ...opts, commandKey: " x".repeat(100) },
|
|
49
|
+
{ ...opts, commandKey: "x".repeat(201) },
|
|
50
|
+
{ ...opts, commandKey: 123 },
|
|
51
|
+
{ ...opts, stripeAccountId: "cus_wrong" },
|
|
52
|
+
{ ...opts, stripePaymentIntentId: "pi_" },
|
|
53
|
+
{ ...opts, stripeChargeId: "ch_wrong space" },
|
|
54
|
+
{ ...opts, currency: "USD" },
|
|
55
|
+
{ ...opts, actor: { type: "admin" } },
|
|
56
|
+
])(
|
|
57
|
+
"rejects malformed public selectors %# before component reads",
|
|
58
|
+
async (options) => {
|
|
59
|
+
const f = fixture();
|
|
60
|
+
const runQuery = vi.fn();
|
|
61
|
+
const read = f.client.getRefundCommandEvidence.bind(f.client) as (
|
|
62
|
+
ctx: RunCtx,
|
|
63
|
+
opts: unknown,
|
|
64
|
+
) => Promise<unknown>;
|
|
65
|
+
await expect(read({ runQuery } as RunCtx, options)).rejects.toThrow();
|
|
66
|
+
expect(runQuery).not.toHaveBeenCalled();
|
|
67
|
+
},
|
|
68
|
+
);
|