import type * as v from 'valibot'; import type { OasOperation } from '../../../oas/operation/Operation.js'; import type { GenerateContextType } from '../../../context/generateTypes.js'; import type { ContentSettings } from '../../ContentSettings.js'; import type { DefinitionBase } from '../../Definition.js'; import type { FindDefinitionsQuery } from '../../CodeFileBase.js'; import type { IdentifierType } from '../../IdentifierType.js'; import type { LangSnippetConstructor } from '../../Lang.js'; import type { GeneratorKey } from '../../GeneratorKeys.js'; import type { IsSupportedOasOperationArgs, ToGeneratorKeyArgs, ToOasOperationGroupNameArgs, ToOasOperationEnrichmentsArgs, ToOasOperationExportPathArgs, ToOasOperationIdentifierNameArgs } from './types.js'; /** * Configuration for {@link toOasOperationContainerBase}. * * The identity half is an operation projection's: `toIdentifierName` and * `toExportPath` are pure functions of `(operation, enrichments, variant)`, * resolved before construction so the cache probe stays cheap. What differs * is that they are expected to be functions of the operation's GROUP — its * tag, its file — so every operation in the group resolves to one * declaration. Nothing enforces that; an identity that varies per operation * simply yields one container per operation, visible in the output. * * Enrichments are read exactly as an operation projection's are, from the * operation inserting into the container. */ export type OasOperationContainerBaseConfig = { id: string; /** * The group this container collects — the operation's tag, its module, * whatever the generator gathers subjects by. Pure, and a function of the * subject like its identity siblings, so every member of a group computes * the same one. * * It is what the container's key is made of. Deriving the key from the * group rather than from where the container lands keeps it saying what * the definition is rather than where it sits, and keeps it stable when a * generator changes its naming or file policy. */ toGroupName: (args: ToOasOperationGroupNameArgs) => string; /** Pure: the cache-key name, a function of the operation's group. */ toIdentifierName: (args: ToOasOperationIdentifierNameArgs) => string; /** Runs only on cache-miss. Returns this language's identifier type. */ toIdentifierType: (operation: OasOperation, context: GenerateContextType) => IdType; /** Pure: the file the container is declared in. */ toExportPath: (args: ToOasOperationExportPathArgs) => string; /** The generator's composite `{ subject, generator, stack }` schema. */ toEnrichmentSchema: () => v.GenericSchema; isSupported?: (args: IsSupportedOasOperationArgs) => boolean; }; /** * Arguments every container projection's constructor receives — the same * shape an operation projection gets, from the operation that reached the * container first. */ export type OasOperationContainerConstructorArgs = { context: GenerateContextType; operation: OasOperation; settings: ContentSettings; }; /** * Build a base class for a declaration that HOLDS definitions — a Kotlin * interface body, a C# class body — rather than one that is a subject's * artifact. * * Two things separate it from {@link import('./toOasOperationProjectionBase.ts').toOasOperationProjectionBase}: * * The value carries a {@link toContainerGeneratorKey} rather than the * operation's own. A subject-derived key is what makes many operations * resolving to one definition fail the integrity check on the second of * them; an identity-derived one is computed identically by every member, * while still carrying the `generatorId` that stops another generator * claiming the declaration. * * And it implements the member store, so the engine can insert into it — * which is also what makes the class assignable where a container is asked * for, with nothing to declare. The subclass renders those members; where * they sit in the declaration, and at what indentation, is the language's * business, not the engine's. */ export declare const toOasOperationContainerBase: (base: LangSnippetConstructor, config: OasOperationContainerBaseConfig) => { new (args: OasOperationContainerConstructorArgs): { settings: ContentSettings; operation: OasOperation; /** * The members inserted into this declaration, in arrival order — which * is the engine's sweep order, so it is stable across runs. */ definitions: DefinitionBase[]; /** * {@link import('@/dsl/DefinitionContainer.ts').DefinitionContainer} * * Re-adding a member already present is a no-op, keyed the way a file * keys its own duplication rule * ({@link import('@/dsl/IdentifierBase.ts').IdentifierBase.declarationKey}). * Without it a container and a file disagree about duplicates, and a * second registration of one member renders it twice. */ addDefinition(definition: DefinitionBase): void; /** * {@link import('@/dsl/DefinitionContainer.ts').DefinitionContainer} * * `name` only. A declaration's `type` is the language's, readable just * from its own identifier subclass, which core cannot name — so the * extractor here always answers `undefined` and a `type` filter would * silently match nothing. A language veneer that narrows the identifier * should override this to answer both, the way its file class does. */ findDefinitions(query?: FindDefinitionsQuery): DefinitionBase[] | undefined; context: GenerateContextType; skipped: boolean; generatorKey: GeneratorKey | undefined; stackTrail: import("../../../mod.js").StackTrail; }; id: string; type: "oasOperation"; toGroupName: (args: ToOasOperationGroupNameArgs) => string; /** * Keyed on the group, so every member of it computes the same key. * * A method rather than a field, and reading `toGroupName` through * `this`: a subclass overriding the group — the normal way a cloned * generator adjusts one policy — must change the key the container is * stored under, not just what callers are told. */ toGeneratorKey({ operation, settings }: ToGeneratorKeyArgs): GeneratorKey; toIdentifierName: (args: ToOasOperationIdentifierNameArgs) => string; toIdentifierType: (operation: OasOperation, context: GenerateContextType) => IdType; toExportPath: (args: ToOasOperationExportPathArgs) => string; isSupported: (args: IsSupportedOasOperationArgs) => boolean; toEnrichments: ({ operation, context, variant }: ToOasOperationEnrichmentsArgs) => EnrichmentType; lang: import("../../Lang.js").Lang; };