@mastra/schema-compat 0.11.2-alpha.1 → 0.11.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-MKYBUMTK.js → chunk-F4D2N3FC.js} +5 -4
- package/dist/chunk-F4D2N3FC.js.map +1 -0
- package/dist/{chunk-V7Y3FXBJ.cjs → chunk-WRGSGOLQ.cjs} +5 -4
- package/dist/chunk-WRGSGOLQ.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/dist/zod-to-json.cjs +2 -2
- package/dist/zod-to-json.d.ts.map +1 -1
- package/dist/zod-to-json.js +1 -1
- package/package.json +14 -1
- package/.turbo/turbo-build.log +0 -4
- package/dist/chunk-MKYBUMTK.js.map +0 -1
- package/dist/chunk-V7Y3FXBJ.cjs.map +0 -1
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -40
- package/src/provider-compats/anthropic.ts +0 -61
- package/src/provider-compats/deepseek.ts +0 -40
- package/src/provider-compats/google.ts +0 -49
- package/src/provider-compats/meta.ts +0 -41
- package/src/provider-compats/openai-reasoning.ts +0 -85
- package/src/provider-compats/openai.ts +0 -65
- package/src/provider-compats.test.ts +0 -407
- package/src/schema-compatibility-v3.ts +0 -664
- package/src/schema-compatibility-v4.test.ts +0 -476
- package/src/schema-compatibility-v4.ts +0 -706
- package/src/schema-compatibility.test.ts +0 -471
- package/src/schema-compatibility.ts +0 -471
- package/src/types.ts +0 -5
- package/src/utils-test-suite.ts +0 -467
- package/src/utils-v3.test.ts +0 -9
- package/src/utils-v4.test.ts +0 -9
- package/src/utils.ts +0 -211
- package/src/zod-to-json.ts +0 -28
- package/src/zodTypes.ts +0 -56
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -22
- package/vitest.config.ts +0 -7
package/src/zod-to-json.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import type { ZodSchema as ZodSchemaV3 } from 'zod/v3';
|
|
4
|
-
import type { ZodType as ZodSchemaV4 } from 'zod/v4';
|
|
5
|
-
import type { Targets } from 'zod-to-json-schema';
|
|
6
|
-
import zodToJsonSchemaOriginal from 'zod-to-json-schema';
|
|
7
|
-
|
|
8
|
-
export function zodToJsonSchema(zodSchema: ZodSchemaV3 | ZodSchemaV4, target: Targets = 'jsonSchema7') {
|
|
9
|
-
if ('toJSONSchema' in z) {
|
|
10
|
-
// Use dynamic property access to avoid import errors in Zod v3
|
|
11
|
-
return (z as any)['toJSONSchema'](zodSchema, {
|
|
12
|
-
unrepresentable: 'any',
|
|
13
|
-
override: (ctx: any) => {
|
|
14
|
-
// Safe access to handle cases where _zod might be undefined
|
|
15
|
-
const def = ctx.zodSchema?._zod?.def;
|
|
16
|
-
if (def && def.type === 'date') {
|
|
17
|
-
ctx.jsonSchema.type = 'string';
|
|
18
|
-
ctx.jsonSchema.format = 'date-time';
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
}) as JSONSchema7;
|
|
22
|
-
} else {
|
|
23
|
-
return zodToJsonSchemaOriginal(zodSchema as ZodSchemaV3, {
|
|
24
|
-
$refStrategy: 'none',
|
|
25
|
-
target,
|
|
26
|
-
}) as JSONSchema7;
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/zodTypes.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { z as zV3 } from 'zod/v3';
|
|
2
|
-
import type { z as zV4 } from 'zod/v4';
|
|
3
|
-
|
|
4
|
-
export function isOptional<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodOptional<any>;
|
|
5
|
-
export function isOptional<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodOptional<any>;
|
|
6
|
-
export function isOptional<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
7
|
-
return (v: any): v is Z['ZodOptional'] => v instanceof z['ZodOptional'];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function isObj<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodObject<any>;
|
|
11
|
-
export function isObj<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodObject;
|
|
12
|
-
export function isObj<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
13
|
-
return (v: any): v is Z['ZodObject'] => v instanceof z['ZodObject'];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function isNull<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNull;
|
|
17
|
-
export function isNull<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNull;
|
|
18
|
-
export function isNull<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
19
|
-
return (v: any): v is Z['ZodNull'] => v instanceof z['ZodNull'];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function isArr<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodArray<any>;
|
|
23
|
-
export function isArr<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodArray;
|
|
24
|
-
export function isArr<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
25
|
-
return (v: any): v is Z['ZodArray'] => v instanceof z['ZodArray'];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function isUnion<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodUnion<any>;
|
|
29
|
-
export function isUnion<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodUnion;
|
|
30
|
-
export function isUnion<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
31
|
-
return (v: any): v is Z['ZodUnion'] => v instanceof z['ZodUnion'];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function isString<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodString;
|
|
35
|
-
export function isString<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodString;
|
|
36
|
-
export function isString<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
37
|
-
return (v: any): v is Z['ZodString'] => v instanceof z['ZodString'];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function isNumber<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodNumber;
|
|
41
|
-
export function isNumber<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodNumber;
|
|
42
|
-
export function isNumber<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
43
|
-
return (v: any): v is Z['ZodNumber'] => v instanceof z['ZodNumber'];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function isDate<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDate;
|
|
47
|
-
export function isDate<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDate;
|
|
48
|
-
export function isDate<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
49
|
-
return (v: any): v is Z['ZodDate'] => v instanceof z['ZodDate'];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isDefault<Z extends typeof zV3>(z: Z): (v: any) => v is zV3.ZodDefault<any>;
|
|
53
|
-
export function isDefault<Z extends typeof zV4>(z: Z): (v: any) => v is zV4.ZodDefault;
|
|
54
|
-
export function isDefault<Z extends typeof zV3 | typeof zV4>(z: Z) {
|
|
55
|
-
return (v: any): v is Z['ZodDefault'] => v instanceof z['ZodDefault'];
|
|
56
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'child_process';
|
|
2
|
-
import { promisify } from 'util';
|
|
3
|
-
import { defineConfig } from 'tsup';
|
|
4
|
-
|
|
5
|
-
const exec = promisify(spawn);
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
entry: ['src/index.ts', 'src/zod-to-json.ts'],
|
|
9
|
-
format: ['esm', 'cjs'],
|
|
10
|
-
clean: true,
|
|
11
|
-
dts: false,
|
|
12
|
-
splitting: true,
|
|
13
|
-
treeshake: {
|
|
14
|
-
preset: 'smallest',
|
|
15
|
-
},
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
onSuccess: async () => {
|
|
18
|
-
await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
});
|