import type { GenerateContextType, InsertNormalizedModelArgs, InsertNormalizedModelOptions, InsertNormalizedModelReturn } from '../../context/generateTypes.js'; import { type ProjectionOptionsArg, type ProjectionOptionsRest } from '../../types/ProjectionOptions.js'; import { type PeerInsertOptions } from '../../types/InsertOptions.js'; import type { RefName } from '../../types/RefName.js'; import type { ContentSettings } from '../ContentSettings.js'; import type { LangSnippetConstructor } from '../Lang.js'; import type { IdentifierType } from '../IdentifierType.js'; import type { GeneratedValue } from '../GeneratedValue.js'; import type { Inserted } from '../Inserted.js'; import type { OasSchema } from '../../oas/schema/Schema.js'; import type { OasRef } from '../../oas/ref/Ref.js'; import type { OasVoid } from '../../oas/void/Void.js'; import type { ModelProjection, NormalizedModelProjection, ToModelIdentifierNameArgs, ToModelExportPathArgs } from './types.js'; import type * as v from 'valibot'; /** * Arguments accepted by classes generated via {@link toModelProjectionBase}. * * The factory injects `generatorKey` before delegating to the language * snippet base, so user code only supplies these fields. */ export type ModelProjectionArgs = { context: GenerateContextType; settings: ContentSettings; refName: RefName; } & ProjectionOptionsArg; type ToEnrichmentsArgs = { refName: RefName; context: GenerateContextType; /** Model variant whose enrichment should be resolved (see {@link Variant}) */ variant: string; }; /** * Configuration for {@link toModelProjectionBase}. * * Generic over the identifier-type shape `IdType`: a language veneer * parameterizes this config with its own `XxIdentifierType` * (`ModelProjectionBaseConfig`) so `toIdentifierType`'s * return tightens to that language's `type` vocabulary — no recast. The * default keeps the loose `type: string` boundary. * * Generic over `ProjectionOptions`: the caller options this projection * accepts, received by the identity statics and stored as `this.options`. */ export type ModelProjectionBaseConfig = { id: string; /** Pure: the cache-key name (the cache-check path runs this). */ toIdentifierName: (args: ToModelIdentifierNameArgs) => string; /** * Context-aware, overridable: the non-`name` parts of the identifier * (`type` / `typeName` / `exported`), derived from the schema. Runs only * on cache-miss. Returns `IdType` — the veneer's `XxIdentifierType`, whose * `type` is bound to that language's `EntityType` vocabulary (the loose * `string` by default). The tightening rides the type argument. */ toIdentifierType: (refName: RefName, context: GenerateContextType) => IdType; toExportPath: (args: ToModelExportPathArgs) => string; /** * Required composite schema for the `{ subject, generator, stack }` * enrichment umbrella. Required (not optional) is load-bearing: it is what * lets `static toEnrichments` parse cast-free. A no-enrichment generator * passes `emptyEnrichmentSchema`. */ toEnrichmentSchema: () => v.GenericSchema; /** * Optional: compute the DEFAULT enrichment values for a model from its schema * — the seed the CMS persists and the user then edits (vs {@link toEnrichments}, * which READS already-authored values). Returns the `{ subject, generator, * stack }` umbrella; a generator typically fills only `subject` and leaves the * run-constant `generator` / `stack` scopes `undefined`. Omitted → the derived * static returns `undefined`. */ toEnrichmentDefaults?: (args: ToEnrichmentsArgs) => EnrichmentType | undefined; /** * Family-level applicability predicate. Becomes a static `isSupported` * on the returned base class so other projections can probe it before * `insertModel` (the model counterpart of the operation-reference * protocol). When omitted, advertises support for every model. */ isSupported?: (args: { refName: RefName; context: GenerateContextType; }) => boolean; }; /** * Build a model projection base class from a per-generator config. * * The returned class extends `base` — the generator's language * snippet base — so the projection hierarchy is language-bound at its root * while core stays language-blind (the base arrives as an opaque * constructor; core never names a concrete language class). The class * exposes the generator's `id`, `toIdentifierName`, `toIdentifierType`, * `toExportPath`, `toEnrichments`, and `isSupported` statics, inherits the * static `lang` from the base, and * injects `generatorKey` so subclasses don't have to. * * Defines NO `register` / `registerInto` — register ergonomics are typed by * each language's concise vocabulary, which core can't name, so they live * in the language package's projection-base veneer over this factory. * * The projection machinery previously hosted on `ModelProjectionBase` lives * here now, because the base class is no longer statically known. */ export declare const toModelProjectionBase: (base: LangSnippetConstructor, config: ModelProjectionBaseConfig) => { new (args: ModelProjectionArgs): { settings: ContentSettings; refName: RefName; /** The caller's options. */ options: ProjectionOptions; /** * Insert a related model and return its `Inserted` reference. The * inserted model is exported to this projection's own `exportPath` * unless `noExport` is set. `{ options }` is required when the peer * declares options and refused when it does not. */ insertModel(projection: ModelProjection, refName: RefName, ...rest: ProjectionOptionsRest, PeerProjectionOptions>): Inserted; /** * Insert a related model with reference normalization. If `schema` is a * `$ref`, the referenced name is used; otherwise `fallbackName` applies. */ insertNormalizedModel | OasVoid, PeerEnrichmentType_1 = undefined, PeerProjectionOptions_1 = undefined>(projection: NormalizedModelProjection, { schema, fallbackName }: Omit, "destinationPath">, ...rest: ProjectionOptionsRest, PeerProjectionOptions_1>): InsertNormalizedModelReturn; context: GenerateContextType; skipped: boolean; generatorKey: import("../GeneratorKeys.js").GeneratorKey | undefined; stackTrail: import("../../mod.js").StackTrail; }; id: string; type: "model"; toIdentifierName: (args: ToModelIdentifierNameArgs) => string; toIdentifierType: (refName: RefName, context: GenerateContextType) => IdType; toExportPath: (args: ToModelExportPathArgs) => string; toEnrichments: ({ refName, context, variant }: ToEnrichmentsArgs) => EnrichmentType; /** * Derive the seed enrichment values for a model from its schema (the CMS * persists these, then the user edits). Returns `undefined` when the * generator declares no `toEnrichmentDefaults` — the common case. */ toEnrichmentDefaults: (args: ToEnrichmentsArgs) => EnrichmentType | undefined; isSupported: (args: { refName: RefName; context: GenerateContextType; }) => boolean; lang: import("../Lang.js").Lang; }; export {};