import type * as v from 'valibot'; import type { OasOperation } from '../../../oas/operation/Operation.js'; import type { EnrichmentRequest } from '../../../types/EnrichmentRequest.js'; import type { IsSupportedOasOperationArgs, ToOasOperationPreviewModuleArgs, ToOasOperationEnrichmentsArgs, TransformOasOperationArgs } from './types.js'; import type { PreviewModule } from '../../../types/Preview.js'; /** * Configuration arguments for creating operation generator entries. * * Defines the structure for operation generator configuration including transform functions, * enrichment schemas, preview/mapping modules, and support validation. * * @template EnrichmentType - Type of enrichment data this operation can provide */ export type ToOasOperationConfigArgs = { id: string; transform: ({ context, operation, variant }: TransformOasOperationArgs) => void; toEnrichmentSchema: () => v.GenericSchema; isSupported?: (args: IsSupportedOasOperationArgs) => boolean; /** * Optional: whether this generator entry supports variants. Defaults to a * function returning `false` when omitted. */ supportsVariant?: () => boolean; toPreviewModule?: ({ context, operation }: ToOasOperationPreviewModuleArgs) => PreviewModule; toEnrichmentRequest?: (operation: OasOperation) => EnrichmentRequest | undefined; /** * Optional: compute the DEFAULT enrichment values for an operation from its * schema — the seed the CMS persists and the user then edits. Typically a * thin forward to the projection base's static of the same name * (`toEnrichmentDefaults: MyProjection.toEnrichmentDefaults`) so the logic * has a single home in `base.ts` while the entry exposes it to the seeding * pass (which walks the generator-config map, not projection classes). */ toEnrichmentDefaults?: ({ operation, context, variant }: ToOasOperationEnrichmentsArgs) => EnrichmentType | undefined; }; export type OasOperationEntry = { id: string; type: 'oasOperation'; transform: ({ context, operation, variant }: TransformOasOperationArgs) => void; toEnrichmentSchema: () => v.GenericSchema; isSupported: (args: IsSupportedOasOperationArgs) => boolean; supportsVariant: () => boolean; toPreviewModule?: ({ context, operation }: ToOasOperationPreviewModuleArgs) => PreviewModule; toEnrichmentRequest?: (operation: OasOperation) => EnrichmentRequest | undefined; toEnrichmentDefaults?: ({ operation, context, variant }: ToOasOperationEnrichmentsArgs) => EnrichmentType | undefined; }; /** * Creates a configured operation generator entry. * * Transforms operation configuration arguments into a standardized operation generator entry * that can be used within the SKMTC generation pipeline. Provides type-safe operation processing * with optional enrichment support and preview capabilities. * * @template EnrichmentType - Type of enrichment data this operation provides * @param config - Configuration object defining operation behavior * @returns Configured operation generator entry ready for pipeline integration * * @example Basic operation entry * ```typescript * import { toOperationEntry } from '@skmtc/core'; * * const operationEntry = toOperationEntry({ * id: 'my-operation-generator', * transform: ({ context, operation }) => { * context.insertOperation({ projection: MyOperation, operation }); * }, * isSupported: ({ operation }) => { * return operation.method === 'POST'; * } * }); * ``` */ export declare const toOasOperationEntry: ({ id, transform, toEnrichmentSchema, isSupported, supportsVariant, toPreviewModule, toEnrichmentRequest, toEnrichmentDefaults }: ToOasOperationConfigArgs) => OasOperationEntry;