Skip to content

Commit dcfcca8

Browse files
committed
chore: consolidate multiple ZodV4Internal and ZodV3Internal defs
1 parent 4e79d6f commit dcfcca8

File tree

3 files changed

+14
-56
lines changed

3 files changed

+14
-56
lines changed

src/client/index.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,17 @@ import {
4242
} from '../types.js';
4343
import { AjvJsonSchemaValidator } from '../validation/ajv-provider.js';
4444
import type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator } from '../validation/types.js';
45-
import { AnyObjectSchema, SchemaOutput, getObjectShape, isZ4Schema, safeParse, type AnySchema } from '../server/zod-compat.js';
45+
import {
46+
AnyObjectSchema,
47+
SchemaOutput,
48+
getObjectShape,
49+
isZ4Schema,
50+
safeParse,
51+
type ZodV3Internal,
52+
type ZodV4Internal
53+
} from '../server/zod-compat.js';
4654
import type { RequestHandlerExtra } from '../shared/protocol.js';
4755

48-
// Helper interfaces for accessing Zod internal properties (same as in zod-compat.ts and protocol.ts)
49-
interface ZodV3Internal {
50-
_def?: {
51-
typeName?: string;
52-
value?: unknown;
53-
values?: unknown[];
54-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
55-
description?: string;
56-
};
57-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
58-
value?: unknown;
59-
}
60-
61-
interface ZodV4Internal {
62-
_zod?: {
63-
def?: {
64-
typeName?: string;
65-
value?: unknown;
66-
values?: unknown[];
67-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
68-
description?: string;
69-
};
70-
};
71-
value?: unknown;
72-
}
73-
7456
/**
7557
* Elicitation default application helper. Applies defaults to the data based on the schema.
7658
*

src/server/zod-compat.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type ZodRawShapeCompat = Record<string, AnySchema>;
1616

1717
// --- Internal property access helpers ---
1818
// These types help us safely access internal properties that differ between v3 and v4
19-
interface ZodV3Internal {
19+
export interface ZodV3Internal {
2020
_def?: {
2121
typeName?: string;
2222
value?: unknown;
@@ -25,9 +25,10 @@ interface ZodV3Internal {
2525
description?: string;
2626
};
2727
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
28+
value?: unknown;
2829
}
2930

30-
interface ZodV4Internal {
31+
export interface ZodV4Internal {
3132
_zod?: {
3233
def?: {
3334
typeName?: string;
@@ -37,6 +38,7 @@ interface ZodV4Internal {
3738
description?: string;
3839
};
3940
};
41+
value?: unknown;
4042
}
4143

4244
// --- Type inference helpers ---

src/shared/protocol.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
import { AnySchema, AnyObjectSchema, SchemaOutput, getObjectShape, safeParse, isZ4Schema } from '../server/zod-compat.js';
2-
3-
// Helper interfaces for accessing Zod internal properties (same as in zod-compat.ts)
4-
interface ZodV3Internal {
5-
_def?: {
6-
typeName?: string;
7-
value?: unknown;
8-
values?: unknown[];
9-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
10-
description?: string;
11-
};
12-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
13-
value?: unknown;
14-
}
15-
16-
interface ZodV4Internal {
17-
_zod?: {
18-
def?: {
19-
typeName?: string;
20-
value?: unknown;
21-
values?: unknown[];
22-
shape?: Record<string, AnySchema> | (() => Record<string, AnySchema>);
23-
description?: string;
24-
};
25-
};
26-
value?: unknown;
27-
}
1+
import { AnySchema, AnyObjectSchema, SchemaOutput, getObjectShape, safeParse, isZ4Schema, type ZodV3Internal, type ZodV4Internal } from '../server/zod-compat.js';
282
import {
293
CancelledNotificationSchema,
304
ClientCapabilities,

0 commit comments

Comments
 (0)