@gram-ai/elements 1.18.3 → 1.18.5

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.
@@ -3,7 +3,8 @@ import { GetSessionFn } from '../types';
3
3
  * Hook to fetch or retrieve the session token for the chat.
4
4
  * @returns The session token string or null
5
5
  */
6
- export declare const useSession: ({ getSession, projectSlug, }: {
6
+ export declare const useSession: ({ getSession, projectSlug, enabled, }: {
7
7
  getSession: GetSessionFn | null;
8
8
  projectSlug: string;
9
+ enabled: boolean;
9
10
  }) => string | null;
@@ -0,0 +1,2 @@
1
+ import { ElementsConfig } from '../types';
2
+ export declare function getApiUrl(config: ElementsConfig): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { ApiKeyAuthConfig, AuthConfig } from '../types';
2
+ /**
3
+ * Checks if the auth config is an API key auth config
4
+ */
5
+ export declare function isApiKeyAuth(auth: AuthConfig | undefined): auth is ApiKeyAuthConfig;
@@ -243,7 +243,7 @@ export interface ElementsConfig {
243
243
  url?: string;
244
244
  } & AuthConfig;
245
245
  }
246
- export type AuthConfig = {
246
+ export type SessionAuthConfig = {
247
247
  /**
248
248
  * The function to use to retrieve the session token from the backend endpoint.
249
249
  * By default, this will attempt to fetch the session token from `/chat/session`.
@@ -257,8 +257,23 @@ export type AuthConfig = {
257
257
  * },
258
258
  * }
259
259
  */
260
- sessionFn?: GetSessionFn;
261
- } | {
260
+ sessionFn: GetSessionFn;
261
+ };
262
+ /**
263
+ * The API key auth config is used to authenticate the Elements library using an API key only.
264
+ *
265
+ * NOTE: This is not recommended for production use, and a warning
266
+ * will be displayed in the chat interface if you use this config.
267
+ * Define a session endpoint instead to avoid this warning.
268
+ *
269
+ * @example
270
+ * const config: ElementsConfig = {
271
+ * api: {
272
+ * UNSAFE_apiKey: 'your-api-key',
273
+ * },
274
+ * }
275
+ */
276
+ export type ApiKeyAuthConfig = {
262
277
  /**
263
278
  * The API key to use if you haven't yet configured a session endpoint.
264
279
  * Do not use this in production.
@@ -272,6 +287,7 @@ export type AuthConfig = {
272
287
  */
273
288
  UNSAFE_apiKey: string;
274
289
  };
290
+ export type AuthConfig = SessionAuthConfig | ApiKeyAuthConfig | undefined;
275
291
  /**
276
292
  * The LLM model to use for the Elements library.
277
293
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gram-ai/elements",
3
3
  "description": "Gram Elements is a library of UI primitives for building chat-like experiences for MCP Servers.",
4
4
  "type": "module",
5
- "version": "1.18.3",
5
+ "version": "1.18.5",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
8
8
  ".": {
@@ -134,10 +134,13 @@
134
134
  "typescript-eslint": "^8.48.1",
135
135
  "vite": "^7.1.6",
136
136
  "vite-plugin-dts": "^4.5.4",
137
+ "vitest": "^4.0.13",
137
138
  "zustand": "^5.0.8"
138
139
  },
139
140
  "scripts": {
140
141
  "build": "vite build",
142
+ "test": "vitest run",
143
+ "test:watch": "vitest",
141
144
  "lint": "eslint src",
142
145
  "analyze": "pnpm dlx vite-bundle-visualizer",
143
146
  "storybook": "storybook dev -p 6006",