@fantastic.dev/better-stripe 0.91.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 +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/configure/actor.js +46 -56
- package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -1
- 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/observation/actor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/actor.js +25 -4
- package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/capture.js +3 -2
- package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -1
- 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/types.d.ts +5 -0
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
- 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/usageCredits/accounting.fixtures.d.ts +16 -16
- package/docs/renewal-material-observation.md +32 -11
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/configure/actor.ts +63 -52
- package/src/client/billing/renewalAttach/internal/configure/ownedContinuation.ts +56 -0
- package/src/client/billing/renewalAttach/internal/observation/actor.ts +46 -3
- package/src/client/billing/renewalAttach/internal/observation/capture.ts +3 -2
- package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -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/types.ts +5 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +5 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +12 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +8 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +10 -23
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { vi } from "vitest";
|
|
3
3
|
import { declaredEntries } from "./attachEntries.js";
|
|
4
|
+
import { captureWriteTestDelegate } from "./configureWriteDelegate.js";
|
|
4
5
|
import {
|
|
5
6
|
declarePreflightCase,
|
|
6
7
|
deepFreeze,
|
|
@@ -502,29 +503,13 @@ export async function configureWriteFixture(mode: WriteCase = "ack") {
|
|
|
502
503
|
writeGates,
|
|
503
504
|
);
|
|
504
505
|
installWriteDigestAccounting(writeGates);
|
|
505
|
-
const writeDelegate =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
assert.equal(options.maxNetworkRetries, 0);
|
|
513
|
-
assert.equal(
|
|
514
|
-
Object.prototype.hasOwnProperty.call(options, "stripeAccount"),
|
|
515
|
-
false,
|
|
516
|
-
);
|
|
517
|
-
const promise = Reflect.apply(method, client, args) as Promise<unknown>;
|
|
518
|
-
state.originalPromises.push(promise);
|
|
519
|
-
writeGates.pending.push(
|
|
520
|
-
promise.then(
|
|
521
|
-
() => {},
|
|
522
|
-
() => {},
|
|
523
|
-
),
|
|
524
|
-
);
|
|
525
|
-
return promise;
|
|
526
|
-
},
|
|
527
|
-
});
|
|
506
|
+
const writeDelegate = captureWriteTestDelegate(
|
|
507
|
+
client,
|
|
508
|
+
method,
|
|
509
|
+
() => family?.currentObservations() ?? writeState,
|
|
510
|
+
writeGates,
|
|
511
|
+
write.baseline.apiVersion,
|
|
512
|
+
);
|
|
528
513
|
family = await configureWriteTestFamily({
|
|
529
514
|
declared: write,
|
|
530
515
|
declarations,
|
|
@@ -582,6 +567,8 @@ export async function configureWriteFixture(mode: WriteCase = "ack") {
|
|
|
582
567
|
expectedACK,
|
|
583
568
|
replayDeclaration: declareExpectedReplay(projected),
|
|
584
569
|
captureWriter: family.captureA,
|
|
570
|
+
fixedAOperation: family.fixedAOperation,
|
|
571
|
+
readFixedA: family.readFixedA,
|
|
585
572
|
captureReplayB: family.captureB,
|
|
586
573
|
captureReplayC: family.captureC,
|
|
587
574
|
replayStates: Object.freeze({ B: family.states.B, C: family.states.C }),
|
package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { data } from "./configurePreflightControls.js";
|
|
3
|
+
import { assertFit } from "./configurePreflightAssertions.js";
|
|
4
|
+
import type { optionalConfigureACK18Fixture } from "./observationConfigureACKOperation.js";
|
|
5
|
+
|
|
6
|
+
export function assertOptionalConfigureACK18(
|
|
7
|
+
h: Awaited<ReturnType<typeof optionalConfigureACK18Fixture>>,
|
|
8
|
+
output: unknown,
|
|
9
|
+
) {
|
|
10
|
+
assert.deepEqual(output, h.expectedOutput);
|
|
11
|
+
const out = data(output);
|
|
12
|
+
assert.deepEqual(
|
|
13
|
+
Object.keys(out).sort(),
|
|
14
|
+
[
|
|
15
|
+
"status",
|
|
16
|
+
"observation",
|
|
17
|
+
"reads",
|
|
18
|
+
"observedAt",
|
|
19
|
+
"retainedConfigureAcknowledgement",
|
|
20
|
+
"operationalAuthority",
|
|
21
|
+
].sort(),
|
|
22
|
+
);
|
|
23
|
+
assert.equal(out.retainedConfigureAcknowledgement, "present");
|
|
24
|
+
assert.equal(out.operationalAuthority, false);
|
|
25
|
+
assert.equal(h.counters.target, 1);
|
|
26
|
+
assert.equal(h.counters.source, 1);
|
|
27
|
+
assert.equal(h.counters.coverage, 1);
|
|
28
|
+
assert.equal(h.counters.observer, 1);
|
|
29
|
+
assert.equal(h.counters.C6, 1);
|
|
30
|
+
assert.equal(h.counters.C3, 1);
|
|
31
|
+
assert.equal(h.counters.C9, 1);
|
|
32
|
+
assert.equal(h.counters.lookup, 1);
|
|
33
|
+
assert.notEqual(output, h.expectedOutput);
|
|
34
|
+
assert.notEqual(out.reads, h.declaration.reads);
|
|
35
|
+
assert.notEqual(data(out.reads).schedule, h.declaration.reads.schedule);
|
|
36
|
+
assert.notEqual(out.observation, data(h.expectedOutput).observation);
|
|
37
|
+
assert.equal(h.writer.writeState.explicitC9, h.writerBefore.c9);
|
|
38
|
+
assert.equal(h.calls.length, 6);
|
|
39
|
+
assert.equal(h.promises.length, 6);
|
|
40
|
+
assert.deepEqual(
|
|
41
|
+
h.calls,
|
|
42
|
+
h.declaration.rows.map((row) => ({ method: "GET", path: row.path })),
|
|
43
|
+
);
|
|
44
|
+
assert.equal(h.writer.writeState.records.length, h.writerBefore.records);
|
|
45
|
+
assert.equal(
|
|
46
|
+
h.writer.writeState.calls.filter((row) => row.method === "POST").length,
|
|
47
|
+
h.writerBefore.posts,
|
|
48
|
+
);
|
|
49
|
+
assert.equal(h.writer.state.records.length, h.setupBefore.records);
|
|
50
|
+
assert.equal(
|
|
51
|
+
h.writer.state.calls.filter((row) => row.method === "POST").length,
|
|
52
|
+
h.setupBefore.posts,
|
|
53
|
+
);
|
|
54
|
+
assert.equal(h.writer.OWNER.basis, h.basis);
|
|
55
|
+
assert.equal(h.operation.configureOperation, h.writer.fixedAOperation());
|
|
56
|
+
assert.equal(h.operation.configureAcknowledgement, h.writerACK);
|
|
57
|
+
assert.equal(
|
|
58
|
+
h.operation.actualAttachAcknowledgement,
|
|
59
|
+
h.writer.acknowledgement,
|
|
60
|
+
);
|
|
61
|
+
assertFit(output);
|
|
62
|
+
const frozen = (value: unknown) => {
|
|
63
|
+
if (value && typeof value === "object") {
|
|
64
|
+
assert(Object.isFrozen(value));
|
|
65
|
+
for (const child of Object.values(value)) frozen(child);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
frozen(output);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function assertOptionalConfigureACKRefusal(
|
|
72
|
+
h: Awaited<ReturnType<typeof optionalConfigureACK18Fixture>>,
|
|
73
|
+
error: unknown,
|
|
74
|
+
) {
|
|
75
|
+
assert.notEqual(h.selected.stage, "positive");
|
|
76
|
+
assert(error instanceof Error);
|
|
77
|
+
assert.equal(error.message, "OWNED_OBSERVATION_STOP");
|
|
78
|
+
for (const key of [
|
|
79
|
+
"failure",
|
|
80
|
+
"cause",
|
|
81
|
+
"rawError",
|
|
82
|
+
"rawReply",
|
|
83
|
+
"headers",
|
|
84
|
+
"token",
|
|
85
|
+
])
|
|
86
|
+
assert.equal(Object.prototype.hasOwnProperty.call(error, key), false);
|
|
87
|
+
const grammar = h.selected.stage === "grammar";
|
|
88
|
+
assert.deepEqual(h.counters, {
|
|
89
|
+
source: 1,
|
|
90
|
+
target: 1,
|
|
91
|
+
coverage: 0,
|
|
92
|
+
observer: 0,
|
|
93
|
+
C6: grammar ? 0 : 1,
|
|
94
|
+
C3: grammar ? 0 : 1,
|
|
95
|
+
C9: 0,
|
|
96
|
+
lookup: grammar ? 0 : 1,
|
|
97
|
+
});
|
|
98
|
+
assert.equal(h.calls.length, 0);
|
|
99
|
+
assert.equal(h.promises.length, 0);
|
|
100
|
+
assert.equal(h.writer.writeState.explicitC9, h.writerBefore.c9);
|
|
101
|
+
assert.equal(h.writer.writeState.records.length, h.writerBefore.records);
|
|
102
|
+
assert.equal(
|
|
103
|
+
h.writer.writeState.calls.filter((row) => row.method === "POST").length,
|
|
104
|
+
h.writerBefore.posts,
|
|
105
|
+
);
|
|
106
|
+
assert.equal(h.writer.state.records.length, h.setupBefore.records);
|
|
107
|
+
assert.equal(
|
|
108
|
+
h.writer.state.calls.filter((row) => row.method === "POST").length,
|
|
109
|
+
h.setupBefore.posts,
|
|
110
|
+
);
|
|
111
|
+
assert.equal(h.writer.OWNER.basis, h.basis);
|
|
112
|
+
assert.equal(h.writer.OWNER.check().retired, false);
|
|
113
|
+
assert.equal(h.operation.configureOperation, h.writer.fixedAOperation());
|
|
114
|
+
assert.equal(h.operation.configureAcknowledgement, h.writerACK);
|
|
115
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { declareConfigureWriteCase } from "./configureWriteDeclarations.js";
|
|
3
|
+
import { deepFreeze } from "./configurePreflightControls.js";
|
|
4
|
+
|
|
5
|
+
export const optionalConfigureACKControlCases = [
|
|
6
|
+
"actual19-default-null",
|
|
7
|
+
"actual19-default-object",
|
|
8
|
+
"cloned-returnedACK",
|
|
9
|
+
"foreign-operation",
|
|
10
|
+
"cloned-actual-operation",
|
|
11
|
+
"raw-C9-input-instead-of-returnedACK",
|
|
12
|
+
"own-ACK-undefined",
|
|
13
|
+
"own-ACK-null",
|
|
14
|
+
"ACK-present-operation-absent",
|
|
15
|
+
"operation-present-ACK-absent",
|
|
16
|
+
] as const;
|
|
17
|
+
export type OptionalConfigureACKControl =
|
|
18
|
+
(typeof optionalConfigureACKControlCases)[number];
|
|
19
|
+
export type OptionalConfigureACKCase =
|
|
20
|
+
OptionalConfigureACKControl | "actual18-default-absent";
|
|
21
|
+
|
|
22
|
+
/** Only raw/data recipes here; all precede actual setup constructors. */
|
|
23
|
+
function declareOptionalConfigureACK(
|
|
24
|
+
writerMode: "ack" | "defaults-null" | "defaults-object",
|
|
25
|
+
) {
|
|
26
|
+
const writer = declareConfigureWriteCase(writerMode);
|
|
27
|
+
const b = writer.currentBundle;
|
|
28
|
+
assert.equal(typeof writer.response.id, "string");
|
|
29
|
+
const scheduleId = writer.response.id;
|
|
30
|
+
assert(typeof scheduleId === "string");
|
|
31
|
+
const reads = {
|
|
32
|
+
schedule: structuredClone(writer.response),
|
|
33
|
+
subscription: structuredClone(b.wireSubscription),
|
|
34
|
+
targetPrice: structuredClone(b.wireTargetPrice),
|
|
35
|
+
billingCustomer: structuredClone(b.wireBillingCustomer),
|
|
36
|
+
coupons: b.couponReads.map((row) => structuredClone(row.wireCoupon)),
|
|
37
|
+
};
|
|
38
|
+
const query = new URLSearchParams([
|
|
39
|
+
["expand[0]", "discounts"],
|
|
40
|
+
["expand[1]", "items.data.discounts"],
|
|
41
|
+
["expand[2]", "items.data.price"],
|
|
42
|
+
]);
|
|
43
|
+
const e = writer.baseline.original.attachRequest.preparation.expected;
|
|
44
|
+
const rows = [
|
|
45
|
+
{
|
|
46
|
+
resource: "schedule",
|
|
47
|
+
path: "/v1/subscription_schedules/" + encodeURIComponent(scheduleId),
|
|
48
|
+
body: reads.schedule,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
resource: "subscription",
|
|
52
|
+
path:
|
|
53
|
+
"/v1/subscriptions/" +
|
|
54
|
+
encodeURIComponent(e.subscriptionId) +
|
|
55
|
+
"?" +
|
|
56
|
+
query,
|
|
57
|
+
body: reads.subscription,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
resource: "price",
|
|
61
|
+
path: "/v1/prices/" + encodeURIComponent(e.targetPriceId),
|
|
62
|
+
body: reads.targetPrice,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
resource: "customer",
|
|
66
|
+
path: "/v1/customers/" + encodeURIComponent(b.wireBillingCustomer.id),
|
|
67
|
+
body: reads.billingCustomer,
|
|
68
|
+
},
|
|
69
|
+
...b.couponReads.map((row) => ({
|
|
70
|
+
resource: "coupon",
|
|
71
|
+
path: "/v1/coupons/" + encodeURIComponent(row.couponId),
|
|
72
|
+
body: row.wireCoupon,
|
|
73
|
+
})),
|
|
74
|
+
];
|
|
75
|
+
return deepFreeze({
|
|
76
|
+
name:
|
|
77
|
+
writerMode === "ack"
|
|
78
|
+
? "actual-published-ACK18"
|
|
79
|
+
: "actual-published-ACK19",
|
|
80
|
+
writer,
|
|
81
|
+
reads,
|
|
82
|
+
rows: rows.map((row, i) => ({
|
|
83
|
+
...row,
|
|
84
|
+
ordinal: i + 1,
|
|
85
|
+
options: {
|
|
86
|
+
apiVersion: writer.baseline.apiVersion,
|
|
87
|
+
maxNetworkRetries: 0 as const,
|
|
88
|
+
},
|
|
89
|
+
})),
|
|
90
|
+
// Every declared writer response retains one phase. Absent/null defaults
|
|
91
|
+
// lack a historical object; object defaults still do not prove configured phases.
|
|
92
|
+
expectedObservation: {
|
|
93
|
+
acknowledgementEstablished: false,
|
|
94
|
+
authenticationEstablished: false,
|
|
95
|
+
providerQualificationRequired: true,
|
|
96
|
+
predicate: "unknown" as const,
|
|
97
|
+
reason:
|
|
98
|
+
writerMode === "defaults-object"
|
|
99
|
+
? "configured_baseline_material_unproven"
|
|
100
|
+
: "incomplete_object",
|
|
101
|
+
},
|
|
102
|
+
observedAt: Math.floor(writer.writeAt / 1000),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export type OptionalConfigureACK18 = ReturnType<
|
|
106
|
+
typeof declareOptionalConfigureACK18
|
|
107
|
+
>;
|
|
108
|
+
|
|
109
|
+
/** Original no-argument raw declaration remains the fixed absent-default18 recipe. */
|
|
110
|
+
export function declareOptionalConfigureACK18() {
|
|
111
|
+
return declareOptionalConfigureACK("ack");
|
|
112
|
+
}
|
|
113
|
+
export function declareOptionalConfigureACKCase(
|
|
114
|
+
controlCase: OptionalConfigureACKCase,
|
|
115
|
+
) {
|
|
116
|
+
const allowed: readonly string[] = [
|
|
117
|
+
"actual18-default-absent",
|
|
118
|
+
...optionalConfigureACKControlCases,
|
|
119
|
+
];
|
|
120
|
+
assert(allowed.includes(controlCase), "UNDECLARED_OPTIONAL_ACK_CASE");
|
|
121
|
+
const writerMode =
|
|
122
|
+
controlCase === "actual19-default-null"
|
|
123
|
+
? "defaults-null"
|
|
124
|
+
: controlCase === "actual19-default-object"
|
|
125
|
+
? "defaults-object"
|
|
126
|
+
: "ack";
|
|
127
|
+
const stage =
|
|
128
|
+
controlCase === "ACK-present-operation-absent" ||
|
|
129
|
+
controlCase === "operation-present-ACK-absent"
|
|
130
|
+
? "grammar"
|
|
131
|
+
: controlCase === "actual18-default-absent" ||
|
|
132
|
+
controlCase.startsWith("actual19-")
|
|
133
|
+
? "positive"
|
|
134
|
+
: "returned-value";
|
|
135
|
+
return deepFreeze({
|
|
136
|
+
controlCase,
|
|
137
|
+
writerMode,
|
|
138
|
+
stage,
|
|
139
|
+
declaration: declareOptionalConfigureACK(writerMode),
|
|
140
|
+
} as const);
|
|
141
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import type { configureACKLifecycleFixture } from "./observationConfigureACKLifecycleOperation.js";
|
|
3
|
+
|
|
4
|
+
export function assertConfigureACKLifecycleResult(
|
|
5
|
+
h: Awaited<ReturnType<typeof configureACKLifecycleFixture>>,
|
|
6
|
+
value: unknown,
|
|
7
|
+
) {
|
|
8
|
+
const retired = h.declaration.expectedOwner === "retired";
|
|
9
|
+
const c6Failure = h.declaration.controlCase === "L07-C6Failure-priority";
|
|
10
|
+
if (c6Failure) {
|
|
11
|
+
assert.equal(value, h.lastC6());
|
|
12
|
+
assert.deepEqual(value, h.directFailure);
|
|
13
|
+
} else {
|
|
14
|
+
assert(value instanceof Error);
|
|
15
|
+
assert.equal(
|
|
16
|
+
value.message,
|
|
17
|
+
retired ? "ORIGINAL_OWNER_STOP" : "OWNED_OBSERVATION_STOP",
|
|
18
|
+
);
|
|
19
|
+
for (const key of [
|
|
20
|
+
"failure",
|
|
21
|
+
"cause",
|
|
22
|
+
"rawError",
|
|
23
|
+
"rawReply",
|
|
24
|
+
"headers",
|
|
25
|
+
"token",
|
|
26
|
+
])
|
|
27
|
+
assert.equal(Object.prototype.hasOwnProperty.call(value, key), false);
|
|
28
|
+
}
|
|
29
|
+
assert.deepEqual(h.counters, {
|
|
30
|
+
source: retired ? 0 : 1,
|
|
31
|
+
target: 1,
|
|
32
|
+
captureEntered: retired ? 0 : 1,
|
|
33
|
+
captureCompleted: retired ? 0 : 1,
|
|
34
|
+
C6: retired ? 0 : 1,
|
|
35
|
+
C3: retired || c6Failure ? 0 : 1,
|
|
36
|
+
C9: 0,
|
|
37
|
+
lookup: retired || c6Failure ? 0 : 1,
|
|
38
|
+
lookupReturned: 0,
|
|
39
|
+
lookupThrew: retired || c6Failure ? 0 : 1,
|
|
40
|
+
observer: 0,
|
|
41
|
+
coverage: 0,
|
|
42
|
+
delegateEntered: 0,
|
|
43
|
+
});
|
|
44
|
+
assert.equal(h.calls.length, 0);
|
|
45
|
+
assert.equal(h.promises.length, 0);
|
|
46
|
+
assert.equal(h.writer.writeState.records.length, h.writerBefore.records);
|
|
47
|
+
assert.equal(
|
|
48
|
+
h.writer.writeState.calls.filter((row) => row.method === "POST").length,
|
|
49
|
+
h.writerBefore.POST,
|
|
50
|
+
);
|
|
51
|
+
assert.equal(h.writer.writeState.explicitC9, h.writerBefore.C9);
|
|
52
|
+
assert.equal(h.writer.state.records.length, h.setupBefore.records);
|
|
53
|
+
assert.equal(
|
|
54
|
+
h.writer.state.calls.filter((row) => row.method === "POST").length,
|
|
55
|
+
h.setupBefore.POST,
|
|
56
|
+
);
|
|
57
|
+
assert.equal(h.operation.configureOperation, h.writer.fixedAOperation());
|
|
58
|
+
assert.equal(
|
|
59
|
+
h.operation.actualAttachAcknowledgement,
|
|
60
|
+
h.writer.acknowledgement,
|
|
61
|
+
);
|
|
62
|
+
assert.deepEqual(h.writer.expectedRecord, h.savedOriginalRecord);
|
|
63
|
+
assert.deepEqual(h.writer.expectedACK, h.savedOracleACK);
|
|
64
|
+
if (retired)
|
|
65
|
+
assert.throws(() => h.writer.OWNER.basis, {
|
|
66
|
+
message: "ORIGINAL_OWNER_STOP",
|
|
67
|
+
});
|
|
68
|
+
else {
|
|
69
|
+
assert.equal(h.writer.OWNER.basis, h.basis);
|
|
70
|
+
assert.equal(h.writer.OWNER.check().retired, false);
|
|
71
|
+
}
|
|
72
|
+
if (h.declaration.controlCase === "L04-POST-pending")
|
|
73
|
+
assert.equal(h.writerSettled(), false);
|
|
74
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { deepFreeze } from "./configurePreflightControls.js";
|
|
3
|
+
import { declareConfigureWriteCase } from "./configureWriteDeclarations.js";
|
|
4
|
+
import { declareOptionalConfigureACK18 } from "./observationConfigureACKDeclarations.js";
|
|
5
|
+
|
|
6
|
+
export const configureACKLifecycleCases = [
|
|
7
|
+
"L01-output-abort",
|
|
8
|
+
"L02-receipt-ACK-fault",
|
|
9
|
+
"L03-final-discard-abort",
|
|
10
|
+
"L04-POST-pending",
|
|
11
|
+
"L05-POST-unknown",
|
|
12
|
+
"L06-receipt-ACK-retire",
|
|
13
|
+
"L07-C6Failure-priority",
|
|
14
|
+
] as const;
|
|
15
|
+
export type ConfigureACKLifecycleCase =
|
|
16
|
+
(typeof configureACKLifecycleCases)[number];
|
|
17
|
+
/** All choices and raw rows precede actual fixture constructors. */
|
|
18
|
+
export function declareConfigureACKLifecycle(
|
|
19
|
+
controlCase: ConfigureACKLifecycleCase,
|
|
20
|
+
) {
|
|
21
|
+
const allowed: readonly string[] = configureACKLifecycleCases;
|
|
22
|
+
assert(allowed.includes(controlCase), "UNDECLARED_LIFECYCLE_CASE");
|
|
23
|
+
const writerMode =
|
|
24
|
+
controlCase === "L04-POST-pending"
|
|
25
|
+
? "pending-prior"
|
|
26
|
+
: controlCase === "L05-POST-unknown"
|
|
27
|
+
? "post-reject"
|
|
28
|
+
: "ack";
|
|
29
|
+
const expectedOwner =
|
|
30
|
+
controlCase === "L06-receipt-ACK-retire" ? "retired" : "live";
|
|
31
|
+
const known = [
|
|
32
|
+
"L01-output-abort",
|
|
33
|
+
"L02-receipt-ACK-fault",
|
|
34
|
+
"L03-final-discard-abort",
|
|
35
|
+
"L06-receipt-ACK-retire",
|
|
36
|
+
].includes(controlCase);
|
|
37
|
+
const recordCount =
|
|
38
|
+
controlCase === "L01-output-abort"
|
|
39
|
+
? 2
|
|
40
|
+
: controlCase === "L04-POST-pending" || controlCase === "L05-POST-unknown"
|
|
41
|
+
? 1
|
|
42
|
+
: 3;
|
|
43
|
+
return deepFreeze({
|
|
44
|
+
controlCase,
|
|
45
|
+
writerMode,
|
|
46
|
+
expectedOwner,
|
|
47
|
+
known,
|
|
48
|
+
writer: declareConfigureWriteCase(writerMode),
|
|
49
|
+
readonly: declareOptionalConfigureACK18(),
|
|
50
|
+
expectedWriterAtRefusal: {
|
|
51
|
+
records: recordCount,
|
|
52
|
+
POST: 1,
|
|
53
|
+
C9: known || controlCase === "L07-C6Failure-priority" ? 1 : 0,
|
|
54
|
+
},
|
|
55
|
+
candidateKind:
|
|
56
|
+
controlCase === "L07-C6Failure-priority"
|
|
57
|
+
? "actual-returned-ACK"
|
|
58
|
+
: known
|
|
59
|
+
? "actual-admission-DATA-never-returned"
|
|
60
|
+
: "pure-oracle-DATA-only",
|
|
61
|
+
invalidAPI: "2026-01-01.unsupported",
|
|
62
|
+
expectedC6FailureReason: "invalid_attach_receipt_binding",
|
|
63
|
+
faults: {
|
|
64
|
+
output: "TEST_ABORT_AFTER_REAL_ACK_ADMISSION",
|
|
65
|
+
discard: "TEST_ABORT_AFTER_REAL_DISCARD",
|
|
66
|
+
},
|
|
67
|
+
expectedUnknown: {
|
|
68
|
+
status: "configure_unknown",
|
|
69
|
+
reason:
|
|
70
|
+
expectedOwner === "retired"
|
|
71
|
+
? "owner_closed_after_post"
|
|
72
|
+
: "post_unverified",
|
|
73
|
+
operationalAuthority: false,
|
|
74
|
+
},
|
|
75
|
+
} as const);
|
|
76
|
+
}
|
|
77
|
+
export type ConfigureACKLifecycleDeclaration = ReturnType<
|
|
78
|
+
typeof declareConfigureACKLifecycle
|
|
79
|
+
>;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import { data } from "./configurePreflightControls.js";
|
|
4
|
+
import type { ConfigureACKLifecycleDeclaration } from "./observationConfigureACKLifecycleDeclarations.js";
|
|
5
|
+
|
|
6
|
+
/** TEST-only fault observers. No History, map, returned-flag setter or Source registrar. */
|
|
7
|
+
export function installConfigureACKLifecycleInstrumentation(
|
|
8
|
+
d: ConfigureACKLifecycleDeclaration,
|
|
9
|
+
) {
|
|
10
|
+
const pending: Promise<unknown>[] = [];
|
|
11
|
+
const state = {
|
|
12
|
+
admitted: null as unknown,
|
|
13
|
+
admissions: 0,
|
|
14
|
+
outputAborts: 0,
|
|
15
|
+
receiptCalls: 0,
|
|
16
|
+
receiptFulfilled: 0,
|
|
17
|
+
receiptRejected: 0,
|
|
18
|
+
wrongACK: 0,
|
|
19
|
+
retirements: 0,
|
|
20
|
+
factoryPairs: 0,
|
|
21
|
+
sourceBindingTrue: 0,
|
|
22
|
+
reservationTrue: 0,
|
|
23
|
+
sameReadTransport: false,
|
|
24
|
+
discardEntered: 0,
|
|
25
|
+
discardCompleted: 0,
|
|
26
|
+
};
|
|
27
|
+
vi.doMock("../configure/output.js", async () => {
|
|
28
|
+
const actual = await vi.importActual<
|
|
29
|
+
typeof import("../configure/output.js")
|
|
30
|
+
>("../configure/output.js");
|
|
31
|
+
return {
|
|
32
|
+
...actual,
|
|
33
|
+
admitConfigureACK(
|
|
34
|
+
this: unknown,
|
|
35
|
+
...args: Parameters<typeof actual.admitConfigureACK>
|
|
36
|
+
) {
|
|
37
|
+
const result = Reflect.apply(
|
|
38
|
+
actual.admitConfigureACK,
|
|
39
|
+
this,
|
|
40
|
+
args,
|
|
41
|
+
) as ReturnType<typeof actual.admitConfigureACK>;
|
|
42
|
+
state.admissions++;
|
|
43
|
+
state.admitted = result;
|
|
44
|
+
if (d.controlCase === "L01-output-abort") {
|
|
45
|
+
state.outputAborts++;
|
|
46
|
+
throw Error(d.faults.output);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
vi.doMock("../c10/configureEvents.js", async () => {
|
|
53
|
+
const actual = await vi.importActual<
|
|
54
|
+
typeof import("../c10/configureEvents.js")
|
|
55
|
+
>("../c10/configureEvents.js");
|
|
56
|
+
const { OWNER } = await import("../originalOwner.js");
|
|
57
|
+
return {
|
|
58
|
+
...actual,
|
|
59
|
+
createConfigureEventCompiler(
|
|
60
|
+
this: unknown,
|
|
61
|
+
...args: Parameters<typeof actual.createConfigureEventCompiler>
|
|
62
|
+
) {
|
|
63
|
+
let selected = args;
|
|
64
|
+
if (d.controlCase === "L02-receipt-ACK-fault") {
|
|
65
|
+
const options = data(args[1]);
|
|
66
|
+
const send = options.send;
|
|
67
|
+
assert(typeof send === "function");
|
|
68
|
+
const faulted = {
|
|
69
|
+
...options,
|
|
70
|
+
send(record: unknown, acknowledge: (value: unknown) => void) {
|
|
71
|
+
const receipt = data(record).sequence === 3;
|
|
72
|
+
const ack = receipt
|
|
73
|
+
? (value: unknown) => {
|
|
74
|
+
state.wrongACK++;
|
|
75
|
+
acknowledge({ ...data(value), binding: "wrong" });
|
|
76
|
+
}
|
|
77
|
+
: acknowledge;
|
|
78
|
+
return Reflect.apply(send, options, [record, ack]);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
selected = [args[0], faulted];
|
|
82
|
+
}
|
|
83
|
+
const compiler = Reflect.apply(
|
|
84
|
+
actual.createConfigureEventCompiler,
|
|
85
|
+
this,
|
|
86
|
+
selected,
|
|
87
|
+
) as ReturnType<typeof actual.createConfigureEventCompiler>;
|
|
88
|
+
const forwarded = {
|
|
89
|
+
...compiler,
|
|
90
|
+
dispatch(...values: Parameters<typeof compiler.dispatch>) {
|
|
91
|
+
return Reflect.apply(
|
|
92
|
+
compiler.dispatch,
|
|
93
|
+
compiler,
|
|
94
|
+
values,
|
|
95
|
+
) as ReturnType<typeof compiler.dispatch>;
|
|
96
|
+
},
|
|
97
|
+
response(...values: Parameters<typeof compiler.response>) {
|
|
98
|
+
return Reflect.apply(
|
|
99
|
+
compiler.response,
|
|
100
|
+
compiler,
|
|
101
|
+
values,
|
|
102
|
+
) as ReturnType<typeof compiler.response>;
|
|
103
|
+
},
|
|
104
|
+
receipt(...values: Parameters<typeof compiler.receipt>) {
|
|
105
|
+
state.receiptCalls++;
|
|
106
|
+
const promise = Reflect.apply(
|
|
107
|
+
compiler.receipt,
|
|
108
|
+
compiler,
|
|
109
|
+
values,
|
|
110
|
+
) as ReturnType<typeof compiler.receipt>;
|
|
111
|
+
pending.push(
|
|
112
|
+
promise.then(
|
|
113
|
+
() => {
|
|
114
|
+
state.receiptFulfilled++;
|
|
115
|
+
if (d.controlCase === "L06-receipt-ACK-retire") {
|
|
116
|
+
state.retirements++;
|
|
117
|
+
OWNER.retire();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
() => {
|
|
121
|
+
state.receiptRejected++;
|
|
122
|
+
},
|
|
123
|
+
),
|
|
124
|
+
);
|
|
125
|
+
return promise;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
return Object.freeze(forwarded);
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
if (d.controlCase === "L03-final-discard-abort")
|
|
133
|
+
vi.doMock("../configure/transport.js", async () => {
|
|
134
|
+
const actual = await vi.importActual<
|
|
135
|
+
typeof import("../configure/transport.js")
|
|
136
|
+
>("../configure/transport.js");
|
|
137
|
+
return {
|
|
138
|
+
...actual,
|
|
139
|
+
createConfigureWriteTransport(
|
|
140
|
+
this: unknown,
|
|
141
|
+
...args: Parameters<typeof actual.createConfigureWriteTransport>
|
|
142
|
+
) {
|
|
143
|
+
const pair = Reflect.apply(
|
|
144
|
+
actual.createConfigureWriteTransport,
|
|
145
|
+
this,
|
|
146
|
+
args,
|
|
147
|
+
) as ReturnType<typeof actual.createConfigureWriteTransport>;
|
|
148
|
+
state.factoryPairs++;
|
|
149
|
+
const capability = Object.fromEntries(
|
|
150
|
+
Object.entries(pair.capability).map(([key, method]) => [
|
|
151
|
+
key,
|
|
152
|
+
(...values: unknown[]) => {
|
|
153
|
+
if (key !== "discardFulfilledQuarantine") {
|
|
154
|
+
const result: unknown = Reflect.apply(
|
|
155
|
+
method,
|
|
156
|
+
pair.capability,
|
|
157
|
+
values,
|
|
158
|
+
);
|
|
159
|
+
if (key === "assertSourceOperationBinding" && result === true)
|
|
160
|
+
state.sourceBindingTrue++;
|
|
161
|
+
if (key === "reserveAcquisition" && result === true)
|
|
162
|
+
state.reservationTrue++;
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
state.discardEntered++;
|
|
166
|
+
assert.equal(values.length, 0);
|
|
167
|
+
const result: unknown = Reflect.apply(
|
|
168
|
+
method,
|
|
169
|
+
pair.capability,
|
|
170
|
+
values,
|
|
171
|
+
);
|
|
172
|
+
assert.equal(result, undefined);
|
|
173
|
+
state.discardCompleted++;
|
|
174
|
+
throw Error(d.faults.discard);
|
|
175
|
+
},
|
|
176
|
+
]),
|
|
177
|
+
) as typeof pair.capability;
|
|
178
|
+
const wrapped = Object.freeze({
|
|
179
|
+
...pair,
|
|
180
|
+
capability: Object.freeze(capability),
|
|
181
|
+
});
|
|
182
|
+
state.sameReadTransport =
|
|
183
|
+
wrapped.transport === pair.transport &&
|
|
184
|
+
wrapped.transport.readTransport === pair.transport.readTransport;
|
|
185
|
+
return wrapped;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
state,
|
|
191
|
+
pending,
|
|
192
|
+
async join() {
|
|
193
|
+
await Promise.all(pending);
|
|
194
|
+
},
|
|
195
|
+
cleanup() {
|
|
196
|
+
for (const path of [
|
|
197
|
+
"../configure/output.js",
|
|
198
|
+
"../c10/configureEvents.js",
|
|
199
|
+
"../configure/transport.js",
|
|
200
|
+
"../configure/actor.js",
|
|
201
|
+
"../observation/record.js",
|
|
202
|
+
"../../../renewalV2/observation.js",
|
|
203
|
+
])
|
|
204
|
+
vi.doUnmock(path);
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|