@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,60 @@
|
|
|
1
|
+
import { it } from "vitest";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { observationFixture } from "../test-fixtures/observationOperation.js";
|
|
4
|
+
import { transportControlCases } from "../test-fixtures/observationDeclarations.js";
|
|
5
|
+
import {
|
|
6
|
+
observationOutcome,
|
|
7
|
+
assertPrivateObservationError,
|
|
8
|
+
assertObservationReadPrefix,
|
|
9
|
+
assertObservationProviderFailure,
|
|
10
|
+
} from "../test-fixtures/observationAssertions.js";
|
|
11
|
+
import {
|
|
12
|
+
retireObservationHeld,
|
|
13
|
+
logObservationFailureFrontier,
|
|
14
|
+
} from "../test-fixtures/observationProbe.js";
|
|
15
|
+
|
|
16
|
+
for (const mode of transportControlCases)
|
|
17
|
+
it("repository observation transport control " + mode, async () => {
|
|
18
|
+
const h = await observationFixture(mode);
|
|
19
|
+
try {
|
|
20
|
+
const original = h.capture().invoke();
|
|
21
|
+
const outcome = h.declaration.transport.held
|
|
22
|
+
? await retireObservationHeld(h, original)
|
|
23
|
+
: await observationOutcome(original);
|
|
24
|
+
assert.equal(outcome.ok, false);
|
|
25
|
+
if (!outcome.ok) {
|
|
26
|
+
if (h.declaration.expectedOwner === "retired")
|
|
27
|
+
assertPrivateObservationError(outcome.error, "ORIGINAL_OWNER_STOP");
|
|
28
|
+
else assertObservationProviderFailure(h, outcome.error);
|
|
29
|
+
}
|
|
30
|
+
assert.equal(h.state.targetCalls, 1);
|
|
31
|
+
assertObservationReadPrefix(h, h.declaration.transport.ordinal);
|
|
32
|
+
assert.equal(
|
|
33
|
+
h.http.traps(),
|
|
34
|
+
0,
|
|
35
|
+
"named late reply sentinel not reflected by owned continuation",
|
|
36
|
+
);
|
|
37
|
+
assert.equal(
|
|
38
|
+
h.http.diagnosticGetterCalls(),
|
|
39
|
+
0,
|
|
40
|
+
"named late error/unsafe diagnostic getter never invoked",
|
|
41
|
+
);
|
|
42
|
+
if (h.declaration.transport.reject) {
|
|
43
|
+
assert(h.http.actualError() instanceof Error);
|
|
44
|
+
assert.equal(h.http.actualError(), h.http.transformedError());
|
|
45
|
+
assert.equal(h.http.errorConfigurationVerified(), 1);
|
|
46
|
+
} else {
|
|
47
|
+
assert.equal(h.http.actualError(), null);
|
|
48
|
+
assert.equal(h.http.errorConfigurationVerified(), 0);
|
|
49
|
+
}
|
|
50
|
+
} catch (originalError) {
|
|
51
|
+
try {
|
|
52
|
+
await logObservationFailureFrontier(h);
|
|
53
|
+
} finally {
|
|
54
|
+
throw originalError;
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
h.http.hold.release.resolve();
|
|
58
|
+
await h.cleanup();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
3
|
+
import type {
|
|
4
|
+
Data,
|
|
5
|
+
ObservationRecord,
|
|
6
|
+
ObservationReadRow,
|
|
7
|
+
ObservationReads,
|
|
8
|
+
Resource,
|
|
9
|
+
} from "./types.js";
|
|
10
|
+
const API = "2026-09-30.endive";
|
|
11
|
+
const need: (x: unknown) => asserts x = (x) => {
|
|
12
|
+
if (!x) throw Error("OWNED_OBSERVATION_STOP");
|
|
13
|
+
};
|
|
14
|
+
function object(x: unknown): Data {
|
|
15
|
+
need(
|
|
16
|
+
x !== null &&
|
|
17
|
+
typeof x === "object" &&
|
|
18
|
+
!types.isProxy(x) &&
|
|
19
|
+
!Array.isArray(x),
|
|
20
|
+
);
|
|
21
|
+
const p = Object.getPrototypeOf(x);
|
|
22
|
+
need(p === Object.prototype || p === null);
|
|
23
|
+
return x as Data;
|
|
24
|
+
}
|
|
25
|
+
function own(x: unknown, key: string): unknown {
|
|
26
|
+
object(x);
|
|
27
|
+
const d = Object.getOwnPropertyDescriptor(x, key);
|
|
28
|
+
need(d && d.enumerable && "value" in d);
|
|
29
|
+
return d.value;
|
|
30
|
+
}
|
|
31
|
+
function resourceID(value: unknown, prefix: string): string {
|
|
32
|
+
need(
|
|
33
|
+
typeof value === "string" &&
|
|
34
|
+
value.length <= 255 &&
|
|
35
|
+
new RegExp("^" + prefix + "_[A-Za-z0-9_]+$").test(value),
|
|
36
|
+
);
|
|
37
|
+
requiredJSONSnapshot(value);
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function reference(
|
|
41
|
+
value: unknown,
|
|
42
|
+
prefix: string,
|
|
43
|
+
kind: string,
|
|
44
|
+
context: ReturnType<typeof ids>,
|
|
45
|
+
) {
|
|
46
|
+
if (typeof value === "string") return resourceID(value, prefix);
|
|
47
|
+
need(
|
|
48
|
+
own(value, "object") === kind &&
|
|
49
|
+
(!Object.prototype.hasOwnProperty.call(value as object, "deleted") ||
|
|
50
|
+
own(value, "deleted") === false),
|
|
51
|
+
);
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(value as object, "livemode"))
|
|
53
|
+
need(own(value, "livemode") === context.livemode);
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(value as object, "customer_account"))
|
|
55
|
+
need(own(value, "customer_account") === context.account);
|
|
56
|
+
return resourceID(own(value, "id"), prefix);
|
|
57
|
+
}
|
|
58
|
+
function ids(record: ObservationRecord) {
|
|
59
|
+
const e = record.configuration.preparation.expected;
|
|
60
|
+
need(
|
|
61
|
+
record.request.scope === "platform" && record.request.apiVersion === API,
|
|
62
|
+
);
|
|
63
|
+
return {
|
|
64
|
+
schedule: resourceID(record.attachReceipt.scheduleId, "sub_sched"),
|
|
65
|
+
subscription: resourceID(e.subscriptionId, "sub"),
|
|
66
|
+
price: resourceID(e.targetPriceId, "price"),
|
|
67
|
+
customer: resourceID(record.originalBundle.wireBillingCustomer.id, "cus"),
|
|
68
|
+
account: e.customerAccountId,
|
|
69
|
+
livemode: e.livemode,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function row(
|
|
73
|
+
resource: Resource,
|
|
74
|
+
id: string,
|
|
75
|
+
ordinal: number,
|
|
76
|
+
): ObservationReadRow {
|
|
77
|
+
const segments = {
|
|
78
|
+
schedule: "subscription_schedules",
|
|
79
|
+
subscription: "subscriptions",
|
|
80
|
+
price: "prices",
|
|
81
|
+
customer: "customers",
|
|
82
|
+
coupon: "coupons",
|
|
83
|
+
};
|
|
84
|
+
const query =
|
|
85
|
+
resource === "subscription"
|
|
86
|
+
? "?" +
|
|
87
|
+
String(
|
|
88
|
+
new URLSearchParams([
|
|
89
|
+
["expand[0]", "discounts"],
|
|
90
|
+
["expand[1]", "items.data.discounts"],
|
|
91
|
+
["expand[2]", "items.data.price"],
|
|
92
|
+
]),
|
|
93
|
+
)
|
|
94
|
+
: "";
|
|
95
|
+
return Object.freeze({
|
|
96
|
+
resource,
|
|
97
|
+
id,
|
|
98
|
+
ordinal,
|
|
99
|
+
method: "GET",
|
|
100
|
+
path: "/v1/" + segments[resource] + "/" + encodeURIComponent(id) + query,
|
|
101
|
+
body: undefined,
|
|
102
|
+
options: Object.freeze({ apiVersion: API, maxNetworkRetries: 0 }),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export function baseReadRows(record: ObservationRecord) {
|
|
106
|
+
const p = ids(record);
|
|
107
|
+
return Object.freeze([
|
|
108
|
+
row("schedule", p.schedule, 1),
|
|
109
|
+
row("subscription", p.subscription, 2),
|
|
110
|
+
row("price", p.price, 3),
|
|
111
|
+
row("customer", p.customer, 4),
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
function soleItem(subscription: unknown) {
|
|
115
|
+
const items = own(subscription, "items"),
|
|
116
|
+
values = own(items, "data");
|
|
117
|
+
need(
|
|
118
|
+
own(items, "has_more") === false &&
|
|
119
|
+
Array.isArray(values) &&
|
|
120
|
+
values.length === 1,
|
|
121
|
+
);
|
|
122
|
+
const item = object(values[0]);
|
|
123
|
+
resourceID(own(item, "id"), "si");
|
|
124
|
+
return item;
|
|
125
|
+
}
|
|
126
|
+
export function validateBaseRouting(
|
|
127
|
+
record: ObservationRecord,
|
|
128
|
+
reads: ObservationReads,
|
|
129
|
+
) {
|
|
130
|
+
const p = ids(record),
|
|
131
|
+
s = object(reads.schedule),
|
|
132
|
+
sub = object(reads.subscription),
|
|
133
|
+
price = object(reads.targetPrice),
|
|
134
|
+
customer = object(reads.billingCustomer);
|
|
135
|
+
need(
|
|
136
|
+
own(s, "id") === p.schedule &&
|
|
137
|
+
own(s, "object") === "subscription_schedule" &&
|
|
138
|
+
s.deleted !== true,
|
|
139
|
+
);
|
|
140
|
+
need(
|
|
141
|
+
own(sub, "id") === p.subscription &&
|
|
142
|
+
own(sub, "object") === "subscription" &&
|
|
143
|
+
sub.deleted !== true,
|
|
144
|
+
);
|
|
145
|
+
need(
|
|
146
|
+
own(price, "id") === p.price &&
|
|
147
|
+
own(price, "object") === "price" &&
|
|
148
|
+
price.deleted !== true,
|
|
149
|
+
);
|
|
150
|
+
need(
|
|
151
|
+
own(customer, "id") === p.customer &&
|
|
152
|
+
own(customer, "object") === "customer" &&
|
|
153
|
+
customer.deleted !== true,
|
|
154
|
+
);
|
|
155
|
+
for (const body of [s, sub, customer])
|
|
156
|
+
need(
|
|
157
|
+
own(body, "customer_account") === p.account &&
|
|
158
|
+
own(body, "livemode") === p.livemode,
|
|
159
|
+
);
|
|
160
|
+
need(own(price, "livemode") === p.livemode);
|
|
161
|
+
need(
|
|
162
|
+
reference(own(s, "customer"), "cus", "customer", p) === p.customer &&
|
|
163
|
+
reference(own(sub, "customer"), "cus", "customer", p) === p.customer,
|
|
164
|
+
);
|
|
165
|
+
if (own(s, "subscription") !== null)
|
|
166
|
+
need(
|
|
167
|
+
reference(s.subscription, "sub", "subscription", p) === p.subscription,
|
|
168
|
+
);
|
|
169
|
+
if (own(sub, "schedule") !== null)
|
|
170
|
+
need(
|
|
171
|
+
reference(sub.schedule, "sub_sched", "subscription_schedule", p) ===
|
|
172
|
+
p.schedule,
|
|
173
|
+
);
|
|
174
|
+
const item = soleItem(sub);
|
|
175
|
+
need(own(item, "subscription") === p.subscription);
|
|
176
|
+
// Do not constrain status, current price, old item ID/period, phases or material
|
|
177
|
+
// equality here. The unchanged public observer decides those data relations.
|
|
178
|
+
}
|
|
179
|
+
function couponID(value: unknown): string {
|
|
180
|
+
need(
|
|
181
|
+
typeof value === "string" &&
|
|
182
|
+
value.length >= 1 &&
|
|
183
|
+
value.length <= 255 &&
|
|
184
|
+
/\S/.test(value) &&
|
|
185
|
+
value !== "." &&
|
|
186
|
+
value !== "..",
|
|
187
|
+
);
|
|
188
|
+
requiredJSONSnapshot(value);
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
export function observationCouponIds(
|
|
192
|
+
record: ObservationRecord,
|
|
193
|
+
currentSubscription: unknown,
|
|
194
|
+
) {
|
|
195
|
+
const p = ids(record),
|
|
196
|
+
original = record.originalBundle.wireSubscription;
|
|
197
|
+
const oldItem = soleItem(original),
|
|
198
|
+
currentItem = soleItem(currentSubscription);
|
|
199
|
+
const groups: readonly (readonly [unknown, Data, "subscription" | "item"])[] =
|
|
200
|
+
[
|
|
201
|
+
[original, oldItem, "subscription"],
|
|
202
|
+
[oldItem, oldItem, "item"],
|
|
203
|
+
[currentSubscription, currentItem, "subscription"],
|
|
204
|
+
[currentItem, currentItem, "item"],
|
|
205
|
+
];
|
|
206
|
+
const result: string[] = [],
|
|
207
|
+
seen = new Set<string>();
|
|
208
|
+
for (const [owner, item, level] of groups) {
|
|
209
|
+
const discounts = own(owner, "discounts");
|
|
210
|
+
need(Array.isArray(discounts) && discounts.length <= 20);
|
|
211
|
+
for (const value of discounts as readonly unknown[]) {
|
|
212
|
+
const d = object(value);
|
|
213
|
+
resourceID(own(d, "id"), "di");
|
|
214
|
+
need(
|
|
215
|
+
own(d, "object") === "discount" &&
|
|
216
|
+
d.deleted !== true &&
|
|
217
|
+
own(d, "customer_account") === p.account,
|
|
218
|
+
);
|
|
219
|
+
if (Object.prototype.hasOwnProperty.call(d, "customer"))
|
|
220
|
+
need(
|
|
221
|
+
reference(own(d, "customer"), "cus", "customer", p) === p.customer,
|
|
222
|
+
);
|
|
223
|
+
if (level === "subscription")
|
|
224
|
+
need(
|
|
225
|
+
own(d, "subscription") === p.subscription &&
|
|
226
|
+
own(d, "subscription_item") === null,
|
|
227
|
+
);
|
|
228
|
+
else
|
|
229
|
+
need(
|
|
230
|
+
own(d, "subscription_item") === item.id &&
|
|
231
|
+
(own(d, "subscription") === null ||
|
|
232
|
+
d.subscription === p.subscription),
|
|
233
|
+
);
|
|
234
|
+
const source = own(d, "source");
|
|
235
|
+
need(own(source, "type") === "coupon");
|
|
236
|
+
const raw = own(source, "coupon"),
|
|
237
|
+
id = couponID(typeof raw === "string" ? raw : own(raw, "id"));
|
|
238
|
+
if (!seen.has(id)) {
|
|
239
|
+
seen.add(id);
|
|
240
|
+
result.push(id);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
need(result.length <= 40);
|
|
245
|
+
return Object.freeze(result);
|
|
246
|
+
}
|
|
247
|
+
export function couponReadRow(id: unknown, ordinal: number) {
|
|
248
|
+
need(Number.isSafeInteger(ordinal) && ordinal >= 5 && ordinal <= 44);
|
|
249
|
+
return row("coupon", couponID(id), ordinal);
|
|
250
|
+
}
|
|
251
|
+
export function validateCoupon(
|
|
252
|
+
record: ObservationRecord,
|
|
253
|
+
id: string,
|
|
254
|
+
body: unknown,
|
|
255
|
+
) {
|
|
256
|
+
const p = ids(record);
|
|
257
|
+
object(body);
|
|
258
|
+
need(
|
|
259
|
+
own(body, "id") === id &&
|
|
260
|
+
own(body, "object") === "coupon" &&
|
|
261
|
+
(body as Data).deleted !== true &&
|
|
262
|
+
own(body, "livemode") === p.livemode,
|
|
263
|
+
);
|
|
264
|
+
}
|