@tambo-ai/react 0.66.0 → 0.66.2

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 (109) hide show
  1. package/dist/hooks/use-current-message.d.ts +2 -0
  2. package/dist/hooks/use-current-message.d.ts.map +1 -1
  3. package/dist/hooks/use-current-message.js +1 -0
  4. package/dist/hooks/use-current-message.js.map +1 -1
  5. package/dist/hooks/use-current-message.test.js +5 -0
  6. package/dist/hooks/use-current-message.test.js.map +1 -1
  7. package/dist/model/component-metadata.d.ts +2 -2
  8. package/dist/model/component-metadata.d.ts.map +1 -1
  9. package/dist/model/component-metadata.js.map +1 -1
  10. package/dist/providers/tambo-interactable-provider-partial-updates.test.js +87 -87
  11. package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  12. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  13. package/dist/providers/tambo-interactable-provider.js +46 -40
  14. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  15. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +8 -8
  16. package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  17. package/dist/providers/tambo-interactables-additional-context.test.js +10 -10
  18. package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
  19. package/dist/providers/tambo-registry-provider.test.js +28 -18
  20. package/dist/providers/tambo-registry-provider.test.js.map +1 -1
  21. package/dist/providers/tambo-registry-schema-compat.test.js +57 -28
  22. package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
  23. package/dist/providers/tambo-thread-provider.test.js +21 -19
  24. package/dist/providers/tambo-thread-provider.test.js.map +1 -1
  25. package/dist/schema/alias.d.ts +3 -0
  26. package/dist/schema/alias.d.ts.map +1 -0
  27. package/dist/schema/alias.js +6 -0
  28. package/dist/schema/alias.js.map +1 -0
  29. package/dist/schema/json-schema.js +29 -29
  30. package/dist/schema/json-schema.js.map +1 -1
  31. package/dist/schema/schema.d.ts.map +1 -1
  32. package/dist/schema/schema.js +27 -19
  33. package/dist/schema/schema.js.map +1 -1
  34. package/dist/schema/schema.test.js +291 -3
  35. package/dist/schema/schema.test.js.map +1 -1
  36. package/dist/schema/standard-schema.js +8 -8
  37. package/dist/schema/standard-schema.js.map +1 -1
  38. package/dist/schema/validate.test.js +31 -31
  39. package/dist/schema/validate.test.js.map +1 -1
  40. package/dist/schema/zod.d.ts +5 -5
  41. package/dist/schema/zod.d.ts.map +1 -1
  42. package/dist/schema/zod.js +45 -32
  43. package/dist/schema/zod.js.map +1 -1
  44. package/dist/util/registry-validators.d.ts.map +1 -1
  45. package/dist/util/registry-validators.js +40 -0
  46. package/dist/util/registry-validators.js.map +1 -1
  47. package/dist/util/registry-validators.test.js +69 -0
  48. package/dist/util/registry-validators.test.js.map +1 -1
  49. package/dist/util/registry.d.ts +1 -5
  50. package/dist/util/registry.d.ts.map +1 -1
  51. package/dist/util/registry.js +1 -5
  52. package/dist/util/registry.js.map +1 -1
  53. package/dist/util/registry.test.js +80 -67
  54. package/dist/util/registry.test.js.map +1 -1
  55. package/esm/hooks/use-current-message.d.ts +2 -0
  56. package/esm/hooks/use-current-message.d.ts.map +1 -1
  57. package/esm/hooks/use-current-message.js +1 -0
  58. package/esm/hooks/use-current-message.js.map +1 -1
  59. package/esm/hooks/use-current-message.test.js +5 -0
  60. package/esm/hooks/use-current-message.test.js.map +1 -1
  61. package/esm/model/component-metadata.d.ts +2 -2
  62. package/esm/model/component-metadata.d.ts.map +1 -1
  63. package/esm/model/component-metadata.js.map +1 -1
  64. package/esm/providers/tambo-interactable-provider-partial-updates.test.js +1 -1
  65. package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
  66. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  67. package/esm/providers/tambo-interactable-provider.js +17 -11
  68. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  69. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +1 -1
  70. package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
  71. package/esm/providers/tambo-interactables-additional-context.test.js +1 -1
  72. package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
  73. package/esm/providers/tambo-registry-provider.test.js +16 -6
  74. package/esm/providers/tambo-registry-provider.test.js.map +1 -1
  75. package/esm/providers/tambo-registry-schema-compat.test.js +57 -28
  76. package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
  77. package/esm/providers/tambo-thread-provider.test.js +8 -6
  78. package/esm/providers/tambo-thread-provider.test.js.map +1 -1
  79. package/esm/schema/alias.d.ts +3 -0
  80. package/esm/schema/alias.d.ts.map +1 -0
  81. package/esm/schema/alias.js +13 -0
  82. package/esm/schema/alias.js.map +1 -0
  83. package/esm/schema/json-schema.js +1 -1
  84. package/esm/schema/json-schema.js.map +1 -1
  85. package/esm/schema/schema.d.ts.map +1 -1
  86. package/esm/schema/schema.js +27 -19
  87. package/esm/schema/schema.js.map +1 -1
  88. package/esm/schema/schema.test.js +258 -3
  89. package/esm/schema/schema.test.js.map +1 -1
  90. package/esm/schema/standard-schema.js +1 -1
  91. package/esm/schema/standard-schema.js.map +1 -1
  92. package/esm/schema/validate.test.js +1 -1
  93. package/esm/schema/validate.test.js.map +1 -1
  94. package/esm/schema/zod.d.ts +5 -5
  95. package/esm/schema/zod.d.ts.map +1 -1
  96. package/esm/schema/zod.js +45 -32
  97. package/esm/schema/zod.js.map +1 -1
  98. package/esm/util/registry-validators.d.ts.map +1 -1
  99. package/esm/util/registry-validators.js +40 -0
  100. package/esm/util/registry-validators.js.map +1 -1
  101. package/esm/util/registry-validators.test.js +69 -0
  102. package/esm/util/registry-validators.test.js.map +1 -1
  103. package/esm/util/registry.d.ts +1 -5
  104. package/esm/util/registry.d.ts.map +1 -1
  105. package/esm/util/registry.js +1 -5
  106. package/esm/util/registry.js.map +1 -1
  107. package/esm/util/registry.test.js +80 -67
  108. package/esm/util/registry.test.js.map +1 -1
  109. package/package.json +1 -2
