@mastra/schema-compat 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 0.0.0-fix-message-list-args-missing-20250807205055

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.
Files changed (42) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +51 -1
  3. package/LICENSE.md +11 -42
  4. package/dist/index.cjs +8 -5
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.ts +9 -31
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +9 -6
  9. package/dist/index.js.map +1 -0
  10. package/dist/provider-compats/anthropic.d.ts +11 -0
  11. package/dist/provider-compats/anthropic.d.ts.map +1 -0
  12. package/dist/provider-compats/deepseek.d.ts +11 -0
  13. package/dist/provider-compats/deepseek.d.ts.map +1 -0
  14. package/dist/provider-compats/google.d.ts +11 -0
  15. package/dist/provider-compats/google.d.ts.map +1 -0
  16. package/dist/provider-compats/meta.d.ts +11 -0
  17. package/dist/provider-compats/meta.d.ts.map +1 -0
  18. package/dist/provider-compats/openai-reasoning.d.ts +12 -0
  19. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -0
  20. package/dist/provider-compats/openai.d.ts +11 -0
  21. package/dist/provider-compats/openai.d.ts.map +1 -0
  22. package/dist/schema-compatibility.d.ts +285 -0
  23. package/dist/schema-compatibility.d.ts.map +1 -0
  24. package/dist/utils.d.ts +84 -0
  25. package/dist/utils.d.ts.map +1 -0
  26. package/package.json +9 -8
  27. package/src/provider-compats/anthropic.ts +2 -3
  28. package/src/provider-compats/deepseek.ts +2 -2
  29. package/src/provider-compats/google.ts +10 -2
  30. package/src/provider-compats/meta.ts +2 -2
  31. package/src/provider-compats/openai-reasoning.ts +7 -3
  32. package/src/provider-compats/openai.ts +2 -3
  33. package/src/provider-compats.test.ts +120 -25
  34. package/src/schema-compatibility.test.ts +22 -6
  35. package/src/schema-compatibility.ts +14 -7
  36. package/src/utils.test.ts +32 -6
  37. package/tsconfig.build.json +9 -0
  38. package/tsconfig.json +1 -1
  39. package/tsup.config.ts +17 -0
  40. package/dist/_tsup-dts-rollup.d.cts +0 -504
  41. package/dist/_tsup-dts-rollup.d.ts +0 -504
  42. package/dist/index.d.cts +0 -31
@@ -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(mockModels.anthropic);
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(mockModels.openai);
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(mockModels.anthropic);
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(mockModels.anthropic);
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(mockModels.openai);
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(mockModels.openai);
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(mockModels.openai);
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(mockModels.openaiReasoning);
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(mockModels.openaiReasoning);
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(mockModels.google);
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(mockModels.google);
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(mockModels.google);
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(mockModels.deepseek);
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(mockModels.openai);
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(mockModels.deepseek);
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(mockModels.deepseek);
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(mockModels.meta);
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(mockModels.meta);
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(mockModels.meta);
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(mockModels.anthropic),
275
- new OpenAISchemaCompatLayer(mockModels.openai),
276
- new OpenAIReasoningSchemaCompatLayer(mockModels.openaiReasoning),
277
- new GoogleSchemaCompatLayer(mockModels.google),
278
- new DeepSeekSchemaCompatLayer(mockModels.deepseek),
279
- new MetaSchemaCompatLayer(mockModels.meta),
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: LanguageModelV1) {
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(mockModel);
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()).toBe(mockModel);
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(mockModel);
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(mockModel);
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(
@@ -1,6 +1,6 @@
1
- import type { Schema, LanguageModelV1 } from 'ai';
1
+ import type { Schema } from 'ai';
2
2
  import type { JSONSchema7 } from 'json-schema';
3
- import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault } from 'zod';
3
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
4
4
  import type { ZodTypeAny } from 'zod';
5
5
  import type { Targets } from 'zod-to-json-schema';
6
6
  import { convertZodSchemaToAISDKSchema } from './utils';
@@ -29,6 +29,7 @@ export const ALL_ARRAY_CHECKS = ['min', 'max', 'length'] as const;
29
29
 
30
30
  export const isOptional = (v: ZodTypeAny): v is ZodOptional<any> => v instanceof ZodOptional;
31
31
  export const isObj = (v: ZodTypeAny): v is ZodObject<any, any, any> => v instanceof ZodObject;
32
+ export const isNull = (v: ZodTypeAny): v is ZodNull => v instanceof ZodNull;
32
33
  export const isArr = (v: ZodTypeAny): v is ZodArray<any, any> => v instanceof ZodArray;
33
34
  export const isUnion = (v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]> => v instanceof ZodUnion;
34
35
  export const isString = (v: ZodTypeAny): v is ZodString => v instanceof ZodString;
@@ -141,6 +142,12 @@ type DateConstraints = {
141
142
  dateFormat?: string;
142
143
  };
143
144
 
145
+ export type ModelInformation = {
146
+ modelId: string;
147
+ provider: string;
148
+ supportsStructuredOutputs: boolean;
149
+ };
150
+
144
151
  /**
145
152
  * Abstract base class for creating schema compatibility layers for different AI model providers.
146
153
  *
@@ -181,14 +188,14 @@ type DateConstraints = {
181
188
  * ```
182
189
  */
