@fantastic.dev/better-stripe 0.104.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +100 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/transport.js +17 -2
- package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js +46 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts +25 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js +62 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +14 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js +17 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts +30 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js +224 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts +61 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js +73 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/mutations.d.ts +43 -43
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +47 -4
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/configure/transport.ts +31 -2
- package/src/client/billing/renewalAttach/internal/producer/configureFrontier.ts +92 -0
- package/src/client/billing/renewalAttach/internal/producer/configureJournalData.ts +84 -0
- package/src/client/billing/renewalAttach/internal/producer/configureJournalWork.ts +16 -0
- package/src/client/billing/renewalAttach/internal/producer/configureWrite.ts +317 -0
- package/src/client/billing/renewalAttach/internal/producer/configureWriteFactory.ts +88 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWrite.integration.test.ts +158 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +537 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +85 -2
|
@@ -22,6 +22,14 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
22
22
|
requestKey: string;
|
|
23
23
|
scopeKey: string;
|
|
24
24
|
}, Promise<{
|
|
25
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
26
|
+
retryable: false;
|
|
27
|
+
status: "conflict";
|
|
28
|
+
} | {
|
|
29
|
+
reason: "policy_invalid";
|
|
30
|
+
retryable: false;
|
|
31
|
+
status: "rejected";
|
|
32
|
+
} | {
|
|
25
33
|
operation: {
|
|
26
34
|
accountId: string;
|
|
27
35
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -32,14 +40,6 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
|
|
|
32
40
|
} | {
|
|
33
41
|
enabled: boolean;
|
|
34
42
|
status: "unchanged";
|
|
35
|
-
} | {
|
|
36
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
37
|
-
retryable: false;
|
|
38
|
-
status: "conflict";
|
|
39
|
-
} | {
|
|
40
|
-
reason: "policy_invalid";
|
|
41
|
-
retryable: false;
|
|
42
|
-
status: "rejected";
|
|
43
43
|
} | {
|
|
44
44
|
reason: "provider_pending";
|
|
45
45
|
retryable: true;
|
|
@@ -395,6 +395,14 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
395
395
|
requestKey: string;
|
|
396
396
|
scopeKey: string;
|
|
397
397
|
}, Promise<{
|
|
398
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
399
|
+
retryable: false;
|
|
400
|
+
status: "conflict";
|
|
401
|
+
} | {
|
|
402
|
+
reason: "policy_invalid";
|
|
403
|
+
retryable: false;
|
|
404
|
+
status: "rejected";
|
|
405
|
+
} | {
|
|
398
406
|
operation: {
|
|
399
407
|
accountId: string;
|
|
400
408
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -405,14 +413,6 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
|
|
|
405
413
|
} | {
|
|
406
414
|
enabled: boolean;
|
|
407
415
|
status: "unchanged";
|
|
408
|
-
} | {
|
|
409
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
410
|
-
retryable: false;
|
|
411
|
-
status: "conflict";
|
|
412
|
-
} | {
|
|
413
|
-
reason: "policy_invalid";
|
|
414
|
-
retryable: false;
|
|
415
|
-
status: "rejected";
|
|
416
416
|
} | {
|
|
417
417
|
reason: "provider_pending";
|
|
418
418
|
retryable: true;
|
|
@@ -595,6 +595,22 @@ export declare const startWorkflow: import("convex/server").RegisteredMutation<"
|
|
|
595
595
|
} & {
|
|
596
596
|
providerAction: string;
|
|
597
597
|
}, Promise<{
|
|
598
|
+
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
599
|
+
retryable: false;
|
|
600
|
+
status: "unknown";
|
|
601
|
+
} | {
|
|
602
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
603
|
+
retryable: false;
|
|
604
|
+
status: "conflict";
|
|
605
|
+
} | {
|
|
606
|
+
reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
|
|
607
|
+
retryable: false;
|
|
608
|
+
status: "rejected";
|
|
609
|
+
} | {
|
|
610
|
+
reason: "provider_pending";
|
|
611
|
+
retryable: true;
|
|
612
|
+
status: "not_ready";
|
|
613
|
+
} | {
|
|
598
614
|
operation: {
|
|
599
615
|
accountId: string;
|
|
600
616
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -611,7 +627,16 @@ export declare const startWorkflow: import("convex/server").RegisteredMutation<"
|
|
|
611
627
|
version: number;
|
|
612
628
|
};
|
|
613
629
|
status: "canceled";
|
|
614
|
-
}
|
|
630
|
+
}>>;
|
|
631
|
+
export declare const resumeWorkflow: import("convex/server").RegisteredMutation<"public", {
|
|
632
|
+
accountId: string;
|
|
633
|
+
definitionVersion: string;
|
|
634
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
635
|
+
providerApiVersion: string;
|
|
636
|
+
scopeKey: string;
|
|
637
|
+
stripeSubscriptionId: string;
|
|
638
|
+
version: number;
|
|
639
|
+
}, Promise<{
|
|
615
640
|
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
616
641
|
retryable: false;
|
|
617
642
|
status: "unknown";
|
|
@@ -627,16 +652,7 @@ export declare const startWorkflow: import("convex/server").RegisteredMutation<"
|
|
|
627
652
|
reason: "provider_pending";
|
|
628
653
|
retryable: true;
|
|
629
654
|
status: "not_ready";
|
|
630
|
-
}
|
|
631
|
-
export declare const resumeWorkflow: import("convex/server").RegisteredMutation<"public", {
|
|
632
|
-
accountId: string;
|
|
633
|
-
definitionVersion: string;
|
|
634
|
-
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
635
|
-
providerApiVersion: string;
|
|
636
|
-
scopeKey: string;
|
|
637
|
-
stripeSubscriptionId: string;
|
|
638
|
-
version: number;
|
|
639
|
-
}, Promise<{
|
|
655
|
+
} | {
|
|
640
656
|
operation: {
|
|
641
657
|
accountId: string;
|
|
642
658
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -653,22 +669,6 @@ export declare const resumeWorkflow: import("convex/server").RegisteredMutation<
|
|
|
653
669
|
version: number;
|
|
654
670
|
};
|
|
655
671
|
status: "canceled";
|
|
656
|
-
} | {
|
|
657
|
-
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
658
|
-
retryable: false;
|
|
659
|
-
status: "unknown";
|
|
660
|
-
} | {
|
|
661
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
662
|
-
retryable: false;
|
|
663
|
-
status: "conflict";
|
|
664
|
-
} | {
|
|
665
|
-
reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
|
|
666
|
-
retryable: false;
|
|
667
|
-
status: "rejected";
|
|
668
|
-
} | {
|
|
669
|
-
reason: "provider_pending";
|
|
670
|
-
retryable: true;
|
|
671
|
-
status: "not_ready";
|
|
672
672
|
}>>;
|
|
673
673
|
export declare const cancelWorkflow: import("convex/server").RegisteredMutation<"public", {
|
|
674
674
|
accountId: string;
|
|
@@ -2,14 +2,6 @@ import type { Infer } from "convex/values";
|
|
|
2
2
|
import type { MutationCtx } from "../_generated/server.js";
|
|
3
3
|
import { prepareArgs, finishPreparationArgs } from "./mutationValidators.js";
|
|
4
4
|
export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prepareArgs>): Promise<{
|
|
5
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
6
|
-
retryable: false;
|
|
7
|
-
status: "conflict";
|
|
8
|
-
} | {
|
|
9
|
-
reason: "policy_invalid";
|
|
10
|
-
retryable: false;
|
|
11
|
-
status: "rejected";
|
|
12
|
-
} | {
|
|
13
5
|
operation: {
|
|
14
6
|
accountId: string;
|
|
15
7
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -20,6 +12,14 @@ export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prep
|
|
|
20
12
|
} | {
|
|
21
13
|
enabled: boolean;
|
|
22
14
|
status: "unchanged";
|
|
15
|
+
} | {
|
|
16
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
17
|
+
retryable: false;
|
|
18
|
+
status: "conflict";
|
|
19
|
+
} | {
|
|
20
|
+
reason: "policy_invalid";
|
|
21
|
+
retryable: false;
|
|
22
|
+
status: "rejected";
|
|
23
23
|
} | {
|
|
24
24
|
reason: "provider_pending";
|
|
25
25
|
retryable: true;
|
|
@@ -180,11 +180,11 @@ export declare const findPreparationOperation: import("convex/server").Registere
|
|
|
180
180
|
retryable: false;
|
|
181
181
|
} | {
|
|
182
182
|
reason?: undefined;
|
|
183
|
-
retryable?: undefined;
|
|
184
183
|
accountId: string;
|
|
185
184
|
scopeKey: string;
|
|
186
185
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
187
186
|
version: number;
|
|
187
|
+
retryable?: undefined;
|
|
188
188
|
status?: undefined;
|
|
189
189
|
state: "canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown";
|
|
190
190
|
cancelRequested: boolean;
|
|
@@ -2632,14 +2632,6 @@ export declare function setupCredits(): Promise<{
|
|
|
2632
2632
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
2633
2633
|
requestKey: string;
|
|
2634
2634
|
result?: {
|
|
2635
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2636
|
-
retryable: false;
|
|
2637
|
-
status: "conflict";
|
|
2638
|
-
} | {
|
|
2639
|
-
reason: "policy_invalid";
|
|
2640
|
-
retryable: false;
|
|
2641
|
-
status: "rejected";
|
|
2642
|
-
} | {
|
|
2643
2635
|
operation: {
|
|
2644
2636
|
accountId: string;
|
|
2645
2637
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2650,6 +2642,14 @@ export declare function setupCredits(): Promise<{
|
|
|
2650
2642
|
} | {
|
|
2651
2643
|
enabled: boolean;
|
|
2652
2644
|
status: "unchanged";
|
|
2645
|
+
} | {
|
|
2646
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2647
|
+
retryable: false;
|
|
2648
|
+
status: "conflict";
|
|
2649
|
+
} | {
|
|
2650
|
+
reason: "policy_invalid";
|
|
2651
|
+
retryable: false;
|
|
2652
|
+
status: "rejected";
|
|
2653
2653
|
} | {
|
|
2654
2654
|
reason: "provider_pending";
|
|
2655
2655
|
retryable: true;
|
|
@@ -2660,14 +2660,6 @@ export declare function setupCredits(): Promise<{
|
|
|
2660
2660
|
payload: import("convex/values").VString<string, "required">;
|
|
2661
2661
|
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
2662
2662
|
result: import("convex/values").VUnion<{
|
|
2663
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2664
|
-
retryable: false;
|
|
2665
|
-
status: "conflict";
|
|
2666
|
-
} | {
|
|
2667
|
-
reason: "policy_invalid";
|
|
2668
|
-
retryable: false;
|
|
2669
|
-
status: "rejected";
|
|
2670
|
-
} | {
|
|
2671
2663
|
operation: {
|
|
2672
2664
|
accountId: string;
|
|
2673
2665
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2678,6 +2670,14 @@ export declare function setupCredits(): Promise<{
|
|
|
2678
2670
|
} | {
|
|
2679
2671
|
enabled: boolean;
|
|
2680
2672
|
status: "unchanged";
|
|
2673
|
+
} | {
|
|
2674
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2675
|
+
retryable: false;
|
|
2676
|
+
status: "conflict";
|
|
2677
|
+
} | {
|
|
2678
|
+
reason: "policy_invalid";
|
|
2679
|
+
retryable: false;
|
|
2680
|
+
status: "rejected";
|
|
2681
2681
|
} | {
|
|
2682
2682
|
reason: "provider_pending";
|
|
2683
2683
|
retryable: true;
|
|
@@ -263,7 +263,7 @@ call.
|
|
|
263
263
|
|
|
264
264
|
The result is an opaque private view containing `owner`, `basisJSON` and
|
|
265
265
|
`operationalAuthority: false`. The separate private C10 factory below can use
|
|
266
|
-
that identity. Configure
|
|
266
|
+
that identity. Configure recovery actors and public scheduling
|
|
267
267
|
remain required, as do genuine generation and operational qualification.
|
|
268
268
|
Production Source profile arrays remain empty.
|
|
269
269
|
|
|
@@ -299,9 +299,9 @@ a committed response or receipt event, and a retained C9 do not establish provid
|
|
|
299
299
|
custody, returned configure ACK custody, pending/effective replacement or fresh
|
|
300
300
|
dispatch permission. Receipt retention remains a separate operation; a future
|
|
301
301
|
configure completion pipeline must retain the complete C9 before publishing
|
|
302
|
-
receipt event 3 and returning its actual acknowledgement.
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
receipt event 3 and returning its actual acknowledgement. Execution requires its
|
|
303
|
+
own frontier checks. This channel factory supplies no provider transport and
|
|
304
|
+
activates no operational Source profile.
|
|
305
305
|
|
|
306
306
|
## Private admitted configure preflight
|
|
307
307
|
|
|
@@ -335,6 +335,49 @@ the actor. The legacy preflight functions retain their original Owner checks
|
|
|
335
335
|
around shared DATA kernels. This readonly consistency result grants no configure
|
|
336
336
|
POST permission, returned configure ACK custody or public scheduling support.
|
|
337
337
|
|
|
338
|
+
## Private admitted configure write
|
|
339
|
+
|
|
340
|
+
`captureAdmittedConfigureWrite(token)` captures one initial write actor from the
|
|
341
|
+
actual completed preflight view. It retains the actual parent ACK, original
|
|
342
|
+
profile entry and preflight predicate pointers. A unique compiled write entry
|
|
343
|
+
must link to that original entry, and its predicate identity remains fixed.
|
|
344
|
+
Copied tokens, output DATA, pending preflight and replacement arguments cannot
|
|
345
|
+
supply custody. Production profile arrays remain empty.
|
|
346
|
+
|
|
347
|
+
The write transport preserves the legacy POST latch and quarantine kernel while
|
|
348
|
+
using the admitted child's original parent Owner and stock SDK delegate. It
|
|
349
|
+
performs its own fixed fresh GET sequence. The separate readonly preflight output
|
|
350
|
+
cannot mark this pair's read generation complete. Current reads and a fresh C6
|
|
351
|
+
reconstruction must still match the retained request exactly, including its key,
|
|
352
|
+
first-dispatch time, path, payload and API version.
|
|
353
|
+
|
|
354
|
+
Before dispatch intent, the actor checks the complete head-zero frontier. It
|
|
355
|
+
awaits the actual committed dispatch event 1 and C10 ACK, then checks full stored
|
|
356
|
+
event DATA, basis, absent acknowledgement, idle journal work and exact head one
|
|
357
|
+
before POST. Each invocation permits at most one POST, with the retained key and
|
|
358
|
+
zero retries. These checks are bounded read fences, not an atomic writer lock.
|
|
359
|
+
The transport marks uncertainty before calling the stock delegate. Synchronous
|
|
360
|
+
throws or non-Promise results cannot establish a proven provider rejection.
|
|
361
|
+
|
|
362
|
+
Fulfillment enters quarantine before response inspection or Owner checks. Only
|
|
363
|
+
safe captured response DATA can publish event 2. After actual C9 construction,
|
|
364
|
+
the actor records the receipt as known, durably retains its complete canonical
|
|
365
|
+
JSON at head two, validates the complete retention reply and reads it back.
|
|
366
|
+
Retention precedes whole-output admission and receipt event 3. Output refusal,
|
|
367
|
+
pending or rejected persistence replies, or failed event-3 publication cannot
|
|
368
|
+
permit another POST or establish a returned ACK. A private live attempt view
|
|
369
|
+
retains immutable actual C9/input DATA and POST disposition independently of the
|
|
370
|
+
returned ACK view. Copied tokens cannot read it, and the view grants no replay
|
|
371
|
+
or dispatch permission.
|
|
372
|
+
|
|
373
|
+
`readAdmittedConfigureAcknowledgement(token)` returns custody only after receipt
|
|
374
|
+
event 3 commits, its actual C10 ACK returns and the final complete history and
|
|
375
|
+
retention fence passes. The view retains the exact returned output and its
|
|
376
|
+
receipt/raw-receipt identities. A final guard precedes quarantine discard with
|
|
377
|
+
no intervening callback or Owner sample. Late fulfillment after retirement stays
|
|
378
|
+
unknown and cannot publish ACK custody. This initial-write path supplies no
|
|
379
|
+
replay, resumption, public scheduling entrypoint or pending/effective claim.
|
|
380
|
+
|
|
338
381
|
## Component operation journal
|
|
339
382
|
|
|
340
383
|
The component's `renewalOperations` functions retain host-authorized operation
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
2
|
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { captureAdmittedConfigureWriteFrame } from "../producer/configureWriteFactory.js";
|
|
3
4
|
import { closed } from "../operations/types.js";
|
|
4
5
|
import { equal } from "../../../renewalAggregate/shared.js";
|
|
5
6
|
import {
|
|
@@ -34,6 +35,13 @@ function build(load: () => unknown) {
|
|
|
34
35
|
OWNER.check();
|
|
35
36
|
const raw = load();
|
|
36
37
|
OWNER.check();
|
|
38
|
+
return configureWriteKernel(raw, OWNER);
|
|
39
|
+
}
|
|
40
|
+
function configureWriteKernel(
|
|
41
|
+
raw: unknown,
|
|
42
|
+
owner: typeof OWNER,
|
|
43
|
+
guard?: () => void,
|
|
44
|
+
) {
|
|
37
45
|
need(!types.isProxy(raw));
|
|
38
46
|
const frame = closed(raw, [
|
|
39
47
|
"owner",
|
|
@@ -42,7 +50,7 @@ function build(load: () => unknown) {
|
|
|
42
50
|
"readPlan",
|
|
43
51
|
"delegate",
|
|
44
52
|
]);
|
|
45
|
-
need(frame.owner ===
|
|
53
|
+
need(frame.owner === owner);
|
|
46
54
|
const operation = frame.operation,
|
|
47
55
|
readPlanReference = frame.readPlan,
|
|
48
56
|
delegate = frame.delegate;
|
|
@@ -77,7 +85,9 @@ function build(load: () => unknown) {
|
|
|
77
85
|
}
|
|
78
86
|
checking = true;
|
|
79
87
|
try {
|
|
80
|
-
|
|
88
|
+
guard?.();
|
|
89
|
+
owner.check();
|
|
90
|
+
guard?.();
|
|
81
91
|
if (closedOwner) stop();
|
|
82
92
|
} catch {
|
|
83
93
|
closedOwner = true;
|
|
@@ -346,3 +356,22 @@ export function createConfigureReplayTransport() {
|
|
|
346
356
|
need(arguments.length === 0);
|
|
347
357
|
return build(loadConfigureReplayTransportSource);
|
|
348
358
|
}
|
|
359
|
+
|
|
360
|
+
/** Actual completed preflight custody only; no caller-supplied frame or Owner. */
|
|
361
|
+
export function createAdmittedConfigureWriteTransport(token: object) {
|
|
362
|
+
const source = captureAdmittedConfigureWriteFrame(token, arguments.length);
|
|
363
|
+
const pair = configureWriteKernel(source.frame, source.owner, source.guard);
|
|
364
|
+
need(
|
|
365
|
+
pair.capability.assertSourceOperationBinding(
|
|
366
|
+
token,
|
|
367
|
+
source.record.request,
|
|
368
|
+
source.frame.readPlan,
|
|
369
|
+
source.frame.delegate,
|
|
370
|
+
source.frame.delegate.rawRequest,
|
|
371
|
+
source.expected,
|
|
372
|
+
),
|
|
373
|
+
);
|
|
374
|
+
need(pair.capability.reserveAcquisition());
|
|
375
|
+
source.guard();
|
|
376
|
+
return Object.freeze({ ...pair, ...source });
|
|
377
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { canonicalJournalEvent } from "../../../../../shared/renewalOperationJournal.js";
|
|
2
|
+
import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
|
|
3
|
+
import {
|
|
4
|
+
captureConfigureHistory,
|
|
5
|
+
checkConfigureRetention,
|
|
6
|
+
object,
|
|
7
|
+
} from "./configureJournalData.js";
|
|
1
8
|
import { readConfigureLineage } from "./configureLineage.js";
|
|
2
9
|
import { ownedAwaitForInitialLineage } from "./ownedAwaitFactory.js";
|
|
3
10
|
import { journalWorkForConfigureLineage } from "./configureJournalWork.js";
|
|
@@ -38,3 +45,88 @@ export async function assertConfigurePreflightFrontier(token: object) {
|
|
|
38
45
|
requireConfigure(work.idle());
|
|
39
46
|
readConfigureLineage(token);
|
|
40
47
|
}
|
|
48
|
+
|
|
49
|
+
/** Fixed expected event DATA from the actor, verified against full stored events. */
|
|
50
|
+
export async function assertConfigureWriteFrontier(
|
|
51
|
+
token: object,
|
|
52
|
+
expectedEvents: readonly unknown[],
|
|
53
|
+
known: {
|
|
54
|
+
receiptJSON: string;
|
|
55
|
+
receiptBinding: string;
|
|
56
|
+
retention: ReturnType<typeof checkConfigureRetention>;
|
|
57
|
+
} | null = null,
|
|
58
|
+
) {
|
|
59
|
+
const lineage = readConfigureLineage(token),
|
|
60
|
+
work = journalWorkForConfigureLineage(token);
|
|
61
|
+
const owned = ownedAwaitForInitialLineage(lineage.parentToken);
|
|
62
|
+
async function checked<T>(call: () => T | PromiseLike<T>) {
|
|
63
|
+
readConfigureLineage(token);
|
|
64
|
+
requireConfigure(work.idle());
|
|
65
|
+
const reply = await owned(call);
|
|
66
|
+
readConfigureLineage(token);
|
|
67
|
+
requireConfigure(work.idle());
|
|
68
|
+
return reply;
|
|
69
|
+
}
|
|
70
|
+
const canonical = [];
|
|
71
|
+
for (let i = 0; i < expectedEvents.length; i++) {
|
|
72
|
+
requireConfigure(i < 3);
|
|
73
|
+
canonical.push(
|
|
74
|
+
await checked(() =>
|
|
75
|
+
canonicalJournalEvent(
|
|
76
|
+
i + 1,
|
|
77
|
+
JSON.stringify(renewalSnapshot(expectedEvents[i])),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
checkOperationLoad(
|
|
83
|
+
await checked(() => lineage.journal.loadAuthorizedOperation()),
|
|
84
|
+
lineage.reservation,
|
|
85
|
+
lineage.parent.basisJSON,
|
|
86
|
+
);
|
|
87
|
+
const history = await checked(() =>
|
|
88
|
+
lineage.journal.readAttempt({ attemptId: lineage.reservation.attemptId }),
|
|
89
|
+
);
|
|
90
|
+
const events = captureConfigureHistory(
|
|
91
|
+
history,
|
|
92
|
+
lineage.reservation,
|
|
93
|
+
canonical.length,
|
|
94
|
+
);
|
|
95
|
+
for (let i = 0; i < events.length; i++) {
|
|
96
|
+
requireConfigure(events[i].binding === canonical[i].binding);
|
|
97
|
+
matchConfigureDATA(
|
|
98
|
+
await checked(() =>
|
|
99
|
+
lineage.journal.readStageEvent({
|
|
100
|
+
attemptId: lineage.reservation.attemptId,
|
|
101
|
+
sequence: i === 0 ? 1 : i === 1 ? 2 : 3,
|
|
102
|
+
}),
|
|
103
|
+
),
|
|
104
|
+
{ ...events[i], dataJSON: canonical[i].json },
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const ack = await checked(() =>
|
|
108
|
+
lineage.journal.readProviderAcknowledgement(),
|
|
109
|
+
);
|
|
110
|
+
if (known) {
|
|
111
|
+
const own = object(ack);
|
|
112
|
+
matchConfigureDATA(own.retention, known.retention);
|
|
113
|
+
checkConfigureRetention(
|
|
114
|
+
own.retention,
|
|
115
|
+
lineage.reservation,
|
|
116
|
+
events,
|
|
117
|
+
known.receiptBinding,
|
|
118
|
+
);
|
|
119
|
+
matchConfigureDATA(ack, {
|
|
120
|
+
retention: own.retention,
|
|
121
|
+
receiptJSON: known.receiptJSON,
|
|
122
|
+
});
|
|
123
|
+
} else matchConfigureDATA(ack, null);
|
|
124
|
+
// Final complete head read follows ACK and event inspection. This is not a lock.
|
|
125
|
+
matchConfigureDATA(
|
|
126
|
+
await checked(() =>
|
|
127
|
+
lineage.journal.readAttempt({ attemptId: lineage.reservation.attemptId }),
|
|
128
|
+
),
|
|
129
|
+
{ reservation: lineage.reservation, events },
|
|
130
|
+
);
|
|
131
|
+
return events;
|
|
132
|
+
}
|
|
@@ -246,3 +246,87 @@ export function checkParentAcknowledgement(
|
|
|
246
246
|
},
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
+
|
|
250
|
+
/** Complete bounded configure history descriptors, without promoting DATA to custody. */
|
|
251
|
+
export function captureConfigureHistory(
|
|
252
|
+
raw: unknown,
|
|
253
|
+
reservation: OperationalReservationDATA,
|
|
254
|
+
count: number,
|
|
255
|
+
) {
|
|
256
|
+
const own = closed(raw, ["reservation", "events"]);
|
|
257
|
+
requireConfigure(
|
|
258
|
+
Number.isInteger(count) &&
|
|
259
|
+
count >= 1 &&
|
|
260
|
+
count <= 3 &&
|
|
261
|
+
!types.isProxy(own.events) &&
|
|
262
|
+
Array.isArray(own.events) &&
|
|
263
|
+
Object.getPrototypeOf(own.events) === Array.prototype &&
|
|
264
|
+
own.events.length === count,
|
|
265
|
+
);
|
|
266
|
+
const events = Array.from({ length: count }, (_, index) => {
|
|
267
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
268
|
+
own.events,
|
|
269
|
+
String(index),
|
|
270
|
+
);
|
|
271
|
+
requireConfigure(
|
|
272
|
+
descriptor && descriptor.enumerable && "value" in descriptor,
|
|
273
|
+
);
|
|
274
|
+
const event = closed(descriptor.value, [
|
|
275
|
+
"operationId",
|
|
276
|
+
"attemptId",
|
|
277
|
+
"stage",
|
|
278
|
+
"sourcePayloadId",
|
|
279
|
+
"sequence",
|
|
280
|
+
"binding",
|
|
281
|
+
"payloadId",
|
|
282
|
+
"eventId",
|
|
283
|
+
]);
|
|
284
|
+
return {
|
|
285
|
+
operationId: reservation.operationId,
|
|
286
|
+
attemptId: reservation.attemptId,
|
|
287
|
+
stage: "configure" as const,
|
|
288
|
+
sourcePayloadId: reservation.payloadId,
|
|
289
|
+
sequence: index + 1,
|
|
290
|
+
binding: text(event.binding),
|
|
291
|
+
payloadId: text(event.payloadId),
|
|
292
|
+
eventId: text(event.eventId),
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
requireConfigure(
|
|
296
|
+
new Set(events.map((e) => e.eventId)).size === count &&
|
|
297
|
+
new Set(events.map((e) => e.payloadId)).size === count &&
|
|
298
|
+
events.every((e) => e.payloadId !== reservation.payloadId),
|
|
299
|
+
);
|
|
300
|
+
matchConfigureDATA(raw, { reservation, events });
|
|
301
|
+
return events;
|
|
302
|
+
}
|
|
303
|
+
export function checkConfigureRetention(
|
|
304
|
+
raw: unknown,
|
|
305
|
+
reservation: OperationalReservationDATA,
|
|
306
|
+
events: ReturnType<typeof captureConfigureHistory>,
|
|
307
|
+
receiptBinding: string,
|
|
308
|
+
) {
|
|
309
|
+
requireConfigure(events.length >= 2);
|
|
310
|
+
const own = object(raw),
|
|
311
|
+
receiptPayloadId = text(own.receiptPayloadId);
|
|
312
|
+
requireConfigure(
|
|
313
|
+
receiptPayloadId !== reservation.payloadId &&
|
|
314
|
+
!events.some((event) => event.payloadId === receiptPayloadId),
|
|
315
|
+
);
|
|
316
|
+
const expected = {
|
|
317
|
+
status: "retained" as const,
|
|
318
|
+
operationId: reservation.operationId,
|
|
319
|
+
schemaVersion: 1 as const,
|
|
320
|
+
stage: "configure" as const,
|
|
321
|
+
attemptId: reservation.attemptId,
|
|
322
|
+
sourcePayloadId: reservation.payloadId,
|
|
323
|
+
dispatchEventId: events[0].eventId,
|
|
324
|
+
dispatchPayloadId: events[0].payloadId,
|
|
325
|
+
responseEventId: events[1].eventId,
|
|
326
|
+
responsePayloadId: events[1].payloadId,
|
|
327
|
+
receiptPayloadId,
|
|
328
|
+
receiptBinding,
|
|
329
|
+
};
|
|
330
|
+
matchConfigureDATA(raw, expected);
|
|
331
|
+
return expected;
|
|
332
|
+
}
|
|
@@ -33,6 +33,22 @@ function construct(token: object) {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
},
|
|
36
|
+
async retain(receiptJSON: string) {
|
|
37
|
+
requireConfigure(arguments.length === 1);
|
|
38
|
+
gate();
|
|
39
|
+
pending++;
|
|
40
|
+
try {
|
|
41
|
+
const reply = await original.journal.retainProviderAcknowledgement({
|
|
42
|
+
attemptId: original.reservation.attemptId,
|
|
43
|
+
expectedSequence: 2,
|
|
44
|
+
receiptJSON,
|
|
45
|
+
});
|
|
46
|
+
gate();
|
|
47
|
+
return reply;
|
|
48
|
+
} finally {
|
|
49
|
+
pending--;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
36
52
|
idle() {
|
|
37
53
|
requireConfigure(arguments.length === 0);
|
|
38
54
|
gate();
|