@fantastic.dev/better-stripe 0.92.0 → 0.93.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 (84) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +30 -0
  4. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +113 -0
  6. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
  7. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +594 -32
  8. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
  10. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  11. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +594 -32
  12. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  13. package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
  14. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  15. package/dist/client/index.d.ts +3 -2
  16. package/dist/client/index.d.ts.map +1 -1
  17. package/dist/client/index.js +16 -3
  18. package/dist/client/index.js.map +1 -1
  19. package/dist/component/_generated/api.d.ts +6 -0
  20. package/dist/component/_generated/api.d.ts.map +1 -1
  21. package/dist/component/_generated/api.js.map +1 -1
  22. package/dist/component/_generated/component.d.ts +406 -0
  23. package/dist/component/_generated/component.d.ts.map +1 -1
  24. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  25. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  26. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  27. package/dist/component/earnings/triggers.d.ts +294 -0
  28. package/dist/component/earnings/triggers.d.ts.map +1 -1
  29. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  30. package/dist/component/renewalOperations/helpers.d.ts +236 -0
  31. package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
  32. package/dist/component/renewalOperations/helpers.js +457 -0
  33. package/dist/component/renewalOperations/helpers.js.map +1 -0
  34. package/dist/component/renewalOperations/mutations.d.ts +252 -0
  35. package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
  36. package/dist/component/renewalOperations/mutations.js +340 -0
  37. package/dist/component/renewalOperations/mutations.js.map +1 -0
  38. package/dist/component/renewalOperations/queries.d.ts +163 -0
  39. package/dist/component/renewalOperations/queries.d.ts.map +1 -0
  40. package/dist/component/renewalOperations/queries.js +167 -0
  41. package/dist/component/renewalOperations/queries.js.map +1 -0
  42. package/dist/component/renewalOperations/schema.d.ts +1988 -0
  43. package/dist/component/renewalOperations/schema.d.ts.map +1 -0
  44. package/dist/component/renewalOperations/schema.js +227 -0
  45. package/dist/component/renewalOperations/schema.js.map +1 -0
  46. package/dist/component/schema.d.ts +281 -0
  47. package/dist/component/schema.js +5 -0
  48. package/dist/component/schema.js.map +1 -1
  49. package/dist/component/usage/allowance.fixtures.d.ts +281 -0
  50. package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
  51. package/dist/component/usageCredits/accounting.fixtures.d.ts +297 -16
  52. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
  53. package/dist/shared/renewalOperationJournal.d.ts +43 -0
  54. package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
  55. package/dist/shared/renewalOperationJournal.js +294 -0
  56. package/dist/shared/renewalOperationJournal.js.map +1 -0
  57. package/docs/renewal-context-reads.md +152 -0
  58. package/package.json +1 -1
  59. package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +380 -0
  60. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +155 -0
  61. package/src/client/index.ts +24 -3
  62. package/src/component/_generated/api.ts +6 -0
  63. package/src/component/_generated/component.ts +450 -0
  64. package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
  65. package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
  66. package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
  67. package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
  68. package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
  69. package/src/component/renewalOperations/basisBinding.test.ts +567 -0
  70. package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
  71. package/src/component/renewalOperations/boundHistory.test.ts +474 -0
  72. package/src/component/renewalOperations/helpers.ts +592 -0
  73. package/src/component/renewalOperations/historyReads.test.ts +595 -0
  74. package/src/component/renewalOperations/initialBasis.test.ts +578 -0
  75. package/src/component/renewalOperations/journal.test.ts +567 -0
  76. package/src/component/renewalOperations/mutations.ts +456 -0
  77. package/src/component/renewalOperations/payload.test.ts +589 -0
  78. package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
  79. package/src/component/renewalOperations/queries.ts +204 -0
  80. package/src/component/renewalOperations/schema.ts +268 -0
  81. package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
  82. package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
  83. package/src/component/schema.ts +11 -0
  84. package/src/shared/renewalOperationJournal.ts +333 -0
