import type { GeneratorKey } from '../../GeneratorKeys.js'; import type { GenerateContextType } from '../../../context/generateTypes.js'; import type { InsertNormalizedModelArgs, InsertNormalizedModelOptions, InsertNormalizedModelReturn } from '../../../context/generateTypes.js'; import { type ProjectionOptionsRest } from '../../../types/ProjectionOptions.js'; import { type PeerInsertOptions } from '../../../types/InsertOptions.js'; import type { OasOperation } from '../../../oas/operation/Operation.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 { ModelProjection, NormalizedModelProjection } from '../../model/types.js'; import type { RefName } from '../../../types/RefName.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 { OasOperationContainerProjection, ToGeneratorKeyArgs, OasOperationProjection, OasOperationProjectionConstructorArgs, ToOasOperationContainerArgs, ToOasOperationIdentifierNameArgs, ToOasOperationExportPathArgs } from './types.js'; import type * as v from 'valibot'; /** * Configuration for {@link toOasOperationProjectionBase}. * * Generic over the language `L`: a language veneer parameterizes this config * (`OasOperationProjectionBaseConfig`) so * `toIdentifierType`'s return tightens to that language's `type` vocabulary — * no recast. */ export type OasOperationProjectionBaseConfig = { id: string; /** Pure: the cache-key name (the cache-check path runs this). */ toIdentifierName: (args: ToOasOperationIdentifierNameArgs) => string; /** * Context-aware, overridable: the non-`name` parts of the identifier, * derived from the operation/schema. Runs only on cache-miss. Returns this * language's `XxIdentifierType` (`IdType`; the loose `type: string` by * default); the tightening rides the type argument. */ toIdentifierType: (operation: OasOperation, context: GenerateContextType) => IdType; toExportPath: (args: ToOasOperationExportPathArgs) => string; /** * Declares this projection a MEMBER: its definition is inserted into the * container this returns, rather than at file level. * * Shaped like its identity siblings, and run on the same cache-check path, * so it must be pure. It returns the container class rather than naming * one, which also defers the reference to call time — a module-level * reference between a member and its container is one more way to build * the load-order cycles a leaf module exists to break. * * A member's file is its container's, so `toExportPath` is not consulted * when this is present. A container takes no caller options: the member's * options may select the container class, never parameterise it. */ toContainer?: (args: ToOasOperationContainerArgs) => OasOperationContainerProjection; /** * 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 an operation 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` (per-operation defaults) and leaves the run-constant `generator` / * `stack` scopes `undefined`. Omitted → the derived static returns * `undefined` (the generator advertises no defaults). */ toEnrichmentDefaults?: (args: ToEnrichmentsArgs) => EnrichmentType | undefined; /** * Family-level applicability predicate. Becomes a static `isSupported` * on the returned base class so other projections can probe it via the * operation-reference protocol. When omitted, advertises support for * every operation. */ isSupported?: (args: { operation: OasOperation; context: GenerateContextType; }) => boolean; }; type ToEnrichmentsArgs = { operation: OasOperation; context: GenerateContextType; /** Operation variant whose enrichment should be resolved (see {@link Variant}) */ variant: string; }; /** * Build an OAS operation 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 * `OasOperationProjectionBase` lives here now, because the base class is no * longer statically known. */ export declare const toOasOperationProjectionBase: (base: LangSnippetConstructor, config: OasOperationProjectionBaseConfig) => { new (args: OasOperationProjectionConstructorArgs): { settings: ContentSettings; operation: OasOperation; /** The caller's options. */ options: ProjectionOptions; /** * Insert a related operation. The inserted operation is exported to this * projection's own `exportPath` unless `noExport` is set. * * Pass `{ variant }` to target a specific variant on the peer; omitting * it defaults to the peer's `'main'` variant. `{ options }` is required * when the peer declares options and refused when it does not. */ insertOperation(projection: OasOperationProjection, operation: OasOperation, ...rest: ProjectionOptionsRest, PeerProjectionOptions>): Inserted; /** * Insert a related model into this projection's export file. * * Pass `{ variant }` to target a specific variant on the peer model * projection; omitting it defaults to the peer's `'main'` variant. * `{ options }` is required when the peer declares options and refused * when it does not. */ insertModel(projection: ModelProjection, refName: RefName, ...rest: ProjectionOptionsRest, PeerProjectionOptions_1>): Inserted; /** * Insert a related model with reference normalization. Useful for inline * request/response schemas where the schema may be either a `$ref` or a * concrete object. * * `{ variant }` and `{ options }` flow through the `$ref` branch only; * for inline schemas, bake what distinguishes them into `fallbackName`. */ insertNormalizedModel | OasVoid, PeerEnrichmentType_2 = undefined, PeerProjectionOptions_2 = undefined>(projection: NormalizedModelProjection, { schema, fallbackName }: Omit, "destinationPath">, ...rest: ProjectionOptionsRest, PeerProjectionOptions_2>): InsertNormalizedModelReturn; context: GenerateContextType; skipped: boolean; generatorKey: GeneratorKey | undefined; stackTrail: import("../../../mod.js").StackTrail; }; id: string; /** * How this projection's key is computed — read by the Driver so it can * check a cache hit without knowing whether it holds a subject's * projection or a container. * * A method rather than a field, and reading `id` through `this`, for the * same reason the container reads its group that way: a subclass * overriding the generator id must change the key its values are stored * under, not just what callers are told. */ toGeneratorKey({ operation, settings }: ToGeneratorKeyArgs): GeneratorKey; type: "oasOperation"; toIdentifierName: (args: ToOasOperationIdentifierNameArgs) => string; toIdentifierType: (operation: OasOperation, context: GenerateContextType) => IdType; toExportPath: (args: ToOasOperationExportPathArgs) => string; toContainer: ((args: ToOasOperationContainerArgs) => OasOperationContainerProjection) | undefined; isSupported: (args: { operation: OasOperation; context: GenerateContextType; }) => boolean; toEnrichments: ({ operation, context, variant }: ToEnrichmentsArgs) => EnrichmentType; /** * Derive the seed enrichment values for an operation 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; lang: import("../../Lang.js").Lang; }; export {};