@databricks/appkit-ui 0.22.0 → 0.23.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.
Files changed (33) hide show
  1. package/CLAUDE.md +10 -0
  2. package/NOTICE.md +1 -0
  3. package/dist/cli/commands/generate-types.js +15 -13
  4. package/dist/cli/commands/generate-types.js.map +1 -1
  5. package/dist/react/hooks/index.d.ts +4 -2
  6. package/dist/react/hooks/index.js +2 -0
  7. package/dist/react/hooks/types.d.ts +30 -1
  8. package/dist/react/hooks/types.d.ts.map +1 -1
  9. package/dist/react/hooks/use-serving-invoke.d.ts +30 -0
  10. package/dist/react/hooks/use-serving-invoke.d.ts.map +1 -0
  11. package/dist/react/hooks/use-serving-invoke.js +82 -0
  12. package/dist/react/hooks/use-serving-invoke.js.map +1 -0
  13. package/dist/react/hooks/use-serving-stream.d.ts +35 -0
  14. package/dist/react/hooks/use-serving-stream.d.ts.map +1 -0
  15. package/dist/react/hooks/use-serving-stream.js +101 -0
  16. package/dist/react/hooks/use-serving-stream.js.map +1 -0
  17. package/dist/react/index.d.ts +4 -2
  18. package/dist/react/index.js +3 -1
  19. package/docs/api/appkit/Class.Plugin.md +8 -3
  20. package/docs/api/appkit/Function.appKitServingTypesPlugin.md +24 -0
  21. package/docs/api/appkit/Function.extractServingEndpoints.md +22 -0
  22. package/docs/api/appkit/Function.findServerFile.md +20 -0
  23. package/docs/api/appkit/Interface.EndpointConfig.md +23 -0
  24. package/docs/api/appkit/Interface.ServingEndpointEntry.md +30 -0
  25. package/docs/api/appkit/Interface.ServingEndpointRegistry.md +3 -0
  26. package/docs/api/appkit/TypeAlias.ExecutionResult.md +36 -0
  27. package/docs/api/appkit/TypeAlias.ServingFactory.md +15 -0
  28. package/docs/api/appkit.md +39 -31
  29. package/docs/faq.md +66 -0
  30. package/docs/plugins/serving.md +223 -0
  31. package/llms.txt +10 -0
  32. package/package.json +1 -1
  33. package/sbom.cdx.json +1 -1
package/CLAUDE.md CHANGED
@@ -27,6 +27,7 @@ npx @databricks/appkit docs <query>
27
27
  - [Configuration](./docs/configuration.md): This guide covers environment variables and configuration options for AppKit applications.
28
28
  - [Core principles](./docs/core-principles.md): Learn about the fundamental concepts and principles behind AppKit.
29
29
  - [Development](./docs/development.md): AppKit provides multiple development workflows to suit different needs: local development with hot reload, AI-assisted development with Agent Skills, and remote tunneling to deployed backends.
30
+ - [FAQ](./docs/faq.md): Integrations
30
31
  - [Plugins](./docs/plugins.md): Plugins are modular extensions that add capabilities to your AppKit application. They follow a defined lifecycle and have access to shared services like caching, telemetry, and streaming.
31
32
 
32
33
  ## Development
@@ -50,6 +51,7 @@ npx @databricks/appkit docs <query>
50
51
  - [Lakebase plugin](./docs/plugins/lakebase.md): Provides a PostgreSQL connection pool for Databricks Lakebase Autoscaling with automatic OAuth token refresh.
51
52
  - [Plugin management](./docs/plugins/plugin-management.md): AppKit includes a CLI for managing plugins. All commands are available under npx @databricks/appkit plugin.
52
53
  - [Server plugin](./docs/plugins/server.md): Provides HTTP server capabilities with development and production modes.
54
+ - [Serving plugin](./docs/plugins/serving.md): Provides an authenticated proxy to Databricks Model Serving endpoints, with invoke and streaming support.
53
55
 
54
56
  ## appkit API reference [collapsed]
55
57
 
@@ -67,9 +69,12 @@ npx @databricks/appkit docs <query>
67
69
  - [Class: ValidationError](./docs/api/appkit/Class.ValidationError.md): Error thrown when input validation fails.
68
70
  - [Enumeration: RequestedClaimsPermissionSet](./docs/api/appkit/Enumeration.RequestedClaimsPermissionSet.md): Permission set for Unity Catalog table access
69
71
  - [Enumeration: ResourceType](./docs/api/appkit/Enumeration.ResourceType.md): Resource types from schema $defs.resourceType.enum
72
+ - [Function: appKitServingTypesPlugin()](./docs/api/appkit/Function.appKitServingTypesPlugin.md): Vite plugin to generate TypeScript types for AppKit serving endpoints.
70
73
  - [Function: appKitTypesPlugin()](./docs/api/appkit/Function.appKitTypesPlugin.md): Vite plugin to generate types for AppKit queries.
71
74
  - [Function: createApp()](./docs/api/appkit/Function.createApp.md): Bootstraps AppKit with the provided configuration.
72
75
  - [Function: createLakebasePool()](./docs/api/appkit/Function.createLakebasePool.md): Create a Lakebase pool with appkit's logger integration.
76
+ - [Function: extractServingEndpoints()](./docs/api/appkit/Function.extractServingEndpoints.md): Extract serving endpoint config from a server file by AST-parsing it.
77
+ - [Function: findServerFile()](./docs/api/appkit/Function.findServerFile.md): Find the server entry file by checking candidate paths in order.
73
78
  - [Function: generateDatabaseCredential()](./docs/api/appkit/Function.generateDatabaseCredential.md): Generate OAuth credentials for Postgres database connection using the proper Postgres API.
74
79
  - [Function: getExecutionContext()](./docs/api/appkit/Function.getExecutionContext.md): Get the current execution context.
75
80
  - [Function: getLakebaseOrmConfig()](./docs/api/appkit/Function.getLakebaseOrmConfig.md): Get Lakebase connection configuration for ORMs that don't accept pg.Pool directly.
@@ -82,6 +87,7 @@ npx @databricks/appkit docs <query>
82
87
  - [Interface: BasePluginConfig](./docs/api/appkit/Interface.BasePluginConfig.md): Base configuration interface for AppKit plugins
83
88
  - [Interface: CacheConfig](./docs/api/appkit/Interface.CacheConfig.md): Configuration for the CacheInterceptor. Controls TTL, size limits, storage backend, and probabilistic cleanup.
84
89
  - [Interface: DatabaseCredential](./docs/api/appkit/Interface.DatabaseCredential.md): Database credentials with OAuth token for Postgres connection
90
+ - [Interface: EndpointConfig](./docs/api/appkit/Interface.EndpointConfig.md): Properties
85
91
  - [Interface: GenerateDatabaseCredentialRequest](./docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md): Request parameters for generating database OAuth credentials
86
92
  - [Interface: ITelemetry](./docs/api/appkit/Interface.ITelemetry.md): Plugin-facing interface for OpenTelemetry instrumentation.
87
93
  - [Interface: LakebasePoolConfig](./docs/api/appkit/Interface.LakebasePoolConfig.md): Configuration for creating a Lakebase connection pool
@@ -91,13 +97,17 @@ npx @databricks/appkit docs <query>
91
97
  - [Interface: ResourceEntry](./docs/api/appkit/Interface.ResourceEntry.md): Internal representation of a resource in the registry.
92
98
  - [Interface: ResourceFieldEntry](./docs/api/appkit/Interface.ResourceFieldEntry.md): Defines a single field for a resource. Each field has its own environment variable and optional description. Single-value types use one key (e.g. id); multi-value types (database, secret) use multiple (e.g. instancename, databasename or scope, key).
93
99
  - [Interface: ResourceRequirement](./docs/api/appkit/Interface.ResourceRequirement.md): Declares a resource requirement for a plugin.
100
+ - [Interface: ServingEndpointEntry](./docs/api/appkit/Interface.ServingEndpointEntry.md): Shape of a single registry entry.
101
+ - [Interface: ServingEndpointRegistry](./docs/api/appkit/Interface.ServingEndpointRegistry.md): Registry interface for serving endpoint type generation.
94
102
  - [Interface: StreamExecutionSettings](./docs/api/appkit/Interface.StreamExecutionSettings.md): Execution settings for streaming endpoints. Extends PluginExecutionSettings with SSE stream configuration.
95
103
  - [Interface: TelemetryConfig](./docs/api/appkit/Interface.TelemetryConfig.md): OpenTelemetry configuration for AppKit applications
96
104
  - [Interface: ValidationResult](./docs/api/appkit/Interface.ValidationResult.md): Result of validating all registered resources against the environment.
97
105
  - [Type Alias: ConfigSchema](./docs/api/appkit/TypeAlias.ConfigSchema.md): Configuration schema definition for plugin config.
106
+ - [Type Alias: ExecutionResult<T>](./docs/api/appkit/TypeAlias.ExecutionResult.md): Discriminated union for plugin execution results.
98
107
  - [Type Alias: IAppRouter](./docs/api/appkit/TypeAlias.IAppRouter.md): Express router type for plugin route registration
99
108
  - [Type Alias: PluginData<T, U, N>](./docs/api/appkit/TypeAlias.PluginData.md): Tuple of plugin class, config, and name. Created by toPlugin() and passed to createApp().
