@mastra/schema-compat 0.10.6 → 0.10.7-alpha.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/provider-compats/anthropic.d.ts +2 -2
- package/dist/provider-compats/anthropic.d.ts.map +1 -1
- package/dist/provider-compats/deepseek.d.ts +2 -2
- package/dist/provider-compats/deepseek.d.ts.map +1 -1
- package/dist/provider-compats/google.d.ts +2 -2
- package/dist/provider-compats/google.d.ts.map +1 -1
- package/dist/provider-compats/meta.d.ts +2 -2
- package/dist/provider-compats/meta.d.ts.map +1 -1
- package/dist/provider-compats/openai-reasoning.d.ts +2 -2
- package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
- package/dist/provider-compats/openai.d.ts +2 -2
- package/dist/provider-compats/openai.d.ts.map +1 -1
- package/dist/schema-compatibility.d.ts +8 -3
- package/dist/schema-compatibility.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/provider-compats/anthropic.ts +2 -3
- package/src/provider-compats/deepseek.ts +2 -2
- package/src/provider-compats/google.ts +2 -2
- package/src/provider-compats/meta.ts +2 -2
- package/src/provider-compats/openai-reasoning.ts +7 -3
- package/src/provider-compats/openai.ts +2 -3
- package/src/provider-compats.test.ts +120 -25
- package/src/schema-compatibility.test.ts +22 -6
- package/src/schema-compatibility.ts +10 -4
- package/src/utils.test.ts +32 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
5
5
|
export declare class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
shouldApply(): boolean;
|
|
9
9
|
processZodType(value: ZodTypeAny): ZodTypeAny;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/provider-compats/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/provider-compats/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AACzG,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAwB9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
5
5
|
export declare class DeepSeekSchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
shouldApply(): boolean;
|
|
9
9
|
processZodType(value: ZodTypeAny): ZodTypeAny;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek.d.ts","sourceRoot":"","sources":["../../src/provider-compats/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"deepseek.d.ts","sourceRoot":"","sources":["../../src/provider-compats/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AACzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAKtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAe9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
3
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
4
4
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
5
5
|
export declare class GoogleSchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
shouldApply(): boolean;
|
|
9
9
|
processZodType(value: ZodTypeAny): ZodTypeAny;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/provider-compats/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/provider-compats/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiC9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
5
5
|
export declare class MetaSchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
shouldApply(): boolean;
|
|
9
9
|
processZodType(value: ZodTypeAny): ZodTypeAny;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/provider-compats/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/provider-compats/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAyD,MAAM,yBAAyB,CAAC;AACnH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,qBAAa,qBAAsB,SAAQ,iBAAiB;gBAC9C,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiB9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
3
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
4
4
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
5
5
|
export declare class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
isReasoningModel(): boolean;
|
|
9
9
|
shouldApply(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-reasoning.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai-reasoning.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,gBAAgB,IAAI,OAAO;IAU3B,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA4C9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer } from '../schema-compatibility.js';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility.js';
|
|
5
5
|
export declare class OpenAISchemaCompatLayer extends SchemaCompatLayer {
|
|
6
|
-
constructor(model:
|
|
6
|
+
constructor(model: ModelInformation);
|
|
7
7
|
getSchemaTarget(): Targets | undefined;
|
|
8
8
|
shouldApply(): boolean;
|
|
9
9
|
processZodType(value: ZodTypeAny): ZodTypeAny;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AACzG,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AAEjF,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA6B9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Schema
|
|
1
|
+
import type { Schema } from 'ai';
|
|
2
2
|
import type { JSONSchema7 } from 'json-schema';
|
|
3
3
|
import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
|
|
4
4
|
import type { ZodTypeAny } from 'zod';
|
|
@@ -108,6 +108,11 @@ type DateConstraints = {
|
|
|
108
108
|
maxDate?: string;
|
|
109
109
|
dateFormat?: string;
|
|
110
110
|
};
|
|
111
|
+
export type ModelInformation = {
|
|
112
|
+
modelId: string;
|
|
113
|
+
provider: string;
|
|
114
|
+
supportsStructuredOutputs: boolean;
|
|
115
|
+
};
|
|
111
116
|
/**
|
|
112
117
|
* Abstract base class for creating schema compatibility layers for different AI model providers.
|
|
113
118
|
*
|
|
@@ -154,13 +159,13 @@ export declare abstract class SchemaCompatLayer {
|
|
|
154
159
|
*
|
|
155
160
|
* @param model - The language model this compatibility layer applies to
|
|
156
161
|
*/
|
|
157
|
-
constructor(model:
|
|
162
|
+
constructor(model: ModelInformation);
|
|
158
163
|
/**
|
|
159
164
|
* Gets the language model associated with this compatibility layer.
|
|
160
165
|
*
|
|
161
166
|
* @returns The language model instance
|
|
162
167
|
*/
|
|
163
|
-
getModel():
|
|
168
|
+
getModel(): ModelInformation;
|
|
164
169
|
/**
|
|
165
170
|
* Determines whether this compatibility layer should be applied for the current model.
|
|
166
171
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-compatibility.d.ts","sourceRoot":"","sources":["../src/schema-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"schema-compatibility.d.ts","sourceRoot":"","sources":["../src/schema-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QA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;;;;;OAMG;IACI,yBAAyB,CAC9B,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,EACvB,WAAW,GAAE,SAAS,UAAU,EAAwB,GACvD,UAAU;IAQb;;;;;OAKG;IACI,oBAAoB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,MAAM;IAM3D;;;;;OAKG;IACI,mBAAmB,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,WAAW;CAGhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/schema-compat",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7-alpha.0",
|
|
4
4
|
"description": "Tool schema compatibility layer for Mastra.ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "^5.8.3",
|
|
46
46
|
"vitest": "^3.2.4",
|
|
47
47
|
"zod": "^3.25.67",
|
|
48
|
-
"@internal/lint": "0.0.
|
|
49
|
-
"@internal/types-builder": "0.0.
|
|
48
|
+
"@internal/lint": "0.0.28",
|
|
49
|
+
"@internal/types-builder": "0.0.3"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup --silent --config tsup.config.ts",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer, isArr, isObj, isOptional, isString, isUnion } from '../schema-compatibility';
|
|
5
|
-
import type { AllZodType } from '../schema-compatibility';
|
|
4
|
+
import type { AllZodType, ModelInformation } from '../schema-compatibility';
|
|
6
5
|
|
|
7
6
|
export class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
|
|
8
|
-
constructor(model:
|
|
7
|
+
constructor(model: ModelInformation) {
|
|
9
8
|
super(model);
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer, isArr, isObj, isOptional, isString, isUnion } from '../schema-compatibility';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility';
|
|
5
5
|
|
|
6
6
|
export class DeepSeekSchemaCompatLayer extends SchemaCompatLayer {
|
|
7
|
-
constructor(model:
|
|
7
|
+
constructor(model: ModelInformation) {
|
|
8
8
|
super(model);
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility';
|
|
5
5
|
import {
|
|
6
6
|
SchemaCompatLayer,
|
|
7
7
|
UNSUPPORTED_ZOD_TYPES,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '../schema-compatibility';
|
|
16
16
|
|
|
17
17
|
export class GoogleSchemaCompatLayer extends SchemaCompatLayer {
|
|
18
|
-
constructor(model:
|
|
18
|
+
constructor(model: ModelInformation) {
|
|
19
19
|
super(model);
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer, isArr, isNumber, isObj, isOptional, isString, isUnion } from '../schema-compatibility';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility';
|
|
5
5
|
|
|
6
6
|
export class MetaSchemaCompatLayer extends SchemaCompatLayer {
|
|
7
|
-
constructor(model:
|
|
7
|
+
constructor(model: ModelInformation) {
|
|
8
8
|
super(model);
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
import type { ZodTypeAny } from 'zod';
|
|
4
3
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
|
+
import type { ModelInformation } from '../schema-compatibility';
|
|
5
5
|
import {
|
|
6
6
|
SchemaCompatLayer,
|
|
7
7
|
isArr,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '../schema-compatibility';
|
|
16
16
|
|
|
17
17
|
export class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
|
|
18
|
-
constructor(model:
|
|
18
|
+
constructor(model: ModelInformation) {
|
|
19
19
|
super(model);
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -26,7 +26,11 @@ export class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
|
|
|
26
26
|
isReasoningModel(): boolean {
|
|
27
27
|
// there isn't a good way to automatically detect reasoning models besides doing this.
|
|
28
28
|
// in the future when o5 is released this compat wont apply and we'll want to come back and update this class + our tests
|
|
29
|
-
return
|
|
29
|
+
return (
|
|
30
|
+
this.getModel().modelId.includes(`o3`) ||
|
|
31
|
+
this.getModel().modelId.includes(`o4`) ||
|
|
32
|
+
this.getModel().modelId.includes(`o1`)
|
|
33
|
+
);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
shouldApply(): boolean {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import type { ZodTypeAny } from 'zod';
|
|
3
2
|
import type { Targets } from 'zod-to-json-schema';
|
|
4
3
|
import { SchemaCompatLayer, isArr, isObj, isOptional, isString, isUnion } from '../schema-compatibility';
|
|
5
|
-
import type { StringCheckType } from '../schema-compatibility';
|
|
4
|
+
import type { ModelInformation, StringCheckType } from '../schema-compatibility';
|
|
6
5
|
|
|
7
6
|
export class OpenAISchemaCompatLayer extends SchemaCompatLayer {
|
|
8
|
-
constructor(model:
|
|
7
|
+
constructor(model: ModelInformation) {
|
|
9
8
|
super(model);
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -40,22 +40,38 @@ describe('Provider Compatibility Classes', () => {
|
|
|
40
40
|
|
|
41
41
|
describe('AnthropicSchemaCompatLayer', () => {
|
|
42
42
|
it('should apply for Anthropic models', () => {
|
|
43
|
-
const compat = new AnthropicSchemaCompatLayer(
|
|
43
|
+
const compat = new AnthropicSchemaCompatLayer({
|
|
44
|
+
modelId: mockModels.anthropic.modelId,
|
|
45
|
+
supportsStructuredOutputs: mockModels.anthropic.supportsStructuredOutputs ?? false,
|
|
46
|
+
provider: mockModels.anthropic.provider,
|
|
47
|
+
});
|
|
44
48
|
expect(compat.shouldApply()).toBe(true);
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
it('should not apply for non-Anthropic models', () => {
|
|
48
|
-
const compat = new AnthropicSchemaCompatLayer(
|
|
52
|
+
const compat = new AnthropicSchemaCompatLayer({
|
|
53
|
+
modelId: mockModels.openai.modelId,
|
|
54
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
55
|
+
provider: mockModels.openai.provider,
|
|
56
|
+
});
|
|
49
57
|
expect(compat.shouldApply()).toBe(false);
|
|
50
58
|
});
|
|
51
59
|
|
|
52
60
|
it('should return correct schema target', () => {
|
|
53
|
-
const compat = new AnthropicSchemaCompatLayer(
|
|
61
|
+
const compat = new AnthropicSchemaCompatLayer({
|
|
62
|
+
modelId: mockModels.anthropic.modelId,
|
|
63
|
+
supportsStructuredOutputs: mockModels.anthropic.supportsStructuredOutputs ?? false,
|
|
64
|
+
provider: mockModels.anthropic.provider,
|
|
65
|
+
});
|
|
54
66
|
expect(compat.getSchemaTarget()).toBe('jsonSchema7');
|
|
55
67
|
});
|
|
56
68
|
|
|
57
69
|
it('should process schemas correctly', () => {
|
|
58
|
-
const compat = new AnthropicSchemaCompatLayer(
|
|
70
|
+
const compat = new AnthropicSchemaCompatLayer({
|
|
71
|
+
modelId: mockModels.anthropic.modelId,
|
|
72
|
+
supportsStructuredOutputs: mockModels.anthropic.supportsStructuredOutputs ?? false,
|
|
73
|
+
provider: mockModels.anthropic.provider,
|
|
74
|
+
});
|
|
59
75
|
const schema = z.object({
|
|
60
76
|
text: z.string().min(1).max(100),
|
|
61
77
|
count: z.number().min(1),
|
|
@@ -79,17 +95,29 @@ describe('Provider Compatibility Classes', () => {
|
|
|
79
95
|
|
|
80
96
|
describe('OpenAISchemaCompatLayer', () => {
|
|
81
97
|
it('should apply for OpenAI models without structured outputs support', () => {
|
|
82
|
-
const compat = new OpenAISchemaCompatLayer(
|
|
98
|
+
const compat = new OpenAISchemaCompatLayer({
|
|
99
|
+
modelId: mockModels.openai.modelId,
|
|
100
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
101
|
+
provider: mockModels.openai.provider,
|
|
102
|
+
});
|
|
83
103
|
expect(compat.shouldApply()).toBe(true);
|
|
84
104
|
});
|
|
85
105
|
|
|
86
106
|
it('should return correct schema target', () => {
|
|
87
|
-
const compat = new OpenAISchemaCompatLayer(
|
|
107
|
+
const compat = new OpenAISchemaCompatLayer({
|
|
108
|
+
modelId: mockModels.openai.modelId,
|
|
109
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
110
|
+
provider: mockModels.openai.provider,
|
|
111
|
+
});
|
|
88
112
|
expect(compat.getSchemaTarget()).toBe('jsonSchema7');
|
|
89
113
|
});
|
|
90
114
|
|
|
91
115
|
it('should process complex schemas', () => {
|
|
92
|
-
const compat = new OpenAISchemaCompatLayer(
|
|
116
|
+
const compat = new OpenAISchemaCompatLayer({
|
|
117
|
+
modelId: mockModels.openai.modelId,
|
|
118
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
119
|
+
provider: mockModels.openai.provider,
|
|
120
|
+
});
|
|
93
121
|
const schema = z.object({
|
|
94
122
|
user: z.object({
|
|
95
123
|
name: z.string().email(),
|
|
@@ -122,29 +150,49 @@ describe('Provider Compatibility Classes', () => {
|
|
|
122
150
|
|
|
123
151
|
describe('OpenAIReasoningSchemaCompatLayer', () => {
|
|
124
152
|
it('should have consistent behavior', () => {
|
|
125
|
-
const compat = new OpenAIReasoningSchemaCompatLayer(
|
|
153
|
+
const compat = new OpenAIReasoningSchemaCompatLayer({
|
|
154
|
+
modelId: mockModels.openaiReasoning.modelId,
|
|
155
|
+
supportsStructuredOutputs: mockModels.openaiReasoning.supportsStructuredOutputs ?? false,
|
|
156
|
+
provider: mockModels.openaiReasoning.provider,
|
|
157
|
+
});
|
|
126
158
|
expect(compat.shouldApply()).toBe(true);
|
|
127
159
|
});
|
|
128
160
|
|
|
129
161
|
it('should return correct schema target', () => {
|
|
130
|
-
const compat = new OpenAIReasoningSchemaCompatLayer(
|
|
162
|
+
const compat = new OpenAIReasoningSchemaCompatLayer({
|
|
163
|
+
modelId: mockModels.openaiReasoning.modelId,
|
|
164
|
+
supportsStructuredOutputs: mockModels.openaiReasoning.supportsStructuredOutputs ?? false,
|
|
165
|
+
provider: mockModels.openaiReasoning.provider,
|
|
166
|
+
});
|
|
131
167
|
expect(compat.getSchemaTarget()).toBe('openApi3');
|
|
132
168
|
});
|
|
133
169
|
});
|
|
134
170
|
|
|
135
171
|
describe('GoogleSchemaCompatLayer', () => {
|
|
136
172
|
it('should have consistent behavior', () => {
|
|
137
|
-
const compat = new GoogleSchemaCompatLayer(
|
|
173
|
+
const compat = new GoogleSchemaCompatLayer({
|
|
174
|
+
modelId: mockModels.google.modelId,
|
|
175
|
+
supportsStructuredOutputs: mockModels.google.supportsStructuredOutputs ?? false,
|
|
176
|
+
provider: mockModels.google.provider,
|
|
177
|
+
});
|
|
138
178
|
expect(typeof compat.shouldApply()).toBe('boolean');
|
|
139
179
|
});
|
|
140
180
|
|
|
141
181
|
it('should return correct schema target', () => {
|
|
142
|
-
const compat = new GoogleSchemaCompatLayer(
|
|
182
|
+
const compat = new GoogleSchemaCompatLayer({
|
|
183
|
+
modelId: mockModels.google.modelId,
|
|
184
|
+
supportsStructuredOutputs: mockModels.google.supportsStructuredOutputs ?? false,
|
|
185
|
+
provider: mockModels.google.provider,
|
|
186
|
+
});
|
|
143
187
|
expect(compat.getSchemaTarget()).toBe('jsonSchema7');
|
|
144
188
|
});
|
|
145
189
|
|
|
146
190
|
it('should handle date types correctly', () => {
|
|
147
|
-
const compat = new GoogleSchemaCompatLayer(
|
|
191
|
+
const compat = new GoogleSchemaCompatLayer({
|
|
192
|
+
modelId: mockModels.google.modelId,
|
|
193
|
+
supportsStructuredOutputs: mockModels.google.supportsStructuredOutputs ?? false,
|
|
194
|
+
provider: mockModels.google.provider,
|
|
195
|
+
});
|
|
148
196
|
const schema = z.object({
|
|
149
197
|
startDate: z.date(),
|
|
150
198
|
endDate: z.date().optional(),
|
|
@@ -169,22 +217,38 @@ describe('Provider Compatibility Classes', () => {
|
|
|
169
217
|
|
|
170
218
|
describe('DeepSeekSchemaCompatLayer', () => {
|
|
171
219
|
it('should apply for DeepSeek models', () => {
|
|
172
|
-
const compat = new DeepSeekSchemaCompatLayer(
|
|
220
|
+
const compat = new DeepSeekSchemaCompatLayer({
|
|
221
|
+
modelId: mockModels.deepseek.modelId,
|
|
222
|
+
supportsStructuredOutputs: mockModels.deepseek.supportsStructuredOutputs ?? false,
|
|
223
|
+
provider: mockModels.deepseek.provider,
|
|
224
|
+
});
|
|
173
225
|
expect(compat.shouldApply()).toBe(true);
|
|
174
226
|
});
|
|
175
227
|
|
|
176
228
|
it('should not apply for non-DeepSeek models', () => {
|
|
177
|
-
const compat = new DeepSeekSchemaCompatLayer(
|
|
229
|
+
const compat = new DeepSeekSchemaCompatLayer({
|
|
230
|
+
modelId: mockModels.openai.modelId,
|
|
231
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
232
|
+
provider: mockModels.openai.provider,
|
|
233
|
+
});
|
|
178
234
|
expect(compat.shouldApply()).toBe(false);
|
|
179
235
|
});
|
|
180
236
|
|
|
181
237
|
it('should return correct schema target', () => {
|
|
182
|
-
const compat = new DeepSeekSchemaCompatLayer(
|
|
238
|
+
const compat = new DeepSeekSchemaCompatLayer({
|
|
239
|
+
modelId: mockModels.deepseek.modelId,
|
|
240
|
+
supportsStructuredOutputs: mockModels.deepseek.supportsStructuredOutputs ?? false,
|
|
241
|
+
provider: mockModels.deepseek.provider,
|
|
242
|
+
});
|
|
183
243
|
expect(compat.getSchemaTarget()).toBe('jsonSchema7');
|
|
184
244
|
});
|
|
185
245
|
|
|
186
246
|
it('should handle string constraints', () => {
|
|
187
|
-
const compat = new DeepSeekSchemaCompatLayer(
|
|
247
|
+
const compat = new DeepSeekSchemaCompatLayer({
|
|
248
|
+
modelId: mockModels.deepseek.modelId,
|
|
249
|
+
supportsStructuredOutputs: mockModels.deepseek.supportsStructuredOutputs ?? false,
|
|
250
|
+
provider: mockModels.deepseek.provider,
|
|
251
|
+
});
|
|
188
252
|
const schema = z.object({
|
|
189
253
|
email: z.string().email(),
|
|
190
254
|
url: z.string().url(),
|
|
@@ -212,17 +276,29 @@ describe('Provider Compatibility Classes', () => {
|
|
|
212
276
|
|
|
213
277
|
describe('MetaSchemaCompatLayer', () => {
|
|
214
278
|
it('should have consistent behavior', () => {
|
|
215
|
-
const compat = new MetaSchemaCompatLayer(
|
|
279
|
+
const compat = new MetaSchemaCompatLayer({
|
|
280
|
+
modelId: mockModels.meta.modelId,
|
|
281
|
+
supportsStructuredOutputs: mockModels.meta.supportsStructuredOutputs ?? false,
|
|
282
|
+
provider: mockModels.meta.provider,
|
|
283
|
+
});
|
|
216
284
|
expect(typeof compat.shouldApply()).toBe('boolean');
|
|
217
285
|
});
|
|
218
286
|
|
|
219
287
|
it('should return correct schema target', () => {
|
|
220
|
-
const compat = new MetaSchemaCompatLayer(
|
|
288
|
+
const compat = new MetaSchemaCompatLayer({
|
|
289
|
+
modelId: mockModels.meta.modelId,
|
|
290
|
+
supportsStructuredOutputs: mockModels.meta.supportsStructuredOutputs ?? false,
|
|
291
|
+
provider: mockModels.meta.provider,
|
|
292
|
+
});
|
|
221
293
|
expect(compat.getSchemaTarget()).toBe('jsonSchema7');
|
|
222
294
|
});
|
|
223
295
|
|
|
224
296
|
it('should handle array and union types', () => {
|
|
225
|
-
const compat = new MetaSchemaCompatLayer(
|
|
297
|
+
const compat = new MetaSchemaCompatLayer({
|
|
298
|
+
modelId: mockModels.meta.modelId,
|
|
299
|
+
supportsStructuredOutputs: mockModels.meta.supportsStructuredOutputs ?? false,
|
|
300
|
+
provider: mockModels.meta.provider,
|
|
301
|
+
});
|
|
226
302
|
const schema = z.object({
|
|
227
303
|
tags: z.array(z.string()).min(1).max(10),
|
|
228
304
|
status: z.union([z.literal('active'), z.literal('inactive')]),
|
|
@@ -271,12 +347,31 @@ describe('Provider Compatibility Classes', () => {
|
|
|
271
347
|
});
|
|
272
348
|
|
|
273
349
|
const providers = [
|
|
274
|
-
new AnthropicSchemaCompatLayer(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
new
|
|
350
|
+
new AnthropicSchemaCompatLayer({
|
|
351
|
+
modelId: mockModels.anthropic.modelId,
|
|
352
|
+
supportsStructuredOutputs: mockModels.anthropic.supportsStructuredOutputs ?? false,
|
|
353
|
+
provider: mockModels.anthropic.provider,
|
|
354
|
+
}),
|
|
355
|
+
new OpenAISchemaCompatLayer({
|
|
356
|
+
modelId: mockModels.openai.modelId,
|
|
357
|
+
supportsStructuredOutputs: mockModels.openai.supportsStructuredOutputs ?? false,
|
|
358
|
+
provider: mockModels.openai.provider,
|
|
359
|
+
}),
|
|
360
|
+
new OpenAIReasoningSchemaCompatLayer({
|
|
361
|
+
modelId: mockModels.openaiReasoning.modelId,
|
|
362
|
+
supportsStructuredOutputs: mockModels.openaiReasoning.supportsStructuredOutputs ?? false,
|
|
363
|
+
provider: mockModels.openaiReasoning.provider,
|
|
364
|
+
}),
|
|
365
|
+
new GoogleSchemaCompatLayer({
|
|
366
|
+
modelId: mockModels.google.modelId,
|
|
367
|
+
supportsStructuredOutputs: mockModels.google.supportsStructuredOutputs ?? false,
|
|
368
|
+
provider: mockModels.google.provider,
|
|
369
|
+
}),
|
|
370
|
+
new MetaSchemaCompatLayer({
|
|
371
|
+
modelId: mockModels.meta.modelId,
|
|
372
|
+
supportsStructuredOutputs: mockModels.meta.supportsStructuredOutputs ?? false,
|
|
373
|
+
provider: mockModels.meta.provider,
|
|
374
|
+
}),
|
|
280
375
|
];
|
|
281
376
|
|
|
282
377
|
providers.forEach(provider => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { LanguageModelV1 } from 'ai';
|
|
2
1
|
import { MockLanguageModelV1 } from 'ai/test';
|
|
3
2
|
import { describe, it, expect, beforeEach } from 'vitest';
|
|
4
3
|
import { z } from 'zod';
|
|
4
|
+
import type { ModelInformation } from './schema-compatibility';
|
|
5
5
|
import { isArr, isObj, isOptional, isString, isUnion, SchemaCompatLayer } from './schema-compatibility';
|
|
6
6
|
|
|
7
7
|
class MockSchemaCompatibility extends SchemaCompatLayer {
|
|
8
|
-
constructor(model:
|
|
8
|
+
constructor(model: ModelInformation) {
|
|
9
9
|
super(model);
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -45,12 +45,20 @@ describe('SchemaCompatLayer', () => {
|
|
|
45
45
|
let compatibility: MockSchemaCompatibility;
|
|
46
46
|
|
|
47
47
|
beforeEach(() => {
|
|
48
|
-
compatibility = new MockSchemaCompatibility(
|
|
48
|
+
compatibility = new MockSchemaCompatibility({
|
|
49
|
+
modelId: mockModel.modelId,
|
|
50
|
+
supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
|
|
51
|
+
provider: mockModel.provider,
|
|
52
|
+
});
|
|
49
53
|
});
|
|
50
54
|
|
|
51
55
|
describe('constructor and getModel', () => {
|
|
52
56
|
it('should store and return the model', () => {
|
|
53
|
-
expect(compatibility.getModel()).
|
|
57
|
+
expect(compatibility.getModel()).toEqual({
|
|
58
|
+
modelId: mockModel.modelId,
|
|
59
|
+
supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
|
|
60
|
+
provider: mockModel.provider,
|
|
61
|
+
});
|
|
54
62
|
});
|
|
55
63
|
});
|
|
56
64
|
|
|
@@ -351,7 +359,11 @@ describe('SchemaCompatLayer', () => {
|
|
|
351
359
|
}
|
|
352
360
|
}
|
|
353
361
|
|
|
354
|
-
const testCompat = new TestCompatibility(
|
|
362
|
+
const testCompat = new TestCompatibility({
|
|
363
|
+
modelId: mockModel.modelId,
|
|
364
|
+
supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
|
|
365
|
+
provider: mockModel.provider,
|
|
366
|
+
});
|
|
355
367
|
const result = testCompat.defaultZodOptionalHandler(optionalSchema);
|
|
356
368
|
|
|
357
369
|
expect(result._def.typeName).toBe('ZodOptional');
|
|
@@ -400,7 +412,11 @@ describe('SchemaCompatLayer', () => {
|
|
|
400
412
|
return super.processZodType(value);
|
|
401
413
|
}
|
|
402
414
|
}
|
|
403
|
-
const preservingCompat = new PreservingMock(
|
|
415
|
+
const preservingCompat = new PreservingMock({
|
|
416
|
+
modelId: mockModel.modelId,
|
|
417
|
+
supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
|
|
418
|
+
provider: mockModel.provider,
|
|
419
|
+
});
|
|
404
420
|
const preservingResult = preservingCompat.processToAISDKSchema(arraySchema);
|
|
405
421
|
expect(preservingResult.jsonSchema.description).toBeUndefined();
|
|
406
422
|
expect(
|