UNPKG

arvo-core

Version:

The core Arvo package which provides application tier core primitives and contract system for building production-grade event-driven application. Provides ArvoEvent (CloudEvents-compliant), ArvoContract for type-safe service interfaces, event factories, O

46 lines (45 loc) 1.45 kB
import type { z } from 'zod'; import ArvoContract from '.'; import type { ArvoSemanticVersion } from '../types'; /** * Creates a validated ArvoContract instance with full control over event types and schemas. * * @param contract - Contract specification object * * @throws {Error} If the event types contain reserved prefix ({@link ArvoOrchestratorEventTypeGen}) * @throws {Error} If any of the ArvoContract's internal validations fail. See {@link ArvoContract} * * @returns A fully typed and validated ArvoContract instance * * @example * ```typescript * const contract = createArvoContract({ * uri: 'com.example.contract', * type: 'input.event', * description: "Some example contract", * metadata: { * owner: 'team-a', * priority: 'high' * }, * versions: { * '1.0.0': { * accepts: z.object({ data: z.string() }), * emits: { * 'output.event': z.object({ result: z.number() }) * } * } * } * }); * ``` */ export declare const createArvoContract: <TUri extends string, TType extends string, TVersions extends Record<ArvoSemanticVersion, { accepts: z.ZodTypeAny; emits: Record<string, z.ZodTypeAny>; }>, TMetaData extends Record<string, any> = Record<string, any>>(contract: { uri: TUri; type: TType; versions: TVersions; domain?: string; metadata?: TMetaData; description?: string; }) => ArvoContract<TUri, TType, TVersions, TMetaData>;