183
190
  export abstract class SchemaCompatLayer {
184
- private model: LanguageModelV1;
191
+ private model: ModelInformation;
185
192
 
186
193
  /**
187
194
  * Creates a new schema compatibility instance.
188
195
  *
189
196
  * @param model - The language model this compatibility layer applies to
190
197
  */
191
- constructor(model: LanguageModelV1) {
198
+ constructor(model: ModelInformation) {
192
199
  this.model = model;
193
200
  }
194
201
 
@@ -197,7 +204,7 @@ export abstract class SchemaCompatLayer {
197
204
  *
198
205
  * @returns The language model instance
199
206
  */
200
- getModel(): LanguageModelV1 {
207
+ getModel(): ModelInformation {
201
208
  return this.model;
202
209
  }
203
210
 
@@ -299,8 +306,8 @@ export abstract class SchemaCompatLayer {
299
306
  value: z.ZodTypeAny,
300
307
  throwOnTypes: readonly UnsupportedZodType[] = UNSUPPORTED_ZOD_TYPES,
301
308
  ): ShapeValue<T> {
302
- if (throwOnTypes.includes(value._def.typeName as UnsupportedZodType)) {
303
- throw new Error(`${this.model.modelId} does not support zod type: ${value._def.typeName}`);
309
+ if (throwOnTypes.includes(value._def?.typeName as UnsupportedZodType)) {
310
+ throw new Error(`${this.model.modelId} does not support zod type: ${value._def?.typeName}`);
304
311
  }
305
312
  return value as ShapeValue<T>;
306
313
  }
package/src/utils.test.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { jsonSchema } from 'ai';
2
- import type { LanguageModelV1, Schema } from 'ai';
2
+ import type { Schema } from 'ai';
3
3
  import { MockLanguageModelV1 } from 'ai/test';
4
4
  import { describe, it, expect, beforeEach, vi } from 'vitest';
5
5
  import { z } from 'zod';
6
+ import type { ModelInformation } from './schema-compatibility';
6
7
  import { SchemaCompatLayer } from './schema-compatibility';
7
8
  import { convertZodSchemaToAISDKSchema, convertSchemaToZod, applyCompatLayer } from './utils';
8
9
 
@@ -13,7 +14,7 @@ const mockModel = new MockLanguageModelV1({
13
14
 
14
15
  class MockSchemaCompatibility extends SchemaCompatLayer {
15
16
  constructor(
16
- model: LanguageModelV1,
17
+ model: ModelInformation,
17
18
  private shouldApplyValue: boolean = true,
18
19
  ) {
19
20
  super(model);
@@ -191,7 +192,11 @@ describe('Builder Functions', () => {
191
192
  let mockCompatibility: MockSchemaCompatibility;
192
193
 
193
194
  beforeEach(() => {
194
- mockCompatibility = new MockSchemaCompatibility(mockModel);
195
+ mockCompatibility = new MockSchemaCompatibility({
196
+ modelId: mockModel.modelId,
197
+ supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
198
+ provider: mockModel.provider,
199
+ });
195
200
  });
196
201
 
197
202
  it('should process Zod object schema with compatibility', () => {
@@ -257,7 +262,14 @@ describe('Builder Functions', () => {
257
262
  });
258
263
 
259
264
  it('should return fallback when no compatibility applies', () => {
260
- const nonApplyingCompatibility = new MockSchemaCompatibility(mockModel, false);
265
+ const nonApplyingCompatibility = new MockSchemaCompatibility(
266
+ {
267
+ modelId: mockModel.modelId,
268
+ supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
269
+ provider: mockModel.provider,
270
+ },
271
+ false,
272
+ );
261
273
  const zodSchema = z.object({
262
274
  name: z.string(),
263
275
  });
@@ -303,8 +315,22 @@ describe('Builder Functions', () => {
303
315
  });
304
316
 
305
317
  it('should handle complex schema with multiple compatLayers', () => {
306
- const compat1 = new MockSchemaCompatibility(mockModel, false);
307
- const compat2 = new MockSchemaCompatibility(mockModel, true);
318
+ const compat1 = new MockSchemaCompatibility(
319
+ {
320
+ modelId: mockModel.modelId,
321
+ supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? true,
322
+ provider: mockModel.provider,
323
+ },
324
+ false,
325
+ );
326
+ const compat2 = new MockSchemaCompatibility(
327
+ {
328
+ modelId: mockModel.modelId,
329
+ supportsStructuredOutputs: mockModel.supportsStructuredOutputs ?? false,
330
+ provider: mockModel.provider,
331
+ },
332
+ true,
333
+ );
308
334
 
309
335
  vi.spyOn(compat1, 'processZodType');
310
336
  vi.spyOn(compat2, 'processZodType');
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
+
4
+ export default defineConfig({
5
+ entry: ['src/index.ts'],
6
+ format: ['esm', 'cjs'],
7
+ clean: true,
8
+ dts: false,
9
+ splitting: true,
10
+ treeshake: {
11
+ preset: 'smallest',
12
+ },
13
+ sourcemap: true,
14
+ onSuccess: async () => {
15
+ await generateTypes(process.cwd());
16
+ },
17
+ });