import type { Expression, AgencyProgram } from "../types.js"; import type { CompilationUnit } from "../compilationUnit.js"; /** * Enforces the spec's restriction on what may appear inside `@jsonSchema(...)`: * * - String / number / boolean / null literals. * - Object literals containing only allowed expressions / spreads. * - Function calls to top-level `def` functions or imported functions, * whose arguments are themselves allowed expressions. * - Identifiers that resolve to a static `const` global (module-level * `const` binding, including const-bound imports). `let` bindings, * function parameters, and local declarations are rejected. * * Anything else (member access, ternaries, binary ops, pipes, template * strings, array literals, etc.) is rejected. */ export type JsonSchemaArgValidationResult = { ok: true; } | { ok: false; reason: string; loc?: { line: number; col: number; }; }; /** * Subset of the compilation unit we need to look up identifiers. * Kept minimal so unit tests don't need a full CompilationUnit. */ export type JsonSchemaArgScope = { /** Names that resolve to a top-level const binding in this module. */ topLevelConstNames: Set; /** Names imported from another module (treated as const-bound). */ importedNames: Set; /** Names of top-level `def` functions. */ topLevelFunctionNames: Set; /** * Names of value parameters in scope for the current alias's tag * arguments. When validating an alias's RAW tags (pre-substitution) * the alias's own `valueParams` names go here so identifier * references resolve cleanly. When validating tags AFTER * `applyValueArgs` has run, this should be empty — any leftover * value-param identifier is a bug, not a valid reference. */ valueParamNames?: Set; }; export declare function validateJsonSchemaArg(expr: Expression, scope: JsonSchemaArgScope): JsonSchemaArgValidationResult; /** * Alias for `validateJsonSchemaArg` — the same restriction set applies * to `@validate(...)` and `@jsonSchema(...)` tag arguments. Use this * name in new call sites; the legacy export stays for compatibility. */ export declare const validateTagArg: typeof validateJsonSchemaArg; /** * Build the scope view needed for validation from a CompilationUnit * and the original AgencyProgram (we need the program to walk top-level * `const` assignments — CompilationUnit doesn't retain them directly). */ export declare function buildJsonSchemaArgScope(program: AgencyProgram, unit: CompilationUnit): JsonSchemaArgScope;