import type { MetaRoot, MetaObject } from "@metaobjectsdev/metadata"; import { type Provider, type RenderFormat } from "@metaobjectsdev/render"; import type { GeneratorFactory } from "../generator.js"; /** The three built-in walk scopes (SP-1 §3.1). Same vocabulary as the engine * helpers perEntity/perPackage/perModel. */ export type TemplateScope = "perEntity" | "perPackage" | "perModel"; export type TemplateFormat = RenderFormat; export interface TemplateWalkResult { /** The data dict to render against. Templates reference its keys; the * shape is the public-API contract template authors consume. */ data: object; /** Output path RELATIVE to the generator's target outDir. */ outputPath: string; } export interface TemplateGeneratorOpts { /** kebab-case identifier; surfaces in diagnostics and the overwrite-policy * per-file snapshot key. */ name: string; /** Walk the loaded metadata tree and produce `{ data, outputPath }` tuples * — one per emitted file. Pattern A (per-entity), pattern B (single * aggregator), pattern C (mixed), pattern D (filter inline) all fit. * Mutually exclusive with `scope` — provide exactly one. The power-user * escape hatch; most consumers declare a `scope` + `outputPattern` instead. */ walk?: (root: MetaRoot) => TemplateWalkResult[] | Promise; /** Built-in walk scope (SP-1 §3.1) — declarative alternative to `walk`. The * generator derives the neutral data dict (template-data.ts) per unit and * names each file via `outputPattern`. Mutually exclusive with `walk`. */ scope?: TemplateScope; /** Output path pattern for the built-in `scope` walk: `{name}` `{Name}` * `{package}` (SP-1 §3.3). Required with `scope`; ignored with `walk`. */ outputPattern?: string; /** Template reference. Resolved by the configured Provider chain — by * default the project's `templates/.mustache` first, then the * framework defaults at `codegen-ts/templates/.mustache`. */ template: string; /** Drives the render engine's escaper. Defaults to "text". */ format?: TemplateFormat; /** Optional per-entity filter for adopters who want to scope a generator * via the standard `Generator.filter` plumbing. Not consulted by the * default `walk` — adopters apply filters inside their walk function. */ filter?: (entity: MetaObject) => boolean; /** Override the Provider used for template resolution. When omitted the * generator resolves via `projectProvider(ctx.projectRoot)`, which layers * the project's `templates/` over the framework defaults. (The project * root is the directory holding `.metaobjects/config.json`, threaded * through `GenContext` by the runner. Adopters needing a different * lookup chain can pass an explicit provider.) */ provider?: Provider; /** Optional named target — same as the other generators. */ target?: string; } export declare const templateGenerator: GeneratorFactory; //# sourceMappingURL=template-generator.d.ts.map