@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,175 @@
|
|
|
1
|
+
import { need, closed, freeze } from "../material/nodeKernel.js";
|
|
2
|
+
import { equal, referenceId } from "../../../renewalAggregate/shared.js";
|
|
3
|
+
import type { Bundle, FreshInput } from "../material/capture.js";
|
|
4
|
+
|
|
5
|
+
function object(value: unknown): Record<string, unknown> {
|
|
6
|
+
need(value !== null && typeof value === "object" && !Array.isArray(value));
|
|
7
|
+
return value as Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
const couponID = (id: unknown): id is string =>
|
|
10
|
+
typeof id === "string" &&
|
|
11
|
+
id.length > 0 &&
|
|
12
|
+
id.length <= 255 &&
|
|
13
|
+
/\S/.test(id) &&
|
|
14
|
+
id !== "." &&
|
|
15
|
+
id !== "..";
|
|
16
|
+
|
|
17
|
+
/** Complete Coupon counterpart relation; no enriched body replaces retained raw JSON. */
|
|
18
|
+
function rebuild(b: Bundle) {
|
|
19
|
+
const subscription = b.wireSubscription;
|
|
20
|
+
need(
|
|
21
|
+
subscription &&
|
|
22
|
+
subscription.items &&
|
|
23
|
+
Array.isArray(subscription.items.data) &&
|
|
24
|
+
subscription.items.data.length === 1,
|
|
25
|
+
);
|
|
26
|
+
const lists = [subscription.discounts, subscription.items.data[0].discounts];
|
|
27
|
+
need(lists.every((x) => Array.isArray(x) && x.length <= 20));
|
|
28
|
+
need(Array.isArray(b.couponReads) && b.couponReads.length <= 40);
|
|
29
|
+
const ids = new Map<string, number>();
|
|
30
|
+
const joined = lists.map((list) =>
|
|
31
|
+
list.map((discount, index) => {
|
|
32
|
+
need(discount && discount.source);
|
|
33
|
+
const ref = discount.source.coupon,
|
|
34
|
+
id = typeof ref === "string" ? ref : ref?.id;
|
|
35
|
+
need(couponID(id));
|
|
36
|
+
if (!ids.has(id)) {
|
|
37
|
+
const i = ids.size,
|
|
38
|
+
row = closed(b.couponReads[i], [
|
|
39
|
+
"couponId",
|
|
40
|
+
"wireCoupon",
|
|
41
|
+
"association",
|
|
42
|
+
]),
|
|
43
|
+
association = closed(row.association, ["resource", "ordinal"]);
|
|
44
|
+
need(
|
|
45
|
+
row.couponId === id &&
|
|
46
|
+
association.resource === "coupon" &&
|
|
47
|
+
association.ordinal === 4 + i,
|
|
48
|
+
);
|
|
49
|
+
const c = object(row.wireCoupon);
|
|
50
|
+
need(c.id === id && c.object === "coupon" && c.deleted !== true);
|
|
51
|
+
ids.set(id, i);
|
|
52
|
+
}
|
|
53
|
+
const couponReadIndex = ids.get(id);
|
|
54
|
+
need(couponReadIndex !== undefined);
|
|
55
|
+
const coupon = b.couponReads[couponReadIndex].wireCoupon;
|
|
56
|
+
need(typeof ref === "string" || equal(ref, coupon));
|
|
57
|
+
const joinedDiscount = {
|
|
58
|
+
...discount,
|
|
59
|
+
source: { ...discount.source, coupon },
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
index,
|
|
63
|
+
discountId: discount.id,
|
|
64
|
+
originalCouponReference: ref,
|
|
65
|
+
couponReadIndex,
|
|
66
|
+
joinedDiscount,
|
|
67
|
+
};
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
need(
|
|
71
|
+
ids.size === b.couponReads.length &&
|
|
72
|
+
equal(b.derivedCouponJoins, { subscription: joined[0], item: joined[1] }),
|
|
73
|
+
);
|
|
74
|
+
return {
|
|
75
|
+
subscription: joined[0].map((x) => x.joinedDiscount),
|
|
76
|
+
item: joined[1].map((x) => x.joinedDiscount),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** One explicit root schedule association transition, with all residual material equal. */
|
|
81
|
+
export function replayCouponEligibility(value: FreshInput) {
|
|
82
|
+
const p = value.attachRequest.preparation,
|
|
83
|
+
original = value.originalBundle,
|
|
84
|
+
current = value.currentBundle;
|
|
85
|
+
need(
|
|
86
|
+
Object.prototype.hasOwnProperty.call(
|
|
87
|
+
original.wireSubscription,
|
|
88
|
+
"schedule",
|
|
89
|
+
) &&
|
|
90
|
+
original.wireSubscription.schedule === null &&
|
|
91
|
+
Object.prototype.hasOwnProperty.call(
|
|
92
|
+
current.wireSubscription,
|
|
93
|
+
"schedule",
|
|
94
|
+
) &&
|
|
95
|
+
current.wireSubscription.schedule !== null,
|
|
96
|
+
);
|
|
97
|
+
const { schedule: oldAssociation, ...oldResidual } =
|
|
98
|
+
original.wireSubscription,
|
|
99
|
+
{ schedule: currentAssociation, ...currentResidual } =
|
|
100
|
+
current.wireSubscription;
|
|
101
|
+
need(
|
|
102
|
+
oldAssociation === null &&
|
|
103
|
+
equal(p.subscription, original.wireSubscription) &&
|
|
104
|
+
equal(oldResidual, currentResidual),
|
|
105
|
+
);
|
|
106
|
+
for (const [key, wire] of [
|
|
107
|
+
["targetPrice", "wireTargetPrice"],
|
|
108
|
+
["billingCustomer", "wireBillingCustomer"],
|
|
109
|
+
] as const)
|
|
110
|
+
need(equal(p[key], original[wire]) && equal(original[wire], current[wire]));
|
|
111
|
+
rebuild(original);
|
|
112
|
+
const joined = rebuild(current);
|
|
113
|
+
need(equal(original.couponReads, current.couponReads));
|
|
114
|
+
const expected = p.expected,
|
|
115
|
+
context = {
|
|
116
|
+
customerAccountId: expected.customerAccountId,
|
|
117
|
+
livemode: expected.livemode,
|
|
118
|
+
};
|
|
119
|
+
const scheduleId = referenceId(
|
|
120
|
+
currentAssociation,
|
|
121
|
+
"sub_sched",
|
|
122
|
+
"subscription_schedule",
|
|
123
|
+
context,
|
|
124
|
+
),
|
|
125
|
+
customerId = referenceId(
|
|
126
|
+
current.wireSubscription.customer,
|
|
127
|
+
"cus",
|
|
128
|
+
"customer",
|
|
129
|
+
context,
|
|
130
|
+
);
|
|
131
|
+
function check(
|
|
132
|
+
v: unknown,
|
|
133
|
+
kind: "customer" | "subscription" | "subscription_schedule",
|
|
134
|
+
depth: number,
|
|
135
|
+
): void {
|
|
136
|
+
need(depth <= 40);
|
|
137
|
+
const prefix =
|
|
138
|
+
kind === "customer"
|
|
139
|
+
? "cus"
|
|
140
|
+
: kind === "subscription"
|
|
141
|
+
? "sub"
|
|
142
|
+
: "sub_sched",
|
|
143
|
+
id =
|
|
144
|
+
kind === "customer"
|
|
145
|
+
? customerId
|
|
146
|
+
: kind === "subscription"
|
|
147
|
+
? expected.subscriptionId
|
|
148
|
+
: scheduleId;
|
|
149
|
+
need(referenceId(v, prefix, kind, context) === id);
|
|
150
|
+
if (typeof v === "string") return;
|
|
151
|
+
const node = object(v);
|
|
152
|
+
need(
|
|
153
|
+
!Object.prototype.hasOwnProperty.call(node, "deleted") ||
|
|
154
|
+
node.deleted === false,
|
|
155
|
+
);
|
|
156
|
+
if (
|
|
157
|
+
kind !== "customer" &&
|
|
158
|
+
Object.prototype.hasOwnProperty.call(node, "customer")
|
|
159
|
+
)
|
|
160
|
+
check(node.customer, "customer", depth + 1);
|
|
161
|
+
if (
|
|
162
|
+
kind === "subscription" &&
|
|
163
|
+
Object.prototype.hasOwnProperty.call(node, "schedule")
|
|
164
|
+
)
|
|
165
|
+
check(node.schedule, "subscription_schedule", depth + 1);
|
|
166
|
+
if (
|
|
167
|
+
kind === "subscription_schedule" &&
|
|
168
|
+
Object.prototype.hasOwnProperty.call(node, "subscription")
|
|
169
|
+
)
|
|
170
|
+
check(node.subscription, "subscription", depth + 1);
|
|
171
|
+
}
|
|
172
|
+
check(current.wireSubscription, "subscription", 0);
|
|
173
|
+
check(current.wireBillingCustomer, "customer", 0);
|
|
174
|
+
return freeze(joined);
|
|
175
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { freeze } from "../material/nodeKernel.js";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { configurationInput } from "../acquisition/test-fixtures/fixture.mjs";
|
|
4
|
+
import {
|
|
5
|
+
captureRetainedInput,
|
|
6
|
+
type Bundle,
|
|
7
|
+
type RetainedInput,
|
|
8
|
+
} from "../material/capture.js";
|
|
9
|
+
import type {
|
|
10
|
+
prepareRenewalPriceReplacementV2,
|
|
11
|
+
prepareRenewalScheduleAttachmentV2,
|
|
12
|
+
} from "../../../renewalV2/index.js";
|
|
13
|
+
import type { validateOwnedReadMaterial } from "../material/readMaterial.js";
|
|
14
|
+
import { equal } from "../../../renewalAggregate/shared.js";
|
|
15
|
+
import { data, list } from "./attachScenarioBarriers.js";
|
|
16
|
+
export const clone = structuredClone;
|
|
17
|
+
export function declaredInputs(name: string) {
|
|
18
|
+
// All raw transforms precede constructors. Whole configurationInput source parity is recorded outside W.
|
|
19
|
+
const seed = data(configurationInput()),
|
|
20
|
+
preparation = data(clone(seed.preparation)),
|
|
21
|
+
subscription = data(preparation.subscription);
|
|
22
|
+
const couponReads: Record<string, unknown>[] = [],
|
|
23
|
+
ids = new Set<unknown>();
|
|
24
|
+
for (const source of [subscription, list(data(subscription.items).data)[0]])
|
|
25
|
+
for (const discount of list(source.discounts)) {
|
|
26
|
+
const ref = data(discount.source),
|
|
27
|
+
coupon = data(ref.coupon);
|
|
28
|
+
coupon.times_redeemed = 7;
|
|
29
|
+
coupon.metadata = { declared: "SYNTHETIC_RETAINED_315", opaque: "keep" };
|
|
30
|
+
coupon.future_native = { unknown: [null, 1.25, "ordinary"] };
|
|
31
|
+
if (!ids.has(coupon.id)) {
|
|
32
|
+
ids.add(coupon.id);
|
|
33
|
+
couponReads.push({
|
|
34
|
+
couponId: coupon.id,
|
|
35
|
+
wireCoupon: clone(coupon),
|
|
36
|
+
association: { resource: "coupon", ordinal: 4 + couponReads.length },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
ref.coupon = coupon.id;
|
|
40
|
+
}
|
|
41
|
+
subscription.opaque = { preserved: ["Sub", null] };
|
|
42
|
+
data(preparation.targetPrice).opaque = { preserved: "Price" };
|
|
43
|
+
data(preparation.billingCustomer).opaque = { preserved: "Customer" };
|
|
44
|
+
const joins = [
|
|
45
|
+
subscription.discounts,
|
|
46
|
+
list(data(subscription.items).data)[0].discounts,
|
|
47
|
+
].map((value) =>
|
|
48
|
+
list(value).map((discount, index) => {
|
|
49
|
+
const ref = data(discount.source).coupon,
|
|
50
|
+
couponReadIndex = couponReads.findIndex((row) => row.couponId === ref);
|
|
51
|
+
assert(couponReadIndex >= 0);
|
|
52
|
+
return {
|
|
53
|
+
index,
|
|
54
|
+
discountId: discount.id,
|
|
55
|
+
originalCouponReference: clone(ref),
|
|
56
|
+
couponReadIndex,
|
|
57
|
+
joinedDiscount: {
|
|
58
|
+
...clone(discount),
|
|
59
|
+
source: {
|
|
60
|
+
...clone(data(discount.source)),
|
|
61
|
+
coupon: clone(couponReads[couponReadIndex].wireCoupon),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
const expected = data(preparation.expected);
|
|
68
|
+
assert(typeof expected.periodStart === "number");
|
|
69
|
+
const original = captureRetainedInput({
|
|
70
|
+
attachRequest: {
|
|
71
|
+
preparation,
|
|
72
|
+
apiVersion: "2026-09-30.endive",
|
|
73
|
+
attachKey: "attach:retained315",
|
|
74
|
+
firstDispatchedAt: expected.periodStart + 1,
|
|
75
|
+
},
|
|
76
|
+
originalBundle: {
|
|
77
|
+
wireSubscription: clone(subscription),
|
|
78
|
+
wireTargetPrice: clone(preparation.targetPrice),
|
|
79
|
+
wireBillingCustomer: clone(preparation.billingCustomer),
|
|
80
|
+
couponReads,
|
|
81
|
+
derivedCouponJoins: { subscription: joins[0], item: joins[1] },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const current = clone(original.originalBundle);
|
|
85
|
+
current.wireSubscription.schedule =
|
|
86
|
+
name === "G02-expanded" || name === "G14-output"
|
|
87
|
+
? {
|
|
88
|
+
id: "sub_sched_observed_recovery",
|
|
89
|
+
object: "subscription_schedule",
|
|
90
|
+
deleted: false,
|
|
91
|
+
subscription: expected.subscriptionId,
|
|
92
|
+
customer: original.originalBundle.wireBillingCustomer.id,
|
|
93
|
+
customer_account: expected.customerAccountId,
|
|
94
|
+
livemode: false,
|
|
95
|
+
...(name === "G14-output" ? { opaque: "o".repeat(120000) } : {}),
|
|
96
|
+
}
|
|
97
|
+
: "sub_sched_observed_recovery";
|
|
98
|
+
const coverageCurrent = clone(current);
|
|
99
|
+
if (name === "G06-current") {
|
|
100
|
+
const item = data(current.wireSubscription.items.data[0]);
|
|
101
|
+
assert(typeof item.quantity === "number");
|
|
102
|
+
item.quantity++;
|
|
103
|
+
}
|
|
104
|
+
const post = clone(data(data(seed.attachReceipt).providerSnapshot));
|
|
105
|
+
post.created = original.attachRequest.firstDispatchedAt;
|
|
106
|
+
const aPost = clone(post),
|
|
107
|
+
bPost = clone(post);
|
|
108
|
+
if (name === "G09-q") aPost.opaque = "x".repeat(500001);
|
|
109
|
+
if (name === "G12-wrong-identity") bPost.subscription = "sub_OTHER";
|
|
110
|
+
if (name === "G14-output") bPost.opaque = "p".repeat(400000);
|
|
111
|
+
return freeze({ original, current, coverageCurrent, post, aPost, bPost });
|
|
112
|
+
}
|
|
113
|
+
type Prepared = Awaited<ReturnType<typeof prepareRenewalPriceReplacementV2>>;
|
|
114
|
+
type Request = Awaited<ReturnType<typeof prepareRenewalScheduleAttachmentV2>>;
|
|
115
|
+
type Reads = ReturnType<typeof validateOwnedReadMaterial>;
|
|
116
|
+
export function declaredEntries(
|
|
117
|
+
original: RetainedInput,
|
|
118
|
+
prepared: Prepared,
|
|
119
|
+
request: Request,
|
|
120
|
+
reads: Reads,
|
|
121
|
+
coverageCurrent: Bundle,
|
|
122
|
+
retainedResult: true | 1 = true,
|
|
123
|
+
) {
|
|
124
|
+
const expectedMaterial = (
|
|
125
|
+
b: Bundle,
|
|
126
|
+
intent: "initial" | "replay_unknown",
|
|
127
|
+
fresh: boolean,
|
|
128
|
+
) => {
|
|
129
|
+
const item = data(b.wireSubscription.items.data[0]);
|
|
130
|
+
return {
|
|
131
|
+
classificationRevision: "renewal-material-v2",
|
|
132
|
+
protocolRevision: "renewal-stage-protocol-v1",
|
|
133
|
+
stage: "attach",
|
|
134
|
+
intent,
|
|
135
|
+
scope: request.scope,
|
|
136
|
+
apiVersion: request.apiVersion,
|
|
137
|
+
profile: reads.profile,
|
|
138
|
+
quantity: prepared.quantity,
|
|
139
|
+
currentPrice: item.price,
|
|
140
|
+
targetPrice: b.wireTargetPrice,
|
|
141
|
+
source: b.wireSubscription,
|
|
142
|
+
nativeItem: item,
|
|
143
|
+
billingCustomer: b.wireBillingCustomer,
|
|
144
|
+
subscriptionDiscounts: reads.discounts,
|
|
145
|
+
itemDiscounts: reads.itemDiscounts,
|
|
146
|
+
settings: reads.originalSettings,
|
|
147
|
+
originalPrepared: prepared,
|
|
148
|
+
completeRequest: request,
|
|
149
|
+
stageEvidence: {
|
|
150
|
+
actualFreshSubscription: b.wireSubscription,
|
|
151
|
+
...(intent === "replay_unknown"
|
|
152
|
+
? {
|
|
153
|
+
historicalOriginalSubscription:
|
|
154
|
+
original.originalBundle.wireSubscription,
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
157
|
+
},
|
|
158
|
+
rawSources: fresh
|
|
159
|
+
? {
|
|
160
|
+
attachRequest: original.attachRequest,
|
|
161
|
+
intent,
|
|
162
|
+
freshSubscription: b.wireSubscription,
|
|
163
|
+
targetPrice: b.wireTargetPrice,
|
|
164
|
+
billingCustomer: b.wireBillingCustomer,
|
|
165
|
+
observedAt: original.attachRequest.firstDispatchedAt,
|
|
166
|
+
}
|
|
167
|
+
: { attachRequest: original.attachRequest, intent },
|
|
168
|
+
freshness: fresh ? "fresh" : "retained",
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const retained = expectedMaterial(original.originalBundle, "initial", false),
|
|
172
|
+
stats = {
|
|
173
|
+
coversReplay: 0,
|
|
174
|
+
retainedCalls: 0,
|
|
175
|
+
retainedMatches: 0,
|
|
176
|
+
lastRetainedResult: null as unknown,
|
|
177
|
+
};
|
|
178
|
+
const entry = Object.freeze({
|
|
179
|
+
coversRetained(value: unknown, bundle: unknown) {
|
|
180
|
+
stats.retainedCalls++;
|
|
181
|
+
const matches =
|
|
182
|
+
Object.keys(data(value)).length === 21 &&
|
|
183
|
+
equal(value, retained) &&
|
|
184
|
+
equal(bundle, original.originalBundle);
|
|
185
|
+
if (matches) stats.retainedMatches++;
|
|
186
|
+
const result = matches ? retainedResult : false;
|
|
187
|
+
stats.lastRetainedResult = result;
|
|
188
|
+
return result;
|
|
189
|
+
},
|
|
190
|
+
coversFresh(value: unknown, before: unknown, current: unknown) {
|
|
191
|
+
return (
|
|
192
|
+
equal(
|
|
193
|
+
value,
|
|
194
|
+
expectedMaterial(original.originalBundle, "initial", true),
|
|
195
|
+
) &&
|
|
196
|
+
equal(before, original.originalBundle) &&
|
|
197
|
+
equal(current, original.originalBundle)
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
const relation = Object.freeze({
|
|
202
|
+
originalEntry: entry,
|
|
203
|
+
coversReplay(value: unknown, before: unknown, current: unknown) {
|
|
204
|
+
stats.coversReplay++;
|
|
205
|
+
return (
|
|
206
|
+
Object.keys(data(value)).length === 21 &&
|
|
207
|
+
equal(
|
|
208
|
+
value,
|
|
209
|
+
expectedMaterial(coverageCurrent, "replay_unknown", true),
|
|
210
|
+
) &&
|
|
211
|
+
equal(before, original.originalBundle) &&
|
|
212
|
+
equal(current, coverageCurrent)
|
|
213
|
+
);
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
return { entry, relation, retained, stats };
|
|
217
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import type { FailureForwarder } from "../operations/ownedAwait.js";
|
|
4
|
+
import type { createInitialOwnedTransportWithAttemptCapability } from "../operations/fixedTransport.js";
|
|
5
|
+
import { data } from "./attachScenarioBarriers.js";
|
|
6
|
+
type Pair = ReturnType<typeof createInitialOwnedTransportWithAttemptCapability>;
|
|
7
|
+
export function observationState() {
|
|
8
|
+
return {
|
|
9
|
+
recovering: false,
|
|
10
|
+
phase: "",
|
|
11
|
+
replay: false,
|
|
12
|
+
digestHeld: false,
|
|
13
|
+
observerErrors: [] as unknown[],
|
|
14
|
+
pending: [] as Promise<unknown>[],
|
|
15
|
+
c3Entries: 0,
|
|
16
|
+
aC3Entries: 0,
|
|
17
|
+
aC3AtPrefix: 0,
|
|
18
|
+
aReceipt: null as unknown,
|
|
19
|
+
c3AtPrefix: 0,
|
|
20
|
+
c1Entries: 0,
|
|
21
|
+
records: [] as Record<string, unknown>[],
|
|
22
|
+
aRecords: [] as Record<string, unknown>[],
|
|
23
|
+
callbacks: [] as ((value: unknown) => void)[],
|
|
24
|
+
aCallbacks: [] as ((value: unknown) => void)[],
|
|
25
|
+
control: null as unknown,
|
|
26
|
+
pairA: null as Pair | null,
|
|
27
|
+
pairB: null as Pair | null,
|
|
28
|
+
receipt: null as unknown,
|
|
29
|
+
result: null as unknown,
|
|
30
|
+
aToken: null as unknown,
|
|
31
|
+
aReply: null as unknown,
|
|
32
|
+
outputEntries: 0,
|
|
33
|
+
compilerReceipt: false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export type Observations = ReturnType<typeof observationState>;
|
|
37
|
+
export async function installObservers(
|
|
38
|
+
s: Observations,
|
|
39
|
+
name: string,
|
|
40
|
+
retire: () => void,
|
|
41
|
+
) {
|
|
42
|
+
vi.doMock("../operations/ownedAwait.js", async () => {
|
|
43
|
+
const actual = await vi.importActual<
|
|
44
|
+
typeof import("../operations/ownedAwait.js")
|
|
45
|
+
>("../operations/ownedAwait.js");
|
|
46
|
+
return {
|
|
47
|
+
...actual,
|
|
48
|
+
owned<T>(
|
|
49
|
+
work: () => T | PromiseLike<T>,
|
|
50
|
+
control: FailureForwarder | null = null,
|
|
51
|
+
) {
|
|
52
|
+
if (s.recovering && control) s.control = control;
|
|
53
|
+
const p = actual.owned(work, control);
|
|
54
|
+
s.pending.push(
|
|
55
|
+
p.then(
|
|
56
|
+
() => {},
|
|
57
|
+
(error) => {
|
|
58
|
+
if (!s.recovering && control) s.aToken = error;
|
|
59
|
+
},
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
return p;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
vi.doMock("../../../renewalV2/index.js", async () => {
|
|
67
|
+
const actual = await vi.importActual<
|
|
68
|
+
typeof import("../../../renewalV2/index.js")
|
|
69
|
+
>("../../../renewalV2/index.js");
|
|
70
|
+
return {
|
|
71
|
+
...actual,
|
|
72
|
+
prepareRenewalPriceReplacementV2(
|
|
73
|
+
...args: Parameters<typeof actual.prepareRenewalPriceReplacementV2>
|
|
74
|
+
) {
|
|
75
|
+
if (s.recovering && ++s.c1Entries >= 3) s.replay = true;
|
|
76
|
+
return actual.prepareRenewalPriceReplacementV2(...args);
|
|
77
|
+
},
|
|
78
|
+
prepareRenewalScheduleAttachmentV2(
|
|
79
|
+
...args: Parameters<typeof actual.prepareRenewalScheduleAttachmentV2>
|
|
80
|
+
) {
|
|
81
|
+
const prior = s.phase;
|
|
82
|
+
s.phase = "C2";
|
|
83
|
+
const p = actual.prepareRenewalScheduleAttachmentV2(...args);
|
|
84
|
+
s.pending.push(
|
|
85
|
+
p.then(
|
|
86
|
+
() => {
|
|
87
|
+
s.phase = prior;
|
|
88
|
+
},
|
|
89
|
+
() => {
|
|
90
|
+
s.phase = prior;
|
|
91
|
+
},
|
|
92
|
+
),
|
|
93
|
+
);
|
|
94
|
+
return p;
|
|
95
|
+
},
|
|
96
|
+
constructRenewalScheduleAttachmentReceiptV2(
|
|
97
|
+
...args: Parameters<
|
|
98
|
+
typeof actual.constructRenewalScheduleAttachmentReceiptV2
|
|
99
|
+
>
|
|
100
|
+
) {
|
|
101
|
+
const explicit = !s.compilerReceipt;
|
|
102
|
+
if (explicit) {
|
|
103
|
+
if (s.recovering) {
|
|
104
|
+
s.c3Entries++;
|
|
105
|
+
s.c3AtPrefix = s.records.length;
|
|
106
|
+
} else {
|
|
107
|
+
s.aC3Entries++;
|
|
108
|
+
s.aC3AtPrefix = s.aRecords.length;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const prior = s.phase;
|
|
112
|
+
if (explicit) s.phase = "C3";
|
|
113
|
+
const p = actual.constructRenewalScheduleAttachmentReceiptV2(...args);
|
|
114
|
+
s.pending.push(
|
|
115
|
+
p.then(
|
|
116
|
+
(value) => {
|
|
117
|
+
if (explicit) {
|
|
118
|
+
if (s.recovering) s.receipt = value;
|
|
119
|
+
else s.aReceipt = value;
|
|
120
|
+
}
|
|
121
|
+
s.phase = prior;
|
|
122
|
+
},
|
|
123
|
+
() => {
|
|
124
|
+
s.phase = prior;
|
|
125
|
+
},
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
return p;
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
vi.doMock("../c10/attachEvents.js", async () => {
|
|
133
|
+
const actual = await vi.importActual<
|
|
134
|
+
typeof import("../c10/attachEvents.js")
|
|
135
|
+
>("../c10/attachEvents.js");
|
|
136
|
+
return {
|
|
137
|
+
...actual,
|
|
138
|
+
createAttachEventCompiler(
|
|
139
|
+
...args: Parameters<typeof actual.createAttachEventCompiler>
|
|
140
|
+
) {
|
|
141
|
+
const compiler = actual.createAttachEventCompiler(...args);
|
|
142
|
+
return Object.freeze({
|
|
143
|
+
...compiler,
|
|
144
|
+
receipt(value: unknown) {
|
|
145
|
+
s.compilerReceipt = true;
|
|
146
|
+
const p = compiler.receipt(value);
|
|
147
|
+
s.pending.push(
|
|
148
|
+
p.then(
|
|
149
|
+
() => {
|
|
150
|
+
s.compilerReceipt = false;
|
|
151
|
+
},
|
|
152
|
+
() => {
|
|
153
|
+
s.compilerReceipt = false;
|
|
154
|
+
},
|
|
155
|
+
),
|
|
156
|
+
);
|
|
157
|
+
return p;
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
vi.doMock("../operations/fixedTransport.js", async () => {
|
|
164
|
+
const actual = await vi.importActual<
|
|
165
|
+
typeof import("../operations/fixedTransport.js")
|
|
166
|
+
>("../operations/fixedTransport.js");
|
|
167
|
+
return {
|
|
168
|
+
...actual,
|
|
169
|
+
createInitialOwnedTransportWithAttemptCapability() {
|
|
170
|
+
const pair = actual.createInitialOwnedTransportWithAttemptCapability();
|
|
171
|
+
s.pairA = pair;
|
|
172
|
+
return pair;
|
|
173
|
+
},
|
|
174
|
+
createRecoveryOwnedTransportWithAttemptCapability() {
|
|
175
|
+
const pair = actual.createRecoveryOwnedTransportWithAttemptCapability();
|
|
176
|
+
s.pairB = pair;
|
|
177
|
+
return pair;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
vi.doMock("../recovery/output.js", async () => {
|
|
182
|
+
const actual = await vi.importActual<
|
|
183
|
+
typeof import("../recovery/output.js")
|
|
184
|
+
>("../recovery/output.js");
|
|
185
|
+
return {
|
|
186
|
+
...actual,
|
|
187
|
+
admitRecoveryOutput(
|
|
188
|
+
...args: Parameters<typeof actual.admitRecoveryOutput>
|
|
189
|
+
) {
|
|
190
|
+
s.outputEntries++;
|
|
191
|
+
const result = actual.admitRecoveryOutput(...args);
|
|
192
|
+
s.result = result;
|
|
193
|
+
if (name === "G07-result") retire();
|
|
194
|
+
return result;
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
export function controlView(value: unknown) {
|
|
200
|
+
const record = data(value);
|
|
201
|
+
const call = (name: string, args: unknown[]) => {
|
|
202
|
+
const f = record[name];
|
|
203
|
+
assert.equal(typeof f, "function");
|
|
204
|
+
return Reflect.apply(f as (...xs: unknown[]) => unknown, value, args);
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
forward: (value: unknown) => call("forward", [value]),
|
|
208
|
+
takePostQuarantine: (...args: unknown[]) =>
|
|
209
|
+
call("takePostQuarantine", args),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export function cleanAttachMocks() {
|
|
213
|
+
for (const name of [
|
|
214
|
+
"../sourceBindings.js",
|
|
215
|
+
"../operations/sourceOperations.js",
|
|
216
|
+
"../operations/ownedAwait.js",
|
|
217
|
+
"../../../renewalV2/index.js",
|
|
218
|
+
"../c10/attachEvents.js",
|
|
219
|
+
"../operations/fixedTransport.js",
|
|
220
|
+
"../recovery/output.js",
|
|
221
|
+
])
|
|
222
|
+
vi.doUnmock(name);
|
|
223
|
+
vi.unstubAllGlobals();
|
|
224
|
+
vi.restoreAllMocks();
|
|
225
|
+
vi.resetModules();
|
|
226
|
+
}
|