@fantastic.dev/better-stripe 0.23.1 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +42 -0
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutSync.d.ts +32 -0
  6. package/dist/client/connect/payoutSync.d.ts.map +1 -0
  7. package/dist/client/connect/payoutSync.js +48 -0
  8. package/dist/client/connect/payoutSync.js.map +1 -0
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +1263 -0
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -0
  11. package/dist/client/connect/payoutSyncTestHelpers.js +62 -0
  12. package/dist/client/connect/payoutSyncTestHelpers.js.map +1 -0
  13. package/dist/client/connect/payoutSyncValidation.d.ts +16 -0
  14. package/dist/client/connect/payoutSyncValidation.d.ts.map +1 -0
  15. package/dist/client/connect/payoutSyncValidation.js +54 -0
  16. package/dist/client/connect/payoutSyncValidation.js.map +1 -0
  17. package/dist/client/index.d.ts +26 -9
  18. package/dist/client/index.d.ts.map +1 -1
  19. package/dist/client/index.js +3 -5
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/readContracts.d.ts +8 -0
  22. package/dist/client/readContracts.d.ts.map +1 -1
  23. package/dist/client/readContracts.js +7 -0
  24. package/dist/client/readContracts.js.map +1 -1
  25. package/dist/component/_generated/component.d.ts +69 -0
  26. package/dist/component/_generated/component.d.ts.map +1 -1
  27. package/dist/component/connect/mutations.d.ts.map +1 -1
  28. package/dist/component/connect/mutations.js +4 -27
  29. package/dist/component/connect/mutations.js.map +1 -1
  30. package/dist/component/connect/payoutWrites.d.ts +21 -0
  31. package/dist/component/connect/payoutWrites.d.ts.map +1 -0
  32. package/dist/component/connect/payoutWrites.js +19 -0
  33. package/dist/component/connect/payoutWrites.js.map +1 -0
  34. package/dist/component/earnings/triggers.d.ts +44 -0
  35. package/dist/component/earnings/triggers.d.ts.map +1 -1
  36. package/dist/component/payoutSync/helpers.d.ts +44 -0
  37. package/dist/component/payoutSync/helpers.d.ts.map +1 -0
  38. package/dist/component/payoutSync/helpers.js +60 -0
  39. package/dist/component/payoutSync/helpers.js.map +1 -0
  40. package/dist/component/payoutSync/mutations.d.ts +51 -0
  41. package/dist/component/payoutSync/mutations.d.ts.map +1 -0
  42. package/dist/component/payoutSync/mutations.js +88 -0
  43. package/dist/component/payoutSync/mutations.js.map +1 -0
  44. package/dist/component/payoutSync/queries.d.ts +16 -0
  45. package/dist/component/payoutSync/queries.d.ts.map +1 -0
  46. package/dist/component/payoutSync/queries.js +11 -0
  47. package/dist/component/payoutSync/queries.js.map +1 -0
  48. package/dist/component/payoutSync/schema.d.ts +46 -0
  49. package/dist/component/payoutSync/schema.d.ts.map +1 -0
  50. package/dist/component/payoutSync/schema.js +22 -0
  51. package/dist/component/payoutSync/schema.js.map +1 -0
  52. package/dist/component/payoutSync/validators.d.ts +137 -0
  53. package/dist/component/payoutSync/validators.d.ts.map +1 -0
  54. package/dist/component/payoutSync/validators.js +19 -0
  55. package/dist/component/payoutSync/validators.js.map +1 -0
  56. package/dist/component/schema.d.ts +21 -0
  57. package/dist/component/schema.js +2 -0
  58. package/dist/component/schema.js.map +1 -1
  59. package/docs/read-contracts.md +40 -5
  60. package/package.json +1 -1
  61. package/src/client/connect/payoutSync.test.ts +313 -0
  62. package/src/client/connect/payoutSync.ts +93 -0
  63. package/src/client/connect/payoutSyncTestHelpers.ts +82 -0
  64. package/src/client/connect/payoutSyncValidation.ts +74 -0
  65. package/src/client/index.ts +14 -11
  66. package/src/client/readContracts.ts +12 -0
  67. package/src/component/_generated/api.ts +10 -0
  68. package/src/component/_generated/component.ts +82 -0
  69. package/src/component/connect/mutations.ts +4 -30
  70. package/src/component/connect/payoutWrites.ts +25 -0
  71. package/src/component/payout-sync.test.ts +117 -0
  72. package/src/component/payoutSync/helpers.ts +86 -0
  73. package/src/component/payoutSync/mutations.ts +102 -0
  74. package/src/component/payoutSync/queries.ts +10 -0
  75. package/src/component/payoutSync/schema.ts +25 -0
  76. package/src/component/payoutSync/validators.ts +21 -0
  77. package/src/component/schema.ts +2 -0