@@ -1 +1 @@
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AAsE,EAAE,GAAG,EAAE;YAC9E,MAAM,SAAS,GAAG;gBAChB,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;aACb,CAAC;YAEF,MAAM,CAAC,IAAA,iCAAmB,EAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { JSONSchema7 } from \"json-schema\";\nimport { z } from \"zodInternalAlias\";\nimport { looksLikeJSONSchema } from \"./json-schema\";\nimport { isStandardSchema } from \"./standard-schema\";\n\ndescribe(\"schema utilities\", () => {\n describe(\"looksLikeJSONSchema\", () => {\n it(\"returns true for a basic JSON Schema object\", () => {\n const jsonSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"integer\" },\n },\n required: [\"name\"],\n };\n\n expect(looksLikeJSONSchema(jsonSchema)).toBe(true);\n });\n\n it(\"returns true for a union type JSON Schema\", () => {\n const jsonSchema: JSONSchema7 = {\n type: [\"string\", \"null\"],\n };\n\n expect(looksLikeJSONSchema(jsonSchema)).toBe(true);\n });\n\n it(\"returns false for Standard Schema validators\", () => {\n const zodSchema = z.object({\n name: z.string(),\n });\n\n expect(isStandardSchema(zodSchema)).toBe(true);\n expect(looksLikeJSONSchema(zodSchema)).toBe(false);\n });\n\n it(\"returns false for arbitrary objects that do not resemble JSON Schema\", () => {\n const notSchema = {\n type: \"foo\",\n other: \"bar\",\n };\n\n expect(looksLikeJSONSchema(notSchema)).toBe(false);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"schema.test.js","sourceRoot":"","sources":["../../src/schema/schema.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,2CAA6B;AAE7B,+CAAoD;AACpD,qCAAuD;AACvD,uDAAqD;AAErD,QAAQ,CAAC,kBAAkB,EAAE,GAAG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M,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACzC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC1C,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,yDAAyD,EAAE,GAAG,EAAE;YACvE,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;gBACnE,MAAM,IAAI,GAAG;oBACX,IAAI,EAAE,WAAW;oBACjB,WAAW,EAAE,WAAW;oBACxB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;oBACf,UAAU,EAAE,EAAE;yBACX,QAAQ,EAAE;yBACV,IAAI,CACH,EAAE,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,EACjC,EAAE,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CACnC;yBACA,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;iBACtB,CAAC;gBAEF,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,IAAI,CAAC,CAAC;gBAEjD,2DAA2D;gBAC3D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;gBAChD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { JSONSchema7 } from \"json-schema\";\nimport * as z3 from \"zod/v3\";\nimport * as z4 from \"zod/v4\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport { looksLikeJSONSchema } from \"./json-schema\";\nimport { getParametersFromToolSchema } from \"./schema\";\nimport { isStandardSchema } from \"./standard-schema\";\n\ndescribe(\"schema utilities\", () => {\n describe(\"looksLikeJSONSchema\", () => {\n it(\"returns true for a basic JSON Schema object\", () => {\n const jsonSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n age: { type: \"integer\" },\n },\n required: [\"name\"],\n };\n\n expect(looksLikeJSONSchema(jsonSchema)).toBe(true);\n });\n\n it(\"returns true for a union type JSON Schema\", () => {\n const jsonSchema: JSONSchema7 = {\n type: [\"string\", \"null\"],\n };\n\n expect(looksLikeJSONSchema(jsonSchema)).toBe(true);\n });\n\n it(\"returns false for Standard Schema validators\", () => {\n const zodSchema = z4.object({\n name: z4.string(),\n });\n\n expect(isStandardSchema(zodSchema)).toBe(true);\n expect(looksLikeJSONSchema(zodSchema)).toBe(false);\n });\n\n it(\"returns false for arbitrary objects that do not resemble JSON Schema\", () => {\n const notSchema = {\n type: \"foo\",\n other: \"bar\",\n };\n\n expect(looksLikeJSONSchema(notSchema)).toBe(false);\n });\n });\n\n describe(\"getParametersFromToolSchema\", () => {\n describe(\"inputSchema interface (object schemas)\", () => {\n it(\"extracts parameters from Zod 4 object schema properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n query: z4.string().describe(\"Search query\"),\n limit: z4.number().describe(\"Max results\"),\n enabled: z4.boolean().optional().describe(\"Whether enabled\"),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(3);\n\n const queryParam = params.find((p) => p.name === \"query\");\n expect(queryParam).toBeDefined();\n expect(queryParam?.type).toBe(\"string\");\n expect(queryParam?.description).toBe(\"Search query\");\n expect(queryParam?.isRequired).toBe(true);\n\n const limitParam = params.find((p) => p.name === \"limit\");\n expect(limitParam).toBeDefined();\n expect(limitParam?.type).toBe(\"number\");\n expect(limitParam?.description).toBe(\"Max results\");\n expect(limitParam?.isRequired).toBe(true);\n\n const enabledParam = params.find((p) => p.name === \"enabled\");\n expect(enabledParam).toBeDefined();\n expect(enabledParam?.type).toBe(\"boolean\");\n // Optional fields are not required\n expect(enabledParam?.isRequired).toBe(false);\n });\n\n it(\"extracts parameters from Zod 3 object schema properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z3.object({\n name: z3.string().describe(\"User name\"),\n age: z3.number().optional(),\n }),\n outputSchema: z3.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(2);\n\n const nameParam = params.find((p) => p.name === \"name\");\n expect(nameParam).toBeDefined();\n expect(nameParam?.type).toBe(\"string\");\n expect(nameParam?.isRequired).toBe(true);\n\n const ageParam = params.find((p) => p.name === \"age\");\n expect(ageParam).toBeDefined();\n expect(ageParam?.type).toBe(\"number\");\n expect(ageParam?.isRequired).toBe(false);\n });\n\n it(\"extracts parameters from JSON Schema object properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Item ID\" },\n count: { type: \"number\", description: \"Item count\" },\n active: { type: \"boolean\" },\n },\n required: [\"id\"],\n } as JSONSchema7,\n outputSchema: {},\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(3);\n\n const idParam = params.find((p) => p.name === \"id\");\n expect(idParam).toBeDefined();\n expect(idParam?.type).toBe(\"string\");\n expect(idParam?.description).toBe(\"Item ID\");\n expect(idParam?.isRequired).toBe(true);\n\n const countParam = params.find((p) => p.name === \"count\");\n expect(countParam).toBeDefined();\n expect(countParam?.type).toBe(\"number\");\n expect(countParam?.isRequired).toBe(false);\n\n const activeParam = params.find((p) => p.name === \"active\");\n expect(activeParam).toBeDefined();\n expect(activeParam?.type).toBe(\"boolean\");\n expect(activeParam?.isRequired).toBe(false);\n });\n\n it(\"handles empty object schema\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({}),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n expect(params).toHaveLength(0);\n });\n\n it(\"handles nested object schemas\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n user: z4\n .object({\n name: z4.string(),\n email: z4.string(),\n })\n .describe(\"User info\"),\n options: z4.object({\n notify: z4.boolean(),\n }),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(2);\n\n const userParam = params.find((p) => p.name === \"user\");\n expect(userParam).toBeDefined();\n expect(userParam?.type).toBe(\"object\");\n expect(userParam?.description).toBe(\"User info\");\n\n const optionsParam = params.find((p) => p.name === \"options\");\n expect(optionsParam).toBeDefined();\n expect(optionsParam?.type).toBe(\"object\");\n });\n\n it(\"handles array properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n tags: z4.array(z4.string()).describe(\"List of tags\"),\n items: z4.array(z4.object({ id: z4.number() })),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(2);\n\n const tagsParam = params.find((p) => p.name === \"tags\");\n expect(tagsParam).toBeDefined();\n expect(tagsParam?.type).toBe(\"array\");\n expect(tagsParam?.description).toBe(\"List of tags\");\n\n const itemsParam = params.find((p) => p.name === \"items\");\n expect(itemsParam).toBeDefined();\n expect(itemsParam?.type).toBe(\"array\");\n });\n });\n\n describe(\"realistic inputSchema scenarios\", () => {\n it(\"handles enum properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n status: z4.enum([\"pending\", \"active\", \"completed\"]),\n priority: z4\n .enum([\"low\", \"medium\", \"high\"])\n .describe(\"Task priority\"),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(2);\n\n const statusParam = params.find((p) => p.name === \"status\");\n expect(statusParam).toBeDefined();\n expect(statusParam?.type).toBe(\"string\");\n expect(statusParam?.isRequired).toBe(true);\n\n const priorityParam = params.find((p) => p.name === \"priority\");\n expect(priorityParam).toBeDefined();\n expect(priorityParam?.type).toBe(\"string\");\n expect(priorityParam?.description).toBe(\"Task priority\");\n });\n\n it(\"handles nullable properties\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n name: z4.string().nullable().describe(\"Optional name\"),\n count: z4.number().nullable(),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(2);\n\n const nameParam = params.find((p) => p.name === \"name\");\n expect(nameParam).toBeDefined();\n expect(nameParam?.description).toBe(\"Optional name\");\n // Nullable fields are still required (they must be provided, even if null)\n expect(nameParam?.isRequired).toBe(true);\n });\n\n it(\"handles deeply nested schemas and preserves full schema\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n config: z4.object({\n database: z4.object({\n host: z4.string(),\n port: z4.number().optional(),\n }),\n }),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(1);\n expect(params[0].name).toBe(\"config\");\n expect(params[0].type).toBe(\"object\");\n // The full nested schema should be preserved\n expect(params[0].schema).toHaveProperty(\"properties\");\n });\n\n it(\"handles mixed required and optional fields correctly\", () => {\n const tool: TamboTool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n inputSchema: z4.object({\n required1: z4.string(),\n optional1: z4.string().optional(),\n required2: z4.number(),\n }),\n outputSchema: z4.void(),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n expect(params).toHaveLength(3);\n\n const required1 = params.find((p) => p.name === \"required1\");\n const optional1 = params.find((p) => p.name === \"optional1\");\n const required2 = params.find((p) => p.name === \"required2\");\n\n expect(required1?.isRequired).toBe(true);\n expect(optional1?.isRequired).toBe(false);\n expect(required2?.isRequired).toBe(true);\n });\n });\n\n describe(\"deprecated toolSchema interface (tuple/positional args)\", () => {\n it(\"extracts positional parameters from Zod 3 function schema\", () => {\n const tool = {\n name: \"test-tool\",\n description: \"Test tool\",\n tool: jest.fn(),\n toolSchema: z3\n .function()\n .args(\n z3.string().describe(\"First arg\"),\n z3.number().describe(\"Second arg\"),\n )\n .returns(z3.void()),\n };\n\n const params = getParametersFromToolSchema(tool);\n\n // toolSchema uses positional params (param1, param2, etc.)\n expect(params.length).toBeGreaterThanOrEqual(1);\n expect(params[0].name).toBe(\"param1\");\n });\n });\n });\n});\n"]}
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isStandardSchema = isStandardSchema;
4
- const zodInternalAlias_1 = require("zodInternalAlias");
5
- const standardSchemaProps = zodInternalAlias_1.z.object({
6
- version: zodInternalAlias_1.z.literal(1),
7
- vendor: zodInternalAlias_1.z.string(),
8
- validate: zodInternalAlias_1.z.function({
9
- input: [zodInternalAlias_1.z.unknown()],
10
- output: zodInternalAlias_1.z.union([zodInternalAlias_1.z.unknown(), zodInternalAlias_1.z.promise(zodInternalAlias_1.z.unknown())]),
4
+ const alias_1 = require("./alias");
5
+ const standardSchemaProps = alias_1.z.object({
6
+ version: alias_1.z.literal(1),
7
+ vendor: alias_1.z.string(),
8
+ validate: alias_1.z.function({
9
+ input: [alias_1.z.unknown()],
10
+ output: alias_1.z.union([alias_1.z.unknown(), alias_1.z.promise(alias_1.z.unknown())]),
11
11
  }),
12
12
  });
13
- const standardSchemaObject = zodInternalAlias_1.z.object({
13
+ const standardSchemaObject = alias_1.z.object({
14
14
  "~standard": standardSchemaProps,
15
15
  });
16
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../../src/schema/standard-schema.ts"],"names":[],"mappings":";;AAkCA,4CAEC;AAnCD,uDAAqC;AAErC,MAAM,mBAAmB,GAAG,oBAAC,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,oBAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,oBAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,oBAAC,CAAC,QAAQ,CAAC;QACnB,KAAK,EAAE,CAAC,oBAAC,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,EAAE,oBAAC,CAAC,KAAK,CAAC,CAAC,oBAAC,CAAC,OAAO,EAAE,EAAE,oBAAC,CAAC,OAAO,CAAC,oBAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;KACvD,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,oBAAC,CAAC,MAAM,CAAC;IACpC,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,gBAAgB,CAAC,GAAY;IAC3C,OAAO,oBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;AACrD,CAAC","sourcesContent":["import { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { z } from \"zodInternalAlias\";\n\nconst standardSchemaProps = z.object({\n version: z.literal(1),\n vendor: z.string(),\n validate: z.function({\n input: [z.unknown()],\n output: z.union([z.unknown(), z.promise(z.unknown())]),\n }),\n});\n\nconst standardSchemaObject = z.object({\n \"~standard\": standardSchemaProps,\n});\n\n/**\n * Type guard to check if an object implements the Standard Schema interface.\n *\n * Standard Schema compliant validators have a `~standard` property containing\n * metadata about the schema including version, vendor, and validate function.\n * @param obj - The object to check\n * @returns True if the object implements StandardSchemaV1\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const zodSchema = z.object({ name: z.string() });\n * isStandardSchema(zodSchema); // true\n *\n * const jsonSchema = { type: \"object\", properties: { name: { type: \"string\" } } };\n * isStandardSchema(jsonSchema); // false\n * ```\n */\nexport function isStandardSchema(obj: unknown): obj is StandardSchemaV1 {\n return standardSchemaObject.safeParse(obj).success;\n}\n"]}
1
+ {"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../../src/schema/standard-schema.ts"],"names":[],"mappings":";;AAkCA,4CAEC;AAnCD,mCAA4B;AAE5B,MAAM,mBAAmB,GAAG,SAAC,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,SAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,SAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,SAAC,CAAC,QAAQ,CAAC;QACnB,KAAK,EAAE,CAAC,SAAC,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,EAAE,SAAC,CAAC,KAAK,CAAC,CAAC,SAAC,CAAC,OAAO,EAAE,EAAE,SAAC,CAAC,OAAO,CAAC,SAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;KACvD,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,SAAC,CAAC,MAAM,CAAC;IACpC,WAAW,EAAE,mBAAmB;CACjC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,gBAAgB,CAAC,GAAY;IAC3C,OAAO,oBAAoB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;AACrD,CAAC","sourcesContent":["import { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { z } from \"./alias\";\n\nconst standardSchemaProps = z.object({\n version: z.literal(1),\n vendor: z.string(),\n validate: z.function({\n input: [z.unknown()],\n output: z.union([z.unknown(), z.promise(z.unknown())]),\n }),\n});\n\nconst standardSchemaObject = z.object({\n \"~standard\": standardSchemaProps,\n});\n\n/**\n * Type guard to check if an object implements the Standard Schema interface.\n *\n * Standard Schema compliant validators have a `~standard` property containing\n * metadata about the schema including version, vendor, and validate function.\n * @param obj - The object to check\n * @returns True if the object implements StandardSchemaV1\n * @example\n * ```typescript\n * import { z } from \"zod/v4\";\n *\n * const zodSchema = z.object({ name: z.string() });\n * isStandardSchema(zodSchema); // true\n *\n * const jsonSchema = { type: \"object\", properties: { name: { type: \"string\" } } };\n * isStandardSchema(jsonSchema); // false\n * ```\n */\nexport function isStandardSchema(obj: unknown): obj is StandardSchemaV1 {\n return standardSchemaObject.safeParse(obj).success;\n}\n"]}
@@ -1,84 +1,84 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const zodInternalAlias_1 = require("zodInternalAlias");
3
+ const v4_1 = require("zod/v4");
4
4
  const validate_1 = require("./validate");
5
5
  describe("assertNoRecordSchema", () => {
6
6
  it("should allow valid schemas without records", () => {
7
- const schema = zodInternalAlias_1.z.object({
8
- name: zodInternalAlias_1.z.string(),
9
- age: zodInternalAlias_1.z.number(),
10
- tags: zodInternalAlias_1.z.array(zodInternalAlias_1.z.string()),
11
- address: zodInternalAlias_1.z.object({
12
- street: zodInternalAlias_1.z.string(),
13
- city: zodInternalAlias_1.z.string(),
7
+ const schema = v4_1.z.object({
8
+ name: v4_1.z.string(),
9
+ age: v4_1.z.number(),
10
+ tags: v4_1.z.array(v4_1.z.string()),
11
+ address: v4_1.z.object({
12
+ street: v4_1.z.string(),
13
+ city: v4_1.z.string(),
14
14
  }),
15
15
  });
16
16
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).not.toThrow();
17
17
  });
18
18
  it("should throw when encountering a record at root level", () => {
19
- const schema = zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string());
19
+ const schema = v4_1.z.record(v4_1.z.string(), v4_1.z.string());
20
20
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "(root)". Replace it with an object using explicit keys.');
21
21
  });
22
22
  it("should throw when encountering a nested record", () => {
23
- const schema = zodInternalAlias_1.z.object({
24
- name: zodInternalAlias_1.z.string(),
25
- metadata: zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string()),
23
+ const schema = v4_1.z.object({
24
+ name: v4_1.z.string(),
25
+ metadata: v4_1.z.record(v4_1.z.string(), v4_1.z.string()),
26
26
  });
27
27
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "metadata". Replace it with an object using explicit keys.');
28
28
  });
29
29
  it("should throw when encountering a record in an array", () => {
30
- const schema = zodInternalAlias_1.z.object({
31
- items: zodInternalAlias_1.z.array(zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string())),
30
+ const schema = v4_1.z.object({
31
+ items: v4_1.z.array(v4_1.z.record(v4_1.z.string(), v4_1.z.string())),
32
32
  });
33
33
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "items.[]". Replace it with an object using explicit keys.');
34
34
  });
35
35
  it("should throw when encountering a record in a union", () => {
36
- const schema = zodInternalAlias_1.z.union([zodInternalAlias_1.z.string(), zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.number())]);
36
+ const schema = v4_1.z.union([v4_1.z.string(), v4_1.z.record(v4_1.z.string(), v4_1.z.number())]);
37
37
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "|1". Replace it with an object using explicit keys.');
38
38
  });
39
39
  it("should throw when encountering a record in an intersection", () => {
40
- const schema = zodInternalAlias_1.z.intersection(zodInternalAlias_1.z.object({ name: zodInternalAlias_1.z.string() }), zodInternalAlias_1.z.object({ metadata: zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string()) }));
40
+ const schema = v4_1.z.intersection(v4_1.z.object({ name: v4_1.z.string() }), v4_1.z.object({ metadata: v4_1.z.record(v4_1.z.string(), v4_1.z.string()) }));
41
41
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow(/Record types \(objects with dynamic keys\) are not supported in schema\. Found at path "(&1\.)?metadata"\. Replace it with an object using explicit keys\./);
42
42
  });
43
43
  it("should throw when encountering a record in a discriminated union", () => {
44
- const schema = zodInternalAlias_1.z.discriminatedUnion("type", [
45
- zodInternalAlias_1.z.object({ type: zodInternalAlias_1.z.literal("string"), value: zodInternalAlias_1.z.string() }),
46
- zodInternalAlias_1.z.object({
47
- type: zodInternalAlias_1.z.literal("record"),
48
- value: zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.number()),
44
+ const schema = v4_1.z.discriminatedUnion("type", [
45
+ v4_1.z.object({ type: v4_1.z.literal("string"), value: v4_1.z.string() }),
46
+ v4_1.z.object({
47
+ type: v4_1.z.literal("record"),
48
+ value: v4_1.z.record(v4_1.z.string(), v4_1.z.number()),
49
49
  }),
50
50
  ]);
51
51
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow(/Record types \(objects with dynamic keys\) are not supported in schema\. Found at path "\|1\.value"\. Replace it with an object using explicit keys\./);
52
52
  });
53
53
  it("should throw when encountering a record in an optional field", () => {
54
- const schema = zodInternalAlias_1.z.object({
55
- optional: zodInternalAlias_1.z.optional(zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string())),
54
+ const schema = v4_1.z.object({
55
+ optional: v4_1.z.optional(v4_1.z.record(v4_1.z.string(), v4_1.z.string())),
56
56
  });
57
57
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "optional". Replace it with an object using explicit keys.');
58
58
  });
59
59
  it("should throw when encountering a record in a nullable field", () => {
60
- const schema = zodInternalAlias_1.z.object({
61
- nullable: zodInternalAlias_1.z.nullable(zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string())),
60
+ const schema = v4_1.z.object({
61
+ nullable: v4_1.z.nullable(v4_1.z.record(v4_1.z.string(), v4_1.z.string())),
62
62
  });
63
63
  // Nullable creates a oneOf in JSON Schema, so the path includes the union index
64
64
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow(/Record types \(objects with dynamic keys\) are not supported in schema\. Found at path "nullable(\.\|0)?"\. Replace it with an object using explicit keys\./);
65
65
  });
66
66
  it("should throw when encountering a record in a tuple", () => {
67
- const schema = zodInternalAlias_1.z.tuple([zodInternalAlias_1.z.string(), zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.number())]);
67
+ const schema = v4_1.z.tuple([v4_1.z.string(), v4_1.z.record(v4_1.z.string(), v4_1.z.number())]);
68
68
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "1". Replace it with an object using explicit keys.');
69
69
  });
70
70
  it("should use custom context name in error message", () => {
71
- const schema = zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string());
71
+ const schema = v4_1.z.record(v4_1.z.string(), v4_1.z.string());
72
72
  expect(() => (0, validate_1.assertNoRecordSchema)(schema, "mySchema")).toThrow('Record types (objects with dynamic keys) are not supported in mySchema. Found at path "(root)". Replace it with an object using explicit keys.');
73
73
  });
74
74
  it("should handle ZodLazy schemas", () => {
75
- const schema = zodInternalAlias_1.z.lazy(() => zodInternalAlias_1.z.record(zodInternalAlias_1.z.string(), zodInternalAlias_1.z.string()));
75
+ const schema = v4_1.z.lazy(() => v4_1.z.record(v4_1.z.string(), v4_1.z.string()));
76
76
  expect(() => (0, validate_1.assertNoRecordSchema)(schema)).toThrow('Record types (objects with dynamic keys) are not supported in schema. Found at path "(root)". Replace it with an object using explicit keys.');
77
77
  });
78
78
  it("should allow z.function() with valid arguments", () => {
79
- const schema = zodInternalAlias_1.z.function({
80
- input: [zodInternalAlias_1.z.string(), zodInternalAlias_1.z.number()],
81
- output: zodInternalAlias_1.z.string(),
79
+ const schema = v4_1.z.function({
80
+ input: [v4_1.z.string(), v4_1.z.number()],
81
+ output: v4_1.z.string(),
82
82
  });
83
83
  // Function schemas can't be converted to JSON Schema directly,
84
84
  // so they should not throw (validation happens on the extracted parameters)
@@ -1 +1 @@
1
- {"version":3,"file":"validate.test.js","sourceRoot":"","sources":["../../src/schema/validate.test.ts"],"names":[],"mappings":";;AAAA,uDAAqC;AACrC,yCAAkD;AAElD,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,oBAAC,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,oBAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,oBAAC,CAAC,MAAM,EAAE;YACf,IAAI,EAAE,oBAAC,CAAC,KAAK,CAAC,oBAAC,CAAC,MAAM,EAAE,CAAC;YACzB,OAAO,EAAE,oBAAC,CAAC,MAAM,CAAC;gBAChB,MAAM,EAAE,oBAAC,CAAC,MAAM,EAAE;gBAClB,IAAI,EAAE,oBAAC,CAAC,MAAM,EAAE;aACjB,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,MAAM,GAAG,oBAAC,CAAC,MAAM,CAAC,oBAAC,CAAC,MAAM,EAAE,EAAE,oBAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEhD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAChD,8IAA8I,CAC/I,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAA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,EAAE;QAC1D,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,QAAiB;YACvB,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;SAClD,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CACpD,8IAA8I,CAC/I,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+EAA+E,EAAE,GAAG,EAAE;QACvF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;aAChC;YACD,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;SAClD,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CACpD,8IAA8I,CAC/I,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAiB;oBACvB,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;iBAClD;aACF;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CACpD,gJAAgJ,CACjJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zodInternalAlias\";\nimport { assertNoRecordSchema } from \"./validate\";\n\ndescribe(\"assertNoRecordSchema\", () => {\n it(\"should allow valid schemas without records\", () => {\n const schema = z.object({\n name: z.string(),\n age: z.number(),\n tags: z.array(z.string()),\n address: z.object({\n street: z.string(),\n city: z.string(),\n }),\n });\n\n expect(() => assertNoRecordSchema(schema)).not.toThrow();\n });\n\n it(\"should throw when encountering a record at root level\", () => {\n const schema = z.record(z.string(), z.string());\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a nested record\", () => {\n const schema = z.object({\n name: z.string(),\n metadata: z.record(z.string(), z.string()),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"metadata\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an array\", () => {\n const schema = z.object({\n items: z.array(z.record(z.string(), z.string())),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"items.[]\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a union\", () => {\n const schema = z.union([z.string(), z.record(z.string(), z.number())]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"|1\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an intersection\", () => {\n const schema = z.intersection(\n z.object({ name: z.string() }),\n z.object({ metadata: z.record(z.string(), z.string()) }),\n );\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"(&1\\.)?metadata\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in a discriminated union\", () => {\n const schema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"string\"), value: z.string() }),\n z.object({\n type: z.literal(\"record\"),\n value: z.record(z.string(), z.number()),\n }),\n ]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"\\|1\\.value\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in an optional field\", () => {\n const schema = z.object({\n optional: z.optional(z.record(z.string(), z.string())),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"optional\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a nullable field\", () => {\n const schema = z.object({\n nullable: z.nullable(z.record(z.string(), z.string())),\n });\n\n // Nullable creates a oneOf in JSON Schema, so the path includes the union index\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"nullable(\\.\\|0)?\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in a tuple\", () => {\n const schema = z.tuple([z.string(), z.record(z.string(), z.number())]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"1\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should use custom context name in error message\", () => {\n const schema = z.record(z.string(), z.string());\n\n expect(() => assertNoRecordSchema(schema, \"mySchema\")).toThrow(\n 'Record types (objects with dynamic keys) are not supported in mySchema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should handle ZodLazy schemas\", () => {\n const schema = z.lazy(() => z.record(z.string(), z.string()));\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should allow z.function() with valid arguments\", () => {\n const schema = z.function({\n input: [z.string(), z.number()],\n output: z.string(),\n });\n\n // Function schemas can't be converted to JSON Schema directly,\n // so they should not throw (validation happens on the extracted parameters)\n expect(() => assertNoRecordSchema(schema)).not.toThrow();\n });\n\n it(\"should allow JSON Schema without records\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n name: { type: \"string\" as const },\n age: { type: \"number\" as const },\n },\n required: [\"name\"],\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).not.toThrow();\n });\n\n it(\"should throw when JSON Schema has record pattern\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n additionalProperties: { type: \"string\" as const },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should treat JSON Schema with properties and additionalProperties as a record\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n id: { type: \"string\" as const },\n },\n additionalProperties: { type: \"number\" as const },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when nested JSON Schema has record pattern\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n metadata: {\n type: \"object\" as const,\n additionalProperties: { type: \"string\" as const },\n },\n },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"metadata\". Replace it with an object using explicit keys.',\n );\n });\n});\n"]}
1
+ {"version":3,"file":"validate.test.js","sourceRoot":"","sources":["../../src/schema/validate.test.ts"],"names":[],"mappings":";;AAAA,+BAA2B;AAC3B,yCAAkD;AAElD,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,MAAC,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,MAAC,CAAC,MAAM,EAAE;YAChB,GAAG,EAAE,MAAC,CAAC,MAAM,EAAE;YACf,IAAI,EAAE,MAAC,CAAC,KAAK,CAAC,MAAC,CAAC,MAAM,EAAE,CAAC;YACzB,OAAO,EAAE,MAAC,CAAC,MAAM,CAAC;gBAChB,MAAM,EAAE,MAAC,CAAC,MAAM,EAAE;gBAClB,IAAI,EAAE,MAAC,C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B,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;iBAClD;aACF;SACF,CAAC;QAEF,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,+BAAoB,EAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CACpD,gJAAgJ,CACjJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { z } from \"zod/v4\";\nimport { assertNoRecordSchema } from \"./validate\";\n\ndescribe(\"assertNoRecordSchema\", () => {\n it(\"should allow valid schemas without records\", () => {\n const schema = z.object({\n name: z.string(),\n age: z.number(),\n tags: z.array(z.string()),\n address: z.object({\n street: z.string(),\n city: z.string(),\n }),\n });\n\n expect(() => assertNoRecordSchema(schema)).not.toThrow();\n });\n\n it(\"should throw when encountering a record at root level\", () => {\n const schema = z.record(z.string(), z.string());\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a nested record\", () => {\n const schema = z.object({\n name: z.string(),\n metadata: z.record(z.string(), z.string()),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"metadata\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an array\", () => {\n const schema = z.object({\n items: z.array(z.record(z.string(), z.string())),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"items.[]\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a union\", () => {\n const schema = z.union([z.string(), z.record(z.string(), z.number())]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"|1\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in an intersection\", () => {\n const schema = z.intersection(\n z.object({ name: z.string() }),\n z.object({ metadata: z.record(z.string(), z.string()) }),\n );\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"(&1\\.)?metadata\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in a discriminated union\", () => {\n const schema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"string\"), value: z.string() }),\n z.object({\n type: z.literal(\"record\"),\n value: z.record(z.string(), z.number()),\n }),\n ]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"\\|1\\.value\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in an optional field\", () => {\n const schema = z.object({\n optional: z.optional(z.record(z.string(), z.string())),\n });\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"optional\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when encountering a record in a nullable field\", () => {\n const schema = z.object({\n nullable: z.nullable(z.record(z.string(), z.string())),\n });\n\n // Nullable creates a oneOf in JSON Schema, so the path includes the union index\n expect(() => assertNoRecordSchema(schema)).toThrow(\n /Record types \\(objects with dynamic keys\\) are not supported in schema\\. Found at path \"nullable(\\.\\|0)?\"\\. Replace it with an object using explicit keys\\./,\n );\n });\n\n it(\"should throw when encountering a record in a tuple\", () => {\n const schema = z.tuple([z.string(), z.record(z.string(), z.number())]);\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"1\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should use custom context name in error message\", () => {\n const schema = z.record(z.string(), z.string());\n\n expect(() => assertNoRecordSchema(schema, \"mySchema\")).toThrow(\n 'Record types (objects with dynamic keys) are not supported in mySchema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should handle ZodLazy schemas\", () => {\n const schema = z.lazy(() => z.record(z.string(), z.string()));\n\n expect(() => assertNoRecordSchema(schema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should allow z.function() with valid arguments\", () => {\n const schema = z.function({\n input: [z.string(), z.number()],\n output: z.string(),\n });\n\n // Function schemas can't be converted to JSON Schema directly,\n // so they should not throw (validation happens on the extracted parameters)\n expect(() => assertNoRecordSchema(schema)).not.toThrow();\n });\n\n it(\"should allow JSON Schema without records\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n name: { type: \"string\" as const },\n age: { type: \"number\" as const },\n },\n required: [\"name\"],\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).not.toThrow();\n });\n\n it(\"should throw when JSON Schema has record pattern\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n additionalProperties: { type: \"string\" as const },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should treat JSON Schema with properties and additionalProperties as a record\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n id: { type: \"string\" as const },\n },\n additionalProperties: { type: \"number\" as const },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"(root)\". Replace it with an object using explicit keys.',\n );\n });\n\n it(\"should throw when nested JSON Schema has record pattern\", () => {\n const jsonSchema = {\n type: \"object\" as const,\n properties: {\n metadata: {\n type: \"object\" as const,\n additionalProperties: { type: \"string\" as const },\n },\n },\n };\n\n expect(() => assertNoRecordSchema(jsonSchema)).toThrow(\n 'Record types (objects with dynamic keys) are not supported in schema. Found at path \"metadata\". Replace it with an object using explicit keys.',\n );\n });\n});\n"]}
@@ -15,11 +15,11 @@ export declare function isZod4FunctionSchema(schema: unknown): schema is $ZodFun
15
15
  */
16
16
  export declare function isZodFunctionSchema(schema: unknown): schema is ZodFunction<ZodTuple<ZodTupleItems, any>, ZodTypeAny> | $ZodFunction<import("zod/v4/core").$ZodFunctionArgs, import("zod/v4/core").$ZodFunctionOut>;
17
17
  /**
18
- * Extracts the args schema from a Zod 3 function schema.
19
- * @param schema - The Zod 3 function schema
20
- * @returns The args schema, or undefined if not a Zod 3 function schema
18
+ * Extracts the args schema from a Zod function schema.
19
+ * @param schema - The Zod function schema
20
+ * @returns The args schema, or undefined if not a Zod function schema
21
21
  */
22
- export declare function getZodFunctionArgs(schema: unknown): any;
22
+ export declare function getZodFunctionArgs(schema: unknown): import("zod/v4/core").$ZodFunctionArgs | ZodTuple<ZodTupleItems, any>;
23
23
  /**
24
24
  * Extracts the return schema from a Zod 3 or Zod 4 function schema.
25
25
  * @param schema - The Zod function schema
@@ -50,5 +50,5 @@ export declare function isZod4Schema(schema: unknown): schema is $ZodType;
50
50
  * @param schema - The schema to check
51
51
  * @returns True if the schema is a Zod schema
52
52
  */
53
- export declare function isZodSchema(schema: unknown): ReturnType<typeof isZod3Schema> | ReturnType<typeof isZod4Schema>;
53
+ export declare function isZodSchema(schema: unknown): schema is ZodType | $ZodType;
54
54
  //# sourceMappingURL=zod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/schema/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,QAAQ,EACR,aAAa,EACb,OAAO,EACP,UAAU,EACX,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,YAAY,EACZ,QAAQ,EAET,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,CAMjE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IA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gB,qBAAqB,CAAC,MAAM,EAAE,OAAO,OAWpD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,OAkBpD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,OAAO,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,QAAQ,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,OAAO,GAAG,QAAQ,CAczE"}
@@ -10,15 +10,15 @@ exports.isZod3Schema = isZod3Schema;
10
10
  exports.isZod4Schema = isZod4Schema;
11
11
  exports.isZodSchema = isZodSchema;
12
12
  const core_1 = require("zod/v4/core");
13
- const zodInternalAlias_1 = require("zodInternalAlias");
14
13
  /**
15
14
  * @returns True if the schema is a Zod 3 function schema
16
15
  */
17
16
  function isZod3FunctionSchema(schema) {
18
- if (!isZod3Schema(schema)) {
17
+ if (!isZodSchema(schema))
19
18
  return false;
20
- }
21
- return "typeName" in schema._def && schema._def.typeName === "ZodFunction";
19
+ return ("_def" in schema &&
20
+ "typeName" in schema._def &&
21
+ schema._def.typeName === "ZodFunction");
22
22
  }
23
23
  /**
24
24
  * @returns True if the schema is a Zod 4 function schema
@@ -27,8 +27,20 @@ function isZod4FunctionSchema(schema) {
27
27
  if (!isZod4Schema(schema)) {
28
28
  return false;
29
29
  }
30
- // @ts-expect-error -- Error in Zod types for v3 vs v4
31
- return "def" in schema && schema._zod.def.type === "function";
30
+ // $ZodFunctions in zod 4.0 most certainly do have .def.type === "function"
31
+ // but the type definitions do not reflect this because $ZodFunction does not
32
+ // extend $ZodType. This is corrected in zod 4.1, but zod 3 does not include
33
+ // the types for 4.1 yet (and might not ever).
34
+ // See: https://github.com/colinhacks/zod/blob/463f03eb8183dcdcdf735b180f2bf40883e66220/packages/zod/src/v4/core/function.ts#L48
35
+ if ("def" in schema && typeof schema.def !== "object" && schema.def) {
36
+ if (schema.def?.type === "function") {
37
+ return true;
38
+ }
39
+ }
40
+ // We're casting as string here because zod 4.0 types don't include "function"
41
+ // literal in the union for `_zod.def.type`. The optional chaining is because
42
+ // _zod does not exist on zod 4 objects from zod 3.
43
+ return schema._zod?.def?.type === "function";
32
44
  }
33
45
  /**
34
46
  * Checks if a schema is a Zod function schema (Zod 3 or Zod 4).
@@ -39,17 +51,17 @@ function isZodFunctionSchema(schema) {
39
51
  return isZod3FunctionSchema(schema) || isZod4FunctionSchema(schema);
40
52
  }
41
53
  /**
42
- * Extracts the args schema from a Zod 3 function schema.
43
- * @param schema - The Zod 3 function schema
44
- * @returns The args schema, or undefined if not a Zod 3 function schema
54
+ * Extracts the args schema from a Zod function schema.
55
+ * @param schema - The Zod function schema
56
+ * @returns The args schema, or undefined if not a Zod function schema
45
57
  */
46
58
  function getZodFunctionArgs(schema) {
47
59
  if (isZod3FunctionSchema(schema)) {
48
60
  return schema._def.args;
49
61
  }
50
62
  if (isZod4FunctionSchema(schema)) {
51
- // @ts-expect-error -- Error in Zod types for v3 vs v4
52
- return schema._zod.def.input;
63
+ // @ts-expect-error -- Error in Zod types for v3 vs v4.0
64
+ return schema?.def?.input ?? schema._zod?.def?.input;
53
65
  }
54
66
  throw new Error("Unable to determine parameters from zod function schema");
55
67
  }
@@ -75,7 +87,7 @@ function getZodFunctionReturns(schema) {
75
87
  * @returns The JSON Schema representation
76
88
  */
77
89
  function handleZodSchemaToJson(schema) {
78
- // Detect Zod 4 by checking for def.type
90
+ // If Zod4 schema detected, use the toJSONSchema function from "zod/v4/core"
79
91
  if (isZod4Schema(schema))
80
92
  return (0, core_1.toJSONSchema)(schema);
81
93
  try {
@@ -91,38 +103,21 @@ function handleZodSchemaToJson(schema) {
91
103
  });
92
104
  }
93
105
  }
94
- // Zod 3 schemas have _def with typeName and ~standard with vendor "zod"
95
- // Use looseObject to allow any _def shape (different for each type)
96
- const zod3SchemaType = zodInternalAlias_1.z.object({
97
- _def: zodInternalAlias_1.z.looseObject({
98
- typeName: zodInternalAlias_1.z.string().optional(),
99
- }),
100
- "~standard": zodInternalAlias_1.z.looseObject({
101
- vendor: zodInternalAlias_1.z.literal("zod"),
102
- }),
103
- });
104
106
  /**
105
107
  * Checks if a schema is probably a Zod 3 schema.
106
108
  * @param schema - The schema to check
107
109
  * @returns True if the schema looks like a Zod 3 schema
108
110
  */
109
111
  function isZod3Schema(schema) {
110
- return zod3SchemaType.safeParse(schema).success;
112
+ return isZodSchema(schema) && "_def" in schema;
111
113
  }
112
- const zod4SchemaType = zodInternalAlias_1.z.object({
113
- def: zodInternalAlias_1.z.object(),
114
- _zod: zodInternalAlias_1.z.looseObject({
115
- def: zodInternalAlias_1.z.looseObject({}),
116
- }),
117
- "~standard": zodInternalAlias_1.z.looseObject({}),
118
- });
119
114
  /**
120
115
  * Detects if a schema is Zod 4 by checking for def.type property.
121
116
  * Zod 4 uses `def.type` with lowercase type names like "object", "string".
122
117
  * @returns True if the schema appears to be Zod 4 style
123
118
  */
124
119
  function isZod4Schema(schema) {
125
- return zod4SchemaType.safeParse(schema).success;
120
+ return isZodSchema(schema) && "_zod" in schema;
126
121
  }
127
122
  /**
128
123
  * Checks if a schema is a Zod schema
@@ -130,6 +125,24 @@ function isZod4Schema(schema) {
130
125
  * @returns True if the schema is a Zod schema
131
126
  */
132
127
  function isZodSchema(schema) {
133
- return isZod3Schema(schema) || isZod4Schema(schema);
128
+ // schema must be { ~standard: { vendor: "zod" } }
129
+ if (typeof schema !== "object")
130
+ return false;
131
+ if (!schema)
132
+ return false;
133
+ if (!("~standard" in schema))
134
+ return false;
135
+ if (!schema["~standard"])
136
+ return false;
137
+ if (typeof schema["~standard"] !== "object")
138
+ return false;
139
+ if (!("vendor" in schema["~standard"]))
140
+ return false;
141
+ if (schema["~standard"].vendor !== "zod")
142
+ return false;
143
+ // Require at least one internal marker to reduce false positives
144
+ const looksLikeV3 = "_def" in schema;
145
+ const looksLikeV4 = "_zod" in schema || "def" in schema;
146
+ return looksLikeV3 || looksLikeV4;
134
147
  }
135
148
  //# sourceMappingURL=zod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/schema/zod.ts"],"names":[],"mappings":";;AAiBA,oDAQC;AAKD,oDAOC;AAOD,kDAEC;AAOD,gDAWC;AAOD,sDAWC;AAQD,sDAkBC;AAkBD,oCAEC;AAeD,oCAEC;AAOD,kCAIC;AArJD,sCAIqB;AACrB,uDAAqC;AAErC;;GAEG;AACH,SAAgB,oBAAoB,CAClC,MAAe;IAEf,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,UAAU,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,aAAa,CAAC;AAC7E,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAe;IAClD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,sDAAsD;IACtD,OAAO,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,MAAe;IACjD,OAAO,oBAAoB,CAAC,MAAM,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,MAAe;IAChD,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,sDAAsD;QACtD,OAAO,MAAM,CAAC,IAAI,CAA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AAC;CACH,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,YAAY,CAAC,MAAe;IAC1C,OAAO,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAClD,CAAC;AAED,MAAM,cAAc,GAAG,oBAAC,CAAC,MAAM,CAAC;IAC9B,GAAG,EAAE,oBAAC,CAAC,MAAM,EAAE;IACf,IAAI,EAAE,oBAAC,CAAC,WAAW,CAAC;QAClB,GAAG,EAAE,oBAAC,CAAC,WAAW,CAAC,EAAE,CAAC;KACvB,CAAC;IACF,WAAW,EAAE,oBAAC,CAAC,WAAW,CAAC,EAAE,CAAC;CAC/B,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,YAAY,CAAC,MAAe;IAC1C,OAAO,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CACzB,MAAe;IAEf,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {\n ZodFunction,\n ZodTuple,\n ZodTupleItems,\n ZodType,\n ZodTypeAny,\n} from \"zod/v3\";\nimport {\n $ZodFunction,\n $ZodType,\n toJSONSchema as zod4ToJSONSchema,\n} from \"zod/v4/core\";\nimport { z } from \"zodInternalAlias\";\n\n/**\n * @returns True if the schema is a Zod 3 function schema\n */\nexport function isZod3FunctionSchema(\n schema: unknown,\n): schema is ZodFunction<ZodTuple<ZodTupleItems, any>, ZodTypeAny> {\n if (!isZod3Schema(schema)) {\n return false;\n }\n\n return \"typeName\" in schema._def && schema._def.typeName === \"ZodFunction\";\n}\n\n/**\n * @returns True if the schema is a Zod 4 function schema\n */\nexport function isZod4FunctionSchema(schema: unknown): schema is $ZodFunction {\n if (!isZod4Schema(schema)) {\n return false;\n }\n\n // @ts-expect-error -- Error in Zod types for v3 vs v4\n return \"def\" in schema && schema._zod.def.type === \"function\";\n}\n\n/**\n * Checks if a schema is a Zod function schema (Zod 3 or Zod 4).\n * @param schema - The schema to check\n * @returns True if the schema is a Zod function schema\n */\nexport function isZodFunctionSchema(schema: unknown) {\n return isZod3FunctionSchema(schema) || isZod4FunctionSchema(schema);\n}\n\n/**\n * Extracts the args schema from a Zod 3 function schema.\n * @param schema - The Zod 3 function schema\n * @returns The args schema, or undefined if not a Zod 3 function schema\n */\nexport function getZodFunctionArgs(schema: unknown) {\n if (isZod3FunctionSchema(schema)) {\n return schema._def.args;\n }\n\n if (isZod4FunctionSchema(schema)) {\n // @ts-expect-error -- Error in Zod types for v3 vs v4\n return schema._zod.def.input;\n }\n\n throw new Error(\"Unable to determine parameters from zod function schema\");\n}\n\n/**\n * Extracts the return schema from a Zod 3 or Zod 4 function schema.\n * @param schema - The Zod function schema\n * @returns The return schema, or undefined if not a Zod function schema\n */\nexport function getZodFunctionReturns(schema: unknown) {\n if (isZod3FunctionSchema(schema)) {\n return schema._def.returns;\n }\n\n if (isZod4FunctionSchema(schema)) {\n // @ts-expect-error -- Error in Zod types for v3 vs v4\n return schema._zod.def.output;\n }\n\n throw new Error(\"Unable to determine return type from zod function schema\");\n}\n\n/**\n * Handles conversion of Zod schemas to JSON Schema.\n * Supports both Zod 3 (via zod-to-json-schema) and Zod 4 (native).\n * @param schema - The Zod schema to convert\n * @returns The JSON Schema representation\n */\nexport function handleZodSchemaToJson(schema: unknown) {\n // Detect Zod 4 by checking for def.type\n if (isZod4Schema(schema)) return zod4ToJSONSchema(schema);\n\n try {\n // Dynamic require for optional peer dependency\n // eslint-disable-next-line @typescript-eslint/no-require-imports -- need require because zod-to-json-schema may be missing\n const { zodToJsonSchema } = require(\"zod-to-json-schema\");\n return zodToJsonSchema(schema);\n } catch (error) {\n throw new Error(\n \"Zod 3 requires 'zod-to-json-schema' package for JSON Schema conversion. \" +\n \"Install it with: npm install zod-to-json-schema\",\n {\n cause: error,\n },\n );\n }\n}\n\n// Zod 3 schemas have _def with typeName and ~standard with vendor \"zod\"\n// Use looseObject to allow any _def shape (different for each type)\nconst zod3SchemaType = z.object({\n _def: z.looseObject({\n typeName: z.string().optional(),\n }),\n \"~standard\": z.looseObject({\n vendor: z.literal(\"zod\"),\n }),\n});\n\n/**\n * Checks if a schema is probably a Zod 3 schema.\n * @param schema - The schema to check\n * @returns True if the schema looks like a Zod 3 schema\n */\nexport function isZod3Schema(schema: unknown): schema is ZodType {\n return zod3SchemaType.safeParse(schema).success;\n}\n\nconst zod4SchemaType = z.object({\n def: z.object(),\n _zod: z.looseObject({\n def: z.looseObject({}),\n }),\n \"~standard\": z.looseObject({}),\n});\n\n/**\n * Detects if a schema is Zod 4 by checking for def.type property.\n * Zod 4 uses `def.type` with lowercase type names like \"object\", \"string\".\n * @returns True if the schema appears to be Zod 4 style\n */\nexport function isZod4Schema(schema: unknown): schema is $ZodType {\n return zod4SchemaType.safeParse(schema).success;\n}\n\n/**\n * Checks if a schema is a Zod schema\n * @param schema - The schema to check\n * @returns True if the schema is a Zod schema\n */\nexport function isZodSchema(\n schema: unknown,\n): ReturnType<typeof isZod3Schema> | ReturnType<typeof isZod4Schema> {\n return isZod3Schema(schema) || isZod4Schema(schema);\n}\n"]}
1
+ {"version":3,"file":"zod.js","sourceRoot":"","sources":["../../src/schema/zod.ts"],"names":[],"mappings":";;AAgBA,oDAUC;AAKD,oDAoBC;AAOD,kDAEC;AAOD,gDAWC;AAOD,sDAWC;AAQD,sDAkBC;AAOD,oCAEC;AAOD,oCAEC;AAOD,kCAcC;AA1JD,sCAIqB;AAErB;;GAEG;AACH,SAAgB,oBAAoB,CAClC,MAAe;IAEf,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAEvC,OAAO,CACL,MAAM,IAAI,MAAM;QAChB,UAAU,IAAI,MAAM,CAAC,IAAI;QACzB,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,aAAa,CACvC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAA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vC,IAAI,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAEvD,iEAAiE;IACjE,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,CAAC;IACrC,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;IACxD,OAAO,WAAW,IAAI,WAAW,CAAC;AACpC,CAAC","sourcesContent":["import {\n ZodFunction,\n ZodTuple,\n ZodTupleItems,\n ZodType,\n ZodTypeAny,\n} from \"zod/v3\";\nimport {\n $ZodFunction,\n $ZodType,\n toJSONSchema as zod4ToJSONSchema,\n} from \"zod/v4/core\";\n\n/**\n * @returns True if the schema is a Zod 3 function schema\n */\nexport function isZod3FunctionSchema(\n schema: unknown,\n): schema is ZodFunction<ZodTuple<ZodTupleItems, any>, ZodTypeAny> {\n if (!isZodSchema(schema)) return false;\n\n return (\n \"_def\" in schema &&\n \"typeName\" in schema._def &&\n schema._def.typeName === \"ZodFunction\"\n );\n}\n\n/**\n * @returns True if the schema is a Zod 4 function schema\n */\nexport function isZod4FunctionSchema(schema: unknown): schema is $ZodFunction {\n if (!isZod4Schema(schema)) {\n return false;\n }\n\n // $ZodFunctions in zod 4.0 most certainly do have .def.type === \"function\"\n // but the type definitions do not reflect this because $ZodFunction does not\n // extend $ZodType. This is corrected in zod 4.1, but zod 3 does not include\n // the types for 4.1 yet (and might not ever).\n // See: https://github.com/colinhacks/zod/blob/463f03eb8183dcdcdf735b180f2bf40883e66220/packages/zod/src/v4/core/function.ts#L48\n if (\"def\" in schema && typeof schema.def !== \"object\" && schema.def) {\n if ((schema.def as { type: string })?.type === \"function\") {\n return true;\n }\n }\n\n // We're casting as string here because zod 4.0 types don't include \"function\"\n // literal in the union for `_zod.def.type`. The optional chaining is because\n // _zod does not exist on zod 4 objects from zod 3.\n return (schema._zod?.def?.type as string) === \"function\";\n}\n\n/**\n * Checks if a schema is a Zod function schema (Zod 3 or Zod 4).\n * @param schema - The schema to check\n * @returns True if the schema is a Zod function schema\n */\nexport function isZodFunctionSchema(schema: unknown) {\n return isZod3FunctionSchema(schema) || isZod4FunctionSchema(schema);\n}\n\n/**\n * Extracts the args schema from a Zod function schema.\n * @param schema - The Zod function schema\n * @returns The args schema, or undefined if not a Zod function schema\n */\nexport function getZodFunctionArgs(schema: unknown) {\n if (isZod3FunctionSchema(schema)) {\n return schema._def.args;\n }\n\n if (isZod4FunctionSchema(schema)) {\n // @ts-expect-error -- Error in Zod types for v3 vs v4.0\n return schema?.def?.input ?? schema._zod?.def?.input;\n }\n\n throw new Error(\"Unable to determine parameters from zod function schema\");\n}\n\n/**\n * Extracts the return schema from a Zod 3 or Zod 4 function schema.\n * @param schema - The Zod function schema\n * @returns The return schema, or undefined if not a Zod function schema\n */\nexport function getZodFunctionReturns(schema: unknown) {\n if (isZod3FunctionSchema(schema)) {\n return schema._def.returns;\n }\n\n if (isZod4FunctionSchema(schema)) {\n // @ts-expect-error -- Error in Zod types for v3 vs v4\n return schema._zod.def.output;\n }\n\n throw new Error(\"Unable to determine return type from zod function schema\");\n}\n\n/**\n * Handles conversion of Zod schemas to JSON Schema.\n * Supports both Zod 3 (via zod-to-json-schema) and Zod 4 (native).\n * @param schema - The Zod schema to convert\n * @returns The JSON Schema representation\n */\nexport function handleZodSchemaToJson(schema: unknown) {\n // If Zod4 schema detected, use the toJSONSchema function from \"zod/v4/core\"\n if (isZod4Schema(schema)) return zod4ToJSONSchema(schema);\n\n try {\n // Dynamic require for optional peer dependency\n // eslint-disable-next-line @typescript-eslint/no-require-imports -- need require because zod-to-json-schema may be missing\n const { zodToJsonSchema } = require(\"zod-to-json-schema\");\n return zodToJsonSchema(schema);\n } catch (error) {\n throw new Error(\n \"Zod 3 requires 'zod-to-json-schema' package for JSON Schema conversion. \" +\n \"Install it with: npm install zod-to-json-schema\",\n {\n cause: error,\n },\n );\n }\n}\n\n/**\n * Checks if a schema is probably a Zod 3 schema.\n * @param schema - The schema to check\n * @returns True if the schema looks like a Zod 3 schema\n */\nexport function isZod3Schema(schema: unknown): schema is ZodType {\n return isZodSchema(schema) && \"_def\" in schema;\n}\n\n/**\n * Detects if a schema is Zod 4 by checking for def.type property.\n * Zod 4 uses `def.type` with lowercase type names like \"object\", \"string\".\n * @returns True if the schema appears to be Zod 4 style\n */\nexport function isZod4Schema(schema: unknown): schema is $ZodType {\n return isZodSchema(schema) && \"_zod\" in schema;\n}\n\n/**\n * Checks if a schema is a Zod schema\n * @param schema - The schema to check\n * @returns True if the schema is a Zod schema\n */\nexport function isZodSchema(schema: unknown): schema is ZodType | $ZodType {\n // schema must be { ~standard: { vendor: \"zod\" } }\n if (typeof schema !== \"object\") return false;\n if (!schema) return false;\n if (!(\"~standard\" in schema)) return false;\n if (!schema[\"~standard\"]) return false;\n if (typeof schema[\"~standard\"] !== \"object\") return false;\n if (!(\"vendor\" in schema[\"~standard\"])) return false;\n if (schema[\"~standard\"].vendor !== \"zod\") return false;\n\n // Require at least one internal marker to reduce false positives\n const looksLikeV3 = \"_def\" in schema;\n const looksLikeV4 = \"_zod\" in schema || \"def\" in schema;\n return looksLikeV3 || looksLikeV4;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"registry-validators.d.ts","sourceRoot":"","sources":["../../src/util/registry-validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAWrC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,uBAAuB,GAAG,IAAI,CAqB5E;AA0CD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,cAAc,GAAG;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CA6BA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,OAAO,GAClB,IAAI,CAWN"}
1
+ {"version":3,"file":"registry-validators.d.ts","sourceRoot":"","sources":["../../src/util/registry-validators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAoDrC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,uBAAuB,GAAG,IAAI,CAuB5E;AA0CD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,cAAc,GAAG;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CA6BA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,OAAO,GAClB,IAAI,CAWN"}
@@ -6,6 +6,44 @@ exports.validateToolAssociation = validateToolAssociation;
6
6
  const schema_1 = require("../schema");
7
7
  const zod_1 = require("../schema/zod");
8
8
  const validate_component_name_1 = require("./validate-component-name");
9
+ /**
10
+ * Checks if a JSON Schema represents an object type.
11
+ * @param schema - The JSON Schema to check
12
+ * @returns True if the schema is an object type
13
+ */
14
+ function isObjectSchema(schema) {
15
+ return schema.type === "object" || schema.properties !== undefined;
16
+ }
17
+ /**
18
+ * Validates that a schema is an object type.
19
+ * Throws an error if it's not.
20
+ * @param schema - The schema to validate (Standard Schema or JSON Schema)
21
+ * @param context - Description of where the schema is used (for error messages)
22
+ */
23
+ function assertObjectSchema(schema, context) {
24
+ let jsonSchema;
25
+ if ((0, schema_1.isStandardSchema)(schema)) {
26
+ try {
27
+ jsonSchema = (0, schema_1.schemaToJsonSchema)(schema);
28
+ }
29
+ catch {
30
+ // If conversion fails, we can't validate - let it fail later
31
+ return;
32
+ }
33
+ }
34
+ else if ((0, schema_1.looksLikeJSONSchema)(schema)) {
35
+ jsonSchema = schema;
36
+ }
37
+ else {
38
+ // Unknown schema type, can't validate
39
+ return;
40
+ }
41
+ if (!isObjectSchema(jsonSchema)) {
42
+ throw new Error(`${context} must be an object schema (e.g., z.object({...})). ` +
43
+ `Received type: "${jsonSchema.type ?? "unknown"}". ` +
44
+ `Tool parameters are passed as a single object argument.`);
45
+ }
46
+ }
9
47
  /**
10
48
  * Validates a tool before registration.
11
49
  * Throws an error if the tool is invalid.
@@ -17,6 +55,8 @@ function validateTool(tool) {
17
55
  // Validate tool schemas
18
56
  // 1. check inputSchema
19
57
  if ("inputSchema" in tool && tool.inputSchema) {
58
+ // inputSchema must be an object schema
59
+ assertObjectSchema(tool.inputSchema, `inputSchema of tool "${tool.name}"`);
20
60
  (0, schema_1.assertNoRecordSchema)(tool.inputSchema, `inputSchema of tool "${tool.name}"`);
21
61
  }
22
62
  // 2. check deprecated toolSchema