@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,211 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { data } from "./configurePreflightControls.js";
|
|
3
|
+
import { assertFit } from "./configurePreflightAssertions.js";
|
|
4
|
+
import type { ObservationFixture } from "./observationOperation.js";
|
|
5
|
+
|
|
6
|
+
export function logObservationPrerequisites(h: {
|
|
7
|
+
initialOutput: unknown;
|
|
8
|
+
record: unknown;
|
|
9
|
+
input: unknown;
|
|
10
|
+
expectedOutput: unknown;
|
|
11
|
+
calls: number;
|
|
12
|
+
targetCalls: number;
|
|
13
|
+
}) {
|
|
14
|
+
assert.equal(h.calls, 0);
|
|
15
|
+
assert.equal(h.targetCalls, 0);
|
|
16
|
+
for (const part of [
|
|
17
|
+
"initialOutput",
|
|
18
|
+
"record",
|
|
19
|
+
"input",
|
|
20
|
+
"expectedOutput",
|
|
21
|
+
] as const)
|
|
22
|
+
console.log(
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
kind: "REPOSITORY_OBSERVATION_PREREQUISITE_METRICS",
|
|
25
|
+
part,
|
|
26
|
+
...assertFit(h[part]),
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
console.log(
|
|
30
|
+
JSON.stringify({
|
|
31
|
+
kind: "REPOSITORY_OBSERVATION_PREREQUISITES",
|
|
32
|
+
actualInitialACK: true,
|
|
33
|
+
actualSourceENTRYAndOwner: true,
|
|
34
|
+
actualACKPointer: true,
|
|
35
|
+
actualCurrentC6: true,
|
|
36
|
+
directUnchangedObserver: "attached_unconfigured_match",
|
|
37
|
+
observationHTTP: 0,
|
|
38
|
+
targetCalls: 0,
|
|
39
|
+
retainedConfigureAcknowledgement: "absent",
|
|
40
|
+
operationalAuthority: false,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function assertObservationOutput(h: ObservationFixture, value: unknown) {
|
|
46
|
+
assert.deepEqual(value, h.expectedOutput);
|
|
47
|
+
const out = data(value);
|
|
48
|
+
assert.notEqual(value, h.expectedOutput);
|
|
49
|
+
assert.notEqual(out.reads, h.declaration.reads);
|
|
50
|
+
assert.deepEqual(
|
|
51
|
+
Object.keys(out).sort(),
|
|
52
|
+
[
|
|
53
|
+
"status",
|
|
54
|
+
"observation",
|
|
55
|
+
"reads",
|
|
56
|
+
"observedAt",
|
|
57
|
+
"retainedConfigureAcknowledgement",
|
|
58
|
+
"operationalAuthority",
|
|
59
|
+
].sort(),
|
|
60
|
+
);
|
|
61
|
+
assert.equal(
|
|
62
|
+
Object.prototype.hasOwnProperty.call(h.input, "configureReceipt"),
|
|
63
|
+
false,
|
|
64
|
+
);
|
|
65
|
+
assert.equal(h.state.targetCalls, 1);
|
|
66
|
+
assert.equal(h.state.sourceLoads, 1);
|
|
67
|
+
assert.equal(h.http.calls.length, h.declaration.rows.length);
|
|
68
|
+
assert.equal(h.declaration.rows.length, 6);
|
|
69
|
+
for (const [i, row] of h.http.calls.entries()) {
|
|
70
|
+
assert.equal(row.method, "GET");
|
|
71
|
+
assert.equal(row.path, h.declaration.rows[i]!.path);
|
|
72
|
+
}
|
|
73
|
+
assert.equal(h.state.ownedC6, 1);
|
|
74
|
+
assert.equal(h.state.ownedC3, 1);
|
|
75
|
+
assert.equal(h.state.ownedC9, 0);
|
|
76
|
+
assert.equal(h.state.ownedObserver, 1);
|
|
77
|
+
assert.equal(h.state.coverage, 1);
|
|
78
|
+
const sample = h.http.finalSample();
|
|
79
|
+
assert(sample);
|
|
80
|
+
assert.equal(out.observedAt, Math.floor(sample.wallMs / 1000));
|
|
81
|
+
assert.equal(h.prerequisite.deltas().records, 0);
|
|
82
|
+
assert.equal(h.prerequisite.deltas().POST, 0);
|
|
83
|
+
assertFit(h.record);
|
|
84
|
+
assertFit(h.input);
|
|
85
|
+
assertFit(value);
|
|
86
|
+
const frozen = (x: unknown) => {
|
|
87
|
+
if (x && typeof x === "object") {
|
|
88
|
+
assert(Object.isFrozen(x));
|
|
89
|
+
for (const child of Object.values(x)) frozen(child);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
frozen(value);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function assertNoObservationReads(h: ObservationFixture) {
|
|
96
|
+
assert.equal(h.http.calls.length, 0);
|
|
97
|
+
assert.equal(h.http.argsSeen.length, 0);
|
|
98
|
+
assert.equal(h.http.delegateEntriesAfterOwner(), 0);
|
|
99
|
+
assert.equal(h.http.originals.length, 0);
|
|
100
|
+
assert.equal(h.prerequisite.deltas().POST, 0);
|
|
101
|
+
assert.equal(h.prerequisite.deltas().records, 0);
|
|
102
|
+
assert.equal(h.state.ownedC9, 0);
|
|
103
|
+
assert.equal(h.state.ownedObserver, 0);
|
|
104
|
+
assert.equal(h.state.coverage, 0);
|
|
105
|
+
}
|
|
106
|
+
export function assertPrivateObservationError(
|
|
107
|
+
error: unknown,
|
|
108
|
+
expected:
|
|
109
|
+
| "OWNED_OBSERVATION_STOP"
|
|
110
|
+
| "OWNED_OBSERVATION_ONCE"
|
|
111
|
+
| "ORIGINAL_OWNER_STOP"
|
|
112
|
+
| "MATERIAL_V2_UNSUPPORTED" = "OWNED_OBSERVATION_STOP",
|
|
113
|
+
) {
|
|
114
|
+
assert(error instanceof Error);
|
|
115
|
+
assert.equal(error.message, expected);
|
|
116
|
+
assert.notEqual(error.message, "OWNED_OBSERVATION_PROVIDER_REJECTED");
|
|
117
|
+
assert.equal(Object.prototype.hasOwnProperty.call(error, "failure"), false);
|
|
118
|
+
}
|
|
119
|
+
export async function observationOutcome<T>(promise: Promise<T>) {
|
|
120
|
+
return promise.then(
|
|
121
|
+
(value) => ({ ok: true as const, value }),
|
|
122
|
+
(error: unknown) => ({ ok: false as const, error }),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function assertObservationReadPrefix(
|
|
127
|
+
h: ObservationFixture,
|
|
128
|
+
count: number,
|
|
129
|
+
) {
|
|
130
|
+
assert.equal(h.declaration.rows.length, 6);
|
|
131
|
+
assert.equal(h.http.calls.length, count);
|
|
132
|
+
assert.equal(h.http.argsSeen.length, count);
|
|
133
|
+
assert.equal(h.http.delegateEntries(), count);
|
|
134
|
+
assert.equal(h.http.delegateEntriesAfterOwner(), count);
|
|
135
|
+
assert.equal(h.http.originals.length, count);
|
|
136
|
+
for (let i = 0; i < count; i++) {
|
|
137
|
+
const row = h.declaration.rows[i]!;
|
|
138
|
+
assert.deepEqual(h.http.calls[i], { method: "GET", path: row.path });
|
|
139
|
+
assert.deepEqual(h.http.argsSeen[i], [
|
|
140
|
+
"GET",
|
|
141
|
+
row.path,
|
|
142
|
+
undefined,
|
|
143
|
+
row.options,
|
|
144
|
+
]);
|
|
145
|
+
assert(h.http.originals[i] instanceof Promise);
|
|
146
|
+
}
|
|
147
|
+
assert.equal(h.state.sourceLoads, 1);
|
|
148
|
+
assert.equal(h.state.ownedC6, 1);
|
|
149
|
+
assert.equal(h.state.ownedC3, 1);
|
|
150
|
+
assert.equal(h.state.C3Fulfilled, 1);
|
|
151
|
+
assert.equal(h.state.recordVerificationCompleted, 1);
|
|
152
|
+
assert.equal(h.state.ownedObserver, 0);
|
|
153
|
+
assert.equal(h.state.coverage, 0);
|
|
154
|
+
assert.equal(h.state.ownedC9, 0);
|
|
155
|
+
assert.equal(h.prerequisite.state.pairLoads, 0);
|
|
156
|
+
assert.equal(h.prerequisite.state.readonlyCalls, 0);
|
|
157
|
+
assert.equal(h.prerequisite.deltas().POST, 0);
|
|
158
|
+
assert.equal(h.prerequisite.deltas().records, 0);
|
|
159
|
+
}
|
|
160
|
+
export function assertObservationProviderFailure(
|
|
161
|
+
h: ObservationFixture,
|
|
162
|
+
error: unknown,
|
|
163
|
+
) {
|
|
164
|
+
assert(error instanceof Error);
|
|
165
|
+
assert.equal(error.message, "OWNED_OBSERVATION_PROVIDER_REJECTED");
|
|
166
|
+
assert.equal(Object.prototype.hasOwnProperty.call(error, "cause"), false);
|
|
167
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, "failure");
|
|
168
|
+
assert(
|
|
169
|
+
descriptor &&
|
|
170
|
+
"value" in descriptor &&
|
|
171
|
+
!descriptor.enumerable &&
|
|
172
|
+
!descriptor.writable &&
|
|
173
|
+
!descriptor.configurable,
|
|
174
|
+
);
|
|
175
|
+
const row = h.declaration.rows[h.declaration.transport.ordinal - 1]!;
|
|
176
|
+
const failure = data(descriptor.value);
|
|
177
|
+
assert.deepEqual(failure, {
|
|
178
|
+
category: "provider_rejected",
|
|
179
|
+
phase: "read",
|
|
180
|
+
resource: row.resource,
|
|
181
|
+
ordinal: row.ordinal,
|
|
182
|
+
request: {
|
|
183
|
+
method: "GET",
|
|
184
|
+
path: row.path,
|
|
185
|
+
apiVersion: h.declaration.baseline.apiVersion,
|
|
186
|
+
},
|
|
187
|
+
diagnostics: h.declaration.transport.expectedDiagnostics,
|
|
188
|
+
outcome: "unknown",
|
|
189
|
+
operationalAuthority: false,
|
|
190
|
+
});
|
|
191
|
+
assert.deepEqual(
|
|
192
|
+
Object.keys(failure).sort(),
|
|
193
|
+
[
|
|
194
|
+
"category",
|
|
195
|
+
"phase",
|
|
196
|
+
"resource",
|
|
197
|
+
"ordinal",
|
|
198
|
+
"request",
|
|
199
|
+
"diagnostics",
|
|
200
|
+
"outcome",
|
|
201
|
+
"operationalAuthority",
|
|
202
|
+
].sort(),
|
|
203
|
+
);
|
|
204
|
+
for (const value of [failure, failure.request, failure.diagnostics])
|
|
205
|
+
assert(Object.isFrozen(value));
|
|
206
|
+
for (const key of ["rawError", "rawReply", "headers", "token"])
|
|
207
|
+
assert.equal(Object.prototype.hasOwnProperty.call(failure, key), false);
|
|
208
|
+
assert.equal(h.http.actualError(), h.http.transformedError());
|
|
209
|
+
assert(h.http.actualError() instanceof Error);
|
|
210
|
+
assert.equal(h.http.errorConfigurationVerified(), 1);
|
|
211
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
declarePreflightCase,
|
|
3
|
+
deepFreeze,
|
|
4
|
+
} from "./configurePreflightControls.js";
|
|
5
|
+
|
|
6
|
+
export const sourceControlCases = [
|
|
7
|
+
"G02-arity",
|
|
8
|
+
"G02-once",
|
|
9
|
+
"G02-owner",
|
|
10
|
+
"G02-origin",
|
|
11
|
+
"G02-entry",
|
|
12
|
+
"G02-observation-entry",
|
|
13
|
+
"G02-ack-clone",
|
|
14
|
+
"G02-tuple-proxy",
|
|
15
|
+
"G02-method-getter",
|
|
16
|
+
"G02-optional-undefined",
|
|
17
|
+
"G02-optional-null",
|
|
18
|
+
"G02-optional-present",
|
|
19
|
+
] as const;
|
|
20
|
+
export const publicFailureCases = [
|
|
21
|
+
"G03-failure",
|
|
22
|
+
"G03-structural",
|
|
23
|
+
"G03-retire",
|
|
24
|
+
] as const;
|
|
25
|
+
export const trustedExportCases = [
|
|
26
|
+
"ABI-data-export",
|
|
27
|
+
"ABI-getter-once",
|
|
28
|
+
"ABI-getter-retire",
|
|
29
|
+
"ABI-undefined-export",
|
|
30
|
+
"ABI-nonfunction-export",
|
|
31
|
+
"ABI-proxy-function-export",
|
|
32
|
+
"ABI-getter-throws",
|
|
33
|
+
] as const;
|
|
34
|
+
export const transportControlCases = [
|
|
35
|
+
"G04-schedule-fulfill",
|
|
36
|
+
"G04-schedule-reject",
|
|
37
|
+
"G04-coupon-fulfill",
|
|
38
|
+
"G04-coupon-reject",
|
|
39
|
+
"G06-actual-schedule",
|
|
40
|
+
"G06-actual-coupon",
|
|
41
|
+
"G06-empty-diagnostics",
|
|
42
|
+
"G06-diagnostics",
|
|
43
|
+
"G06-retire-catch",
|
|
44
|
+
] as const;
|
|
45
|
+
export const observationControls = [
|
|
46
|
+
"positive",
|
|
47
|
+
"G02-empty",
|
|
48
|
+
...sourceControlCases,
|
|
49
|
+
...publicFailureCases,
|
|
50
|
+
...trustedExportCases,
|
|
51
|
+
...transportControlCases,
|
|
52
|
+
] as const;
|
|
53
|
+
export type ObservationControl = (typeof observationControls)[number];
|
|
54
|
+
|
|
55
|
+
/** Fixed complete positive raw input and clock cues precede all constructors. */
|
|
56
|
+
export function declareObservationPositive(
|
|
57
|
+
controlCase: ObservationControl = "positive",
|
|
58
|
+
) {
|
|
59
|
+
if (!observationControls.includes(controlCase))
|
|
60
|
+
throw Error("UNDECLARED_OBSERVATION_CASE");
|
|
61
|
+
const baseline = declarePreflightCase("positive");
|
|
62
|
+
const b = baseline.baselineBundle;
|
|
63
|
+
const reads = {
|
|
64
|
+
schedule: structuredClone(baseline.schedule),
|
|
65
|
+
subscription: structuredClone(b.wireSubscription),
|
|
66
|
+
targetPrice: structuredClone(b.wireTargetPrice),
|
|
67
|
+
billingCustomer: structuredClone(b.wireBillingCustomer),
|
|
68
|
+
coupons: b.couponReads.map((row) => structuredClone(row.wireCoupon)),
|
|
69
|
+
};
|
|
70
|
+
const expected = {
|
|
71
|
+
acknowledgementEstablished: false,
|
|
72
|
+
authenticationEstablished: false,
|
|
73
|
+
providerQualificationRequired: true,
|
|
74
|
+
predicate: "attached_unconfigured_match",
|
|
75
|
+
} as const;
|
|
76
|
+
const query = new URLSearchParams([
|
|
77
|
+
["expand[0]", "discounts"],
|
|
78
|
+
["expand[1]", "items.data.discounts"],
|
|
79
|
+
["expand[2]", "items.data.price"],
|
|
80
|
+
]);
|
|
81
|
+
const e = baseline.original.attachRequest.preparation.expected;
|
|
82
|
+
const rows = [
|
|
83
|
+
{
|
|
84
|
+
resource: "schedule",
|
|
85
|
+
path:
|
|
86
|
+
"/v1/subscription_schedules/" +
|
|
87
|
+
encodeURIComponent(baseline.schedule.id),
|
|
88
|
+
body: reads.schedule,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
resource: "subscription",
|
|
92
|
+
path:
|
|
93
|
+
"/v1/subscriptions/" +
|
|
94
|
+
encodeURIComponent(e.subscriptionId) +
|
|
95
|
+
"?" +
|
|
96
|
+
query,
|
|
97
|
+
body: reads.subscription,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
resource: "price",
|
|
101
|
+
path: "/v1/prices/" + encodeURIComponent(e.targetPriceId),
|
|
102
|
+
body: reads.targetPrice,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
resource: "customer",
|
|
106
|
+
path: "/v1/customers/" + encodeURIComponent(b.wireBillingCustomer.id),
|
|
107
|
+
body: reads.billingCustomer,
|
|
108
|
+
},
|
|
109
|
+
...b.couponReads.map((row) => ({
|
|
110
|
+
resource: "coupon",
|
|
111
|
+
path: "/v1/coupons/" + encodeURIComponent(row.couponId),
|
|
112
|
+
body: row.wireCoupon,
|
|
113
|
+
})),
|
|
114
|
+
];
|
|
115
|
+
return deepFreeze({
|
|
116
|
+
mode: "G01-owned-absent-ACK" as const,
|
|
117
|
+
controlCase,
|
|
118
|
+
expectedOwner:
|
|
119
|
+
controlCase === "G03-retire" ||
|
|
120
|
+
controlCase === "ABI-getter-retire" ||
|
|
121
|
+
controlCase.startsWith("G04-") ||
|
|
122
|
+
controlCase === "G06-retire-catch"
|
|
123
|
+
? ("retired" as const)
|
|
124
|
+
: ("live" as const),
|
|
125
|
+
transport: {
|
|
126
|
+
active: controlCase.startsWith("G04-") || controlCase.startsWith("G06-"),
|
|
127
|
+
held: controlCase.startsWith("G04-"),
|
|
128
|
+
ordinal: controlCase.includes("coupon") ? rows.length : 1,
|
|
129
|
+
reject: controlCase.startsWith("G06-") || controlCase.endsWith("-reject"),
|
|
130
|
+
emptyDiagnostics: controlCase === "G06-empty-diagnostics",
|
|
131
|
+
safeDiagnostics: controlCase === "G06-actual-coupon",
|
|
132
|
+
hostileDiagnostics:
|
|
133
|
+
controlCase === "G06-diagnostics" ||
|
|
134
|
+
controlCase === "G06-retire-catch" ||
|
|
135
|
+
controlCase.endsWith("-reject"),
|
|
136
|
+
retireAtCatch: controlCase === "G06-retire-catch",
|
|
137
|
+
safe: {
|
|
138
|
+
type: "api_error",
|
|
139
|
+
code: "TEST_DECLARED_CODE",
|
|
140
|
+
statusCode: 409,
|
|
141
|
+
requestId: "req_safe",
|
|
142
|
+
},
|
|
143
|
+
unsafeRequestId: "Bearer TEST_SECRET_NOT_A_CREDENTIAL",
|
|
144
|
+
expectedDiagnostics:
|
|
145
|
+
controlCase === "G06-empty-diagnostics"
|
|
146
|
+
? {}
|
|
147
|
+
: controlCase === "G06-actual-coupon"
|
|
148
|
+
? {
|
|
149
|
+
type: "api_error",
|
|
150
|
+
code: "TEST_DECLARED_CODE",
|
|
151
|
+
statusCode: 409,
|
|
152
|
+
requestId: "req_safe",
|
|
153
|
+
}
|
|
154
|
+
: { type: "StripeConnectionError" },
|
|
155
|
+
},
|
|
156
|
+
invalidAPI: "2026-01-01.unsupported",
|
|
157
|
+
foreign: Object.freeze({ declared: "TEST_FOREIGN_POINTER" }),
|
|
158
|
+
exportThrow: "TEST_DECLARED_TRUSTED_EXPORT_THROW",
|
|
159
|
+
baseline,
|
|
160
|
+
reads,
|
|
161
|
+
expected,
|
|
162
|
+
rows: rows.map((row, index) => ({
|
|
163
|
+
...row,
|
|
164
|
+
ordinal: index + 1,
|
|
165
|
+
method: "GET" as const,
|
|
166
|
+
options: {
|
|
167
|
+
apiVersion: baseline.apiVersion,
|
|
168
|
+
maxNetworkRetries: 0 as const,
|
|
169
|
+
},
|
|
170
|
+
})),
|
|
171
|
+
// Existing fixture advances its original Source to baseAt. No setter is exposed.
|
|
172
|
+
// Positive can sample that same live clock; distinct later-time controls are held.
|
|
173
|
+
expectedOwnerAt: baseline.baseAt,
|
|
174
|
+
originalFirstAt: baseline.firstAt,
|
|
175
|
+
retentionEpoch: baseline.original.attachRequest.firstDispatchedAt,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
export type ObservationDeclaration = ReturnType<
|
|
179
|
+
typeof declareObservationPositive
|
|
180
|
+
>;
|
|
181
|
+
export const heldObservationCases = Object.freeze({
|
|
182
|
+
structural:
|
|
183
|
+
"Direct public rejection plus possible earlier private capture; not target-C6 throw proof",
|
|
184
|
+
outputDataCap: "Helper-only, not actor-reachable output overflow",
|
|
185
|
+
ownKeysAndRepeatedOriginal:
|
|
186
|
+
"Need explicit stateless fixture extraction before authoring",
|
|
187
|
+
distinctFinalAndLaterSample:
|
|
188
|
+
"Existing fixture exposes no clock advance; no replacement clock allowed",
|
|
189
|
+
old43: "Actual opaque initial43 token unbound",
|
|
190
|
+
optionalACKAndHistory:
|
|
191
|
+
"Actual optional ACK18/19/history/effective remain required",
|
|
192
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import { types } from "node:util";
|
|
4
|
+
import { observationLatch } from "./observationProbe.js";
|
|
5
|
+
import type { ObservationDeclaration } from "./observationDeclarations.js";
|
|
6
|
+
|
|
7
|
+
/** Fresh READONLY closed fake HTTP. No old43 or preflight transport capability. */
|
|
8
|
+
export async function observationHTTP(
|
|
9
|
+
d: ObservationDeclaration,
|
|
10
|
+
owner: typeof import("../originalOwner.js").OWNER,
|
|
11
|
+
) {
|
|
12
|
+
const hold = observationLatch();
|
|
13
|
+
let delegateEntered = 0;
|
|
14
|
+
let delegatePassedOwnerEntries = 0;
|
|
15
|
+
let traps = 0,
|
|
16
|
+
diagnosticGetterCalls = 0,
|
|
17
|
+
actualError: unknown = null;
|
|
18
|
+
let networkError: Error | null = null;
|
|
19
|
+
let errorConfigurationVerified = 0;
|
|
20
|
+
let transformedError: unknown = null;
|
|
21
|
+
const decorateError = (error: unknown) => {
|
|
22
|
+
assert(error instanceof Error && !types.isProxy(error));
|
|
23
|
+
assert.notEqual(
|
|
24
|
+
error,
|
|
25
|
+
networkError,
|
|
26
|
+
"actual SDK rejection, not injected delegate rejection",
|
|
27
|
+
);
|
|
28
|
+
actualError = error;
|
|
29
|
+
assert(Object.isExtensible(error));
|
|
30
|
+
for (const key of ["type", "code", "statusCode", "requestId"]) {
|
|
31
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, key);
|
|
32
|
+
assert(
|
|
33
|
+
descriptor && "value" in descriptor && descriptor.configurable === true,
|
|
34
|
+
"declared four-field actual SDK error transformation must be applicable",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
errorConfigurationVerified++;
|
|
38
|
+
if (d.transport.safeDiagnostics)
|
|
39
|
+
for (const [key, value] of Object.entries(d.transport.safe))
|
|
40
|
+
Object.defineProperty(error, key, {
|
|
41
|
+
value,
|
|
42
|
+
configurable: true,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
});
|
|
46
|
+
if (d.transport.emptyDiagnostics)
|
|
47
|
+
for (const key of ["type", "code", "statusCode", "requestId"])
|
|
48
|
+
assert.equal(Reflect.deleteProperty(error, key), true);
|
|
49
|
+
if (d.transport.hostileDiagnostics) {
|
|
50
|
+
Object.defineProperty(error, "code", {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get() {
|
|
54
|
+
diagnosticGetterCalls++;
|
|
55
|
+
throw Error("TEST_DIAGNOSTIC_GETTER_MUST_NOT_RUN");
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(error, "requestId", {
|
|
59
|
+
value: d.transport.unsafeRequestId,
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
transformedError = error;
|
|
66
|
+
assert.equal(
|
|
67
|
+
transformedError,
|
|
68
|
+
actualError,
|
|
69
|
+
"four-field TEST decoration preserves actual error identity",
|
|
70
|
+
);
|
|
71
|
+
if (d.transport.retireAtCatch) owner.retire();
|
|
72
|
+
};
|
|
73
|
+
const calls: { method: string; path: string }[] = [];
|
|
74
|
+
const argsSeen: unknown[][] = [];
|
|
75
|
+
const originals: Promise<unknown>[] = [];
|
|
76
|
+
const joined: Promise<unknown>[] = [];
|
|
77
|
+
let finalReadSample: ReturnType<typeof owner.check> | null = null;
|
|
78
|
+
vi.stubGlobal("fetch", async (input: unknown, init: RequestInit) => {
|
|
79
|
+
const row = d.rows[calls.length];
|
|
80
|
+
assert(row, "UNDECLARED_OBSERVATION_HTTP");
|
|
81
|
+
const url = new URL(String(input));
|
|
82
|
+
assert.equal(url.origin, "https://api.stripe.com");
|
|
83
|
+
assert.equal(url.pathname + url.search, row.path);
|
|
84
|
+
assert.equal(init.method, "GET");
|
|
85
|
+
assert.equal(init.redirect, "error");
|
|
86
|
+
assert.equal(init.body, undefined);
|
|
87
|
+
const headers = new Headers(init.headers);
|
|
88
|
+
assert.equal(headers.get("stripe-version"), d.baseline.apiVersion);
|
|
89
|
+
assert.equal(headers.get("stripe-account"), null);
|
|
90
|
+
calls.push({ method: "GET", path: row.path });
|
|
91
|
+
if (d.transport.active && calls.length === d.transport.ordinal) {
|
|
92
|
+
if (d.transport.held) {
|
|
93
|
+
hold.entered.resolve();
|
|
94
|
+
await hold.release.promise;
|
|
95
|
+
}
|
|
96
|
+
if (d.transport.reject) {
|
|
97
|
+
networkError = Object.assign(
|
|
98
|
+
Error("DECLARED_CLOSED_OBSERVATION_HTTP_REJECTION"),
|
|
99
|
+
{ code: "ECONNRESET" },
|
|
100
|
+
);
|
|
101
|
+
throw networkError;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return new Response(JSON.stringify(row.body), {
|
|
105
|
+
status: 200,
|
|
106
|
+
headers: {
|
|
107
|
+
"content-type": "application/json",
|
|
108
|
+
"request-id": "req_SYNTHETIC_OBSERVATION",
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
const { getStripeClient } = await import("../../../../helpers.js");
|
|
113
|
+
const client = getStripeClient(
|
|
114
|
+
"sk_test_SYNTHETIC_OBSERVATION_NO_CREDENTIAL",
|
|
115
|
+
d.baseline.apiVersion,
|
|
116
|
+
{ singleAttempt: true },
|
|
117
|
+
);
|
|
118
|
+
const method = client.rawRequest;
|
|
119
|
+
const delegate = Object.freeze({
|
|
120
|
+
rawRequest(...args: unknown[]) {
|
|
121
|
+
delegateEntered++;
|
|
122
|
+
owner.check();
|
|
123
|
+
delegatePassedOwnerEntries++;
|
|
124
|
+
const row = d.rows[argsSeen.length];
|
|
125
|
+
assert(row);
|
|
126
|
+
assert.deepEqual(args, ["GET", row.path, undefined, row.options]);
|
|
127
|
+
argsSeen.push(args);
|
|
128
|
+
const promise = Reflect.apply(method, client, args) as Promise<unknown>;
|
|
129
|
+
originals.push(promise);
|
|
130
|
+
joined.push(
|
|
131
|
+
promise.then(
|
|
132
|
+
(value) => {
|
|
133
|
+
if (d.transport.held && argsSeen.length === d.transport.ordinal) {
|
|
134
|
+
assert(
|
|
135
|
+
value !== null &&
|
|
136
|
+
typeof value === "object" &&
|
|
137
|
+
Object.isExtensible(value),
|
|
138
|
+
);
|
|
139
|
+
const sentinel = new Proxy(
|
|
140
|
+
{ declared: true },
|
|
141
|
+
{
|
|
142
|
+
get(target, key, receiver) {
|
|
143
|
+
traps++;
|
|
144
|
+
return Reflect.get(target, key, receiver);
|
|
145
|
+
},
|
|
146
|
+
ownKeys(target) {
|
|
147
|
+
traps++;
|
|
148
|
+
return Reflect.ownKeys(target);
|
|
149
|
+
},
|
|
150
|
+
getPrototypeOf(target) {
|
|
151
|
+
traps++;
|
|
152
|
+
return Reflect.getPrototypeOf(target);
|
|
153
|
+
},
|
|
154
|
+
getOwnPropertyDescriptor(target, key) {
|
|
155
|
+
traps++;
|
|
156
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
Object.defineProperty(value, "ownedLateSentinel", {
|
|
161
|
+
value: sentinel,
|
|
162
|
+
enumerable: true,
|
|
163
|
+
configurable: true,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (d.expectedOwner === "live") {
|
|
167
|
+
const sample = owner.check();
|
|
168
|
+
if (argsSeen.length === d.rows.length) finalReadSample = sample;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
(error: unknown) => {
|
|
172
|
+
if (d.transport.active) decorateError(error);
|
|
173
|
+
},
|
|
174
|
+
),
|
|
175
|
+
);
|
|
176
|
+
return promise;
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
calls,
|
|
181
|
+
hold,
|
|
182
|
+
delegateEntries: () => delegateEntered,
|
|
183
|
+
traps: () => traps,
|
|
184
|
+
diagnosticGetterCalls: () => diagnosticGetterCalls,
|
|
185
|
+
actualError: () => actualError,
|
|
186
|
+
transformedError: () => transformedError,
|
|
187
|
+
errorConfigurationVerified: () => errorConfigurationVerified,
|
|
188
|
+
argsSeen,
|
|
189
|
+
originals,
|
|
190
|
+
delegate,
|
|
191
|
+
finalSample: () => finalReadSample,
|
|
192
|
+
delegateEntriesAfterOwner: () => delegatePassedOwnerEntries,
|
|
193
|
+
async cleanup() {
|
|
194
|
+
await Promise.all(joined);
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|