@@ -432,6 +432,28 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
432
432
  searchIndexes: {};
433
433
  vectorIndexes: {};
434
434
  };
435
+ payoutSyncClaims: {
436
+ document: {
437
+ _creationTime: number;
438
+ _id: import("convex/values").GenericId<"payoutSyncClaims">;
439
+ acceptedAt?: number | undefined;
440
+ acceptedFingerprint?: string | undefined;
441
+ acceptedGeneration?: number | undefined;
442
+ accountId: string;
443
+ generation: number;
444
+ startedAt: number;
445
+ status: "accepted" | "pending" | "unknown";
446
+ stripePayoutId: string;
447
+ };
448
+ fieldPaths: "_id" | ("_creationTime" | "acceptedAt" | "acceptedFingerprint" | "acceptedGeneration" | "accountId" | "generation" | "startedAt" | "status" | "stripePayoutId");
449
+ indexes: {
450
+ by_id: ["_id"];
451
+ by_creation_time: ["_creationTime"];
452
+ by_stripe_payout_id: ["stripePayoutId", "_creationTime"];
453
+ };
454
+ searchIndexes: {};
455
+ vectorIndexes: {};
456
+ };
435
457
  payouts: {
436
458
  document: {
437
459
  _creationTime: number;
@@ -1262,6 +1284,28 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
1262
1284
  searchIndexes: {};
1263
1285
  vectorIndexes: {};
1264
1286
  };
1287
+ payoutSyncClaims: {
1288
+ document: {
1289
+ _creationTime: number;
1290
+ _id: import("convex/values").GenericId<"payoutSyncClaims">;
1291
+ acceptedAt?: number | undefined;
1292
+ acceptedFingerprint?: string | undefined;
1293
+ acceptedGeneration?: number | undefined;
1294
+ accountId: string;
1295
+ generation: number;
1296
+ startedAt: number;
1297
+ status: "accepted" | "pending" | "unknown";
1298
+ stripePayoutId: string;
1299
+ };
1300
+ fieldPaths: "_id" | ("_creationTime" | "acceptedAt" | "acceptedFingerprint" | "acceptedGeneration" | "accountId" | "generation" | "startedAt" | "status" | "stripePayoutId");
1301
+ indexes: {
1302
+ by_id: ["_id"];
1303
+ by_creation_time: ["_creationTime"];
1304
+ by_stripe_payout_id: ["stripePayoutId", "_creationTime"];
1305
+ };
1306
+ searchIndexes: {};
1307
+ vectorIndexes: {};
1308
+ };
1265
1309
  payouts: {
1266
1310
  document: {
1267
1311
  _creationTime: number;
@@ -1 +1 @@
1
- {"version":3,"file":"triggers.d.ts","sourceRoot":"","sources":["../../../src/component/earnings/triggers.ts"],"names":[],"mappings":"AA+FA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAA0D,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { Infer } from "convex/values";
2
+ import type { MutationCtx, QueryCtx } from "../_generated/server.js";
3
+ import type { Doc } from "../_generated/dataModel.js";
4
+ import type { snapshot } from "./validators.js";
5
+ export declare function validateIdentity(args: {
6
+ stripePayoutId: string;
7
+ accountId: string;
8
+ }): void;
9
+ export declare function claimByPayout(ctx: QueryCtx | MutationCtx, args: {
10
+ stripePayoutId: string;
11
+ accountId: string;
12
+ }): Promise<{
13
+ _creationTime: number;
14
+ _id: import("convex/values").GenericId<"payoutSyncClaims">;
15
+ acceptedAt?: number | undefined;
16
+ acceptedFingerprint?: string | undefined;
17
+ acceptedGeneration?: number | undefined;
18
+ accountId: string;
19
+ generation: number;
20
+ startedAt: number;
21
+ status: "accepted" | "pending" | "unknown";
22
+ stripePayoutId: string;
23
+ } | null>;
24
+ export declare function payoutById(ctx: QueryCtx | MutationCtx, args: {
25
+ stripePayoutId: string;
26
+ accountId: string;
27
+ }): Promise<{
28
+ _creationTime: number;
29
+ _id: import("convex/values").GenericId<"payouts">;
30
+ accountId: string;
31
+ amount: number;
32
+ arrivalDate?: string | undefined;
33
+ currency: string;
34
+ failureCode?: string | undefined;
35
+ failureMessage?: string | undefined;
36
+ metadata?: any;
37
+ method?: string | undefined;
38
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
39
+ stripePayoutId: string;
40
+ totalsRecorded?: true | undefined;
41
+ } | null>;
42
+ export declare function validateSnapshot(p: Infer<typeof snapshot>): void;
43
+ export declare function fingerprint(p: Infer<typeof snapshot> | Doc<"payouts">): Promise<string>;
44
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/payoutSync/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,QASA;AACD,wBAAsB,aAAa,CACjC,GAAG,EAAE,QAAQ,GAAG,WAAW,EAC3B,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;UAYpD;AACD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,QAAQ,GAAG,WAAW,EAC3B,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;UAWpD;AACD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,QAAQ,CAAC,QAoBzD;AACD,wBAAsB,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,QAAQ,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,mBAiB3E"}
@@ -0,0 +1,60 @@
1
+ import { generateIdempotencyKey } from "../lib/idempotency.js";
2
+ export function validateIdentity(args) {
3
+ if (!/^po_[A-Za-z0-9_]+$/.test(args.stripePayoutId) ||
4
+ args.stripePayoutId.length > 255 ||
5
+ (args.accountId !== "platform" &&
6
+ !/^acct_[A-Za-z0-9_]+$/.test(args.accountId)) ||
7
+ args.accountId.length > 255)
8
+ throw new Error("Invalid payout synchronization identity.");
9
+ }
10
+ export async function claimByPayout(ctx, args) {
11
+ validateIdentity(args);
12
+ const claim = await ctx.db
13
+ .query("payoutSyncClaims")
14
+ .withIndex("by_stripe_payout_id", (q) => q.eq("stripePayoutId", args.stripePayoutId))
15
+ .unique();
16
+ if (claim && claim.accountId !== args.accountId)
17
+ throw new Error("Payout synchronization account does not match.");
18
+ return claim;
19
+ }
20
+ export async function payoutById(ctx, args) {
21
+ const payout = await ctx.db
22
+ .query("payouts")
23
+ .withIndex("by_stripe_payout_id", (q) => q.eq("stripePayoutId", args.stripePayoutId))
24
+ .unique();
25
+ if (payout && payout.accountId !== args.accountId)
26
+ throw new Error("Existing payout account does not match.");
27
+ return payout;
28
+ }
29
+ export function validateSnapshot(p) {
30
+ validateIdentity(p);
31
+ if (!Number.isSafeInteger(p.amount) ||
32
+ p.amount <= 0 ||
33
+ !/^[a-z]{3}$/.test(p.currency) ||
34
+ (p.method !== undefined && !["standard", "instant"].includes(p.method)))
35
+ throw new Error("Invalid payout synchronization money or method.");
36
+ if (p.arrivalDate !== undefined &&
37
+ (!Number.isFinite(Date.parse(p.arrivalDate)) ||
38
+ new Date(p.arrivalDate).toISOString() !== p.arrivalDate))
39
+ throw new Error("Invalid payout arrival date.");
40
+ if ((p.failureCode !== undefined && p.failureCode.length > 255) ||
41
+ (p.failureMessage !== undefined && p.failureMessage.length > 4096))
42
+ throw new Error("Invalid payout failure detail.");
43
+ }
44
+ export async function fingerprint(p) {
45
+ return generateIdempotencyKey("payout-sync", {
46
+ snapshot: [
47
+ p.stripePayoutId,
48
+ p.accountId,
49
+ p.amount,
50
+ p.currency,
51
+ p.status,
52
+ p.arrivalDate,
53
+ p.method,
54
+ p.failureCode,
55
+ p.failureMessage,
56
+ Object.entries(p.metadata ?? {}).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0),
57
+ ],
58
+ });
59
+ }
60
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/component/payoutSync/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,UAAU,gBAAgB,CAAC,IAGhC;IACC,IACE,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAC/C,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,GAAG;QAChC,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU;YAC5B,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG;QAE3B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAChE,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAA2B,EAC3B,IAAmD;IAEn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;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,51 @@
1
+ export declare const begin: import("convex/server").RegisteredMutation<"public", {
2
+ accountId: string;
3
+ stripePayoutId: string;
4
+ }, Promise<number>>;
5
+ export declare const finish: import("convex/server").RegisteredMutation<"public", {
6
+ accountId: string;
7
+ generation: number;
8
+ payout: {
9
+ accountId: string;
10
+ amount: number;
11
+ arrivalDate?: string | undefined;
12
+ currency: string;
13
+ failureCode?: string | undefined;
14
+ failureMessage?: string | undefined;
15
+ metadata?: Record<string, string> | undefined;
16
+ method?: string | undefined;
17
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
18
+ stripePayoutId: string;
19
+ };
20
+ stripePayoutId: string;
21
+ }, Promise<{
22
+ status: "superseded";
23
+ generation: number;
24
+ changed?: undefined;
25
+ payout?: undefined;
26
+ } | {
27
+ status: "accepted";
28
+ generation: number;
29
+ changed: boolean;
30
+ payout: {
31
+ _creationTime: number;
32
+ _id: import("convex/values").GenericId<"payouts">;
33
+ accountId: string;
34
+ amount: number;
35
+ arrivalDate?: string | undefined;
36
+ currency: string;
37
+ failureCode?: string | undefined;
38
+ failureMessage?: string | undefined;
39
+ metadata?: any;
40
+ method?: string | undefined;
41
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
42
+ stripePayoutId: string;
43
+ totalsRecorded?: true | undefined;
44
+ };
45
+ }>>;
46
+ export declare const markUnknown: import("convex/server").RegisteredMutation<"public", {
47
+ accountId: string;
48
+ generation: number;
49
+ stripePayoutId: string;
50
+ }, Promise<null>>;
51
+ //# sourceMappingURL=mutations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/payoutSync/mutations.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,KAAK;;;mBAwBhB,CAAC;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;YAOI,YAAY;;;;;YA8BnB,UAAU;;;;;;;;;;;;;;;;;;GAmBxB,CAAC;AACH,eAAO,MAAM,WAAW;;;;iBAStB,CAAC"}
@@ -0,0 +1,88 @@
1
+ import { v } from "convex/values";
2
+ import { mutation } from "../earnings/triggers.js";
3
+ import { writePayout } from "../connect/payoutWrites.js";
4
+ import { claimByPayout, payoutById, validateSnapshot, fingerprint, } from "./helpers.js";
5
+ import { identity, prepared, result } from "./validators.js";
6
+ export const begin = mutation({
7
+ args: identity,
8
+ returns: v.number(),
9
+ handler: async (ctx, args) => {
10
+ const claim = await claimByPayout(ctx, args);
11
+ await payoutById(ctx, args);
12
+ const generation = (claim?.generation ?? 0) + 1;
13
+ if (!Number.isSafeInteger(generation))
14
+ throw new Error("Payout synchronization generation exhausted.");
15
+ if (claim)
16
+ await ctx.db.patch("payoutSyncClaims", claim._id, {
17
+ generation,
18
+ status: "pending",
19
+ startedAt: Date.now(),
20
+ });
21
+ else
22
+ await ctx.db.insert("payoutSyncClaims", {
23
+ ...args,
24
+ generation,
25
+ status: "pending",
26
+ startedAt: Date.now(),
27
+ });
28
+ return generation;
29
+ },
30
+ });
31
+ export const finish = mutation({
32
+ args: prepared,
33
+ returns: result,
34
+ handler: async (ctx, args) => {
35
+ const claim = await claimByPayout(ctx, args);
36
+ if (!claim)
37
+ throw new Error("Payout synchronization claim is missing.");
38
+ if (claim.generation !== args.generation)
39
+ return { status: "superseded", generation: args.generation };
40
+ validateSnapshot(args.payout);
41
+ if (args.payout.accountId !== args.accountId ||
42
+ args.payout.stripePayoutId !== args.stripePayoutId)
43
+ throw new Error("Payout synchronization snapshot identity does not match.");
44
+ const existing = await payoutById(ctx, args);
45
+ if (existing &&
46
+ (existing.amount !== args.payout.amount ||
47
+ existing.currency !== args.payout.currency))
48
+ throw new Error("Existing payout original money does not match.");
49
+ const nextFingerprint = await fingerprint(args.payout);
50
+ if (claim.status === "accepted" &&
51
+ claim.acceptedFingerprint !== nextFingerprint)
52
+ throw new Error("An accepted payout observation cannot be replaced.");
53
+ const changed = !existing || (await fingerprint(existing)) !== nextFingerprint;
54
+ if (claim.status === "accepted" && changed)
55
+ throw new Error("Accepted payout state changed outside its synchronization.");
56
+ if (claim.status === "accepted")
57
+ return {
58
+ status: "accepted",
59
+ generation: args.generation,
60
+ changed: false,
61
+ payout: existing,
62
+ };
63
+ const payout = changed ? await writePayout(ctx, args.payout) : existing;
64
+ await ctx.db.patch("payoutSyncClaims", claim._id, {
65
+ status: "accepted",
66
+ acceptedGeneration: args.generation,
67
+ acceptedAt: Date.now(),
68
+ acceptedFingerprint: nextFingerprint,
69
+ });
70
+ return {
71
+ status: "accepted",
72
+ generation: args.generation,
73
+ changed,
74
+ payout,
75
+ };
76
+ },
77
+ });
78
+ export const markUnknown = mutation({
79
+ args: { ...identity, generation: v.number() },
80
+ returns: v.null(),
81
+ handler: async (ctx, args) => {
82
+ const claim = await claimByPayout(ctx, args);
83
+ if (claim?.generation === args.generation && claim.status === "pending")
84
+ await ctx.db.patch("payoutSyncClaims", claim._id, { status: "unknown" });
85
+ return null;
86
+ },
87
+ });
88
+ //# sourceMappingURL=mutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/payoutSync/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,E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AAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,GAAG,EAAE;YAChD,MAAM,EAAE,UAAU;YAClB,kBAAkB,EAAE,IAAI,CAAC,UAAU;YACnC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,mBAAmB,EAAE,eAAe;SACrC,CAAC,CAAC;QACH,OAAO;YACL,MAAM,EAAE,UAAmB;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO;YACP,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IAC7C,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE;IACjB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YACrE,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const get: import("convex/server").RegisteredQuery<"public", {
2
+ stripePayoutId: string;
3
+ accountId: string;
4
+ }, Promise<{
5
+ _creationTime: number;
6
+ _id: import("convex/values").GenericId<"payoutSyncClaims">;
7
+ acceptedAt?: number | undefined;
8
+ acceptedFingerprint?: string | undefined;
9
+ acceptedGeneration?: number | undefined;
10
+ accountId: string;
11
+ generation: number;
12
+ startedAt: number;
13
+ status: "accepted" | "pending" | "unknown";
14
+ stripePayoutId: string;
15
+ } | null>>;
16
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutSync/queries.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;UAId,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { v } from "convex/values";
2
+ import { query } from "../_generated/server.js";
3
+ import { claimByPayout } from "./helpers.js";
4
+ import { claimDoc } from "./schema.js";
5
+ import { identity } from "./validators.js";
6
+ export const get = query({
7
+ args: identity,
8
+ returns: v.union(claimDoc, v.null()),
9
+ handler: claimByPayout,
10
+ });
11
+ //# sourceMappingURL=queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/payoutSync/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ export declare const claimDoc: import("convex/values").VObject<{
2
+ _creationTime: number;
3
+ _id: import("convex/values").GenericId<"payoutSyncClaims">;
4
+ acceptedAt?: number | undefined;
5
+ acceptedFingerprint?: string | undefined;
6
+ acceptedGeneration?: number | undefined;
7
+ accountId: string;
8
+ generation: number;
9
+ startedAt: number;
10
+ status: "accepted" | "pending" | "unknown";
11
+ stripePayoutId: string;
12
+ }, {
13
+ stripePayoutId: import("convex/values").VString<string, "required">;
14
+ accountId: import("convex/values").VString<string, "required">;
15
+ generation: import("convex/values").VFloat64<number, "required">;
16
+ status: import("convex/values").VUnion<"accepted" | "pending" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
17
+ startedAt: import("convex/values").VFloat64<number, "required">;
18
+ acceptedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
19
+ acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
20
+ acceptedFingerprint: import("convex/values").VString<string | undefined, "optional">;
21
+ _id: import("convex/values").VId<import("convex/values").GenericId<"payoutSyncClaims">, "required">;
22
+ _creationTime: import("convex/values").VFloat64<number, "required">;
23
+ }, "required", "_creationTime" | "_id" | "acceptedAt" | "acceptedFingerprint" | "acceptedGeneration" | "accountId" | "generation" | "startedAt" | "status" | "stripePayoutId">;
24
+ /** Operational generations only. Financial facts remain in the existing payouts table. */
25
+ export declare const claimsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
26
+ acceptedAt?: number | undefined;
27
+ acceptedFingerprint?: string | undefined;
28
+ acceptedGeneration?: number | undefined;
29
+ accountId: string;
30
+ generation: number;
31
+ startedAt: number;
32
+ status: "accepted" | "pending" | "unknown";
33
+ stripePayoutId: string;
34
+ }, {
35
+ stripePayoutId: import("convex/values").VString<string, "required">;
36
+ accountId: import("convex/values").VString<string, "required">;
37
+ generation: import("convex/values").VFloat64<number, "required">;
38
+ status: import("convex/values").VUnion<"accepted" | "pending" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
39
+ startedAt: import("convex/values").VFloat64<number, "required">;
40
+ acceptedGeneration: import("convex/values").VFloat64<number | undefined, "optional">;
41
+ acceptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
42
+ acceptedFingerprint: import("convex/values").VString<string | undefined, "optional">;
43
+ }, "required", "acceptedAt" | "acceptedFingerprint" | "acceptedGeneration" | "accountId" | "generation" | "startedAt" | "status" | "stripePayoutId">, {
44
+ by_stripe_payout_id: ["stripePayoutId", "_creationTime"];
45
+ }, {}, {}>;
46
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/payoutSync/schema.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;8KAInB,CAAC;AACH,0FAA0F;AAC1F,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;UAEtB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ import { identity } from "./validators.js";
4
+ const fields = {
5
+ ...identity,
6
+ generation: v.number(),
7
+ status: v.union(v.literal("pending"), v.literal("accepted"), v.literal("unknown")),
8
+ startedAt: v.number(),
9
+ acceptedGeneration: v.optional(v.number()),
10
+ acceptedAt: v.optional(v.number()),
11
+ acceptedFingerprint: v.optional(v.string()),
12
+ };
13
+ export const claimDoc = v.object({
14
+ ...fields,
15
+ _id: v.id("payoutSyncClaims"),
16
+ _creationTime: v.number(),
17
+ });
18
+ /** Operational generations only. Financial facts remain in the existing payouts table. */
19
+ export const claimsTable = defineTable(fields).index("by_stripe_payout_id", [
20
+ "stripePayoutId",
21
+ ]);
22
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/payoutSync/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,MAAM,MAAM,GAAG;IACb,GAAG,QAAQ;IACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,KAAK,CACb,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB;IACD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC5C,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,MAAM;IACT,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC;IAC7B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC;AACH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,qBAAqB,EAAE;IAC1E,gBAAgB;CACjB,CAAC,CAAC"}
@@ -0,0 +1,137 @@
1
+ export declare const identity: {
2
+ stripePayoutId: import("convex/values").VString<string, "required">;
3
+ accountId: import("convex/values").VString<string, "required">;
4
+ };
5
+ export declare const snapshot: import("convex/values").VObject<{
6
+ accountId: string;
7
+ amount: number;
8
+ arrivalDate?: string | undefined;
9
+ currency: string;
10
+ failureCode?: string | undefined;
11
+ failureMessage?: string | undefined;
12
+ metadata?: Record<string, string> | undefined;
13
+ method?: string | undefined;
14
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
15
+ stripePayoutId: string;
16
+ }, {
17
+ stripePayoutId: import("convex/values").VString<string, "required">;
18
+ accountId: import("convex/values").VString<string, "required">;
19
+ amount: import("convex/values").VFloat64<number, "required">;
20
+ currency: import("convex/values").VString<string, "required">;
21
+ status: import("convex/values").VUnion<"canceled" | "failed" | "in_transit" | "paid" | "pending", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"paid", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"in_transit", "required">], "required", never>;
22
+ arrivalDate: import("convex/values").VString<string | undefined, "optional">;
23
+ method: import("convex/values").VString<string | undefined, "optional">;
24
+ failureCode: import("convex/values").VString<string | undefined, "optional">;
25
+ failureMessage: import("convex/values").VString<string | undefined, "optional">;
26
+ metadata: import("convex/values").VRecord<Record<string, string> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VString<string, "required">, "optional", string>;
27
+ }, "required", "accountId" | "amount" | "arrivalDate" | "currency" | "failureCode" | "failureMessage" | "metadata" | "method" | "status" | "stripePayoutId" | `metadata.${string}`>;
28
+ export declare const prepared: {
29
+ stripePayoutId: import("convex/values").VString<string, "required">;
30
+ accountId: import("convex/values").VString<string, "required">;
31
+ generation: import("convex/values").VFloat64<number, "required">;
32
+ payout: import("convex/values").VObject<{
33
+ accountId: string;
34
+ amount: number;
35
+ arrivalDate?: string | undefined;
36
+ currency: string;
37
+ failureCode?: string | undefined;
38
+ failureMessage?: string | undefined;
39
+ metadata?: Record<string, string> | undefined;
40
+ method?: string | undefined;
41
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
42
+ stripePayoutId: string;
43
+ }, {
44
+ stripePayoutId: import("convex/values").VString<string, "required">;
45
+ accountId: import("convex/values").VString<string, "required">;
46
+ amount: import("convex/values").VFloat64<number, "required">;
47
+ currency: import("convex/values").VString<string, "required">;
48
+ status: import("convex/values").VUnion<"canceled" | "failed" | "in_transit" | "paid" | "pending", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"paid", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"in_transit", "required">], "required", never>;
49
+ arrivalDate: import("convex/values").VString<string | undefined, "optional">;
50
+ method: import("convex/values").VString<string | undefined, "optional">;
51
+ failureCode: import("convex/values").VString<string | undefined, "optional">;
52
+ failureMessage: import("convex/values").VString<string | undefined, "optional">;
53
+ metadata: import("convex/values").VRecord<Record<string, string> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VString<string, "required">, "optional", string>;
54
+ }, "required", "accountId" | "amount" | "arrivalDate" | "currency" | "failureCode" | "failureMessage" | "metadata" | "method" | "status" | "stripePayoutId" | `metadata.${string}`>;
55
+ };
56
+ export declare const result: import("convex/values").VUnion<{
57
+ changed: boolean;
58
+ generation: number;
59
+ payout: {
60
+ _creationTime: number;
61
+ _id: import("convex/values").GenericId<"payouts">;
62
+ accountId: string;
63
+ amount: number;
64
+ arrivalDate?: string | undefined;
65
+ currency: string;
66
+ failureCode?: string | undefined;
67
+ failureMessage?: string | undefined;
68
+ metadata?: any;
69
+ method?: string | undefined;
70
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
71
+ stripePayoutId: string;
72
+ totalsRecorded?: true | undefined;
73
+ };
74
+ status: "accepted";
75
+ } | {
76
+ generation: number;
77
+ status: "superseded";
78
+ }, [import("convex/values").VObject<{
79
+ changed: boolean;
80
+ generation: number;
81
+ payout: {
82
+ _creationTime: number;
83
+ _id: import("convex/values").GenericId<"payouts">;
84
+ accountId: string;
85
+ amount: number;
86
+ arrivalDate?: string | undefined;
87
+ currency: string;
88
+ failureCode?: string | undefined;
89
+ failureMessage?: string | undefined;
90
+ metadata?: any;
91
+ method?: string | undefined;
92
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
93
+ stripePayoutId: string;
94
+ totalsRecorded?: true | undefined;
95
+ };
96
+ status: "accepted";
97
+ }, {
98
+ status: import("convex/values").VLiteral<"accepted", "required">;
99
+ generation: import("convex/values").VFloat64<number, "required">;
100
+ changed: import("convex/values").VBoolean<boolean, "required">;
101
+ payout: import("convex/values").VObject<{
102
+ _creationTime: number;
103
+ _id: import("convex/values").GenericId<"payouts">;
104
+ accountId: string;
105
+ amount: number;
106
+ arrivalDate?: string | undefined;
107
+ currency: string;
108
+ failureCode?: string | undefined;
109
+ failureMessage?: string | undefined;
110
+ metadata?: any;
111
+ method?: string | undefined;
112
+ status: "canceled" | "failed" | "in_transit" | "paid" | "pending";
113
+ stripePayoutId: string;
114
+ totalsRecorded?: true | undefined;
115
+ }, {
116
+ stripePayoutId: import("convex/values").VString<string, "required">;
117
+ accountId: import("convex/values").VString<string, "required">;
118
+ amount: import("convex/values").VFloat64<number, "required">;
119
+ currency: import("convex/values").VString<string, "required">;
120
+ status: import("convex/values").VUnion<"canceled" | "failed" | "in_transit" | "paid" | "pending", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"paid", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"in_transit", "required">], "required", never>;
121
+ arrivalDate: import("convex/values").VString<string | undefined, "optional">;
122
+ method: import("convex/values").VString<string | undefined, "optional">;
123
+ failureCode: import("convex/values").VString<string | undefined, "optional">;
124
+ failureMessage: import("convex/values").VString<string | undefined, "optional">;
125
+ metadata: import("convex/values").VAny<any, "optional", string>;
126
+ _id: import("convex/values").VId<import("convex/values").GenericId<"payouts">, "required">;
127
+ _creationTime: import("convex/values").VFloat64<number, "required">;
128
+ totalsRecorded: import("convex/values").VLiteral<true | undefined, "optional">;
129
+ }, "required", "_creationTime" | "_id" | "accountId" | "amount" | "arrivalDate" | "currency" | "failureCode" | "failureMessage" | "metadata" | "method" | "status" | "stripePayoutId" | "totalsRecorded" | `metadata.${string}`>;
130
+ }, "required", "changed" | "generation" | "payout" | "payout._creationTime" | "payout._id" | "payout.accountId" | "payout.amount" | "payout.arrivalDate" | "payout.currency" | "payout.failureCode" | "payout.failureMessage" | "payout.metadata" | "payout.method" | "payout.status" | "payout.stripePayoutId" | "payout.totalsRecorded" | "status" | `payout.metadata.${string}`>, import("convex/values").VObject<{
131
+ generation: number;
132
+ status: "superseded";
133
+ }, {
134
+ status: import("convex/values").VLiteral<"superseded", "required">;
135
+ generation: import("convex/values").VFloat64<number, "required">;
136
+ }, "required", "generation" | "status">], "required", "changed" | "generation" | "payout" | "payout._creationTime" | "payout._id" | "payout.accountId" | "payout.amount" | "payout.arrivalDate" | "payout.currency" | "payout.failureCode" | "payout.failureMessage" | "payout.metadata" | "payout.method" | "payout.status" | "payout.stripePayoutId" | "payout.totalsRecorded" | "status" | `payout.metadata.${string}`>;
137
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/component/payoutSync/validators.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;IAAK,cAAc;IAAc,SAAS;CAAc,CAAC;AAC9E,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;mLAGnB,CAAC;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIpB,CAAC;AACF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0ZAQlB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { v } from "convex/values";
2
+ import { payoutFields, payoutDocValidator } from "../connect/validators.js";
3
+ export const identity = { stripePayoutId: v.string(), accountId: v.string() };
4
+ export const snapshot = v.object({
5
+ ...payoutFields,
6
+ metadata: v.optional(v.record(v.string(), v.string())),
7
+ });
8
+ export const prepared = {
9
+ ...identity,
10
+ generation: v.number(),
11
+ payout: snapshot,
12
+ };
13
+ export const result = v.union(v.object({
14
+ status: v.literal("accepted"),
15
+ generation: v.number(),
16
+ changed: v.boolean(),
17
+ payout: payoutDocValidator,
18
+ }), v.object({ status: v.literal("superseded"), generation: v.number() }));
19
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/component/payoutSync/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,YAAY;IACf,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;CACvD,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG,QAAQ;IACX,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,QAAQ;CACjB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAC3B,CAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,MAAM,EAAE,kBAAkB;CAC3B,CAAC,EACF,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACtE,CAAC"}