Docs@skmtc/core

Operations

FUNCTION

toOasOperationEntry

@skmtc/core 0.63.4

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.

Signature

import { toOasOperationEntry } from '@skmtc/core'

toOasOperationEntry<EnrichmentType = undefined>(
  config: ToOasOperationConfigArgs<EnrichmentType>
): OasOperationEntry<EnrichmentType>
EnrichmentType

Type of enrichment data this operation provides

Parameters

config, ToOasOperationConfigArgs<EnrichmentType> required

Configuration object defining operation behavior

id, string required
projections, readonly DeclaredProjection[]

Every projection class this generator can insert: its own, and each one of another generator that it inserts. Core reads only their statics. See DeclaredProjection. Optional.

transform, (args: TransformOasOperationArgs) => void required
toEnrichmentSchema, () => v.GenericSchema<EnrichmentType> required
isSupported, (args: IsSupportedOasOperationArgs) => boolean
supportsVariant, () => boolean

Optional: whether this generator entry supports variants. Defaults to a function returning false when omitted.

toPreviewModule, (args: ToOasOperationPreviewModuleArgs) => PreviewModule
toEnrichmentRequest, <RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined
toEnrichmentDefaults, (args: ToOasOperationEnrichmentsArgs) => EnrichmentType | 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).

Basic operation entry
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';
  }
});

Returns

OasOperationEntry<EnrichmentType>

Configured operation generator entry ready for pipeline integration