@fantastic.dev/better-stripe 0.92.0 → 0.94.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts +41 -0
  4. package/dist/client/billing/renewalAttach/internal/operationJournal.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/operationJournal.js +378 -0
  6. package/dist/client/billing/renewalAttach/internal/operationJournal.js.map +1 -0
  7. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +44 -0
  8. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +251 -0
  10. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
  11. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +562 -0
  12. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  13. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
  14. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  15. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +562 -0
  16. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  17. package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
  18. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  19. package/dist/client/index.d.ts +3 -2
  20. package/dist/client/index.d.ts.map +1 -1
  21. package/dist/client/index.js +16 -3
  22. package/dist/client/index.js.map +1 -1
  23. package/dist/component/_generated/api.d.ts +6 -0
  24. package/dist/component/_generated/api.d.ts.map +1 -1
  25. package/dist/component/_generated/api.js.map +1 -1
  26. package/dist/component/_generated/component.d.ts +406 -0
  27. package/dist/component/_generated/component.d.ts.map +1 -1
  28. package/dist/component/balanceFunding/mutations.d.ts +27 -27
  29. package/dist/component/balanceFunding/queries.d.ts +1 -1
  30. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  31. package/dist/component/earnings/triggers.d.ts +294 -0
  32. package/dist/component/earnings/triggers.d.ts.map +1 -1
  33. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  34. package/dist/component/renewalOperations/helpers.d.ts +236 -0
  35. package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
  36. package/dist/component/renewalOperations/helpers.js +457 -0
  37. package/dist/component/renewalOperations/helpers.js.map +1 -0
  38. package/dist/component/renewalOperations/mutations.d.ts +252 -0
  39. package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
  40. package/dist/component/renewalOperations/mutations.js +340 -0
  41. package/dist/component/renewalOperations/mutations.js.map +1 -0
  42. package/dist/component/renewalOperations/queries.d.ts +163 -0
  43. package/dist/component/renewalOperations/queries.d.ts.map +1 -0
  44. package/dist/component/renewalOperations/queries.js +167 -0
  45. package/dist/component/renewalOperations/queries.js.map +1 -0
  46. package/dist/component/renewalOperations/schema.d.ts +1988 -0
  47. package/dist/component/renewalOperations/schema.d.ts.map +1 -0
  48. package/dist/component/renewalOperations/schema.js +227 -0
  49. package/dist/component/renewalOperations/schema.js.map +1 -0
  50. package/dist/component/schema.d.ts +281 -0
  51. package/dist/component/schema.js +5 -0
  52. package/dist/component/schema.js.map +1 -1
  53. package/dist/component/usage/allowance.fixtures.d.ts +281 -0
  54. package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
  55. package/dist/component/usageCredits/accounting.fixtures.d.ts +297 -16
  56. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
  57. package/dist/shared/renewalOperationJournal.d.ts +43 -0
  58. package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
  59. package/dist/shared/renewalOperationJournal.js +294 -0
  60. package/dist/shared/renewalOperationJournal.js.map +1 -0
  61. package/docs/renewal-context-reads.md +180 -0
  62. package/package.json +1 -1
  63. package/src/client/billing/renewalAttach/internal/operationJournal.acknowledgement.integration.test.ts +500 -0
  64. package/src/client/billing/renewalAttach/internal/operationJournal.c10.integration.test.ts +560 -0
  65. package/src/client/billing/renewalAttach/internal/operationJournal.controls.integration.test.ts +356 -0
  66. package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +560 -0
  67. package/src/client/billing/renewalAttach/internal/operationJournal.methods.integration.test.ts +534 -0
  68. package/src/client/billing/renewalAttach/internal/operationJournal.ts +561 -0
  69. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +334 -0
  70. package/src/client/billing/renewalAttach/internal/producer/producerGuards.integration.test.ts +323 -0
  71. package/src/client/billing/renewalAttach/internal/producer/producerInitial.integration.test.ts +301 -0
  72. package/src/client/billing/renewalAttach/internal/producer/producerIsolation.integration.test.ts +531 -0
  73. package/src/client/index.ts +24 -3
  74. package/src/component/_generated/api.ts +6 -0
  75. package/src/component/_generated/component.ts +450 -0
  76. package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
  77. package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
  78. package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
  79. package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
  80. package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
  81. package/src/component/renewalOperations/basisBinding.test.ts +567 -0
  82. package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
  83. package/src/component/renewalOperations/boundHistory.test.ts +474 -0
  84. package/src/component/renewalOperations/helpers.ts +592 -0
  85. package/src/component/renewalOperations/historyReads.test.ts +595 -0
  86. package/src/component/renewalOperations/initialBasis.test.ts +578 -0
  87. package/src/component/renewalOperations/journal.test.ts +567 -0
  88. package/src/component/renewalOperations/mutations.ts +456 -0
  89. package/src/component/renewalOperations/payload.test.ts +589 -0
  90. package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
  91. package/src/component/renewalOperations/queries.ts +204 -0
  92. package/src/component/renewalOperations/schema.ts +268 -0
  93. package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
  94. package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
  95. package/src/component/schema.ts +11 -0
  96. package/src/shared/renewalOperationJournal.ts +333 -0
