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 { OasWebhook } from '../../oas/webhook/Webhook.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 { OasOperationProjection } from '../operation/oas/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 { WebhookProjectionConstructorArgs, ToWebhookIdentifierNameArgs, ToWebhookExportPathArgs } from './types.js'; import type * as v from 'valibot'; /** * Configuration for {@link toWebhookProjectionBase}. * * Sibling of `OasOperationProjectionBaseConfig` for the webhook subject. * Generic over the identifier-type shape `IdType`: a language veneer * parameterizes this config with its own `XxIdentifierType` * (`WebhookProjectionBaseConfig`) so `toIdentifierType`'s * return tightens to that language's `type` vocabulary — no recast. */ export type WebhookProjectionBaseConfig = { id: string; /** Pure: the cache-key name (the cache-check path runs this). */ toIdentifierName: (args: ToWebhookIdentifierNameArgs) => string; /** * Context-aware, overridable: the non-`name` parts of the identifier, * derived from the webhook. Runs only on cache-miss. Returns this * language's `XxIdentifierType` (`IdType`; the loose `type: string` by default). */ toIdentifierType: (webhook: OasWebhook, context: GenerateContextType) => IdType; toExportPath: (args: ToWebhookExportPathArgs) => 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 webhook from its * schema — the seed the CMS persists and the user then edits (vs * {@link toEnrichments}, which READS already-authored values). */ 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 * webhook-reference protocol. When omitted, advertises support for every * webhook. */ isSupported?: (args: { webhook: OasWebhook; context: GenerateContextType; }) => boolean; }; type ToEnrichmentsArgs = { webhook: OasWebhook; context: GenerateContextType; /** Webhook variant whose enrichment should be resolved (see {@link Variant}) */ variant: string; }; /** * Build a webhook projection base class from a per-generator config. * * Sibling of `toOasOperationProjectionBase`. 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. * It exposes the generator's `id`, `toIdentifierName`, `toIdentifierType`, * `toExportPath`, `toEnrichments`, and `isSupported` statics, inherits the * static `lang` from the base, and injects the webhook `generatorKey`. * * Defines NO `register` / `registerInto` — those live in the language * package's projection-base veneer over this factory. */ export declare const toWebhookProjectionBase: (base: LangSnippetConstructor, config: WebhookProjectionBaseConfig) => { new (args: WebhookProjectionConstructorArgs): { settings: ContentSettings; webhook: OasWebhook; /** The caller's options. */ options: ProjectionOptions; /** * Insert a related operation (the operation-reference protocol — e.g. a * webhook handler that references a list endpoint). 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. */ insertOperation(projection: OasOperationProjection, operation: OasOperation, ...rest: ProjectionOptionsRest, PeerProjectionOptions>): Inserted; /** * Insert a related model into this projection's export file (e.g. the * webhook's payload type). `{ 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 * payload schemas where the schema may be either a `$ref` or a concrete * object. */ insertNormalizedModel | OasVoid, PeerEnrichmentType_2 = undefined, PeerProjectionOptions_2 = undefined>(projection: NormalizedModelProjection, { schema, fallbackName }: Omit, "destinationPath">, ...rest: ProjectionOptionsRest, PeerProjectionOptions_2>): InsertNormalizedModelReturn; context: GenerateContextType; skipped: boolean; generatorKey: import("../GeneratorKeys.js").GeneratorKey | undefined; stackTrail: import("../../mod.js").StackTrail; }; id: string; type: "webhook"; toIdentifierName: (args: ToWebhookIdentifierNameArgs) => string; toIdentifierType: (webhook: OasWebhook, context: GenerateContextType) => IdType; toExportPath: (args: ToWebhookExportPathArgs) => string; isSupported: (args: { webhook: OasWebhook; context: GenerateContextType; }) => boolean; toEnrichments: ({ webhook, context, variant }: ToEnrichmentsArgs) => EnrichmentType; /** * Derive the seed enrichment values for a webhook from its schema. * Returns `undefined` when the generator declares no * `toEnrichmentDefaults` — the common case. */ toEnrichmentDefaults: (args: ToEnrichmentsArgs) => EnrichmentType | undefined; lang: import("../Lang.js").Lang; }; export {};