@@ -0,0 +1,474 @@
1
+ import { makeFunctionReference } from "convex/server";
2
+ import { getConvexSize, getDocumentSize } from "convex/values";
3
+ import { afterEach, expect, it, vi } from "vitest";
4
+ import { canonicalJournalEvent } from "../../shared/renewalOperationJournal.js";
5
+ import {
6
+ canonical,
7
+ codecFixture,
8
+ componentFixture,
9
+ create,
10
+ load,
11
+ VALUE_LIMIT,
12
+ } from "./timingPolicy.fixtures.js";
13
+
14
+ const reserve = makeFunctionReference<"mutation">(
15
+ "renewalOperations/mutations:reserveAttempt",
16
+ );
17
+ const bind = makeFunctionReference<"mutation">(
18
+ "renewalOperations/mutations:bindInitialBasis",
19
+ );
20
+ const append = makeFunctionReference<"mutation">(
21
+ "renewalOperations/mutations:appendStageEvent",
22
+ );
23
+ const manifest = makeFunctionReference<"query">(
24
+ "renewalOperations/queries:readAttempt",
25
+ );
26
+ const readEvent = makeFunctionReference<"query">(
27
+ "renewalOperations/queries:readStageEvent",
28
+ );
29
+ const readACK = makeFunctionReference<"query">(
30
+ "renewalOperations/queries:readProviderAcknowledgement",
31
+ );
32
+ // Unsigned fixed DATA, not a live clock, Origin, Owner or provider receipt.
33
+ const basis = Object.freeze({
34
+ startWallMs: 1700000001000,
35
+ startNsDecimal: "1000000000",
36
+ workEndWallMs: 1700000005000,
37
+ workEndNsDecimal: "5000000000",
38
+ endWallMs: 1700000006000,
39
+ endNsDecimal: "6000000000",
40
+ });
41
+ const corruptions = [
42
+ "owner-stage",
43
+ "event-binding",
44
+ "counter",
45
+ "counter-zero",
46
+ "missing-basis",
47
+ ] as const;
48
+ afterEach(() => vi.unstubAllGlobals());
49
+
50
+ async function boundOperation() {
51
+ const h = await codecFixture();
52
+ const { t, physical } = componentFixture();
53
+ expect(BigInt(basis.workEndNsDecimal)).toBe(
54
+ BigInt(basis.startNsDecimal) + 4000000000n,
55
+ );
56
+ expect(BigInt(basis.endNsDecimal)).toBe(
57
+ BigInt(basis.startNsDecimal) + 5000000000n,
58
+ );
59
+ const createArgs = {
60
+ authorizationScope: h.record.authorization.scope,
61
+ logicalOperationId: h.record.logicalOperationId,
62
+ authorizationRevision: h.record.authorization.revision,
63
+ recordJSON: h.recordJSON,
64
+ };
65
+ expect(getConvexSize(createArgs)).toBeLessThanOrEqual(VALUE_LIMIT);
66
+ expect(await physical()).toEqual({
67
+ operations: [],
68
+ attempts: [],
69
+ events: [],
70
+ payloads: [],
71
+ });
72
+ const created = await t.mutation(create, createArgs);
73
+ expect(created.status).toBe("created");
74
+ expect(getConvexSize(created)).toBeLessThanOrEqual(VALUE_LIMIT);
75
+ const queryArgs = { operationId: created.operationId };
76
+ expect(getConvexSize(queryArgs)).toBeLessThanOrEqual(VALUE_LIMIT);
77
+ expect(await t.query(load, queryArgs)).toEqual({
78
+ recordVersion: 2,
79
+ operationId: created.operationId,
80
+ recordJSON: h.recordJSON,
81
+ revision: 0,
82
+ activeAttempt: null,
83
+ initialBasis: null,
84
+ });
85
+ const reserveArgs = {
86
+ operationId: created.operationId,
87
+ expectedRevision: 0,
88
+ stage: "attach" as const,
89
+ expectedRequestBinding: h.record.requestBinding,
90
+ recordJSON: h.recordJSON,
91
+ };
92
+ expect(getConvexSize(reserveArgs)).toBeLessThanOrEqual(VALUE_LIMIT);
93
+ const acquired = await t.mutation(reserve, reserveArgs);
94
+ expect(acquired.disposition).toBe("acquired");
95
+ expect(getConvexSize(acquired)).toBeLessThanOrEqual(VALUE_LIMIT);
96
+ const before = await physical();
97
+ expect(before.operations).toHaveLength(1);
98
+ expect(before.attempts).toHaveLength(1);
99
+ expect(before.payloads).toHaveLength(1);
100
+ expect(before.events).toHaveLength(0);
101
+ const operation = before.operations[0];
102
+ const attempt = before.attempts[0];
103
+ const payload = before.payloads[0];
104
+ expect(operation).toMatchObject({
105
+ _id: created.operationId,
106
+ recordVersion: 2,
107
+ payloadId: payload._id,
108
+ requestBinding: h.record.requestBinding,
109
+ revision: 1,
110
+ state: "RESERVED",
111
+ activeAttemptId: attempt._id,
112
+ });
113
+ expect(payload).toMatchObject({
114
+ codecVersion: 1,
115
+ json: h.recordJSON,
116
+ owner: { kind: "operation", operationId: created.operationId },
117
+ });
118
+ expect(Object.prototype.hasOwnProperty.call(operation, "initialBasis")).toBe(
119
+ false,
120
+ );
121
+ const summary = {
122
+ recordVersion: 2,
123
+ operationId: created.operationId,
124
+ payloadId: payload._id,
125
+ authorizationScope: h.record.authorization.scope,
126
+ authorizationId: h.record.authorization.id,
127
+ authorizationRevision: h.record.authorization.revision,
128
+ logicalOperationId: h.record.logicalOperationId,
129
+ requestBinding: h.record.requestBinding,
130
+ stage: "attach",
131
+ key: h.request.key,
132
+ apiVersion: h.request.apiVersion,
133
+ accountJSON: canonical(h.record.account),
134
+ timingPolicyJSON: canonical(h.record.timingPolicy),
135
+ firstDispatchedAt: h.request.firstDispatchedAt,
136
+ ordinal: 1,
137
+ preparedRevision: 0,
138
+ committedRevision: 1,
139
+ attemptId: attempt._id,
140
+ };
141
+ expect(acquired).toEqual({
142
+ disposition: "acquired",
143
+ previousRevision: 0,
144
+ committedRevision: 1,
145
+ reservation: { ...summary, recordJSON: h.recordJSON },
146
+ });
147
+ const { attemptId, ...fields } = summary;
148
+ expect(attempt).toEqual({
149
+ ...fields,
150
+ _id: attemptId,
151
+ _creationTime: attempt._creationTime,
152
+ lastSequence: 0,
153
+ });
154
+ const reserved = await t.query(load, queryArgs);
155
+ expect(reserved).toEqual({
156
+ recordVersion: 2,
157
+ operationId: created.operationId,
158
+ recordJSON: h.recordJSON,
159
+ revision: 1,
160
+ activeAttempt: summary,
161
+ initialBasis: null,
162
+ });
163
+ expect(getConvexSize(reserved)).toBeLessThanOrEqual(VALUE_LIMIT);
164
+ const args = {
165
+ operationId: created.operationId,
166
+ attemptId: attempt._id,
167
+ policyJSON: canonical(h.record.timingPolicy),
168
+ basisJSON: canonical(basis),
169
+ };
170
+ expect(getConvexSize(args)).toBeLessThanOrEqual(VALUE_LIMIT);
171
+ const initialBasis = {
172
+ version: 1 as const,
173
+ attemptId: attempt._id,
174
+ sourcePayloadId: payload._id,
175
+ stage: "attach" as const,
176
+ policyJSON: args.policyJSON,
177
+ basisJSON: args.basisJSON,
178
+ };
179
+ const receipt = {
180
+ status: "bound",
181
+ operationId: created.operationId,
182
+ initialBasis,
183
+ };
184
+ const result = await t.mutation(bind, args);
185
+ expect(result).toEqual(receipt);
186
+ expect(getConvexSize(result)).toBeLessThanOrEqual(VALUE_LIMIT);
187
+ const boundRows = await physical();
188
+ expect(boundRows).toEqual({
189
+ ...before,
190
+ operations: [{ ...operation, initialBasis }],
191
+ });
192
+ for (const rows of Object.values(boundRows)) {
193
+ for (const row of rows)
194
+ expect(getDocumentSize(row)).toBeLessThanOrEqual(VALUE_LIMIT);
195
+ }
196
+ const loaded = await t.query(load, queryArgs);
197
+ expect(getConvexSize(loaded)).toBeLessThanOrEqual(VALUE_LIMIT);
198
+ expect(loaded).toEqual({ ...reserved, initialBasis });
199
+ expect(h.fetchCalls()).toBe(0);
200
+ return {
201
+ fixture: h,
202
+ t,
203
+ physical,
204
+ args,
205
+ queryArgs,
206
+ initialBasis,
207
+ receipt,
208
+ boundRows,
209
+ reservation: acquired.reservation,
210
+ loaded,
211
+ };
212
+ }
213
+
214
+ async function historyFixture() {
215
+ const h = await boundOperation();
216
+ const datum = {
217
+ event: "dispatch",
218
+ stage: "attach",
219
+ request: h.fixture.request,
220
+ };
221
+ const event = await canonicalJournalEvent(1, canonical(datum));
222
+ expect(JSON.parse(event.json)).toEqual(datum);
223
+ const appendArgs = {
224
+ reservation: h.reservation,
225
+ expectedSequence: 0,
226
+ event: { sequence: 1, binding: event.binding, dataJSON: event.json },
227
+ };
228
+ expect(getConvexSize(appendArgs)).toBeLessThanOrEqual(VALUE_LIMIT);
229
+ const appended = await h.t.mutation(append, appendArgs);
230
+ expect(getConvexSize(appended)).toBeLessThanOrEqual(VALUE_LIMIT);
231
+ const descriptor = {
232
+ operationId: h.args.operationId,
233
+ attemptId: h.args.attemptId,
234
+ stage: "attach",
235
+ sourcePayloadId: h.reservation.payloadId,
236
+ sequence: 1,
237
+ binding: event.binding,
238
+ payloadId: appended.payloadId,
239
+ eventId: appended.eventId,
240
+ };
241
+ expect(appended).toEqual({ ...descriptor, reservation: h.reservation });
242
+ const rows = await h.physical();
243
+ expect(rows.operations).toEqual(h.boundRows.operations);
244
+ expect(rows.attempts).toEqual([
245
+ { ...h.boundRows.attempts[0], lastSequence: 1 },
246
+ ]);
247
+ expect(rows.payloads).toHaveLength(2);
248
+ expect(rows.events).toHaveLength(1);
249
+ expect(
250
+ rows.payloads.find((row) => row._id === h.reservation.payloadId),
251
+ ).toEqual(h.boundRows.payloads[0]);
252
+ const payload = rows.payloads.find((row) => row._id === appended.payloadId);
253
+ expect(payload).toBeDefined();
254
+ if (!payload) throw Error("BOUND_HISTORY_MISSING_REAL_PAYLOAD");
255
+ expect(payload).toEqual({
256
+ _id: appended.payloadId,
257
+ _creationTime: payload._creationTime,
258
+ codecVersion: 1,
259
+ json: event.json,
260
+ owner: {
261
+ kind: "event",
262
+ operationId: h.args.operationId,
263
+ attemptId: h.args.attemptId,
264
+ stage: "attach",
265
+ sequence: 1,
266
+ },
267
+ });
268
+ const owner = payload.owner;
269
+ if (!owner || owner.kind !== "event")
270
+ throw Error("BOUND_HISTORY_WRONG_OWNER");
271
+ expect(rows.events[0]).toEqual({
272
+ _id: appended.eventId,
273
+ _creationTime: rows.events[0]._creationTime,
274
+ operationId: descriptor.operationId,
275
+ attemptId: descriptor.attemptId,
276
+ stage: descriptor.stage,
277
+ sourcePayloadId: descriptor.sourcePayloadId,
278
+ sequence: 1,
279
+ binding: event.binding,
280
+ payloadId: descriptor.payloadId,
281
+ });
282
+ for (const group of Object.values(rows)) {
283
+ for (const row of group)
284
+ expect(getDocumentSize(row)).toBeLessThanOrEqual(VALUE_LIMIT);
285
+ }
286
+ const loaded = await h.t.query(load, h.queryArgs);
287
+ expect(getConvexSize(loaded)).toBeLessThanOrEqual(VALUE_LIMIT);
288
+ expect(loaded).toEqual(h.loaded);
289
+ const reserveArgs = {
290
+ operationId: h.args.operationId,
291
+ expectedRevision: 0,
292
+ stage: "attach" as const,
293
+ expectedRequestBinding: h.fixture.record.requestBinding,
294
+ recordJSON: h.fixture.recordJSON,
295
+ };
296
+ const createArgs = {
297
+ authorizationScope: h.fixture.record.authorization.scope,
298
+ logicalOperationId: h.fixture.record.logicalOperationId,
299
+ authorizationRevision: h.fixture.record.authorization.revision,
300
+ recordJSON: h.fixture.recordJSON,
301
+ };
302
+ const historyArgs = {
303
+ operationId: h.args.operationId,
304
+ attemptId: h.args.attemptId,
305
+ };
306
+ for (const args of [reserveArgs, createArgs, historyArgs])
307
+ expect(getConvexSize(args)).toBeLessThanOrEqual(VALUE_LIMIT);
308
+ for (const sequence of [1, 2]) {
309
+ expect(getConvexSize({ ...historyArgs, sequence })).toBeLessThanOrEqual(
310
+ VALUE_LIMIT,
311
+ );
312
+ }
313
+ expect(await h.physical()).toEqual(rows);
314
+ expect(h.fixture.fetchCalls()).toBe(0);
315
+ return {
316
+ ...h,
317
+ event,
318
+ appendArgs,
319
+ appended,
320
+ descriptor,
321
+ rows,
322
+ owner,
323
+ reserveArgs,
324
+ createArgs,
325
+ historyArgs,
326
+ };
327
+ }
328
+
329
+ it("BOUNDH01 reads full event DATA and preserves every stable duplicate response", async () => {
330
+ const h = await historyFixture();
331
+ let targetFailed = false;
332
+ try {
333
+ const results = await Promise.allSettled([
334
+ h.t.mutation(append, h.appendArgs),
335
+ h.t.query(manifest, h.historyArgs),
336
+ h.t.query(readEvent, { ...h.historyArgs, sequence: 1 }),
337
+ h.t.query(readEvent, { ...h.historyArgs, sequence: 2 }),
338
+ h.t.query(readACK, h.queryArgs),
339
+ h.t.query(load, h.queryArgs),
340
+ h.t.mutation(reserve, h.reserveArgs),
341
+ h.t.mutation(bind, h.args),
342
+ h.t.mutation(create, h.createArgs),
343
+ ]);
344
+ const values = results.map((result) => {
345
+ if (result.status !== "fulfilled") throw result.reason;
346
+ expect(getConvexSize(result.value)).toBeLessThanOrEqual(VALUE_LIMIT);
347
+ return result.value;
348
+ });
349
+ expect(values).toEqual([
350
+ h.appended,
351
+ { reservation: h.reservation, events: [h.descriptor] },
352
+ { ...h.descriptor, dataJSON: h.event.json },
353
+ null,
354
+ null,
355
+ h.loaded,
356
+ {
357
+ disposition: "existing",
358
+ committedRevision: 1,
359
+ reservation: h.reservation,
360
+ },
361
+ h.receipt,
362
+ { status: "existing", operationId: h.args.operationId },
363
+ ]);
364
+ } catch (error) {
365
+ targetFailed = true;
366
+ throw error;
367
+ } finally {
368
+ try {
369
+ expect(await h.physical()).toEqual(h.rows);
370
+ expect(h.fixture.fetchCalls()).toBe(0);
371
+ } catch (inspectionError) {
372
+ if (!targetFailed) throw inspectionError;
373
+ console.info("BOUNDH01_READONLY_INSPECTION_FAILED");
374
+ }
375
+ }
376
+ });
377
+
378
+ it.each(corruptions)(
379
+ "BOUNDH02 refuses %s corruption through all eight APIs without repair",
380
+ async (kind) => {
381
+ const h = await historyFixture();
382
+ let expected = h.rows;
383
+ if (kind === "owner-stage") {
384
+ const owner = { ...h.owner, stage: "configure" as const };
385
+ await h.t.run((ctx) =>
386
+ ctx.db.patch("renewalOperationPayloads", h.descriptor.payloadId, {
387
+ owner,
388
+ }),
389
+ );
390
+ expected = {
391
+ ...expected,
392
+ payloads: expected.payloads.map((row) =>
393
+ row._id === h.descriptor.payloadId ? { ...row, owner } : row,
394
+ ),
395
+ };
396
+ } else if (kind === "event-binding") {
397
+ const binding =
398
+ h.event.binding.slice(0, -1) +
399
+ (h.event.binding.endsWith("0") ? "1" : "0");
400
+ expect(binding).not.toBe(h.event.binding);
401
+ await h.t.run((ctx) =>
402
+ ctx.db.patch("renewalOperationEvents", h.descriptor.eventId, {
403
+ binding,
404
+ }),
405
+ );
406
+ expected = { ...expected, events: [{ ...expected.events[0], binding }] };
407
+ } else if (kind === "counter" || kind === "counter-zero") {
408
+ const lastSequence = kind === "counter" ? 2 : 0;
409
+ await h.t.run((ctx) =>
410
+ ctx.db.patch("renewalOperationAttempts", h.args.attemptId, {
411
+ lastSequence,
412
+ }),
413
+ );
414
+ expected = {
415
+ ...expected,
416
+ attempts: [{ ...expected.attempts[0], lastSequence }],
417
+ };
418
+ } else if (kind === "missing-basis") {
419
+ await h.t.run((ctx) =>
420
+ ctx.db.patch("renewalOperations", h.args.operationId, {
421
+ initialBasis: undefined,
422
+ }),
423
+ );
424
+ const { initialBasis: _basis, ...operation } = expected.operations[0];
425
+ void _basis;
426
+ expected = { ...expected, operations: [operation] };
427
+ }
428
+ const damaged = await h.physical();
429
+ expect(damaged).toEqual(expected);
430
+ for (const group of Object.values(damaged)) {
431
+ for (const row of group)
432
+ expect(getDocumentSize(row)).toBeLessThanOrEqual(VALUE_LIMIT);
433
+ }
434
+ let targetFailed = false;
435
+ try {
436
+ const settled = await Promise.allSettled([
437
+ h.t.query(load, h.queryArgs),
438
+ h.t.query(manifest, h.historyArgs),
439
+ h.t.query(readEvent, { ...h.historyArgs, sequence: 2 }),
440
+ h.t.query(readACK, h.queryArgs),
441
+ h.t.mutation(reserve, h.reserveArgs),
442
+ h.t.mutation(bind, h.args),
443
+ h.t.mutation(create, h.createArgs),
444
+ h.t.mutation(append, h.appendArgs),
445
+ ]);
446
+ console.info(
447
+ "BOUNDH02_SETTLEMENT",
448
+ JSON.stringify({
449
+ kind,
450
+ statuses: settled.map((result) => result.status),
451
+ }),
452
+ );
453
+ expect(settled).toEqual(
454
+ Array.from({ length: 8 }, () => ({
455
+ status: "rejected",
456
+ reason: expect.objectContaining({
457
+ message: "RENEWAL_JOURNAL_CONFLICT",
458
+ }),
459
+ })),
460
+ );
461
+ } catch (error) {
462
+ targetFailed = true;
463
+ throw error;
464
+ } finally {
465
+ try {
466
+ expect(await h.physical()).toEqual(damaged);
467
+ expect(h.fixture.fetchCalls()).toBe(0);
468
+ } catch (inspectionError) {
469
+ if (!targetFailed) throw inspectionError;
470
+ console.info("BOUNDH02_READONLY_INSPECTION_FAILED");
471
+ }
472
+ }
473
+ },
474
+ );