Files
reverse-engineering-anything/src/domain/analysisView/javascriptModuleReferences.ts
T
郭立 Guo Li 7590b50801 perf(schema): reduce retained integer validator allocations (#4360)
Construct integer formats directly while preserving bounds, refinements, metadata and current shared schema owners. Keep Incur-dependent CLI numeric coercion declarations unchanged.

Verify canonical advertisements, 126 numeric boundary cases, 974 actual CLI parser cases, broad source tests and real public-artifact SDK workflows. Record 72 normal tasks and 12 separate owned-inspector heap diagnostics with whole-family resource bounds; distinguish SDK spans and asymmetric audit overhead. Generate numerical report sections from receipts and reject stale tables through documentation conformance checks.

Closes #6236. Current-head CI and Greptile pass; actionable review findings are addressed. Codex review was unavailable due repository usage limits.
2026-10-22 05:11:08 +00:00

49 lines
1.6 KiB
TypeScript

import { z } from "zod";
import { prefixedDigestSchema } from "../digests.js";
import {
applicationGraphEvidenceSchema,
applicationNodeIdentitySchema,
} from "../javascript/javascriptApplicationEvidenceSchemas.js";
const moduleKindSchema = z.enum([
"javascript-asset",
"javascript-module",
"source-module",
]);
/** Exact filters over retained owner facts; paths are not filesystem lookups. */
export const javascriptModuleReferencesRequestSchema = z.strictObject({
kind: z.literal("javascript"),
collection: z.literal("modules"),
projection: z.literal("references"),
where: z
.strictObject({
path: z.string().nullable().optional(),
kind: moduleKindSchema.optional(),
})
.default({}),
offset: z.int().nonnegative().default(0),
limit: z.int().positive().default(64),
});
/** Unique support states, without promoting mixed observations to one fact. */
const basisSchema = z.strictObject({
authority: applicationGraphEvidenceSchema.shape.authority,
state: applicationGraphEvidenceSchema.shape.state,
confidence: applicationGraphEvidenceSchema.shape.confidence,
});
/** Reusable facts rather than task-specific dependency interpretations. */
export const javascriptModuleReferenceSchema = z.strictObject({
node_id: prefixedDigestSchema("jag_node"),
kind: moduleKindSchema,
path: z.string().nullable(),
identity: applicationNodeIdentitySchema,
retained_source_range_count: z.int().nonnegative(),
basis: z.array(basisSchema).min(1),
});
export type JavaScriptModuleReference = z.infer<
typeof javascriptModuleReferenceSchema
>;