@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,99 @@
|
|
|
1
|
+
import type { declarePreflightCase } from "./configurePreflightControls.js";
|
|
2
|
+
type Baseline = ReturnType<typeof declarePreflightCase>;
|
|
3
|
+
export type ConfiguredHistoryWriterMode =
|
|
4
|
+
| "configured-history"
|
|
5
|
+
| "configured-history-onephase"
|
|
6
|
+
| "configured-history-drift";
|
|
7
|
+
export const CONFIGURED_TARGET_SECONDS = 2419200;
|
|
8
|
+
|
|
9
|
+
/** Exact full native Plan mapping from the accepted baseline helper; DATA only. */
|
|
10
|
+
function targetPlan(p: Baseline["baselineBundle"]["wireTargetPrice"]) {
|
|
11
|
+
return {
|
|
12
|
+
id: p.id,
|
|
13
|
+
object: "plan",
|
|
14
|
+
active: p.active,
|
|
15
|
+
amount: p.unit_amount,
|
|
16
|
+
amount_decimal: p.unit_amount_decimal,
|
|
17
|
+
billing_scheme: "per_unit",
|
|
18
|
+
created: p.created,
|
|
19
|
+
currency: p.currency,
|
|
20
|
+
interval: p.recurring.interval,
|
|
21
|
+
interval_count: p.recurring.interval_count,
|
|
22
|
+
livemode: p.livemode,
|
|
23
|
+
metadata: p.metadata,
|
|
24
|
+
meter: p.recurring.meter,
|
|
25
|
+
nickname: p.nickname,
|
|
26
|
+
product: p.product,
|
|
27
|
+
tiers_mode: null,
|
|
28
|
+
transform_usage: null,
|
|
29
|
+
trial_period_days: p.recurring.trial_period_days,
|
|
30
|
+
usage_type: "licensed",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Fixed complete reply recipe precedes all Source/Owner/C1/C2 construction. */
|
|
34
|
+
export function configuredHistoryResponse(
|
|
35
|
+
baseline: Baseline,
|
|
36
|
+
mode: ConfiguredHistoryWriterMode,
|
|
37
|
+
) {
|
|
38
|
+
const response = structuredClone(baseline.schedule);
|
|
39
|
+
const original = response.phases[0]!;
|
|
40
|
+
const target = {
|
|
41
|
+
...structuredClone(original),
|
|
42
|
+
start_date: baseline.original.attachRequest.preparation.expected.periodEnd,
|
|
43
|
+
end_date:
|
|
44
|
+
baseline.original.attachRequest.preparation.expected.periodEnd +
|
|
45
|
+
CONFIGURED_TARGET_SECONDS,
|
|
46
|
+
proration_behavior: "none",
|
|
47
|
+
billing_cycle_anchor: "automatic",
|
|
48
|
+
items: original.items.map((item) => ({
|
|
49
|
+
...structuredClone(item),
|
|
50
|
+
price: "price_target",
|
|
51
|
+
plan: "price_target",
|
|
52
|
+
})),
|
|
53
|
+
metadata:
|
|
54
|
+
mode === "configured-history-drift"
|
|
55
|
+
? { ...original.metadata, declared: "TEST_HISTORY_PHASE_DRIFT" }
|
|
56
|
+
: structuredClone(original.metadata),
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
...response,
|
|
60
|
+
phases:
|
|
61
|
+
mode === "configured-history-onephase" ? [original] : [original, target],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function configuredHistoryLiveReads(
|
|
65
|
+
baseline: Baseline,
|
|
66
|
+
active: boolean,
|
|
67
|
+
) {
|
|
68
|
+
// The independently declared live Schedule is always the clean complete history.
|
|
69
|
+
const schedule = configuredHistoryResponse(baseline, "configured-history");
|
|
70
|
+
const subscription = structuredClone(
|
|
71
|
+
baseline.baselineBundle.wireSubscription,
|
|
72
|
+
);
|
|
73
|
+
const targetPrice = structuredClone(baseline.baselineBundle.wireTargetPrice);
|
|
74
|
+
if (active) {
|
|
75
|
+
const target = schedule.phases[1]!;
|
|
76
|
+
schedule.current_phase = {
|
|
77
|
+
start_date: target.start_date,
|
|
78
|
+
end_date: target.end_date,
|
|
79
|
+
};
|
|
80
|
+
const item = subscription.items.data[0]!;
|
|
81
|
+
item.id = "si_successor";
|
|
82
|
+
item.price = structuredClone(targetPrice);
|
|
83
|
+
item.plan = targetPlan(targetPrice);
|
|
84
|
+
item.current_period_start = target.start_date;
|
|
85
|
+
item.current_period_end = target.end_date;
|
|
86
|
+
for (const discount of item.discounts) discount.subscription_item = item.id;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
schedule,
|
|
90
|
+
subscription,
|
|
91
|
+
targetPrice,
|
|
92
|
+
billingCustomer: structuredClone(
|
|
93
|
+
baseline.baselineBundle.wireBillingCustomer,
|
|
94
|
+
),
|
|
95
|
+
coupons: baseline.baselineBundle.couponReads.map((row) =>
|
|
96
|
+
structuredClone(row.wireCoupon),
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import * as actualPublicAPI from "../../../renewalV2/index.js";
|
|
4
|
+
import * as publicObserver from "../../../renewalV2/observation.js";
|
|
5
|
+
import {
|
|
6
|
+
declareConfiguredHistoryCase,
|
|
7
|
+
type ConfiguredHistoryCase,
|
|
8
|
+
} from "./observationConfiguredHistoryDeclarations.js";
|
|
9
|
+
import { configureWriteFixture } from "./configureWriteOperation.js";
|
|
10
|
+
import { assertConfigureACK, ackSlots } from "./configureWriteAssertions.js";
|
|
11
|
+
import { assertFit } from "./configurePreflightAssertions.js";
|
|
12
|
+
import { data, deepFreeze } from "./configurePreflightControls.js";
|
|
13
|
+
|
|
14
|
+
/** New closed TEST chain; actual writer/publication and original Owner/client retained. */
|
|
15
|
+
export async function configuredHistoryFixture(
|
|
16
|
+
controlCase: ConfiguredHistoryCase,
|
|
17
|
+
) {
|
|
18
|
+
const declaration = declareConfiguredHistoryCase(controlCase);
|
|
19
|
+
const writer = await configureWriteFixture(declaration.writerMode);
|
|
20
|
+
let finalReadSample: ReturnType<typeof writer.OWNER.check> | null = null;
|
|
21
|
+
const pending: Promise<unknown>[] = [];
|
|
22
|
+
const calls: { method: string; path: string }[] = [];
|
|
23
|
+
const promises: Promise<unknown>[] = [];
|
|
24
|
+
const counters = {
|
|
25
|
+
source: 0,
|
|
26
|
+
target: 0,
|
|
27
|
+
coverage: 0,
|
|
28
|
+
observer: 0,
|
|
29
|
+
C6: 0,
|
|
30
|
+
C3: 0,
|
|
31
|
+
C9: 0,
|
|
32
|
+
lookup: 0,
|
|
33
|
+
};
|
|
34
|
+
const clean = async () => {
|
|
35
|
+
try {
|
|
36
|
+
await Promise.all(pending);
|
|
37
|
+
} finally {
|
|
38
|
+
vi.doUnmock("../configure/actor.js");
|
|
39
|
+
vi.doUnmock("../../../renewalV2/observation.js");
|
|
40
|
+
await writer.cleanup();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
assert.deepEqual(
|
|
45
|
+
writer.write,
|
|
46
|
+
declaration.writer,
|
|
47
|
+
"PREDECLARED_WRITER_RECIPE_PARITY",
|
|
48
|
+
);
|
|
49
|
+
const basis = writer.OWNER.basis;
|
|
50
|
+
const writerACK: unknown = await writer.captureWriter().invoke();
|
|
51
|
+
assertConfigureACK(writer, writerACK);
|
|
52
|
+
const expectedSlots = 19;
|
|
53
|
+
const expectedDefaultsPresent = expectedSlots === 19;
|
|
54
|
+
assert.equal(ackSlots(writer).length, expectedSlots);
|
|
55
|
+
const ack = data(writerACK);
|
|
56
|
+
assert.equal(
|
|
57
|
+
Object.prototype.hasOwnProperty.call(
|
|
58
|
+
data(ack.receipt),
|
|
59
|
+
"defaultSettingsBinding",
|
|
60
|
+
),
|
|
61
|
+
expectedDefaultsPresent,
|
|
62
|
+
);
|
|
63
|
+
const rawReceipt = data(ack.rawReceipt);
|
|
64
|
+
assert.equal(
|
|
65
|
+
Object.prototype.hasOwnProperty.call(
|
|
66
|
+
data(rawReceipt.providerSnapshot),
|
|
67
|
+
"default_settings",
|
|
68
|
+
),
|
|
69
|
+
expectedDefaultsPresent,
|
|
70
|
+
);
|
|
71
|
+
if (expectedDefaultsPresent) {
|
|
72
|
+
const defaults = data(rawReceipt.providerSnapshot).default_settings;
|
|
73
|
+
assert.deepEqual(defaults, declaration.writer.response.default_settings);
|
|
74
|
+
assert(defaults !== null && typeof defaults === "object");
|
|
75
|
+
const defaultBinding = data(ack.receipt).defaultSettingsBinding;
|
|
76
|
+
assert.equal(
|
|
77
|
+
defaultBinding,
|
|
78
|
+
writer.expectedReceipt.defaultSettingsBinding,
|
|
79
|
+
);
|
|
80
|
+
assert(typeof defaultBinding === "string");
|
|
81
|
+
assert.match(
|
|
82
|
+
defaultBinding,
|
|
83
|
+
/^renewal-configured-defaults:v2:sha256:[0-9a-f]{64}$/,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
assert.deepEqual(rawReceipt, writer.rawReceipt);
|
|
87
|
+
const phases = data(rawReceipt.providerSnapshot).phases;
|
|
88
|
+
assert(Array.isArray(phases));
|
|
89
|
+
assert.equal(phases.length, declaration.historyPhaseCount);
|
|
90
|
+
const actualOperation = writer.fixedAOperation();
|
|
91
|
+
assert.equal(actualOperation.owner, writer.OWNER);
|
|
92
|
+
assert.equal(
|
|
93
|
+
actualOperation.actualAttachAcknowledgement,
|
|
94
|
+
writer.acknowledgement,
|
|
95
|
+
);
|
|
96
|
+
const originalEntry = actualOperation.originalEntry;
|
|
97
|
+
const origin = actualOperation.originAssociation;
|
|
98
|
+
const source = await import("../operations/sourceOperations.js");
|
|
99
|
+
assert.equal(source.ORIGINAL_ORIGIN_ASSOCIATION, origin);
|
|
100
|
+
assert(source.COMPILED_INITIAL_ENTRIES.includes(originalEntry));
|
|
101
|
+
const writerBefore = Object.freeze({
|
|
102
|
+
records: writer.writeState.records.length,
|
|
103
|
+
posts: writer.writeState.calls.filter((row) => row.method === "POST")
|
|
104
|
+
.length,
|
|
105
|
+
c9: writer.writeState.explicitC9,
|
|
106
|
+
});
|
|
107
|
+
assert.deepEqual(writerBefore, { records: 3, posts: 1, c9: 1 });
|
|
108
|
+
const setupBefore = Object.freeze({
|
|
109
|
+
records: writer.state.records.length,
|
|
110
|
+
posts: writer.state.calls.filter((row) => row.method === "POST").length,
|
|
111
|
+
});
|
|
112
|
+
assert.deepEqual(setupBefore, { records: 3, posts: 1 });
|
|
113
|
+
const input = deepFreeze({
|
|
114
|
+
configuration: writer.expectedRecord.configuration,
|
|
115
|
+
reads: declaration.reads,
|
|
116
|
+
configureReceipt: rawReceipt,
|
|
117
|
+
});
|
|
118
|
+
const direct: unknown = await Reflect.apply(
|
|
119
|
+
publicObserver.inspectRenewalScheduleMaterialV2,
|
|
120
|
+
publicObserver,
|
|
121
|
+
[input],
|
|
122
|
+
);
|
|
123
|
+
assert.deepEqual(
|
|
124
|
+
direct,
|
|
125
|
+
declaration.expectedObservation,
|
|
126
|
+
"CONFIGURED_HISTORY_PURE_RESULT_PREREQUISITE",
|
|
127
|
+
);
|
|
128
|
+
if (controlCase === "H01-pending") {
|
|
129
|
+
const withoutReceipt: unknown = await Reflect.apply(
|
|
130
|
+
publicObserver.inspectRenewalScheduleMaterialV2,
|
|
131
|
+
publicObserver,
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
configuration: writer.expectedRecord.configuration,
|
|
135
|
+
reads: declaration.reads,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
);
|
|
139
|
+
writer.OWNER.check();
|
|
140
|
+
assert.deepEqual(
|
|
141
|
+
withoutReceipt,
|
|
142
|
+
declaration.expectedWithoutReceipt,
|
|
143
|
+
"MONTHLY_HISTORY_CAUSAL_PREREQUISITE",
|
|
144
|
+
);
|
|
145
|
+
assert.notDeepEqual(withoutReceipt, direct);
|
|
146
|
+
}
|
|
147
|
+
const expectedOutput = deepFreeze({
|
|
148
|
+
status: "owned_observation_data",
|
|
149
|
+
observation: direct,
|
|
150
|
+
reads: declaration.reads,
|
|
151
|
+
observedAt: declaration.observedAt,
|
|
152
|
+
retainedConfigureAcknowledgement: "present",
|
|
153
|
+
operationalAuthority: false,
|
|
154
|
+
});
|
|
155
|
+
const prerequisites = {
|
|
156
|
+
record: assertFit(writer.expectedRecord),
|
|
157
|
+
actualACK: assertFit(writerACK),
|
|
158
|
+
rawReceipt: assertFit(rawReceipt),
|
|
159
|
+
publicInput: assertFit(input),
|
|
160
|
+
publicResult: assertFit(direct),
|
|
161
|
+
expectedOutput: assertFit(expectedOutput),
|
|
162
|
+
};
|
|
163
|
+
assert.equal(writer.OWNER.basis, basis);
|
|
164
|
+
vi.stubGlobal("fetch", async (value: unknown, init: RequestInit) => {
|
|
165
|
+
const row = declaration.rows[calls.length];
|
|
166
|
+
assert(row, "UNDECLARED_OPTIONAL_ACK_READ");
|
|
167
|
+
const url = new URL(String(value));
|
|
168
|
+
assert.equal(url.origin, "https://api.stripe.com");
|
|
169
|
+
assert.equal(url.pathname + url.search, row.path);
|
|
170
|
+
assert.equal(init.method, "GET");
|
|
171
|
+
assert.equal(init.body, undefined);
|
|
172
|
+
assert.equal(init.redirect, "error");
|
|
173
|
+
const headers = new Headers(init.headers);
|
|
174
|
+
assert.equal(
|
|
175
|
+
headers.get("stripe-version"),
|
|
176
|
+
declaration.writer.baseline.apiVersion,
|
|
177
|
+
);
|
|
178
|
+
assert.equal(headers.get("stripe-account"), null);
|
|
179
|
+
calls.push({ method: "GET", path: row.path });
|
|
180
|
+
return new Response(JSON.stringify(row.body), {
|
|
181
|
+
status: 200,
|
|
182
|
+
headers: {
|
|
183
|
+
"content-type": "application/json",
|
|
184
|
+
"request-id": "req_SYNTHETIC_OPTIONAL_ACK",
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
const readTransport = Object.freeze({
|
|
189
|
+
rawRequest(...args: unknown[]) {
|
|
190
|
+
writer.OWNER.check();
|
|
191
|
+
const row = declaration.rows[promises.length];
|
|
192
|
+
assert(row);
|
|
193
|
+
assert.deepEqual(args, ["GET", row.path, undefined, row.options]);
|
|
194
|
+
const promise = writer.readFixedA(...args);
|
|
195
|
+
promises.push(promise);
|
|
196
|
+
pending.push(
|
|
197
|
+
promise.then(
|
|
198
|
+
() => {
|
|
199
|
+
const sample = writer.OWNER.check();
|
|
200
|
+
if (row.ordinal === declaration.rows.length)
|
|
201
|
+
finalReadSample = sample;
|
|
202
|
+
},
|
|
203
|
+
() => {},
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
return promise;
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const observationEntry = Object.freeze({
|
|
210
|
+
originalEntry,
|
|
211
|
+
coversObservation(
|
|
212
|
+
record: unknown,
|
|
213
|
+
actualInput: unknown,
|
|
214
|
+
result: unknown,
|
|
215
|
+
) {
|
|
216
|
+
counters.coverage++;
|
|
217
|
+
assert.deepEqual(record, writer.expectedRecord);
|
|
218
|
+
assert.deepEqual(actualInput, input);
|
|
219
|
+
assert.deepEqual(result, direct);
|
|
220
|
+
return true;
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
const operation = Object.freeze({
|
|
224
|
+
owner: writer.OWNER,
|
|
225
|
+
originAssociation: origin,
|
|
226
|
+
originalEntry,
|
|
227
|
+
observationEntry,
|
|
228
|
+
record: writer.expectedRecord,
|
|
229
|
+
actualAttachAcknowledgement: writer.acknowledgement,
|
|
230
|
+
readTransport,
|
|
231
|
+
configureAcknowledgement: writerACK,
|
|
232
|
+
configureOperation: actualOperation,
|
|
233
|
+
});
|
|
234
|
+
const sourceOperation = operation;
|
|
235
|
+
const actualWriterActor = await import("../configure/actor.js");
|
|
236
|
+
const actualLookup = actualWriterActor.readOwnedConfigureAcknowledgement;
|
|
237
|
+
assert.equal(typeof actualLookup, "function");
|
|
238
|
+
vi.doMock("../configure/actor.js", () => ({
|
|
239
|
+
...actualWriterActor,
|
|
240
|
+
readOwnedConfigureAcknowledgement(
|
|
241
|
+
this: unknown,
|
|
242
|
+
...args: Parameters<typeof actualLookup>
|
|
243
|
+
) {
|
|
244
|
+
counters.lookup++;
|
|
245
|
+
return Reflect.apply(actualLookup, this, args) as ReturnType<
|
|
246
|
+
typeof actualLookup
|
|
247
|
+
>;
|
|
248
|
+
},
|
|
249
|
+
}));
|
|
250
|
+
vi.doMock("../operations/sourceOperations.js", () => ({
|
|
251
|
+
...source,
|
|
252
|
+
COMPILED_OBSERVATION_ENTRIES: Object.freeze([observationEntry]),
|
|
253
|
+
loadFixedObservationOperation() {
|
|
254
|
+
assert.equal(arguments.length, 0);
|
|
255
|
+
counters.source++;
|
|
256
|
+
return sourceOperation;
|
|
257
|
+
},
|
|
258
|
+
}));
|
|
259
|
+
const keep = <T>(promise: Promise<T>) => {
|
|
260
|
+
pending.push(
|
|
261
|
+
promise.then(
|
|
262
|
+
() => {},
|
|
263
|
+
() => {},
|
|
264
|
+
),
|
|
265
|
+
);
|
|
266
|
+
return promise;
|
|
267
|
+
};
|
|
268
|
+
vi.doMock("../../../renewalV2/index.js", () => ({
|
|
269
|
+
...actualPublicAPI,
|
|
270
|
+
projectRenewalConfigurationV2(
|
|
271
|
+
...args: Parameters<
|
|
272
|
+
typeof actualPublicAPI.projectRenewalConfigurationV2
|
|
273
|
+
>
|
|
274
|
+
) {
|
|
275
|
+
counters.C6++;
|
|
276
|
+
return keep(
|
|
277
|
+
Reflect.apply(
|
|
278
|
+
actualPublicAPI.projectRenewalConfigurationV2,
|
|
279
|
+
actualPublicAPI,
|
|
280
|
+
args,
|
|
281
|
+
) as ReturnType<typeof actualPublicAPI.projectRenewalConfigurationV2>,
|
|
282
|
+
);
|
|
283
|
+
},
|
|
284
|
+
constructRenewalScheduleAttachmentReceiptV2(
|
|
285
|
+
...args: Parameters<
|
|
286
|
+
typeof actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2
|
|
287
|
+
>
|
|
288
|
+
) {
|
|
289
|
+
counters.C3++;
|
|
290
|
+
return keep(
|
|
291
|
+
Reflect.apply(
|
|
292
|
+
actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2,
|
|
293
|
+
actualPublicAPI,
|
|
294
|
+
args,
|
|
295
|
+
) as ReturnType<
|
|
296
|
+
typeof actualPublicAPI.constructRenewalScheduleAttachmentReceiptV2
|
|
297
|
+
>,
|
|
298
|
+
);
|
|
299
|
+
},
|
|
300
|
+
constructRenewalConfigurationReceiptV2(
|
|
301
|
+
...args: Parameters<
|
|
302
|
+
typeof actualPublicAPI.constructRenewalConfigurationReceiptV2
|
|
303
|
+
>
|
|
304
|
+
) {
|
|
305
|
+
counters.C9++;
|
|
306
|
+
return keep(
|
|
307
|
+
Reflect.apply(
|
|
308
|
+
actualPublicAPI.constructRenewalConfigurationReceiptV2,
|
|
309
|
+
actualPublicAPI,
|
|
310
|
+
args,
|
|
311
|
+
) as ReturnType<
|
|
312
|
+
typeof actualPublicAPI.constructRenewalConfigurationReceiptV2
|
|
313
|
+
>,
|
|
314
|
+
);
|
|
315
|
+
},
|
|
316
|
+
}));
|
|
317
|
+
vi.doMock("../../../renewalV2/observation.js", () => ({
|
|
318
|
+
...publicObserver,
|
|
319
|
+
inspectRenewalScheduleMaterialV2(
|
|
320
|
+
...args: Parameters<
|
|
321
|
+
typeof publicObserver.inspectRenewalScheduleMaterialV2
|
|
322
|
+
>
|
|
323
|
+
) {
|
|
324
|
+
counters.observer++;
|
|
325
|
+
const promise = Reflect.apply(
|
|
326
|
+
publicObserver.inspectRenewalScheduleMaterialV2,
|
|
327
|
+
publicObserver,
|
|
328
|
+
args,
|
|
329
|
+
) as ReturnType<typeof publicObserver.inspectRenewalScheduleMaterialV2>;
|
|
330
|
+
pending.push(
|
|
331
|
+
promise.then(
|
|
332
|
+
() => {},
|
|
333
|
+
() => {},
|
|
334
|
+
),
|
|
335
|
+
);
|
|
336
|
+
return promise;
|
|
337
|
+
},
|
|
338
|
+
}));
|
|
339
|
+
const actor = await import("../observation/actor.js");
|
|
340
|
+
writer.OWNER.check();
|
|
341
|
+
assert.deepEqual(counters, {
|
|
342
|
+
source: 0,
|
|
343
|
+
target: 0,
|
|
344
|
+
coverage: 0,
|
|
345
|
+
observer: 0,
|
|
346
|
+
C6: 0,
|
|
347
|
+
C3: 0,
|
|
348
|
+
C9: 0,
|
|
349
|
+
lookup: 0,
|
|
350
|
+
});
|
|
351
|
+
assert.equal(calls.length, 0);
|
|
352
|
+
console.log(
|
|
353
|
+
JSON.stringify({
|
|
354
|
+
kind: "CONFIGURED_HISTORY_ACTUAL_PREREQUISITES",
|
|
355
|
+
actualInitialACK: true,
|
|
356
|
+
actualWriterACK: true,
|
|
357
|
+
actualConfigureOperationPointer: true,
|
|
358
|
+
sameOriginalOwnerENTRYAndOrigin: true,
|
|
359
|
+
controlCase,
|
|
360
|
+
generatedSlots: expectedSlots,
|
|
361
|
+
originalClientAndPromisePath: true,
|
|
362
|
+
writerBefore,
|
|
363
|
+
setupBefore,
|
|
364
|
+
observationHTTP: 0,
|
|
365
|
+
directUnmodifiedObserver: direct,
|
|
366
|
+
prerequisites,
|
|
367
|
+
operationalAuthority: false,
|
|
368
|
+
}),
|
|
369
|
+
);
|
|
370
|
+
return {
|
|
371
|
+
declaration,
|
|
372
|
+
writer,
|
|
373
|
+
writerACK,
|
|
374
|
+
operation,
|
|
375
|
+
sourceOperation,
|
|
376
|
+
basis,
|
|
377
|
+
input,
|
|
378
|
+
expectedOutput,
|
|
379
|
+
finalSample: () => finalReadSample,
|
|
380
|
+
writerBefore,
|
|
381
|
+
setupBefore,
|
|
382
|
+
calls,
|
|
383
|
+
promises,
|
|
384
|
+
counters,
|
|
385
|
+
capture() {
|
|
386
|
+
const handle = actor.captureOwnedRenewalObservationV2();
|
|
387
|
+
return Object.freeze({
|
|
388
|
+
invoke() {
|
|
389
|
+
counters.target++;
|
|
390
|
+
const promise = Reflect.apply(
|
|
391
|
+
handle.invoke,
|
|
392
|
+
handle,
|
|
393
|
+
[],
|
|
394
|
+
) as ReturnType<typeof handle.invoke>;
|
|
395
|
+
pending.push(
|
|
396
|
+
promise.then(
|
|
397
|
+
() => {},
|
|
398
|
+
() => {},
|
|
399
|
+
),
|
|
400
|
+
);
|
|
401
|
+
return promise;
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
cleanup: clean,
|
|
406
|
+
};
|
|
407
|
+
} catch (error) {
|
|
408
|
+
await clean();
|
|
409
|
+
throw error;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
@@ -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
|
+
});
|