@tambo-ai/react 0.65.3 → 0.66.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 +120 -20
- package/dist/{providers/hoc → hoc}/with-tambo-interactable.d.ts +2 -2
- package/dist/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/dist/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
- package/dist/hoc/with-tambo-interactable.js.map +1 -0
- package/dist/hoc/with-tambo-interactable.test.d.ts +2 -0
- package/dist/hoc/with-tambo-interactable.test.d.ts.map +1 -0
- package/dist/hoc/with-tambo-interactable.test.js +192 -0
- package/dist/hoc/with-tambo-interactable.test.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-current-message.d.ts +51 -7
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +50 -6
- package/dist/hooks/use-current-message.js.map +1 -1
- package/dist/hooks/use-current-message.test.d.ts +2 -0
- package/dist/hooks/use-current-message.test.d.ts.map +1 -0
- package/dist/hooks/use-current-message.test.js +264 -0
- package/dist/hooks/use-current-message.test.js.map +1 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcp-hooks.d.ts +77 -6
- package/dist/mcp/mcp-hooks.d.ts.map +1 -1
- package/dist/mcp/mcp-hooks.js +104 -40
- package/dist/mcp/mcp-hooks.js.map +1 -1
- package/dist/mcp/mcp-hooks.test.js +83 -18
- package/dist/mcp/mcp-hooks.test.js.map +1 -1
- package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/dist/mcp/tambo-mcp-provider.js +2 -1
- package/dist/mcp/tambo-mcp-provider.js.map +1 -1
- package/dist/model/component-metadata.d.ts +444 -14
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/model/generate-component-response.d.ts +12 -1
- package/dist/model/generate-component-response.d.ts.map +1 -1
- package/dist/model/generate-component-response.js.map +1 -1
- package/dist/model/resource-info.d.ts +55 -0
- package/dist/model/resource-info.d.ts.map +1 -0
- package/dist/model/resource-info.js +3 -0
- package/dist/model/resource-info.js.map +1 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-component-provider.d.ts +4 -4
- 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-partial-updates.test.js +87 -87
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +2 -3
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +47 -41
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +9 -9
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +11 -11
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.d.ts +28 -7
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -1
- package/dist/providers/tambo-registry-provider.js +70 -181
- package/dist/providers/tambo-registry-provider.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +152 -30
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.d.ts +2 -0
- package/dist/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
- package/dist/providers/tambo-registry-schema-compat.test.js +616 -0
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -0
- 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 +5 -0
- package/dist/providers/tambo-stubs.js.map +1 -1
- package/dist/providers/tambo-thread-input-provider.d.ts +1 -0
- package/dist/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-input-provider.js +3 -3
- package/dist/providers/tambo-thread-input-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -1
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +32 -36
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +18 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/json-schema.d.ts +35 -0
- package/dist/schema/json-schema.d.ts.map +1 -0
- package/dist/schema/json-schema.js +103 -0
- package/dist/schema/json-schema.js.map +1 -0
- package/dist/schema/schema.d.ts +66 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +192 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/schema.test.d.ts +2 -0
- package/dist/schema/schema.test.d.ts.map +1 -0
- package/dist/schema/schema.test.js +41 -0
- package/dist/schema/schema.test.js.map +1 -0
- package/dist/schema/standard-schema.d.ts +21 -0
- package/dist/schema/standard-schema.d.ts.map +1 -0
- package/dist/schema/standard-schema.js +37 -0
- package/dist/schema/standard-schema.js.map +1 -0
- package/dist/schema/validate.d.ts +14 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +148 -0
- package/dist/schema/validate.js.map +1 -0
- package/dist/schema/validate.test.d.ts +2 -0
- package/dist/schema/validate.test.d.ts.map +1 -0
- package/dist/schema/validate.test.js +128 -0
- package/dist/schema/validate.test.js.map +1 -0
- package/dist/schema/zod.d.ts +54 -0
- package/dist/schema/zod.d.ts.map +1 -0
- package/dist/schema/zod.js +135 -0
- package/dist/schema/zod.js.map +1 -0
- package/dist/testing/tools.d.ts +29 -15
- package/dist/testing/tools.d.ts.map +1 -1
- package/dist/testing/tools.js +64 -19
- package/dist/testing/tools.js.map +1 -1
- package/dist/util/generate-component.d.ts.map +1 -1
- package/dist/util/generate-component.js +3 -3
- package/dist/util/generate-component.js.map +1 -1
- package/dist/util/mcp-server-utils.d.ts +23 -0
- package/dist/util/mcp-server-utils.d.ts.map +1 -0
- package/dist/util/mcp-server-utils.js +107 -0
- package/dist/util/mcp-server-utils.js.map +1 -0
- package/dist/util/mcp-server-utils.test.d.ts +2 -0
- package/dist/util/mcp-server-utils.test.d.ts.map +1 -0
- package/dist/util/mcp-server-utils.test.js +287 -0
- package/dist/util/mcp-server-utils.test.js.map +1 -0
- package/dist/util/message-builder.d.ts +2 -1
- package/dist/util/message-builder.d.ts.map +1 -1
- package/dist/util/message-builder.js +54 -36
- package/dist/util/message-builder.js.map +1 -1
- package/dist/util/message-builder.test.js +500 -13
- package/dist/util/message-builder.test.js.map +1 -1
- package/dist/util/registry-validators.d.ts +26 -0
- package/dist/util/registry-validators.d.ts.map +1 -0
- package/dist/util/registry-validators.js +105 -0
- package/dist/util/registry-validators.js.map +1 -0
- package/dist/util/registry-validators.test.d.ts +2 -0
- package/dist/util/registry-validators.test.d.ts.map +1 -0
- package/dist/util/registry-validators.test.js +235 -0
- package/dist/util/registry-validators.test.js.map +1 -0
- package/dist/util/registry.d.ts +35 -7
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +60 -77
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.d.ts +2 -0
- package/dist/util/registry.test.d.ts.map +1 -0
- package/dist/util/registry.test.js +204 -0
- package/dist/util/registry.test.js.map +1 -0
- package/dist/util/resource-validators.d.ts +16 -0
- package/dist/util/resource-validators.d.ts.map +1 -0
- package/dist/util/resource-validators.js +34 -0
- package/dist/util/resource-validators.js.map +1 -0
- 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 +12 -4
- package/dist/util/tool-caller.js.map +1 -1
- package/esm/{providers/hoc → hoc}/with-tambo-interactable.d.ts +2 -2
- package/esm/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/esm/{providers/hoc → hoc}/with-tambo-interactable.js +29 -2
- package/esm/hoc/with-tambo-interactable.js.map +1 -0
- package/esm/hoc/with-tambo-interactable.test.d.ts +2 -0
- package/esm/hoc/with-tambo-interactable.test.d.ts.map +1 -0
- package/esm/hoc/with-tambo-interactable.test.js +187 -0
- package/esm/hoc/with-tambo-interactable.test.js.map +1 -0
- package/esm/hooks/index.d.ts +1 -1
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +1 -1
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/use-current-message.d.ts +51 -7
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +48 -5
- package/esm/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.test.d.ts +2 -0
- package/esm/hooks/use-current-message.test.d.ts.map +1 -0
- package/esm/hooks/use-current-message.test.js +259 -0
- package/esm/hooks/use-current-message.test.js.map +1 -0
- package/esm/index.d.ts +10 -8
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/esm/mcp/index.d.ts +1 -1
- package/esm/mcp/index.d.ts.map +1 -1
- package/esm/mcp/index.js +1 -1
- package/esm/mcp/index.js.map +1 -1
- package/esm/mcp/mcp-hooks.d.ts +77 -6
- package/esm/mcp/mcp-hooks.d.ts.map +1 -1
- package/esm/mcp/mcp-hooks.js +103 -40
- package/esm/mcp/mcp-hooks.js.map +1 -1
- package/esm/mcp/mcp-hooks.test.js +84 -19
- package/esm/mcp/mcp-hooks.test.js.map +1 -1
- package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
- package/esm/mcp/tambo-mcp-provider.js +2 -1
- package/esm/mcp/tambo-mcp-provider.js.map +1 -1
- package/esm/model/component-metadata.d.ts +444 -14
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/model/generate-component-response.d.ts +12 -1
- package/esm/model/generate-component-response.d.ts.map +1 -1
- package/esm/model/generate-component-response.js.map +1 -1
- package/esm/model/resource-info.d.ts +55 -0
- package/esm/model/resource-info.d.ts.map +1 -0
- package/esm/model/resource-info.js +2 -0
- package/esm/model/resource-info.js.map +1 -0
- package/esm/providers/index.d.ts +1 -1
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-component-provider.d.ts +4 -4
- 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-partial-updates.test.js +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +2 -3
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +44 -38
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +3 -3
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +3 -3
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.d.ts +28 -7
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -1
- package/esm/providers/tambo-registry-provider.js +67 -175
- package/esm/providers/tambo-registry-provider.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +148 -26
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.d.ts +2 -0
- package/esm/providers/tambo-registry-schema-compat.test.d.ts.map +1 -0
- package/esm/providers/tambo-registry-schema-compat.test.js +578 -0
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -0
- 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 +5 -0
- package/esm/providers/tambo-stubs.js.map +1 -1
- package/esm/providers/tambo-thread-input-provider.d.ts +1 -0
- package/esm/providers/tambo-thread-input-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-input-provider.js +3 -3
- package/esm/providers/tambo-thread-input-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -1
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +24 -28
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/index.d.ts +6 -0
- package/esm/schema/index.d.ts.map +1 -0
- package/esm/schema/index.js +6 -0
- package/esm/schema/index.js.map +1 -0
- package/esm/schema/json-schema.d.ts +35 -0
- package/esm/schema/json-schema.d.ts.map +1 -0
- package/esm/schema/json-schema.js +98 -0
- package/esm/schema/json-schema.js.map +1 -0
- package/esm/schema/schema.d.ts +66 -0
- package/esm/schema/schema.d.ts.map +1 -0
- package/esm/schema/schema.js +185 -0
- package/esm/schema/schema.js.map +1 -0
- package/esm/schema/schema.test.d.ts +2 -0
- package/esm/schema/schema.test.d.ts.map +1 -0
- package/esm/schema/schema.test.js +39 -0
- package/esm/schema/schema.test.js.map +1 -0
- package/esm/schema/standard-schema.d.ts +21 -0
- package/esm/schema/standard-schema.d.ts.map +1 -0
- package/esm/schema/standard-schema.js +34 -0
- package/esm/schema/standard-schema.js.map +1 -0
- package/esm/schema/validate.d.ts +14 -0
- package/esm/schema/validate.d.ts.map +1 -0
- package/esm/schema/validate.js +145 -0
- package/esm/schema/validate.js.map +1 -0
- package/esm/schema/validate.test.d.ts +2 -0
- package/esm/schema/validate.test.d.ts.map +1 -0
- package/esm/schema/validate.test.js +126 -0
- package/esm/schema/validate.test.js.map +1 -0
- package/esm/schema/zod.d.ts +54 -0
- package/esm/schema/zod.d.ts.map +1 -0
- package/esm/schema/zod.js +124 -0
- package/esm/schema/zod.js.map +1 -0
- package/esm/testing/tools.d.ts +29 -15
- package/esm/testing/tools.d.ts.map +1 -1
- package/esm/testing/tools.js +62 -16
- package/esm/testing/tools.js.map +1 -1
- package/esm/util/generate-component.d.ts.map +1 -1
- package/esm/util/generate-component.js +3 -3
- package/esm/util/generate-component.js.map +1 -1
- package/esm/util/mcp-server-utils.d.ts +23 -0
- package/esm/util/mcp-server-utils.d.ts.map +1 -0
- package/esm/util/mcp-server-utils.js +102 -0
- package/esm/util/mcp-server-utils.js.map +1 -0
- package/esm/util/mcp-server-utils.test.d.ts +2 -0
- package/esm/util/mcp-server-utils.test.d.ts.map +1 -0
- package/esm/util/mcp-server-utils.test.js +285 -0
- package/esm/util/mcp-server-utils.test.js.map +1 -0
- package/esm/util/message-builder.d.ts +2 -1
- package/esm/util/message-builder.d.ts.map +1 -1
- package/esm/util/message-builder.js +54 -36
- package/esm/util/message-builder.js.map +1 -1
- package/esm/util/message-builder.test.js +500 -13
- package/esm/util/message-builder.test.js.map +1 -1
- package/esm/util/registry-validators.d.ts +26 -0
- package/esm/util/registry-validators.d.ts.map +1 -0
- package/esm/util/registry-validators.js +100 -0
- package/esm/util/registry-validators.js.map +1 -0
- package/esm/util/registry-validators.test.d.ts +2 -0
- package/esm/util/registry-validators.test.d.ts.map +1 -0
- package/esm/util/registry-validators.test.js +233 -0
- package/esm/util/registry-validators.test.js.map +1 -0
- package/esm/util/registry.d.ts +35 -7
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +57 -73
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.d.ts +2 -0
- package/esm/util/registry.test.d.ts.map +1 -0
- package/esm/util/registry.test.js +169 -0
- package/esm/util/registry.test.js.map +1 -0
- package/esm/util/resource-validators.d.ts +16 -0
- package/esm/util/resource-validators.d.ts.map +1 -0
- package/esm/util/resource-validators.js +30 -0
- package/esm/util/resource-validators.js.map +1 -0
- 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 +12 -4
- package/esm/util/tool-caller.js.map +1 -1
- package/package.json +13 -8
- package/dist/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
- package/dist/providers/hoc/with-tambo-interactable.js.map +0 -1
- package/dist/util/validate-zod-schema.d.ts +0 -10
- package/dist/util/validate-zod-schema.d.ts.map +0 -1
- package/dist/util/validate-zod-schema.js +0 -100
- package/dist/util/validate-zod-schema.js.map +0 -1
- package/dist/util/validate-zod-schema.test.d.ts +0 -2
- package/dist/util/validate-zod-schema.test.d.ts.map +0 -1
- package/dist/util/validate-zod-schema.test.js +0 -96
- package/dist/util/validate-zod-schema.test.js.map +0 -1
- package/esm/providers/hoc/with-tambo-interactable.d.ts.map +0 -1
- package/esm/providers/hoc/with-tambo-interactable.js.map +0 -1
- package/esm/util/validate-zod-schema.d.ts +0 -10
- package/esm/util/validate-zod-schema.d.ts.map +0 -1
- package/esm/util/validate-zod-schema.js +0 -97
- package/esm/util/validate-zod-schema.js.map +0 -1
- package/esm/util/validate-zod-schema.test.d.ts +0 -2
- package/esm/util/validate-zod-schema.test.d.ts.map +0 -1
- package/esm/util/validate-zod-schema.test.js +0 -94
- package/esm/util/validate-zod-schema.test.js.map +0 -1
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
/**
|
|
40
|
+
* Tests for schema compatibility with registerTool and registerComponent.
|
|
41
|
+
*
|
|
42
|
+
* These tests verify that the registry functions work correctly with:
|
|
43
|
+
* - Zod 3 schemas (current primary)
|
|
44
|
+
* - Zod 4 schemas (Standard Schema native)
|
|
45
|
+
* - Raw JSON Schema objects
|
|
46
|
+
*/
|
|
47
|
+
const react_1 = require("@testing-library/react");
|
|
48
|
+
const react_2 = __importDefault(require("react"));
|
|
49
|
+
const z3 = __importStar(require("zod/v3"));
|
|
50
|
+
const z4 = __importStar(require("zod/v4"));
|
|
51
|
+
const registry_1 = require("../util/registry");
|
|
52
|
+
const tambo_registry_provider_1 = require("./tambo-registry-provider");
|
|
53
|
+
// Test component for registration tests
|
|
54
|
+
const TestComponent = ({ message }) => (react_2.default.createElement("div", null, message));
|
|
55
|
+
describe("Schema Compatibility", () => {
|
|
56
|
+
const wrapper = ({ children }) => (react_2.default.createElement(tambo_registry_provider_1.TamboRegistryProvider, null, children));
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
jest.clearAllMocks();
|
|
59
|
+
});
|
|
60
|
+
describe("registerComponent with different schema types", () => {
|
|
61
|
+
describe("Zod 3 schemas", () => {
|
|
62
|
+
it("should register component with Zod 3 object schema", () => {
|
|
63
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
64
|
+
const component = {
|
|
65
|
+
name: "Zod3ObjectComponent",
|
|
66
|
+
component: TestComponent,
|
|
67
|
+
description: "Component with Zod 3 object schema",
|
|
68
|
+
propsSchema: z3.object({
|
|
69
|
+
message: z3.string().describe("The message to display"),
|
|
70
|
+
count: z3.number().optional().describe("Optional count"),
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
(0, react_1.act)(() => {
|
|
74
|
+
result.current.registerComponent(component);
|
|
75
|
+
});
|
|
76
|
+
expect(result.current.componentList).toHaveProperty("Zod3ObjectComponent");
|
|
77
|
+
const registered = result.current.componentList.Zod3ObjectComponent;
|
|
78
|
+
expect(registered.name).toBe("Zod3ObjectComponent");
|
|
79
|
+
expect(registered.props).toBeDefined();
|
|
80
|
+
expect(registered.props).toHaveProperty("type", "object");
|
|
81
|
+
});
|
|
82
|
+
it("should register component with Zod 3 nested object schema", () => {
|
|
83
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
84
|
+
const component = {
|
|
85
|
+
name: "Zod3NestedComponent",
|
|
86
|
+
component: TestComponent,
|
|
87
|
+
description: "Component with nested Zod 3 schema",
|
|
88
|
+
propsSchema: z3.object({
|
|
89
|
+
user: z3.object({
|
|
90
|
+
name: z3.string(),
|
|
91
|
+
email: z3.string().email(),
|
|
92
|
+
}),
|
|
93
|
+
settings: z3.object({
|
|
94
|
+
theme: z3.enum(["light", "dark"]),
|
|
95
|
+
notifications: z3.boolean(),
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
(0, react_1.act)(() => {
|
|
100
|
+
result.current.registerComponent(component);
|
|
101
|
+
});
|
|
102
|
+
expect(result.current.componentList).toHaveProperty("Zod3NestedComponent");
|
|
103
|
+
});
|
|
104
|
+
it("should register component with Zod 3 array schema", () => {
|
|
105
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
106
|
+
const component = {
|
|
107
|
+
name: "Zod3ArrayComponent",
|
|
108
|
+
component: TestComponent,
|
|
109
|
+
description: "Component with Zod 3 array schema",
|
|
110
|
+
propsSchema: z3.object({
|
|
111
|
+
items: z3.array(z3.string()).describe("List of items"),
|
|
112
|
+
tags: z3.array(z3.object({
|
|
113
|
+
id: z3.number(),
|
|
114
|
+
label: z3.string(),
|
|
115
|
+
})),
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
(0, react_1.act)(() => {
|
|
119
|
+
result.current.registerComponent(component);
|
|
120
|
+
});
|
|
121
|
+
expect(result.current.componentList).toHaveProperty("Zod3ArrayComponent");
|
|
122
|
+
});
|
|
123
|
+
it("should register component with Zod 3 union schema", () => {
|
|
124
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
125
|
+
const component = {
|
|
126
|
+
name: "Zod3UnionComponent",
|
|
127
|
+
component: TestComponent,
|
|
128
|
+
description: "Component with Zod 3 union schema",
|
|
129
|
+
propsSchema: z3.object({
|
|
130
|
+
value: z3.union([z3.string(), z3.number()]),
|
|
131
|
+
status: z3.enum(["pending", "active", "completed"]),
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
(0, react_1.act)(() => {
|
|
135
|
+
result.current.registerComponent(component);
|
|
136
|
+
});
|
|
137
|
+
expect(result.current.componentList).toHaveProperty("Zod3UnionComponent");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe("Zod 4 schemas", () => {
|
|
141
|
+
it("should register component with Zod 4 object schema", () => {
|
|
142
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
143
|
+
const component = {
|
|
144
|
+
name: "Zod4ObjectComponent",
|
|
145
|
+
component: TestComponent,
|
|
146
|
+
description: "Component with Zod 4 object schema",
|
|
147
|
+
propsSchema: z4.object({
|
|
148
|
+
message: z4.string().describe("The message to display"),
|
|
149
|
+
count: z4.number().optional().describe("Optional count"),
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
(0, react_1.act)(() => {
|
|
153
|
+
result.current.registerComponent(component);
|
|
154
|
+
});
|
|
155
|
+
expect(result.current.componentList).toHaveProperty("Zod4ObjectComponent");
|
|
156
|
+
const registered = result.current.componentList.Zod4ObjectComponent;
|
|
157
|
+
expect(registered.name).toBe("Zod4ObjectComponent");
|
|
158
|
+
expect(registered.props).toBeDefined();
|
|
159
|
+
expect(registered.props).toHaveProperty("type", "object");
|
|
160
|
+
});
|
|
161
|
+
it("should register component with Zod 4 nested object schema", () => {
|
|
162
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
163
|
+
const component = {
|
|
164
|
+
name: "Zod4NestedComponent",
|
|
165
|
+
component: TestComponent,
|
|
166
|
+
description: "Component with nested Zod 4 schema",
|
|
167
|
+
propsSchema: z4.object({
|
|
168
|
+
user: z4.object({
|
|
169
|
+
name: z4.string(),
|
|
170
|
+
email: z4.email(),
|
|
171
|
+
}),
|
|
172
|
+
settings: z4.object({
|
|
173
|
+
theme: z4.enum(["light", "dark"]),
|
|
174
|
+
notifications: z4.boolean(),
|
|
175
|
+
}),
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
(0, react_1.act)(() => {
|
|
179
|
+
result.current.registerComponent(component);
|
|
180
|
+
});
|
|
181
|
+
expect(result.current.componentList).toHaveProperty("Zod4NestedComponent");
|
|
182
|
+
});
|
|
183
|
+
it("should register component with Zod 4 array schema", () => {
|
|
184
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
185
|
+
const component = {
|
|
186
|
+
name: "Zod4ArrayComponent",
|
|
187
|
+
component: TestComponent,
|
|
188
|
+
description: "Component with Zod 4 array schema",
|
|
189
|
+
propsSchema: z4.object({
|
|
190
|
+
items: z4.array(z4.string()).describe("List of items"),
|
|
191
|
+
tags: z4.array(z4.object({
|
|
192
|
+
id: z4.number(),
|
|
193
|
+
label: z4.string(),
|
|
194
|
+
})),
|
|
195
|
+
}),
|
|
196
|
+
};
|
|
197
|
+
(0, react_1.act)(() => {
|
|
198
|
+
result.current.registerComponent(component);
|
|
199
|
+
});
|
|
200
|
+
expect(result.current.componentList).toHaveProperty("Zod4ArrayComponent");
|
|
201
|
+
});
|
|
202
|
+
it("should register component with Zod 4 union schema", () => {
|
|
203
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
204
|
+
const component = {
|
|
205
|
+
name: "Zod4UnionComponent",
|
|
206
|
+
component: TestComponent,
|
|
207
|
+
description: "Component with Zod 4 union schema",
|
|
208
|
+
propsSchema: z4.object({
|
|
209
|
+
value: z4.union([z4.string(), z4.number()]),
|
|
210
|
+
status: z4.enum(["pending", "active", "completed"]),
|
|
211
|
+
}),
|
|
212
|
+
};
|
|
213
|
+
(0, react_1.act)(() => {
|
|
214
|
+
result.current.registerComponent(component);
|
|
215
|
+
});
|
|
216
|
+
expect(result.current.componentList).toHaveProperty("Zod4UnionComponent");
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe("JSON Schema objects", () => {
|
|
220
|
+
it("should register component with raw JSON Schema", () => {
|
|
221
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
222
|
+
const jsonSchema = {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {
|
|
225
|
+
message: { type: "string", description: "The message to display" },
|
|
226
|
+
count: { type: "number", description: "Optional count" },
|
|
227
|
+
},
|
|
228
|
+
required: ["message"],
|
|
229
|
+
};
|
|
230
|
+
const component = {
|
|
231
|
+
name: "JsonSchemaComponent",
|
|
232
|
+
component: TestComponent,
|
|
233
|
+
description: "Component with raw JSON Schema",
|
|
234
|
+
propsSchema: jsonSchema,
|
|
235
|
+
};
|
|
236
|
+
(0, react_1.act)(() => {
|
|
237
|
+
result.current.registerComponent(component);
|
|
238
|
+
});
|
|
239
|
+
expect(result.current.componentList).toHaveProperty("JsonSchemaComponent");
|
|
240
|
+
const registered = result.current.componentList.JsonSchemaComponent;
|
|
241
|
+
expect(registered.props).toEqual(jsonSchema);
|
|
242
|
+
});
|
|
243
|
+
it("should register component with complex JSON Schema", () => {
|
|
244
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
245
|
+
const jsonSchema = {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: {
|
|
248
|
+
user: {
|
|
249
|
+
type: "object",
|
|
250
|
+
properties: {
|
|
251
|
+
name: { type: "string" },
|
|
252
|
+
email: { type: "string", format: "email" },
|
|
253
|
+
},
|
|
254
|
+
required: ["name", "email"],
|
|
255
|
+
},
|
|
256
|
+
items: {
|
|
257
|
+
type: "array",
|
|
258
|
+
items: {
|
|
259
|
+
type: "object",
|
|
260
|
+
properties: {
|
|
261
|
+
id: { type: "number" },
|
|
262
|
+
label: { type: "string" },
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
required: ["user"],
|
|
268
|
+
};
|
|
269
|
+
const component = {
|
|
270
|
+
name: "ComplexJsonSchemaComponent",
|
|
271
|
+
component: TestComponent,
|
|
272
|
+
description: "Component with complex JSON Schema",
|
|
273
|
+
propsSchema: jsonSchema,
|
|
274
|
+
};
|
|
275
|
+
(0, react_1.act)(() => {
|
|
276
|
+
result.current.registerComponent(component);
|
|
277
|
+
});
|
|
278
|
+
expect(result.current.componentList).toHaveProperty("ComplexJsonSchemaComponent");
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe("registerTool with different schema types", () => {
|
|
283
|
+
describe("Zod 3 function schemas", () => {
|
|
284
|
+
it("should register tool with Zod 3 function schema", () => {
|
|
285
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
286
|
+
const tool = (0, registry_1.defineTool)({
|
|
287
|
+
name: "zod3-function-tool",
|
|
288
|
+
description: "Tool with Zod 3 function schema",
|
|
289
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
290
|
+
toolSchema: z3
|
|
291
|
+
.function()
|
|
292
|
+
.args(z3.string().describe("input parameter"))
|
|
293
|
+
.returns(z3.string()),
|
|
294
|
+
});
|
|
295
|
+
(0, react_1.act)(() => {
|
|
296
|
+
result.current.registerTool(tool);
|
|
297
|
+
});
|
|
298
|
+
expect(result.current.toolRegistry).toHaveProperty("zod3-function-tool");
|
|
299
|
+
});
|
|
300
|
+
it("should register tool with Zod 3 function schema with multiple args", () => {
|
|
301
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
302
|
+
const tool = (0, registry_1.defineTool)({
|
|
303
|
+
name: "zod3-multi-arg-tool",
|
|
304
|
+
description: "Tool with multiple arguments",
|
|
305
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
306
|
+
toolSchema: z3
|
|
307
|
+
.function()
|
|
308
|
+
.args(z3.string().describe("first argument"), z3.number().describe("second argument"), z3.boolean().optional().describe("optional third argument"))
|
|
309
|
+
.returns(z3.object({ success: z3.boolean() })),
|
|
310
|
+
});
|
|
311
|
+
(0, react_1.act)(() => {
|
|
312
|
+
result.current.registerTool(tool);
|
|
313
|
+
});
|
|
314
|
+
expect(result.current.toolRegistry).toHaveProperty("zod3-multi-arg-tool");
|
|
315
|
+
});
|
|
316
|
+
it("should register tool with Zod 3 function schema with object arg", () => {
|
|
317
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
318
|
+
const tool = (0, registry_1.defineTool)({
|
|
319
|
+
name: "zod3-object-arg-tool",
|
|
320
|
+
description: "Tool with object argument",
|
|
321
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
322
|
+
toolSchema: z3
|
|
323
|
+
.function()
|
|
324
|
+
.args(z3
|
|
325
|
+
.object({
|
|
326
|
+
query: z3.string().describe("search query"),
|
|
327
|
+
limit: z3.number().optional().describe("max results"),
|
|
328
|
+
filters: z3.array(z3.string()).optional(),
|
|
329
|
+
})
|
|
330
|
+
.describe("search options"))
|
|
331
|
+
.returns(z3.array(z3.string())),
|
|
332
|
+
});
|
|
333
|
+
(0, react_1.act)(() => {
|
|
334
|
+
result.current.registerTool(tool);
|
|
335
|
+
});
|
|
336
|
+
expect(result.current.toolRegistry).toHaveProperty("zod3-object-arg-tool");
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
describe("Zod 4 object schemas for tools", () => {
|
|
340
|
+
// Note: Zod 4 uses a different function schema API than Zod 3
|
|
341
|
+
// Zod 4: z.function({ input: z.tuple([...]), output: ... })
|
|
342
|
+
// For tools, we recommend using object schemas instead of function schemas
|
|
343
|
+
// since they work consistently across both versions
|
|
344
|
+
it("should register tool with Zod 4 object schema", () => {
|
|
345
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
346
|
+
const tool = (0, registry_1.defineTool)({
|
|
347
|
+
name: "zod4-object-tool",
|
|
348
|
+
description: "Tool with Zod 4 object schema",
|
|
349
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
350
|
+
inputSchema: z4.tuple([z4.string().describe("input parameter")]),
|
|
351
|
+
outputSchema: z4.string(),
|
|
352
|
+
});
|
|
353
|
+
(0, react_1.act)(() => {
|
|
354
|
+
result.current.registerTool(tool);
|
|
355
|
+
});
|
|
356
|
+
expect(result.current.toolRegistry).toHaveProperty("zod4-object-tool");
|
|
357
|
+
});
|
|
358
|
+
it("should register tool with Zod 4 object schema with multiple fields", () => {
|
|
359
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
360
|
+
const tool = (0, registry_1.defineTool)({
|
|
361
|
+
name: "zod4-multi-field-tool",
|
|
362
|
+
description: "Tool with multiple Zod 4 fields",
|
|
363
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
364
|
+
inputSchema: z4.tuple([
|
|
365
|
+
z4.object({
|
|
366
|
+
first: z4.string().describe("first argument"),
|
|
367
|
+
second: z4.number().describe("second argument"),
|
|
368
|
+
third: z4
|
|
369
|
+
.boolean()
|
|
370
|
+
.optional()
|
|
371
|
+
.describe("optional third argument"),
|
|
372
|
+
}),
|
|
373
|
+
]),
|
|
374
|
+
outputSchema: z4.array(z4.string()),
|
|
375
|
+
});
|
|
376
|
+
(0, react_1.act)(() => {
|
|
377
|
+
result.current.registerTool(tool);
|
|
378
|
+
});
|
|
379
|
+
expect(result.current.toolRegistry).toHaveProperty("zod4-multi-field-tool");
|
|
380
|
+
});
|
|
381
|
+
it("should register tool with Zod 4 nested object schema", () => {
|
|
382
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
383
|
+
const tool = (0, registry_1.defineTool)({
|
|
384
|
+
name: "zod4-nested-object-tool",
|
|
385
|
+
description: "Tool with Zod 4 nested object",
|
|
386
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
387
|
+
inputSchema: z4.tuple([
|
|
388
|
+
z4
|
|
389
|
+
.object({
|
|
390
|
+
query: z4.string().describe("search query"),
|
|
391
|
+
limit: z4.number().optional().describe("max results"),
|
|
392
|
+
filters: z4.array(z4.string()).optional(),
|
|
393
|
+
})
|
|
394
|
+
.describe("search options"),
|
|
395
|
+
]),
|
|
396
|
+
outputSchema: z4.array(z4.string()),
|
|
397
|
+
});
|
|
398
|
+
(0, react_1.act)(() => {
|
|
399
|
+
result.current.registerTool(tool);
|
|
400
|
+
});
|
|
401
|
+
expect(result.current.toolRegistry).toHaveProperty("zod4-nested-object-tool");
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
describe("JSON Schema for tools", () => {
|
|
405
|
+
it("should register tool with JSON Schema", () => {
|
|
406
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
407
|
+
const jsonSchema = {
|
|
408
|
+
type: "object",
|
|
409
|
+
description: "Tool parameters",
|
|
410
|
+
properties: {
|
|
411
|
+
query: { type: "string", description: "The search query" },
|
|
412
|
+
limit: { type: "number", description: "Max results to return" },
|
|
413
|
+
},
|
|
414
|
+
required: ["query"],
|
|
415
|
+
};
|
|
416
|
+
const tool = (0, registry_1.defineTool)({
|
|
417
|
+
name: "json-schema-tool",
|
|
418
|
+
description: "Tool with raw JSON Schema",
|
|
419
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
420
|
+
inputSchema: jsonSchema,
|
|
421
|
+
outputSchema: {},
|
|
422
|
+
});
|
|
423
|
+
(0, react_1.act)(() => {
|
|
424
|
+
result.current.registerTool(tool);
|
|
425
|
+
});
|
|
426
|
+
expect(result.current.toolRegistry).toHaveProperty("json-schema-tool");
|
|
427
|
+
});
|
|
428
|
+
it("should register tool with complex JSON Schema", () => {
|
|
429
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
430
|
+
const jsonSchema = {
|
|
431
|
+
type: "object",
|
|
432
|
+
description: "Complex search parameters",
|
|
433
|
+
properties: {
|
|
434
|
+
search: {
|
|
435
|
+
type: "object",
|
|
436
|
+
properties: {
|
|
437
|
+
query: { type: "string" },
|
|
438
|
+
filters: {
|
|
439
|
+
type: "array",
|
|
440
|
+
items: {
|
|
441
|
+
type: "object",
|
|
442
|
+
properties: {
|
|
443
|
+
field: { type: "string" },
|
|
444
|
+
value: { type: "string" },
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
required: ["query"],
|
|
450
|
+
},
|
|
451
|
+
pagination: {
|
|
452
|
+
type: "object",
|
|
453
|
+
properties: {
|
|
454
|
+
page: { type: "number" },
|
|
455
|
+
pageSize: { type: "number" },
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
required: ["search"],
|
|
460
|
+
};
|
|
461
|
+
const tool = (0, registry_1.defineTool)({
|
|
462
|
+
name: "complex-json-schema-tool",
|
|
463
|
+
description: "Tool with complex JSON Schema",
|
|
464
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
465
|
+
inputSchema: jsonSchema,
|
|
466
|
+
outputSchema: {},
|
|
467
|
+
});
|
|
468
|
+
(0, react_1.act)(() => {
|
|
469
|
+
result.current.registerTool(tool);
|
|
470
|
+
});
|
|
471
|
+
expect(result.current.toolRegistry).toHaveProperty("complex-json-schema-tool");
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
describe("Schema validation errors", () => {
|
|
476
|
+
it("should reject Zod 3 z.record() in component propsSchema", () => {
|
|
477
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
478
|
+
const component = {
|
|
479
|
+
name: "InvalidZod3RecordComponent",
|
|
480
|
+
component: TestComponent,
|
|
481
|
+
description: "Component with invalid z.record() schema",
|
|
482
|
+
propsSchema: z3.record(z3.string()),
|
|
483
|
+
};
|
|
484
|
+
expect(() => {
|
|
485
|
+
(0, react_1.act)(() => {
|
|
486
|
+
result.current.registerComponent(component);
|
|
487
|
+
});
|
|
488
|
+
}).toThrow(/Record types \(objects with dynamic keys\) are not supported/);
|
|
489
|
+
});
|
|
490
|
+
it("should reject Zod 4 z.record() in component propsSchema", () => {
|
|
491
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
492
|
+
const component = {
|
|
493
|
+
name: "InvalidZod4RecordComponent",
|
|
494
|
+
component: TestComponent,
|
|
495
|
+
description: "Component with invalid Zod 4 z.record() schema",
|
|
496
|
+
// Zod 4 record requires key type and value type
|
|
497
|
+
propsSchema: z4.record(z4.string(), z4.string()),
|
|
498
|
+
};
|
|
499
|
+
expect(() => {
|
|
500
|
+
(0, react_1.act)(() => {
|
|
501
|
+
result.current.registerComponent(component);
|
|
502
|
+
});
|
|
503
|
+
}).toThrow(/Record types \(objects with dynamic keys\) are not supported/);
|
|
504
|
+
});
|
|
505
|
+
it("should reject Zod 3 z.record() in tool schema", () => {
|
|
506
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
507
|
+
const tool = (0, registry_1.defineTool)({
|
|
508
|
+
name: "invalid-zod3-record-tool",
|
|
509
|
+
description: "Tool with invalid z.record() schema",
|
|
510
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
511
|
+
inputSchema: z3.tuple([z3.record(z3.string())]),
|
|
512
|
+
outputSchema: z3.string(),
|
|
513
|
+
});
|
|
514
|
+
expect(() => {
|
|
515
|
+
(0, react_1.act)(() => {
|
|
516
|
+
result.current.registerTool(tool);
|
|
517
|
+
});
|
|
518
|
+
}).toThrow(/Record types \(objects with dynamic keys\) are not supported/);
|
|
519
|
+
});
|
|
520
|
+
it("should reject Zod 4 z.record() in tool schema", () => {
|
|
521
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
522
|
+
const tool = (0, registry_1.defineTool)({
|
|
523
|
+
name: "invalid-zod4-record-tool",
|
|
524
|
+
description: "Tool with invalid Zod 4 z.record() schema",
|
|
525
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
526
|
+
inputSchema: z4.array(z4.record(z4.string(), z4.string())),
|
|
527
|
+
outputSchema: z4.string(),
|
|
528
|
+
});
|
|
529
|
+
expect(() => {
|
|
530
|
+
(0, react_1.act)(() => {
|
|
531
|
+
result.current.registerTool(tool);
|
|
532
|
+
});
|
|
533
|
+
}).toThrow(/Record types \(objects with dynamic keys\) are not supported/);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
describe("Cross-version compatibility", () => {
|
|
537
|
+
it("should register components with mixed Zod 3 and Zod 4 schemas", () => {
|
|
538
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
539
|
+
// Register Zod 3 component
|
|
540
|
+
const zod3Component = {
|
|
541
|
+
name: "MixedZod3Component",
|
|
542
|
+
component: TestComponent,
|
|
543
|
+
description: "Zod 3 component",
|
|
544
|
+
propsSchema: z3.object({ value: z3.string() }),
|
|
545
|
+
};
|
|
546
|
+
// Register Zod 4 component
|
|
547
|
+
const zod4Component = {
|
|
548
|
+
name: "MixedZod4Component",
|
|
549
|
+
component: TestComponent,
|
|
550
|
+
description: "Zod 4 component",
|
|
551
|
+
propsSchema: z4.object({ value: z4.string() }),
|
|
552
|
+
};
|
|
553
|
+
(0, react_1.act)(() => {
|
|
554
|
+
result.current.registerComponent(zod3Component);
|
|
555
|
+
result.current.registerComponent(zod4Component);
|
|
556
|
+
});
|
|
557
|
+
expect(result.current.componentList).toHaveProperty("MixedZod3Component");
|
|
558
|
+
expect(result.current.componentList).toHaveProperty("MixedZod4Component");
|
|
559
|
+
});
|
|
560
|
+
it("should register tools with mixed Zod 3, Zod 4, and JSON Schema", () => {
|
|
561
|
+
const { result } = (0, react_1.renderHook)(() => (0, tambo_registry_provider_1.useTamboRegistry)(), { wrapper });
|
|
562
|
+
// Zod 3 tool (using function schema)
|
|
563
|
+
const zod3Tool = (0, registry_1.defineTool)({
|
|
564
|
+
name: "mixed-zod3-tool",
|
|
565
|
+
description: "Zod 3 tool",
|
|
566
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
567
|
+
toolSchema: z3.function().args(z3.string()).returns(z3.string()),
|
|
568
|
+
});
|
|
569
|
+
// Zod 4 tool (using Standard Schema)
|
|
570
|
+
const zod4Tool = (0, registry_1.defineTool)({
|
|
571
|
+
name: "mixed-zod4-tool",
|
|
572
|
+
description: "Zod 4 tool",
|
|
573
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
574
|
+
inputSchema: z4.tuple([z4.string()]),
|
|
575
|
+
outputSchema: z4.string(),
|
|
576
|
+
});
|
|
577
|
+
// JSON Schema tool
|
|
578
|
+
const jsonSchemaTool = (0, registry_1.defineTool)({
|
|
579
|
+
name: "mixed-json-schema-tool",
|
|
580
|
+
description: "JSON Schema tool",
|
|
581
|
+
tool: jest.fn().mockResolvedValue("result"),
|
|
582
|
+
inputSchema: {
|
|
583
|
+
type: "object",
|
|
584
|
+
properties: {
|
|
585
|
+
input: { type: "string" },
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
outputSchema: { type: "string" },
|
|
589
|
+
});
|
|
590
|
+
(0, react_1.act)(() => {
|
|
591
|
+
result.current.registerTools([zod3Tool, zod4Tool, jsonSchemaTool]);
|
|
592
|
+
});
|
|
593
|
+
expect(result.current.toolRegistry).toHaveProperty("mixed-zod3-tool");
|
|
594
|
+
expect(result.current.toolRegistry).toHaveProperty("mixed-zod4-tool");
|
|
595
|
+
expect(result.current.toolRegistry).toHaveProperty("mixed-json-schema-tool");
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
describe("Standard Schema interface verification", () => {
|
|
599
|
+
it("should verify Zod 3 schema has ~standard property", () => {
|
|
600
|
+
const schema = z3.object({ value: z3.string() });
|
|
601
|
+
expect("~standard" in schema).toBe(true);
|
|
602
|
+
});
|
|
603
|
+
it("should verify Zod 4 schema has ~standard property", () => {
|
|
604
|
+
const schema = z4.object({ value: z4.string() });
|
|
605
|
+
expect("~standard" in schema).toBe(true);
|
|
606
|
+
});
|
|
607
|
+
it("should verify JSON Schema does not have ~standard property", () => {
|
|
608
|
+
const schema = {
|
|
609
|
+
type: "object",
|
|
610
|
+
properties: { value: { type: "string" } },
|
|
611
|
+
};
|
|
612
|
+
expect("~standard" in schema).toBe(false);
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
//# sourceMappingURL=tambo-registry-schema-compat.test.js.map
|