100
109
  - [Type Alias: ResourcePermission](./docs/api/appkit/TypeAlias.ResourcePermission.md): Union of all possible permission levels across all resource types.
110
+ - [Type Alias: ServingFactory](./docs/api/appkit/TypeAlias.ServingFactory.md): Factory function returned by AppKit.serving.
101
111
  - [Type Alias: ToPlugin()<T, U, N>](./docs/api/appkit/TypeAlias.ToPlugin.md): Factory function type returned by toPlugin(). Accepts optional config and returns a PluginData tuple.
102
112
  - [Variable: sql](./docs/api/appkit/Variable.sql.md): SQL helper namespace
103
113
 
package/NOTICE.md CHANGED
@@ -58,6 +58,7 @@ This Software contains code from the following open source projects:
58
58
  | [clsx](https://www.npmjs.com/package/clsx) | 2.1.1 | MIT | https://github.com/lukeed/clsx#readme |
59
59
  | [cmdk](https://www.npmjs.com/package/cmdk) | 1.1.1 | MIT | https://github.com/pacocoursey/cmdk#readme |
60
60
  | [commander](https://www.npmjs.com/package/commander) | 2.20.3, 5.1.0, 7.2.0, 8.3.0, 10.0.1, 12.1.0 | MIT | https://github.com/tj/commander.js#readme |
61
+ | [dompurify](https://www.npmjs.com/package/dompurify) | 3.3.3 | (MPL-2.0 OR Apache-2.0) | https://github.com/cure53/DOMPurify |
61
62
  | [dotenv](https://www.npmjs.com/package/dotenv) | 16.6.1 | BSD-2-Clause | https://github.com/motdotla/dotenv#readme |
62
63
  | [echarts](https://www.npmjs.com/package/echarts) | 6.0.0 | Apache-2.0 | https://echarts.apache.org |
63
64
  | [echarts-for-react](https://www.npmjs.com/package/echarts-for-react) | 3.0.5 | MIT | https://github.com/hustcc/echarts-for-react |
@@ -8,21 +8,23 @@ import { Command } from "commander";
8
8
  */
9
9
  async function runGenerateTypes(rootDir, outFile, warehouseId, options) {
10
10
  try {
11
- const resolvedWarehouseId = warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;
12
- if (!resolvedWarehouseId) process.exit(0);
13
- const { generateFromEntryPoint } = await import("@databricks/appkit/type-generator");
14
11
  const resolvedRootDir = rootDir || process.cwd();
15
- const resolvedOutFile = outFile || path.join(process.cwd(), "client/src/appKitTypes.d.ts");
16
- const queryFolder = path.join(resolvedRootDir, "config/queries");
17
- if (!fs.existsSync(queryFolder)) {
18
- console.warn(`Warning: No queries found at ${queryFolder}. Skipping type generation.`);
19
- return;
12
+ const noCache = options?.noCache || false;
13
+ const typeGen = await import("@databricks/appkit/type-generator");
14
+ const resolvedWarehouseId = warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;
15
+ if (resolvedWarehouseId) {
16
+ const resolvedOutFile = outFile || path.join(process.cwd(), "client/src/appKitTypes.d.ts");
17
+ const queryFolder = path.join(resolvedRootDir, "config/queries");
18
+ if (fs.existsSync(queryFolder)) await typeGen.generateFromEntryPoint({
19
+ queryFolder,
20
+ outFile: resolvedOutFile,
21
+ warehouseId: resolvedWarehouseId,
22
+ noCache
23
+ });
20
24
  }
21
- await generateFromEntryPoint({
22
- queryFolder,
23
- outFile: resolvedOutFile,
24
- warehouseId: resolvedWarehouseId,
25
- noCache: options?.noCache || false
25
+ await typeGen.generateServingTypes({
26
+ outFile: path.join(process.cwd(), "client/src/appKitServingTypes.d.ts"),
27
+ noCache
26
28
  });
27
29
  } catch (error) {
28
30
  if (error instanceof Error && error.message.includes("Cannot find module")) {
@@ -1 +1 @@
1
- {"version":3,"file":"generate-types.js","names":[],"sources":["../../../src/cli/commands/generate-types.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Command } from \"commander\";\n\n/**\n * Generate types command implementation\n */\nasync function runGenerateTypes(\n rootDir?: string,\n outFile?: string,\n warehouseId?: string,\n options?: { noCache?: boolean },\n) {\n try {\n const resolvedWarehouseId =\n warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;\n\n if (!resolvedWarehouseId) {\n process.exit(0);\n }\n\n // Try to import the type generator from @databricks/appkit\n const { generateFromEntryPoint } = await import(\n \"@databricks/appkit/type-generator\"\n );\n\n const resolvedRootDir = rootDir || process.cwd();\n const resolvedOutFile =\n outFile || path.join(process.cwd(), \"client/src/appKitTypes.d.ts\");\n\n const queryFolder = path.join(resolvedRootDir, \"config/queries\");\n if (!fs.existsSync(queryFolder)) {\n console.warn(\n `Warning: No queries found at ${queryFolder}. Skipping type generation.`,\n );\n return;\n }\n\n await generateFromEntryPoint({\n queryFolder,\n outFile: resolvedOutFile,\n warehouseId: resolvedWarehouseId,\n noCache: options?.noCache || false,\n });\n } catch (error) {\n if (\n error instanceof Error &&\n error.message.includes(\"Cannot find module\")\n ) {\n console.error(\n \"Error: The 'generate-types' command is only available in @databricks/appkit.\",\n );\n console.error(\"Please install @databricks/appkit to use this command.\");\n process.exit(1);\n }\n throw error;\n }\n}\n\nexport const generateTypesCommand = new Command(\"generate-types\")\n .description(\"Generate TypeScript types from SQL queries\")\n .argument(\"[rootDir]\", \"Root directory of the project\", process.cwd())\n .argument(\n \"[outFile]\",\n \"Output file path\",\n path.join(process.cwd(), \"client/src/appKitTypes.d.ts\"),\n )\n .argument(\"[warehouseId]\", \"Databricks warehouse ID\")\n .option(\"--no-cache\", \"Disable caching for type generation\")\n .action(runGenerateTypes);\n"],"mappings":";;;;;;;;AAOA,eAAe,iBACb,SACA,SACA,aACA,SACA;AACA,KAAI;EACF,MAAM,sBACJ,eAAe,QAAQ,IAAI;AAE7B,MAAI,CAAC,oBACH,SAAQ,KAAK,EAAE;EAIjB,MAAM,EAAE,2BAA2B,MAAM,OACvC;EAGF,MAAM,kBAAkB,WAAW,QAAQ,KAAK;EAChD,MAAM,kBACJ,WAAW,KAAK,KAAK,QAAQ,KAAK,EAAE,8BAA8B;EAEpE,MAAM,cAAc,KAAK,KAAK,iBAAiB,iBAAiB;AAChE,MAAI,CAAC,GAAG,WAAW,YAAY,EAAE;AAC/B,WAAQ,KACN,gCAAgC,YAAY,6BAC7C;AACD;;AAGF,QAAM,uBAAuB;GAC3B;GACA,SAAS;GACT,aAAa;GACb,SAAS,SAAS,WAAW;GAC9B,CAAC;UACK,OAAO;AACd,MACE,iBAAiB,SACjB,MAAM,QAAQ,SAAS,qBAAqB,EAC5C;AACA,WAAQ,MACN,+EACD;AACD,WAAQ,MAAM,yDAAyD;AACvE,WAAQ,KAAK,EAAE;;AAEjB,QAAM;;;AAIV,MAAa,uBAAuB,IAAI,QAAQ,iBAAiB,CAC9D,YAAY,6CAA6C,CACzD,SAAS,aAAa,iCAAiC,QAAQ,KAAK,CAAC,CACrE,SACC,aACA,oBACA,KAAK,KAAK,QAAQ,KAAK,EAAE,8BAA8B,CACxD,CACA,SAAS,iBAAiB,0BAA0B,CACpD,OAAO,cAAc,sCAAsC,CAC3D,OAAO,iBAAiB"}
1
+ {"version":3,"file":"generate-types.js","names":[],"sources":["../../../src/cli/commands/generate-types.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { Command } from \"commander\";\n\n/**\n * Generate types command implementation\n */\nasync function runGenerateTypes(\n rootDir?: string,\n outFile?: string,\n warehouseId?: string,\n options?: { noCache?: boolean },\n) {\n try {\n const resolvedRootDir = rootDir || process.cwd();\n const noCache = options?.noCache || false;\n\n const typeGen = await import(\"@databricks/appkit/type-generator\");\n\n // Generate analytics query types (requires warehouse ID)\n const resolvedWarehouseId =\n warehouseId || process.env.DATABRICKS_WAREHOUSE_ID;\n\n if (resolvedWarehouseId) {\n const resolvedOutFile =\n outFile || path.join(process.cwd(), \"client/src/appKitTypes.d.ts\");\n\n const queryFolder = path.join(resolvedRootDir, \"config/queries\");\n if (fs.existsSync(queryFolder)) {\n await typeGen.generateFromEntryPoint({\n queryFolder,\n outFile: resolvedOutFile,\n warehouseId: resolvedWarehouseId,\n noCache,\n });\n }\n }\n\n // Generate serving endpoint types (no warehouse required)\n await typeGen.generateServingTypes({\n outFile: path.join(process.cwd(), \"client/src/appKitServingTypes.d.ts\"),\n noCache,\n });\n } catch (error) {\n if (\n error instanceof Error &&\n error.message.includes(\"Cannot find module\")\n ) {\n console.error(\n \"Error: The 'generate-types' command is only available in @databricks/appkit.\",\n );\n console.error(\"Please install @databricks/appkit to use this command.\");\n process.exit(1);\n }\n throw error;\n }\n}\n\nexport const generateTypesCommand = new Command(\"generate-types\")\n .description(\"Generate TypeScript types from SQL queries\")\n .argument(\"[rootDir]\", \"Root directory of the project\", process.cwd())\n .argument(\n \"[outFile]\",\n \"Output file path\",\n path.join(process.cwd(), \"client/src/appKitTypes.d.ts\"),\n )\n .argument(\"[warehouseId]\", \"Databricks warehouse ID\")\n .option(\"--no-cache\", \"Disable caching for type generation\")\n .action(runGenerateTypes);\n"],"mappings":";;;;;;;;AAOA,eAAe,iBACb,SACA,SACA,aACA,SACA;AACA,KAAI;EACF,MAAM,kBAAkB,WAAW,QAAQ,KAAK;EAChD,MAAM,UAAU,SAAS,WAAW;EAEpC,MAAM,UAAU,MAAM,OAAO;EAG7B,MAAM,sBACJ,eAAe,QAAQ,IAAI;AAE7B,MAAI,qBAAqB;GACvB,MAAM,kBACJ,WAAW,KAAK,KAAK,QAAQ,KAAK,EAAE,8BAA8B;GAEpE,MAAM,cAAc,KAAK,KAAK,iBAAiB,iBAAiB;AAChE,OAAI,GAAG,WAAW,YAAY,CAC5B,OAAM,QAAQ,uBAAuB;IACnC;IACA,SAAS;IACT,aAAa;IACb;IACD,CAAC;;AAKN,QAAM,QAAQ,qBAAqB;GACjC,SAAS,KAAK,KAAK,QAAQ,KAAK,EAAE,qCAAqC;GACvE;GACD,CAAC;UACK,OAAO;AACd,MACE,iBAAiB,SACjB,MAAM,QAAQ,SAAS,qBAAqB,EAC5C;AACA,WAAQ,MACN,+EACD;AACD,WAAQ,MAAM,yDAAyD;AACvE,WAAQ,KAAK,EAAE;;AAEjB,QAAM;;;AAIV,MAAa,uBAAuB,IAAI,QAAQ,iBAAiB,CAC9D,YAAY,6CAA6C,CACzD,SAAS,aAAa,iCAAiC,QAAQ,KAAK,CAAC,CACrE,SACC,aACA,oBACA,KAAK,KAAK,QAAQ,KAAK,EAAE,8BAA8B,CACxD,CACA,SAAS,iBAAiB,0BAA0B,CACpD,OAAO,cAAc,sCAAsC,CAC3D,OAAO,iBAAiB"}
@@ -1,4 +1,6 @@
1
1
  import { UseChartDataOptions, UseChartDataResult, useChartData } from "./use-chart-data.js";
2
- import { AnalyticsFormat, InferResultByFormat, InferRowType, PluginRegistry, QueryRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult } from "./types.js";
2
+ import { AnalyticsFormat, InferResultByFormat, InferRowType, InferServingChunk, InferServingRequest, InferServingResponse, PluginRegistry, QueryRegistry, ServingAlias, ServingEndpointRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult } from "./types.js";
3
3
  import { useAnalyticsQuery } from "./use-analytics-query.js";
4
- import { usePluginClientConfig } from "./use-plugin-config.js";
4
+ import { usePluginClientConfig } from "./use-plugin-config.js";
5
+ import { UseServingInvokeOptions, UseServingInvokeResult, useServingInvoke } from "./use-serving-invoke.js";
6
+ import { UseServingStreamOptions, UseServingStreamResult, useServingStream } from "./use-serving-stream.js";
@@ -1,3 +1,5 @@
1
1
  import { useAnalyticsQuery } from "./use-analytics-query.js";
2
2
  import { useChartData } from "./use-chart-data.js";
3
3
  import { usePluginClientConfig } from "./use-plugin-config.js";
4
+ import { useServingInvoke } from "./use-serving-invoke.js";
5
+ import { useServingStream } from "./use-serving-stream.js";
@@ -96,6 +96,35 @@ type InferParams<K> = K extends AugmentedRegistry<QueryRegistry> ? QueryRegistry
96
96
  interface PluginRegistry {
97
97
  [key: string]: Record<string, any>;
98
98
  }
99
+ /**
100
+ * Serving endpoint registry for type-safe alias names.
101
+ * Extend this interface via module augmentation to get alias autocomplete:
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // Auto-generated by appKitServingTypesPlugin()
106
+ * declare module "@databricks/appkit-ui/react" {
107
+ * interface ServingEndpointRegistry {
108
+ * llm: { request: {...}; response: {...}; chunk: {...} };
109
+ * }
110
+ * }
111
+ * ```
112
+ */
113
+ interface ServingEndpointRegistry {}
114
+ /** Resolves to registry keys if populated, otherwise string */
115
+ type ServingAlias = AugmentedRegistry<ServingEndpointRegistry> extends never ? string : AugmentedRegistry<ServingEndpointRegistry>;
116
+ /** Infers chunk type from registry when alias is a known key */
117
+ type InferServingChunk<K> = K extends AugmentedRegistry<ServingEndpointRegistry> ? ServingEndpointRegistry[K] extends {
118
+ chunk: infer C;
119
+ } ? C : unknown : unknown;
120
+ /** Infers response type from registry when alias is a known key */
121
+ type InferServingResponse<K> = K extends AugmentedRegistry<ServingEndpointRegistry> ? ServingEndpointRegistry[K] extends {
122
+ response: infer R;
123
+ } ? R : unknown : unknown;
124
+ /** Infers request type from registry when alias is a known key */
125
+ type InferServingRequest<K> = K extends AugmentedRegistry<ServingEndpointRegistry> ? ServingEndpointRegistry[K] extends {
126
+ request: infer Req;
127
+ } ? Req : Record<string, unknown> : Record<string, unknown>;
99
128
  //#endregion
100
- export { AnalyticsFormat, InferParams, InferResultByFormat, InferRowType, PluginRegistry, QueryKey, QueryRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult };
129
+ export { AnalyticsFormat, InferParams, InferResultByFormat, InferRowType, InferServingChunk, InferServingRequest, InferServingResponse, PluginRegistry, QueryKey, QueryRegistry, ServingAlias, ServingEndpointRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult };
101
130
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/react/hooks/types.ts"],"mappings":";;;;KAOY,eAAA;AAAZ;;;;;AAYA;;;;;AAZA,UAYiB,eAAA,cACF,MAAA,oBAA0B,MAAA,2BAC/B,KAAA;EAAA;;;;EAAA,SAKC,SAAA,GAAY,IAAA;AAAA;;UAQN,wBAAA,WAAmC,eAAA;EAR7B;EAUrB,MAAA,GAAS,CAAA;EAVgB;EAazB,iBAAA;EALuC;EAQvC,SAAA;AAAA;;UAIe,uBAAA;EAVf;EAYA,IAAA,EAAM,CAAA;EATN;EAWA,OAAA;EARS;EAUT,KAAA;AAAA;;;;;;;;;;;AAqBF;;;;;;;;UAAiB,aAAA;EAAA,CACd,GAAA;IACC,IAAA;IACA,UAAA,EAAY,MAAA;IACZ,MAAA;EAAA;AAAA;;KAKQ,iBAAA,0BACE,CAAA,mBAAoB,CAAA,WAAY,CAAA,GAAI,CAAA,CAAE,CAAA;;KAIxC,QAAA,GAAW,iBAAA,CAAkB,aAAA,2BAErC,iBAAA,CAAkB,aAAA;;;;;KAMV,WAAA,SAAoB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACxD,aAAA,CAAc,CAAA;EAAa,MAAA;AAAA,IACzB,CAAA,GACA,CAAA,GACF,CAAA;;;AAZJ;;KAkBY,YAAA,MAAkB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACtD,aAAA,CAAc,CAAA;EAAa,MAAA,EAAQ,KAAA;AAAA,IACjC,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,oBACF,MAAA,oBACF,MAAA;;;;;;KAOQ,mBAAA,iBAGA,eAAA,IACR,CAAA,mBAAoB,eAAA,CAAgB,YAAA,CAAa,CAAA,KAAM,WAAA,CAAY,CAAA,EAAG,CAAA;;;;KAK9D,WAAA,MAAiB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACrD,aAAA,CAAc,CAAA;EAAa,UAAA;AAAA,IACzB,CAAA,GACA,MAAA,oBACF,MAAA;AAAA,UAEa,cAAA;EAAA,CACd,GAAA,WAAc,MAAA;AAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/react/hooks/types.ts"],"mappings":";;;;KAOY,eAAA;AAAZ;;;;;AAYA;;;;;AAZA,UAYiB,eAAA,cACF,MAAA,oBAA0B,MAAA,2BAC/B,KAAA;EAAA;;;;EAAA,SAKC,SAAA,GAAY,IAAA;AAAA;;UAQN,wBAAA,WAAmC,eAAA;EAR7B;EAUrB,MAAA,GAAS,CAAA;EAVgB;EAazB,iBAAA;EALuC;EAQvC,SAAA;AAAA;;UAIe,uBAAA;EAVf;EAYA,IAAA,EAAM,CAAA;EATN;EAWA,OAAA;EARS;EAUT,KAAA;AAAA;;;;;;;;;;;AAqBF;;;;;;;;UAAiB,aAAA;EAAA,CACd,GAAA;IACC,IAAA;IACA,UAAA,EAAY,MAAA;IACZ,MAAA;EAAA;AAAA;;KAKQ,iBAAA,0BACE,CAAA,mBAAoB,CAAA,WAAY,CAAA,GAAI,CAAA,CAAE,CAAA;;KAIxC,QAAA,GAAW,iBAAA,CAAkB,aAAA,2BAErC,iBAAA,CAAkB,aAAA;;;;;KAMV,WAAA,SAAoB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACxD,aAAA,CAAc,CAAA;EAAa,MAAA;AAAA,IACzB,CAAA,GACA,CAAA,GACF,CAAA;;;AAZJ;;KAkBY,YAAA,MAAkB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACtD,aAAA,CAAc,CAAA;EAAa,MAAA,EAAQ,KAAA;AAAA,IACjC,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,oBACF,MAAA,oBACF,MAAA;;;;;;KAOQ,mBAAA,iBAGA,eAAA,IACR,CAAA,mBAAoB,eAAA,CAAgB,YAAA,CAAa,CAAA,KAAM,WAAA,CAAY,CAAA,EAAG,CAAA;;;;KAK9D,WAAA,MAAiB,CAAA,SAAU,iBAAA,CAAkB,aAAA,IACrD,aAAA,CAAc,CAAA;EAAa,UAAA;AAAA,IACzB,CAAA,GACA,MAAA,oBACF,MAAA;AAAA,UAEa,cAAA;EAAA,CACd,GAAA,WAAc,MAAA;AAAA;;;;;;;;;;;;;;;UA2BA,uBAAA;;KAGL,YAAA,GACV,iBAAA,CAAkB,uBAAA,2BAEd,iBAAA,CAAkB,uBAAA;;KAGZ,iBAAA,MACV,CAAA,SAAU,iBAAA,CAAkB,uBAAA,IACxB,uBAAA,CAAwB,CAAA;EAAa,KAAA;AAAA,IACnC,CAAA;;KAKI,oBAAA,MACV,CAAA,SAAU,iBAAA,CAAkB,uBAAA,IACxB,uBAAA,CAAwB,CAAA;EAAa,QAAA;AAAA,IACnC,CAAA;;KAKI,mBAAA,MACV,CAAA,SAAU,iBAAA,CAAkB,uBAAA,IACxB,uBAAA,CAAwB,CAAA;EAAa,OAAA;AAAA,IACnC,GAAA,GACA,MAAA,oBACF,MAAA"}
@@ -0,0 +1,30 @@
1
+ import { InferServingRequest, InferServingResponse, ServingAlias } from "./types.js";
2
+
3
+ //#region src/react/hooks/use-serving-invoke.d.ts
4
+ interface UseServingInvokeOptions<K extends ServingAlias = ServingAlias> {
5
+ /** Endpoint alias for named mode. Omit for default mode. */
6
+ alias?: K;
7
+ /** If false, does not invoke automatically on mount. Default: false */
8
+ autoStart?: boolean;
9
+ }
10
+ interface UseServingInvokeResult<T = unknown, TBody = Record<string, unknown>> {
11
+ /** Trigger the invocation. Pass an optional body override for this invocation. */
12
+ invoke: (overrideBody?: TBody) => Promise<T | null>;
13
+ /** Response data, null until loaded. */
14
+ data: T | null;
15
+ /** Whether a request is in progress. */
16
+ loading: boolean;
17
+ /** Error message, if any. */
18
+ error: string | null;
19
+ }
20
+ /**
21
+ * Hook for non-streaming invocation of a serving endpoint.
22
+ * Calls `POST /api/serving/invoke` (default) or `POST /api/serving/{alias}/invoke` (named).
23
+ *
24
+ * When the type generator has populated `ServingEndpointRegistry`, the response type
25
+ * is automatically inferred from the endpoint's OpenAPI schema.
26
+ */
27
+ declare function useServingInvoke<K extends ServingAlias = ServingAlias>(body: InferServingRequest<K>, options?: UseServingInvokeOptions<K>): UseServingInvokeResult<InferServingResponse<K>, InferServingRequest<K>>;
28
+ //#endregion
29
+ export { UseServingInvokeOptions, UseServingInvokeResult, useServingInvoke };
30
+ //# sourceMappingURL=use-serving-invoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-serving-invoke.d.ts","names":[],"sources":["../../../src/react/hooks/use-serving-invoke.ts"],"mappings":";;;UASiB,uBAAA,WACL,YAAA,GAAe,YAAA;;EAGzB,KAAA,GAAQ,CAAA;EAJ8B;EAMtC,SAAA;AAAA;AAAA,UAGe,sBAAA,sBAEP,MAAA;EAPA;EAUR,MAAA,GAAS,YAAA,GAAe,KAAA,KAAU,OAAA,CAAQ,CAAA;EAVjC;EAYT,IAAA,EAAM,CAAA;EAfI;EAiBV,OAAA;EAdA;EAgBA,KAAA;AAAA;;;AAXF;;;;;iBAqBgB,gBAAA,WAA2B,YAAA,GAAe,YAAA,CAAA,CACxD,IAAA,EAAM,mBAAA,CAAoB,CAAA,GAC1B,OAAA,GAAS,uBAAA,CAAwB,CAAA,IAChC,sBAAA,CAAuB,oBAAA,CAAqB,CAAA,GAAI,mBAAA,CAAoB,CAAA"}
@@ -0,0 +1,82 @@
1
+ import { usePluginClientConfig } from "./use-plugin-config.js";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+
4
+ //#region src/react/hooks/use-serving-invoke.ts
5
+ /**
6
+ * Hook for non-streaming invocation of a serving endpoint.
7
+ * Calls `POST /api/serving/invoke` (default) or `POST /api/serving/{alias}/invoke` (named).
8
+ *
9
+ * When the type generator has populated `ServingEndpointRegistry`, the response type
10
+ * is automatically inferred from the endpoint's OpenAPI schema.
11
+ */
12
+ function useServingInvoke(body, options = {}) {
13
+ const { alias, autoStart = false } = options;
14
+ const config = usePluginClientConfig("serving");
15
+ const aliasError = useMemo(() => {
16
+ if (!alias || !config.aliases) return null;
17
+ const aliasStr = String(alias);
18
+ if (!config.aliases.includes(aliasStr)) return `Unknown serving alias "${aliasStr}". Available: ${config.aliases.join(", ")}`;
19
+ return null;
20
+ }, [alias, config.aliases]);
21
+ const [data, setData] = useState(null);
22
+ const [loading, setLoading] = useState(false);
23
+ const [error, setError] = useState(aliasError);
24
+ const abortControllerRef = useRef(null);
25
+ const urlSuffix = alias ? `/api/serving/${encodeURIComponent(String(alias))}/invoke` : "/api/serving/invoke";
26
+ const bodyJson = JSON.stringify(body);
27
+ const invoke = useCallback((overrideBody) => {
28
+ if (aliasError) {
29
+ setError(aliasError);
30
+ return Promise.resolve(null);
31
+ }
32
+ if (abortControllerRef.current) abortControllerRef.current.abort();
33
+ setLoading(true);
34
+ setError(null);
35
+ setData(null);
36
+ const abortController = new AbortController();
37
+ abortControllerRef.current = abortController;
38
+ const payload = overrideBody ? JSON.stringify(overrideBody) : bodyJson;
39
+ return fetch(urlSuffix, {
40
+ method: "POST",
41
+ headers: { "Content-Type": "application/json" },
42
+ body: payload,
43
+ signal: abortController.signal
44
+ }).then(async (res) => {
45
+ if (!res.ok) {
46
+ const errorBody = await res.json().catch(() => null);
47
+ throw new Error(errorBody?.error || `HTTP ${res.status}`);
48
+ }
49
+ return res.json();
50
+ }).then((result) => {
51
+ if (abortController.signal.aborted) return null;
52
+ setData(result);
53
+ setLoading(false);
54
+ return result;
55
+ }).catch((err) => {
56
+ if (abortController.signal.aborted) return null;
57
+ setError(err.message || "Request failed");
58
+ setLoading(false);
59
+ return null;
60
+ });
61
+ }, [
62
+ urlSuffix,
63
+ bodyJson,
64
+ aliasError
65
+ ]);
66
+ useEffect(() => {
67
+ if (autoStart) invoke();
68
+ return () => {
69
+ abortControllerRef.current?.abort();
70
+ };
71
+ }, [invoke, autoStart]);
72
+ return {
73
+ invoke,
74
+ data,
75
+ loading,
76
+ error
77
+ };
78
+ }
79
+
80
+ //#endregion
81
+ export { useServingInvoke };
82
+ //# sourceMappingURL=use-serving-invoke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-serving-invoke.js","names":[],"sources":["../../../src/react/hooks/use-serving-invoke.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n InferServingRequest,\n InferServingResponse,\n ServingAlias,\n ServingClientConfig,\n} from \"./types\";\nimport { usePluginClientConfig } from \"./use-plugin-config\";\n\nexport interface UseServingInvokeOptions<\n K extends ServingAlias = ServingAlias,\n> {\n /** Endpoint alias for named mode. Omit for default mode. */\n alias?: K;\n /** If false, does not invoke automatically on mount. Default: false */\n autoStart?: boolean;\n}\n\nexport interface UseServingInvokeResult<\n T = unknown,\n TBody = Record<string, unknown>,\n> {\n /** Trigger the invocation. Pass an optional body override for this invocation. */\n invoke: (overrideBody?: TBody) => Promise<T | null>;\n /** Response data, null until loaded. */\n data: T | null;\n /** Whether a request is in progress. */\n loading: boolean;\n /** Error message, if any. */\n error: string | null;\n}\n\n/**\n * Hook for non-streaming invocation of a serving endpoint.\n * Calls `POST /api/serving/invoke` (default) or `POST /api/serving/{alias}/invoke` (named).\n *\n * When the type generator has populated `ServingEndpointRegistry`, the response type\n * is automatically inferred from the endpoint's OpenAPI schema.\n */\nexport function useServingInvoke<K extends ServingAlias = ServingAlias>(\n body: InferServingRequest<K>,\n options: UseServingInvokeOptions<K> = {} as UseServingInvokeOptions<K>,\n): UseServingInvokeResult<InferServingResponse<K>, InferServingRequest<K>> {\n type TResponse = InferServingResponse<K>;\n const { alias, autoStart = false } = options;\n\n const config = usePluginClientConfig<ServingClientConfig>(\"serving\");\n\n const aliasError = useMemo(() => {\n if (!alias || !config.aliases) return null;\n const aliasStr = String(alias);\n if (!config.aliases.includes(aliasStr)) {\n return `Unknown serving alias \"${aliasStr}\". Available: ${config.aliases.join(\", \")}`;\n }\n return null;\n }, [alias, config.aliases]);\n\n const [data, setData] = useState<TResponse | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(aliasError);\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const urlSuffix = alias\n ? `/api/serving/${encodeURIComponent(String(alias))}/invoke`\n : \"/api/serving/invoke\";\n\n const bodyJson = JSON.stringify(body);\n\n const invoke = useCallback(\n (overrideBody?: InferServingRequest<K>): Promise<TResponse | null> => {\n if (aliasError) {\n setError(aliasError);\n return Promise.resolve(null);\n }\n\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n setLoading(true);\n setError(null);\n setData(null);\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const payload = overrideBody ? JSON.stringify(overrideBody) : bodyJson;\n\n return fetch(urlSuffix, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: payload,\n signal: abortController.signal,\n })\n .then(async (res) => {\n if (!res.ok) {\n const errorBody = await res.json().catch(() => null);\n throw new Error(errorBody?.error || `HTTP ${res.status}`);\n }\n return res.json();\n })\n .then((result: TResponse) => {\n if (abortController.signal.aborted) return null;\n setData(result);\n setLoading(false);\n return result;\n })\n .catch((err: Error) => {\n if (abortController.signal.aborted) return null;\n setError(err.message || \"Request failed\");\n setLoading(false);\n return null;\n });\n },\n [urlSuffix, bodyJson, aliasError],\n );\n\n useEffect(() => {\n if (autoStart) {\n invoke();\n }\n\n return () => {\n abortControllerRef.current?.abort();\n };\n }, [invoke, autoStart]);\n\n return { invoke, data, loading, error };\n}\n"],"mappings":";;;;;;;;;;;AAuCA,SAAgB,iBACd,MACA,UAAsC,EAAE,EACiC;CAEzE,MAAM,EAAE,OAAO,YAAY,UAAU;CAErC,MAAM,SAAS,sBAA2C,UAAU;CAEpE,MAAM,aAAa,cAAc;AAC/B,MAAI,CAAC,SAAS,CAAC,OAAO,QAAS,QAAO;EACtC,MAAM,WAAW,OAAO,MAAM;AAC9B,MAAI,CAAC,OAAO,QAAQ,SAAS,SAAS,CACpC,QAAO,0BAA0B,SAAS,gBAAgB,OAAO,QAAQ,KAAK,KAAK;AAErF,SAAO;IACN,CAAC,OAAO,OAAO,QAAQ,CAAC;CAE3B,MAAM,CAAC,MAAM,WAAW,SAA2B,KAAK;CACxD,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,CAAC,OAAO,YAAY,SAAwB,WAAW;CAC7D,MAAM,qBAAqB,OAA+B,KAAK;CAE/D,MAAM,YAAY,QACd,gBAAgB,mBAAmB,OAAO,MAAM,CAAC,CAAC,WAClD;CAEJ,MAAM,WAAW,KAAK,UAAU,KAAK;CAErC,MAAM,SAAS,aACZ,iBAAqE;AACpE,MAAI,YAAY;AACd,YAAS,WAAW;AACpB,UAAO,QAAQ,QAAQ,KAAK;;AAG9B,MAAI,mBAAmB,QACrB,oBAAmB,QAAQ,OAAO;AAGpC,aAAW,KAAK;AAChB,WAAS,KAAK;AACd,UAAQ,KAAK;EAEb,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,qBAAmB,UAAU;EAE7B,MAAM,UAAU,eAAe,KAAK,UAAU,aAAa,GAAG;AAE9D,SAAO,MAAM,WAAW;GACtB,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAC/C,MAAM;GACN,QAAQ,gBAAgB;GACzB,CAAC,CACC,KAAK,OAAO,QAAQ;AACnB,OAAI,CAAC,IAAI,IAAI;IACX,MAAM,YAAY,MAAM,IAAI,MAAM,CAAC,YAAY,KAAK;AACpD,UAAM,IAAI,MAAM,WAAW,SAAS,QAAQ,IAAI,SAAS;;AAE3D,UAAO,IAAI,MAAM;IACjB,CACD,MAAM,WAAsB;AAC3B,OAAI,gBAAgB,OAAO,QAAS,QAAO;AAC3C,WAAQ,OAAO;AACf,cAAW,MAAM;AACjB,UAAO;IACP,CACD,OAAO,QAAe;AACrB,OAAI,gBAAgB,OAAO,QAAS,QAAO;AAC3C,YAAS,IAAI,WAAW,iBAAiB;AACzC,cAAW,MAAM;AACjB,UAAO;IACP;IAEN;EAAC;EAAW;EAAU;EAAW,CAClC;AAED,iBAAgB;AACd,MAAI,UACF,SAAQ;AAGV,eAAa;AACX,sBAAmB,SAAS,OAAO;;IAEpC,CAAC,QAAQ,UAAU,CAAC;AAEvB,QAAO;EAAE;EAAQ;EAAM;EAAS;EAAO"}
@@ -0,0 +1,35 @@
1
+ import { InferServingChunk, InferServingRequest, ServingAlias } from "./types.js";
2
+
3
+ //#region src/react/hooks/use-serving-stream.d.ts
4
+ interface UseServingStreamOptions<K extends ServingAlias = ServingAlias, T = InferServingChunk<K>> {
5
+ /** Endpoint alias for named mode. Omit for default mode. */
6
+ alias?: K;
7
+ /** If true, starts streaming automatically on mount. Default: false */
8
+ autoStart?: boolean;
9
+ /** Called with accumulated chunks when the stream completes successfully. */
10
+ onComplete?: (chunks: T[]) => void;
11
+ }
12
+ interface UseServingStreamResult<T = unknown, TBody = Record<string, unknown>> {
13
+ /** Trigger the streaming invocation. Pass an optional body override for this invocation. */
14
+ stream: (overrideBody?: TBody) => void;
15
+ /** Accumulated chunks received so far. */
16
+ chunks: T[];
17
+ /** Whether streaming is in progress. */
18
+ streaming: boolean;
19
+ /** Error message, if any. */
20
+ error: string | null;
21
+ /** Reset chunks and abort any active stream. */
22
+ reset: () => void;
23
+ }
24
+ /**
25
+ * Hook for streaming invocation of a serving endpoint via SSE.
26
+ * Calls `POST /api/serving/stream` (default) or `POST /api/serving/{alias}/stream` (named).
27
+ * Accumulates parsed chunks in state.
28
+ *
29
+ * When the type generator has populated `ServingEndpointRegistry`, the chunk type
30
+ * is automatically inferred from the endpoint's OpenAPI schema.
31
+ */
32
+ declare function useServingStream<K extends ServingAlias = ServingAlias>(body: InferServingRequest<K>, options?: UseServingStreamOptions<K>): UseServingStreamResult<InferServingChunk<K>, InferServingRequest<K>>;
33
+ //#endregion
34
+ export { UseServingStreamOptions, UseServingStreamResult, useServingStream };
35
+ //# sourceMappingURL=use-serving-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-serving-stream.d.ts","names":[],"sources":["../../../src/react/hooks/use-serving-stream.ts"],"mappings":";;;UAUiB,uBAAA,WACL,YAAA,GAAe,YAAA,MACrB,iBAAA,CAAkB,CAAA;;EAGtB,KAAA,GAAQ,CAAA;EAL8B;EAOtC,SAAA;EANU;EAQV,UAAA,IAAc,MAAA,EAAQ,CAAA;AAAA;AAAA,UAGP,sBAAA,sBAEP,MAAA;EATA;EAYR,MAAA,GAAS,YAAA,GAAe,KAAA;EARD;EAUvB,MAAA,EAAQ,CAAA;EAlBR;EAoBA,SAAA;EApByB;EAsBzB,KAAA;EArBI;EAuBJ,KAAA;AAAA;;;;;;;;AAbF;iBAwBgB,gBAAA,WAA2B,YAAA,GAAe,YAAA,CAAA,CACxD,IAAA,EAAM,mBAAA,CAAoB,CAAA,GAC1B,OAAA,GAAS,uBAAA,CAAwB,CAAA,IAChC,sBAAA,CAAuB,iBAAA,CAAkB,CAAA,GAAI,mBAAA,CAAoB,CAAA"}
@@ -0,0 +1,101 @@
1
+ import { connectSSE } from "../../js/sse/connect-sse.js";
2
+ import "../../js/index.js";
3
+ import { usePluginClientConfig } from "./use-plugin-config.js";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
+
6
+ //#region src/react/hooks/use-serving-stream.ts
7
+ /**
8
+ * Hook for streaming invocation of a serving endpoint via SSE.
9
+ * Calls `POST /api/serving/stream` (default) or `POST /api/serving/{alias}/stream` (named).
10
+ * Accumulates parsed chunks in state.
11
+ *
12
+ * When the type generator has populated `ServingEndpointRegistry`, the chunk type
13
+ * is automatically inferred from the endpoint's OpenAPI schema.
14
+ */
15
+ function useServingStream(body, options = {}) {
16
+ const { alias, autoStart = false, onComplete } = options;
17
+ const config = usePluginClientConfig("serving");
18
+ const aliasError = useMemo(() => {
19
+ if (!alias || !config.aliases) return null;
20
+ const aliasStr = String(alias);
21
+ if (!config.aliases.includes(aliasStr)) return `Unknown serving alias "${aliasStr}". Available: ${config.aliases.join(", ")}`;
22
+ return null;
23
+ }, [alias, config.aliases]);
24
+ const [chunks, setChunks] = useState([]);
25
+ const [streaming, setStreaming] = useState(false);
26
+ const [error, setError] = useState(aliasError);
27
+ const abortControllerRef = useRef(null);
28
+ const chunksRef = useRef([]);
29
+ const onCompleteRef = useRef(onComplete);
30
+ onCompleteRef.current = onComplete;
31
+ const urlSuffix = alias ? `/api/serving/${encodeURIComponent(String(alias))}/stream` : "/api/serving/stream";
32
+ const reset = useCallback(() => {
33
+ abortControllerRef.current?.abort();
34
+ abortControllerRef.current = null;
35
+ chunksRef.current = [];
36
+ setChunks([]);
37
+ setStreaming(false);
38
+ setError(null);
39
+ }, []);
40
+ const bodyJson = JSON.stringify(body);
41
+ const stream = useCallback((overrideBody) => {
42
+ if (aliasError) {
43
+ setError(aliasError);
44
+ return;
45
+ }
46
+ abortControllerRef.current?.abort();
47
+ setStreaming(true);
48
+ setError(null);
49
+ setChunks([]);
50
+ chunksRef.current = [];
51
+ const abortController = new AbortController();
52
+ abortControllerRef.current = abortController;
53
+ connectSSE({
54
+ url: urlSuffix,
55
+ payload: overrideBody ? JSON.stringify(overrideBody) : bodyJson,
56
+ signal: abortController.signal,
57
+ onMessage: async (message) => {
58
+ if (abortController.signal.aborted) return;
59
+ try {
60
+ const parsed = JSON.parse(message.data);
61
+ chunksRef.current = [...chunksRef.current, parsed];
62
+ setChunks(chunksRef.current);
63
+ } catch {}
64
+ },
65
+ onError: (err) => {
66
+ if (abortController.signal.aborted) return;
67
+ setStreaming(false);
68
+ setError(err instanceof Error ? err.message : "Streaming failed");
69
+ }
70
+ }).then(() => {
71
+ if (abortController.signal.aborted) return;
72
+ setStreaming(false);
73
+ onCompleteRef.current?.(chunksRef.current);
74
+ }).catch(() => {
75
+ if (abortController.signal.aborted) return;
76
+ setStreaming(false);
77
+ setError("Connection error");
78
+ });
79
+ }, [
80
+ urlSuffix,
81
+ bodyJson,
82
+ aliasError
83
+ ]);
84
+ useEffect(() => {
85
+ if (autoStart) stream();
86
+ return () => {
87
+ abortControllerRef.current?.abort();
88
+ };
89
+ }, [stream, autoStart]);
90
+ return {
91
+ stream,
92
+ chunks,
93
+ streaming,
94
+ error,
95
+ reset
96
+ };
97
+ }
98
+
99
+ //#endregion
100
+ export { useServingStream };
101
+ //# sourceMappingURL=use-serving-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-serving-stream.js","names":[],"sources":["../../../src/react/hooks/use-serving-stream.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { connectSSE } from \"@/js\";\nimport type {\n InferServingChunk,\n InferServingRequest,\n ServingAlias,\n ServingClientConfig,\n} from \"./types\";\nimport { usePluginClientConfig } from \"./use-plugin-config\";\n\nexport interface UseServingStreamOptions<\n K extends ServingAlias = ServingAlias,\n T = InferServingChunk<K>,\n> {\n /** Endpoint alias for named mode. Omit for default mode. */\n alias?: K;\n /** If true, starts streaming automatically on mount. Default: false */\n autoStart?: boolean;\n /** Called with accumulated chunks when the stream completes successfully. */\n onComplete?: (chunks: T[]) => void;\n}\n\nexport interface UseServingStreamResult<\n T = unknown,\n TBody = Record<string, unknown>,\n> {\n /** Trigger the streaming invocation. Pass an optional body override for this invocation. */\n stream: (overrideBody?: TBody) => void;\n /** Accumulated chunks received so far. */\n chunks: T[];\n /** Whether streaming is in progress. */\n streaming: boolean;\n /** Error message, if any. */\n error: string | null;\n /** Reset chunks and abort any active stream. */\n reset: () => void;\n}\n\n/**\n * Hook for streaming invocation of a serving endpoint via SSE.\n * Calls `POST /api/serving/stream` (default) or `POST /api/serving/{alias}/stream` (named).\n * Accumulates parsed chunks in state.\n *\n * When the type generator has populated `ServingEndpointRegistry`, the chunk type\n * is automatically inferred from the endpoint's OpenAPI schema.\n */\nexport function useServingStream<K extends ServingAlias = ServingAlias>(\n body: InferServingRequest<K>,\n options: UseServingStreamOptions<K> = {} as UseServingStreamOptions<K>,\n): UseServingStreamResult<InferServingChunk<K>, InferServingRequest<K>> {\n type TChunk = InferServingChunk<K>;\n const { alias, autoStart = false, onComplete } = options;\n\n const config = usePluginClientConfig<ServingClientConfig>(\"serving\");\n\n const aliasError = useMemo(() => {\n if (!alias || !config.aliases) return null;\n const aliasStr = String(alias);\n if (!config.aliases.includes(aliasStr)) {\n return `Unknown serving alias \"${aliasStr}\". Available: ${config.aliases.join(\", \")}`;\n }\n return null;\n }, [alias, config.aliases]);\n\n const [chunks, setChunks] = useState<TChunk[]>([]);\n const [streaming, setStreaming] = useState(false);\n const [error, setError] = useState<string | null>(aliasError);\n const abortControllerRef = useRef<AbortController | null>(null);\n const chunksRef = useRef<TChunk[]>([]);\n const onCompleteRef = useRef(onComplete);\n onCompleteRef.current = onComplete;\n\n const urlSuffix = alias\n ? `/api/serving/${encodeURIComponent(String(alias))}/stream`\n : \"/api/serving/stream\";\n\n const reset = useCallback(() => {\n abortControllerRef.current?.abort();\n abortControllerRef.current = null;\n chunksRef.current = [];\n setChunks([]);\n setStreaming(false);\n setError(null);\n }, []);\n\n const bodyJson = JSON.stringify(body);\n\n const stream = useCallback(\n (overrideBody?: InferServingRequest<K>) => {\n if (aliasError) {\n setError(aliasError);\n return;\n }\n\n // Abort any existing stream\n abortControllerRef.current?.abort();\n\n setStreaming(true);\n setError(null);\n setChunks([]);\n chunksRef.current = [];\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const payload = overrideBody ? JSON.stringify(overrideBody) : bodyJson;\n\n connectSSE({\n url: urlSuffix,\n payload,\n signal: abortController.signal,\n onMessage: async (message) => {\n if (abortController.signal.aborted) return;\n try {\n const parsed = JSON.parse(message.data);\n\n chunksRef.current = [...chunksRef.current, parsed as TChunk];\n setChunks(chunksRef.current);\n } catch {\n // Skip malformed messages\n }\n },\n onError: (err) => {\n if (abortController.signal.aborted) return;\n setStreaming(false);\n setError(err instanceof Error ? err.message : \"Streaming failed\");\n },\n })\n .then(() => {\n if (abortController.signal.aborted) return;\n // Stream completed\n setStreaming(false);\n onCompleteRef.current?.(chunksRef.current);\n })\n .catch(() => {\n if (abortController.signal.aborted) return;\n setStreaming(false);\n setError(\"Connection error\");\n });\n },\n [urlSuffix, bodyJson, aliasError],\n );\n\n useEffect(() => {\n if (autoStart) {\n stream();\n }\n\n return () => {\n abortControllerRef.current?.abort();\n };\n }, [stream, autoStart]);\n\n return { stream, chunks, streaming, error, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgB,iBACd,MACA,UAAsC,EAAE,EAC8B;CAEtE,MAAM,EAAE,OAAO,YAAY,OAAO,eAAe;CAEjD,MAAM,SAAS,sBAA2C,UAAU;CAEpE,MAAM,aAAa,cAAc;AAC/B,MAAI,CAAC,SAAS,CAAC,OAAO,QAAS,QAAO;EACtC,MAAM,WAAW,OAAO,MAAM;AAC9B,MAAI,CAAC,OAAO,QAAQ,SAAS,SAAS,CACpC,QAAO,0BAA0B,SAAS,gBAAgB,OAAO,QAAQ,KAAK,KAAK;AAErF,SAAO;IACN,CAAC,OAAO,OAAO,QAAQ,CAAC;CAE3B,MAAM,CAAC,QAAQ,aAAa,SAAmB,EAAE,CAAC;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,OAAO,YAAY,SAAwB,WAAW;CAC7D,MAAM,qBAAqB,OAA+B,KAAK;CAC/D,MAAM,YAAY,OAAiB,EAAE,CAAC;CACtC,MAAM,gBAAgB,OAAO,WAAW;AACxC,eAAc,UAAU;CAExB,MAAM,YAAY,QACd,gBAAgB,mBAAmB,OAAO,MAAM,CAAC,CAAC,WAClD;CAEJ,MAAM,QAAQ,kBAAkB;AAC9B,qBAAmB,SAAS,OAAO;AACnC,qBAAmB,UAAU;AAC7B,YAAU,UAAU,EAAE;AACtB,YAAU,EAAE,CAAC;AACb,eAAa,MAAM;AACnB,WAAS,KAAK;IACb,EAAE,CAAC;CAEN,MAAM,WAAW,KAAK,UAAU,KAAK;CAErC,MAAM,SAAS,aACZ,iBAA0C;AACzC,MAAI,YAAY;AACd,YAAS,WAAW;AACpB;;AAIF,qBAAmB,SAAS,OAAO;AAEnC,eAAa,KAAK;AAClB,WAAS,KAAK;AACd,YAAU,EAAE,CAAC;AACb,YAAU,UAAU,EAAE;EAEtB,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,qBAAmB,UAAU;AAI7B,aAAW;GACT,KAAK;GACL,SAJc,eAAe,KAAK,UAAU,aAAa,GAAG;GAK5D,QAAQ,gBAAgB;GACxB,WAAW,OAAO,YAAY;AAC5B,QAAI,gBAAgB,OAAO,QAAS;AACpC,QAAI;KACF,MAAM,SAAS,KAAK,MAAM,QAAQ,KAAK;AAEvC,eAAU,UAAU,CAAC,GAAG,UAAU,SAAS,OAAiB;AAC5D,eAAU,UAAU,QAAQ;YACtB;;GAIV,UAAU,QAAQ;AAChB,QAAI,gBAAgB,OAAO,QAAS;AACpC,iBAAa,MAAM;AACnB,aAAS,eAAe,QAAQ,IAAI,UAAU,mBAAmB;;GAEpE,CAAC,CACC,WAAW;AACV,OAAI,gBAAgB,OAAO,QAAS;AAEpC,gBAAa,MAAM;AACnB,iBAAc,UAAU,UAAU,QAAQ;IAC1C,CACD,YAAY;AACX,OAAI,gBAAgB,OAAO,QAAS;AACpC,gBAAa,MAAM;AACnB,YAAS,mBAAmB;IAC5B;IAEN;EAAC;EAAW;EAAU;EAAW,CAClC;AAED,iBAAgB;AACd,MAAI,UACF,SAAQ;AAGV,eAAa;AACX,sBAAmB,SAAS,OAAO;;IAEpC,CAAC,QAAQ,UAAU,CAAC;AAEvB,QAAO;EAAE;EAAQ;EAAQ;EAAW;EAAO;EAAO"}
@@ -36,9 +36,11 @@ import { GenieChatMessageList } from "./genie/genie-chat-message-list.js";
36
36
  import { GenieQueryVisualization } from "./genie/genie-query-visualization.js";
37
37
  import { useGenieChat } from "./genie/use-genie-chat.js";
38
38
  import "./genie/index.js";
39
- import { AnalyticsFormat, InferResultByFormat, InferRowType, PluginRegistry, QueryRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult } from "./hooks/types.js";
39
+ import { AnalyticsFormat, InferResultByFormat, InferRowType, InferServingChunk, InferServingRequest, InferServingResponse, PluginRegistry, QueryRegistry, ServingAlias, ServingEndpointRegistry, TypedArrowTable, UseAnalyticsQueryOptions, UseAnalyticsQueryResult } from "./hooks/types.js";
40
40
  import { useAnalyticsQuery } from "./hooks/use-analytics-query.js";
41
41
  import { usePluginClientConfig } from "./hooks/use-plugin-config.js";
42
+ import { UseServingInvokeOptions, UseServingInvokeResult, useServingInvoke } from "./hooks/use-serving-invoke.js";
43
+ import { UseServingStreamOptions, UseServingStreamResult, useServingStream } from "./hooks/use-serving-stream.js";
42
44
  import "./hooks/index.js";
43
45
  import { cn } from "./lib/utils.js";
44
46
  import { PortalContainerContext, PortalContainerProvider, usePortalContainer, useResolvedPortalContainer } from "./portal-container-context.js";
@@ -98,4 +100,4 @@ import { Textarea } from "./ui/textarea.js";
98
100
  import { Toggle, toggleVariants } from "./ui/toggle.js";
99
101
  import { ToggleGroup, ToggleGroupItem } from "./ui/toggle-group.js";
100
102
  import "./ui/index.js";
101
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnalyticsFormat, AreaChart, AreaChartProps, AreaChartSpecificProps, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BarChart, BarChartProps, BarChartSpecificProps, BaseChart, BaseChartProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHART_COLOR_VARS, CHART_COLOR_VARS_CATEGORICAL, CHART_COLOR_VARS_DIVERGING, CHART_COLOR_VARS_SEQUENTIAL, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CartesianContext, ChartBaseProps, ChartColorPalette, ChartConfig, ChartContainer, ChartData, ChartInference, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, ChartType, ChartWrapper, ChartWrapperProps, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColumnCategory, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DATE_FIELD_PATTERNS, DataFormat, DataProps, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectoryEntry, DirectoryList, DirectoryListProps, DonutChart, DonutChartProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FALLBACK_COLORS_CATEGORICAL, FALLBACK_COLORS_DIVERGING, FALLBACK_COLORS_SEQUENTIAL, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileBreadcrumb, FileBreadcrumbProps, FileBrowserLabels, FileEntry, FileEntryProps, FilePreview, FilePreviewPanel, FilePreviewPanelProps, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GenieAttachmentResponse, GenieChat, GenieChatInput, GenieChatMessage, GenieChatMessageList, GenieChatProps, GenieChatStatus, GenieColumnMeta, GenieMessageItem, GenieMessageResponse, GenieQueryVisualization, GenieStatementResponse, GenieStreamEvent, HeatmapChart, HeatmapChartProps, HeatmapChartSpecificProps, HeatmapContext, HoverCard, HoverCardContent, HoverCardTrigger, InferResultByFormat, InferRowType, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, LineChart, LineChartProps, LineChartSpecificProps, METADATA_DATE_PATTERNS, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NAME_FIELD_PATTERNS, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NewFolderInput, NewFolderInputProps, NormalizedChartData, NormalizedChartDataBase, NormalizedHeatmapData, OptionBuilderContext, Orientation, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PieChart, PieChartProps, PieChartSpecificProps, PluginRegistry, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalContainerContext, PortalContainerProvider, Progress, QueryProps, QueryRegistry, RadarChart, RadarChartProps, RadarChartSpecificProps, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScatterChart, ScatterChartProps, ScatterChartSpecificProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, TERMINAL_STATUSES, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TransformedGenieData, TypedArrowTable, UnifiedChartProps, UseAnalyticsQueryOptions, UseAnalyticsQueryResult, UseChartDataOptions, UseChartDataResult, UseGenieChatOptions, UseGenieChatReturn, badgeVariants, buildCartesianOption, buildHeatmapOption, buildHorizontalBarOption, buildPieOption, buildRadarOption, buttonGroupVariants, buttonVariants, cn, createChart, createTimeSeriesData, formatFileSize, formatLabel, getCompatibleChartTypes, inferChartType, isArrowTable, isDataProps, isQueryProps, navigationMenuTriggerStyle, normalizeChartData, normalizeHeatmapData, sortTimeSeriesAscending, toChartArray, toChartValue, toggleVariants, transformGenieData, truncateLabel, useAllThemeColors, useAnalyticsQuery, useChartData, useFormField, useGenieChat, usePluginClientConfig, usePortalContainer, useResolvedPortalContainer, useSidebar, useThemeColors };
103
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnalyticsFormat, AreaChart, AreaChartProps, AreaChartSpecificProps, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BarChart, BarChartProps, BarChartSpecificProps, BaseChart, BaseChartProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHART_COLOR_VARS, CHART_COLOR_VARS_CATEGORICAL, CHART_COLOR_VARS_DIVERGING, CHART_COLOR_VARS_SEQUENTIAL, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, CartesianContext, ChartBaseProps, ChartColorPalette, ChartConfig, ChartContainer, ChartData, ChartInference, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, ChartType, ChartWrapper, ChartWrapperProps, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColumnCategory, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DATE_FIELD_PATTERNS, DataFormat, DataProps, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectoryEntry, DirectoryList, DirectoryListProps, DonutChart, DonutChartProps, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FALLBACK_COLORS_CATEGORICAL, FALLBACK_COLORS_DIVERGING, FALLBACK_COLORS_SEQUENTIAL, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileBreadcrumb, FileBreadcrumbProps, FileBrowserLabels, FileEntry, FileEntryProps, FilePreview, FilePreviewPanel, FilePreviewPanelProps, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GenieAttachmentResponse, GenieChat, GenieChatInput, GenieChatMessage, GenieChatMessageList, GenieChatProps, GenieChatStatus, GenieColumnMeta, GenieMessageItem, GenieMessageResponse, GenieQueryVisualization, GenieStatementResponse, GenieStreamEvent, HeatmapChart, HeatmapChartProps, HeatmapChartSpecificProps, HeatmapContext, HoverCard, HoverCardContent, HoverCardTrigger, InferResultByFormat, InferRowType, InferServingChunk, InferServingRequest, InferServingResponse, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, LineChart, LineChartProps, LineChartSpecificProps, METADATA_DATE_PATTERNS, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NAME_FIELD_PATTERNS, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NewFolderInput, NewFolderInputProps, NormalizedChartData, NormalizedChartDataBase, NormalizedHeatmapData, OptionBuilderContext, Orientation, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PieChart, PieChartProps, PieChartSpecificProps, PluginRegistry, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalContainerContext, PortalContainerProvider, Progress, QueryProps, QueryRegistry, RadarChart, RadarChartProps, RadarChartSpecificProps, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScatterChart, ScatterChartProps, ScatterChartSpecificProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, ServingAlias, ServingEndpointRegistry, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, TERMINAL_STATUSES, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TransformedGenieData, TypedArrowTable, UnifiedChartProps, UseAnalyticsQueryOptions, UseAnalyticsQueryResult, UseChartDataOptions, UseChartDataResult, UseGenieChatOptions, UseGenieChatReturn, UseServingInvokeOptions, UseServingInvokeResult, UseServingStreamOptions, UseServingStreamResult, badgeVariants, buildCartesianOption, buildHeatmapOption, buildHorizontalBarOption, buildPieOption, buildRadarOption, buttonGroupVariants, buttonVariants, cn, createChart, createTimeSeriesData, formatFileSize, formatLabel, getCompatibleChartTypes, inferChartType, isArrowTable, isDataProps, isQueryProps, navigationMenuTriggerStyle, normalizeChartData, normalizeHeatmapData, sortTimeSeriesAscending, toChartArray, toChartValue, toggleVariants, transformGenieData, truncateLabel, useAllThemeColors, useAnalyticsQuery, useChartData, useFormField, useGenieChat, usePluginClientConfig, usePortalContainer, useResolvedPortalContainer, useServingInvoke, useServingStream, useSidebar, useThemeColors };
@@ -47,6 +47,8 @@ import { useGenieChat } from "./genie/use-genie-chat.js";
47
47
  import { GenieChat } from "./genie/genie-chat.js";
48
48
  import "./genie/index.js";
49
49
  import { usePluginClientConfig } from "./hooks/use-plugin-config.js";
50
+ import { useServingInvoke } from "./hooks/use-serving-invoke.js";
51
+ import { useServingStream } from "./hooks/use-serving-stream.js";
50
52
  import "./hooks/index.js";
51
53
  import { Input } from "./ui/input.js";
52
54
  import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "./ui/select.js";
@@ -95,4 +97,4 @@ import { Toggle, toggleVariants } from "./ui/toggle.js";
95
97
  import { ToggleGroup, ToggleGroupItem } from "./ui/toggle-group.js";
96
98
  import "./ui/index.js";
97
99
 
98
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AreaChart, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BarChart, BaseChart, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHART_COLOR_VARS, CHART_COLOR_VARS_CATEGORICAL, CHART_COLOR_VARS_DIVERGING, CHART_COLOR_VARS_SEQUENTIAL, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, ChartWrapper, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DATE_FIELD_PATTERNS, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectoryList, DonutChart, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FALLBACK_COLORS_CATEGORICAL, FALLBACK_COLORS_DIVERGING, FALLBACK_COLORS_SEQUENTIAL, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileBreadcrumb, FileEntry, FilePreviewPanel, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GenieChat, GenieChatInput, GenieChatMessage, GenieChatMessageList, GenieQueryVisualization, HeatmapChart, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, LineChart, METADATA_DATE_PATTERNS, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NAME_FIELD_PATTERNS, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NewFolderInput, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PieChart, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalContainerContext, PortalContainerProvider, Progress, RadarChart, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScatterChart, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buildCartesianOption, buildHeatmapOption, buildHorizontalBarOption, buildPieOption, buildRadarOption, buttonGroupVariants, buttonVariants, cn, createChart, createTimeSeriesData, formatFileSize, formatLabel, getCompatibleChartTypes, inferChartType, isArrowTable, isDataProps, isQueryProps, navigationMenuTriggerStyle, normalizeChartData, normalizeHeatmapData, sortTimeSeriesAscending, toChartArray, toChartValue, toggleVariants, transformGenieData, truncateLabel, useAllThemeColors, useAnalyticsQuery, useChartData, useFormField, useGenieChat, usePluginClientConfig, usePortalContainer, useResolvedPortalContainer, useSidebar, useThemeColors };
100
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AreaChart, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, BarChart, BaseChart, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CHART_COLOR_VARS, CHART_COLOR_VARS_CATEGORICAL, CHART_COLOR_VARS_DIVERGING, CHART_COLOR_VARS_SEQUENTIAL, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, ChartWrapper, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DATE_FIELD_PATTERNS, DataTable, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectoryList, DonutChart, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FALLBACK_COLORS_CATEGORICAL, FALLBACK_COLORS_DIVERGING, FALLBACK_COLORS_SEQUENTIAL, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, FileBreadcrumb, FileEntry, FilePreviewPanel, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GenieChat, GenieChatInput, GenieChatMessage, GenieChatMessageList, GenieQueryVisualization, HeatmapChart, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, LineChart, METADATA_DATE_PATTERNS, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NAME_FIELD_PATTERNS, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NewFolderInput, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PieChart, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PortalContainerContext, PortalContainerProvider, Progress, RadarChart, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScatterChart, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buildCartesianOption, buildHeatmapOption, buildHorizontalBarOption, buildPieOption, buildRadarOption, buttonGroupVariants, buttonVariants, cn, createChart, createTimeSeriesData, formatFileSize, formatLabel, getCompatibleChartTypes, inferChartType, isArrowTable, isDataProps, isQueryProps, navigationMenuTriggerStyle, normalizeChartData, normalizeHeatmapData, sortTimeSeriesAscending, toChartArray, toChartValue, toggleVariants, transformGenieData, truncateLabel, useAllThemeColors, useAnalyticsQuery, useChartData, useFormField, useGenieChat, usePluginClientConfig, usePortalContainer, useResolvedPortalContainer, useServingInvoke, useServingStream, useSidebar, useThemeColors };
@@ -319,13 +319,18 @@ BasePlugin.clientConfig
319
319
  protected execute<T>(
320
320
  fn: (signal?: AbortSignal) => Promise<T>,
321
321
  options: PluginExecutionSettings,
322
- userKey?: string): Promise<T | undefined>;
322
+ userKey?: string): Promise<ExecutionResult<T>>;
323
323
 
324
324
  ```
325
325
 
326
326
  Execute a function with the plugin's interceptor chain.
327
327
 
328
- All errors are caught and `undefined` is returned (production-safe). Route handlers should check for `undefined` and respond with an appropriate error status.
328
+ Returns an [ExecutionResult](./docs/api/appkit/TypeAlias.ExecutionResult.md) discriminated union:
329
+
330
+ * `{ ok: true, data: T }` on success
331
+ * `{ ok: false, status: number, message: string }` on failure
332
+
333
+ Errors are never thrown — the method is production-safe.
329
334
 
330
335
  #### Type Parameters[​](#type-parameters-1 "Direct link to Type Parameters")
331
336
 
@@ -343,7 +348,7 @@ All errors are caught and `undefined` is returned (production-safe). Route handl
343
348
 
344
349
  #### Returns[​](#returns-4 "Direct link to Returns")
345
350
 
346
- `Promise`<`T` | `undefined`>
351
+ `Promise`<[`ExecutionResult`](./docs/api/appkit/TypeAlias.ExecutionResult.md)<`T`>>
347
352
 
348
353
  ***
349
354