diff --git a/.changeset/wicked-ties-laugh.md b/.changeset/wicked-ties-laugh.md new file mode 100644 index 00000000..38f443d1 --- /dev/null +++ b/.changeset/wicked-ties-laugh.md @@ -0,0 +1,5 @@ +--- +"inngest": patch +--- + +Separate Zod typing from library, enabling minor-agnostic versioning support diff --git a/packages/inngest/etc/inngest.api.md b/packages/inngest/etc/inngest.api.md index 82cd016f..345e8f7c 100644 --- a/packages/inngest/etc/inngest.api.md +++ b/packages/inngest/etc/inngest.api.md @@ -6,7 +6,7 @@ import { Jsonify } from 'type-fest'; import { Simplify } from 'type-fest'; -import { z } from 'zod'; +import { z as z_2 } from 'zod'; // @public export interface ClientOptions { @@ -78,7 +78,7 @@ export type FailureEventPayload

= { data: { function_id: string; run_id: string; - error: z.output; + error: z_2.output; event: P; }; }; @@ -230,6 +230,8 @@ export enum internalEvents { // @internal export type IsStringLiteral = string extends T ? false : true; +// Warning: (ae-forgotten-export) The symbol "z" needs to be exported by the entry point index.d.ts +// // @public export type LiteralZodEventSchema = z.ZodObject<{ name: z.ZodLiteral; diff --git a/packages/inngest/src/components/EventSchemas.ts b/packages/inngest/src/components/EventSchemas.ts index ccdc0e80..f80e9bde 100644 --- a/packages/inngest/src/components/EventSchemas.ts +++ b/packages/inngest/src/components/EventSchemas.ts @@ -1,6 +1,6 @@ import { type Simplify } from "type-fest"; -import { type z } from "zod"; import { type IsEmptyObject, type IsStringLiteral } from "../helpers/types"; +import type * as z from "../helpers/validators/zod"; import { type EventPayload } from "../types"; /** @@ -104,7 +104,7 @@ export type PickLiterals = { * * @public */ -export type GetName = T extends z.ZodObject +export type GetName = T extends z.ZodObject ? U extends { name: z.ZodLiteral } ? S : never diff --git a/packages/inngest/src/helpers/validators/zod.ts b/packages/inngest/src/helpers/validators/zod.ts new file mode 100644 index 00000000..020b355c --- /dev/null +++ b/packages/inngest/src/helpers/validators/zod.ts @@ -0,0 +1,38 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/** + * Shim for Zod types to ensure hopeful compatibility between minor versions; + * let developers the latest version of Zod without having to have Inngest match + * the same version. + * + * Feels weird to be using internal properties like this, but types break across + * minors anyway, so at least with this we rely on fewer fields staying the + * same. + */ +export type ZodLiteral = { + get value(): TValue; + _def: { + typeName: "ZodLiteral"; + }; +}; + +export type ZodTypeAny = { + _type: any; + _output: any; + _input: any; + _def: any; +}; + +export type ZodObject = { + get shape(): TShape; + _def: { + typeName: "ZodObject"; + }; +}; + +export type AnyZodObject = ZodObject; + +export type ZodAny = { + _any: true; +}; + +export type infer = T["_output"];