@fantastic.dev/better-stripe 0.90.0 → 0.92.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 +12 -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 +14 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +444 -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/ownedContinuation.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
- package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.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 +383 -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 +216 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
- package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.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 +84 -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/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +26 -8
- package/docs/renewal-material-observation.md +58 -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 +586 -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/ownedContinuation.ts +56 -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 +487 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +251 -0
- package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
- package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -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 +107 -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 +537 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +325 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +471 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +587 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -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,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
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import type {
|
|
4
|
+
ObservationControl,
|
|
5
|
+
ObservationDeclaration,
|
|
6
|
+
} from "./observationDeclarations.js";
|
|
7
|
+
|
|
8
|
+
export function observationState() {
|
|
9
|
+
return {
|
|
10
|
+
targetCalls: 0,
|
|
11
|
+
sourceLoads: 0,
|
|
12
|
+
ownedC6: 0,
|
|
13
|
+
ownedC3: 0,
|
|
14
|
+
C3Fulfilled: 0,
|
|
15
|
+
C3Rejected: 0,
|
|
16
|
+
recordVerificationEntered: 0,
|
|
17
|
+
recordVerificationCompleted: 0,
|
|
18
|
+
ownedC9: 0,
|
|
19
|
+
ownedObserver: 0,
|
|
20
|
+
coverage: 0,
|
|
21
|
+
tupleTraps: 0,
|
|
22
|
+
methodGetterCalls: 0,
|
|
23
|
+
exportFactoryLoads: 0,
|
|
24
|
+
exportReads: 0,
|
|
25
|
+
exportCalls: 0,
|
|
26
|
+
exportProxyApplies: 0,
|
|
27
|
+
exportDescriptorData: false,
|
|
28
|
+
exportDescriptorGetter: false,
|
|
29
|
+
lastC6: null as unknown,
|
|
30
|
+
pending: [] as Promise<unknown>[],
|
|
31
|
+
originals: [] as Promise<unknown>[],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type ObservationState = ReturnType<typeof observationState>;
|
|
35
|
+
|
|
36
|
+
/** Install only after the actual initial actor/Owner/ACK have been captured. */
|
|
37
|
+
export async function observeObservationAPI(
|
|
38
|
+
s: ObservationState,
|
|
39
|
+
owner: typeof import("../originalOwner.js").OWNER,
|
|
40
|
+
mode: ObservationControl,
|
|
41
|
+
) {
|
|
42
|
+
const actual = await vi.importActual<
|
|
43
|
+
typeof import("../../../renewalV2/index.js")
|
|
44
|
+
>("../../../renewalV2/index.js");
|
|
45
|
+
const observer = await vi.importActual<
|
|
46
|
+
typeof import("../../../renewalV2/observation.js")
|
|
47
|
+
>("../../../renewalV2/observation.js");
|
|
48
|
+
assert.equal(typeof observer.inspectRenewalScheduleMaterialV2, "function");
|
|
49
|
+
const actualRecord = await vi.importActual<
|
|
50
|
+
typeof import("../observation/record.js")
|
|
51
|
+
>("../observation/record.js");
|
|
52
|
+
const verify = actualRecord.verifyObservationRecord;
|
|
53
|
+
vi.doMock("../observation/record.js", () => ({
|
|
54
|
+
...actualRecord,
|
|
55
|
+
verifyObservationRecord(...args: Parameters<typeof verify>) {
|
|
56
|
+
s.recordVerificationEntered++;
|
|
57
|
+
const result = Reflect.apply(verify, actualRecord, args) as ReturnType<
|
|
58
|
+
typeof verify
|
|
59
|
+
>;
|
|
60
|
+
s.recordVerificationCompleted++;
|
|
61
|
+
return result;
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
64
|
+
const keep = <T>(promise: Promise<T>) => {
|
|
65
|
+
s.originals.push(promise);
|
|
66
|
+
s.pending.push(
|
|
67
|
+
promise.then(
|
|
68
|
+
() => {},
|
|
69
|
+
() => {},
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
return promise;
|
|
73
|
+
};
|
|
74
|
+
vi.doMock("../../../renewalV2/index.js", () => ({
|
|
75
|
+
...actual,
|
|
76
|
+
projectRenewalConfigurationV2(
|
|
77
|
+
...args: Parameters<typeof actual.projectRenewalConfigurationV2>
|
|
78
|
+
) {
|
|
79
|
+
s.ownedC6++;
|
|
80
|
+
const promise = Reflect.apply(
|
|
81
|
+
actual.projectRenewalConfigurationV2,
|
|
82
|
+
actual,
|
|
83
|
+
args,
|
|
84
|
+
) as ReturnType<typeof actual.projectRenewalConfigurationV2>;
|
|
85
|
+
s.pending.push(
|
|
86
|
+
promise.then(
|
|
87
|
+
(value) => {
|
|
88
|
+
s.lastC6 = value;
|
|
89
|
+
if (mode === "G03-retire") owner.retire();
|
|
90
|
+
},
|
|
91
|
+
() => {},
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
return keep(promise);
|
|
95
|
+
},
|
|
96
|
+
constructRenewalScheduleAttachmentReceiptV2(
|
|
97
|
+
...args: Parameters<
|
|
98
|
+
typeof actual.constructRenewalScheduleAttachmentReceiptV2
|
|
99
|
+
>
|
|
100
|
+
) {
|
|
101
|
+
s.ownedC3++;
|
|
102
|
+
const promise = Reflect.apply(
|
|
103
|
+
actual.constructRenewalScheduleAttachmentReceiptV2,
|
|
104
|
+
actual,
|
|
105
|
+
args,
|
|
106
|
+
) as ReturnType<
|
|
107
|
+
typeof actual.constructRenewalScheduleAttachmentReceiptV2
|
|
108
|
+
>;
|
|
109
|
+
s.pending.push(
|
|
110
|
+
promise.then(
|
|
111
|
+
() => {
|
|
112
|
+
s.C3Fulfilled++;
|
|
113
|
+
},
|
|
114
|
+
() => {
|
|
115
|
+
s.C3Rejected++;
|
|
116
|
+
},
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
return keep(promise);
|
|
120
|
+
},
|
|
121
|
+
constructRenewalConfigurationReceiptV2(
|
|
122
|
+
...args: Parameters<typeof actual.constructRenewalConfigurationReceiptV2>
|
|
123
|
+
) {
|
|
124
|
+
s.ownedC9++;
|
|
125
|
+
return keep(
|
|
126
|
+
Reflect.apply(
|
|
127
|
+
actual.constructRenewalConfigurationReceiptV2,
|
|
128
|
+
actual,
|
|
129
|
+
args,
|
|
130
|
+
) as ReturnType<typeof actual.constructRenewalConfigurationReceiptV2>,
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
vi.doMock("../../../renewalV2/observation.js", () => ({
|
|
135
|
+
...observer,
|
|
136
|
+
inspectRenewalScheduleMaterialV2(
|
|
137
|
+
...args: Parameters<typeof observer.inspectRenewalScheduleMaterialV2>
|
|
138
|
+
) {
|
|
139
|
+
s.ownedObserver++;
|
|
140
|
+
return keep(
|
|
141
|
+
Reflect.apply(
|
|
142
|
+
observer.inspectRenewalScheduleMaterialV2,
|
|
143
|
+
observer,
|
|
144
|
+
args,
|
|
145
|
+
) as ReturnType<typeof observer.inspectRenewalScheduleMaterialV2>,
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
}));
|
|
149
|
+
return Object.freeze({ configuration: actual, observation: observer });
|
|
150
|
+
}
|
|
151
|
+
export function cleanObservationAPI() {
|
|
152
|
+
vi.doUnmock("../../../renewalV2/observation.js");
|
|
153
|
+
vi.doUnmock("../observation/record.js");
|
|
154
|
+
vi.doUnmock("../material/classifiers.js");
|
|
155
|
+
}
|
|
156
|
+
export async function joinObservationWork(s: ObservationState) {
|
|
157
|
+
const joined = await Promise.allSettled(s.pending);
|
|
158
|
+
assert.equal(joined.length, s.pending.length);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Fixed TEST export variants after genuine initial ACK; default positive is unmocked SSR. */
|
|
162
|
+
export async function installTrustedExportCase(
|
|
163
|
+
s: ObservationState,
|
|
164
|
+
owner: typeof import("../originalOwner.js").OWNER,
|
|
165
|
+
declaration: ObservationDeclaration,
|
|
166
|
+
) {
|
|
167
|
+
const mode = declaration.controlCase;
|
|
168
|
+
if (!mode.startsWith("ABI-") && mode !== "G03-failure") return;
|
|
169
|
+
const actual = await vi.importActual<
|
|
170
|
+
typeof import("../material/classifiers.js")
|
|
171
|
+
>("../material/classifiers.js");
|
|
172
|
+
const classify = actual.classifyOwnedRetainedInitialAttachment;
|
|
173
|
+
vi.doMock("../material/classifiers.js", () => {
|
|
174
|
+
s.exportFactoryLoads++;
|
|
175
|
+
const forward = (...args: Parameters<typeof classify>) => {
|
|
176
|
+
s.exportCalls++;
|
|
177
|
+
const promise = Reflect.apply(classify, actual, args) as ReturnType<
|
|
178
|
+
typeof classify
|
|
179
|
+
>;
|
|
180
|
+
s.pending.push(
|
|
181
|
+
promise.then(
|
|
182
|
+
() => {},
|
|
183
|
+
() => {},
|
|
184
|
+
),
|
|
185
|
+
);
|
|
186
|
+
return promise;
|
|
187
|
+
};
|
|
188
|
+
const namespace = { ...actual };
|
|
189
|
+
let value: unknown = forward;
|
|
190
|
+
if (mode === "ABI-undefined-export") value = undefined;
|
|
191
|
+
if (mode === "ABI-nonfunction-export")
|
|
192
|
+
value = Object.freeze({ declared: "NOT_A_FUNCTION" });
|
|
193
|
+
if (mode === "ABI-proxy-function-export")
|
|
194
|
+
value = new Proxy(forward, {
|
|
195
|
+
apply(target, receiver, args: Parameters<typeof classify>) {
|
|
196
|
+
s.exportProxyApplies++;
|
|
197
|
+
return Reflect.apply(target, receiver, args);
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
if (
|
|
201
|
+
[
|
|
202
|
+
"ABI-getter-once",
|
|
203
|
+
"ABI-getter-retire",
|
|
204
|
+
"ABI-getter-throws",
|
|
205
|
+
"G03-failure",
|
|
206
|
+
].includes(mode)
|
|
207
|
+
)
|
|
208
|
+
Object.defineProperty(
|
|
209
|
+
namespace,
|
|
210
|
+
"classifyOwnedRetainedInitialAttachment",
|
|
211
|
+
{
|
|
212
|
+
enumerable: true,
|
|
213
|
+
configurable: true,
|
|
214
|
+
get() {
|
|
215
|
+
s.exportReads++;
|
|
216
|
+
if (mode === "ABI-getter-retire") owner.retire();
|
|
217
|
+
if (mode === "ABI-getter-throws" || mode === "G03-failure")
|
|
218
|
+
throw Error(declaration.exportThrow);
|
|
219
|
+
return forward;
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
else
|
|
224
|
+
Object.defineProperty(
|
|
225
|
+
namespace,
|
|
226
|
+
"classifyOwnedRetainedInitialAttachment",
|
|
227
|
+
{
|
|
228
|
+
enumerable: true,
|
|
229
|
+
configurable: true,
|
|
230
|
+
value,
|
|
231
|
+
},
|
|
232
|
+
);
|
|
233
|
+
return namespace;
|
|
234
|
+
});
|
|
235
|
+
if (mode.startsWith("ABI-")) {
|
|
236
|
+
const resolved = await import("../material/classifiers.js");
|
|
237
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
238
|
+
resolved,
|
|
239
|
+
"classifyOwnedRetainedInitialAttachment",
|
|
240
|
+
);
|
|
241
|
+
assert(descriptor, "TRUSTED_EXPORT_VARIANT_MUST_RESOLVE");
|
|
242
|
+
s.exportDescriptorData = Object.prototype.hasOwnProperty.call(
|
|
243
|
+
descriptor,
|
|
244
|
+
"value",
|
|
245
|
+
);
|
|
246
|
+
s.exportDescriptorGetter = typeof descriptor.get === "function";
|
|
247
|
+
const getter = [
|
|
248
|
+
"ABI-getter-once",
|
|
249
|
+
"ABI-getter-retire",
|
|
250
|
+
"ABI-getter-throws",
|
|
251
|
+
].includes(mode);
|
|
252
|
+
assert.equal(
|
|
253
|
+
s.exportDescriptorGetter,
|
|
254
|
+
getter,
|
|
255
|
+
"DECLARED_ABI_SHAPE_BEFORE_TARGET",
|
|
256
|
+
);
|
|
257
|
+
assert.equal(
|
|
258
|
+
s.exportDescriptorData,
|
|
259
|
+
!getter,
|
|
260
|
+
"DECLARED_ABI_SHAPE_BEFORE_TARGET",
|
|
261
|
+
);
|
|
262
|
+
assert.equal(
|
|
263
|
+
s.exportReads,
|
|
264
|
+
0,
|
|
265
|
+
"descriptor inspection never invokes getter",
|
|
266
|
+
);
|
|
267
|
+
assert.equal(s.exportCalls, 0);
|
|
268
|
+
}
|
|
269
|
+
}
|