import type { z } from 'zod'; import type { VersionedArvoContract } from './ArvoContract/VersionedArvoContract'; import type ArvoEvent from './ArvoEvent'; import type { CloudEventExtensionSchema } from './ArvoEvent/schema'; import type { ArvoExtension, OpenTelemetryExtension } from './ArvoEvent/types'; import type { ArvoErrorSchema } from './schema'; /** * Represents a semantic version string following the SemVer format (MAJOR.MINOR.PATCH). */ export type ArvoSemanticVersion = `${number}.${number}.${number}`; /** * Infers the complete structure of an ArvoEvent by combining base CloudEvents fields, * Arvo-specific extensions, OpenTelemetry extensions, and custom extensions. * * @example * ```typescript * type UserCreatedEvent = InferArvoEvent>; * ``` */ export type InferArvoEvent> = { id: string; source: string; specversion: string; type: TEvent['type']; subject: string; datacontenttype: string; dataschema: string | null; data: TEvent['data']; time: string; } & ArvoExtension & OpenTelemetryExtension & TEvent['extensions']; /** * Utility type to infer the TypeScript type from a Zod schema. */ type InferZodSchema = z.infer; /** * Represents the structure of an Arvo system error, inferred from the ArvoErrorSchema. * Provides the standard error format used across all Arvo contracts. * * @see {@link ArvoErrorSchema} for the underlying Zod schema definition */ export type ArvoErrorType = z.infer; /** * Infers that complete ArvoEvent structure for all the events * that can be accepted and emitted by the handler bound to the * provided versioned ArvoContract. * * @see {@link VersionedArvoContract} for the input contract structure * @see {@link InferArvoEvent} for the event inference utility * @see {@link ArvoEvent} for the base event structure */ export type InferVersionedArvoContract> = { uri: TVersion['uri']; version: TVersion['version']; description: TVersion['description']; metadata: TVersion['metadata']; systemError: InferArvoEvent, z.infer, TVersion['systemError']['type']>>; accepts: InferArvoEvent, z.infer, TVersion['accepts']['type']>>; emits: { [K in string & keyof TVersion['emits']]: InferArvoEvent, Record, K>>; }; emitList: Array<{ [K in string & keyof TVersion['emits']]: InferArvoEvent, Record, K>>; }[string & keyof TVersion['emits']]>; }; export {};