@apollo/client-ai-apps 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/dist/core/typeRegistration.d.ts +33 -0
  3. package/dist/core/typeRegistration.d.ts.map +1 -0
  4. package/dist/core/typeRegistration.js +2 -0
  5. package/dist/core/typeRegistration.js.map +1 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/mcp/react/hooks/useToolInfo.d.ts +3 -0
  10. package/dist/mcp/react/hooks/useToolInfo.d.ts.map +1 -0
  11. package/dist/mcp/react/hooks/useToolInfo.js +10 -0
  12. package/dist/mcp/react/hooks/useToolInfo.js.map +1 -0
  13. package/dist/mcp/react/hooks/useToolInput.d.ts +6 -1
  14. package/dist/mcp/react/hooks/useToolInput.d.ts.map +1 -1
  15. package/dist/mcp/react/hooks/useToolInput.js +4 -0
  16. package/dist/mcp/react/hooks/useToolInput.js.map +1 -1
  17. package/dist/mcp/react/hooks/useToolName.d.ts +6 -1
  18. package/dist/mcp/react/hooks/useToolName.d.ts.map +1 -1
  19. package/dist/mcp/react/hooks/useToolName.js +4 -0
  20. package/dist/mcp/react/hooks/useToolName.js.map +1 -1
  21. package/dist/mcp/react/index.d.ts +1 -0
  22. package/dist/mcp/react/index.d.ts.map +1 -1
  23. package/dist/mcp/react/index.js +1 -0
  24. package/dist/mcp/react/index.js.map +1 -1
  25. package/dist/openai/react/hooks/useToolInfo.d.ts +3 -0
  26. package/dist/openai/react/hooks/useToolInfo.d.ts.map +1 -0
  27. package/dist/openai/react/hooks/useToolInfo.js +10 -0
  28. package/dist/openai/react/hooks/useToolInfo.js.map +1 -0
  29. package/dist/openai/react/hooks/useToolInput.d.ts +6 -1
  30. package/dist/openai/react/hooks/useToolInput.d.ts.map +1 -1
  31. package/dist/openai/react/hooks/useToolInput.js +4 -0
  32. package/dist/openai/react/hooks/useToolInput.js.map +1 -1
  33. package/dist/openai/react/hooks/useToolName.d.ts +6 -1
  34. package/dist/openai/react/hooks/useToolName.d.ts.map +1 -1
  35. package/dist/openai/react/hooks/useToolName.js +4 -0
  36. package/dist/openai/react/hooks/useToolName.js.map +1 -1
  37. package/dist/openai/react/index.d.ts +1 -0
  38. package/dist/openai/react/index.d.ts.map +1 -1
  39. package/dist/openai/react/index.js +1 -0
  40. package/dist/openai/react/index.js.map +1 -1
  41. package/dist/react/index.d.ts +9 -0
  42. package/dist/react/index.d.ts.map +1 -1
  43. package/dist/react/index.js +9 -0
  44. package/dist/react/index.js.map +1 -1
  45. package/dist/react/index.mcp.d.ts +1 -1
  46. package/dist/react/index.mcp.d.ts.map +1 -1
  47. package/dist/react/index.mcp.js +1 -1
  48. package/dist/react/index.mcp.js.map +1 -1
  49. package/dist/react/index.openai.d.ts +1 -1
  50. package/dist/react/index.openai.d.ts.map +1 -1
  51. package/dist/react/index.openai.js +1 -1
  52. package/dist/react/index.openai.js.map +1 -1
  53. package/dist/tsconfig/core/tsconfig.json +2 -0
  54. package/dist/tsconfig/mcp/tsconfig.json +2 -0
  55. package/dist/tsconfig/openai/tsconfig.json +2 -0
  56. package/dist/vite/apolloClientAiApps.d.ts +1 -0
  57. package/dist/vite/apolloClientAiApps.d.ts.map +1 -1
  58. package/dist/vite/apolloClientAiApps.js +346 -43
  59. package/dist/vite/apolloClientAiApps.js.map +1 -1
  60. package/dist/vite/utilities/recast.d.ts +54 -0
  61. package/dist/vite/utilities/recast.d.ts.map +1 -0
  62. package/dist/vite/utilities/recast.js +71 -0
  63. package/dist/vite/utilities/recast.js.map +1 -0
  64. package/package.json +7 -3
  65. package/src/core/typeRegistration.ts +32 -0
  66. package/src/index.ts +7 -0
  67. package/src/mcp/react/hooks/__tests__/useToolInfo.test.tsx +53 -0
  68. package/src/mcp/react/hooks/useToolInfo.ts +13 -0
  69. package/src/mcp/react/hooks/useToolInput.ts +6 -1
  70. package/src/mcp/react/hooks/useToolName.ts +6 -1
  71. package/src/mcp/react/index.ts +1 -0
  72. package/src/openai/react/hooks/__tests__/useToolInfo.test.tsx +92 -0
  73. package/src/openai/react/hooks/useToolInfo.ts +13 -0
  74. package/src/openai/react/hooks/useToolInput.ts +6 -1
  75. package/src/openai/react/hooks/useToolName.ts +6 -1
  76. package/src/openai/react/index.ts +1 -0
  77. package/src/react/index.mcp.ts +1 -0
  78. package/src/react/index.openai.ts +1 -0
  79. package/src/react/index.ts +11 -0
  80. package/src/tsconfig/core/tsconfig.json +2 -0
  81. package/src/tsconfig/mcp/tsconfig.json +2 -0
  82. package/src/tsconfig/openai/tsconfig.json +2 -0
  83. package/src/vite/__tests__/apolloClientAiApps.test.ts +754 -6
  84. package/src/vite/apolloClientAiApps.ts +564 -68
  85. package/src/vite/utilities/recast.ts +100 -0
