@fantastic.dev/better-stripe 0.90.0 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
- package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
- package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +454 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
- package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
- package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
- package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
- package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
- package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
- package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
- package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
- package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
- package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
- package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
- package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
- package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
- package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
- package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
- package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
- package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
- package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
- package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
- package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
- package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
- package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
- package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
- package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +26 -8
- package/docs/renewal-material-observation.md +37 -0
- package/docs/renewal-phase-assembly.md +68 -0
- package/docs/renewal-raw-acquisition.md +19 -5
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
- package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
- package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
- package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
- package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
- package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
- package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
- package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
- package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
- package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
- package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
- package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
- package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
- package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
- package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
- package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
- package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
- package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
- package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
- package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
- package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
- package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
- package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
- package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
- package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
- package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
- package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
- package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
- package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
- package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
- package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
- package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
- package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
- package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
- package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
- package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
- package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
- package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
- package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
- package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import type { OWNER } from "../originalOwner.js";
|
|
3
|
+
import type { declaredInputs, declaredEntries } from "./attachEntries.js";
|
|
4
|
+
import type { Observations } from "./attachObservations.js";
|
|
5
|
+
import type {
|
|
6
|
+
prepareRenewalPriceReplacementV2,
|
|
7
|
+
prepareRenewalScheduleAttachmentV2,
|
|
8
|
+
} from "../../../renewalV2/index.js";
|
|
9
|
+
import type { validateOwnedReadMaterial } from "../material/readMaterial.js";
|
|
10
|
+
import { requiredJSONSnapshot } from "../material/requiredJson.js";
|
|
11
|
+
import { data, metrics } from "./attachScenarioBarriers.js";
|
|
12
|
+
type Declared = ReturnType<typeof declaredInputs>;
|
|
13
|
+
export interface AssertionFixture {
|
|
14
|
+
OWNER: typeof OWNER;
|
|
15
|
+
original: Declared["original"];
|
|
16
|
+
declared: Declared;
|
|
17
|
+
prepared: Awaited<ReturnType<typeof prepareRenewalPriceReplacementV2>>;
|
|
18
|
+
request: Awaited<ReturnType<typeof prepareRenewalScheduleAttachmentV2>>;
|
|
19
|
+
reads: ReturnType<typeof validateOwnedReadMaterial>;
|
|
20
|
+
entries: ReturnType<typeof declaredEntries>;
|
|
21
|
+
state: Observations;
|
|
22
|
+
record: unknown;
|
|
23
|
+
plan: readonly unknown[];
|
|
24
|
+
calls: { method: string }[];
|
|
25
|
+
posts: unknown[];
|
|
26
|
+
originalBasis: typeof OWNER.basis;
|
|
27
|
+
getStats(): { sourceLoads: number; reservations: number; slotTakes: number };
|
|
28
|
+
health(): void;
|
|
29
|
+
}
|
|
30
|
+
export function scenarioAssertions(h: AssertionFixture) {
|
|
31
|
+
const { state } = h;
|
|
32
|
+
function fit(value: unknown) {
|
|
33
|
+
const row = metrics(value);
|
|
34
|
+
assert(
|
|
35
|
+
row.chars <= 500000 &&
|
|
36
|
+
row.bytes <= 500000 &&
|
|
37
|
+
row.nodes <= 10000 &&
|
|
38
|
+
row.depth <= 40,
|
|
39
|
+
);
|
|
40
|
+
return row;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
assertAcknowledged(value: unknown) {
|
|
44
|
+
const out = data(value),
|
|
45
|
+
receipt = data(out.receipt),
|
|
46
|
+
observation = data(out.observation);
|
|
47
|
+
assert.equal(out.kind, "EXPLICIT_ATTACH_RECOVERY_V2_DATA_ONLY");
|
|
48
|
+
assert.equal(out.status, "attach_acknowledged");
|
|
49
|
+
assert.equal(out.operationalAuthority, false);
|
|
50
|
+
assert.equal(receipt.scheduleId, h.declared.post.id);
|
|
51
|
+
assert.deepEqual(receipt.request, h.request);
|
|
52
|
+
assert.deepEqual(receipt.providerSnapshot, h.declared.bPost);
|
|
53
|
+
assert.deepEqual(observation, {
|
|
54
|
+
schedule: h.declared.coverageCurrent.wireSubscription.schedule,
|
|
55
|
+
conflict: true,
|
|
56
|
+
authority: "unowned_prepost_observation_only",
|
|
57
|
+
});
|
|
58
|
+
assert.equal(observation.authority, "unowned_prepost_observation_only");
|
|
59
|
+
assert(Object.isFrozen(out));
|
|
60
|
+
},
|
|
61
|
+
assertBInnerOwnership() {
|
|
62
|
+
const stats = h.getStats();
|
|
63
|
+
assert.equal(stats.reservations, 1);
|
|
64
|
+
assert.equal(stats.sourceLoads, 1);
|
|
65
|
+
assert.equal(
|
|
66
|
+
h.calls.filter((row) => row.method === "GET").length,
|
|
67
|
+
h.plan.length * 2,
|
|
68
|
+
);
|
|
69
|
+
assert(state.pairA && state.pairB);
|
|
70
|
+
assert.notEqual(state.pairA, state.pairB);
|
|
71
|
+
assert.notEqual(state.pairA.capability, state.pairB.capability);
|
|
72
|
+
assert.notEqual(state.callbacks[0], state.aCallbacks[0]);
|
|
73
|
+
assert.equal(h.entries.stats.coversReplay, 1);
|
|
74
|
+
assert.equal(stats.slotTakes, 1);
|
|
75
|
+
assert.equal(h.posts.length, 2);
|
|
76
|
+
assert.equal(state.records.length, 3);
|
|
77
|
+
assert(state.receipt);
|
|
78
|
+
assert.equal(state.c3AtPrefix, 2);
|
|
79
|
+
assert.equal(h.OWNER.basis, h.originalBasis);
|
|
80
|
+
const actual = data(data(state.records[0].data).request);
|
|
81
|
+
for (const key of [
|
|
82
|
+
"scope",
|
|
83
|
+
"apiVersion",
|
|
84
|
+
"method",
|
|
85
|
+
"path",
|
|
86
|
+
"payload",
|
|
87
|
+
"key",
|
|
88
|
+
"firstDispatchedAt",
|
|
89
|
+
] as const)
|
|
90
|
+
assert.deepEqual(actual[key], h.request[key]);
|
|
91
|
+
},
|
|
92
|
+
assertWholeMetrics() {
|
|
93
|
+
const parts: [string, unknown][] = [
|
|
94
|
+
["originalRecord", h.record],
|
|
95
|
+
...state.records.map((record, i): [string, unknown] => [
|
|
96
|
+
"C10-" + i,
|
|
97
|
+
record,
|
|
98
|
+
]),
|
|
99
|
+
["result", state.result],
|
|
100
|
+
];
|
|
101
|
+
for (const [part, value] of parts) {
|
|
102
|
+
assert(value);
|
|
103
|
+
console.log(
|
|
104
|
+
JSON.stringify({
|
|
105
|
+
kind: "RECOVERY_ACTOR_ACTUAL_BOUNDARY_METRICS",
|
|
106
|
+
part,
|
|
107
|
+
...fit(value),
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
assertOutputOnlyOverflow(value: unknown) {
|
|
113
|
+
h.OWNER.check();
|
|
114
|
+
const out = data(value);
|
|
115
|
+
assert.equal(out.status, "fulfilled_unverified");
|
|
116
|
+
assert(Object.prototype.hasOwnProperty.call(out, "quarantine"));
|
|
117
|
+
assert.equal(state.records.length, 3);
|
|
118
|
+
assert(state.receipt);
|
|
119
|
+
assert.equal(state.c3Entries, 1);
|
|
120
|
+
assert.equal(state.outputEntries, 1);
|
|
121
|
+
const proposed = {
|
|
122
|
+
kind: "EXPLICIT_ATTACH_RECOVERY_V2_DATA_ONLY",
|
|
123
|
+
status: "attach_acknowledged",
|
|
124
|
+
operationalAuthority: false,
|
|
125
|
+
receipt: state.receipt,
|
|
126
|
+
observation: {
|
|
127
|
+
schedule: h.declared.coverageCurrent.wireSubscription.schedule,
|
|
128
|
+
conflict: true,
|
|
129
|
+
authority: "unowned_prepost_observation_only",
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
const row = metrics(proposed);
|
|
133
|
+
assert(row.chars > 500000);
|
|
134
|
+
fit(h.record);
|
|
135
|
+
for (const record of state.records) fit(record);
|
|
136
|
+
assert.equal(state.result, null);
|
|
137
|
+
console.log(
|
|
138
|
+
JSON.stringify({
|
|
139
|
+
kind: "RECOVERY_ACK_WRAPPER_REFUSAL_METRICS",
|
|
140
|
+
...row,
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
ordinaryCredentialRejected() {
|
|
145
|
+
try {
|
|
146
|
+
requiredJSONSnapshot({ client_secret: "" });
|
|
147
|
+
return false;
|
|
148
|
+
} catch {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
assertInitialAcknowledged(value: unknown) {
|
|
153
|
+
const out = data(value);
|
|
154
|
+
assert.equal(out.status, "attach_acknowledged");
|
|
155
|
+
assert.equal(out.operationalAuthority, false);
|
|
156
|
+
assert.equal(data(out.receipt).scheduleId, h.declared.post.id);
|
|
157
|
+
assert.deepEqual(Object.keys(out).sort(), [
|
|
158
|
+
"operationalAuthority",
|
|
159
|
+
"receipt",
|
|
160
|
+
"status",
|
|
161
|
+
]);
|
|
162
|
+
assert.deepEqual(data(out.receipt).request, h.request);
|
|
163
|
+
assert.deepEqual(data(out.receipt).providerSnapshot, h.declared.aPost);
|
|
164
|
+
assert.deepEqual(out.receipt, state.aReceipt);
|
|
165
|
+
assert.equal(state.aC3Entries, 1);
|
|
166
|
+
assert.equal(state.aC3AtPrefix, 2);
|
|
167
|
+
assert(Object.isFrozen(out));
|
|
168
|
+
assert(Object.isFrozen(out.receipt));
|
|
169
|
+
assert.equal(state.aRecords.length, 3);
|
|
170
|
+
assert.equal(h.posts.length, 1);
|
|
171
|
+
console.log(
|
|
172
|
+
JSON.stringify({
|
|
173
|
+
kind: "INITIAL_ACTOR_ACTUAL_ACK_WRAPPER_METRICS",
|
|
174
|
+
...fit(out),
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
for (const record of state.aRecords) fit(record);
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { webcrypto } from "node:crypto";
|
|
3
|
+
import { vi } from "vitest";
|
|
4
|
+
export function data(value: unknown): Record<string, unknown> {
|
|
5
|
+
assert(value !== null && typeof value === "object" && !Array.isArray(value));
|
|
6
|
+
return value as Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export function list(value: unknown): Record<string, unknown>[] {
|
|
9
|
+
assert(Array.isArray(value));
|
|
10
|
+
return value.map(data);
|
|
11
|
+
}
|
|
12
|
+
export function metrics(value: unknown) {
|
|
13
|
+
const text = JSON.stringify(value);
|
|
14
|
+
assert.equal(typeof text, "string");
|
|
15
|
+
let nodes = 0,
|
|
16
|
+
depth = 0;
|
|
17
|
+
const active = new Set<object>();
|
|
18
|
+
function visit(v: unknown, d: number) {
|
|
19
|
+
nodes++;
|
|
20
|
+
depth = Math.max(depth, d);
|
|
21
|
+
if (v && typeof v === "object") {
|
|
22
|
+
assert(!active.has(v));
|
|
23
|
+
active.add(v);
|
|
24
|
+
for (const child of Object.values(v)) visit(child, d + 1);
|
|
25
|
+
active.delete(v);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
visit(value, 0);
|
|
29
|
+
return {
|
|
30
|
+
chars: text.length,
|
|
31
|
+
bytes: new TextEncoder().encode(text).length,
|
|
32
|
+
nodes,
|
|
33
|
+
depth,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function deferred() {
|
|
37
|
+
let resolve!: () => void;
|
|
38
|
+
const promise = new Promise<void>((r) => {
|
|
39
|
+
resolve = r;
|
|
40
|
+
});
|
|
41
|
+
return { promise, resolve };
|
|
42
|
+
}
|
|
43
|
+
export function barriers() {
|
|
44
|
+
const rows = new Map<
|
|
45
|
+
string,
|
|
46
|
+
{
|
|
47
|
+
entered: ReturnType<typeof deferred>;
|
|
48
|
+
release: ReturnType<typeof deferred>;
|
|
49
|
+
}
|
|
50
|
+
>();
|
|
51
|
+
const get = (name: string) => {
|
|
52
|
+
let value = rows.get(name);
|
|
53
|
+
if (!value) {
|
|
54
|
+
value = { entered: deferred(), release: deferred() };
|
|
55
|
+
rows.set(name, value);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
get,
|
|
61
|
+
async hold(name: string) {
|
|
62
|
+
const value = get(name);
|
|
63
|
+
value.entered.resolve();
|
|
64
|
+
await value.release.promise;
|
|
65
|
+
},
|
|
66
|
+
release(name: string) {
|
|
67
|
+
get(name).release.resolve();
|
|
68
|
+
},
|
|
69
|
+
releaseAll() {
|
|
70
|
+
for (const value of rows.values()) value.release.resolve();
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export type Barriers = ReturnType<typeof barriers>;
|
|
75
|
+
export function installDigestBarrier(
|
|
76
|
+
state: {
|
|
77
|
+
recovering: boolean;
|
|
78
|
+
phase: string;
|
|
79
|
+
replay: boolean;
|
|
80
|
+
digestHeld: boolean;
|
|
81
|
+
observerErrors: unknown[];
|
|
82
|
+
pending: Promise<unknown>[];
|
|
83
|
+
},
|
|
84
|
+
name: string,
|
|
85
|
+
gates: Barriers,
|
|
86
|
+
) {
|
|
87
|
+
let digests = 0;
|
|
88
|
+
vi.stubGlobal("crypto", {
|
|
89
|
+
subtle: {
|
|
90
|
+
digest(
|
|
91
|
+
algorithm: Parameters<typeof webcrypto.subtle.digest>[0],
|
|
92
|
+
input: Parameters<typeof webcrypto.subtle.digest>[1],
|
|
93
|
+
) {
|
|
94
|
+
const actual = webcrypto.subtle.digest(algorithm, input);
|
|
95
|
+
const observed = actual.then(async (value) => {
|
|
96
|
+
if (!state.recovering) return value;
|
|
97
|
+
const index = ++digests;
|
|
98
|
+
let hold =
|
|
99
|
+
(name === "G07-retire" || name === "G10-delivery") && index === 1;
|
|
100
|
+
hold ||= name === "G07-C2" && state.phase === "C2";
|
|
101
|
+
hold ||= name === "G07-replay" && state.replay;
|
|
102
|
+
hold ||= name === "G07-C3" && state.phase === "C3";
|
|
103
|
+
if (name === "G07-C10") {
|
|
104
|
+
try {
|
|
105
|
+
assert(ArrayBuffer.isView(input) && input.byteLength <= 500000);
|
|
106
|
+
const tuple: unknown = JSON.parse(
|
|
107
|
+
new TextDecoder("utf-8", { fatal: true }).decode(
|
|
108
|
+
new Uint8Array(
|
|
109
|
+
input.buffer,
|
|
110
|
+
input.byteOffset,
|
|
111
|
+
input.byteLength,
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
assert(Array.isArray(tuple));
|
|
116
|
+
hold ||=
|
|
117
|
+
tuple[2] === "unbound-qualification-event" &&
|
|
118
|
+
data(tuple[3]).sequence === 1;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
state.observerErrors.push(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (hold && !state.digestHeld) {
|
|
124
|
+
state.digestHeld = true;
|
|
125
|
+
await gates.hold("B_DIGEST");
|
|
126
|
+
}
|
|
127
|
+
return value;
|
|
128
|
+
});
|
|
129
|
+
state.pending.push(observed.catch(() => {}));
|
|
130
|
+
return observed;
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export type Observed =
|
|
136
|
+
{ ok: true; value: Record<string, unknown> } | { ok: false; error: Error };
|
|
137
|
+
export const observe = (p: Promise<unknown>): Promise<Observed> =>
|
|
138
|
+
p.then(
|
|
139
|
+
(value) => ({ ok: true, value: data(value) }),
|
|
140
|
+
(error: unknown) => {
|
|
141
|
+
assert(error instanceof Error);
|
|
142
|
+
return { ok: false, error };
|
|
143
|
+
},
|
|
144
|
+
);
|
package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import type { PreflightFixture } from "./configurePreflightOperation.js";
|
|
3
|
+
import { data } from "./configurePreflightControls.js";
|
|
4
|
+
import { configureReadMetrics as metrics } from "./configureReadOperation.js";
|
|
5
|
+
|
|
6
|
+
export { metrics };
|
|
7
|
+
|
|
8
|
+
export function assertFit(value: unknown) {
|
|
9
|
+
const result = metrics(value);
|
|
10
|
+
assert(result.chars <= 500000 && result.bytes <= 500000);
|
|
11
|
+
assert(result.nodes <= 10000 && result.depth <= 40);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function assertNoPreflightWrites(
|
|
16
|
+
h: PreflightFixture,
|
|
17
|
+
expectedOwner: "live" | "retired" = "live",
|
|
18
|
+
) {
|
|
19
|
+
assert.equal(h.deltas().POST, 0);
|
|
20
|
+
assert.equal(h.deltas().records, 0);
|
|
21
|
+
if (expectedOwner === "retired")
|
|
22
|
+
assert.throws(() => h.OWNER.basis, {
|
|
23
|
+
name: "Error",
|
|
24
|
+
message: "ORIGINAL_OWNER_STOP",
|
|
25
|
+
});
|
|
26
|
+
else assert.equal(h.OWNER.basis, h.basis);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function expectedPreflightOutput(h: PreflightFixture) {
|
|
30
|
+
return {
|
|
31
|
+
status: "configure_preflight_consistent",
|
|
32
|
+
originalRecord: h.expectedRecord,
|
|
33
|
+
currentEvidence: h.expectedEvidence,
|
|
34
|
+
request: h.projected,
|
|
35
|
+
operationalAuthority: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function assertPreflightPositive(h: PreflightFixture, value: unknown) {
|
|
40
|
+
const out = data(value);
|
|
41
|
+
assert.deepEqual(out, expectedPreflightOutput(h));
|
|
42
|
+
assert.deepEqual(Object.keys(out).sort(), [
|
|
43
|
+
"currentEvidence",
|
|
44
|
+
"operationalAuthority",
|
|
45
|
+
"originalRecord",
|
|
46
|
+
"request",
|
|
47
|
+
"status",
|
|
48
|
+
]);
|
|
49
|
+
assert.equal(Object.keys(data(out.originalRecord)).length, 4);
|
|
50
|
+
assert.equal(Object.keys(data(out.currentEvidence)).length, 3);
|
|
51
|
+
assert.equal(Object.keys(data(out.request)).length, 18);
|
|
52
|
+
const receipt = data(h.acknowledgement),
|
|
53
|
+
attach = data(receipt.request);
|
|
54
|
+
const recordSlots: [string[], unknown][] = [
|
|
55
|
+
[["request", "logicalBinding"], h.projected.logicalBinding],
|
|
56
|
+
[["request", "attachReceiptBinding"], h.projected.attachReceiptBinding],
|
|
57
|
+
[["request", "baselineBinding"], h.projected.baselineBinding],
|
|
58
|
+
[["request", "defaultSettingsBinding"], h.projected.defaultSettingsBinding],
|
|
59
|
+
[
|
|
60
|
+
["request", "requestIdentity", "binding"],
|
|
61
|
+
h.projected.requestIdentity.binding,
|
|
62
|
+
],
|
|
63
|
+
[["attachReceipt", "logicalBinding"], receipt.logicalBinding],
|
|
64
|
+
[["attachReceipt", "request", "logicalBinding"], attach.logicalBinding],
|
|
65
|
+
[
|
|
66
|
+
["attachReceipt", "request", "requestIdentity", "binding"],
|
|
67
|
+
data(attach.requestIdentity).binding,
|
|
68
|
+
],
|
|
69
|
+
[["attachReceipt", "binding"], receipt.binding],
|
|
70
|
+
];
|
|
71
|
+
const allSlots: [string[], unknown][] = [
|
|
72
|
+
...recordSlots.map(([path, expected]): [string[], unknown] => [
|
|
73
|
+
["originalRecord", ...path],
|
|
74
|
+
expected,
|
|
75
|
+
]),
|
|
76
|
+
...recordSlots.slice(0, 5),
|
|
77
|
+
];
|
|
78
|
+
assert.equal(allSlots.length, 14);
|
|
79
|
+
for (const [path, expected] of allSlots) {
|
|
80
|
+
let found: unknown = out;
|
|
81
|
+
for (const key of path) found = data(found)[key];
|
|
82
|
+
assert.equal(found, expected);
|
|
83
|
+
}
|
|
84
|
+
assert(Object.isFrozen(out));
|
|
85
|
+
for (const key of ["originalRecord", "currentEvidence", "request"] as const)
|
|
86
|
+
assert(Object.isFrozen(out[key]));
|
|
87
|
+
assert(Object.isFrozen(data(out.currentEvidence).schedule));
|
|
88
|
+
assert.notEqual(data(out.originalRecord).attachReceipt, h.acknowledgement);
|
|
89
|
+
assert.equal(
|
|
90
|
+
data(out.currentEvidence).observedAt,
|
|
91
|
+
Math.floor(h.declared.scheduleAt / 1000),
|
|
92
|
+
);
|
|
93
|
+
assert.equal(h.state.c6, 2);
|
|
94
|
+
assert.equal(h.state.c3, 1); // Explicit actor reconstruction; not nested constructor internals.
|
|
95
|
+
assert.equal(h.state.releaseEntries, 1);
|
|
96
|
+
assert.equal(h.state.coverage, 1);
|
|
97
|
+
assert.equal(h.state.pairLoads, 1);
|
|
98
|
+
assert.equal(h.state.pairCreations, 1);
|
|
99
|
+
assert.equal(h.state.readerBindings, 1);
|
|
100
|
+
assert.equal(h.state.children, 1);
|
|
101
|
+
assert.equal(h.state.finishes, 1);
|
|
102
|
+
assert.equal(h.state.finishAt, h.declared.scheduleAt);
|
|
103
|
+
assert.equal(
|
|
104
|
+
h.deltas().GET,
|
|
105
|
+
4 + h.declared.original.originalBundle.couponReads.length,
|
|
106
|
+
);
|
|
107
|
+
assert(h.deltas().GET <= 44);
|
|
108
|
+
assertNoPreflightWrites(h);
|
|
109
|
+
assert.equal(h.OWNER.check().retired, false);
|
|
110
|
+
for (const [part, item] of [
|
|
111
|
+
["record", h.expectedRecord],
|
|
112
|
+
["currentEvidence", out.currentEvidence],
|
|
113
|
+
["output", out],
|
|
114
|
+
] as const)
|
|
115
|
+
console.log(
|
|
116
|
+
JSON.stringify({
|
|
117
|
+
kind: "OWNED_PREFLIGHT_ACTUAL_METRICS",
|
|
118
|
+
part,
|
|
119
|
+
...assertFit(item),
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|