@@ -0,0 +1,252 @@
1
+ /** Trusted host component API. Authorization policy remains outside the SDK. */
2
+ export declare const createAuthorizedOperation: import("convex/server").RegisteredMutation<"public", {
3
+ authorizationRevision: number;
4
+ authorizationScope: string;
5
+ logicalOperationId: string;
6
+ recordJSON: string;
7
+ }, Promise<{
8
+ status: "conflict";
9
+ reason: "identity_changed";
10
+ } | {
11
+ status: "existing";
12
+ operationId: import("convex/values").GenericId<"renewalOperations">;
13
+ } | {
14
+ status: "created";
15
+ operationId: import("convex/values").GenericId<"renewalOperations">;
16
+ }>>;
17
+ /** First CAS only. The transient acquired result is never stored or echoed. */
18
+ export declare const reserveAttempt: import("convex/server").RegisteredMutation<"public", {
19
+ expectedRequestBinding: string;
20
+ expectedRevision: number;
21
+ operationId: import("convex/values").GenericId<"renewalOperations">;
22
+ recordJSON: string;
23
+ stage: "attach" | "configure";
24
+ }, Promise<{
25
+ disposition: "conflict";
26
+ reason: "identity_changed";
27
+ } | {
28
+ disposition: "existing";
29
+ committedRevision: 1;
30
+ reservation: {
31
+ key: string;
32
+ apiVersion: string;
33
+ firstDispatchedAt: number;
34
+ accountJSON: string;
35
+ stage: "attach";
36
+ recordVersion: 2;
37
+ timingPolicyJSON: string;
38
+ operationId: import("convex/values").GenericId<"renewalOperations">;
39
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
40
+ authorizationScope: string;
41
+ authorizationId: string;
42
+ authorizationRevision: number;
43
+ logicalOperationId: string;
44
+ requestBinding: string;
45
+ ordinal: 1;
46
+ preparedRevision: 0;
47
+ committedRevision: 1;
48
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
49
+ recordJSON: string;
50
+ } | {
51
+ stage: "attach" | "configure";
52
+ key: string;
53
+ apiVersion: string;
54
+ firstDispatchedAt: number;
55
+ accountJSON: string;
56
+ basisJSON: string;
57
+ operationId: import("convex/values").GenericId<"renewalOperations">;
58
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
59
+ authorizationScope: string;
60
+ authorizationId: string;
61
+ authorizationRevision: number;
62
+ logicalOperationId: string;
63
+ requestBinding: string;
64
+ ordinal: 1;
65
+ preparedRevision: 0;
66
+ committedRevision: 1;
67
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
68
+ recordJSON: string;
69
+ };
70
+ previousRevision?: undefined;
71
+ } | {
72
+ disposition: "acquired";
73
+ previousRevision: 0;
74
+ committedRevision: 1;
75
+ reservation: {
76
+ key: string;
77
+ apiVersion: string;
78
+ firstDispatchedAt: number;
79
+ accountJSON: string;
80
+ stage: "attach";
81
+ recordVersion: 2;
82
+ timingPolicyJSON: string;
83
+ operationId: import("convex/values").GenericId<"renewalOperations">;
84
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
85
+ authorizationScope: string;
86
+ authorizationId: string;
87
+ authorizationRevision: number;
88
+ logicalOperationId: string;
89
+ requestBinding: string;
90
+ ordinal: 1;
91
+ preparedRevision: 0;
92
+ committedRevision: 1;
93
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
94
+ recordJSON: string;
95
+ } | {
96
+ stage: "attach" | "configure";
97
+ key: string;
98
+ apiVersion: string;
99
+ firstDispatchedAt: number;
100
+ accountJSON: string;
101
+ basisJSON: string;
102
+ operationId: import("convex/values").GenericId<"renewalOperations">;
103
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
104
+ authorizationScope: string;
105
+ authorizationId: string;
106
+ authorizationRevision: number;
107
+ logicalOperationId: string;
108
+ requestBinding: string;
109
+ ordinal: 1;
110
+ preparedRevision: 0;
111
+ committedRevision: 1;
112
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
113
+ recordJSON: string;
114
+ };
115
+ }>>;
116
+ /** Storage consistency only. A stored row is not actual C10 fulfillment. */
117
+ export declare const appendStageEvent: import("convex/server").RegisteredMutation<"public", {
118
+ event: {
119
+ binding: string;
120
+ dataJSON: string;
121
+ sequence: 1 | 2 | 3;
122
+ };
123
+ expectedSequence: number;
124
+ reservation: {
125
+ accountJSON: string;
126
+ apiVersion: string;
127
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
128
+ authorizationId: string;
129
+ authorizationRevision: number;
130
+ authorizationScope: string;
131
+ basisJSON: string;
132
+ committedRevision: 1;
133
+ firstDispatchedAt: number;
134
+ key: string;
135
+ logicalOperationId: string;
136
+ operationId: import("convex/values").GenericId<"renewalOperations">;
137
+ ordinal: 1;
138
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
139
+ preparedRevision: 0;
140
+ recordJSON: string;
141
+ requestBinding: string;
142
+ stage: "attach" | "configure";
143
+ } | {
144
+ accountJSON: string;
145
+ apiVersion: string;
146
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
147
+ authorizationId: string;
148
+ authorizationRevision: number;
149
+ authorizationScope: string;
150
+ committedRevision: 1;
151
+ firstDispatchedAt: number;
152
+ key: string;
153
+ logicalOperationId: string;
154
+ operationId: import("convex/values").GenericId<"renewalOperations">;
155
+ ordinal: 1;
156
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
157
+ preparedRevision: 0;
158
+ recordJSON: string;
159
+ recordVersion: 2;
160
+ requestBinding: string;
161
+ stage: "attach";
162
+ timingPolicyJSON: string;
163
+ };
164
+ }, Promise<{
165
+ operationId: import("convex/values").GenericId<"renewalOperations">;
166
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
167
+ stage: "attach" | "configure";
168
+ sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
169
+ sequence: 1 | 2 | 3;
170
+ binding: string;
171
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
172
+ eventId: import("convex/values").GenericId<"renewalOperationEvents">;
173
+ reservation: {
174
+ key: string;
175
+ apiVersion: string;
176
+ firstDispatchedAt: number;
177
+ accountJSON: string;
178
+ stage: "attach";
179
+ recordVersion: 2;
180
+ timingPolicyJSON: string;
181
+ operationId: import("convex/values").GenericId<"renewalOperations">;
182
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
183
+ authorizationScope: string;
184
+ authorizationId: string;
185
+ authorizationRevision: number;
186
+ logicalOperationId: string;
187
+ requestBinding: string;
188
+ ordinal: 1;
189
+ preparedRevision: 0;
190
+ committedRevision: 1;
191
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
192
+ recordJSON: string;
193
+ } | {
194
+ stage: "attach" | "configure";
195
+ key: string;
196
+ apiVersion: string;
197
+ firstDispatchedAt: number;
198
+ accountJSON: string;
199
+ basisJSON: string;
200
+ operationId: import("convex/values").GenericId<"renewalOperations">;
201
+ payloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
202
+ authorizationScope: string;
203
+ authorizationId: string;
204
+ authorizationRevision: number;
205
+ logicalOperationId: string;
206
+ requestBinding: string;
207
+ ordinal: 1;
208
+ preparedRevision: 0;
209
+ committedRevision: 1;
210
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
211
+ recordJSON: string;
212
+ };
213
+ }>>;
214
+ /** ATTACH retention at the checked head, with immutable known-DATA repeats. */
215
+ export declare const retainProviderAcknowledgement: import("convex/server").RegisteredMutation<"public", {
216
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
217
+ expectedSequence: 2 | 3;
218
+ operationId: import("convex/values").GenericId<"renewalOperations">;
219
+ receiptJSON: string;
220
+ }, Promise<{
221
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
222
+ dispatchEventId: import("convex/values").GenericId<"renewalOperationEvents">;
223
+ dispatchPayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
224
+ operationId: import("convex/values").GenericId<"renewalOperations">;
225
+ receiptBinding: string;
226
+ receiptPayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
227
+ responseEventId: import("convex/values").GenericId<"renewalOperationEvents">;
228
+ responsePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
229
+ schemaVersion: 1;
230
+ sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
231
+ stage: "attach";
232
+ status: "retained";
233
+ }>>;
234
+ /** Atomic first basis DATA binding; never mints a clock, Origin or Owner. */
235
+ export declare const bindInitialBasis: import("convex/server").RegisteredMutation<"public", {
236
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
237
+ basisJSON: string;
238
+ operationId: import("convex/values").GenericId<"renewalOperations">;
239
+ policyJSON: string;
240
+ }, Promise<{
241
+ status: "bound";
242
+ operationId: import("convex/values").GenericId<"renewalOperations">;
243
+ initialBasis: {
244
+ attemptId: import("convex/values").GenericId<"renewalOperationAttempts">;
245
+ basisJSON: string;
246
+ policyJSON: string;
247
+ sourcePayloadId: import("convex/values").GenericId<"renewalOperationPayloads">;
248
+ stage: "attach";
249
+ version: 1;
250
+ };
251
+ }>>;
252
+ //# sourceMappingURL=mutations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/renewalOperations/mutations.ts"],"names":[],"mappings":"AAsCA,gFAAgF;AAChF,eAAO,MAAM,yBAAyB;;;;;;YAYxB,UAAU;YACV,kBAAkB;;YA8BT,UAAU;;;YAuBZ,SAAS;;GAE5B,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,cAAc;;;;;;;iBAKR,UAAU;YACf,kBAAkB;;iBAoBX,UAAU;uBACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBT,UAAU;sBACL,CAAC;uBACA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIxB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyH3B,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;GAwGxC,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB;;;;;;YAiDb,OAAO;;;;;;;;;;GAYrB,CAAC"}
@@ -0,0 +1,340 @@
1
+ import { mutation } from "../_generated/server.js";
2
+ import { admitJournalValue, admitJournalStrings, canonicalJournalEvent, canonicalInitialBasis, canonicalJournalRecord, } from "../../shared/renewalOperationJournal.js";
3
+ import { findOperation, validateOperationalAttachSource, originalRecord, currentReservation, checkedInitialBasis, reservationFields, reservationMatches, eventChain, validateAttachAcknowledgement, validateAttachReceiptEventDATA, validateKnownAcknowledgement, validateV2KnownAcknowledgement, } from "./helpers.js";
4
+ import { creationArgs, creationResult, reserveArgs, reserveResult, appendArgs, eventReceipt, retainAcknowledgementArgs, retentionReceipt, bindInitialBasisArgs, basisBindingReceipt, } from "./schema.js";
5
+ /** Trusted host component API. Authorization policy remains outside the SDK. */
6
+ export const createAuthorizedOperation = mutation({
7
+ args: creationArgs,
8
+ returns: creationResult,
9
+ handler: async (ctx, args) => {
10
+ const full = canonicalJournalRecord(args.recordJSON);
11
+ admitJournalStrings([
12
+ full.authorizationScope,
13
+ full.authorizationId,
14
+ full.logicalOperationId,
15
+ full.requestBinding,
16
+ ]);
17
+ const conflict = {
18
+ status: "conflict",
19
+ reason: "identity_changed",
20
+ };
21
+ if (full.authorizationScope !== args.authorizationScope ||
22
+ full.logicalOperationId !== args.logicalOperationId ||
23
+ full.authorizationRevision !== args.authorizationRevision)
24
+ return conflict;
25
+ await validateOperationalAttachSource(full);
26
+ const existing = await findOperation(ctx, args.authorizationScope, args.logicalOperationId);
27
+ if (existing) {
28
+ const original = await originalRecord(ctx, existing);
29
+ if (original.json !== full.json)
30
+ return conflict;
31
+ if (existing.recordVersion === 2) {
32
+ const current = await currentReservation(ctx, existing, original);
33
+ if (current) {
34
+ const events = await eventChain(ctx, current);
35
+ await validateV2KnownAcknowledgement(ctx, existing, original, current, events);
36
+ }
37
+ }
38
+ return { status: "existing", operationId: existing._id };
39
+ }
40
+ const payloadId = await ctx.db.insert("renewalOperationPayloads", {
41
+ codecVersion: 1,
42
+ json: full.json,
43
+ });
44
+ const operationId = await ctx.db.insert("renewalOperations", {
45
+ ...("recordVersion" in full && full.recordVersion === 2
46
+ ? { recordVersion: 2 }
47
+ : {}),
48
+ authorizationScope: full.authorizationScope,
49
+ authorizationId: full.authorizationId,
50
+ authorizationRevision: full.authorizationRevision,
51
+ logicalOperationId: full.logicalOperationId,
52
+ requestBinding: full.requestBinding,
53
+ payloadId,
54
+ revision: 0,
55
+ state: "PREPARED",
56
+ });
57
+ // Link the actual operation before this transaction commits.
58
+ await ctx.db.patch("renewalOperationPayloads", payloadId, {
59
+ owner: { kind: "operation", operationId },
60
+ });
61
+ return { status: "created", operationId };
62
+ },
63
+ });
64
+ /** First CAS only. The transient acquired result is never stored or echoed. */
65
+ export const reserveAttempt = mutation({
66
+ args: reserveArgs,
67
+ returns: reserveResult,
68
+ handler: async (ctx, args) => {
69
+ const conflict = {
70
+ disposition: "conflict",
71
+ reason: "identity_changed",
72
+ };
73
+ const row = await ctx.db.get("renewalOperations", args.operationId);
74
+ if (!row || args.expectedRevision !== 0)
75
+ return conflict;
76
+ const full = await originalRecord(ctx, row);
77
+ const supplied = canonicalJournalRecord(args.recordJSON);
78
+ if (supplied.json !== full.json ||
79
+ args.expectedRequestBinding !== full.requestBinding)
80
+ return conflict;
81
+ const fields = reservationFields(row, full);
82
+ if (args.stage !== fields.stage)
83
+ return conflict;
84
+ const current = await currentReservation(ctx, row, full);
85
+ if (current) {
86
+ if ("recordVersion" in current) {
87
+ const events = await eventChain(ctx, current);
88
+ await validateV2KnownAcknowledgement(ctx, row, full, current, events);
89
+ }
90
+ return {
91
+ disposition: "existing",
92
+ committedRevision: 1,
93
+ reservation: current,
94
+ };
95
+ }
96
+ // This read of PREPARED and both writes commit atomically under Convex OCC.
97
+ // A competing committed winner makes a rerun return existing above.
98
+ if (row.knownAcknowledgement !== undefined)
99
+ return conflict;
100
+ const attemptId = await ctx.db.insert("renewalOperationAttempts", {
101
+ ...fields,
102
+ lastSequence: 0,
103
+ });
104
+ await ctx.db.patch("renewalOperations", row._id, {
105
+ revision: 1,
106
+ state: "RESERVED",
107
+ activeAttemptId: attemptId,
108
+ });
109
+ return {
110
+ disposition: "acquired",
111
+ previousRevision: 0,
112
+ committedRevision: 1,
113
+ reservation: { ...fields, attemptId, recordJSON: full.json },
114
+ };
115
+ },
116
+ });
117
+ /** Storage consistency only. A stored row is not actual C10 fulfillment. */
118
+ export const appendStageEvent = mutation({
119
+ args: appendArgs,
120
+ returns: eventReceipt,
121
+ handler: async (ctx, args) => {
122
+ admitJournalValue(args);
123
+ const row = await ctx.db.get("renewalOperations", args.reservation.operationId);
124
+ if (!row)
125
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
126
+ const full = await originalRecord(ctx, row);
127
+ const reservation = await currentReservation(ctx, row, full);
128
+ if (!reservation || !reservationMatches(reservation, args.reservation))
129
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
130
+ if (row.recordVersion === 2 &&
131
+ checkedInitialBasis(row, reservation.attemptId, reservation) === null)
132
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
133
+ if (!Number.isSafeInteger(args.expectedSequence) ||
134
+ args.expectedSequence < 0 ||
135
+ args.expectedSequence > 2 ||
136
+ args.event.sequence !== args.expectedSequence + 1)
137
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
138
+ const incoming = await canonicalJournalEvent(args.event.sequence, args.event.dataJSON);
139
+ if (incoming.binding !== args.event.binding)
140
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
141
+ const events = await eventChain(ctx, reservation);
142
+ const known = "recordVersion" in reservation
143
+ ? await validateV2KnownAcknowledgement(ctx, row, full, reservation, events)
144
+ : null;
145
+ if (known !== null && incoming.sequence === 3) {
146
+ try {
147
+ validateAttachReceiptEventDATA(incoming.json, known.admitted.receipt);
148
+ }
149
+ catch {
150
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
151
+ }
152
+ }
153
+ // Known receipt3 publication must match the full retained C3/source, even
154
+ // on the identical-event duplicate branch below. Generic no-known DATA is
155
+ // deliberately unchanged.
156
+ if (!("recordVersion" in reservation) &&
157
+ row.knownAcknowledgement !== undefined &&
158
+ incoming.sequence === 3) {
159
+ try {
160
+ const payload = await ctx.db.get("renewalOperationPayloads", row.knownAcknowledgement.receiptPayloadId);
161
+ if (!payload)
162
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
163
+ const admitted = await validateAttachAcknowledgement(full, reservation, events, payload.json);
164
+ await validateKnownAcknowledgement(ctx, row, reservation, events, admitted);
165
+ validateAttachReceiptEventDATA(incoming.json, admitted.receipt);
166
+ }
167
+ catch {
168
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
169
+ }
170
+ }
171
+ const prior = events.find((event) => event.sequence === incoming.sequence);
172
+ if (prior) {
173
+ if (prior.binding !== incoming.binding ||
174
+ prior.dataJSON !== incoming.json)
175
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
176
+ const { dataJSON: _dataJSON, ...receipt } = prior;
177
+ void _dataJSON;
178
+ return { ...receipt, reservation };
179
+ }
180
+ if (args.expectedSequence !== events.length)
181
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
182
+ const payloadId = await ctx.db.insert("renewalOperationPayloads", {
183
+ codecVersion: 1,
184
+ json: incoming.json,
185
+ owner: {
186
+ kind: "event",
187
+ operationId: reservation.operationId,
188
+ attemptId: reservation.attemptId,
189
+ stage: reservation.stage,
190
+ sequence: incoming.sequence,
191
+ },
192
+ });
193
+ const fields = {
194
+ operationId: reservation.operationId,
195
+ attemptId: reservation.attemptId,
196
+ stage: reservation.stage,
197
+ sourcePayloadId: reservation.payloadId,
198
+ sequence: incoming.sequence,
199
+ binding: incoming.binding,
200
+ payloadId,
201
+ };
202
+ const eventId = await ctx.db.insert("renewalOperationEvents", fields);
203
+ await ctx.db.patch("renewalOperationAttempts", reservation.attemptId, {
204
+ lastSequence: incoming.sequence,
205
+ });
206
+ return { ...fields, eventId, reservation };
207
+ },
208
+ });
209
+ /** ATTACH retention at the checked head, with immutable known-DATA repeats. */
210
+ export const retainProviderAcknowledgement = mutation({
211
+ args: retainAcknowledgementArgs,
212
+ returns: retentionReceipt,
213
+ handler: async (ctx, args) => {
214
+ admitJournalValue(args);
215
+ try {
216
+ const row = await ctx.db.get("renewalOperations", args.operationId);
217
+ if (!row)
218
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
219
+ const full = await originalRecord(ctx, row);
220
+ const reservation = await currentReservation(ctx, row, full);
221
+ if (!reservation ||
222
+ reservation.attemptId !== args.attemptId ||
223
+ reservation.stage !== "attach")
224
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
225
+ if ("recordVersion" in reservation &&
226
+ checkedInitialBasis(row, reservation.attemptId, reservation) === null)
227
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
228
+ const events = await eventChain(ctx, reservation);
229
+ const head = events.length;
230
+ if ((head !== 2 && head !== 3) ||
231
+ args.expectedSequence > head ||
232
+ (row.knownAcknowledgement === undefined &&
233
+ args.expectedSequence !== head))
234
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
235
+ const admitted = await validateAttachAcknowledgement(full, reservation, events, args.receiptJSON);
236
+ const checkedKnown = "recordVersion" in reservation
237
+ ? await validateV2KnownAcknowledgement(ctx, row, full, reservation, events)
238
+ : null;
239
+ if (checkedKnown !== null &&
240
+ checkedKnown.admitted.receiptJSON !== admitted.receiptJSON)
241
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
242
+ const retained = checkedKnown === null
243
+ ? await validateKnownAcknowledgement(ctx, row, reservation, events, admitted)
244
+ : checkedKnown.retained;
245
+ if (retained !== null) {
246
+ const result = {
247
+ status: "retained",
248
+ operationId: row._id,
249
+ ...retained,
250
+ };
251
+ return result;
252
+ }
253
+ const receiptPayloadId = await ctx.db.insert("renewalOperationPayloads", {
254
+ codecVersion: 1,
255
+ json: admitted.receiptJSON,
256
+ owner: {
257
+ kind: "receipt",
258
+ operationId: row._id,
259
+ attemptId: reservation.attemptId,
260
+ stage: "attach",
261
+ },
262
+ });
263
+ const known = {
264
+ schemaVersion: 1,
265
+ stage: "attach",
266
+ attemptId: reservation.attemptId,
267
+ sourcePayloadId: reservation.payloadId,
268
+ dispatchEventId: events[0].eventId,
269
+ dispatchPayloadId: events[0].payloadId,
270
+ responseEventId: events[1].eventId,
271
+ responsePayloadId: events[1].payloadId,
272
+ receiptPayloadId,
273
+ receiptBinding: admitted.receiptBinding,
274
+ };
275
+ await ctx.db.patch("renewalOperations", row._id, {
276
+ knownAcknowledgement: known,
277
+ });
278
+ const result = {
279
+ status: "retained",
280
+ operationId: row._id,
281
+ ...known,
282
+ };
283
+ return result;
284
+ }
285
+ catch {
286
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
287
+ }
288
+ },
289
+ });
290
+ /** Atomic first basis DATA binding; never mints a clock, Origin or Owner. */
291
+ export const bindInitialBasis = mutation({
292
+ args: bindInitialBasisArgs,
293
+ returns: basisBindingReceipt,
294
+ handler: async (ctx, args) => {
295
+ admitJournalValue(args);
296
+ try {
297
+ const row = await ctx.db.get("renewalOperations", args.operationId);
298
+ if (!row || row.recordVersion !== 2)
299
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
300
+ const full = await originalRecord(ctx, row);
301
+ const reservation = await currentReservation(ctx, row, full);
302
+ if (!reservation ||
303
+ !("recordVersion" in reservation) ||
304
+ reservation.attemptId !== args.attemptId)
305
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
306
+ const normalized = canonicalInitialBasis(args.policyJSON, args.basisJSON);
307
+ if (normalized.policyJSON !== reservation.timingPolicyJSON)
308
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
309
+ const existing = checkedInitialBasis(row, reservation.attemptId, reservation);
310
+ const initialBasis = {
311
+ version: 1,
312
+ attemptId: reservation.attemptId,
313
+ sourcePayloadId: reservation.payloadId,
314
+ stage: "attach",
315
+ policyJSON: normalized.policyJSON,
316
+ basisJSON: normalized.basisJSON,
317
+ };
318
+ if (existing !== null) {
319
+ const events = await eventChain(ctx, reservation);
320
+ await validateV2KnownAcknowledgement(ctx, row, full, reservation, events);
321
+ if (existing.policyJSON !== initialBasis.policyJSON ||
322
+ existing.basisJSON !== initialBasis.basisJSON)
323
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
324
+ }
325
+ const result = {
326
+ status: "bound",
327
+ operationId: row._id,
328
+ initialBasis: existing ?? initialBasis,
329
+ };
330
+ admitJournalValue(result);
331
+ if (existing === null)
332
+ await ctx.db.patch("renewalOperations", row._id, { initialBasis });
333
+ return result;
334
+ }
335
+ catch {
336
+ throw Error("RENEWAL_JOURNAL_CONFLICT");
337
+ }
338
+ },
339
+ });
340
+ //# sourceMappingURL=mutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/renewalOperations/mutations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,aAAa,EACb,+BAA+B,EAC/B,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACV,YAAY,EACZ,yBAAyB,EACzB,gBAAgB,EAEhB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,aAAa,C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