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(framework): Specify zod-to-json-schema as a dependency #6741

Merged
merged 7 commits into from
Oct 23, 2024
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
1 change: 1 addition & 0 deletions packages/framework/src/types/discover.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type DiscoverStepOutput = {
export type DiscoverWorkflowOutput = {
workflowId: string;
execute: Execute<Record<string, unknown>, Record<string, unknown>>;
/** @deprecated use top-level properties instead */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should've been added already. It will be cleaned up soon.

options: WorkflowOptions<Schema, Schema>;
code: string;
steps: Array<DiscoverStepOutput>;
Expand Down
4 changes: 3 additions & 1 deletion packages/framework/src/validators/zod.validator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ZodSchema } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';

import type { FromSchema, FromSchemaUnvalidated, JsonSchema, Schema } from '../types/schema.types';
import type { ValidateResult, Validator } from '../types/validator.types';
Expand Down Expand Up @@ -30,6 +29,9 @@ export class ZodValidator implements Validator<ZodSchema> {

transformToJsonSchema(schema: ZodSchema): JsonSchema {
try {
// eslint-disable-next-line global-require
const { zodToJsonSchema } = require('zod-to-json-schema') as typeof import('zod-to-json-schema');

// @ts-expect-error - zod-to-json-schema is not using JSONSchema7
return zodToJsonSchema(schema);
} catch (error) {
Expand Down
Loading