@@ -0,0 +1,13 @@
1
+ import type { ToolInfo } from "../../../core/typeRegistration.js";
2
+ import { useApolloClient } from "./useApolloClient.js";
3
+
4
+ export function useToolInfo(): ToolInfo | undefined {
5
+ const appManager = useApolloClient()["appManager"];
6
+ const toolName = appManager.toolName;
7
+
8
+ if (!toolName) {
9
+ return;
10
+ }
11
+
12
+ return { toolName, toolInput: appManager.toolInput };
13
+ }
@@ -1,5 +1,10 @@
1
+ import type { ToolInput } from "../../../core/typeRegistration.js";
1
2
  import { useApolloClient } from "./useApolloClient.js";
2
3
 
3
- export function useToolInput() {
4
+ /**
5
+ * @deprecated Please use the `useToolInfo` hook. `useToolInput` will be removed
6
+ * in the next major version.
7
+ */
8
+ export function useToolInput(): ToolInput | undefined {
4
9
  return useApolloClient()["appManager"].toolInput;
5
10
  }
@@ -1,5 +1,10 @@
1
+ import type { ToolName } from "../../../core/typeRegistration.js";
1
2
  import { useApolloClient } from "./useApolloClient.js";
2
3
 
3
- export const useToolName = () => {
4
+ /**
5
+ * @deprecated Please use the `useToolInfo` hook. `useToolName` will be removed
6
+ * in the next major version.
7
+ */
8
+ export const useToolName = (): ToolName | undefined => {
4
9
  return useApolloClient()["appManager"].toolName;
5
10
  };
@@ -3,5 +3,6 @@ export { useHostContext } from "./hooks/useHostContext.js";
3
3
  export { useToolName } from "./hooks/useToolName.js";
4
4
  export { useToolMetadata } from "./hooks/useToolMetadata.js";
5
5
  export { useToolInput } from "./hooks/useToolInput.js";
6
+ export { useToolInfo } from "./hooks/useToolInfo.js";
6
7
  export { createHydrationUtils } from "./hooks/createHydrationUtils.js";
7
8
  export { useWidgetState } from "./hooks/useWidgetState.js";
@@ -3,6 +3,7 @@ export {
3
3
  useApp,
4
4
  useHostContext,
5
5
  useToolInput,
6
+ useToolInfo,
6
7
  createHydrationUtils,
7
8
  useToolMetadata,
8
9
  useToolName,
@@ -3,6 +3,7 @@ export {
3
3
  useApp,
4
4
  useHostContext,
5
5
  useToolInput,
6
+ useToolInfo,
6
7
  createHydrationUtils,
7
8
  useToolMetadata,
8
9
  useToolName,
@@ -12,6 +12,10 @@ export const useApp =
12
12
  export const useHostContext =
13
13
  missingHook<typeof import("./index.mcp.js").useHostContext>("useHostContext");
14
14
 
15
+ /**
16
+ * @deprecated Please use the `useToolInfo` hook. `useToolInput` will be removed
17
+ * in the next major version.
18
+ */
15
19
  export const useToolInput =
16
20
  missingHook<typeof import("./index.mcp.js").useToolInput>("useToolInput");
17
21
 
@@ -20,9 +24,16 @@ export const useToolMetadata =
20
24
  "useToolMetadata"
21
25
  );
22
26
 
27
+ /**
28
+ * @deprecated Please use the `useToolInfo` hook. `useToolName` will be removed
29
+ * in the next major version.
30
+ */
23
31
  export const useToolName =
24
32
  missingHook<typeof import("./index.mcp.js").useToolName>("useToolName");
25
33
 
34
+ export const useToolInfo =
35
+ missingHook<typeof import("./index.mcp.js").useToolInfo>("useToolInfo");
36
+
26
37
  /** @experimental */
27
38
  export const createHydrationUtils = missingHook<
28
39
  typeof import("./index.mcp.js").createHydrationUtils
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "allowArbitraryExtensions": true,
4
+ "resolveJsonModule": true,
3
5
  "moduleSuffixes": [".mcp", ".openai", ""]
4
6
  }
5
7
  }
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "allowArbitraryExtensions": true,
4
+ "resolveJsonModule": true,
3
5
  "customConditions": ["mcp"],
4
6
  "moduleSuffixes": [".mcp", ""]
5
7
  }
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "allowArbitraryExtensions": true,
4
+ "resolveJsonModule": true,
3
5
  "customConditions": ["openai"],
4
6
  "types": ["@apollo/client-ai-apps/openai/globals"],
5
7
  "moduleSuffixes": [".openai", ""]