@fantastic.dev/better-stripe 0.91.0 → 0.93.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/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/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +30 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +113 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +562 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +562 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +16 -3
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +6 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +406 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +294 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- 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/renewalOperations/helpers.d.ts +236 -0
- package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
- package/dist/component/renewalOperations/helpers.js +457 -0
- package/dist/component/renewalOperations/helpers.js.map +1 -0
- package/dist/component/renewalOperations/mutations.d.ts +252 -0
- package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
- package/dist/component/renewalOperations/mutations.js +340 -0
- package/dist/component/renewalOperations/mutations.js.map +1 -0
- package/dist/component/renewalOperations/queries.d.ts +163 -0
- package/dist/component/renewalOperations/queries.d.ts.map +1 -0
- package/dist/component/renewalOperations/queries.js +167 -0
- package/dist/component/renewalOperations/queries.js.map +1 -0
- package/dist/component/renewalOperations/schema.d.ts +1988 -0
- package/dist/component/renewalOperations/schema.d.ts.map +1 -0
- package/dist/component/renewalOperations/schema.js +227 -0
- package/dist/component/renewalOperations/schema.js.map +1 -0
- package/dist/component/schema.d.ts +281 -0
- package/dist/component/schema.js +5 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +281 -0
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +281 -0
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/dist/shared/renewalOperationJournal.d.ts +43 -0
- package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
- package/dist/shared/renewalOperationJournal.js +294 -0
- package/dist/shared/renewalOperationJournal.js.map +1 -0
- package/docs/renewal-context-reads.md +152 -0
- 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/operationJournal.integration.test.ts +380 -0
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +155 -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
- package/src/client/index.ts +24 -3
- package/src/component/_generated/api.ts +6 -0
- package/src/component/_generated/component.ts +450 -0
- package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
- package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
- package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
- package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
- package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
- package/src/component/renewalOperations/basisBinding.test.ts +567 -0
- package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
- package/src/component/renewalOperations/boundHistory.test.ts +474 -0
- package/src/component/renewalOperations/helpers.ts +592 -0
- package/src/component/renewalOperations/historyReads.test.ts +595 -0
- package/src/component/renewalOperations/initialBasis.test.ts +578 -0
- package/src/component/renewalOperations/journal.test.ts +567 -0
- package/src/component/renewalOperations/mutations.ts +456 -0
- package/src/component/renewalOperations/payload.test.ts +589 -0
- package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
- package/src/component/renewalOperations/queries.ts +204 -0
- package/src/component/renewalOperations/schema.ts +268 -0
- package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
- package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
- package/src/component/schema.ts +11 -0
- package/src/shared/renewalOperationJournal.ts +333 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import * as api from "../../../renewalV2/index.js";
|
|
4
|
+
import * as observer from "../../../renewalV2/observation.js";
|
|
5
|
+
import { configureWriteFixture } from "./configureWriteOperation.js";
|
|
6
|
+
import {
|
|
7
|
+
assertConfigureACK,
|
|
8
|
+
assertProviderFailure,
|
|
9
|
+
} from "./configureWriteAssertions.js";
|
|
10
|
+
import { assertFit } from "./configurePreflightAssertions.js";
|
|
11
|
+
import { data } from "./configurePreflightControls.js";
|
|
12
|
+
import {
|
|
13
|
+
declareConfigureACKLifecycle,
|
|
14
|
+
type ConfigureACKLifecycleCase,
|
|
15
|
+
} from "./observationConfigureACKLifecycleDeclarations.js";
|
|
16
|
+
import { installConfigureACKLifecycleInstrumentation } from "./observationConfigureACKLifecycleInstrumentation.js";
|
|
17
|
+
|
|
18
|
+
/** Negative lifecycle chain. Oracle/admission DATA is never relabeled a returned ACK. */
|
|
19
|
+
export async function configureACKLifecycleFixture(
|
|
20
|
+
controlCase: ConfigureACKLifecycleCase,
|
|
21
|
+
) {
|
|
22
|
+
const declaration = declareConfigureACKLifecycle(controlCase);
|
|
23
|
+
const instruments = installConfigureACKLifecycleInstrumentation(declaration);
|
|
24
|
+
const pending: Promise<unknown>[] = [];
|
|
25
|
+
let writer: Awaited<ReturnType<typeof configureWriteFixture>> | undefined;
|
|
26
|
+
let originalWriter: Promise<unknown> | undefined;
|
|
27
|
+
let settled = false;
|
|
28
|
+
let lastC6: unknown = null;
|
|
29
|
+
const counters = {
|
|
30
|
+
source: 0,
|
|
31
|
+
target: 0,
|
|
32
|
+
captureEntered: 0,
|
|
33
|
+
captureCompleted: 0,
|
|
34
|
+
C6: 0,
|
|
35
|
+
C3: 0,
|
|
36
|
+
C9: 0,
|
|
37
|
+
lookup: 0,
|
|
38
|
+
lookupReturned: 0,
|
|
39
|
+
lookupThrew: 0,
|
|
40
|
+
observer: 0,
|
|
41
|
+
coverage: 0,
|
|
42
|
+
delegateEntered: 0,
|
|
43
|
+
};
|
|
44
|
+
const calls: { method: string; path: string }[] = [];
|
|
45
|
+
const promises: Promise<unknown>[] = [];
|
|
46
|
+
const clean = async () => {
|
|
47
|
+
writer?.writeGates.release("post");
|
|
48
|
+
try {
|
|
49
|
+
if (originalWriter) await originalWriter.catch(() => {});
|
|
50
|
+
await Promise.all(pending);
|
|
51
|
+
await instruments.join();
|
|
52
|
+
} finally {
|
|
53
|
+
try {
|
|
54
|
+
if (writer) await writer.cleanup();
|
|
55
|
+
} finally {
|
|
56
|
+
instruments.cleanup();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
try {
|
|
61
|
+
writer = await configureWriteFixture(declaration.writerMode);
|
|
62
|
+
const w = writer;
|
|
63
|
+
assert.deepEqual(w.write, declaration.writer);
|
|
64
|
+
assert.equal(
|
|
65
|
+
instruments.state.admissions,
|
|
66
|
+
0,
|
|
67
|
+
"fixture oracle is not operation admission",
|
|
68
|
+
);
|
|
69
|
+
const basis = w.OWNER.basis;
|
|
70
|
+
const savedOriginalRecord = structuredClone(w.expectedRecord);
|
|
71
|
+
const savedOracleACK = structuredClone(w.expectedACK);
|
|
72
|
+
const actualOperation = w.fixedAOperation();
|
|
73
|
+
originalWriter = w.captureWriter().invoke();
|
|
74
|
+
const observedWriter = originalWriter.then(
|
|
75
|
+
(value) => {
|
|
76
|
+
settled = true;
|
|
77
|
+
return { ok: true as const, value };
|
|
78
|
+
},
|
|
79
|
+
(error: unknown) => {
|
|
80
|
+
settled = true;
|
|
81
|
+
return { ok: false as const, error };
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
pending.push(observedWriter.then(() => {}));
|
|
85
|
+
let publicWriterACK: unknown = null;
|
|
86
|
+
if (controlCase === "L04-POST-pending") {
|
|
87
|
+
await w.writeGates.entered("post", originalWriter);
|
|
88
|
+
assert.equal(settled, false);
|
|
89
|
+
} else {
|
|
90
|
+
const outcome = await observedWriter;
|
|
91
|
+
if (controlCase === "L05-POST-unknown") {
|
|
92
|
+
assert.equal(outcome.ok, false);
|
|
93
|
+
if (!outcome.ok) assertProviderFailure(w, outcome.error, "post");
|
|
94
|
+
} else {
|
|
95
|
+
assert.equal(outcome.ok, true);
|
|
96
|
+
if (!outcome.ok) assert.fail("EXPECTED_FIXED_WRITER_OUTCOME");
|
|
97
|
+
if (controlCase === "L07-C6Failure-priority") {
|
|
98
|
+
publicWriterACK = outcome.value;
|
|
99
|
+
assertConfigureACK(w, publicWriterACK);
|
|
100
|
+
assert.equal(publicWriterACK, instruments.state.admitted);
|
|
101
|
+
} else assert.deepEqual(outcome.value, declaration.expectedUnknown);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const writerBefore = Object.freeze({
|
|
105
|
+
records: w.writeState.records.length,
|
|
106
|
+
POST: w.writeState.calls.filter((row) => row.method === "POST").length,
|
|
107
|
+
C9: w.writeState.explicitC9,
|
|
108
|
+
});
|
|
109
|
+
assert.deepEqual(writerBefore, declaration.expectedWriterAtRefusal);
|
|
110
|
+
assert.equal(
|
|
111
|
+
w.writeState.calls.length,
|
|
112
|
+
5 + w.write.currentBundle.couponReads.length,
|
|
113
|
+
);
|
|
114
|
+
const setupBefore = Object.freeze({
|
|
115
|
+
records: w.state.records.length,
|
|
116
|
+
POST: w.state.calls.filter((row) => row.method === "POST").length,
|
|
117
|
+
});
|
|
118
|
+
assert.deepEqual(setupBefore, { records: 3, POST: 1 });
|
|
119
|
+
const stages = instruments.state;
|
|
120
|
+
if (controlCase === "L01-output-abort") {
|
|
121
|
+
assert.equal(stages.admissions, 1);
|
|
122
|
+
assert.equal(stages.outputAborts, 1);
|
|
123
|
+
assert.equal(stages.receiptCalls, 0);
|
|
124
|
+
}
|
|
125
|
+
if (controlCase === "L02-receipt-ACK-fault") {
|
|
126
|
+
assert.equal(stages.admissions, 1);
|
|
127
|
+
assert.equal(stages.wrongACK, 1);
|
|
128
|
+
assert.equal(stages.receiptCalls, 1);
|
|
129
|
+
assert.equal(stages.receiptRejected, 1);
|
|
130
|
+
assert.equal(stages.receiptFulfilled, 0);
|
|
131
|
+
}
|
|
132
|
+
if (controlCase === "L03-final-discard-abort") {
|
|
133
|
+
assert.equal(stages.admissions, 1);
|
|
134
|
+
assert.equal(stages.factoryPairs, 1);
|
|
135
|
+
assert.equal(stages.sourceBindingTrue, 1);
|
|
136
|
+
assert.equal(stages.reservationTrue, 1);
|
|
137
|
+
assert.equal(stages.sameReadTransport, true);
|
|
138
|
+
assert.equal(stages.receiptCalls, 1);
|
|
139
|
+
assert.equal(stages.receiptFulfilled, 1);
|
|
140
|
+
assert.equal(stages.receiptRejected, 0);
|
|
141
|
+
assert.equal(stages.discardEntered, 1);
|
|
142
|
+
assert.equal(stages.discardCompleted, 1);
|
|
143
|
+
assert.equal(w.OWNER.check().retired, false);
|
|
144
|
+
}
|
|
145
|
+
if (controlCase === "L06-receipt-ACK-retire") {
|
|
146
|
+
assert.equal(stages.admissions, 1);
|
|
147
|
+
assert.equal(stages.receiptFulfilled, 1);
|
|
148
|
+
assert.equal(stages.retirements, 1);
|
|
149
|
+
assert.throws(() => w.OWNER.basis, { message: "ORIGINAL_OWNER_STOP" });
|
|
150
|
+
}
|
|
151
|
+
if (
|
|
152
|
+
controlCase === "L04-POST-pending" ||
|
|
153
|
+
controlCase === "L05-POST-unknown"
|
|
154
|
+
) {
|
|
155
|
+
assert.equal(stages.admissions, 0);
|
|
156
|
+
assert.equal(stages.receiptCalls, 0);
|
|
157
|
+
}
|
|
158
|
+
const candidate =
|
|
159
|
+
controlCase === "L07-C6Failure-priority"
|
|
160
|
+
? publicWriterACK
|
|
161
|
+
: declaration.known
|
|
162
|
+
? stages.admitted
|
|
163
|
+
: w.expectedACK;
|
|
164
|
+
assert(candidate !== null && typeof candidate === "object");
|
|
165
|
+
assert.deepEqual(candidate, w.expectedACK);
|
|
166
|
+
assert(Object.isFrozen(candidate));
|
|
167
|
+
const candidateRecord =
|
|
168
|
+
controlCase === "L07-C6Failure-priority"
|
|
169
|
+
? Object.freeze({
|
|
170
|
+
...w.expectedRecord,
|
|
171
|
+
configuration: Object.freeze({
|
|
172
|
+
...w.expectedRecord.configuration,
|
|
173
|
+
apiVersion: declaration.invalidAPI,
|
|
174
|
+
}),
|
|
175
|
+
})
|
|
176
|
+
: w.expectedRecord;
|
|
177
|
+
let directFailure: unknown = null;
|
|
178
|
+
const realRecord = await vi.importActual<
|
|
179
|
+
typeof import("../observation/record.js")
|
|
180
|
+
>("../observation/record.js");
|
|
181
|
+
if (controlCase === "L07-C6Failure-priority") {
|
|
182
|
+
realRecord.captureObservationRecord(candidateRecord);
|
|
183
|
+
directFailure = await Reflect.apply(
|
|
184
|
+
api.projectRenewalConfigurationV2,
|
|
185
|
+
api,
|
|
186
|
+
[candidateRecord.configuration],
|
|
187
|
+
);
|
|
188
|
+
const failure = data(directFailure);
|
|
189
|
+
assert.equal(failure.status, "conflict");
|
|
190
|
+
assert.equal(failure.reason, declaration.expectedC6FailureReason);
|
|
191
|
+
assert.notEqual(candidateRecord, w.expectedRecord);
|
|
192
|
+
assert.deepEqual(w.expectedRecord, savedOriginalRecord);
|
|
193
|
+
}
|
|
194
|
+
const prerequisiteMetrics = {
|
|
195
|
+
originalRecord: assertFit(w.expectedRecord),
|
|
196
|
+
candidateRecord: assertFit(candidateRecord),
|
|
197
|
+
candidateDATA: assertFit(candidate),
|
|
198
|
+
};
|
|
199
|
+
const source = await import("../operations/sourceOperations.js");
|
|
200
|
+
const originalEntry = actualOperation.originalEntry;
|
|
201
|
+
const origin = actualOperation.originAssociation;
|
|
202
|
+
assert.equal(actualOperation.owner, w.OWNER);
|
|
203
|
+
assert.equal(
|
|
204
|
+
actualOperation.actualAttachAcknowledgement,
|
|
205
|
+
w.acknowledgement,
|
|
206
|
+
);
|
|
207
|
+
assert.equal(source.ORIGINAL_ORIGIN_ASSOCIATION, origin);
|
|
208
|
+
assert(source.COMPILED_INITIAL_ENTRIES.includes(originalEntry));
|
|
209
|
+
const readonly = declaration.readonly;
|
|
210
|
+
vi.stubGlobal("fetch", async (input: unknown, init: RequestInit) => {
|
|
211
|
+
const row = readonly.rows[calls.length];
|
|
212
|
+
assert(row);
|
|
213
|
+
const url = new URL(String(input));
|
|
214
|
+
assert.equal(url.origin, "https://api.stripe.com");
|
|
215
|
+
assert.equal(url.pathname + url.search, row.path);
|
|
216
|
+
assert.equal(init.method, "GET");
|
|
217
|
+
assert.equal(init.body, undefined);
|
|
218
|
+
assert.equal(init.redirect, "error");
|
|
219
|
+
const headers = new Headers(init.headers);
|
|
220
|
+
assert.equal(
|
|
221
|
+
headers.get("stripe-version"),
|
|
222
|
+
declaration.writer.baseline.apiVersion,
|
|
223
|
+
);
|
|
224
|
+
assert.equal(headers.get("stripe-account"), null);
|
|
225
|
+
calls.push({ method: "GET", path: row.path });
|
|
226
|
+
return new Response(JSON.stringify(row.body), {
|
|
227
|
+
status: 200,
|
|
228
|
+
headers: {
|
|
229
|
+
"content-type": "application/json",
|
|
230
|
+
"request-id": "req_SYNTHETIC_LIFECYCLE",
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
const readTransport = Object.freeze({
|
|
235
|
+
rawRequest(...args: unknown[]) {
|
|
236
|
+
counters.delegateEntered++;
|
|
237
|
+
w.OWNER.check();
|
|
238
|
+
const row = readonly.rows[promises.length];
|
|
239
|
+
assert(row);
|
|
240
|
+
assert.deepEqual(args, ["GET", row.path, undefined, row.options]);
|
|
241
|
+
const promise = w.readFixedA(...args);
|
|
242
|
+
promises.push(promise);
|
|
243
|
+
pending.push(
|
|
244
|
+
promise.then(
|
|
245
|
+
() => {},
|
|
246
|
+
() => {},
|
|
247
|
+
),
|
|
248
|
+
);
|
|
249
|
+
return promise;
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
const observationEntry = Object.freeze({
|
|
253
|
+
originalEntry,
|
|
254
|
+
coversObservation() {
|
|
255
|
+
counters.coverage++;
|
|
256
|
+
throw Error("LIFECYCLE_COVERAGE_MUST_NOT_BE_REACHED");
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
const operation = Object.freeze({
|
|
260
|
+
owner: w.OWNER,
|
|
261
|
+
originAssociation: origin,
|
|
262
|
+
originalEntry,
|
|
263
|
+
observationEntry,
|
|
264
|
+
record: candidateRecord,
|
|
265
|
+
actualAttachAcknowledgement: w.acknowledgement,
|
|
266
|
+
readTransport,
|
|
267
|
+
configureOperation: actualOperation,
|
|
268
|
+
configureAcknowledgement: candidate,
|
|
269
|
+
});
|
|
270
|
+
const writerActor = await import("../configure/actor.js");
|
|
271
|
+
const lookup = writerActor.readOwnedConfigureAcknowledgement;
|
|
272
|
+
vi.doMock("../configure/actor.js", () => ({
|
|
273
|
+
...writerActor,
|
|
274
|
+
readOwnedConfigureAcknowledgement(
|
|
275
|
+
this: unknown,
|
|
276
|
+
...args: Parameters<typeof lookup>
|
|
277
|
+
) {
|
|
278
|
+
counters.lookup++;
|
|
279
|
+
try {
|
|
280
|
+
const result = Reflect.apply(lookup, this, args) as ReturnType<
|
|
281
|
+
typeof lookup
|
|
282
|
+
>;
|
|
283
|
+
counters.lookupReturned++;
|
|
284
|
+
return result;
|
|
285
|
+
} catch (error) {
|
|
286
|
+
counters.lookupThrew++;
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
}));
|
|
291
|
+
vi.doMock("../observation/record.js", () => ({
|
|
292
|
+
...realRecord,
|
|
293
|
+
captureObservationRecord(
|
|
294
|
+
this: unknown,
|
|
295
|
+
...args: Parameters<typeof realRecord.captureObservationRecord>
|
|
296
|
+
) {
|
|
297
|
+
counters.captureEntered++;
|
|
298
|
+
const result = Reflect.apply(
|
|
299
|
+
realRecord.captureObservationRecord,
|
|
300
|
+
this,
|
|
301
|
+
args,
|
|
302
|
+
) as ReturnType<typeof realRecord.captureObservationRecord>;
|
|
303
|
+
counters.captureCompleted++;
|
|
304
|
+
return result;
|
|
305
|
+
},
|
|
306
|
+
}));
|
|
307
|
+
vi.doMock("../operations/sourceOperations.js", () => ({
|
|
308
|
+
...source,
|
|
309
|
+
COMPILED_OBSERVATION_ENTRIES: Object.freeze([observationEntry]),
|
|
310
|
+
loadFixedObservationOperation() {
|
|
311
|
+
assert.equal(arguments.length, 0);
|
|
312
|
+
counters.source++;
|
|
313
|
+
return operation;
|
|
314
|
+
},
|
|
315
|
+
}));
|
|
316
|
+
const keep = <T>(promise: Promise<T>) => {
|
|
317
|
+
pending.push(
|
|
318
|
+
promise.then(
|
|
319
|
+
() => {},
|
|
320
|
+
() => {},
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
return promise;
|
|
324
|
+
};
|
|
325
|
+
vi.doMock("../../../renewalV2/index.js", () => ({
|
|
326
|
+
...api,
|
|
327
|
+
projectRenewalConfigurationV2(
|
|
328
|
+
...args: Parameters<typeof api.projectRenewalConfigurationV2>
|
|
329
|
+
) {
|
|
330
|
+
counters.C6++;
|
|
331
|
+
const promise = Reflect.apply(
|
|
332
|
+
api.projectRenewalConfigurationV2,
|
|
333
|
+
api,
|
|
334
|
+
args,
|
|
335
|
+
) as ReturnType<typeof api.projectRenewalConfigurationV2>;
|
|
336
|
+
pending.push(
|
|
337
|
+
promise.then(
|
|
338
|
+
(value) => {
|
|
339
|
+
lastC6 = value;
|
|
340
|
+
},
|
|
341
|
+
() => {},
|
|
342
|
+
),
|
|
343
|
+
);
|
|
344
|
+
return keep(promise);
|
|
345
|
+
},
|
|
346
|
+
constructRenewalScheduleAttachmentReceiptV2(
|
|
347
|
+
...args: Parameters<
|
|
348
|
+
typeof api.constructRenewalScheduleAttachmentReceiptV2
|
|
349
|
+
>
|
|
350
|
+
) {
|
|
351
|
+
counters.C3++;
|
|
352
|
+
return keep(
|
|
353
|
+
Reflect.apply(
|
|
354
|
+
api.constructRenewalScheduleAttachmentReceiptV2,
|
|
355
|
+
api,
|
|
356
|
+
args,
|
|
357
|
+
) as ReturnType<
|
|
358
|
+
typeof api.constructRenewalScheduleAttachmentReceiptV2
|
|
359
|
+
>,
|
|
360
|
+
);
|
|
361
|
+
},
|
|
362
|
+
constructRenewalConfigurationReceiptV2(
|
|
363
|
+
...args: Parameters<typeof api.constructRenewalConfigurationReceiptV2>
|
|
364
|
+
) {
|
|
365
|
+
counters.C9++;
|
|
366
|
+
return keep(
|
|
367
|
+
Reflect.apply(
|
|
368
|
+
api.constructRenewalConfigurationReceiptV2,
|
|
369
|
+
api,
|
|
370
|
+
args,
|
|
371
|
+
) as ReturnType<typeof api.constructRenewalConfigurationReceiptV2>,
|
|
372
|
+
);
|
|
373
|
+
},
|
|
374
|
+
}));
|
|
375
|
+
vi.doMock("../../../renewalV2/observation.js", () => ({
|
|
376
|
+
...observer,
|
|
377
|
+
inspectRenewalScheduleMaterialV2(
|
|
378
|
+
...args: Parameters<typeof observer.inspectRenewalScheduleMaterialV2>
|
|
379
|
+
) {
|
|
380
|
+
counters.observer++;
|
|
381
|
+
return keep(
|
|
382
|
+
Reflect.apply(
|
|
383
|
+
observer.inspectRenewalScheduleMaterialV2,
|
|
384
|
+
observer,
|
|
385
|
+
args,
|
|
386
|
+
) as ReturnType<typeof observer.inspectRenewalScheduleMaterialV2>,
|
|
387
|
+
);
|
|
388
|
+
},
|
|
389
|
+
}));
|
|
390
|
+
const actor = await import("../observation/actor.js");
|
|
391
|
+
assert.equal(calls.length, 0);
|
|
392
|
+
assert.equal(promises.length, 0);
|
|
393
|
+
assert.deepEqual(counters, {
|
|
394
|
+
source: 0,
|
|
395
|
+
target: 0,
|
|
396
|
+
captureEntered: 0,
|
|
397
|
+
captureCompleted: 0,
|
|
398
|
+
C6: 0,
|
|
399
|
+
C3: 0,
|
|
400
|
+
C9: 0,
|
|
401
|
+
lookup: 0,
|
|
402
|
+
lookupReturned: 0,
|
|
403
|
+
lookupThrew: 0,
|
|
404
|
+
observer: 0,
|
|
405
|
+
coverage: 0,
|
|
406
|
+
delegateEntered: 0,
|
|
407
|
+
});
|
|
408
|
+
console.log(
|
|
409
|
+
JSON.stringify({
|
|
410
|
+
kind: "OPTIONAL_ACK_LIFECYCLE_PREREQUISITES",
|
|
411
|
+
controlCase,
|
|
412
|
+
actualInitialACK: true,
|
|
413
|
+
actualOwnedPreflight: true,
|
|
414
|
+
operationC9Known:
|
|
415
|
+
declaration.known || controlCase === "L07-C6Failure-priority",
|
|
416
|
+
operationReturnedACK: controlCase === "L07-C6Failure-priority",
|
|
417
|
+
candidateKind: declaration.candidateKind,
|
|
418
|
+
writerBefore,
|
|
419
|
+
setupBefore,
|
|
420
|
+
stageMarkers: {
|
|
421
|
+
admissions: stages.admissions,
|
|
422
|
+
receiptFulfilled: stages.receiptFulfilled,
|
|
423
|
+
receiptRejected: stages.receiptRejected,
|
|
424
|
+
wrongACK: stages.wrongACK,
|
|
425
|
+
sourceBindingTrue: stages.sourceBindingTrue,
|
|
426
|
+
discardCompleted: stages.discardCompleted,
|
|
427
|
+
},
|
|
428
|
+
prerequisiteMetrics,
|
|
429
|
+
operationalAuthority: false,
|
|
430
|
+
}),
|
|
431
|
+
);
|
|
432
|
+
return {
|
|
433
|
+
declaration,
|
|
434
|
+
writer: w,
|
|
435
|
+
instruments,
|
|
436
|
+
writerBefore,
|
|
437
|
+
setupBefore,
|
|
438
|
+
basis,
|
|
439
|
+
savedOriginalRecord,
|
|
440
|
+
savedOracleACK,
|
|
441
|
+
operation,
|
|
442
|
+
directFailure,
|
|
443
|
+
counters,
|
|
444
|
+
calls,
|
|
445
|
+
promises,
|
|
446
|
+
lastC6: () => lastC6,
|
|
447
|
+
writerSettled: () => settled,
|
|
448
|
+
capture() {
|
|
449
|
+
const handle = actor.captureOwnedRenewalObservationV2();
|
|
450
|
+
return Object.freeze({
|
|
451
|
+
invoke() {
|
|
452
|
+
counters.target++;
|
|
453
|
+
const promise = Reflect.apply(
|
|
454
|
+
handle.invoke,
|
|
455
|
+
handle,
|
|
456
|
+
[],
|
|
457
|
+
) as ReturnType<typeof handle.invoke>;
|
|
458
|
+
pending.push(
|
|
459
|
+
promise.then(
|
|
460
|
+
() => {},
|
|
461
|
+
() => {},
|
|
462
|
+
),
|
|
463
|
+
);
|
|
464
|
+
return promise;
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
async finishPendingWriter() {
|
|
469
|
+
assert.equal(controlCase, "L04-POST-pending");
|
|
470
|
+
w.writeGates.release("post");
|
|
471
|
+
const late = await observedWriter;
|
|
472
|
+
assert.equal(late.ok, true);
|
|
473
|
+
if (late.ok) assertConfigureACK(w, late.value);
|
|
474
|
+
console.log(
|
|
475
|
+
JSON.stringify({
|
|
476
|
+
kind: "LIFECYCLE_POST_RELEASE_JOIN",
|
|
477
|
+
operationReturnedACKNow: true,
|
|
478
|
+
writerC9: w.writeState.explicitC9,
|
|
479
|
+
writerRecords: w.writeState.records.length,
|
|
480
|
+
earlierRefusalHadReturnedACK: false,
|
|
481
|
+
operationalAuthority: false,
|
|
482
|
+
}),
|
|
483
|
+
);
|
|
484
|
+
},
|
|
485
|
+
cleanup: clean,
|
|
486
|
+
};
|
|
487
|
+
} catch (error) {
|
|
488
|
+
try {
|
|
489
|
+
await clean();
|
|
490
|
+
} finally {
|
|
491
|
+
throw error;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|