@tambo-ai/react 0.69.1 → 0.71.0
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.
- package/README.md +7 -7
- package/dist/hooks/use-tambo-threads.test.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -5
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +4 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/model/component-metadata.d.ts +88 -241
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/mcp-server-info.d.ts +3 -3
- package/dist/model/mcp-server-info.js.map +1 -1
- package/dist/providers/hooks/use-tambo-session-token.test.js.map +1 -1
- package/dist/providers/tambo-component-provider.d.ts +2 -2
- package/dist/providers/tambo-component-provider.d.ts.map +1 -1
- package/dist/providers/tambo-component-provider.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +4 -4
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +11 -8
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +31 -0
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +42 -52
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/providers/tambo-stubs.d.ts +2 -2
- package/dist/providers/tambo-stubs.d.ts.map +1 -1
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/dist/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js +107 -141
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +274 -445
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/index.d.ts +1 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -5
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/schema.d.ts +7 -24
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +34 -105
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/schema.test.js +26 -124
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/testing/tools.d.ts +2 -12
- package/dist/testing/tools.d.ts.map +1 -1
- package/dist/testing/tools.js +1 -20
- package/dist/testing/tools.js.map +1 -1
- package/dist/testing/types.d.ts +2 -2
- package/dist/testing/types.d.ts.map +1 -1
- package/dist/testing/types.js.map +1 -1
- package/dist/util/registry-validators.d.ts +2 -2
- package/dist/util/registry-validators.d.ts.map +1 -1
- package/dist/util/registry-validators.js +37 -17
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/util/registry-validators.test.js +64 -25
- package/dist/util/registry-validators.test.js.map +1 -1
- package/dist/util/registry.d.ts +4 -10
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +6 -22
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.js +1 -47
- package/dist/util/registry.test.js.map +1 -1
- package/dist/util/tool-caller.d.ts +2 -2
- package/dist/util/tool-caller.d.ts.map +1 -1
- package/dist/util/tool-caller.js +5 -12
- package/dist/util/tool-caller.js.map +1 -1
- package/dist/v1/hooks/use-tambo-v1-messages.d.ts +58 -0
- package/dist/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-messages.js +54 -0
- package/dist/v1/hooks/use-tambo-v1-messages.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-messages.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1-messages.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-messages.test.js +137 -0
- package/dist/v1/hooks/use-tambo-v1-messages.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts +96 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.js +227 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js +827 -0
- package/dist/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts +61 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.js +56 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js +98 -0
- package/dist/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts +37 -0
- package/dist/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread.js +49 -0
- package/dist/v1/hooks/use-tambo-v1-thread.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1-thread.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1-thread.test.js +83 -0
- package/dist/v1/hooks/use-tambo-v1-thread.test.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1.d.ts +107 -0
- package/dist/v1/hooks/use-tambo-v1.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1.js +87 -0
- package/dist/v1/hooks/use-tambo-v1.js.map +1 -0
- package/dist/v1/hooks/use-tambo-v1.test.d.ts +2 -0
- package/dist/v1/hooks/use-tambo-v1.test.d.ts.map +1 -0
- package/dist/v1/hooks/use-tambo-v1.test.js +150 -0
- package/dist/v1/hooks/use-tambo-v1.test.js.map +1 -0
- package/dist/v1/index.d.ts +73 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +106 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/providers/tambo-v1-provider.d.ts +91 -0
- package/dist/v1/providers/tambo-v1-provider.d.ts.map +1 -0
- package/dist/v1/providers/tambo-v1-provider.js +110 -0
- package/dist/v1/providers/tambo-v1-provider.js.map +1 -0
- package/dist/v1/providers/tambo-v1-provider.test.d.ts +2 -0
- package/dist/v1/providers/tambo-v1-provider.test.d.ts.map +1 -0
- package/dist/v1/providers/tambo-v1-provider.test.js +123 -0
- package/dist/v1/providers/tambo-v1-provider.test.js.map +1 -0
- package/dist/v1/providers/tambo-v1-stream-context.d.ts +136 -0
- package/dist/v1/providers/tambo-v1-stream-context.d.ts.map +1 -0
- package/dist/v1/providers/tambo-v1-stream-context.js +230 -0
- package/dist/v1/providers/tambo-v1-stream-context.js.map +1 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.d.ts +2 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.d.ts.map +1 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.js +85 -0
- package/dist/v1/providers/tambo-v1-stream-context.test.js.map +1 -0
- package/dist/v1/types/component.d.ts +50 -0
- package/dist/v1/types/component.d.ts.map +1 -0
- package/dist/v1/types/component.js +14 -0
- package/dist/v1/types/component.js.map +1 -0
- package/dist/v1/types/event.d.ts +72 -0
- package/dist/v1/types/event.d.ts.map +1 -0
- package/dist/v1/types/event.js +54 -0
- package/dist/v1/types/event.js.map +1 -0
- package/dist/v1/types/event.test.d.ts +2 -0
- package/dist/v1/types/event.test.d.ts.map +1 -0
- package/dist/v1/types/event.test.js +70 -0
- package/dist/v1/types/event.test.js.map +1 -0
- package/dist/v1/types/message.d.ts +35 -0
- package/dist/v1/types/message.d.ts.map +1 -0
- package/dist/v1/types/message.js +10 -0
- package/dist/v1/types/message.js.map +1 -0
- package/dist/v1/types/thread.d.ts +52 -0
- package/dist/v1/types/thread.d.ts.map +1 -0
- package/dist/v1/types/thread.js +9 -0
- package/dist/v1/types/thread.js.map +1 -0
- package/dist/v1/utils/event-accumulator.d.ts +100 -0
- package/dist/v1/utils/event-accumulator.d.ts.map +1 -0
- package/dist/v1/utils/event-accumulator.js +715 -0
- package/dist/v1/utils/event-accumulator.js.map +1 -0
- package/dist/v1/utils/event-accumulator.test.d.ts +2 -0
- package/dist/v1/utils/event-accumulator.test.d.ts.map +1 -0
- package/dist/v1/utils/event-accumulator.test.js +1010 -0
- package/dist/v1/utils/event-accumulator.test.js.map +1 -0
- package/dist/v1/utils/json-patch.d.ts +18 -0
- package/dist/v1/utils/json-patch.d.ts.map +1 -0
- package/dist/v1/utils/json-patch.js +35 -0
- package/dist/v1/utils/json-patch.js.map +1 -0
- package/dist/v1/utils/json-patch.test.d.ts +2 -0
- package/dist/v1/utils/json-patch.test.d.ts.map +1 -0
- package/dist/v1/utils/json-patch.test.js +28 -0
- package/dist/v1/utils/json-patch.test.js.map +1 -0
- package/dist/v1/utils/registry-conversion.d.ts +53 -0
- package/dist/v1/utils/registry-conversion.d.ts.map +1 -0
- package/dist/v1/utils/registry-conversion.js +114 -0
- package/dist/v1/utils/registry-conversion.js.map +1 -0
- package/dist/v1/utils/registry-conversion.test.d.ts +2 -0
- package/dist/v1/utils/registry-conversion.test.d.ts.map +1 -0
- package/dist/v1/utils/registry-conversion.test.js +179 -0
- package/dist/v1/utils/registry-conversion.test.js.map +1 -0
- package/dist/v1/utils/stream-handler.d.ts +45 -0
- package/dist/v1/utils/stream-handler.d.ts.map +1 -0
- package/dist/v1/utils/stream-handler.js +47 -0
- package/dist/v1/utils/stream-handler.js.map +1 -0
- package/dist/v1/utils/stream-handler.test.d.ts +2 -0
- package/dist/v1/utils/stream-handler.test.d.ts.map +1 -0
- package/dist/v1/utils/stream-handler.test.js +74 -0
- package/dist/v1/utils/stream-handler.test.js.map +1 -0
- package/dist/v1/utils/tool-call-tracker.d.ts +41 -0
- package/dist/v1/utils/tool-call-tracker.d.ts.map +1 -0
- package/dist/v1/utils/tool-call-tracker.js +90 -0
- package/dist/v1/utils/tool-call-tracker.js.map +1 -0
- package/dist/v1/utils/tool-executor.d.ts +33 -0
- package/dist/v1/utils/tool-executor.d.ts.map +1 -0
- package/dist/v1/utils/tool-executor.js +103 -0
- package/dist/v1/utils/tool-executor.js.map +1 -0
- package/dist/v1/utils/tool-executor.test.d.ts +2 -0
- package/dist/v1/utils/tool-executor.test.d.ts.map +1 -0
- package/dist/v1/utils/tool-executor.test.js +222 -0
- package/dist/v1/utils/tool-executor.test.js.map +1 -0
- package/esm/hooks/use-tambo-threads.test.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/mcp/index.d.ts +4 -5
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +4 -5
- package/esm/mcp/index.js.map +1 -1
- package/esm/model/component-metadata.d.ts +88 -241
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/mcp-server-info.d.ts +3 -3
- package/esm/model/mcp-server-info.js.map +1 -1
- package/esm/providers/hooks/use-tambo-session-token.test.js.map +1 -1
- package/esm/providers/tambo-component-provider.d.ts +2 -2
- package/esm/providers/tambo-component-provider.d.ts.map +1 -1
- package/esm/providers/tambo-component-provider.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +4 -4
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +11 -8
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +31 -0
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +42 -52
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/providers/tambo-stubs.d.ts +2 -2
- package/esm/providers/tambo-stubs.d.ts.map +1 -1
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/esm/providers/tambo-thread-provider-initial-messages.test.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js +107 -141
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +241 -445
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/index.d.ts +1 -2
- package/esm/schema/index.d.ts.map +1 -1
- package/esm/schema/index.js +1 -2
- package/esm/schema/index.js.map +1 -1
- package/esm/schema/schema.d.ts +7 -24
- package/esm/schema/schema.d.ts.map +1 -1
- package/esm/schema/schema.js +34 -103
- package/esm/schema/schema.js.map +1 -1
- package/esm/schema/schema.test.js +27 -125
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/testing/tools.d.ts +2 -12
- package/esm/testing/tools.d.ts.map +1 -1
- package/esm/testing/tools.js +2 -20
- package/esm/testing/tools.js.map +1 -1
- package/esm/testing/types.d.ts +2 -2
- package/esm/testing/types.d.ts.map +1 -1
- package/esm/testing/types.js.map +1 -1
- package/esm/util/registry-validators.d.ts +2 -2
- package/esm/util/registry-validators.d.ts.map +1 -1
- package/esm/util/registry-validators.js +38 -18
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/util/registry-validators.test.js +64 -25
- package/esm/util/registry-validators.test.js.map +1 -1
- package/esm/util/registry.d.ts +4 -10
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +7 -22
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.js +3 -49
- package/esm/util/registry.test.js.map +1 -1
- package/esm/util/tool-caller.d.ts +2 -2
- package/esm/util/tool-caller.d.ts.map +1 -1
- package/esm/util/tool-caller.js +5 -12
- package/esm/util/tool-caller.js.map +1 -1
- package/esm/v1/hooks/use-tambo-v1-messages.d.ts +58 -0
- package/esm/v1/hooks/use-tambo-v1-messages.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-messages.js +51 -0
- package/esm/v1/hooks/use-tambo-v1-messages.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-messages.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1-messages.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-messages.test.js +132 -0
- package/esm/v1/hooks/use-tambo-v1-messages.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts +96 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.js +223 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js +822 -0
- package/esm/v1/hooks/use-tambo-v1-send-message.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts +61 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.js +53 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js +93 -0
- package/esm/v1/hooks/use-tambo-v1-thread-list.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts +37 -0
- package/esm/v1/hooks/use-tambo-v1-thread.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread.js +46 -0
- package/esm/v1/hooks/use-tambo-v1-thread.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1-thread.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1-thread.test.js +78 -0
- package/esm/v1/hooks/use-tambo-v1-thread.test.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1.d.ts +107 -0
- package/esm/v1/hooks/use-tambo-v1.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1.js +84 -0
- package/esm/v1/hooks/use-tambo-v1.js.map +1 -0
- package/esm/v1/hooks/use-tambo-v1.test.d.ts +2 -0
- package/esm/v1/hooks/use-tambo-v1.test.d.ts.map +1 -0
- package/esm/v1/hooks/use-tambo-v1.test.js +145 -0
- package/esm/v1/hooks/use-tambo-v1.test.js.map +1 -0
- package/esm/v1/index.d.ts +73 -0
- package/esm/v1/index.d.ts.map +1 -0
- package/esm/v1/index.js +83 -0
- package/esm/v1/index.js.map +1 -0
- package/esm/v1/providers/tambo-v1-provider.d.ts +91 -0
- package/esm/v1/providers/tambo-v1-provider.d.ts.map +1 -0
- package/esm/v1/providers/tambo-v1-provider.js +74 -0
- package/esm/v1/providers/tambo-v1-provider.js.map +1 -0
- package/esm/v1/providers/tambo-v1-provider.test.d.ts +2 -0
- package/esm/v1/providers/tambo-v1-provider.test.d.ts.map +1 -0
- package/esm/v1/providers/tambo-v1-provider.test.js +118 -0
- package/esm/v1/providers/tambo-v1-provider.test.js.map +1 -0
- package/esm/v1/providers/tambo-v1-stream-context.d.ts +136 -0
- package/esm/v1/providers/tambo-v1-stream-context.d.ts.map +1 -0
- package/esm/v1/providers/tambo-v1-stream-context.js +191 -0
- package/esm/v1/providers/tambo-v1-stream-context.js.map +1 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.d.ts +2 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.d.ts.map +1 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.js +80 -0
- package/esm/v1/providers/tambo-v1-stream-context.test.js.map +1 -0
- package/esm/v1/types/component.d.ts +50 -0
- package/esm/v1/types/component.d.ts.map +1 -0
- package/esm/v1/types/component.js +13 -0
- package/esm/v1/types/component.js.map +1 -0
- package/esm/v1/types/event.d.ts +72 -0
- package/esm/v1/types/event.d.ts.map +1 -0
- package/esm/v1/types/event.js +50 -0
- package/esm/v1/types/event.js.map +1 -0
- package/esm/v1/types/event.test.d.ts +2 -0
- package/esm/v1/types/event.test.d.ts.map +1 -0
- package/esm/v1/types/event.test.js +68 -0
- package/esm/v1/types/event.test.js.map +1 -0
- package/esm/v1/types/message.d.ts +35 -0
- package/esm/v1/types/message.d.ts.map +1 -0
- package/esm/v1/types/message.js +9 -0
- package/esm/v1/types/message.js.map +1 -0
- package/esm/v1/types/thread.d.ts +52 -0
- package/esm/v1/types/thread.d.ts.map +1 -0
- package/esm/v1/types/thread.js +8 -0
- package/esm/v1/types/thread.js.map +1 -0
- package/esm/v1/utils/event-accumulator.d.ts +100 -0
- package/esm/v1/utils/event-accumulator.d.ts.map +1 -0
- package/esm/v1/utils/event-accumulator.js +708 -0
- package/esm/v1/utils/event-accumulator.js.map +1 -0
- package/esm/v1/utils/event-accumulator.test.d.ts +2 -0
- package/esm/v1/utils/event-accumulator.test.d.ts.map +1 -0
- package/esm/v1/utils/event-accumulator.test.js +1008 -0
- package/esm/v1/utils/event-accumulator.test.js.map +1 -0
- package/esm/v1/utils/json-patch.d.ts +18 -0
- package/esm/v1/utils/json-patch.d.ts.map +1 -0
- package/esm/v1/utils/json-patch.js +32 -0
- package/esm/v1/utils/json-patch.js.map +1 -0
- package/esm/v1/utils/json-patch.test.d.ts +2 -0
- package/esm/v1/utils/json-patch.test.d.ts.map +1 -0
- package/esm/v1/utils/json-patch.test.js +26 -0
- package/esm/v1/utils/json-patch.test.js.map +1 -0
- package/esm/v1/utils/registry-conversion.d.ts +53 -0
- package/esm/v1/utils/registry-conversion.d.ts.map +1 -0
- package/esm/v1/utils/registry-conversion.js +108 -0
- package/esm/v1/utils/registry-conversion.js.map +1 -0
- package/esm/v1/utils/registry-conversion.test.d.ts +2 -0
- package/esm/v1/utils/registry-conversion.test.d.ts.map +1 -0
- package/esm/v1/utils/registry-conversion.test.js +177 -0
- package/esm/v1/utils/registry-conversion.test.js.map +1 -0
- package/esm/v1/utils/stream-handler.d.ts +45 -0
- package/esm/v1/utils/stream-handler.d.ts.map +1 -0
- package/esm/v1/utils/stream-handler.js +44 -0
- package/esm/v1/utils/stream-handler.js.map +1 -0
- package/esm/v1/utils/stream-handler.test.d.ts +2 -0
- package/esm/v1/utils/stream-handler.test.d.ts.map +1 -0
- package/esm/v1/utils/stream-handler.test.js +72 -0
- package/esm/v1/utils/stream-handler.test.js.map +1 -0
- package/esm/v1/utils/tool-call-tracker.d.ts +41 -0
- package/esm/v1/utils/tool-call-tracker.d.ts.map +1 -0
- package/esm/v1/utils/tool-call-tracker.js +86 -0
- package/esm/v1/utils/tool-call-tracker.js.map +1 -0
- package/esm/v1/utils/tool-executor.d.ts +33 -0
- package/esm/v1/utils/tool-executor.d.ts.map +1 -0
- package/esm/v1/utils/tool-executor.js +99 -0
- package/esm/v1/utils/tool-executor.js.map +1 -0
- package/esm/v1/utils/tool-executor.test.d.ts +2 -0
- package/esm/v1/utils/tool-executor.test.d.ts.map +1 -0
- package/esm/v1/utils/tool-executor.test.js +220 -0
- package/esm/v1/utils/tool-executor.test.js.map +1 -0
- package/package.json +20 -9
- package/dist/schema/zod.d.ts +0 -57
- package/dist/schema/zod.d.ts.map +0 -1
- package/dist/schema/zod.js +0 -191
- package/dist/schema/zod.js.map +0 -1
- package/dist/schema/zod.test.d.ts +0 -2
- package/dist/schema/zod.test.d.ts.map +0 -1
- package/dist/schema/zod.test.js +0 -663
- package/dist/schema/zod.test.js.map +0 -1
- package/esm/schema/zod.d.ts +0 -57
- package/esm/schema/zod.d.ts.map +0 -1
- package/esm/schema/zod.js +0 -180
- package/esm/schema/zod.js.map +0 -1
- package/esm/schema/zod.test.d.ts +0 -2
- package/esm/schema/zod.test.d.ts.map +0 -1
- package/esm/schema/zod.test.js +0 -628
- package/esm/schema/zod.test.js.map +0 -1
package/esm/schema/zod.test.js
DELETED
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
import * as z3 from "zod/v3";
|
|
2
|
-
import * as z4 from "zod/v4";
|
|
3
|
-
import { getZodFunctionArgs, getZodFunctionReturns, handleZodSchemaToJson, isZod3FunctionSchema, isZod3Schema, isZod4FunctionSchema, isZod4Schema, isZodFunctionSchema, isZodSchema, } from "./zod";
|
|
4
|
-
// Test helper: assumes `value` is JSON-serializable (plain objects/arrays/primitives).
|
|
5
|
-
// Conservative helper: returns true if any object in the tree has an own `key`
|
|
6
|
-
// property at any depth. This lets us assert against JSON Schema `$ref` keys
|
|
7
|
-
// structurally (not via incidental substrings in string values).
|
|
8
|
-
function hasKeyDeep(value, key) {
|
|
9
|
-
const seen = new Set();
|
|
10
|
-
function isPlainObject(v) {
|
|
11
|
-
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
12
|
-
return false;
|
|
13
|
-
const proto = Object.getPrototypeOf(v);
|
|
14
|
-
return proto === Object.prototype || proto === null;
|
|
15
|
-
}
|
|
16
|
-
function visit(node) {
|
|
17
|
-
if (!node || typeof node !== "object")
|
|
18
|
-
return false;
|
|
19
|
-
if (seen.has(node))
|
|
20
|
-
return false;
|
|
21
|
-
seen.add(node);
|
|
22
|
-
if (Array.isArray(node)) {
|
|
23
|
-
return node.some(visit);
|
|
24
|
-
}
|
|
25
|
-
if (!isPlainObject(node))
|
|
26
|
-
return false;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(node, key))
|
|
28
|
-
return true;
|
|
29
|
-
return Object.values(node).some(visit);
|
|
30
|
-
}
|
|
31
|
-
return visit(value);
|
|
32
|
-
}
|
|
33
|
-
function resolveJsonPointer(doc, pointer) {
|
|
34
|
-
if (!pointer.startsWith("#"))
|
|
35
|
-
return undefined;
|
|
36
|
-
if (pointer === "#")
|
|
37
|
-
return doc;
|
|
38
|
-
if (!pointer.startsWith("#/"))
|
|
39
|
-
return undefined;
|
|
40
|
-
return pointer
|
|
41
|
-
.slice(2)
|
|
42
|
-
.split("/")
|
|
43
|
-
.map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"))
|
|
44
|
-
.reduce((current, segment) => {
|
|
45
|
-
if (!current || typeof current !== "object")
|
|
46
|
-
return undefined;
|
|
47
|
-
if (Array.isArray(current)) {
|
|
48
|
-
const index = Number(segment);
|
|
49
|
-
if (!Number.isInteger(index))
|
|
50
|
-
return undefined;
|
|
51
|
-
return current[index];
|
|
52
|
-
}
|
|
53
|
-
return current[segment];
|
|
54
|
-
}, doc);
|
|
55
|
-
}
|
|
56
|
-
function createRecursiveZod4NodeSchema() {
|
|
57
|
-
// Placeholder schema so we can self-reference via `z4.lazy` without
|
|
58
|
-
// fighting ESLint `prefer-const`.
|
|
59
|
-
let nodeSchema = z4.any();
|
|
60
|
-
nodeSchema = z4.object({ next: z4.lazy(() => nodeSchema).optional() });
|
|
61
|
-
return nodeSchema;
|
|
62
|
-
}
|
|
63
|
-
describe("zod schema utilities", () => {
|
|
64
|
-
describe("isZod3Schema", () => {
|
|
65
|
-
it("returns true for Zod 3 schemas", () => {
|
|
66
|
-
const schema = z3.object({ name: z3.string() });
|
|
67
|
-
expect(isZod3Schema(schema)).toBe(true);
|
|
68
|
-
expect(isZod4Schema(schema)).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
it("returns true for Zod 4 schemas (they also have _def)", () => {
|
|
71
|
-
// Note: Zod 4 schemas have both _def and _zod, so isZod3Schema returns true.
|
|
72
|
-
// This is fine because handleZodSchemaToJson checks isZod4Schema first.
|
|
73
|
-
const schema = z4.object({ name: z4.string() });
|
|
74
|
-
expect(isZod4Schema(schema)).toBe(true);
|
|
75
|
-
expect(isZod3Schema(schema)).toBe(false);
|
|
76
|
-
});
|
|
77
|
-
it("returns false for non-Zod values", () => {
|
|
78
|
-
expect(isZod3Schema({})).toBe(false);
|
|
79
|
-
expect(isZod3Schema(null)).toBe(false);
|
|
80
|
-
expect(isZod3Schema("string")).toBe(false);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe("isZod4Schema", () => {
|
|
84
|
-
it("returns true for Zod 4 schemas", () => {
|
|
85
|
-
const schema = z4.object({ name: z4.string() });
|
|
86
|
-
expect(isZod4Schema(schema)).toBe(true);
|
|
87
|
-
});
|
|
88
|
-
it("returns false for Zod 3 schemas", () => {
|
|
89
|
-
const schema = z3.object({ name: z3.string() });
|
|
90
|
-
expect(isZod4Schema(schema)).toBe(false);
|
|
91
|
-
});
|
|
92
|
-
it("returns false for non-Zod values", () => {
|
|
93
|
-
expect(isZod4Schema({})).toBe(false);
|
|
94
|
-
expect(isZod4Schema(null)).toBe(false);
|
|
95
|
-
expect(isZod4Schema("string")).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe("isZodSchema", () => {
|
|
99
|
-
it("returns true for Zod 3 schemas", () => {
|
|
100
|
-
expect(isZodSchema(z3.string())).toBe(true);
|
|
101
|
-
expect(isZodSchema(z3.object({ a: z3.string() }))).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
it("returns true for Zod 4 schemas", () => {
|
|
104
|
-
expect(isZodSchema(z4.string())).toBe(true);
|
|
105
|
-
expect(isZodSchema(z4.object({ a: z4.string() }))).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
it("returns false for non-objects", () => {
|
|
108
|
-
expect(isZodSchema(null)).toBe(false);
|
|
109
|
-
expect(isZodSchema(undefined)).toBe(false);
|
|
110
|
-
expect(isZodSchema("string")).toBe(false);
|
|
111
|
-
expect(isZodSchema(123)).toBe(false);
|
|
112
|
-
});
|
|
113
|
-
it("returns false for objects without ~standard", () => {
|
|
114
|
-
expect(isZodSchema({})).toBe(false);
|
|
115
|
-
expect(isZodSchema({ foo: "bar" })).toBe(false);
|
|
116
|
-
});
|
|
117
|
-
it("returns false for objects with invalid ~standard", () => {
|
|
118
|
-
expect(isZodSchema({ "~standard": null })).toBe(false);
|
|
119
|
-
expect(isZodSchema({ "~standard": "not-object" })).toBe(false);
|
|
120
|
-
expect(isZodSchema({ "~standard": {} })).toBe(false);
|
|
121
|
-
expect(isZodSchema({ "~standard": { vendor: "not-zod" } })).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
describe("isZodFunctionSchema", () => {
|
|
125
|
-
it("returns true for Zod 3 function schemas", () => {
|
|
126
|
-
const schema = z3.function().args(z3.string()).returns(z3.void());
|
|
127
|
-
expect(isZodFunctionSchema(schema)).toBe(true);
|
|
128
|
-
expect(isZod3FunctionSchema(schema)).toBe(true);
|
|
129
|
-
expect(isZod4FunctionSchema(schema)).toBe(false);
|
|
130
|
-
});
|
|
131
|
-
it("returns true for Zod 4 function schemas", () => {
|
|
132
|
-
const schema = z4.function({
|
|
133
|
-
input: z4.tuple([z4.string()]),
|
|
134
|
-
output: z4.void(),
|
|
135
|
-
});
|
|
136
|
-
expect(isZodFunctionSchema(schema)).toBe(true);
|
|
137
|
-
expect(isZod3FunctionSchema(schema)).toBe(false);
|
|
138
|
-
expect(isZod4FunctionSchema(schema)).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
it("returns false for non-function Zod schemas", () => {
|
|
141
|
-
expect(isZodFunctionSchema(z3.string())).toBe(false);
|
|
142
|
-
expect(isZodFunctionSchema(z3.object({ a: z3.string() }))).toBe(false);
|
|
143
|
-
expect(isZodFunctionSchema(z4.string())).toBe(false);
|
|
144
|
-
expect(isZodFunctionSchema(z4.object({ a: z4.string() }))).toBe(false);
|
|
145
|
-
});
|
|
146
|
-
it("returns false for non-Zod values", () => {
|
|
147
|
-
expect(isZodFunctionSchema(null)).toBe(false);
|
|
148
|
-
expect(isZodFunctionSchema({})).toBe(false);
|
|
149
|
-
expect(isZodFunctionSchema("function")).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
describe("handleZodSchemaToJson", () => {
|
|
153
|
-
describe("basic conversion", () => {
|
|
154
|
-
it("converts Zod 3 schema to JSON Schema", () => {
|
|
155
|
-
const schema = z3.object({
|
|
156
|
-
name: z3.string(),
|
|
157
|
-
age: z3.number(),
|
|
158
|
-
});
|
|
159
|
-
const result = handleZodSchemaToJson(schema);
|
|
160
|
-
expect(result).toMatchObject({
|
|
161
|
-
type: "object",
|
|
162
|
-
properties: {
|
|
163
|
-
name: { type: "string" },
|
|
164
|
-
age: { type: "number" },
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
it("converts Zod 4 schema to JSON Schema", () => {
|
|
169
|
-
const schema = z4.object({
|
|
170
|
-
name: z4.string(),
|
|
171
|
-
age: z4.number(),
|
|
172
|
-
});
|
|
173
|
-
const result = handleZodSchemaToJson(schema);
|
|
174
|
-
expect(result).toMatchObject({
|
|
175
|
-
type: "object",
|
|
176
|
-
properties: {
|
|
177
|
-
name: { type: "string" },
|
|
178
|
-
age: { type: "number" },
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
describe("reused schemas - no $ref references", () => {
|
|
184
|
-
it("inlines reused Zod 3 schemas without any $ref in output", () => {
|
|
185
|
-
// Define a shared schema that will be reused
|
|
186
|
-
const dataSchema = z3.object({
|
|
187
|
-
name: z3.string(),
|
|
188
|
-
value: z3.number(),
|
|
189
|
-
});
|
|
190
|
-
// Use the same schema in multiple places
|
|
191
|
-
const props = z3.object({
|
|
192
|
-
data: z3.array(dataSchema),
|
|
193
|
-
historicalData: z3.array(dataSchema),
|
|
194
|
-
});
|
|
195
|
-
const result = handleZodSchemaToJson(props);
|
|
196
|
-
// Ensure there are no JSON Schema `$ref` keys anywhere in the produced schema.
|
|
197
|
-
expect(hasKeyDeep(result, "$ref")).toBe(false);
|
|
198
|
-
// Both arrays should have the full schema inline
|
|
199
|
-
expect(result).toMatchObject({
|
|
200
|
-
type: "object",
|
|
201
|
-
properties: {
|
|
202
|
-
data: {
|
|
203
|
-
type: "array",
|
|
204
|
-
items: {
|
|
205
|
-
type: "object",
|
|
206
|
-
properties: {
|
|
207
|
-
name: { type: "string" },
|
|
208
|
-
value: { type: "number" },
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
historicalData: {
|
|
213
|
-
type: "array",
|
|
214
|
-
items: {
|
|
215
|
-
type: "object",
|
|
216
|
-
properties: {
|
|
217
|
-
name: { type: "string" },
|
|
218
|
-
value: { type: "number" },
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
it("inlines reused Zod 4 schemas without any $ref in output", () => {
|
|
226
|
-
// Define a shared schema that will be reused
|
|
227
|
-
const dataSchema = z4.object({
|
|
228
|
-
name: z4.string(),
|
|
229
|
-
value: z4.number(),
|
|
230
|
-
});
|
|
231
|
-
// Use the same schema in multiple places
|
|
232
|
-
const props = z4.object({
|
|
233
|
-
data: z4.array(dataSchema),
|
|
234
|
-
historicalData: z4.array(dataSchema),
|
|
235
|
-
});
|
|
236
|
-
const result = handleZodSchemaToJson(props);
|
|
237
|
-
expect(hasKeyDeep(result, "$ref")).toBe(false);
|
|
238
|
-
// Both arrays should have the full schema inline
|
|
239
|
-
expect(result).toMatchObject({
|
|
240
|
-
type: "object",
|
|
241
|
-
properties: {
|
|
242
|
-
data: {
|
|
243
|
-
type: "array",
|
|
244
|
-
items: {
|
|
245
|
-
type: "object",
|
|
246
|
-
properties: {
|
|
247
|
-
name: { type: "string" },
|
|
248
|
-
value: { type: "number" },
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
historicalData: {
|
|
253
|
-
type: "array",
|
|
254
|
-
items: {
|
|
255
|
-
type: "object",
|
|
256
|
-
properties: {
|
|
257
|
-
name: { type: "string" },
|
|
258
|
-
value: { type: "number" },
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
it("handles deeply nested reused Zod 3 schemas without any $ref", () => {
|
|
266
|
-
const addressSchema = z3.object({
|
|
267
|
-
street: z3.string(),
|
|
268
|
-
city: z3.string(),
|
|
269
|
-
});
|
|
270
|
-
const personSchema = z3.object({
|
|
271
|
-
name: z3.string(),
|
|
272
|
-
homeAddress: addressSchema,
|
|
273
|
-
workAddress: addressSchema,
|
|
274
|
-
});
|
|
275
|
-
const result = handleZodSchemaToJson(personSchema);
|
|
276
|
-
expect(hasKeyDeep(result, "$ref")).toBe(false);
|
|
277
|
-
expect(result).toMatchObject({
|
|
278
|
-
type: "object",
|
|
279
|
-
properties: {
|
|
280
|
-
name: { type: "string" },
|
|
281
|
-
homeAddress: {
|
|
282
|
-
type: "object",
|
|
283
|
-
properties: {
|
|
284
|
-
street: { type: "string" },
|
|
285
|
-
city: { type: "string" },
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
workAddress: {
|
|
289
|
-
type: "object",
|
|
290
|
-
properties: {
|
|
291
|
-
street: { type: "string" },
|
|
292
|
-
city: { type: "string" },
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
it("handles deeply nested reused Zod 4 schemas without any $ref", () => {
|
|
299
|
-
const addressSchema = z4.object({
|
|
300
|
-
street: z4.string(),
|
|
301
|
-
city: z4.string(),
|
|
302
|
-
});
|
|
303
|
-
const personSchema = z4.object({
|
|
304
|
-
name: z4.string(),
|
|
305
|
-
homeAddress: addressSchema,
|
|
306
|
-
workAddress: addressSchema,
|
|
307
|
-
});
|
|
308
|
-
const result = handleZodSchemaToJson(personSchema);
|
|
309
|
-
expect(hasKeyDeep(result, "$ref")).toBe(false);
|
|
310
|
-
expect(result).toMatchObject({
|
|
311
|
-
type: "object",
|
|
312
|
-
properties: {
|
|
313
|
-
name: { type: "string" },
|
|
314
|
-
homeAddress: {
|
|
315
|
-
type: "object",
|
|
316
|
-
properties: {
|
|
317
|
-
street: { type: "string" },
|
|
318
|
-
city: { type: "string" },
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
workAddress: {
|
|
322
|
-
type: "object",
|
|
323
|
-
properties: {
|
|
324
|
-
street: { type: "string" },
|
|
325
|
-
city: { type: "string" },
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
it("handles triple-nested reused Zod 4 schemas without any $ref", () => {
|
|
332
|
-
const pointSchema = z4.object({
|
|
333
|
-
x: z4.number(),
|
|
334
|
-
y: z4.number(),
|
|
335
|
-
});
|
|
336
|
-
const lineSchema = z4.object({
|
|
337
|
-
start: pointSchema,
|
|
338
|
-
end: pointSchema,
|
|
339
|
-
});
|
|
340
|
-
const shapeSchema = z4.object({
|
|
341
|
-
outline: z4.array(lineSchema),
|
|
342
|
-
boundingBox: z4.object({
|
|
343
|
-
topLeft: pointSchema,
|
|
344
|
-
bottomRight: pointSchema,
|
|
345
|
-
}),
|
|
346
|
-
});
|
|
347
|
-
const result = handleZodSchemaToJson(shapeSchema);
|
|
348
|
-
expect(result).toMatchInlineSnapshot(`
|
|
349
|
-
{
|
|
350
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
351
|
-
"additionalProperties": false,
|
|
352
|
-
"properties": {
|
|
353
|
-
"boundingBox": {
|
|
354
|
-
"additionalProperties": false,
|
|
355
|
-
"properties": {
|
|
356
|
-
"bottomRight": {
|
|
357
|
-
"additionalProperties": false,
|
|
358
|
-
"properties": {
|
|
359
|
-
"x": {
|
|
360
|
-
"type": "number",
|
|
361
|
-
},
|
|
362
|
-
"y": {
|
|
363
|
-
"type": "number",
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
"required": [
|
|
367
|
-
"x",
|
|
368
|
-
"y",
|
|
369
|
-
],
|
|
370
|
-
"type": "object",
|
|
371
|
-
},
|
|
372
|
-
"topLeft": {
|
|
373
|
-
"additionalProperties": false,
|
|
374
|
-
"properties": {
|
|
375
|
-
"x": {
|
|
376
|
-
"type": "number",
|
|
377
|
-
},
|
|
378
|
-
"y": {
|
|
379
|
-
"type": "number",
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
"required": [
|
|
383
|
-
"x",
|
|
384
|
-
"y",
|
|
385
|
-
],
|
|
386
|
-
"type": "object",
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
"required": [
|
|
390
|
-
"topLeft",
|
|
391
|
-
"bottomRight",
|
|
392
|
-
],
|
|
393
|
-
"type": "object",
|
|
394
|
-
},
|
|
395
|
-
"outline": {
|
|
396
|
-
"items": {
|
|
397
|
-
"additionalProperties": false,
|
|
398
|
-
"properties": {
|
|
399
|
-
"end": {
|
|
400
|
-
"additionalProperties": false,
|
|
401
|
-
"properties": {
|
|
402
|
-
"x": {
|
|
403
|
-
"type": "number",
|
|
404
|
-
},
|
|
405
|
-
"y": {
|
|
406
|
-
"type": "number",
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
"required": [
|
|
410
|
-
"x",
|
|
411
|
-
"y",
|
|
412
|
-
],
|
|
413
|
-
"type": "object",
|
|
414
|
-
},
|
|
415
|
-
"start": {
|
|
416
|
-
"additionalProperties": false,
|
|
417
|
-
"properties": {
|
|
418
|
-
"x": {
|
|
419
|
-
"type": "number",
|
|
420
|
-
},
|
|
421
|
-
"y": {
|
|
422
|
-
"type": "number",
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
"required": [
|
|
426
|
-
"x",
|
|
427
|
-
"y",
|
|
428
|
-
],
|
|
429
|
-
"type": "object",
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
"required": [
|
|
433
|
-
"start",
|
|
434
|
-
"end",
|
|
435
|
-
],
|
|
436
|
-
"type": "object",
|
|
437
|
-
},
|
|
438
|
-
"type": "array",
|
|
439
|
-
},
|
|
440
|
-
},
|
|
441
|
-
"required": [
|
|
442
|
-
"outline",
|
|
443
|
-
"boundingBox",
|
|
444
|
-
],
|
|
445
|
-
"type": "object",
|
|
446
|
-
}
|
|
447
|
-
`);
|
|
448
|
-
expect(hasKeyDeep(result, "$ref")).toBe(false);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
describe("recursive schemas", () => {
|
|
452
|
-
it("represents Zod 4 recursive schemas using $ref", () => {
|
|
453
|
-
const nodeSchema = createRecursiveZod4NodeSchema();
|
|
454
|
-
const result = handleZodSchemaToJson(nodeSchema);
|
|
455
|
-
const schema = result;
|
|
456
|
-
const properties = schema.properties;
|
|
457
|
-
const next = properties?.next;
|
|
458
|
-
const ref = next?.$ref;
|
|
459
|
-
expect(hasKeyDeep(result, "$ref")).toBe(true);
|
|
460
|
-
expect(result).toMatchObject({
|
|
461
|
-
type: "object",
|
|
462
|
-
properties: {
|
|
463
|
-
next: {
|
|
464
|
-
$ref: expect.stringMatching(/^#(\/.*)?$/),
|
|
465
|
-
},
|
|
466
|
-
},
|
|
467
|
-
});
|
|
468
|
-
expect(ref).toEqual(expect.stringMatching(/^#(\/.*)?$/));
|
|
469
|
-
const resolved = typeof ref === "string" ? resolveJsonPointer(result, ref) : undefined;
|
|
470
|
-
expect(resolved).toBe(result);
|
|
471
|
-
expect(resolved).toMatchObject({
|
|
472
|
-
type: "object",
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
describe("complex schemas", () => {
|
|
477
|
-
it("handles optional fields in Zod 3", () => {
|
|
478
|
-
const schema = z3.object({
|
|
479
|
-
required: z3.string(),
|
|
480
|
-
optional: z3.string().optional(),
|
|
481
|
-
});
|
|
482
|
-
const result = handleZodSchemaToJson(schema);
|
|
483
|
-
expect(result).toMatchObject({
|
|
484
|
-
type: "object",
|
|
485
|
-
properties: {
|
|
486
|
-
required: { type: "string" },
|
|
487
|
-
optional: { type: "string" },
|
|
488
|
-
},
|
|
489
|
-
required: ["required"],
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
it("handles optional fields in Zod 4", () => {
|
|
493
|
-
const schema = z4.object({
|
|
494
|
-
required: z4.string(),
|
|
495
|
-
optional: z4.string().optional(),
|
|
496
|
-
});
|
|
497
|
-
const result = handleZodSchemaToJson(schema);
|
|
498
|
-
expect(result).toMatchObject({
|
|
499
|
-
type: "object",
|
|
500
|
-
properties: {
|
|
501
|
-
required: { type: "string" },
|
|
502
|
-
optional: { type: "string" },
|
|
503
|
-
},
|
|
504
|
-
required: ["required"],
|
|
505
|
-
});
|
|
506
|
-
});
|
|
507
|
-
it("handles enums in Zod 3", () => {
|
|
508
|
-
const schema = z3.object({
|
|
509
|
-
status: z3.enum(["active", "inactive", "pending"]),
|
|
510
|
-
});
|
|
511
|
-
const result = handleZodSchemaToJson(schema);
|
|
512
|
-
expect(result).toMatchObject({
|
|
513
|
-
type: "object",
|
|
514
|
-
properties: {
|
|
515
|
-
status: {
|
|
516
|
-
type: "string",
|
|
517
|
-
enum: ["active", "inactive", "pending"],
|
|
518
|
-
},
|
|
519
|
-
},
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
it("handles enums in Zod 4", () => {
|
|
523
|
-
const schema = z4.object({
|
|
524
|
-
status: z4.enum(["active", "inactive", "pending"]),
|
|
525
|
-
});
|
|
526
|
-
const result = handleZodSchemaToJson(schema);
|
|
527
|
-
expect(result).toMatchObject({
|
|
528
|
-
type: "object",
|
|
529
|
-
properties: {
|
|
530
|
-
status: {
|
|
531
|
-
type: "string",
|
|
532
|
-
enum: ["active", "inactive", "pending"],
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
});
|
|
536
|
-
});
|
|
537
|
-
it("handles descriptions in Zod 3", () => {
|
|
538
|
-
const schema = z3.object({
|
|
539
|
-
name: z3.string().describe("The user name"),
|
|
540
|
-
});
|
|
541
|
-
const result = handleZodSchemaToJson(schema);
|
|
542
|
-
expect(result).toMatchObject({
|
|
543
|
-
type: "object",
|
|
544
|
-
properties: {
|
|
545
|
-
name: {
|
|
546
|
-
type: "string",
|
|
547
|
-
description: "The user name",
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
it("handles descriptions in Zod 4", () => {
|
|
553
|
-
const schema = z4.object({
|
|
554
|
-
name: z4.string().describe("The user name"),
|
|
555
|
-
});
|
|
556
|
-
const result = handleZodSchemaToJson(schema);
|
|
557
|
-
expect(result).toMatchObject({
|
|
558
|
-
type: "object",
|
|
559
|
-
properties: {
|
|
560
|
-
name: {
|
|
561
|
-
type: "string",
|
|
562
|
-
description: "The user name",
|
|
563
|
-
},
|
|
564
|
-
},
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
describe("getZodFunctionArgs", () => {
|
|
570
|
-
it("extracts args from Zod 3 function schema", () => {
|
|
571
|
-
const schema = z3
|
|
572
|
-
.function()
|
|
573
|
-
.args(z3.string(), z3.number())
|
|
574
|
-
.returns(z3.boolean());
|
|
575
|
-
const args = getZodFunctionArgs(schema);
|
|
576
|
-
expect(args).toBeDefined();
|
|
577
|
-
// Zod 3 args is a ZodTuple - check the _def property exists
|
|
578
|
-
expect(args._def.typeName).toBe("ZodTuple");
|
|
579
|
-
});
|
|
580
|
-
it("extracts args from Zod 4 function schema", () => {
|
|
581
|
-
const schema = z4.function({
|
|
582
|
-
input: z4.tuple([z4.string(), z4.number()]),
|
|
583
|
-
output: z4.boolean(),
|
|
584
|
-
});
|
|
585
|
-
const args = getZodFunctionArgs(schema);
|
|
586
|
-
expect(args).toBeDefined();
|
|
587
|
-
// Zod 4 args is accessed via .def.input - it's the tuple schema
|
|
588
|
-
expect(args).toHaveProperty("def");
|
|
589
|
-
});
|
|
590
|
-
it("throws for non-function schemas", () => {
|
|
591
|
-
expect(() => getZodFunctionArgs(z3.string())).toThrow("Unable to determine parameters from zod function schema");
|
|
592
|
-
expect(() => getZodFunctionArgs(z4.string())).toThrow("Unable to determine parameters from zod function schema");
|
|
593
|
-
});
|
|
594
|
-
it("throws for non-Zod values", () => {
|
|
595
|
-
expect(() => getZodFunctionArgs({})).toThrow("Unable to determine parameters from zod function schema");
|
|
596
|
-
});
|
|
597
|
-
});
|
|
598
|
-
describe("getZodFunctionReturns", () => {
|
|
599
|
-
it("extracts returns from Zod 3 function schema", () => {
|
|
600
|
-
const schema = z3
|
|
601
|
-
.function()
|
|
602
|
-
.args(z3.string())
|
|
603
|
-
.returns(z3.object({ result: z3.boolean() }));
|
|
604
|
-
const returns = getZodFunctionReturns(schema);
|
|
605
|
-
expect(returns).toBeDefined();
|
|
606
|
-
// Cast to access _def property on Zod 3 schema
|
|
607
|
-
expect(returns._def.typeName).toBe("ZodObject");
|
|
608
|
-
});
|
|
609
|
-
it("extracts returns from Zod 4 function schema", () => {
|
|
610
|
-
const schema = z4.function({
|
|
611
|
-
input: z4.tuple([z4.string()]),
|
|
612
|
-
output: z4.object({ result: z4.boolean() }),
|
|
613
|
-
});
|
|
614
|
-
const returns = getZodFunctionReturns(schema);
|
|
615
|
-
expect(returns).toBeDefined();
|
|
616
|
-
// Zod 4 returns is accessed via .def.output - it's the object schema
|
|
617
|
-
expect(returns).toHaveProperty("def");
|
|
618
|
-
});
|
|
619
|
-
it("throws for non-function schemas", () => {
|
|
620
|
-
expect(() => getZodFunctionReturns(z3.string())).toThrow("Unable to determine return type from zod function schema");
|
|
621
|
-
expect(() => getZodFunctionReturns(z4.string())).toThrow("Unable to determine return type from zod function schema");
|
|
622
|
-
});
|
|
623
|
-
it("throws for non-Zod values", () => {
|
|
624
|
-
expect(() => getZodFunctionReturns({})).toThrow("Unable to determine return type from zod function schema");
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
});
|
|
628
|
-
//# sourceMappingURL=zod.test.js.map
|