Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
chore(ts/e2e): refactored json-schema-to-zod e2e tests into unified ts/e2e-tests location
jkomynoa815c73084bb
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b9e12da8e..f78f0615c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -390,6 +390,35 @@ importers:specifier: workspace:*version: link:../../../_utils+ ts/e2e-tests/runtimes/node/json-schema-to-zod-v3:+ dependencies:+ '@composio/json-schema-to-zod':+ specifier: workspace:*+ version: link:../../../../packages/json-schema-to-zod+ zod:+ specifier: 3.25.76+ version: 3.25.76+ zod-to-json-schema:+ specifier: ^3.25.1+ version: 3.25.1([email protected])+ devDependencies:+ '@e2e-tests/utils':+ specifier: workspace:*+ version: link:../../../_utils++ ts/e2e-tests/runtimes/node/json-schema-to-zod-v4:+ dependencies:+ '@composio/json-schema-to-zod':+ specifier: workspace:*+ version: link:../../../../packages/json-schema-to-zod+ zod:+ specifier: ^4.1.0+ version: 4.3.6+ devDependencies:+ '@e2e-tests/utils':+ specifier: workspace:*+ version: link:../../../_utils+ts/e2e-tests/runtimes/node/openai-zod4-compat:devDependencies:'@e2e-tests/utils':@@ -1149,35 +1178,6 @@ importers:specifier: 'catalog:'version: 4.3.6- ts/packages/json-schema-to-zod/test/e2e/zod-v3:- dependencies:- '@composio/json-schema-to-zod':- specifier: workspace:*- version: link:../../..- zod:- specifier: 3.25.76- version: 3.25.76- zod-to-json-schema:- specifier: 'catalog:'- version: 3.25.1([email protected])- devDependencies:- vitest:- specifier: 'catalog:'- version: 3.2.4(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected])-- ts/packages/json-schema-to-zod/test/e2e/zod-v4:- dependencies:- '@composio/json-schema-to-zod':- specifier: workspace:*- version: link:../../..- zod:- specifier: ^4.1.0- version: 4.3.6- devDependencies:- vitest:- specifier: 'catalog:'- version: 3.2.4(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected])-ts/packages/providers/anthropic:dependencies:'@anthropic-ai/sdk':@@ -10232,7 +10232,7 @@ snapshots:'@openrouter/[email protected]':dependencies:- zod: 4.3.6+ zod: 3.25.76'@opentelemetry/[email protected]':dependencies:diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex bb3cbedf0..2de781855 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -6,7 +6,6 @@ packages:- ts/packages/cli- ts/packages/core- ts/packages/json-schema-to-zod- - ts/packages/json-schema-to-zod/test/e2e/*- ts/packages/providers/*- ts/packages/ts-builders- ts/packages/wrappers/*diff --git a/ts/e2e-tests/README.md b/ts/e2e-tests/README.mdindex 3f2bfedbf..24ca2a602 100644--- a/ts/e2e-tests/README.md+++ b/ts/e2e-tests/README.md@@ -25,6 +25,8 @@ ts/e2e-tests/├── node/ # Node.js runtime tests│ ├── cjs-basic/ # CommonJS compatibility tests│ ├── esm-basic/ # ESM compatibility tests+ │ ├── json-schema-to-zod-v3/ # @composio/json-schema-to-zod + Zod v3 tests+ │ ├── json-schema-to-zod-v4/ # @composio/json-schema-to-zod + Zod v4 tests│ ├── openai-zod4-compat/ # OpenAI + Zod v4 compatibility tests│ └── typescript-mjs-import-nodenext/ # TypeScript moduleResolution: nodenext tests└── cloudflare/ # Cloudflare runtime testsdiff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/README.md b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/README.mdnew file mode 100644index 000000000..c928e9c47--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/README.md@@ -0,0 +1,30 @@+# json-schema-to-zod + Zod v3 Compatibility Test++Verifies that `@composio/json-schema-to-zod` works correctly with `[email protected]`.++## Why This Exists++The `@composio/json-schema-to-zod` package must support both Zod v3 and v4. This suite ensures:++- JSON Schema to Zod conversion works with Zod v3+- All schema types (string, object, array, anyOf) convert correctly+- Round-trip conversion (JSON Schema -> Zod -> JSON Schema) preserves semantics+- `additionalProperties` handling works correctly++## What It Tests++| Test | Description |+| --------------------- | ---------------------------------------------------------------- |+| Basic string schema | Converts `{ type: 'string' }` and validates |+| Object schema | Required fields, nested properties, validation constraints |+| Array schema | Typed array items with validation |+| Email format | Format validation for email strings |+| Nested schemas | Complex nested objects and arrays |+| anyOf schemas | Union type conversion |+| Round-trip conversion | JSON Schema -> Zod -> JSON Schema preserves `additionalProperties` |++## Running++```bash+pnpm test:e2e+```diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/e2e.test.ts b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/e2e.test.tsnew file mode 100644index 000000000..7a8cd9628--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/e2e.test.ts@@ -0,0 +1,264 @@+/**+ * @composio/json-schema-to-zod + Zod v3 e2e test+ *+ * Verifies that @composio/json-schema-to-zod works correctly with [email protected],+ * including basic schema conversion and round-trip tests with zod-to-json-schema.+ */++import { jsonSchemaToZod, type JsonSchema } from '@composio/json-schema-to-zod';+import { describe, it, expect } from 'bun:test';+import zodToJsonSchema from 'zod-to-json-schema';++describe('json-schema-to-zod with Zod v3', () => {+ describe('Basic functionality', () => {+ it('converts basic string schema', () => {+ const schema: JsonSchema = { type: 'string' };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('hello')).toBe('hello');+ expect(() => zodSchema.parse(123)).toThrow();+ });++ it('converts object schema with validation', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ age: { type: 'number', minimum: 0 },+ },+ required: ['name'],+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });+ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(() => zodSchema.parse({ age: 30 })).toThrow();+ });++ it('converts array schema', () => {+ const schema: JsonSchema = {+ type: 'array',+ items: { type: 'string' },+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse(['one', 'two', 'three'])).toEqual(['one', 'two', 'three']);+ expect(() => zodSchema.parse(['one', 2])).toThrow();+ });++ it('validates email format', () => {+ const schema: JsonSchema = {+ type: 'string',+ format: 'email',+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('[email protected]')).toBe('[email protected]');+ expect(() => zodSchema.parse('invalid-email')).toThrow();+ });++ it('handles complex nested schemas', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ user: {+ type: 'object',+ properties: {+ name: { type: 'string' },+ contacts: {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ type: { type: 'string' },+ value: { type: 'string' },+ },+ required: ['type', 'value'],+ },+ },+ },+ required: ['name'],+ },+ },+ required: ['user'],+ };+ const zodSchema = jsonSchemaToZod(schema);++ const validData = {+ user: {+ name: 'Jane Doe',+ contacts: [+ { type: 'email', value: '[email protected]' },+ { type: 'phone', value: '555-1234' },+ ],+ },+ };+ expect(zodSchema.parse(validData)).toEqual(validData);+ });++ it('handles anyOf schemas', () => {+ const schema: JsonSchema = {+ anyOf: [{ type: 'string' }, { type: 'number' }],+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('hello')).toBe('hello');+ expect(zodSchema.parse(42)).toBe(42);+ expect(() => zodSchema.parse(true)).toThrow();+ });+ });++ describe('Round-trip conversion', () => {+ it('preserves additionalProperties: true for empty objects', () => {+ const schema: JsonSchema = {+ type: 'object',+ additionalProperties: true,+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ expect(convertedBack.additionalProperties).toBe(true);+ expect(convertedBack.type).toBe('object');++ expect(zodSchema.parse({})).toEqual({});+ expect(zodSchema.parse({ any: 'value', number: 123 })).toEqual({ any: 'value', number: 123 });+ });++ it('preserves additionalProperties: true for objects with properties', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ age: { type: 'number' },+ },+ required: ['name'],+ additionalProperties: true,+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ expect(convertedBack.additionalProperties).toBe(true);+ expect(convertedBack.properties).toBeDefined();+ expect(convertedBack.required).toEqual(['name']);++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(zodSchema.parse({ name: 'John', age: 30, extra: 'field' })).toEqual({+ name: 'John',+ age: 30,+ extra: 'field',+ });+ });++ it('preserves additionalProperties: false for empty objects', () => {+ const schema: JsonSchema = {+ type: 'object',+ additionalProperties: false,+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ // zod-to-json-schema may convert z.object({}).strict() to { not: {} }+ // which is semantically equivalent to additionalProperties: false+ const additionalPropsValid =+ convertedBack.additionalProperties === false ||+ (convertedBack.not && typeof convertedBack.not === 'object');+ expect(additionalPropsValid).toBe(true);+ expect(convertedBack.type).toBe('object');++ expect(zodSchema.parse({})).toEqual({});+ expect(() => zodSchema.parse({ extra: 'field' })).toThrow();+ });++ it('preserves additionalProperties: false for objects with properties', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: false,+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ expect(convertedBack.additionalProperties).toBe(false);+ expect(convertedBack.properties).toBeDefined();++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();+ });++ it('handles additionalProperties with type schema', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: { type: 'number' },+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ expect(convertedBack.additionalProperties).toEqual({ type: 'number' });+ expect(convertedBack.properties).toBeDefined();++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });+ expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();+ });++ it('handles nested objects with different additionalProperties settings', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ strictChild: {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: false,+ },+ flexibleChild: {+ type: 'object',+ properties: {+ age: { type: 'number' },+ },+ additionalProperties: true,+ },+ },+ additionalProperties: { type: 'string' },+ };++ const zodSchema = jsonSchemaToZod(schema);+ const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' });++ expect(convertedBack.additionalProperties).toEqual({ type: 'string' });+ expect((convertedBack.properties as Record<string, unknown>)?.strictChild).toBeDefined();+ expect((convertedBack.properties as Record<string, unknown>)?.flexibleChild).toBeDefined();++ const validData = {+ strictChild: { name: 'John' },+ flexibleChild: { age: 30, extra: 'allowed' },+ extraString: 'this should be a string',+ };+ expect(zodSchema.parse(validData)).toEqual(validData);++ // Test invalid cases+ expect(() =>+ zodSchema.parse({+ strictChild: { name: 'John', extra: 'not allowed' },+ })+ ).toThrow();++ expect(() =>+ zodSchema.parse({+ extraNumber: 123, // should be string according to additionalProperties+ })+ ).toThrow();+ });+ });+});diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/package.json b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/package.jsonnew file mode 100644index 000000000..0c492078d--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/package.json@@ -0,0 +1,19 @@+{+ "name": "@e2e-tests/node-json-schema-to-zod-v3",+ "version": "0.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "test:e2e": "bun test e2e.test.ts",+ "test:e2e:node": "bun test e2e.test.ts"+ },+ "dependencies": {+ "@composio/json-schema-to-zod": "workspace:*",+ "zod": "3.25.76",+ "zod-to-json-schema": "^3.25.1"+ },+ "devDependencies": {+ "@e2e-tests/utils": "workspace:*"+ }+}diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/tsconfig.json b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/tsconfig.jsonnew file mode 100644index 000000000..3eeaa418d--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v3/tsconfig.json@@ -0,0 +1,12 @@+{+ "$schema": "https://json.schemastore.org/tsconfig",+ "compilerOptions": {+ "target": "es2022",+ "module": "esnext",+ "moduleResolution": "bundler",+ "strict": true,+ "skipLibCheck": true,+ "noEmit": true+ },+ "include": ["e2e.test.ts"]+}diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/README.md b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/README.mdnew file mode 100644index 000000000..4fa0dcb66--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/README.md@@ -0,0 +1,32 @@+# json-schema-to-zod + Zod v4 Compatibility Test++Verifies that `@composio/json-schema-to-zod` works correctly with `zod@4`.++## Why This Exists++The `@composio/json-schema-to-zod` package must support both Zod v3 and v4. This suite ensures:++- JSON Schema to Zod conversion works with Zod v4+- All schema types (string, object, array, anyOf) convert correctly+- `additionalProperties` handling works correctly with Zod v4's API+- Complex nested structures and union types parse correctly++## What It Tests++| Test | Description |+| ---------------------- | ---------------------------------------------------------- |+| Basic string schema | Converts `{ type: 'string' }` and validates |+| Object schema | Required fields, nested properties, validation constraints |+| Array schema | Typed array items with validation |+| Email format | Format validation for email strings |+| Nested schemas | Complex nested objects and arrays |+| anyOf schemas | Union type conversion |+| additionalProperties | Strict, passthrough, and typed catchall modes |+| Complex nested arrays | Arrays of objects with nested arrays |+| Union with constraints | anyOf with minLength, minimum, and required fields |++## Running++```bash+pnpm test:e2e+```diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/e2e.test.ts b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/e2e.test.tsnew file mode 100644index 000000000..e97886506--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/e2e.test.ts@@ -0,0 +1,265 @@+/**+ * @composio/json-schema-to-zod + Zod v4 e2e test+ *+ * Verifies that @composio/json-schema-to-zod works correctly with zod@4,+ * including basic schema conversion and parsing behavior tests.+ */++import { jsonSchemaToZod, type JsonSchema } from '@composio/json-schema-to-zod';+import { describe, it, expect } from 'bun:test';++describe('json-schema-to-zod with Zod v4', () => {+ describe('Basic functionality', () => {+ it('converts basic string schema', () => {+ const schema: JsonSchema = { type: 'string' };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('hello')).toBe('hello');+ expect(() => zodSchema.parse(123)).toThrow();+ });++ it('converts object schema with validation', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ age: { type: 'number', minimum: 0 },+ },+ required: ['name'],+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });+ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(() => zodSchema.parse({ age: 30 })).toThrow();+ });++ it('converts array schema', () => {+ const schema: JsonSchema = {+ type: 'array',+ items: { type: 'string' },+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse(['one', 'two', 'three'])).toEqual(['one', 'two', 'three']);+ expect(() => zodSchema.parse(['one', 2])).toThrow();+ });++ it('validates email format', () => {+ const schema: JsonSchema = {+ type: 'string',+ format: 'email',+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('[email protected]')).toBe('[email protected]');+ expect(() => zodSchema.parse('invalid-email')).toThrow();+ });++ it('handles complex nested schemas', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ user: {+ type: 'object',+ properties: {+ name: { type: 'string' },+ contacts: {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ type: { type: 'string' },+ value: { type: 'string' },+ },+ required: ['type', 'value'],+ },+ },+ },+ required: ['name'],+ },+ },+ required: ['user'],+ };+ const zodSchema = jsonSchemaToZod(schema);++ const validData = {+ user: {+ name: 'Jane Doe',+ contacts: [+ { type: 'email', value: '[email protected]' },+ { type: 'phone', value: '555-1234' },+ ],+ },+ };+ expect(zodSchema.parse(validData)).toEqual(validData);+ });++ it('handles anyOf schemas', () => {+ const schema: JsonSchema = {+ anyOf: [{ type: 'string' }, { type: 'number' }],+ };+ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('hello')).toBe('hello');+ expect(zodSchema.parse(42)).toBe(42);+ expect(() => zodSchema.parse(true)).toThrow();+ });+ });++ describe('Parsing behavior', () => {+ it('converts basic schemas and verifies parsing behavior', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ age: { type: 'number' },+ },+ required: ['name'],+ additionalProperties: false,+ };++ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });+ expect(() => zodSchema.parse({ age: 30 })).toThrow();+ expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();+ });++ it('handles additionalProperties: true', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: true,+ };++ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(zodSchema.parse({ name: 'John', extra: 'allowed', another: 123 })).toEqual({+ name: 'John',+ extra: 'allowed',+ another: 123,+ });+ });++ it('handles additionalProperties with type constraint', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: { type: 'number' },+ };++ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });+ expect(zodSchema.parse({ name: 'John', age: 30, count: 5 })).toEqual({+ name: 'John',+ age: 30,+ count: 5,+ });+ expect(() => zodSchema.parse({ name: 'John', extra: 'string' })).toThrow();+ });++ it('handles nested objects with different additionalProperties settings', () => {+ const schema: JsonSchema = {+ type: 'object',+ properties: {+ strictChild: {+ type: 'object',+ properties: {+ name: { type: 'string' },+ },+ additionalProperties: false,+ },+ flexibleChild: {+ type: 'object',+ properties: {+ age: { type: 'number' },+ },+ additionalProperties: true,+ },+ },+ additionalProperties: { type: 'string' },+ };++ const zodSchema = jsonSchemaToZod(schema);++ const validData = {+ strictChild: { name: 'John' },+ flexibleChild: { age: 30, extra: 'allowed' },+ extraString: 'this should be a string',+ };+ expect(zodSchema.parse(validData)).toEqual(validData);++ expect(() =>+ zodSchema.parse({+ strictChild: { name: 'John', extra: 'not allowed' },+ })+ ).toThrow();++ expect(() =>+ zodSchema.parse({+ extraNumber: 123,+ })+ ).toThrow();+ });++ it('handles complex nested arrays', () => {+ const schema: JsonSchema = {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ id: { type: 'number' },+ tags: {+ type: 'array',+ items: { type: 'string' },+ },+ },+ required: ['id'],+ },+ };++ const zodSchema = jsonSchemaToZod(schema);++ const validData = [{ id: 1, tags: ['a', 'b'] }, { id: 2, tags: ['c'] }, { id: 3 }];+ expect(zodSchema.parse(validData)).toEqual(validData);++ expect(() =>+ zodSchema.parse([{ tags: ['a', 'b'] }])+ ).toThrow();+ });++ it('handles union types with anyOf', () => {+ const schema: JsonSchema = {+ anyOf: [+ { type: 'string', minLength: 3 },+ { type: 'number', minimum: 0 },+ {+ type: 'object',+ properties: {+ type: { type: 'string' },+ },+ required: ['type'],+ },+ ],+ };++ const zodSchema = jsonSchemaToZod(schema);++ expect(zodSchema.parse('hello')).toBe('hello');+ expect(zodSchema.parse(42)).toBe(42);+ expect(zodSchema.parse({ type: 'custom' })).toEqual({ type: 'custom' });++ expect(() => zodSchema.parse('ab')).toThrow();+ expect(() => zodSchema.parse(-1)).toThrow();+ expect(() => zodSchema.parse({ foo: 'bar' })).toThrow();+ });+ });+});diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/package.json b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/package.jsonnew file mode 100644index 000000000..45c90fc8f--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/package.json@@ -0,0 +1,18 @@+{+ "name": "@e2e-tests/node-json-schema-to-zod-v4",+ "version": "0.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "test:e2e": "bun test e2e.test.ts",+ "test:e2e:node": "bun test e2e.test.ts"+ },+ "dependencies": {+ "@composio/json-schema-to-zod": "workspace:*",+ "zod": "^4.1.0"+ },+ "devDependencies": {+ "@e2e-tests/utils": "workspace:*"+ }+}diff --git a/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/tsconfig.json b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/tsconfig.jsonnew file mode 100644index 000000000..3eeaa418d--- /dev/null+++ b/ts/e2e-tests/runtimes/node/json-schema-to-zod-v4/tsconfig.json@@ -0,0 +1,12 @@+{+ "$schema": "https://json.schemastore.org/tsconfig",+ "compilerOptions": {+ "target": "es2022",+ "module": "esnext",+ "moduleResolution": "bundler",+ "strict": true,+ "skipLibCheck": true,+ "noEmit": true+ },+ "include": ["e2e.test.ts"]+}diff --git a/ts/packages/json-schema-to-zod/test/e2e/.gitignore b/ts/packages/json-schema-to-zod/test/e2e/.gitignoredeleted file mode 100644index c2658d7d1..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/.gitignore+++ /dev/null@@ -1 +0,0 @@-node_modules/diff --git a/ts/packages/json-schema-to-zod/test/e2e/README.md b/ts/packages/json-schema-to-zod/test/e2e/README.mddeleted file mode 100644index ce36ffe76..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/README.md+++ /dev/null@@ -1,8 +0,0 @@-# E2E Tests--End-to-end tests that verify `@composio/json-schema-to-zod` works correctly with different versions of zod.--## Structure--- `zod-v3/` - Tests with zod 3.25.76 and `zod-to-json-schema` for round-trip conversion-- `zod-v4/` - Tests with zod ^4.0.0 and native `z.toJSONSchema()` for validationdiff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/basic.test.ts b/ts/packages/json-schema-to-zod/test/e2e/zod-v3/basic.test.tsdeleted file mode 100644index f1ee85c8b..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/basic.test.ts+++ /dev/null@@ -1,102 +0,0 @@-import { describe, it, expect } from 'vitest';-import { jsonSchemaToZod } from '@composio/json-schema-to-zod';-import type { JsonSchema } from '@composio/json-schema-to-zod';--describe('E2E with Zod v3 - Basic functionality', () => {- it('should convert basic string schema', () => {- const schema: JsonSchema = { type: 'string' };- const zodSchema = jsonSchemaToZod(schema);-- // Note: instanceof check doesn't work reliably across zod versions- expect(zodSchema.parse('hello')).toBe('hello');- expect(() => zodSchema.parse(123)).toThrow();- });-- it('should convert object schema with validation', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- age: { type: 'number', minimum: 0 },- },- required: ['name'],- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(() => zodSchema.parse({ age: 30 })).toThrow();- });-- it('should convert array schema', () => {- const schema: JsonSchema = {- type: 'array',- items: { type: 'string' },- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse(['one', 'two', 'three'])).toEqual(['one', 'two', 'three']);- expect(() => zodSchema.parse(['one', 2])).toThrow();- });-- it('should validate email format', () => {- const schema: JsonSchema = {- type: 'string',- format: 'email',- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse('[email protected]')).toBe('[email protected]');- expect(() => zodSchema.parse('invalid-email')).toThrow();- });-- it('should handle complex nested schemas', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- user: {- type: 'object',- properties: {- name: { type: 'string' },- contacts: {- type: 'array',- items: {- type: 'object',- properties: {- type: { type: 'string' },- value: { type: 'string' },- },- required: ['type', 'value'],- },- },- },- required: ['name'],- },- },- required: ['user'],- };- const zodSchema = jsonSchemaToZod(schema);-- const validData = {- user: {- name: 'Jane Doe',- contacts: [- { type: 'email', value: '[email protected]' },- { type: 'phone', value: '555-1234' },- ],- },- };- expect(zodSchema.parse(validData)).toEqual(validData);- });-- it('should handle anyOf schemas', () => {- const schema: JsonSchema = {- anyOf: [{ type: 'string' }, { type: 'number' }],- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse('hello')).toBe('hello');- expect(zodSchema.parse(42)).toBe(42);- expect(() => zodSchema.parse(true)).toThrow();- });-});diff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/package.json b/ts/packages/json-schema-to-zod/test/e2e/zod-v3/package.jsondeleted file mode 100644index 539553f70..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/package.json+++ /dev/null@@ -1,17 +0,0 @@-{- "name": "@test-e2e/json-schema-to-zod-e2e-zod-v3",- "version": "1.0.0",- "private": true,- "type": "module",- "scripts": {- "test": "vitest run"- },- "dependencies": {- "@composio/json-schema-to-zod": "workspace:*",- "zod": "3.25.76",- "zod-to-json-schema": "catalog:"- },- "devDependencies": {- "vitest": "catalog:"- }-}diff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/round-trip.test.ts b/ts/packages/json-schema-to-zod/test/e2e/zod-v3/round-trip.test.tsdeleted file mode 100644index 7f85dfe25..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v3/round-trip.test.ts+++ /dev/null@@ -1,173 +0,0 @@-import { describe, it, expect } from 'vitest';-import { jsonSchemaToZod } from '@composio/json-schema-to-zod';-import zodToJsonSchema from 'zod-to-json-schema';-import type { JsonSchema } from '@composio/json-schema-to-zod';--describe('E2E with Zod v3 - Round-trip conversion', () => {- const testRoundTrip = (originalSchema: JsonSchema, expectedAdditionalProperties: any) => {- const zodSchema = jsonSchemaToZod(originalSchema);- const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' }) as any;-- const { $schema, ...cleanConverted } = convertedBack;-- return {- zodSchema,- convertedBack: cleanConverted,- additionalPropertiesMatch:- convertedBack.additionalProperties === expectedAdditionalProperties,- };- };-- it('should preserve additionalProperties: true for empty objects', () => {- const schema: JsonSchema = {- type: 'object',- additionalProperties: true,- };-- const { zodSchema, convertedBack, additionalPropertiesMatch } = testRoundTrip(schema, true);-- expect(additionalPropertiesMatch).toBe(true);- expect(convertedBack.additionalProperties).toBe(true);- expect(convertedBack.type).toBe('object');- expect(convertedBack.properties).toEqual({});-- expect(zodSchema.parse({})).toEqual({});- expect(zodSchema.parse({ any: 'value', number: 123 })).toEqual({ any: 'value', number: 123 });- });-- it('should preserve additionalProperties: true for objects with properties', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- age: { type: 'number' },- },- required: ['name'],- additionalProperties: true,- };-- const { zodSchema, convertedBack, additionalPropertiesMatch } = testRoundTrip(schema, true);-- expect(additionalPropertiesMatch).toBe(true);- expect(convertedBack.additionalProperties).toBe(true);- expect(convertedBack.properties).toBeDefined();- expect(convertedBack.required).toEqual(['name']);-- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(zodSchema.parse({ name: 'John', age: 30, extra: 'field' })).toEqual({- name: 'John',- age: 30,- extra: 'field',- });- });-- it('should preserve additionalProperties: false for empty objects', () => {- const schema: JsonSchema = {- type: 'object',- additionalProperties: false,- };-- const zodSchema = jsonSchemaToZod(schema);- const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' }) as any;-- // zod-to-json-schema may convert z.object({}).strict() to { not: {} }- // which is semantically equivalent to additionalProperties: false- expect(- convertedBack.additionalProperties === false ||- (convertedBack.not && typeof convertedBack.not === 'object')- ).toBe(true);- expect(convertedBack.type).toBe('object');-- expect(zodSchema.parse({})).toEqual({});- expect(() => zodSchema.parse({ extra: 'field' })).toThrow();- });-- it('should preserve additionalProperties: false for objects with properties', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: false,- };-- const zodSchema = jsonSchemaToZod(schema);- const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' }) as any;-- expect(convertedBack.additionalProperties).toBe(false);- expect(convertedBack.properties).toBeDefined();-- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();- });-- it('should handle additionalProperties with type schema', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: { type: 'number' },- };-- const zodSchema = jsonSchemaToZod(schema);- const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' }) as any;-- expect(convertedBack.additionalProperties).toEqual({ type: 'number' });- expect(convertedBack.properties).toBeDefined();-- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });- expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();- });-- it('should handle nested objects with different additionalProperties settings', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- strictChild: {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: false,- },- flexibleChild: {- type: 'object',- properties: {- age: { type: 'number' },- },- additionalProperties: true,- },- },- additionalProperties: { type: 'string' },- };-- const zodSchema = jsonSchemaToZod(schema);- const convertedBack = zodToJsonSchema(zodSchema, { target: 'jsonSchema7' }) as any;-- expect(convertedBack.additionalProperties).toEqual({ type: 'string' });- expect(convertedBack.properties?.strictChild).toBeDefined();- expect(convertedBack.properties?.flexibleChild).toBeDefined();-- const validData = {- strictChild: { name: 'John' },- flexibleChild: { age: 30, extra: 'allowed' },- extraString: 'this should be a string',- };- expect(zodSchema.parse(validData)).toEqual(validData);-- // Test invalid cases- expect(() =>- zodSchema.parse({- strictChild: { name: 'John', extra: 'not allowed' },- })- ).toThrow();-- expect(() =>- zodSchema.parse({- extraNumber: 123, // should be string according to additionalProperties- })- ).toThrow();- });-});diff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/basic.test.ts b/ts/packages/json-schema-to-zod/test/e2e/zod-v4/basic.test.tsdeleted file mode 100644index 476bd4a75..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/basic.test.ts+++ /dev/null@@ -1,102 +0,0 @@-import { describe, it, expect } from 'vitest';-import { jsonSchemaToZod } from '@composio/json-schema-to-zod';-import type { JsonSchema } from '@composio/json-schema-to-zod';--describe('E2E with Zod v4 - Basic functionality', () => {- it('should convert basic string schema', () => {- const schema: JsonSchema = { type: 'string' };- const zodSchema = jsonSchemaToZod(schema);-- // Note: instanceof check doesn't work reliably across zod versions- expect(zodSchema.parse('hello')).toBe('hello');- expect(() => zodSchema.parse(123)).toThrow();- });-- it('should convert object schema with validation', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- age: { type: 'number', minimum: 0 },- },- required: ['name'],- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(() => zodSchema.parse({ age: 30 })).toThrow();- });-- it('should convert array schema', () => {- const schema: JsonSchema = {- type: 'array',- items: { type: 'string' },- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse(['one', 'two', 'three'])).toEqual(['one', 'two', 'three']);- expect(() => zodSchema.parse(['one', 2])).toThrow();- });-- it('should validate email format', () => {- const schema: JsonSchema = {- type: 'string',- format: 'email',- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse('[email protected]')).toBe('[email protected]');- expect(() => zodSchema.parse('invalid-email')).toThrow();- });-- it('should handle complex nested schemas', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- user: {- type: 'object',- properties: {- name: { type: 'string' },- contacts: {- type: 'array',- items: {- type: 'object',- properties: {- type: { type: 'string' },- value: { type: 'string' },- },- required: ['type', 'value'],- },- },- },- required: ['name'],- },- },- required: ['user'],- };- const zodSchema = jsonSchemaToZod(schema);-- const validData = {- user: {- name: 'Jane Doe',- contacts: [- { type: 'email', value: '[email protected]' },- { type: 'phone', value: '555-1234' },- ],- },- };- expect(zodSchema.parse(validData)).toEqual(validData);- });-- it('should handle anyOf schemas', () => {- const schema: JsonSchema = {- anyOf: [{ type: 'string' }, { type: 'number' }],- };- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse('hello')).toBe('hello');- expect(zodSchema.parse(42)).toBe(42);- expect(() => zodSchema.parse(true)).toThrow();- });-});diff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/package.json b/ts/packages/json-schema-to-zod/test/e2e/zod-v4/package.jsondeleted file mode 100644index 047b6fcd0..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/package.json+++ /dev/null@@ -1,16 +0,0 @@-{- "name": "@test-e2e/json-schema-to-zod-e2e-zod-v4",- "version": "1.0.0",- "private": true,- "type": "module",- "scripts": {- "test": "vitest run"- },- "dependencies": {- "@composio/json-schema-to-zod": "workspace:*",- "zod": "^4.1.0"- },- "devDependencies": {- "vitest": "catalog:"- }-}diff --git a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/round-trip.test.ts b/ts/packages/json-schema-to-zod/test/e2e/zod-v4/round-trip.test.tsdeleted file mode 100644index 0aeb40323..000000000--- a/ts/packages/json-schema-to-zod/test/e2e/zod-v4/round-trip.test.ts+++ /dev/null@@ -1,166 +0,0 @@-import { describe, it, expect } from 'vitest';-import { jsonSchemaToZod } from '@composio/json-schema-to-zod';-import type { JsonSchema } from '@composio/json-schema-to-zod';--describe('E2E with Zod v4 - Round-trip conversion with native toJSONSchema', () => {- it('should convert basic schemas and verify parsing behavior', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- age: { type: 'number' },- },- required: ['name'],- additionalProperties: false,- };-- const zodSchema = jsonSchemaToZod(schema);-- // Test parsing behavior- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(zodSchema.parse({ name: 'John', age: 30 })).toEqual({ name: 'John', age: 30 });- expect(() => zodSchema.parse({ age: 30 })).toThrow();- expect(() => zodSchema.parse({ name: 'John', extra: 'field' })).toThrow();- });-- it('should handle additionalProperties: true', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: true,- };-- const zodSchema = jsonSchemaToZod(schema);-- // Test parsing behavior- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(zodSchema.parse({ name: 'John', extra: 'allowed', another: 123 })).toEqual({- name: 'John',- extra: 'allowed',- another: 123,- });- });-- it('should handle additionalProperties with type constraint', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: { type: 'number' },- };-- const zodSchema = jsonSchemaToZod(schema);-- // Test parsing behavior- expect(zodSchema.parse({ name: 'John' })).toEqual({ name: 'John' });- expect(zodSchema.parse({ name: 'John', age: 30, count: 5 })).toEqual({- name: 'John',- age: 30,- count: 5,- });- expect(() => zodSchema.parse({ name: 'John', extra: 'string' })).toThrow();- });-- it('should handle nested objects with different additionalProperties settings', () => {- const schema: JsonSchema = {- type: 'object',- properties: {- strictChild: {- type: 'object',- properties: {- name: { type: 'string' },- },- additionalProperties: false,- },- flexibleChild: {- type: 'object',- properties: {- age: { type: 'number' },- },- additionalProperties: true,- },- },- additionalProperties: { type: 'string' },- };-- const zodSchema = jsonSchemaToZod(schema);-- // Test parsing behavior- const validData = {- strictChild: { name: 'John' },- flexibleChild: { age: 30, extra: 'allowed' },- extraString: 'this should be a string',- };- expect(zodSchema.parse(validData)).toEqual(validData);-- // Test invalid cases- expect(() =>- zodSchema.parse({- strictChild: { name: 'John', extra: 'not allowed' },- })- ).toThrow();-- expect(() =>- zodSchema.parse({- extraNumber: 123, // should be string according to additionalProperties- })- ).toThrow();- });-- it('should handle complex nested arrays', () => {- const schema: JsonSchema = {- type: 'array',- items: {- type: 'object',- properties: {- id: { type: 'number' },- tags: {- type: 'array',- items: { type: 'string' },- },- },- required: ['id'],- },- };-- const zodSchema = jsonSchemaToZod(schema);-- const validData = [{ id: 1, tags: ['a', 'b'] }, { id: 2, tags: ['c'] }, { id: 3 }];- expect(zodSchema.parse(validData)).toEqual(validData);-- expect(() =>- zodSchema.parse([- { tags: ['a', 'b'] }, // missing required id- ])- ).toThrow();- });-- it('should handle union types with anyOf', () => {- const schema: JsonSchema = {- anyOf: [- { type: 'string', minLength: 3 },- { type: 'number', minimum: 0 },- {- type: 'object',- properties: {- type: { type: 'string' },- },- required: ['type'],- },- ],- };-- const zodSchema = jsonSchemaToZod(schema);-- expect(zodSchema.parse('hello')).toBe('hello');- expect(zodSchema.parse(42)).toBe(42);- expect(zodSchema.parse({ type: 'custom' })).toEqual({ type: 'custom' });-- expect(() => zodSchema.parse('ab')).toThrow(); // too short- expect(() => zodSchema.parse(-1)).toThrow(); // negative- expect(() => zodSchema.parse({ foo: 'bar' })).toThrow(); // missing required type- });-});