UNPKG

arvo-core

Version:

This core package contains all the core classes and components of the Arvo Event Driven System

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>;