@tambo-ai/react 0.37.3 → 0.38.1
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/dist/hooks/__tests__/use-tambo-threads.test.js +1 -0
- package/dist/hooks/__tests__/use-tambo-threads.test.js.map +1 -1
- package/dist/hooks/use-tambo-threads.d.ts +5 -0
- package/dist/hooks/use-tambo-threads.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/model/tambo-interactable.d.ts +24 -0
- package/dist/model/tambo-interactable.d.ts.map +1 -0
- package/dist/model/tambo-interactable.js +3 -0
- package/dist/model/tambo-interactable.js.map +1 -0
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.d.ts +2 -0
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.d.ts.map +1 -0
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.js +278 -0
- package/dist/providers/__tests__/tambo-prop-stream-provider.test.js.map +1 -0
- package/dist/providers/hoc/with-tambo-interactable.d.ts +34 -0
- package/dist/providers/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/dist/providers/hoc/with-tambo-interactable.js +119 -0
- package/dist/providers/hoc/with-tambo-interactable.js.map +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +4 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts +20 -0
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -0
- package/dist/providers/tambo-interactable-provider.js +243 -0
- package/dist/providers/tambo-interactable-provider.js.map +1 -0
- package/dist/providers/tambo-prop-stream-provider.d.ts +96 -0
- package/dist/providers/tambo-prop-stream-provider.d.ts.map +1 -0
- package/dist/providers/tambo-prop-stream-provider.js +185 -0
- package/dist/providers/tambo-prop-stream-provider.js.map +1 -0
- package/dist/providers/tambo-provider.d.ts +6 -4
- package/dist/providers/tambo-provider.d.ts.map +1 -1
- package/dist/providers/tambo-provider.js +9 -4
- package/dist/providers/tambo-provider.js.map +1 -1
- package/dist/util/query-utils.d.ts.map +1 -1
- package/dist/util/query-utils.js +1 -0
- package/dist/util/query-utils.js.map +1 -1
- package/esm/hooks/__tests__/use-tambo-threads.test.js +1 -0
- package/esm/hooks/__tests__/use-tambo-threads.test.js.map +1 -1
- package/esm/hooks/use-tambo-threads.d.ts +5 -0
- package/esm/hooks/use-tambo-threads.d.ts.map +1 -1
- package/esm/index.d.ts +5 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/esm/model/tambo-interactable.d.ts +24 -0
- package/esm/model/tambo-interactable.d.ts.map +1 -0
- package/esm/model/tambo-interactable.js +2 -0
- package/esm/model/tambo-interactable.js.map +1 -0
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.d.ts +2 -0
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.d.ts.map +1 -0
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.js +273 -0
- package/esm/providers/__tests__/tambo-prop-stream-provider.test.js.map +1 -0
- package/esm/providers/hoc/with-tambo-interactable.d.ts +34 -0
- package/esm/providers/hoc/with-tambo-interactable.d.ts.map +1 -0
- package/esm/providers/hoc/with-tambo-interactable.js +83 -0
- package/esm/providers/hoc/with-tambo-interactable.js.map +1 -0
- package/esm/providers/index.d.ts +2 -0
- package/esm/providers/index.d.ts.map +1 -1
- package/esm/providers/index.js +1 -0
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts +20 -0
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -0
- package/esm/providers/tambo-interactable-provider.js +205 -0
- package/esm/providers/tambo-interactable-provider.js.map +1 -0
- package/esm/providers/tambo-prop-stream-provider.d.ts +96 -0
- package/esm/providers/tambo-prop-stream-provider.d.ts.map +1 -0
- package/esm/providers/tambo-prop-stream-provider.js +148 -0
- package/esm/providers/tambo-prop-stream-provider.js.map +1 -0
- package/esm/providers/tambo-provider.d.ts +6 -4
- package/esm/providers/tambo-provider.d.ts.map +1 -1
- package/esm/providers/tambo-provider.js +9 -4
- package/esm/providers/tambo-provider.js.map +1 -1
- package/esm/util/query-utils.d.ts.map +1 -1
- package/esm/util/query-utils.js +1 -0
- package/esm/util/query-utils.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TamboPropStreamProvider = exports.useTamboStream = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const TamboPropStreamContext = (0, react_1.createContext)(null);
|
|
40
|
+
/**
|
|
41
|
+
* Loading component that renders children when the stream is in a loading state
|
|
42
|
+
* @param props - The props for the Loading component
|
|
43
|
+
* @param props.streamKey - The key to identify this loading state
|
|
44
|
+
* @param props.children - The children to render when loading
|
|
45
|
+
* @param props.className - Optional className for styling
|
|
46
|
+
* @returns The Loading component
|
|
47
|
+
*/
|
|
48
|
+
const Loading = ({ streamKey = "default", children, className, }) => {
|
|
49
|
+
const { getStatusForKey } = (0, exports.useTamboStream)();
|
|
50
|
+
const status = getStatusForKey(streamKey);
|
|
51
|
+
if (!status.isPending && !status.isStreaming) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return (react_1.default.createElement("div", { className: className, "data-stream-key": streamKey, "data-stream-state": "loading" }, children));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Empty component that renders children when the stream has no data
|
|
58
|
+
* @param props - The props for the Empty component
|
|
59
|
+
* @param props.streamKey - The key to identify this empty state
|
|
60
|
+
* @param props.children - The children to render when empty
|
|
61
|
+
* @param props.className - Optional className for styling
|
|
62
|
+
* @returns The Empty component
|
|
63
|
+
*/
|
|
64
|
+
const Empty = ({ streamKey = "default", children, className, }) => {
|
|
65
|
+
const { data, getStatusForKey } = (0, exports.useTamboStream)();
|
|
66
|
+
const status = getStatusForKey(streamKey);
|
|
67
|
+
// Get the specific data for this key
|
|
68
|
+
const keyData = data && typeof data === "object" && !Array.isArray(data)
|
|
69
|
+
? data[streamKey]
|
|
70
|
+
: data;
|
|
71
|
+
// Show empty state when not loading, not streaming, not successful, and no data for this key
|
|
72
|
+
const shouldShowEmpty = !status.isPending &&
|
|
73
|
+
!status.isStreaming &&
|
|
74
|
+
!status.isSuccess &&
|
|
75
|
+
!status.isError &&
|
|
76
|
+
(keyData === undefined || keyData === null || keyData === "");
|
|
77
|
+
if (!shouldShowEmpty) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return (react_1.default.createElement("div", { className: className, "data-stream-key": streamKey, "data-stream-state": "empty" }, children));
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Complete component that renders children when the stream has data
|
|
84
|
+
* @param props - The props for the Complete component
|
|
85
|
+
* @param props.streamKey - The key to identify this complete state
|
|
86
|
+
* @param props.children - The children to render when complete
|
|
87
|
+
* @param props.className - Optional className for styling
|
|
88
|
+
* @returns The Complete component
|
|
89
|
+
*/
|
|
90
|
+
const Complete = ({ streamKey = "default", children, className, }) => {
|
|
91
|
+
const { data, getStatusForKey } = (0, exports.useTamboStream)();
|
|
92
|
+
const status = getStatusForKey(streamKey);
|
|
93
|
+
// Get the specific data for this key
|
|
94
|
+
const keyData = data && typeof data === "object" && !Array.isArray(data)
|
|
95
|
+
? data[streamKey]
|
|
96
|
+
: data;
|
|
97
|
+
// Show complete when we have data for this key and the stream is successful
|
|
98
|
+
const shouldShowComplete = status.isSuccess && keyData !== undefined && keyData !== null;
|
|
99
|
+
if (!shouldShowComplete) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return (react_1.default.createElement("div", { className: className, "data-stream-key": streamKey, "data-stream-state": "complete" }, children));
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Hook to use the TamboStream context
|
|
106
|
+
* @returns The TamboStream context
|
|
107
|
+
*/
|
|
108
|
+
const useTamboStream = () => {
|
|
109
|
+
const context = (0, react_1.useContext)(TamboPropStreamContext);
|
|
110
|
+
if (!context) {
|
|
111
|
+
throw new Error("useTamboStream must be used within a TamboPropStreamProvider");
|
|
112
|
+
}
|
|
113
|
+
return context;
|
|
114
|
+
};
|
|
115
|
+
exports.useTamboStream = useTamboStream;
|
|
116
|
+
/**
|
|
117
|
+
* The TamboStreamProvider provides a context for managing stream states
|
|
118
|
+
* with compound components for Loading, Empty, and Complete states.
|
|
119
|
+
* @param props - The props for the TamboStreamProvider
|
|
120
|
+
* @param props.children - The children to wrap
|
|
121
|
+
* @param props.data - The stream data
|
|
122
|
+
* @param props.streamStatus - Optional stream status for more granular control
|
|
123
|
+
* @returns The TamboStreamProvider component
|
|
124
|
+
*/
|
|
125
|
+
const TamboPropStreamProviderComponent = ({ children, data, streamStatus }) => {
|
|
126
|
+
// Create a default stream status if none provided
|
|
127
|
+
const defaultStreamStatus = (0, react_1.useMemo)(() => ({
|
|
128
|
+
isPending: false, // No external stream, so not pending
|
|
129
|
+
isStreaming: false, // No external stream, so not streaming
|
|
130
|
+
isSuccess: true, // If no stream status provided, assume success
|
|
131
|
+
isError: false,
|
|
132
|
+
streamError: undefined,
|
|
133
|
+
}), []);
|
|
134
|
+
const finalStreamStatus = streamStatus ?? defaultStreamStatus;
|
|
135
|
+
// Track status by key for compound components
|
|
136
|
+
const keyStatusMap = (0, react_1.useMemo)(() => {
|
|
137
|
+
const map = new Map();
|
|
138
|
+
// Track per-key status based on data structure
|
|
139
|
+
// If data is an object with keys, create status for each key
|
|
140
|
+
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
141
|
+
Object.keys(data).forEach((key) => {
|
|
142
|
+
const keyData = data[key];
|
|
143
|
+
const hasData = keyData !== undefined && keyData !== null && keyData !== "";
|
|
144
|
+
map.set(key, {
|
|
145
|
+
// If no external stream, show loading when key has no data
|
|
146
|
+
isPending: finalStreamStatus.isPending ||
|
|
147
|
+
(!finalStreamStatus.isStreaming && !hasData),
|
|
148
|
+
isStreaming: finalStreamStatus.isStreaming && !hasData,
|
|
149
|
+
isSuccess: finalStreamStatus.isSuccess && hasData,
|
|
150
|
+
isError: finalStreamStatus.isError,
|
|
151
|
+
error: finalStreamStatus.streamError,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Always set default status for fallback
|
|
156
|
+
map.set("default", {
|
|
157
|
+
isPending: finalStreamStatus.isPending,
|
|
158
|
+
isStreaming: finalStreamStatus.isStreaming,
|
|
159
|
+
isSuccess: finalStreamStatus.isSuccess,
|
|
160
|
+
isError: finalStreamStatus.isError,
|
|
161
|
+
error: finalStreamStatus.streamError,
|
|
162
|
+
});
|
|
163
|
+
return map;
|
|
164
|
+
}, [finalStreamStatus, data]);
|
|
165
|
+
const getStatusForKey = (0, react_1.useMemo)(() => (key) => {
|
|
166
|
+
return (keyStatusMap.get(key) ??
|
|
167
|
+
keyStatusMap.get("default") ?? {
|
|
168
|
+
isPending: false,
|
|
169
|
+
isStreaming: false,
|
|
170
|
+
isSuccess: false,
|
|
171
|
+
isError: false,
|
|
172
|
+
});
|
|
173
|
+
}, [keyStatusMap]);
|
|
174
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
175
|
+
data,
|
|
176
|
+
streamStatus: finalStreamStatus,
|
|
177
|
+
getStatusForKey,
|
|
178
|
+
}), [data, finalStreamStatus, getStatusForKey]);
|
|
179
|
+
return (react_1.default.createElement(TamboPropStreamContext.Provider, { value: contextValue }, children));
|
|
180
|
+
};
|
|
181
|
+
exports.TamboPropStreamProvider = TamboPropStreamProviderComponent;
|
|
182
|
+
exports.TamboPropStreamProvider.Loading = Loading;
|
|
183
|
+
exports.TamboPropStreamProvider.Empty = Empty;
|
|
184
|
+
exports.TamboPropStreamProvider.Complete = Complete;
|
|
185
|
+
//# sourceMappingURL=tambo-prop-stream-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-prop-stream-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-prop-stream-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;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ACtC,+BAAuB,CAAC,QAAQ,GAAG,QAAQ,CAAC","sourcesContent":["\"use client\";\n\nimport React, {\n createContext,\n PropsWithChildren,\n useContext,\n useMemo,\n} from \"react\";\nimport { StreamStatus } from \"../hooks/use-tambo-stream-status\";\n\ninterface TamboPropStreamContextValue {\n /** The stream data */\n data: any;\n /** The stream status */\n streamStatus: StreamStatus;\n /** Get the status for a specific key */\n getStatusForKey: (key: string) => {\n isPending: boolean;\n isStreaming: boolean;\n isSuccess: boolean;\n isError: boolean;\n error?: Error;\n };\n}\n\nconst TamboPropStreamContext =\n createContext<TamboPropStreamContextValue | null>(null);\n\nexport interface TamboPropStreamProviderProps {\n /** The stream data */\n data: any;\n /** Optional stream status for more granular control */\n streamStatus?: StreamStatus;\n}\n\nexport interface LoadingProps {\n /** The key to identify this loading state */\n streamKey?: string;\n /** The children to render when loading */\n children: React.ReactNode;\n /** Optional className for styling */\n className?: string;\n}\n\nexport interface EmptyProps {\n /** The key to identify this empty state */\n streamKey?: string;\n /** The children to render when empty */\n children: React.ReactNode;\n /** Optional className for styling */\n className?: string;\n}\n\nexport interface CompleteProps {\n /** The key to identify this complete state */\n streamKey?: string;\n /** The children to render when complete */\n children: React.ReactNode;\n /** Optional className for styling */\n className?: string;\n}\n\n/**\n * Loading component that renders children when the stream is in a loading state\n * @param props - The props for the Loading component\n * @param props.streamKey - The key to identify this loading state\n * @param props.children - The children to render when loading\n * @param props.className - Optional className for styling\n * @returns The Loading component\n */\nconst Loading: React.FC<LoadingProps> = ({\n streamKey = \"default\",\n children,\n className,\n}) => {\n const { getStatusForKey } = useTamboStream();\n const status = getStatusForKey(streamKey);\n\n if (!status.isPending && !status.isStreaming) {\n return null;\n }\n\n return (\n <div\n className={className}\n data-stream-key={streamKey}\n data-stream-state=\"loading\"\n >\n {children}\n </div>\n );\n};\n\n/**\n * Empty component that renders children when the stream has no data\n * @param props - The props for the Empty component\n * @param props.streamKey - The key to identify this empty state\n * @param props.children - The children to render when empty\n * @param props.className - Optional className for styling\n * @returns The Empty component\n */\nconst Empty: React.FC<EmptyProps> = ({\n streamKey = \"default\",\n children,\n className,\n}) => {\n const { data, getStatusForKey } = useTamboStream();\n const status = getStatusForKey(streamKey);\n\n // Get the specific data for this key\n const keyData =\n data && typeof data === \"object\" && !Array.isArray(data)\n ? data[streamKey]\n : data;\n\n // Show empty state when not loading, not streaming, not successful, and no data for this key\n const shouldShowEmpty =\n !status.isPending &&\n !status.isStreaming &&\n !status.isSuccess &&\n !status.isError &&\n (keyData === undefined || keyData === null || keyData === \"\");\n\n if (!shouldShowEmpty) {\n return null;\n }\n\n return (\n <div\n className={className}\n data-stream-key={streamKey}\n data-stream-state=\"empty\"\n >\n {children}\n </div>\n );\n};\n\n/**\n * Complete component that renders children when the stream has data\n * @param props - The props for the Complete component\n * @param props.streamKey - The key to identify this complete state\n * @param props.children - The children to render when complete\n * @param props.className - Optional className for styling\n * @returns The Complete component\n */\nconst Complete: React.FC<CompleteProps> = ({\n streamKey = \"default\",\n children,\n className,\n}) => {\n const { data, getStatusForKey } = useTamboStream();\n const status = getStatusForKey(streamKey);\n\n // Get the specific data for this key\n const keyData =\n data && typeof data === \"object\" && !Array.isArray(data)\n ? data[streamKey]\n : data;\n\n // Show complete when we have data for this key and the stream is successful\n const shouldShowComplete =\n status.isSuccess && keyData !== undefined && keyData !== null;\n\n if (!shouldShowComplete) {\n return null;\n }\n\n return (\n <div\n className={className}\n data-stream-key={streamKey}\n data-stream-state=\"complete\"\n >\n {children}\n </div>\n );\n};\n\n/**\n * Hook to use the TamboStream context\n * @returns The TamboStream context\n */\nexport const useTamboStream = () => {\n const context = useContext(TamboPropStreamContext);\n if (!context) {\n throw new Error(\n \"useTamboStream must be used within a TamboPropStreamProvider\",\n );\n }\n return context;\n};\n\n/**\n * The TamboStreamProvider provides a context for managing stream states\n * with compound components for Loading, Empty, and Complete states.\n * @param props - The props for the TamboStreamProvider\n * @param props.children - The children to wrap\n * @param props.data - The stream data\n * @param props.streamStatus - Optional stream status for more granular control\n * @returns The TamboStreamProvider component\n */\nconst TamboPropStreamProviderComponent: React.FC<\n PropsWithChildren<TamboPropStreamProviderProps>\n> = ({ children, data, streamStatus }) => {\n // Create a default stream status if none provided\n const defaultStreamStatus: StreamStatus = useMemo(\n () => ({\n isPending: false, // No external stream, so not pending\n isStreaming: false, // No external stream, so not streaming\n isSuccess: true, // If no stream status provided, assume success\n isError: false,\n streamError: undefined,\n }),\n [],\n );\n\n const finalStreamStatus = streamStatus ?? defaultStreamStatus;\n\n // Track status by key for compound components\n const keyStatusMap = useMemo(() => {\n const map = new Map<\n string,\n {\n isPending: boolean;\n isStreaming: boolean;\n isSuccess: boolean;\n isError: boolean;\n error?: Error;\n }\n >();\n\n // Track per-key status based on data structure\n // If data is an object with keys, create status for each key\n if (data && typeof data === \"object\" && !Array.isArray(data)) {\n Object.keys(data).forEach((key) => {\n const keyData = data[key];\n const hasData =\n keyData !== undefined && keyData !== null && keyData !== \"\";\n\n map.set(key, {\n // If no external stream, show loading when key has no data\n isPending:\n finalStreamStatus.isPending ||\n (!finalStreamStatus.isStreaming && !hasData),\n isStreaming: finalStreamStatus.isStreaming && !hasData,\n isSuccess: finalStreamStatus.isSuccess && hasData,\n isError: finalStreamStatus.isError,\n error: finalStreamStatus.streamError,\n });\n });\n }\n\n // Always set default status for fallback\n map.set(\"default\", {\n isPending: finalStreamStatus.isPending,\n isStreaming: finalStreamStatus.isStreaming,\n isSuccess: finalStreamStatus.isSuccess,\n isError: finalStreamStatus.isError,\n error: finalStreamStatus.streamError,\n });\n\n return map;\n }, [finalStreamStatus, data]);\n\n const getStatusForKey = useMemo(\n () => (key: string) => {\n return (\n keyStatusMap.get(key) ??\n keyStatusMap.get(\"default\") ?? {\n isPending: false,\n isStreaming: false,\n isSuccess: false,\n isError: false,\n }\n );\n },\n [keyStatusMap],\n );\n\n const contextValue = useMemo(\n () => ({\n data,\n streamStatus: finalStreamStatus,\n getStatusForKey,\n }),\n [data, finalStreamStatus, getStatusForKey],\n );\n\n return (\n <TamboPropStreamContext.Provider value={contextValue}>\n {children}\n </TamboPropStreamContext.Provider>\n );\n};\n\n// Create the compound component type\ntype TamboPropStreamProviderCompound =\n typeof TamboPropStreamProviderComponent & {\n Loading: typeof Loading;\n Empty: typeof Empty;\n Complete: typeof Complete;\n };\n\nexport const TamboPropStreamProvider =\n TamboPropStreamProviderComponent as TamboPropStreamProviderCompound;\n\nTamboPropStreamProvider.Loading = Loading;\nTamboPropStreamProvider.Empty = Empty;\nTamboPropStreamProvider.Complete = Complete;\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { TamboInteractableContext } from "../model/tambo-interactable";
|
|
2
3
|
import { TamboClientContextProps, TamboClientProviderProps } from "./tambo-client-provider";
|
|
3
4
|
import { TamboComponentContextProps } from "./tambo-component-provider";
|
|
4
5
|
import { TamboRegistryProviderProps } from "./tambo-registry-provider";
|
|
5
6
|
import { TamboThreadContextProps, TamboThreadProviderProps } from "./tambo-thread-provider";
|
|
6
7
|
/**
|
|
7
8
|
* The TamboProvider gives full access to the whole Tambo API. This includes the
|
|
8
|
-
* TamboAI client, the component registry,
|
|
9
|
+
* TamboAI client, the component registry, the current thread context, and interactable components.
|
|
9
10
|
* @param props - The props for the TamboProvider
|
|
10
11
|
* @param props.children - The children to wrap
|
|
11
12
|
* @param props.tamboUrl - The URL of the Tambo API
|
|
@@ -17,11 +18,11 @@ import { TamboThreadContextProps, TamboThreadProviderProps } from "./tambo-threa
|
|
|
17
18
|
* @returns The TamboProvider component
|
|
18
19
|
*/
|
|
19
20
|
export declare const TamboProvider: React.FC<PropsWithChildren<TamboClientProviderProps & TamboRegistryProviderProps & TamboThreadProviderProps>>;
|
|
20
|
-
export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps;
|
|
21
|
+
export type TamboContextProps = TamboClientContextProps & TamboThreadContextProps & TamboComponentContextProps & TamboInteractableContext;
|
|
21
22
|
export declare const TamboContext: React.Context<TamboContextProps>;
|
|
22
23
|
/**
|
|
23
24
|
* TamboCompositeProvider is a provider that combines the TamboClient,
|
|
24
|
-
* TamboThread, and
|
|
25
|
+
* TamboThread, TamboComponent, and TamboInteractable providers
|
|
25
26
|
* @param props - The props for the TamboCompositeProvider
|
|
26
27
|
* @param props.children - The children to wrap
|
|
27
28
|
* @returns The wrapped component
|
|
@@ -31,7 +32,8 @@ export declare const TamboCompositeProvider: React.FC<PropsWithChildren>;
|
|
|
31
32
|
* The useTambo hook provides access to the Tambo API. This is the primary entrypoint
|
|
32
33
|
* for the Tambo React SDK.
|
|
33
34
|
*
|
|
34
|
-
* This includes the TamboAI client, the component registry,
|
|
35
|
+
* This includes the TamboAI client, the component registry, the current thread context,
|
|
36
|
+
* and interactable component management.
|
|
35
37
|
* @returns The Tambo API
|
|
36
38
|
*/
|
|
37
39
|
export declare const useTambo: () => TamboContextProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAEL,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CACf,wBAAwB,GACtB,0BAA0B,GAC1B,wBAAwB,CAC3B,CAkCF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACrD,uBAAuB,GACvB,0BAA0B,GAC1B,wBAAwB,CAAC;AAE3B,eAAO,MAAM,YAAY,kCAExB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAsB9D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
|
|
@@ -38,11 +38,12 @@ exports.useTambo = exports.TamboCompositeProvider = exports.TamboContext = expor
|
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const tambo_client_provider_1 = require("./tambo-client-provider");
|
|
40
40
|
const tambo_component_provider_1 = require("./tambo-component-provider");
|
|
41
|
+
const tambo_interactable_provider_1 = require("./tambo-interactable-provider");
|
|
41
42
|
const tambo_registry_provider_1 = require("./tambo-registry-provider");
|
|
42
43
|
const tambo_thread_provider_1 = require("./tambo-thread-provider");
|
|
43
44
|
/**
|
|
44
45
|
* The TamboProvider gives full access to the whole Tambo API. This includes the
|
|
45
|
-
* TamboAI client, the component registry,
|
|
46
|
+
* TamboAI client, the component registry, the current thread context, and interactable components.
|
|
46
47
|
* @param props - The props for the TamboProvider
|
|
47
48
|
* @param props.children - The children to wrap
|
|
48
49
|
* @param props.tamboUrl - The URL of the Tambo API
|
|
@@ -62,13 +63,14 @@ const TamboProvider = ({ children, tamboUrl, apiKey, userToken, components, envi
|
|
|
62
63
|
react_1.default.createElement(tambo_registry_provider_1.TamboRegistryProvider, { components: components, tools: tools },
|
|
63
64
|
react_1.default.createElement(tambo_thread_provider_1.TamboThreadProvider, { streaming: streaming },
|
|
64
65
|
react_1.default.createElement(tambo_component_provider_1.TamboComponentProvider, null,
|
|
65
|
-
react_1.default.createElement(
|
|
66
|
+
react_1.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
|
|
67
|
+
react_1.default.createElement(exports.TamboCompositeProvider, null, children)))))));
|
|
66
68
|
};
|
|
67
69
|
exports.TamboProvider = TamboProvider;
|
|
68
70
|
exports.TamboContext = (0, react_1.createContext)({});
|
|
69
71
|
/**
|
|
70
72
|
* TamboCompositeProvider is a provider that combines the TamboClient,
|
|
71
|
-
* TamboThread, and
|
|
73
|
+
* TamboThread, TamboComponent, and TamboInteractable providers
|
|
72
74
|
* @param props - The props for the TamboCompositeProvider
|
|
73
75
|
* @param props.children - The children to wrap
|
|
74
76
|
* @returns The wrapped component
|
|
@@ -78,11 +80,13 @@ const TamboCompositeProvider = ({ children, }) => {
|
|
|
78
80
|
const client = (0, tambo_client_provider_1.useTamboClient)();
|
|
79
81
|
const queryClient = (0, tambo_client_provider_1.useTamboQueryClient)();
|
|
80
82
|
const componentRegistry = (0, tambo_component_provider_1.useTamboComponent)();
|
|
83
|
+
const interactableComponents = (0, tambo_interactable_provider_1.useTamboInteractable)();
|
|
81
84
|
return (react_1.default.createElement(exports.TamboContext.Provider, { value: {
|
|
82
85
|
client,
|
|
83
86
|
queryClient,
|
|
84
87
|
...componentRegistry,
|
|
85
88
|
...threads,
|
|
89
|
+
...interactableComponents,
|
|
86
90
|
} }, children));
|
|
87
91
|
};
|
|
88
92
|
exports.TamboCompositeProvider = TamboCompositeProvider;
|
|
@@ -90,7 +94,8 @@ exports.TamboCompositeProvider = TamboCompositeProvider;
|
|
|
90
94
|
* The useTambo hook provides access to the Tambo API. This is the primary entrypoint
|
|
91
95
|
* for the Tambo React SDK.
|
|
92
96
|
*
|
|
93
|
-
* This includes the TamboAI client, the component registry,
|
|
97
|
+
* This includes the TamboAI client, the component registry, the current thread context,
|
|
98
|
+
* and interactable component management.
|
|
94
99
|
* @returns The Tambo API
|
|
95
100
|
*/
|
|
96
101
|
const useTambo = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAA4E;
|
|
1
|
+
{"version":3,"file":"tambo-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAA4E;AAE5E,mEAMiC;AACjC,yEAIoC;AACpC,+EAGuC;AACvC,uEAGmC;AACnC,mEAKiC;AAEjC;;;;;;;;;;;;GAYG;AACI,MAAM,aAAa,GAMtB,CAAC,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,GACV,EAAE,EAAE;IACH,iCAAiC;IACjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,CACL,8BAAC,2CAAmB,IAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS;QAEpB,8BAAC,+CAAqB,IAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK;YACzD,8BAAC,2CAAmB,IAAC,SAAS,EAAE,SAAS;gBACvC,8BAAC,iDAAsB;oBACrB,8BAAC,uDAAyB;wBACxB,8BAAC,8BAAsB,QAAE,QAAQ,CAA0B,CACjC,CACL,CACL,CACA,CACJ,CACvB,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,aAAa,iBAuCxB;AAOW,QAAA,YAAY,GAAG,IAAA,qBAAa,EACvC,EAAuB,CACxB,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,IAAA,sCAAc,GAAE,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAA,2CAAmB,GAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,IAAA,4CAAiB,GAAE,CAAC;IAC9C,MAAM,sBAAsB,GAAG,IAAA,kDAAoB,GAAE,CAAC;IAEtD,OAAO,CACL,8BAAC,oBAAY,CAAC,QAAQ,IACpB,KAAK,EAAE;YACL,MAAM;YACN,WAAW;YACX,GAAG,iBAAiB;YACpB,GAAG,OAAO;YACV,GAAG,sBAAsB;SAC1B,IAEA,QAAQ,CACa,CACzB,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,sBAAsB,0BAsBjC;AAEF;;;;;;;GAOG;AACI,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,OAAO,IAAA,kBAAU,EAAC,oBAAY,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB","sourcesContent":["\"use client\";\nimport React, { PropsWithChildren, createContext, useContext } from \"react\";\nimport { TamboInteractableContext } from \"../model/tambo-interactable\";\nimport {\n TamboClientContextProps,\n TamboClientProvider,\n TamboClientProviderProps,\n useTamboClient,\n useTamboQueryClient,\n} from \"./tambo-client-provider\";\nimport {\n TamboComponentContextProps,\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\nimport {\n TamboRegistryProvider,\n TamboRegistryProviderProps,\n} from \"./tambo-registry-provider\";\nimport {\n TamboThreadContextProps,\n TamboThreadProvider,\n TamboThreadProviderProps,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n\n/**\n * The TamboProvider gives full access to the whole Tambo API. This includes the\n * TamboAI client, the component registry, the current thread context, and interactable components.\n * @param props - The props for the TamboProvider\n * @param props.children - The children to wrap\n * @param props.tamboUrl - The URL of the Tambo API\n * @param props.apiKey - The API key for the Tambo API\n * @param props.components - The components to register\n * @param props.environment - The environment to use for the Tambo API\n * @param props.tools - The tools to register\n * @param props.streaming - Whether to stream the response by default. Defaults to true.\n * @returns The TamboProvider component\n */\nexport const TamboProvider: React.FC<\n PropsWithChildren<\n TamboClientProviderProps &\n TamboRegistryProviderProps &\n TamboThreadProviderProps\n >\n> = ({\n children,\n tamboUrl,\n apiKey,\n userToken,\n components,\n environment,\n tools,\n streaming,\n}) => {\n // Should only be used in browser\n if (typeof window === \"undefined\") {\n console.error(\"TamboProvider must be used within a browser\");\n }\n\n return (\n <TamboClientProvider\n tamboUrl={tamboUrl}\n apiKey={apiKey}\n environment={environment}\n userToken={userToken}\n >\n <TamboRegistryProvider components={components} tools={tools}>\n <TamboThreadProvider streaming={streaming}>\n <TamboComponentProvider>\n <TamboInteractableProvider>\n <TamboCompositeProvider>{children}</TamboCompositeProvider>\n </TamboInteractableProvider>\n </TamboComponentProvider>\n </TamboThreadProvider>\n </TamboRegistryProvider>\n </TamboClientProvider>\n );\n};\n\nexport type TamboContextProps = TamboClientContextProps &\n TamboThreadContextProps &\n TamboComponentContextProps &\n TamboInteractableContext;\n\nexport const TamboContext = createContext<TamboContextProps>(\n {} as TamboContextProps,\n);\n\n/**\n * TamboCompositeProvider is a provider that combines the TamboClient,\n * TamboThread, TamboComponent, and TamboInteractable providers\n * @param props - The props for the TamboCompositeProvider\n * @param props.children - The children to wrap\n * @returns The wrapped component\n */\nexport const TamboCompositeProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const threads = useTamboThread();\n const client = useTamboClient();\n const queryClient = useTamboQueryClient();\n const componentRegistry = useTamboComponent();\n const interactableComponents = useTamboInteractable();\n\n return (\n <TamboContext.Provider\n value={{\n client,\n queryClient,\n ...componentRegistry,\n ...threads,\n ...interactableComponents,\n }}\n >\n {children}\n </TamboContext.Provider>\n );\n};\n\n/**\n * The useTambo hook provides access to the Tambo API. This is the primary entrypoint\n * for the Tambo React SDK.\n *\n * This includes the TamboAI client, the component registry, the current thread context,\n * and interactable component management.\n * @returns The Tambo API\n */\nexport const useTambo = () => {\n return useContext(TamboContext);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-utils.d.ts","sourceRoot":"","sources":["../../src/util/query-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE1E,MAAM,MAAM,sBAAsB,CAChC,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,OAAO,EAChB,UAAU,GAAG,OAAO,EACpB,QAAQ,GAAG,OAAO,IAChB,IAAI,CACN,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EACtD,QAAQ,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CACtE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EACrE,OAAO,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,EACrD,OAAO,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GACpD,sBAAsB,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAsB5D;AAED,MAAM,MAAM,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI,CACtE,cAAc,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,EAClD,MAAM,GAAG,SAAS,GAAG,SAAS,CAC/B,CAAC;AACF;;;;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;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAClE,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAuCnD"}
|
package/dist/util/query-utils.js
CHANGED
|
@@ -45,6 +45,7 @@ function combineQueryResults(resultA, resultB) {
|
|
|
45
45
|
isPending: resultA.isPending || resultB.isPending,
|
|
46
46
|
isSuccess: resultA.isSuccess && resultB.isSuccess,
|
|
47
47
|
isError: resultA.isError || resultB.isError,
|
|
48
|
+
isEnabled: resultA.isEnabled && resultB.isEnabled,
|
|
48
49
|
isLoading: resultA.isLoading || resultB.isLoading,
|
|
49
50
|
isFetched: resultA.isFetched && resultB.isFetched,
|
|
50
51
|
isFetchedAfterMount: resultA.isFetchedAfterMount && resultB.isFetchedAfterMount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-utils.js","sourceRoot":"","sources":["../../src/util/query-utils.ts"],"names":[],"mappings":";;AAoBA,wDAyBC;AAcD,
|
|
1
|
+
{"version":3,"file":"query-utils.js","sourceRoot":"","sources":["../../src/util/query-utils.ts"],"names":[],"mappings":";;AAoBA,wDAyBC;AAcD,kDA0CC;AAzFD;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,OAAqD,EACrD,OAAqD;IAErD,CAAC;QACC,OAAO;YACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS;YACjD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS;YACjD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO;YAC3C,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM;YACxC,QAAQ,EAAE,O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C,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["import { UseMutationResult, UseQueryResult } from \"@tanstack/react-query\";\n\nexport type CombinedMutationResult<\n TData = unknown,\n TError = unknown,\n TVariables = unknown,\n TContext = unknown,\n> = Omit<\n UseMutationResult<TData, TError, TVariables, TContext>,\n \"mutate\" | \"mutateAsync\" | \"reset\" | \"data\" | \"variables\" | \"context\"\n>;\n\n/**\n * Combines two mutation results, showing the \"loading state\" of the two\n * mutations. For instance, if either mutation is pending, the combined\n * mutation result will be pending.\n * @param resultA - The first mutation result\n * @param resultB - The second mutation result\n * @returns The combined mutation result\n */\nexport function combineMutationResults<TData1, TData2, TError1, TError2>(\n resultA: UseMutationResult<TData1, TError1, any, any>,\n resultB: UseMutationResult<TData2, TError2, any, any>,\n): CombinedMutationResult<TData1 | TData2, TError1 | TError2> {\n {\n return {\n isPending: resultA.isPending || resultB.isPending,\n isSuccess: resultA.isSuccess && resultB.isSuccess,\n isError: resultA.isError || resultB.isError,\n isIdle: resultA.isIdle && resultB.isIdle,\n isPaused: resultA.isPaused || resultB.isPaused,\n submittedAt: resultA.submittedAt || resultB.submittedAt,\n status:\n resultA.isPending || resultB.isPending\n ? \"pending\"\n : resultA.isError || resultB.isError\n ? \"error\"\n : resultA.isSuccess && resultB.isSuccess\n ? \"success\"\n : \"idle\",\n error: resultA.error ?? resultB.error,\n failureCount: resultA.failureCount + resultB.failureCount,\n failureReason: resultA.failureReason ?? resultB.failureReason,\n };\n }\n}\n\nexport type CombinedQueryResult<TData1, TData2, TError1, TError2> = Omit<\n UseQueryResult<TData1 | TData2, TError1 | TError2>,\n \"data\" | \"refetch\" | \"promise\"\n>;\n/**\n * Combines two query results, showing the \"loading state\" of the two queries.\n * For instance, if either query is loading, the combined query result will be\n * loading.\n * @param resultA - The first query result\n * @param resultB - The second query result\n * @returns The combined query result\n */\nexport function combineQueryResults<TData1, TData2, TError1, TError2>(\n resultA: UseQueryResult<TData1, TError1>,\n resultB: UseQueryResult<TData2, TError2>,\n): CombinedQueryResult<void, void, TError1, TError2> {\n return {\n isPending: resultA.isPending || resultB.isPending,\n isSuccess: resultA.isSuccess && resultB.isSuccess,\n isError: resultA.isError || resultB.isError,\n isEnabled: resultA.isEnabled && resultB.isEnabled,\n isLoading: resultA.isLoading || resultB.isLoading,\n isFetched: resultA.isFetched && resultB.isFetched,\n isFetchedAfterMount:\n resultA.isFetchedAfterMount && resultB.isFetchedAfterMount,\n isInitialLoading: resultA.isInitialLoading || resultB.isInitialLoading,\n isPaused: resultA.isPaused || resultB.isPaused,\n isLoadingError: resultA.isLoadingError || resultB.isLoadingError,\n isRefetchError: resultA.isRefetchError || resultB.isRefetchError,\n isPlaceholderData: resultA.isPlaceholderData || resultB.isPlaceholderData,\n isStale: resultA.isStale || resultB.isStale,\n isRefetching: resultA.isRefetching || resultB.isRefetching,\n isFetching: resultA.isFetching || resultB.isFetching,\n status:\n resultA.isPending || resultB.isPending\n ? \"pending\"\n : resultA.isError || resultB.isError\n ? \"error\"\n : resultA.isSuccess && resultB.isSuccess\n ? \"success\"\n : \"pending\",\n error: resultA.error ?? resultB.error,\n failureCount: resultA.failureCount + resultB.failureCount,\n failureReason: resultA.failureReason ?? resultB.failureReason,\n errorUpdateCount: resultA.errorUpdateCount + resultB.errorUpdateCount,\n fetchStatus:\n resultA.isFetching || resultB.isFetching\n ? \"fetching\"\n : resultA.isPaused || resultB.isPaused\n ? \"paused\"\n : \"idle\",\n dataUpdatedAt: Math.max(resultA.dataUpdatedAt, resultB.dataUpdatedAt),\n errorUpdatedAt: Math.max(resultA.errorUpdatedAt, resultB.errorUpdatedAt),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tambo-threads.test.js","sourceRoot":"","sources":["../../../src/hooks/__tests__/use-tambo-threads.test.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC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C,kBAAkB,CAAC,KAAK,IAAI,EAAE;wBAC5C,6CAA6C;wBAC7C,MAAM,SAAS,CAAC;oBAClB,CAAC,CAAC;iBACH;aACF;SAC8B,CAAC,CAAC;QAEnC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CACjC,kBAAkB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CACzC,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,EAAE;YACjB,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YACrD,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { renderHook, waitFor } from \"@testing-library/react\";\nimport { DeepPartial } from \"ts-essentials\";\nimport {\n useTamboClient,\n useTamboQueryClient,\n} from \"../../providers/tambo-client-provider\";\nimport { PartialTamboAI } from \"../../testing/types\";\nimport { useTamboThreadList } from \"../use-tambo-threads\";\n\njest.mock(\"../../providers/tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n useTamboQueryClient: jest.fn(),\n}));\n\ndescribe(\"useTamboThreadList\", () => {\n const mockThreads = [\n { id: \"thread-1\", title: \"Thread 1\" },\n { id: \"thread-2\", title: \"Thread 2\" },\n ];\n\n const mockProjects = {\n getCurrent: jest.fn(),\n retrieve: jest.fn(),\n delete: jest.fn(),\n } satisfies Partial<TamboAI[\"beta\"][\"projects\"]>;\n\n const mockThreadsApi = {\n list: jest.fn(),\n messages: {\n list: jest.fn(),\n create: jest.fn(),\n delete: jest.fn(),\n updateComponentState: jest.fn(),\n },\n suggestions: {\n list: jest.fn(),\n generate: jest.fn(),\n },\n create: jest.fn(),\n retrieve: jest.fn(),\n update: jest.fn(),\n delete: jest.fn(),\n advance: jest.fn(),\n advanceById: jest.fn(),\n } satisfies DeepPartial<TamboAI[\"beta\"][\"threads\"]>;\n\n const mockBeta = {\n projects: mockProjects,\n threads: mockThreadsApi,\n registry: {\n retrieve: jest.fn(),\n },\n } satisfies PartialTamboAI[\"beta\"];\n\n const mockTamboAI = {\n apiKey: \"\",\n beta: mockBeta,\n } satisfies PartialTamboAI as unknown as TamboAI;\n\n beforeEach(() => {\n jest.mocked(useTamboQueryClient).mockReturnValue(new QueryClient());\n });\n\n it(\"should fetch threads for current project when no projectId is provided\", async () => {\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockResolvedValue(mockThreads),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() => useTamboThreadList());\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n });\n\n it(\"should fetch threads for specified projectId\", async () => {\n const mockList = jest.fn().mockResolvedValue(mockThreads);\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n threads: {\n ...mockThreadsApi,\n list: mockList,\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({ projectId: \"custom-project\" }),\n );\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n\n expect(mockList).toHaveBeenCalledWith(\"custom-project\", {});\n });\n\n it(\"should fetch threads with contextKey when provided\", async () => {\n const mockList = jest.fn().mockResolvedValue(mockThreads);\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: mockList,\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({ contextKey: \"test-context\" }),\n );\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n\n expect(mockList).toHaveBeenCalledWith(\"current-project\", {\n contextKey: \"test-context\",\n });\n });\n\n it(\"should handle loading state\", async () => {\n let resolvePromise: (value: any) => void;\n const promise = new Promise((resolve) => {\n resolvePromise = resolve;\n });\n\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockReturnValue(promise),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({}, { retry: false }),\n );\n\n expect(result.current).toMatchInlineSnapshot(`\n {\n \"data\": null,\n \"dataUpdatedAt\": 0,\n \"error\": null,\n \"errorUpdateCount\": 0,\n \"errorUpdatedAt\": 0,\n \"failureCount\": 0,\n \"failureReason\": null,\n \"fetchStatus\": \"fetching\",\n \"isError\": false,\n \"isFetched\": false,\n \"isFetchedAfterMount\": false,\n \"isFetching\": true,\n \"isInitialLoading\": true,\n \"isLoading\": true,\n \"isLoadingError\": false,\n \"isPaused\": false,\n \"isPending\": true,\n \"isPlaceholderData\": false,\n \"isRefetchError\": false,\n \"isRefetching\": false,\n \"isStale\": true,\n \"isSuccess\": false,\n \"promise\": Promise {\n \"reason\": [Error: experimental_prefetchInRender feature flag is not enabled],\n \"status\": \"rejected\",\n },\n \"refetch\": [Function],\n \"status\": \"pending\",\n }\n `);\n expect(result.current.isLoading).toBe(true);\n expect(result.current.data).toBeNull();\n\n resolvePromise!(mockThreads);\n await waitFor(() => {\n expect(result.current.isLoading).toBe(false);\n });\n await waitFor(() => {\n expect(result.current.isLoading).toBe(false);\n });\n });\n\n it(\"should handle error state\", async () => {\n const mockError = new Error(\"Failed to fetch threads\");\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockImplementation(async () => {\n // console.log(\"Mocking error\", mockCount++);\n throw mockError;\n }),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({}, { retry: false }),\n );\n\n await waitFor(() => {\n const { isLoading, error, isError } = result.current;\n expect(isLoading).toBe(false);\n expect(isError).toBe(true);\n expect(error).toBe(mockError);\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"use-tambo-threads.test.js","sourceRoot":"","sources":["../../../src/hooks/__tests__/use-tambo-threads.test.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EACL,cAAc,EACd,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,IAAI,CAAC,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE,CAAC,CAAC;IACxD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;IACzB,mBAAmB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC/B,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,WAAW,GAAG;QAClB,EAAE,E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AC,CAAC;YAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { renderHook, waitFor } from \"@testing-library/react\";\nimport { DeepPartial } from \"ts-essentials\";\nimport {\n useTamboClient,\n useTamboQueryClient,\n} from \"../../providers/tambo-client-provider\";\nimport { PartialTamboAI } from \"../../testing/types\";\nimport { useTamboThreadList } from \"../use-tambo-threads\";\n\njest.mock(\"../../providers/tambo-client-provider\", () => ({\n useTamboClient: jest.fn(),\n useTamboQueryClient: jest.fn(),\n}));\n\ndescribe(\"useTamboThreadList\", () => {\n const mockThreads = [\n { id: \"thread-1\", title: \"Thread 1\" },\n { id: \"thread-2\", title: \"Thread 2\" },\n ];\n\n const mockProjects = {\n getCurrent: jest.fn(),\n retrieve: jest.fn(),\n delete: jest.fn(),\n } satisfies Partial<TamboAI[\"beta\"][\"projects\"]>;\n\n const mockThreadsApi = {\n list: jest.fn(),\n messages: {\n list: jest.fn(),\n create: jest.fn(),\n delete: jest.fn(),\n updateComponentState: jest.fn(),\n },\n suggestions: {\n list: jest.fn(),\n generate: jest.fn(),\n },\n create: jest.fn(),\n retrieve: jest.fn(),\n update: jest.fn(),\n delete: jest.fn(),\n advance: jest.fn(),\n advanceById: jest.fn(),\n } satisfies DeepPartial<TamboAI[\"beta\"][\"threads\"]>;\n\n const mockBeta = {\n projects: mockProjects,\n threads: mockThreadsApi,\n registry: {\n retrieve: jest.fn(),\n },\n } satisfies PartialTamboAI[\"beta\"];\n\n const mockTamboAI = {\n apiKey: \"\",\n beta: mockBeta,\n } satisfies PartialTamboAI as unknown as TamboAI;\n\n beforeEach(() => {\n jest.mocked(useTamboQueryClient).mockReturnValue(new QueryClient());\n });\n\n it(\"should fetch threads for current project when no projectId is provided\", async () => {\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockResolvedValue(mockThreads),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() => useTamboThreadList());\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n });\n\n it(\"should fetch threads for specified projectId\", async () => {\n const mockList = jest.fn().mockResolvedValue(mockThreads);\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n threads: {\n ...mockThreadsApi,\n list: mockList,\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({ projectId: \"custom-project\" }),\n );\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n\n expect(mockList).toHaveBeenCalledWith(\"custom-project\", {});\n });\n\n it(\"should fetch threads with contextKey when provided\", async () => {\n const mockList = jest.fn().mockResolvedValue(mockThreads);\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: mockList,\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({ contextKey: \"test-context\" }),\n );\n\n await waitFor(() => {\n expect(result.current.data).toEqual(mockThreads);\n });\n\n expect(mockList).toHaveBeenCalledWith(\"current-project\", {\n contextKey: \"test-context\",\n });\n });\n\n it(\"should handle loading state\", async () => {\n let resolvePromise: (value: any) => void;\n const promise = new Promise((resolve) => {\n resolvePromise = resolve;\n });\n\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockReturnValue(promise),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({}, { retry: false }),\n );\n\n expect(result.current).toMatchInlineSnapshot(`\n {\n \"data\": null,\n \"dataUpdatedAt\": 0,\n \"error\": null,\n \"errorUpdateCount\": 0,\n \"errorUpdatedAt\": 0,\n \"failureCount\": 0,\n \"failureReason\": null,\n \"fetchStatus\": \"fetching\",\n \"isEnabled\": true,\n \"isError\": false,\n \"isFetched\": false,\n \"isFetchedAfterMount\": false,\n \"isFetching\": true,\n \"isInitialLoading\": true,\n \"isLoading\": true,\n \"isLoadingError\": false,\n \"isPaused\": false,\n \"isPending\": true,\n \"isPlaceholderData\": false,\n \"isRefetchError\": false,\n \"isRefetching\": false,\n \"isStale\": true,\n \"isSuccess\": false,\n \"promise\": Promise {\n \"reason\": [Error: experimental_prefetchInRender feature flag is not enabled],\n \"status\": \"rejected\",\n },\n \"refetch\": [Function],\n \"status\": \"pending\",\n }\n `);\n expect(result.current.isLoading).toBe(true);\n expect(result.current.data).toBeNull();\n\n resolvePromise!(mockThreads);\n await waitFor(() => {\n expect(result.current.isLoading).toBe(false);\n });\n await waitFor(() => {\n expect(result.current.isLoading).toBe(false);\n });\n });\n\n it(\"should handle error state\", async () => {\n const mockError = new Error(\"Failed to fetch threads\");\n const mockClient = jest.mocked(useTamboClient);\n mockClient.mockReturnValue({\n ...mockTamboAI,\n beta: {\n ...mockBeta,\n projects: {\n ...mockProjects,\n getCurrent: jest.fn().mockResolvedValue({ id: \"current-project\" }),\n },\n threads: {\n ...mockThreadsApi,\n list: jest.fn().mockImplementation(async () => {\n // console.log(\"Mocking error\", mockCount++);\n throw mockError;\n }),\n },\n },\n } satisfies PartialTamboAI as any);\n\n const { result } = renderHook(() =>\n useTamboThreadList({}, { retry: false }),\n );\n\n await waitFor(() => {\n const { isLoading, error, isError } = result.current;\n expect(isLoading).toBe(false);\n expect(isError).toBe(true);\n expect(error).toBe(mockError);\n });\n });\n});\n"]}
|
|
@@ -57,6 +57,7 @@ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboT
|
|
|
57
57
|
isPaused: boolean;
|
|
58
58
|
isRefetching: boolean;
|
|
59
59
|
isStale: boolean;
|
|
60
|
+
isEnabled: boolean;
|
|
60
61
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
61
62
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
62
63
|
promise: Promise<string>;
|
|
@@ -83,6 +84,7 @@ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboT
|
|
|
83
84
|
isPaused: boolean;
|
|
84
85
|
isRefetching: boolean;
|
|
85
86
|
isStale: boolean;
|
|
87
|
+
isEnabled: boolean;
|
|
86
88
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
87
89
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
88
90
|
promise: Promise<string>;
|
|
@@ -109,6 +111,7 @@ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboT
|
|
|
109
111
|
isPaused: boolean;
|
|
110
112
|
isRefetching: boolean;
|
|
111
113
|
isStale: boolean;
|
|
114
|
+
isEnabled: boolean;
|
|
112
115
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
113
116
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
114
117
|
promise: Promise<string>;
|
|
@@ -135,6 +138,7 @@ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboT
|
|
|
135
138
|
isPaused: boolean;
|
|
136
139
|
isRefetching: boolean;
|
|
137
140
|
isStale: boolean;
|
|
141
|
+
isEnabled: boolean;
|
|
138
142
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
139
143
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
140
144
|
promise: Promise<string>;
|
|
@@ -161,6 +165,7 @@ export declare function useTamboThreadList({ projectId, contextKey }?: UseTamboT
|
|
|
161
165
|
isPaused: boolean;
|
|
162
166
|
isRefetching: boolean;
|
|
163
167
|
isStale: boolean;
|
|
168
|
+
isEnabled: boolean;
|
|
164
169
|
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<string, Error>>;
|
|
165
170
|
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
166
171
|
promise: Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAE,wBAA6B,EACxD,OAAO,GAAE,OAAO,CACd,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAC9D
|
|
1
|
+
{"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,wBAAwB;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,SAAS,EAAE,UAAU,EAAE,GAAE,wBAA6B,EACxD,OAAO,GAAE,OAAO,CACd,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAC9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BP"}
|
package/esm/index.d.ts
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
export { useTamboComponentState } from "./hooks/use-component-state";
|
|
3
3
|
export { TamboMessageProvider, useTamboCurrentMessage, useTamboMessageContext, } from "./hooks/use-current-message";
|
|
4
4
|
export { useTamboStreamingProps } from "./hooks/use-streaming-props";
|
|
5
|
-
export { useTamboStreamStatus, type StreamStatus, type PropStatus, } from "./hooks/use-tambo-stream-status";
|
|
6
5
|
export * from "./hooks/use-suggestions";
|
|
6
|
+
export { useTamboStreamStatus, type PropStatus, type StreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
7
7
|
export { useTamboThreadInput } from "./hooks/use-thread-input";
|
|
8
|
-
export { TamboClientProvider, TamboComponentProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboThread, type TamboComponent, type TamboRegistryContext, type TamboStubProviderProps, } from "./providers";
|
|
8
|
+
export { TamboClientProvider, TamboComponentProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboStream, useTamboThread, type TamboComponent, type TamboRegistryContext, type TamboStubProviderProps, } from "./providers";
|
|
9
9
|
export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
|
|
10
10
|
export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
|
11
11
|
export { useTamboThreadList } from "./hooks/use-tambo-threads";
|
|
12
12
|
export { type ComponentContextToolMetadata, type ComponentRegistry, type ParameterSpec, type RegisteredComponent, type TamboTool, } from "./model/component-metadata";
|
|
13
13
|
export { GenerationStage, type TamboThreadMessage, } from "./model/generate-component-response";
|
|
14
14
|
export { type TamboThread } from "./model/tambo-thread";
|
|
15
|
+
export type { TamboInteractableComponent as InteractableComponent, TamboInteractableContext, } from "./model/tambo-interactable";
|
|
16
|
+
export { withTamboInteractable as withInteractable, type InteractableConfig, type WithTamboInteractableProps, } from "./providers/hoc/with-tambo-interactable";
|
|
17
|
+
export { useTamboInteractable } from "./providers/tambo-interactable-provider";
|
|
15
18
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAA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index.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
export { useTamboComponentState } from "./hooks/use-component-state";
|
|
3
3
|
export { TamboMessageProvider, useTamboCurrentMessage, useTamboMessageContext, } from "./hooks/use-current-message";
|
|
4
4
|
export { useTamboStreamingProps } from "./hooks/use-streaming-props";
|
|
5
|
-
export { useTamboStreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
6
5
|
export * from "./hooks/use-suggestions";
|
|
6
|
+
export { useTamboStreamStatus, } from "./hooks/use-tambo-stream-status";
|
|
7
7
|
export { useTamboThreadInput } from "./hooks/use-thread-input";
|
|
8
8
|
// Re-export provider components
|
|
9
|
-
export { TamboClientProvider, TamboComponentProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboThread, } from "./providers";
|
|
9
|
+
export { TamboClientProvider, TamboComponentProvider, TamboPropStreamProvider, TamboProvider, TamboStubProvider, TamboThreadProvider, useTambo, useTamboClient, useTamboStream, useTamboThread, } from "./providers";
|
|
10
10
|
export { useTamboThreadList } from "./hooks/use-tambo-threads";
|
|
11
11
|
export { GenerationStage, } from "./model/generate-component-response";
|
|
12
|
+
export { withTamboInteractable as withInteractable, } from "./providers/hoc/with-tambo-interactable";
|
|
13
|
+
export { useTamboInteractable } from "./providers/tambo-interactable-provider";
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AAExK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,oBAAoB,GAGrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,gCAAgC;AAChC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,GAIf,MAAM,aAAa,CAAC;AAcrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,EACL,eAAe,GAEhB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EACL,qBAAqB,IAAI,gBAAgB,GAG1C,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\n\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n useTamboMessageContext,\n} from \"./hooks/use-current-message\";\nexport { useTamboStreamingProps } from \"./hooks/use-streaming-props\";\nexport * from \"./hooks/use-suggestions\";\nexport {\n useTamboStreamStatus,\n type PropStatus,\n type StreamStatus,\n} from \"./hooks/use-tambo-stream-status\";\nexport { useTamboThreadInput } from \"./hooks/use-thread-input\";\n\n// Re-export provider components\nexport {\n TamboClientProvider,\n TamboComponentProvider,\n TamboPropStreamProvider,\n TamboProvider,\n TamboStubProvider,\n TamboThreadProvider,\n useTambo,\n useTamboClient,\n useTamboStream,\n useTamboThread,\n type TamboComponent,\n type TamboRegistryContext,\n type TamboStubProviderProps,\n} from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreadList } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\n\nexport type {\n TamboInteractableComponent as InteractableComponent,\n TamboInteractableContext,\n} from \"./model/tambo-interactable\";\nexport {\n withTamboInteractable as withInteractable,\n type InteractableConfig,\n type WithTamboInteractableProps,\n} from \"./providers/hoc/with-tambo-interactable\";\nexport { useTamboInteractable } from \"./providers/tambo-interactable-provider\";\n"]}
|