{"_id":"@techery/zod-to-vertex-schema","_rev":"4-88f9320c0603241e7e861478ce59f6fa","name":"@techery/zod-to-vertex-schema","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@techery/zod-to-vertex-schema","version":"0.1.0","keywords":["zod","vertex-ai","gemini","schema","typescript"],"author":{"name":"Serge Zenchenko"},"license":"MIT","_id":"@techery/zod-to-vertex-schema@0.1.0","maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"homepage":"https://github.com/techery/zod-to-vertex-schema#readme","bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"dist":{"shasum":"7781a6c579024752952fa908ab6ae3bbad7c9b01","tarball":"https://registry.npmjs.org/@techery/zod-to-vertex-schema/-/zod-to-vertex-schema-0.1.0.tgz","fileCount":15,"integrity":"sha512-OWtDqqvynA49w4CncjGxef10fP9A7IcQsvLGQNy0obKx8b1eioZoqVrJRmdMEswItnhJPrJwwIScISPoX5JY1A==","signatures":[{"sig":"MEUCIBjCyp2ZQ39EBEmdlOMkdC9u9qjdMDLybECIGmkq8DCTAiEA/miy6COYu1hjMGBCmWIpz/eutytuqSLNCctTv4wY35M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32286},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"6c1ec58812017acdb35a617169d461a146a4f807","scripts":{"lint":"eslint src --ext .ts","test":"jest","build":"tsc","check":"npm run format:check && npm run lint && npm run test","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","prepare":"npm run build","lint:fix":"eslint src --ext .ts --fix","prebuild":"npm run clean","format:check":"prettier --check \"src/**/*.ts\"","prepublishOnly":"npm test && npm run build"},"_npmUser":{"name":"techery","email":"serge.z@techery.io"},"repository":{"url":"git+https://github.com/techery/zod-to-vertex-schema.git","type":"git"},"_npmVersion":"10.8.2","description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","directories":{},"_nodeVersion":"20.18.1","dependencies":{"zod":"^3.*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.57.1","ts-jest":"^29.2.5","prettier":"^3.4.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.5","@jest/globals":"^29.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-to-vertex-schema_0.1.0_1736774793863_0.9084850963774984","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@techery/zod-to-vertex-schema","version":"0.1.1","keywords":["zod","vertex-ai","gemini","schema","typescript"],"author":{"name":"Serge Zenchenko"},"license":"MIT","_id":"@techery/zod-to-vertex-schema@0.1.1","maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"homepage":"https://github.com/techery/zod-to-vertex-schema#readme","bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"dist":{"shasum":"6617364b0496a4827a4a2020005f3e92676c01e8","tarball":"https://registry.npmjs.org/@techery/zod-to-vertex-schema/-/zod-to-vertex-schema-0.1.1.tgz","fileCount":15,"integrity":"sha512-oIrb/aXkVfK0FpRZodLaVVGc3eUz86zB/Zwv8u0OHXD1VkVptMOEoS53esQ2zPtVqyH1gwJJ1RNoB7UAweSZQg==","signatures":[{"sig":"MEUCIEpYxiVLSt4lFsOxYlSq/8I4Rh7do5Xt/OgbtXNLw5zrAiEA9MZj++V17ap4TbD2fxkTMUexyWNsh7rpck2Mret0GOw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32142},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"0c43faa57a18addf6a48d9b786fcf7c93fccfa47","scripts":{"lint":"eslint src --ext .ts","test":"jest","build":"tsc","check":"npm run format:check && npm run lint && npm run test","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","prepare":"npm run build","lint:fix":"eslint src --ext .ts --fix","prebuild":"npm run clean","format:check":"prettier --check \"src/**/*.ts\"","prepublishOnly":"npm test && npm run build"},"_npmUser":{"name":"techery","email":"serge.z@techery.io"},"repository":{"url":"git+https://github.com/techery/zod-to-vertex-schema.git","type":"git"},"_npmVersion":"10.8.2","description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","directories":{},"_nodeVersion":"20.18.1","dependencies":{"zod":"^3.*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.57.1","ts-jest":"^29.2.5","prettier":"^3.4.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.5","@jest/globals":"^29.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-to-vertex-schema_0.1.1_1736774986761_0.858037039968959","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@techery/zod-to-vertex-schema","version":"0.1.2","keywords":["zod","vertex-ai","gemini","schema","typescript"],"author":{"name":"Serge Zenchenko"},"license":"MIT","_id":"@techery/zod-to-vertex-schema@0.1.2","maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"homepage":"https://github.com/techery/zod-to-vertex-schema#readme","bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"dist":{"shasum":"c06d4ff222d0857f065e81e89146e1e7b2a9955b","tarball":"https://registry.npmjs.org/@techery/zod-to-vertex-schema/-/zod-to-vertex-schema-0.1.2.tgz","fileCount":15,"integrity":"sha512-KEbtJDknfKYWQzJmpLg3NJPqeZUDSU1qYOtyKdSDBGX/1POBn6LMVF6hEQiMhZFakbIO47lxjQbL3+Bn4KwD+w==","signatures":[{"sig":"MEUCIQCCgVBIqfEstF889m9+m9ArDyXw5Y2AlR4/30IElQp8twIgWXDT1rb0tKPsys2I6oFILasV/mxBpEW25tsQMtQaoCg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32577},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"f6f710991f8d5b0c9efdf719759cd41006d8eeac","scripts":{"lint":"eslint src --ext .ts","test":"jest","build":"tsc","check":"npm run format:check && npm run lint && npm run test","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","prepare":"npm run build","lint:fix":"eslint src --ext .ts --fix","prebuild":"npm run clean","format:check":"prettier --check \"src/**/*.ts\"","prepublishOnly":"npm test && npm run build"},"_npmUser":{"name":"techery","email":"serge.z@techery.io"},"repository":{"url":"git+https://github.com/techery/zod-to-vertex-schema.git","type":"git"},"_npmVersion":"10.8.2","description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","directories":{},"_nodeVersion":"20.18.1","dependencies":{"zod":"^3.*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.57.1","ts-jest":"^29.2.5","prettier":"^3.4.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.5","@jest/globals":"^29.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-to-vertex-schema_0.1.2_1736776579946_0.45137718598497556","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@techery/zod-to-vertex-schema","version":"0.1.3","keywords":["zod","vertex-ai","gemini","schema","typescript"],"author":{"name":"Serge Zenchenko"},"license":"MIT","_id":"@techery/zod-to-vertex-schema@0.1.3","maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"homepage":"https://github.com/techery/zod-to-vertex-schema#readme","bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"dist":{"shasum":"961651b6de1d0cb3d4c141ff215ff3324b5db962","tarball":"https://registry.npmjs.org/@techery/zod-to-vertex-schema/-/zod-to-vertex-schema-0.1.3.tgz","fileCount":19,"integrity":"sha512-+IA2fnOCvDfJIsG+eh39HlOGgP6akvuQ6VO2FE1JOdKfXEUqoaJU0vslJQ54eya91NIKJL8ZJo8t1RM9KHE3/g==","signatures":[{"sig":"MEYCIQCGG4UkbE8sz3B2wA59m+J0mGhRvxHHXidcyH/wSz4CBAIhAJ0YbBM/qJT6tPvnAyX1WM3Ni86jI8GaoMzllgSJjMkb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45205},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"gitHead":"66bbaa5cf340ce0b0b6c87eb08283a461709fea9","scripts":{"lint":"eslint src --ext .ts","test":"jest","build":"tsc","check":"npm run format:check && npm run lint && npm run test","clean":"rm -rf dist","format":"prettier --write \"src/**/*.ts\"","prepare":"npm run build","lint:fix":"eslint src --ext .ts --fix","prebuild":"npm run clean","format:check":"prettier --check \"src/**/*.ts\"","prepublishOnly":"npm test && npm run build"},"_npmUser":{"name":"techery","email":"serge.z@techery.io"},"repository":{"url":"git+https://github.com/techery/zod-to-vertex-schema.git","type":"git"},"_npmVersion":"10.8.2","description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","directories":{},"_nodeVersion":"20.18.1","dependencies":{"zod":"^3.*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","eslint":"^8.57.1","ts-jest":"^29.2.5","prettier":"^3.4.2","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.5","@jest/globals":"^29.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^7.0.0","@typescript-eslint/eslint-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-to-vertex-schema_0.1.3_1736877127347_0.16968183562549632","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@techery/zod-to-vertex-schema","version":"0.1.4","description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"jest","prepublishOnly":"npm test && npm run build","clean":"rm -rf dist","prebuild":"npm run clean","lint":"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix","format":"prettier --write \"src/**/*.ts\"","format:check":"prettier --check \"src/**/*.ts\"","prepare":"npm run build","check":"npm run format:check && npm run lint && npm run test"},"keywords":["zod","vertex-ai","gemini","schema","typescript"],"author":{"name":"Serge Zenchenko"},"license":"MIT","devDependencies":{"@jest/globals":"^29.7.0","@types/jest":"^29.5.14","@types/node":"^22.10.5","@typescript-eslint/eslint-plugin":"^7.0.0","@typescript-eslint/parser":"^7.0.0","eslint":"^8.57.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","jest":"^29.7.0","prettier":"^3.4.2","ts-jest":"^29.2.5","typescript":"^5.7.3"},"dependencies":{"zod":"^3.*"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/techery/zod-to-vertex-schema.git"},"engines":{"node":">=16"},"bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"homepage":"https://github.com/techery/zod-to-vertex-schema#readme","_id":"@techery/zod-to-vertex-schema@0.1.4","gitHead":"ec50ab1b4b656b4f2cd90e234b08e44ece832b4b","_nodeVersion":"20.18.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-8FcCrKAmUDGkQhncq1q+9UbbMEN81wH9bxzKxACm2egnjSOQdXkba8ayXaX8nJtFSVYVDxt1/U2+wECZ9NtRyg==","shasum":"1ca6309c4347d20f87b6e963d94390636cd9ee67","tarball":"https://registry.npmjs.org/@techery/zod-to-vertex-schema/-/zod-to-vertex-schema-0.1.4.tgz","fileCount":19,"unpackedSize":49004,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCID+MLjol0aNdcb6XXGh7n9R5k+kxvQ4+XEWQiMyS+qOYAiASjh88QC/iyetEJ3qJCDpw1beyYcQ7NX6csQV0jmx3AQ=="}]},"_npmUser":{"name":"techery","email":"serge.z@techery.io"},"directories":{},"maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zod-to-vertex-schema_0.1.4_1738162847056_0.24544107739577137"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-13T13:26:33.726Z","modified":"2025-01-29T15:00:47.464Z","0.1.0":"2025-01-13T13:26:34.098Z","0.1.1":"2025-01-13T13:29:46.935Z","0.1.2":"2025-01-13T13:56:20.139Z","0.1.3":"2025-01-14T17:52:07.622Z","0.1.4":"2025-01-29T15:00:47.278Z"},"bugs":{"url":"https://github.com/techery/zod-to-vertex-schema/issues"},"author":{"name":"Serge Zenchenko"},"license":"MIT","homepage":"https://github.com/techery/zod-to-vertex-schema#readme","keywords":["zod","vertex-ai","gemini","schema","typescript"],"repository":{"type":"git","url":"git+https://github.com/techery/zod-to-vertex-schema.git"},"description":"Convert Zod schemas to Vertex AI/Gemini compatible schemas","maintainers":[{"name":"techery","email":"serge.z@techery.io"}],"readme":"# zod-to-vertex-schema\n\n[![npm version](https://badge.fury.io/js/@techery%2Fzod-to-vertex-schema.svg)](https://www.npmjs.com/package/@techery/zod-to-vertex-schema)\n![CI Status](https://github.com/techery/zod-to-vertex-schema/actions/workflows/pr-checks.yml/badge.svg?branch=main)\n\nConvert [Zod](https://github.com/colinhacks/zod) schemas to [Vertex AI/Gemini](https://cloud.google.com/vertex-ai) compatible schemas and back. This library helps you define your Vertex AI/Gemini function parameters using Zod's powerful schema definition system.\n\nDeveloped by [Techery](https://techery.io).\n\n## Features\n- Two-way conversion between Zod and Vertex AI schemas\n- Preserves property ordering and descriptions\n- Full TypeScript support\n- Zero dependencies (except Zod)\n\n## Type Compatibility\n\n| Zod Type | Vertex AI Schema Type | Notes |\n|----------|---------------------|-------|\n| `z.string()` | `STRING` | Basic string type |\n| `z.string().datetime()` | `STRING` | With `format: \"date-time\"` |\n| `z.string().date()` | `STRING` | With `format: \"date\"` |\n| `z.number()` | `NUMBER` | Floating point numbers |\n| `z.number().int()` | `INTEGER` | Integer numbers |\n| `z.boolean()` | `BOOLEAN` | Boolean values |\n| `z.enum([...])` | `STRING` | With `enum: [...]` |\n| `z.object({...})` | `OBJECT` | With `properties`, `required`, and `propertyOrdering` matching Zod field order |\n| `z.array(...)` | `ARRAY` | With `items` schema |\n| `z.union([...])` | N/A | Converted to `anyOf: [...]` |\n| `z.discriminatedUnion(...)` | N/A | Converted to `anyOf: [...]` |\n| `z.literal(string)` | `STRING` | With `enum: [value]` |\n| `z.null()` | `STRING` | With `nullable: true` |\n| `someSchema.optional()` | Same as base | Field removed from `required` |\n| `someSchema.nullable()` | Same as base | With `nullable: true` |\n| `z.lazy(...)` | N/A | Not supported - Vertex AI schema doesn't support recursive definitions |\n\n## Installation\n\n```bash\nnpm install zod-to-vertex-schema\n```\n\n## Usage\n\n### Converting Zod to Vertex AI Schema\n\n```typescript\nimport { z } from 'zod';\nimport { zodToVertexSchema } from 'zod-to-vertex-schema';\n\n// Define your Zod schema\nconst userSchema = z.object({\n  name: z.string(),\n  age: z.number().int().min(0),\n  email: z.string().email(),\n  roles: z.array(z.enum(['admin', 'user'])),\n});\n\n// Convert to Vertex AI schema\nconst vertexSchema = zodToVertexSchema(userSchema);\n```\n\n### Converting Vertex AI Schema to Zod\n\n```typescript\nimport { vertexSchemaToZod } from 'zod-to-vertex-schema';\nimport { SchemaType } from 'zod-to-vertex-schema';\n\n// Your Vertex AI schema\nconst vertexSchema = {\n  type: SchemaType.OBJECT,\n  properties: {\n    name: { type: SchemaType.STRING },\n    age: { type: SchemaType.INTEGER, minimum: 0 },\n    email: { type: SchemaType.STRING },\n    roles: {\n      type: SchemaType.ARRAY,\n      items: { type: SchemaType.STRING, enum: [\"admin\", \"user\"] }\n    }\n  },\n  required: [\"name\", \"age\", \"email\", \"roles\"],\n  propertyOrdering: [\"name\", \"age\", \"email\", \"roles\"]\n};\n\n// Convert back to Zod schema\nconst zodSchema = vertexSchemaToZod(vertexSchema);\n\n// Now you can use it for validation\nconst validUser = {\n  name: \"John\",\n  age: 30,\n  email: \"john@example.com\",\n  roles: [\"admin\"]\n};\n\nconst result = zodSchema.safeParse(validUser);\nconsole.log(result.success); // true\n```\n\n### Basic Example\n\n```typescript\nimport { z } from 'zod';\nimport { zodToVertexSchema } from 'zod-to-vertex-schema';\n\n// Define your Zod schema\nconst userSchema = z.object({\n  name: z.string(),\n  age: z.number().int().min(0),\n  email: z.string().email(),\n  roles: z.array(z.enum(['admin', 'user'])),\n});\n\n// Convert to Vertex AI schema\nconst vertexSchema = zodToVertexSchema(userSchema);\n\n// Resulting Vertex AI schema:\n{\n  type: \"OBJECT\",\n  properties: {\n    name: { type: \"STRING\" },\n    age: { type: \"INTEGER\", minimum: 0 },\n    email: { type: \"STRING\" },\n    roles: {\n      type: \"ARRAY\",\n      items: { type: \"STRING\", enum: [\"admin\", \"user\"] }\n    }\n  },\n  required: [\"name\", \"age\", \"email\", \"roles\"],\n  propertyOrdering: [\"name\", \"age\", \"email\", \"roles\"]\n}\n```\n\n### Advanced Examples\n\n#### Optional and Nullable Fields\n\n```typescript\nconst profileSchema = z.object({\n  username: z.string(),\n  displayName: z.string().optional(), // Will be marked as not required\n  bio: z.string().nullable(), // Will be marked as nullable\n  lastSeen: z.date().optional().nullable(), // Both optional and nullable\n});\n\nconst vertexProfileSchema = zodToVertexSchema(profileSchema);\n\n// Resulting Vertex AI schema:\n{\n  type: \"OBJECT\",\n  properties: {\n    username: { type: \"STRING\" },\n    displayName: { type: \"STRING\" },\n    bio: { type: \"STRING\", nullable: true },\n    lastSeen: { type: \"STRING\", format: \"date\", nullable: true }\n  },\n  required: [\"username\"],\n  propertyOrdering: [\"username\", \"displayName\", \"bio\", \"lastSeen\"]\n}\n```\n\n#### Complex Nested Objects\n\n```typescript\nconst addressSchema = z.object({\n  street: z.string(),\n  city: z.string(),\n  country: z.string(),\n  postalCode: z.string(),\n});\n\nconst orderSchema = z.object({\n  orderId: z.string(),\n  customer: z.object({\n    id: z.string(),\n    name: z.string(),\n    addresses: z.array(addressSchema),\n  }),\n  items: z.array(z.object({\n    productId: z.string(),\n    quantity: z.number().int().min(1),\n    price: z.number().min(0),\n  })),\n  status: z.enum(['pending', 'processing', 'shipped', 'delivered']),\n  createdAt: z.date(),\n});\n\nconst vertexOrderSchema = zodToVertexSchema(orderSchema);\n\n// Resulting Vertex AI schema:\n{\n  type: \"OBJECT\",\n  properties: {\n    orderId: { type: \"STRING\" },\n    customer: {\n      type: \"OBJECT\",\n      properties: {\n        id: { type: \"STRING\" },\n        name: { type: \"STRING\" },\n        addresses: {\n          type: \"ARRAY\",\n          items: {\n            type: \"OBJECT\",\n            properties: {\n              street: { type: \"STRING\" },\n              city: { type: \"STRING\" },\n              country: { type: \"STRING\" },\n              postalCode: { type: \"STRING\" }\n            },\n            required: [\"street\", \"city\", \"country\", \"postalCode\"],\n            propertyOrdering: [\"street\", \"city\", \"country\", \"postalCode\"]\n          }\n        }\n      },\n      required: [\"id\", \"name\", \"addresses\"],\n      propertyOrdering: [\"id\", \"name\", \"addresses\"]\n    },\n    items: {\n      type: \"ARRAY\",\n      items: {\n        type: \"OBJECT\",\n        properties: {\n          productId: { type: \"STRING\" },\n          quantity: { type: \"INTEGER\", minimum: 1 },\n          price: { type: \"NUMBER\", minimum: 0 }\n        },\n        required: [\"productId\", \"quantity\", \"price\"],\n        propertyOrdering: [\"productId\", \"quantity\", \"price\"]\n      }\n    },\n    status: { type: \"STRING\", enum: [\"pending\", \"processing\", \"shipped\", \"delivered\"] },\n    createdAt: { type: \"STRING\", format: \"date\" }\n  },\n  required: [\"orderId\", \"customer\", \"items\", \"status\", \"createdAt\"],\n  propertyOrdering: [\"orderId\", \"customer\", \"items\", \"status\", \"createdAt\"]\n}\n```\n\n#### Unions and Discriminated Unions\n\n```typescript\n// Simple union\nconst resultSchema = z.union([\n  z.object({ success: z.literal(true), data: z.string() }),\n  z.object({ success: z.literal(false), error: z.string() }),\n]);\n\n// Discriminated union\nconst shapeSchema = z.discriminatedUnion('type', [\n  z.object({ type: z.literal('circle'), radius: z.number() }),\n  z.object({ type: z.literal('rectangle'), width: z.number(), height: z.number() }),\n]);\n\nconst vertexResultSchema = zodToVertexSchema(resultSchema);\nconst vertexShapeSchema = zodToVertexSchema(shapeSchema);\n\n// Resulting Vertex AI schemas:\n// For resultSchema:\n{\n  anyOf: [\n    {\n      type: \"OBJECT\",\n      properties: {\n        success: { type: \"STRING\", enum: [\"true\"] },\n        data: { type: \"STRING\" }\n      },\n      required: [\"success\", \"data\"],\n      propertyOrdering: [\"success\", \"data\"]\n    },\n    {\n      type: \"OBJECT\",\n      properties: {\n        success: { type: \"STRING\", enum: [\"false\"] },\n        error: { type: \"STRING\" }\n      },\n      required: [\"success\", \"error\"],\n      propertyOrdering: [\"success\", \"error\"]\n    }\n  ]\n}\n\n// For shapeSchema:\n{\n  anyOf: [\n    {\n      type: \"OBJECT\",\n      properties: {\n        type: { type: \"STRING\", enum: [\"circle\"] },\n        radius: { type: \"NUMBER\" }\n      },\n      required: [\"type\", \"radius\"],\n      propertyOrdering: [\"type\", \"radius\"]\n    },\n    {\n      type: \"OBJECT\",\n      properties: {\n        type: { type: \"STRING\", enum: [\"rectangle\"] },\n        width: { type: \"NUMBER\" },\n        height: { type: \"NUMBER\" }\n      },\n      required: [\"type\", \"width\", \"height\"],\n      propertyOrdering: [\"type\", \"width\", \"height\"]\n    }\n  ]\n}\n```\n\n#### Date and Format Validation\n\n```typescript\nconst eventSchema = z.object({\n  title: z.string(),\n  startDate: z.date(), // Will be converted to date format\n  endDate: z.date(),\n  createdAt: z.string().datetime(), // Will be converted to date-time format\n});\n\nconst vertexEventSchema = zodToVertexSchema(eventSchema);\n\n// Resulting Vertex AI schema:\n{\n  type: \"OBJECT\",\n  properties: {\n    title: { type: \"STRING\" },\n    startDate: { type: \"STRING\", format: \"date\" },\n    endDate: { type: \"STRING\", format: \"date\" },\n    createdAt: { type: \"STRING\", format: \"date-time\" }\n  },\n  required: [\"title\", \"startDate\", \"endDate\", \"createdAt\"],\n  propertyOrdering: [\"title\", \"startDate\", \"endDate\", \"createdAt\"]\n}\n```\n\n## Supported Features\n\n- Basic Types:\n  - `string`\n  - `number` (with `int()` support)\n  - `boolean`\n  - `date`\n  \n- Complex Types:\n  - Objects (`z.object()`)\n  - Arrays (`z.array()`)\n  - Enums (`z.enum()`)\n  - Unions (`z.union()`)\n  - Discriminated Unions (`z.discriminatedUnion()`)\n  - Literals (`z.literal()`) for strings\n\n- Modifiers:\n  - Optional fields (`optional()`)\n  - Nullable fields (`nullable()`)\n  - String formats (`date()`, `datetime()`)\n  - Number constraints (`min()`, `max()`)\n\n- Metadata:\n  - Description preservation\n  - Property ordering in objects (preserves the exact order of fields as defined in your Zod schema)\n\n## API Reference\n\n### `zodToVertexSchema(schema: z.ZodTypeAny): VertexSchema`\n\nConverts any Zod schema into a Vertex AI/Gemini-compatible schema.\n\n### `vertexSchemaToZod(schema: VertexSchema): z.ZodTypeAny`\n\nConverts a Vertex AI/Gemini schema back into a Zod schema. Supports all features that are available in the Vertex AI schema format.\n\n### `zodDynamicEnum(values: string[]): z.ZodEnum`\n\nHelper function to create an enum schema from a dynamic array of strings.\n\n```typescript\nconst roles = ['admin', 'user', 'guest'];\nconst roleSchema = zodDynamicEnum(roles);\n```\n\n## Notes\n\n- Default values are intentionally ignored in the conversion process\n- Recursive schemas (using `z.lazy()`) are not supported because Vertex AI schema format doesn't support schema definitions or recursive references\n- Some Zod features like transformers, refinements, and custom validators are not supported\n- Non-string literals are not supported in the current version\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Authors\n\n- [Serge Zenchenko](https://github.com/sergezenchenko) - CTO at [Techery](https://techery.io)\n\n## License\n\nMIT","readmeFilename":"README.md"}