UNPKG

@whook/whook

Version:

Build strong and efficient REST web services.

35 lines (34 loc) 2.02 kB
import { type Dependencies, type ServiceInitializer, type ProviderInitializer } from 'knifecycle'; import { type WhookAPISchemaDefinition } from './openapi.js'; import { type JsonValue } from 'type-fest'; import { type ExpressiveJSONSchema } from 'ya-json-schema-types'; import { type WhookHandlerWrapper } from './wrappers.js'; import { type WhookEnvironmentsConfig } from '../libs/environments.js'; export declare const DEFAULT_TRANSFORMER_CONFIG: WhookTransformerConfig; export type WhookBaseTransformerConfig = { environments?: WhookEnvironmentsConfig; targetHandler?: string; }; export interface WhookTransformerConfig extends WhookBaseTransformerConfig { } export type WhookTransformerDefinition = { name: string; inputSchema: ExpressiveJSONSchema; outputSchema: ExpressiveJSONSchema; config?: WhookTransformerConfig; }; export interface WhookTransformerHandler<T extends JsonValue, U extends JsonValue, D extends WhookTransformerDefinition = WhookTransformerDefinition> { (input: T, definition: D): Promise<U>; } export type WhookTransformerHandlerInitializer<T extends JsonValue, U extends JsonValue, D extends Dependencies = Record<string, unknown>> = ServiceInitializer<D, WhookTransformerHandler<T, U>> | ProviderInitializer<D, WhookTransformerHandler<T, U>>; export declare const TRANSFORMER_ASIDE_COMPONENTS_SUFFIXES: readonly ["Schema"]; export declare const TRANSFORMER_ASIDE_COMPONENTS_PROPERTY_MAP: { readonly Schema: "schema"; }; export type WhookTransformerAsideComponentSuffix = (typeof TRANSFORMER_ASIDE_COMPONENTS_SUFFIXES)[number]; export interface WhookTransformerModule<T extends JsonValue = JsonValue, U extends JsonValue = JsonValue> { default: WhookTransformerHandlerInitializer<T, U>; definition: WhookTransformerDefinition; [name: `${string}Schema`]: WhookAPISchemaDefinition<unknown>; } export type WhookTransformerHandlerWrapper<T extends JsonValue = JsonValue, U extends JsonValue = JsonValue> = WhookHandlerWrapper<WhookTransformerHandler<T, U>>;