Docs@skmtc/core

Webhooks

FUNCTION

toWebhookProjectionBase

@skmtc/core 0.63.4

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, and toExportPath 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.

Signature

import { toWebhookProjectionBase } from '@skmtc/core'

toWebhookProjectionBase<EnrichmentType = undefined, IdType extends IdentifierType = IdentifierType, ProjectionOptions = undefined>(
  base: LangSnippetConstructor,
  config: WebhookProjectionBaseConfig<EnrichmentType, IdType, ProjectionOptions>
): WebhookProjectionBaseClass<EnrichmentType, IdType, ProjectionOptions>

Parameters

base, LangSnippetConstructor required
config, WebhookProjectionBaseConfig<EnrichmentType, IdType, ProjectionOptions> required
id, string required
toIdentifierName, (args: ToWebhookIdentifierNameArgs<EnrichmentType, ProjectionOptions>) => string required

Pure: the cache-key name (the cache-check path runs this).

toIdentifierType, (webhook: OasWebhook, context: GenerateContextType) => IdType required

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).

toExportPath, (args: ToWebhookExportPathArgs<EnrichmentType, ProjectionOptions>) => string required
toEnrichmentDefaults, (args: ToEnrichmentsArgs) => EnrichmentType | undefined

Optional: compute the DEFAULT enrichment values for a webhook from its schema - the seed the CMS persists and the user then edits (vs the entry's toEnrichments, which READS already-authored values).

Returns

WebhookProjectionBaseClass<EnrichmentType, IdType, ProjectionOptions>