Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Availability of the proprietary schema definitions #953

Merged
merged 2 commits into from
Apr 21, 2023
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Version 10

### v10.3.1

- Fixed issue of the insufficient exports of the proprietary schema definitions.
- The issue introduced in version 10.0.0-beta1 due to changing the compiler to `tsup`.
- The issue manifested only when `declaration` is enabled in your `tsconfig.json`.
- The issue caused following error:
- `TS4023: Exported variable '' has or is using name 'ZodFileDef' from external module "" but cannot be named.`
- The following interfaces are now available within the exported `ez` namespace:
- `ez.ZodFileDef`, `ez.ZodUploadDef`, `ez.ZodDateInDef`, `ez.ZodDateOutDef`.

### v10.3.0

- Feature #945 for a client generator, proposed by [@McMerph](https://github.com/McMerph).
Expand Down
17 changes: 0 additions & 17 deletions src/ez-namespace.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export {
export { withMeta } from "./metadata";
export { testEndpoint } from "./mock";
export { Client } from "./client";
export { ez } from "./ez-namespace";
export * as ez from "./proprietary-schemas";
RobinTail marked this conversation as resolved.
Show resolved Hide resolved

import createHttpError from "http-errors";
export { createHttpError };
14 changes: 14 additions & 0 deletions src/proprietary-schemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ZodDateIn } from "./date-in-schema";
import { ZodDateOut } from "./date-out-schema";
import { ZodFile } from "./file-schema";
import { ZodUpload } from "./upload-schema";

export type { ZodDateInDef } from "./date-in-schema";
export type { ZodDateOutDef } from "./date-out-schema";
export type { ZodFileDef } from "./file-schema";
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
export type { ZodUploadDef } from "./upload-schema";

export const file = ZodFile.create;
export const upload = ZodUpload.create;
export const dateIn = ZodDateIn.create;
export const dateOut = ZodDateOut.create;
13 changes: 12 additions & 1 deletion src/schema-walker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { z } from "zod";
import { ProprietaryKinds } from "./ez-namespace";
import {
ZodDateInDef,
ZodDateOutDef,
ZodFileDef,
ZodUploadDef,
} from "./proprietary-schemas";

export type HandlingVariant = "last" | "regular" | "each";

Expand Down Expand Up @@ -29,6 +34,12 @@ export type SchemaHandler<
Variant extends HandlingVariant = "regular"
> = (params: SchemaHandlingProps<T, U, Context, Variant>) => U;

export type ProprietaryKinds =
RobinTail marked this conversation as resolved.
Show resolved Hide resolved
| ZodFileDef["typeName"]
| ZodUploadDef["typeName"]
| ZodDateInDef["typeName"]
| ZodDateOutDef["typeName"];

export type HandlingRules<U, Context extends object = {}> = Partial<
Record<
z.ZodFirstPartyTypeKind | ProprietaryKinds,
Expand Down