diff --git a/lib/dezerialize.ts b/lib/dezerialize.ts index 9a59665..0ba9617 100644 --- a/lib/dezerialize.ts +++ b/lib/dezerialize.ts @@ -35,11 +35,11 @@ import { SzVoid, SzRef, NUMBER_FORMATS, -} from "./types"; +} from "./types.js"; -import { ZodTypes } from "./zod-types"; +import { ZodTypes } from "./zod-types.js"; -type DezerializerOptions = { +export type DezerializerOptions = { errors?: { [key: string]: z.core.$ZodErrorMap; }; diff --git a/lib/index.test.ts b/lib/index.test.ts index 18147e2..841033e 100644 --- a/lib/index.test.ts +++ b/lib/index.test.ts @@ -1,10 +1,10 @@ import fs from "fs"; import { expect, test } from "vitest"; import { z } from "zod"; -import { SzCatch, SzEnum } from "./types"; -import { ZodTypes } from "./zod-types"; +import { SzCatch, SzEnum } from "./types.js"; +import { ZodTypes } from "./zod-types.js"; -import { dezerialize, SzType, zerialize, Zerialize } from "./index"; +import { dezerialize, SzType, zerialize, Zerialize } from "./index.js"; const zodexSchemaJSON = JSON.parse( fs.readFileSync("./schema.zodex.json", "utf-8"), diff --git a/lib/index.ts b/lib/index.ts index 22d9b69..b349c2f 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,11 +1,12 @@ -import { SzType } from "./types"; +import { SzType } from "./types.js"; -export * from "./dezerialize"; -export * from "./zerialize"; +export * from "./dezerialize.js"; +export * from "./zerialize.js"; -export * from "./types"; +export * from "./types.js"; +export * from "./zod-types.js"; -type KeysOfUnion = T extends T ? keyof T : never; +export type KeysOfUnion = T extends T ? keyof T : never; export type SzPropertyKeysOf = KeysOfUnion< Extract["properties"] >; diff --git a/lib/infer.ts b/lib/infer.ts index 7593771..79dceb0 100644 --- a/lib/infer.ts +++ b/lib/infer.ts @@ -1,5 +1,3 @@ -import { RequiredKeysOf, OptionalKeysOf } from "type-fest"; - import { SzType, SzOptional, @@ -16,7 +14,7 @@ import { SzEnum, SzPromise, // SzRef, -} from "./types"; +} from "./types.js"; type PrimitiveTypes = { string: string; diff --git a/lib/zerialize.ts b/lib/zerialize.ts index 402a127..4cdc607 100644 --- a/lib/zerialize.ts +++ b/lib/zerialize.ts @@ -30,8 +30,8 @@ import { SzSymbol, SzExtras, SzKey, -} from "./types"; -import { ZodTypes, ZTypeName } from "./zod-types"; +} from "./types.js"; +import { ZodTypes, ZTypeName } from "./zod-types.js"; export const PRIMITIVES = { ZodString: "string", @@ -50,7 +50,7 @@ export const PRIMITIVES = { } as const satisfies Readonly>>; export type PrimitiveMap = typeof PRIMITIVES; -type IsZodPrimitive = +export type IsZodPrimitive = ZTypeName extends keyof PrimitiveMap ? any : never; // Helper type to extract SomeType from Zod 4 diff --git a/lib/zod-types.ts b/lib/zod-types.ts index 88d3c7c..564a301 100644 --- a/lib/zod-types.ts +++ b/lib/zod-types.ts @@ -1,9 +1,9 @@ import { z } from "zod"; // Helper type to extract SomeType from Zod 4 -type SomeType = z.core.SomeType; +export type SomeType = z.core.SomeType; -type Modifiers = +export type Modifiers = | z.ZodOptional | z.ZodNullable | z.ZodDefault @@ -13,7 +13,7 @@ type Modifiers = | z.ZodLazy | z.ZodReadonly; -type Primitives = +export type Primitives = | z.ZodString | z.ZodCoercedString | z.ZodNumber @@ -33,17 +33,17 @@ type Primitives = | z.ZodVoid | z.ZodSymbol; -type ListCollections = +export type ListCollections = | z.ZodTuple | z.ZodSet | z.ZodArray; -type KVCollections = +export type KVCollections = | z.ZodObject | z.ZodRecord | z.ZodMap; -type ADTs = +export type ADTs = | z.ZodUnion | z.ZodDiscriminatedUnion | z.ZodIntersection