@fantastic.dev/better-stripe 0.90.0 → 0.91.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/acquisition/ownedAcquisition.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +454 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +26 -8
- package/docs/renewal-material-observation.md +37 -0
- package/docs/renewal-phase-assembly.md +68 -0
- package/docs/renewal-raw-acquisition.md +19 -5
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
- package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
- package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
- package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
- package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
- package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
- package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
- package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
- package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
- package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
- package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
- package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
- package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
- package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
- package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
- package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
- package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
- package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
- package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
- package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
- package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
- package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
- package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
- package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
- package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
- package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
- package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
- package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
- package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
- package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
- package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
- package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
- package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { OWNER } from "../originalOwner.js";
|
|
3
|
+
import { closed } from "../operations/types.js";
|
|
4
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
5
|
+
import {
|
|
6
|
+
loadConfigureWriteTransportSource,
|
|
7
|
+
loadConfigureReplayTransportSource,
|
|
8
|
+
} from "../operations/sourceOperations.js";
|
|
9
|
+
import { captureConfigureRequest } from "./output.js";
|
|
10
|
+
import { captureConfigureReply, configureDiagnostics } from "./capture.js";
|
|
11
|
+
import {
|
|
12
|
+
capturePlan,
|
|
13
|
+
samePlan,
|
|
14
|
+
ownMethod,
|
|
15
|
+
need,
|
|
16
|
+
stop,
|
|
17
|
+
type Row,
|
|
18
|
+
} from "./request.js";
|
|
19
|
+
import type { Diagnostics } from "../operations/providerFailure.js";
|
|
20
|
+
|
|
21
|
+
type Fact = Readonly<{
|
|
22
|
+
phase: "read" | "post";
|
|
23
|
+
resource: string;
|
|
24
|
+
ordinal: number;
|
|
25
|
+
diagnostics: Diagnostics;
|
|
26
|
+
}>;
|
|
27
|
+
export type Disposition =
|
|
28
|
+
| "NOT_STARTED"
|
|
29
|
+
| "PENDING"
|
|
30
|
+
| "REJECTED"
|
|
31
|
+
| "FULFILLED_UNVERIFIED"
|
|
32
|
+
| "FULFILLED_SAFE";
|
|
33
|
+
function build(load: () => unknown) {
|
|
34
|
+
OWNER.check();
|
|
35
|
+
const raw = load();
|
|
36
|
+
OWNER.check();
|
|
37
|
+
need(!types.isProxy(raw));
|
|
38
|
+
const frame = closed(raw, [
|
|
39
|
+
"owner",
|
|
40
|
+
"operation",
|
|
41
|
+
"request",
|
|
42
|
+
"readPlan",
|
|
43
|
+
"delegate",
|
|
44
|
+
]);
|
|
45
|
+
need(frame.owner === OWNER);
|
|
46
|
+
const operation = frame.operation,
|
|
47
|
+
readPlanReference = frame.readPlan,
|
|
48
|
+
delegate = frame.delegate;
|
|
49
|
+
const request = captureConfigureRequest(frame.request),
|
|
50
|
+
plan = capturePlan(readPlanReference),
|
|
51
|
+
method = ownMethod(delegate, "rawRequest"),
|
|
52
|
+
generation = Object.freeze({});
|
|
53
|
+
let phase = "unused",
|
|
54
|
+
index = 0,
|
|
55
|
+
closedOwner = false,
|
|
56
|
+
checking = false,
|
|
57
|
+
dispatching = false,
|
|
58
|
+
postState: Disposition = "NOT_STARTED";
|
|
59
|
+
type Attempt = Readonly<{
|
|
60
|
+
generation: object;
|
|
61
|
+
ordinal: number;
|
|
62
|
+
phase: "read" | "post";
|
|
63
|
+
resource: string;
|
|
64
|
+
promise: Promise<unknown>;
|
|
65
|
+
}>;
|
|
66
|
+
let pending: Attempt | null = null,
|
|
67
|
+
readCatch: { attempt: Attempt; fact: Fact } | null = null,
|
|
68
|
+
lastRead: Attempt | null = null,
|
|
69
|
+
postAttempt: Attempt | null = null;
|
|
70
|
+
const postCatches = new WeakMap<object, { attempt: Attempt; fact: Fact }>(),
|
|
71
|
+
notStarted = new WeakSet<object>();
|
|
72
|
+
let _quarantine: { attempt: Attempt; raw: unknown } | null = null;
|
|
73
|
+
function gate() {
|
|
74
|
+
if (closedOwner || checking) {
|
|
75
|
+
closedOwner = true;
|
|
76
|
+
stop();
|
|
77
|
+
}
|
|
78
|
+
checking = true;
|
|
79
|
+
try {
|
|
80
|
+
OWNER.check();
|
|
81
|
+
if (closedOwner) stop();
|
|
82
|
+
} catch {
|
|
83
|
+
closedOwner = true;
|
|
84
|
+
stop();
|
|
85
|
+
} finally {
|
|
86
|
+
checking = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const live = () => {
|
|
90
|
+
try {
|
|
91
|
+
gate();
|
|
92
|
+
return true;
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const valid = (a: Attempt) => pending === a && a.generation === generation;
|
|
98
|
+
function start(kind: "read" | "post", resource: string, args: unknown[]) {
|
|
99
|
+
need(pending === null && !dispatching);
|
|
100
|
+
// A synchronous throw or non-Promise result is not an actual asynchronous catch.
|
|
101
|
+
let promise: unknown;
|
|
102
|
+
dispatching = true;
|
|
103
|
+
try {
|
|
104
|
+
promise = Reflect.apply(method, delegate, args);
|
|
105
|
+
} finally {
|
|
106
|
+
dispatching = false;
|
|
107
|
+
}
|
|
108
|
+
need(types.isPromise(promise));
|
|
109
|
+
const attempt = Object.freeze({
|
|
110
|
+
generation,
|
|
111
|
+
ordinal: index + 1,
|
|
112
|
+
phase: kind,
|
|
113
|
+
resource,
|
|
114
|
+
promise: promise as Promise<unknown>,
|
|
115
|
+
});
|
|
116
|
+
need(attempt.ordinal <= (kind === "read" ? 44 : 45));
|
|
117
|
+
pending = attempt;
|
|
118
|
+
return attempt;
|
|
119
|
+
}
|
|
120
|
+
const readTransport = Object.freeze({
|
|
121
|
+
async rawRequest(
|
|
122
|
+
verb: "GET",
|
|
123
|
+
path: string,
|
|
124
|
+
body: undefined,
|
|
125
|
+
options: unknown,
|
|
126
|
+
): Promise<unknown> {
|
|
127
|
+
need(arguments.length === 4);
|
|
128
|
+
gate();
|
|
129
|
+
need(
|
|
130
|
+
phase === "reserved" &&
|
|
131
|
+
pending === null &&
|
|
132
|
+
!dispatching &&
|
|
133
|
+
index < plan.length,
|
|
134
|
+
);
|
|
135
|
+
const row = plan[index];
|
|
136
|
+
need(!types.isProxy(options));
|
|
137
|
+
const o = closed(options, ["apiVersion", "maxNetworkRetries"]);
|
|
138
|
+
need(
|
|
139
|
+
verb === row.method &&
|
|
140
|
+
path === row.path &&
|
|
141
|
+
body === undefined &&
|
|
142
|
+
o.apiVersion === row.options.apiVersion &&
|
|
143
|
+
o.maxNetworkRetries === 0,
|
|
144
|
+
);
|
|
145
|
+
const a = start("read", row.resource, [verb, path, body, row.options]);
|
|
146
|
+
let reply: unknown;
|
|
147
|
+
try {
|
|
148
|
+
reply = await a.promise;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
phase = "failed";
|
|
151
|
+
lastRead = a;
|
|
152
|
+
if (live() && valid(a))
|
|
153
|
+
readCatch = {
|
|
154
|
+
attempt: a,
|
|
155
|
+
fact: Object.freeze({
|
|
156
|
+
phase: "read",
|
|
157
|
+
resource: a.resource,
|
|
158
|
+
ordinal: a.ordinal,
|
|
159
|
+
diagnostics: configureDiagnostics(error),
|
|
160
|
+
}),
|
|
161
|
+
};
|
|
162
|
+
pending = null;
|
|
163
|
+
return stop();
|
|
164
|
+
}
|
|
165
|
+
gate();
|
|
166
|
+
need(valid(a));
|
|
167
|
+
pending = null;
|
|
168
|
+
index++;
|
|
169
|
+
if (index === plan.length) phase = "readclosed";
|
|
170
|
+
return reply;
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
const transport = Object.freeze({
|
|
174
|
+
readTransport,
|
|
175
|
+
postDisposition(): Disposition {
|
|
176
|
+
need(arguments.length === 0);
|
|
177
|
+
return postState;
|
|
178
|
+
},
|
|
179
|
+
async postConfigure() {
|
|
180
|
+
need(arguments.length === 0);
|
|
181
|
+
if (
|
|
182
|
+
phase !== "readclosed" ||
|
|
183
|
+
pending !== null ||
|
|
184
|
+
postState !== "NOT_STARTED" ||
|
|
185
|
+
!live()
|
|
186
|
+
) {
|
|
187
|
+
const reply = Object.freeze({ outcome: "not_started" as const });
|
|
188
|
+
notStarted.add(reply);
|
|
189
|
+
return reply;
|
|
190
|
+
}
|
|
191
|
+
phase = "posting";
|
|
192
|
+
// Mark mutation uncertainty before invoking the actual stock delegate.
|
|
193
|
+
postState = "PENDING";
|
|
194
|
+
let a: Attempt;
|
|
195
|
+
try {
|
|
196
|
+
a = start("post", "configure", [
|
|
197
|
+
request.method,
|
|
198
|
+
request.path,
|
|
199
|
+
request.payload,
|
|
200
|
+
{
|
|
201
|
+
apiVersion: request.apiVersion,
|
|
202
|
+
idempotencyKey: request.key,
|
|
203
|
+
maxNetworkRetries: 0,
|
|
204
|
+
},
|
|
205
|
+
]);
|
|
206
|
+
} catch {
|
|
207
|
+
phase = "failed";
|
|
208
|
+
return Object.freeze({ outcome: "post_unknown" as const });
|
|
209
|
+
}
|
|
210
|
+
postAttempt = a;
|
|
211
|
+
let reply: unknown;
|
|
212
|
+
try {
|
|
213
|
+
reply = await a.promise;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
postState = "REJECTED";
|
|
216
|
+
phase = "failed";
|
|
217
|
+
const record = Object.freeze({ outcome: "provider_rejected" as const });
|
|
218
|
+
if (live() && valid(a))
|
|
219
|
+
postCatches.set(record, {
|
|
220
|
+
attempt: a,
|
|
221
|
+
fact: Object.freeze({
|
|
222
|
+
phase: "post",
|
|
223
|
+
resource: "configure",
|
|
224
|
+
ordinal: a.ordinal,
|
|
225
|
+
diagnostics: configureDiagnostics(error),
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
pending = null;
|
|
229
|
+
return record;
|
|
230
|
+
}
|
|
231
|
+
if (valid(a) && postAttempt === a)
|
|
232
|
+
_quarantine = { attempt: a, raw: reply };
|
|
233
|
+
postState = "FULFILLED_UNVERIFIED";
|
|
234
|
+
phase = "fulfilled";
|
|
235
|
+
try {
|
|
236
|
+
gate();
|
|
237
|
+
need(valid(a));
|
|
238
|
+
const admitted = captureConfigureReply(reply);
|
|
239
|
+
gate();
|
|
240
|
+
pending = null;
|
|
241
|
+
postState = "FULFILLED_SAFE";
|
|
242
|
+
return Object.freeze({
|
|
243
|
+
outcome: "fulfilled_safe" as const,
|
|
244
|
+
body: admitted.body,
|
|
245
|
+
transport: admitted.transport,
|
|
246
|
+
});
|
|
247
|
+
} catch {
|
|
248
|
+
pending = null;
|
|
249
|
+
return Object.freeze({ outcome: "fulfilled_unverified" as const });
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
const capability = Object.freeze({
|
|
254
|
+
assertSourceOperationBinding(
|
|
255
|
+
actualOperation: unknown,
|
|
256
|
+
originalRequest: unknown,
|
|
257
|
+
actualReadPlan: unknown,
|
|
258
|
+
actualDelegate: unknown,
|
|
259
|
+
originalMethod: unknown,
|
|
260
|
+
expected: readonly Row[],
|
|
261
|
+
) {
|
|
262
|
+
need(arguments.length === 6);
|
|
263
|
+
gate();
|
|
264
|
+
if (
|
|
265
|
+
phase !== "unused" ||
|
|
266
|
+
operation !== actualOperation ||
|
|
267
|
+
actualReadPlan !== readPlanReference ||
|
|
268
|
+
actualDelegate !== delegate ||
|
|
269
|
+
originalMethod !== method
|
|
270
|
+
) {
|
|
271
|
+
phase = "invalid";
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
const matches =
|
|
275
|
+
equal(request, captureConfigureRequest(originalRequest)) &&
|
|
276
|
+
samePlan(plan, capturePlan(actualReadPlan)) &&
|
|
277
|
+
samePlan(plan, expected);
|
|
278
|
+
gate();
|
|
279
|
+
phase = matches ? "bound" : "invalid";
|
|
280
|
+
return matches;
|
|
281
|
+
},
|
|
282
|
+
reserveAcquisition() {
|
|
283
|
+
need(arguments.length === 0);
|
|
284
|
+
gate();
|
|
285
|
+
if (phase !== "bound" || index !== 0 || pending !== null) return false;
|
|
286
|
+
phase = "reserved";
|
|
287
|
+
return true;
|
|
288
|
+
},
|
|
289
|
+
consumeReadCatch() {
|
|
290
|
+
need(arguments.length === 0);
|
|
291
|
+
if (!live()) return null;
|
|
292
|
+
const slot = readCatch;
|
|
293
|
+
if (
|
|
294
|
+
!slot ||
|
|
295
|
+
slot.attempt !== lastRead ||
|
|
296
|
+
slot.attempt.generation !== generation ||
|
|
297
|
+
pending !== null ||
|
|
298
|
+
phase !== "failed"
|
|
299
|
+
)
|
|
300
|
+
return null;
|
|
301
|
+
readCatch = null;
|
|
302
|
+
return slot.fact;
|
|
303
|
+
},
|
|
304
|
+
consumePostCatch(actualReply: unknown) {
|
|
305
|
+
need(arguments.length === 1);
|
|
306
|
+
if (!live()) return null;
|
|
307
|
+
const slot =
|
|
308
|
+
actualReply !== null && typeof actualReply === "object"
|
|
309
|
+
? postCatches.get(actualReply)
|
|
310
|
+
: undefined;
|
|
311
|
+
if (
|
|
312
|
+
!slot ||
|
|
313
|
+
slot.attempt !== postAttempt ||
|
|
314
|
+
slot.attempt.generation !== generation ||
|
|
315
|
+
pending !== null ||
|
|
316
|
+
postState !== "REJECTED"
|
|
317
|
+
)
|
|
318
|
+
return null;
|
|
319
|
+
postCatches.delete(actualReply as object);
|
|
320
|
+
return slot.fact;
|
|
321
|
+
},
|
|
322
|
+
consumeNotStarted(actualReply: unknown) {
|
|
323
|
+
need(arguments.length === 1);
|
|
324
|
+
if (
|
|
325
|
+
actualReply === null ||
|
|
326
|
+
typeof actualReply !== "object" ||
|
|
327
|
+
!notStarted.has(actualReply) ||
|
|
328
|
+
postState !== "NOT_STARTED"
|
|
329
|
+
)
|
|
330
|
+
return false;
|
|
331
|
+
notStarted.delete(actualReply);
|
|
332
|
+
return true;
|
|
333
|
+
},
|
|
334
|
+
// No Owner sample/callback/reflection here: final actor gate immediately precedes this.
|
|
335
|
+
discardFulfilledQuarantine() {
|
|
336
|
+
_quarantine = null;
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
return Object.freeze({ transport, capability });
|
|
340
|
+
}
|
|
341
|
+
export function createConfigureWriteTransport() {
|
|
342
|
+
need(arguments.length === 0);
|
|
343
|
+
return build(loadConfigureWriteTransportSource);
|
|
344
|
+
}
|
|
345
|
+
export function createConfigureReplayTransport() {
|
|
346
|
+
need(arguments.length === 0);
|
|
347
|
+
return build(loadConfigureReplayTransportSource);
|
|
348
|
+
}
|