Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/dezerialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/index.test.ts
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
11 changes: 6 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -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> = T extends T ? keyof T : never;
export type KeysOfUnion<T> = T extends T ? keyof T : never;
export type SzPropertyKeysOf<T extends SzType> = KeysOfUnion<
Extract<T, { type: "object" }>["properties"]
>;
4 changes: 1 addition & 3 deletions lib/infer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { RequiredKeysOf, OptionalKeysOf } from "type-fest";

import {
SzType,
SzOptional,
Expand All @@ -16,7 +14,7 @@ import {
SzEnum,
SzPromise,
// SzRef,
} from "./types";
} from "./types.js";

type PrimitiveTypes = {
string: string;
Expand Down
6 changes: 3 additions & 3 deletions lib/zerialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -50,7 +50,7 @@ export const PRIMITIVES = {
} as const satisfies Readonly<Partial<Record<string, SzPrimitive["type"]>>>;
export type PrimitiveMap = typeof PRIMITIVES;

type IsZodPrimitive<T extends ZodTypes> =
export type IsZodPrimitive<T extends ZodTypes> =
ZTypeName<T> extends keyof PrimitiveMap ? any : never;

// Helper type to extract SomeType from Zod 4
Expand Down
12 changes: 6 additions & 6 deletions lib/zod-types.ts
Original file line number Diff line number Diff line change
@@ -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<SomeType>
| z.ZodNullable<SomeType>
| z.ZodDefault<SomeType>
Expand All @@ -13,7 +13,7 @@ type Modifiers =
| z.ZodLazy<SomeType>
| z.ZodReadonly<SomeType>;

type Primitives =
export type Primitives =
| z.ZodString
| z.ZodCoercedString
| z.ZodNumber
Expand All @@ -33,17 +33,17 @@ type Primitives =
| z.ZodVoid
| z.ZodSymbol;

type ListCollections =
export type ListCollections =
| z.ZodTuple<any, any>
| z.ZodSet<SomeType>
| z.ZodArray<SomeType>;

type KVCollections =
export type KVCollections =
| z.ZodObject<any>
| z.ZodRecord<any, SomeType>
| z.ZodMap<SomeType, SomeType>;

type ADTs =
export type ADTs =
| z.ZodUnion<readonly [SomeType, ...SomeType[]]>
| z.ZodDiscriminatedUnion<readonly SomeType[]>
| z.ZodIntersection<SomeType, SomeType>
Expand Down