Files
reverse-engineering-anything/src/domain/browserScenarioCapture.ts
T
morluto 9b392bb2f8 chore(deps): finish toolchain upgrades and drop dead weight (#644)
* chore(deps): finish toolchain upgrades and drop dead weight

pino 9 to 10, @types/node 24 to 26, oxlint 1.73 to 1.87, knip 6.26
to 6.39, turbo 2.10 to 2.11. Narrow engines to supported majors
(22/24/26; vitest 5 refuses Node 25). Scope no-var-requires off for
Electron CJS hooks and fixtures.

Remove TypeDoc: incompatible with TypeScript 7 at install and
runtime, used by nothing in any gate. Drop the dep, docs:api
workflow, typedoc.json, CI artifact step, and related docs.

Replace graphology with a local call-graph adjacency plus BFS: the
only consumer is call-path search, and graphology-types ships no
types entry for TS7 NodeNext resolution. Delete both graphology
dependencies.

Remove dead re-exports newly flagged by knip 6.39.

* chore: drop stale typedoc and replay references

Remove the docs:api release-checklist step, the orphaned docs/api
ignore entry, and the nonexistent replay glob from the adapters
project.
2026-10-06 06:02:02 +08:00

85 lines
2.7 KiB
TypeScript

import { z } from "zod";
import {
browserScenarioCompletenessSchema,
browserScenarioEventSchema,
browserScenarioStepSchema,
} from "./browserScenarioCaptureValues.js";
export {
classifyBrowserScenarioCompleteness,
browserScenarioEventSchema,
browserScenarioStepSchema,
browserStepArtifactsSchema,
type BrowserScenarioCompleteness,
type BrowserScenarioCompletenessSection,
type BrowserScenarioEvent,
type BrowserScenarioStep,
type BrowserScenarioStepOutcome,
type BrowserStepArtifacts,
} from "./browserScenarioCaptureValues.js";
/** Step-indexed browser scenario observation. */
export const browserScenarioCaptureSchema = z
.strictObject({
browser: z.strictObject({
mode: z.enum(["launch", "connect"]),
process_ownership: z.enum(["provider-owned", "external"]),
cleanup: z.enum(["terminated-owned-process", "disconnected-external"]),
product: z.string().min(1),
version: z.string().min(1),
}),
scenario: z.strictObject({
start_origin: z.string().min(1),
action_count: z.number().int().min(1),
secret_references: z.array(z.string().min(1)),
}),
duration_ms: z.number().int().min(0),
steps: z.array(browserScenarioStepSchema).min(1),
events: z.strictObject({
retained: z.number().int().min(0),
dropped: z.number().int().min(0),
items: z.array(browserScenarioEventSchema),
}),
completeness: browserScenarioCompletenessSchema,
limitations: z.array(z.string().min(1)),
})
.superRefine((capture, context) => {
if (capture.events.retained !== capture.events.items.length)
context.addIssue({
code: "custom",
path: ["events", "retained"],
message: "Retained event count must equal items length",
});
if (capture.steps.length !== capture.scenario.action_count + 1)
context.addIssue({
code: "custom",
path: ["steps"],
message: "Capture must include initial state and one entry per action",
});
const expectedIndices = capture.steps.map((_, index) => index);
if (
capture.steps.some(
({ step_index: index }, offset) => index !== expectedIndices[offset],
)
)
context.addIssue({
code: "custom",
path: ["steps"],
message: "Step indices must be contiguous from zero",
});
if (
capture.events.items.some(
({ step_index: index }) => index >= capture.steps.length,
)
)
context.addIssue({
code: "custom",
path: ["events", "items"],
message: "Event references an unknown step index",
});
});
export type BrowserScenarioCapture = z.infer<
typeof browserScenarioCaptureSchema
>;