UNPKG

torotask

Version:

Task queue processing in NodeJS based on BullMQ and Redis

19 lines 969 B
import type { ZodSchema, z } from 'zod'; import type { IsStrictlyUnknown } from './utils.js'; /** * Defines the type for a schema. It can be a ZodSchema instance or undefined. */ export type SchemaHandler = ZodSchema | undefined; /** * Resolves the actual ZodSchema type. * If SH is a ZodSchema, that schema type is returned. * Otherwise (e.g., SH is undefined), it resolves to undefined. */ export type ResolvedSchemaType<SH extends SchemaHandler> = SH extends ZodSchema ? SH : undefined; /** * Determines the effective payload type for a task. * If a schema is present, the payload type is inferred from it. * Otherwise, it falls back to `PayloadExplicit` or `unknown`. */ export type EffectivePayloadType<PayloadExplicit, SchemaTypeResolved extends ZodSchema | undefined> = SchemaTypeResolved extends ZodSchema ? z.infer<SchemaTypeResolved> : IsStrictlyUnknown<PayloadExplicit> extends true ? unknown : PayloadExplicit; //# sourceMappingURL=schema.d.ts.map