@fantastic.dev/better-stripe 0.63.0 → 0.64.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 +11 -0
- package/README.md +19 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +550 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +275 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +582 -32
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +291 -16
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/financialOwnership.d.ts +2 -2
- package/dist/client/financialOwnership.d.ts.map +1 -1
- package/dist/client/financialOwnership.js +2 -2
- package/dist/client/financialOwnership.js.map +1 -1
- package/dist/client/payoutRevisionMigration.d.ts +37 -0
- package/dist/client/payoutRevisionMigration.d.ts.map +1 -0
- package/dist/client/payoutRevisionMigration.js +49 -0
- package/dist/client/payoutRevisionMigration.js.map +1 -0
- package/dist/client/publicTypes.d.ts +2 -0
- package/dist/client/publicTypes.d.ts.map +1 -1
- package/dist/client/reversalObservations.d.ts +62 -0
- package/dist/client/reversalObservations.d.ts.map +1 -0
- package/dist/client/reversalObservations.js +79 -0
- package/dist/client/reversalObservations.js.map +1 -0
- package/dist/component/_generated/api.d.ts +28 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +354 -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/stateHandlers.d.ts +8 -8
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +2 -0
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts.map +1 -1
- package/dist/component/connect/reversalClaims.js +10 -1
- package/dist/component/connect/reversalClaims.js.map +1 -1
- package/dist/component/earnings/triggers.d.ts +408 -16
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/financialObservations/transferSchema.d.ts +1 -0
- package/dist/component/financialObservations/transferSchema.d.ts.map +1 -1
- package/dist/component/financialObservations/transferSchema.js +1 -0
- package/dist/component/financialObservations/transferSchema.js.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/payoutRevisionJournal/mutations.d.ts +15 -0
- package/dist/component/payoutRevisionJournal/mutations.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/mutations.js +11 -0
- package/dist/component/payoutRevisionJournal/mutations.js.map +1 -0
- package/dist/component/payoutRevisionJournal/schema.d.ts +45 -0
- package/dist/component/payoutRevisionJournal/schema.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/schema.js +22 -0
- package/dist/component/payoutRevisionJournal/schema.js.map +1 -0
- package/dist/component/payoutRevisionJournal/state.d.ts +36 -0
- package/dist/component/payoutRevisionJournal/state.d.ts.map +1 -0
- package/dist/component/payoutRevisionJournal/state.js +111 -0
- package/dist/component/payoutRevisionJournal/state.js.map +1 -0
- package/dist/component/payoutRevisionMigration/mutations.d.ts +36 -0
- package/dist/component/payoutRevisionMigration/mutations.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/mutations.js +126 -0
- package/dist/component/payoutRevisionMigration/mutations.js.map +1 -0
- package/dist/component/payoutRevisionMigration/queries.d.ts +38 -0
- package/dist/component/payoutRevisionMigration/queries.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/queries.js +39 -0
- package/dist/component/payoutRevisionMigration/queries.js.map +1 -0
- package/dist/component/payoutRevisionMigration/schema.d.ts +115 -0
- package/dist/component/payoutRevisionMigration/schema.d.ts.map +1 -0
- package/dist/component/payoutRevisionMigration/schema.js +52 -0
- package/dist/component/payoutRevisionMigration/schema.js.map +1 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts +4 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.js +33 -0
- package/dist/component/payoutSnapshots/legacyRevisionWriter.js.map +1 -0
- package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -1
- package/dist/component/payoutSnapshots/revisions.js +23 -29
- package/dist/component/payoutSnapshots/revisions.js.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/refundSync/mutations.d.ts +1 -1
- package/dist/component/refundSync/mutations.d.ts.map +1 -1
- package/dist/component/reversalObservations/capture.d.ts +6 -0
- package/dist/component/reversalObservations/capture.d.ts.map +1 -0
- package/dist/component/reversalObservations/capture.js +96 -0
- package/dist/component/reversalObservations/capture.js.map +1 -0
- package/dist/component/reversalObservations/indexSlice.d.ts +29 -0
- package/dist/component/reversalObservations/indexSlice.d.ts.map +1 -0
- package/dist/component/reversalObservations/indexSlice.js +101 -0
- package/dist/component/reversalObservations/indexSlice.js.map +1 -0
- package/dist/component/reversalObservations/integrity.d.ts +25 -0
- package/dist/component/reversalObservations/integrity.d.ts.map +1 -0
- package/dist/component/reversalObservations/integrity.js +19 -0
- package/dist/component/reversalObservations/integrity.js.map +1 -0
- package/dist/component/reversalObservations/mutations.d.ts +37 -0
- package/dist/component/reversalObservations/mutations.d.ts.map +1 -0
- package/dist/component/reversalObservations/mutations.js +181 -0
- package/dist/component/reversalObservations/mutations.js.map +1 -0
- package/dist/component/reversalObservations/pagination.d.ts +34 -0
- package/dist/component/reversalObservations/pagination.d.ts.map +1 -0
- package/dist/component/reversalObservations/pagination.js +31 -0
- package/dist/component/reversalObservations/pagination.js.map +1 -0
- package/dist/component/reversalObservations/queries.d.ts +221 -0
- package/dist/component/reversalObservations/queries.d.ts.map +1 -0
- package/dist/component/reversalObservations/queries.js +114 -0
- package/dist/component/reversalObservations/queries.js.map +1 -0
- package/dist/component/reversalObservations/references.d.ts +17 -0
- package/dist/component/reversalObservations/references.d.ts.map +1 -0
- package/dist/component/reversalObservations/references.js +95 -0
- package/dist/component/reversalObservations/references.js.map +1 -0
- package/dist/component/reversalObservations/schema.d.ts +525 -0
- package/dist/component/reversalObservations/schema.d.ts.map +1 -0
- package/dist/component/reversalObservations/schema.js +92 -0
- package/dist/component/reversalObservations/schema.js.map +1 -0
- package/dist/component/reversalObservations/selectors.d.ts +3 -0
- package/dist/component/reversalObservations/selectors.d.ts.map +1 -0
- package/dist/component/reversalObservations/selectors.js +8 -0
- package/dist/component/reversalObservations/selectors.js.map +1 -0
- package/dist/component/reversalObservations/state.d.ts +34 -0
- package/dist/component/reversalObservations/state.d.ts.map +1 -0
- package/dist/component/reversalObservations/state.js +34 -0
- package/dist/component/reversalObservations/state.js.map +1 -0
- package/dist/component/schema.d.ts +275 -0
- package/dist/component/schema.js +10 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +291 -16
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +275 -0
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/docs/README.md +2 -1
- package/docs/client-api.md +6 -0
- package/docs/financial-observations.md +51 -8
- package/docs/payout-revision-migration.md +54 -0
- package/docs/react-workflows-audit.md +73 -2
- package/docs/usage-example.md +4 -0
- package/package.json +3 -2
- package/src/client/financialOwnership.ts +2 -2
- package/src/client/payoutRevisionMigration.test.ts +40 -0
- package/src/client/payoutRevisionMigration.ts +96 -0
- package/src/client/publicTypes.ts +15 -0
- package/src/client/reversalObservations.test.ts +69 -0
- package/src/client/reversalObservations.ts +151 -0
- package/src/component/_generated/api.ts +28 -0
- package/src/component/_generated/component.ts +423 -0
- package/src/component/connect/mutations.ts +2 -0
- package/src/component/connect/reversalClaims.ts +13 -1
- package/src/component/financialObservations/transferSchema.ts +1 -0
- package/src/component/payoutRevisionJournal/mutations.ts +11 -0
- package/src/component/payoutRevisionJournal/schema.ts +34 -0
- package/src/component/payoutRevisionJournal/state.ts +141 -0
- package/src/component/payoutRevisionMigration/mutations.ts +135 -0
- package/src/component/payoutRevisionMigration/queries.ts +50 -0
- package/src/component/payoutRevisionMigration/schema.ts +51 -0
- package/src/component/payoutSnapshots/legacy-revisions.test.ts +246 -0
- package/src/component/payoutSnapshots/legacyRevisionWriter.ts +39 -0
- package/src/component/payoutSnapshots/revision-journal-callbacks.test.ts +160 -0
- package/src/component/payoutSnapshots/revision-journal-held.test.ts +94 -0
- package/src/component/payoutSnapshots/revision-journal.test.ts +310 -0
- package/src/component/payoutSnapshots/revision-migration.test.ts +128 -0
- package/src/component/payoutSnapshots/revisions.ts +22 -30
- package/src/component/reversalObservations/boundaries.test.ts +62 -0
- package/src/component/reversalObservations/capture-integrity.test.ts +119 -0
- package/src/component/reversalObservations/capture.ts +129 -0
- package/src/component/reversalObservations/continuation.test.ts +131 -0
- package/src/component/reversalObservations/indexSlice.ts +124 -0
- package/src/component/reversalObservations/integrity.ts +31 -0
- package/src/component/reversalObservations/lifecycle.test.ts +81 -0
- package/src/component/reversalObservations/mutations.ts +211 -0
- package/src/component/reversalObservations/pagination.ts +40 -0
- package/src/component/reversalObservations/provenance.test.ts +167 -0
- package/src/component/reversalObservations/queries.ts +121 -0
- package/src/component/reversalObservations/references.ts +134 -0
- package/src/component/reversalObservations/schema.ts +100 -0
- package/src/component/reversalObservations/selectors.ts +9 -0
- package/src/component/reversalObservations/state.ts +42 -0
- package/src/component/schema.ts +18 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { transferReversalOpFields } from "../connect/validators.js";
|
|
4
|
+
import { legFields } from "../financialObservations/schema.js";
|
|
5
|
+
export const payloadsTable = defineTable(transferReversalOpFields);
|
|
6
|
+
export const payloadDoc = v.object({
|
|
7
|
+
...transferReversalOpFields,
|
|
8
|
+
_id: v.id("reversalObservationPayloads"),
|
|
9
|
+
_creationTime: v.number(),
|
|
10
|
+
});
|
|
11
|
+
export const ref = v.object({
|
|
12
|
+
transferId: v.id("transfers"),
|
|
13
|
+
bucketDigest: v.string(),
|
|
14
|
+
ownerDigest: v.optional(v.string()),
|
|
15
|
+
identityFingerprint: v.string(),
|
|
16
|
+
ambiguous: v.boolean(),
|
|
17
|
+
markerId: v.optional(v.id("financialTransferObservations")),
|
|
18
|
+
markerGeneration: v.optional(v.number()),
|
|
19
|
+
markerIdentityFingerprint: v.optional(v.string()),
|
|
20
|
+
ownershipFingerprint: v.optional(v.string()),
|
|
21
|
+
registrationId: v.optional(v.id("financialOwnership")),
|
|
22
|
+
});
|
|
23
|
+
export const headerFields = {
|
|
24
|
+
originalOperationId: v.id("transferReversalOps"),
|
|
25
|
+
sourceCreatedAt: v.number(),
|
|
26
|
+
producer: v.literal("reversal_claim_lifecycle"),
|
|
27
|
+
producerVersion: v.literal(1),
|
|
28
|
+
originalPayloadId: v.id("reversalObservationPayloads"),
|
|
29
|
+
latestPayloadId: v.id("reversalObservationPayloads"),
|
|
30
|
+
referenceFingerprints: v.array(v.string()),
|
|
31
|
+
originalFingerprint: v.string(),
|
|
32
|
+
latestIdentityFingerprint: v.string(),
|
|
33
|
+
originalIdentityFingerprint: v.string(),
|
|
34
|
+
fingerprint: v.string(),
|
|
35
|
+
operationDigest: v.string(),
|
|
36
|
+
sourceChargeDigest: v.string(),
|
|
37
|
+
generation: v.number(),
|
|
38
|
+
deleted: v.boolean(),
|
|
39
|
+
sliceCount: v.number(),
|
|
40
|
+
indexedCount: v.number(),
|
|
41
|
+
nextIndex: v.number(),
|
|
42
|
+
status: v.union(
|
|
43
|
+
v.literal("pending"),
|
|
44
|
+
v.literal("validating"),
|
|
45
|
+
v.literal("complete"),
|
|
46
|
+
v.literal("held"),
|
|
47
|
+
),
|
|
48
|
+
legacy: v.boolean(),
|
|
49
|
+
isContradictory: v.boolean(),
|
|
50
|
+
indexTransferGeneration: v.union(v.number(), v.null()),
|
|
51
|
+
};
|
|
52
|
+
export const headerDoc = v.object({
|
|
53
|
+
...headerFields,
|
|
54
|
+
_id: v.id("reversalObservations"),
|
|
55
|
+
_creationTime: v.number(),
|
|
56
|
+
});
|
|
57
|
+
export const observationsTable = defineTable(headerFields)
|
|
58
|
+
.index("by_original_operation", ["originalOperationId"])
|
|
59
|
+
.index("by_operation_digest", ["operationDigest"])
|
|
60
|
+
.index("by_source_charge_digest", ["sourceChargeDigest"]);
|
|
61
|
+
export const refsTable = defineTable({
|
|
62
|
+
observationId: v.id("reversalObservations"),
|
|
63
|
+
chunkIndex: v.number(),
|
|
64
|
+
refs: v.array(v.union(ref, v.null())),
|
|
65
|
+
}).index("by_observation_chunk", ["observationId", "chunkIndex"]);
|
|
66
|
+
export const sliceFields = {
|
|
67
|
+
originalOperationId: v.id("transferReversalOps"),
|
|
68
|
+
observationId: v.id("reversalObservations"),
|
|
69
|
+
sliceIndex: v.number(),
|
|
70
|
+
generation: v.number(),
|
|
71
|
+
bucketDigest: v.optional(v.string()),
|
|
72
|
+
ownerDigest: v.optional(v.string()),
|
|
73
|
+
transferId: v.optional(v.id("transfers")),
|
|
74
|
+
bucketKey: v.optional(v.string()),
|
|
75
|
+
registrationId: legFields.registrationId,
|
|
76
|
+
userId: legFields.userId,
|
|
77
|
+
orgId: legFields.orgId,
|
|
78
|
+
ownershipStatus: legFields.ownershipStatus,
|
|
79
|
+
identityStatus: v.union(
|
|
80
|
+
v.literal("matched"),
|
|
81
|
+
v.literal("unknown"),
|
|
82
|
+
v.literal("contradictory"),
|
|
83
|
+
),
|
|
84
|
+
transferGeneration: v.union(v.number(), v.null()),
|
|
85
|
+
};
|
|
86
|
+
export const sliceDoc = v.object({
|
|
87
|
+
...sliceFields,
|
|
88
|
+
_id: v.id("reversalObservationSlices"),
|
|
89
|
+
_creationTime: v.number(),
|
|
90
|
+
});
|
|
91
|
+
export const slicesTable = defineTable(sliceFields)
|
|
92
|
+
.index("by_observation_slice", ["observationId", "sliceIndex"])
|
|
93
|
+
.index("by_bucket", ["bucketDigest"])
|
|
94
|
+
.index("by_owner", ["ownerDigest"]);
|
|
95
|
+
export const operationResult = v.object({
|
|
96
|
+
coverage: v.literal("unknown"),
|
|
97
|
+
generation: v.union(v.number(), v.null()),
|
|
98
|
+
transferGeneration: v.union(v.number(), v.null()),
|
|
99
|
+
observation: v.union(headerDoc, v.null()),
|
|
100
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { canonicalFingerprint } from "../operationEvidence/canonical.js";
|
|
2
|
+
export const bucketDigest = (bucketKey: string) =>
|
|
3
|
+
canonicalFingerprint({ domain: "reversal-bucket-v1", bucketKey });
|
|
4
|
+
export const ownerDigest = (userId: string, orgId?: string) =>
|
|
5
|
+
canonicalFingerprint({
|
|
6
|
+
domain: "reversal-owner-v1",
|
|
7
|
+
userId,
|
|
8
|
+
...(orgId === undefined ? {} : { orgId }),
|
|
9
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Id } from "../_generated/dataModel.js";
|
|
2
|
+
import type { QueryCtx } from "../_generated/server.js";
|
|
3
|
+
import { observationGeneration } from "../financialObservations/generations.js";
|
|
4
|
+
import { transferProducerScope } from "../financialObservations/transferHelpers.js";
|
|
5
|
+
import { lifecycleScope } from "./capture.js";
|
|
6
|
+
export async function header(
|
|
7
|
+
ctx: QueryCtx,
|
|
8
|
+
operationId: Id<"transferReversalOps">,
|
|
9
|
+
) {
|
|
10
|
+
const rows = await ctx.db
|
|
11
|
+
.query("reversalObservations")
|
|
12
|
+
.withIndex("by_original_operation", (q) =>
|
|
13
|
+
q.eq("originalOperationId", operationId),
|
|
14
|
+
)
|
|
15
|
+
.take(2);
|
|
16
|
+
const row = rows[0];
|
|
17
|
+
return rows.length === 1 &&
|
|
18
|
+
[row.generation, row.sliceCount, row.indexedCount, row.nextIndex].every(
|
|
19
|
+
Number.isSafeInteger,
|
|
20
|
+
) &&
|
|
21
|
+
row.generation >= 1 &&
|
|
22
|
+
row.sliceCount >= 0 &&
|
|
23
|
+
row.indexedCount >= 0 &&
|
|
24
|
+
row.indexedCount <= row.sliceCount &&
|
|
25
|
+
row.nextIndex >= 0 &&
|
|
26
|
+
row.nextIndex <= row.sliceCount &&
|
|
27
|
+
row.referenceFingerprints.length ===
|
|
28
|
+
(row.legacy ? 0 : Math.ceil(row.sliceCount / 64)) &&
|
|
29
|
+
row.referenceFingerprints.every((value) => /^[a-f0-9]{64}$/.test(value)) &&
|
|
30
|
+
(!(row.status === "complete" || row.status === "validating") ||
|
|
31
|
+
row.indexedCount === row.sliceCount) &&
|
|
32
|
+
(row.status !== "complete" || row.nextIndex === 0)
|
|
33
|
+
? row
|
|
34
|
+
: null;
|
|
35
|
+
}
|
|
36
|
+
export async function readState(ctx: QueryCtx) {
|
|
37
|
+
return {
|
|
38
|
+
coverage: "unknown" as const,
|
|
39
|
+
generation: await observationGeneration(ctx, lifecycleScope),
|
|
40
|
+
transferGeneration: await observationGeneration(ctx, transferProducerScope),
|
|
41
|
+
};
|
|
42
|
+
}
|
package/src/component/schema.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
observationsTable as reversalObservations,
|
|
3
|
+
payloadsTable as reversalObservationPayloads,
|
|
4
|
+
refsTable as reversalObservationRefs,
|
|
5
|
+
slicesTable as reversalObservationSlices,
|
|
6
|
+
} from "./reversalObservations/schema.js";
|
|
7
|
+
import {
|
|
8
|
+
jobsTable as payoutRevisionMigrationsTable,
|
|
9
|
+
resultsTable as payoutRevisionMigrationResultsTable,
|
|
10
|
+
} from "./payoutRevisionMigration/schema.js";
|
|
11
|
+
import { journalTable as payoutRevisionJournal } from "./payoutRevisionJournal/schema.js";
|
|
1
12
|
import {
|
|
2
13
|
claimsTable as usageCorrectionClaims,
|
|
3
14
|
operationsTable as usageCorrections,
|
|
@@ -125,6 +136,13 @@ import { pricesTable, productsTable } from "./products/schema";
|
|
|
125
136
|
import { webhookEventsTable } from "./webhooks/schema";
|
|
126
137
|
|
|
127
138
|
export default defineSchema({
|
|
139
|
+
reversalObservations,
|
|
140
|
+
reversalObservationPayloads,
|
|
141
|
+
reversalObservationRefs,
|
|
142
|
+
reversalObservationSlices,
|
|
143
|
+
payoutRevisionJournal,
|
|
144
|
+
payoutRevisionMigrations: payoutRevisionMigrationsTable,
|
|
145
|
+
payoutRevisionMigrationResults: payoutRevisionMigrationResultsTable,
|
|
128
146
|
usageCorrectionClaims,
|
|
129
147
|
usageCorrections,
|
|
130
148
|
usageCorrectionHistory,
|