@boldvideo/bold-js 1.13.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @boldvideo/bold-js
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d7e0675: Add `bold.ai.getConversation(conversationId)` method to fetch conversation history by ID. Returns the full conversation including messages, metadata, and timestamps.
8
+
9
+ ## 1.14.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4bfba45: Add Portal analytics and custom redirects support
14
+
15
+ - Add `analyticsProvider` and `analyticsId` fields to Portal type for Plausible, GA4, and Fathom integrations
16
+ - Add `customRedirects` field to Portal type for custom redirect configuration
17
+ - Export new types: `AnalyticsProvider`, `CustomRedirect`
18
+
3
19
  ## 1.13.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -220,6 +220,19 @@ const stream = await bold.ai.chat({
220
220
  });
221
221
  ```
222
222
 
223
+ ### Get Conversation History
224
+
225
+ Retrieve a conversation by ID to display message history:
226
+
227
+ ```typescript
228
+ const conversation = await bold.ai.getConversation('550e8400-e29b-41d4-a716-446655440000');
229
+
230
+ console.log(`Created: ${conversation.createdAt}`);
231
+ for (const msg of conversation.messages) {
232
+ console.log(`${msg.role}: ${msg.content}`);
233
+ }
234
+ ```
235
+
223
236
  ### Multi-turn Conversations
224
237
 
225
238
  Use the `context` parameter for follow-up questions:
@@ -279,6 +292,8 @@ import type {
279
292
  RecommendationsOptions,
280
293
  RecommendationsResponse,
281
294
  Recommendation,
295
+ Conversation,
296
+ ConversationMessage,
282
297
  Source
283
298
  } from '@boldvideo/bold-js';
284
299
  ```
package/dist/index.cjs CHANGED
@@ -321,6 +321,21 @@ async function jsonRequest(path, body, config) {
321
321
  const raw = await response.json();
322
322
  return camelizeKeys(raw);
323
323
  }
324
+ async function getRequest(path, config) {
325
+ const url = buildURL(config.baseURL, path);
326
+ const response = await fetch(url, {
327
+ method: "GET",
328
+ headers: {
329
+ "Accept": "application/json",
330
+ ...config.headers
331
+ }
332
+ });
333
+ if (!response.ok) {
334
+ throw new Error(`AI request failed: ${response.status} ${response.statusText}`);
335
+ }
336
+ const raw = await response.json();
337
+ return camelizeKeys(raw);
338
+ }
324
339
  function createAI(config) {
325
340
  async function chat(options) {
326
341
  const isVideoScoped = !!options.videoId;
@@ -387,13 +402,20 @@ function createAI(config) {
387
402
  async function recommend(options) {
388
403
  return recommendations(options);
389
404
  }
405
+ async function getConversation(conversationId) {
406
+ if (!conversationId) {
407
+ throw new Error("conversationId is required");
408
+ }
409
+ return getRequest(`ai/chat/${conversationId}`, config);
410
+ }
390
411
  return {
391
412
  chat,
392
413
  ask,
393
414
  coach,
394
415
  search,
395
416
  recommendations,
396
- recommend
417
+ recommend,
418
+ getConversation
397
419
  };
398
420
  }
399
421
 
package/dist/index.d.ts CHANGED
@@ -109,6 +109,12 @@ type PortalTheme = {
109
109
  type PortalHero = {
110
110
  type: 'none' | 'custom';
111
111
  };
112
+ type CustomRedirect = {
113
+ path: string;
114
+ url: string;
115
+ permanent: boolean;
116
+ };
117
+ type AnalyticsProvider = 'plausible' | 'ga4' | 'fathom';
112
118
  type Portal = {
113
119
  colorScheme?: 'toggle' | 'light' | 'dark';
114
120
  display: PortalDisplay;
@@ -116,6 +122,9 @@ type Portal = {
116
122
  layout: PortalLayout;
117
123
  navigation: PortalNavigation;
118
124
  theme: PortalTheme;
125
+ customRedirects?: CustomRedirect[];
126
+ analyticsProvider?: AnalyticsProvider;
127
+ analyticsId?: string;
119
128
  };
120
129
  type ThemeColors = {
121
130
  accent: string;
@@ -351,6 +360,35 @@ interface RecommendationsResponse {
351
360
  * @deprecated Use RecommendationsResponse instead
352
361
  */
353
362
  type RecommendResponse = RecommendationsResponse;
363
+ /**
364
+ * A message in a conversation
365
+ */
366
+ interface ConversationMessage {
367
+ id: string;
368
+ role: 'user' | 'assistant' | 'system';
369
+ content: string;
370
+ sources: Segment[];
371
+ insertedAt: string;
372
+ }
373
+ /**
374
+ * Conversation metadata
375
+ */
376
+ interface ConversationMetadata {
377
+ originalQuery: string;
378
+ status: string;
379
+ confidence: string;
380
+ chunksFound: number;
381
+ }
382
+ /**
383
+ * Full conversation with message history
384
+ */
385
+ interface Conversation {
386
+ conversationId: string;
387
+ messages: ConversationMessage[];
388
+ metadata: ConversationMetadata;
389
+ createdAt: string;
390
+ updatedAt: string;
391
+ }
354
392
 
355
393
  /**
356
394
  * AI client interface for type-safe method overloading
@@ -452,6 +490,16 @@ interface AIClient {
452
490
  stream?: true;
453
491
  }): Promise<AsyncIterable<AIEvent>>;
454
492
  recommend(options: RecommendOptions): Promise<AsyncIterable<AIEvent> | RecommendResponse>;
493
+ /**
494
+ * Get conversation history by ID
495
+ *
496
+ * @example
497
+ * const conversation = await bold.ai.getConversation("550e8400-e29b-41d4-a716-446655440000");
498
+ * for (const msg of conversation.messages) {
499
+ * console.log(`${msg.role}: ${msg.content}`);
500
+ * }
501
+ */
502
+ getConversation(conversationId: string): Promise<Conversation>;
455
503
  }
456
504
 
457
505
  type ClientOptions = {
@@ -496,4 +544,4 @@ declare const DEFAULT_API_BASE_URL = "https://app.boldvideo.io/api/v1/";
496
544
  */
497
545
  declare const DEFAULT_INTERNAL_API_BASE_URL = "https://app.boldvideo.io/i/v1/";
498
546
 
499
- export { AIContextMessage, AIEvent, AIResponse, AIUsage, Account, AccountAI, AskOptions, AssistantConfig, ChatOptions, Citation, ClientOptions, DEFAULT_API_BASE_URL, DEFAULT_INTERNAL_API_BASE_URL, MenuItem, Playlist, Portal, PortalDisplay, PortalHero, PortalLayout, PortalNavigation, PortalTheme, RecommendOptions, RecommendResponse, Recommendation, RecommendationVideo, RecommendationsOptions, RecommendationsResponse, SearchOptions, Segment, Settings, Source, ThemeColors, ThemeConfig, Video, VideoAttachment, VideoDownloadUrls, VideoMetadata, VideoSubtitles, VideoTranscript, createClient };
547
+ export { AIContextMessage, AIEvent, AIResponse, AIUsage, Account, AccountAI, AnalyticsProvider, AskOptions, AssistantConfig, ChatOptions, Citation, ClientOptions, Conversation, ConversationMessage, ConversationMetadata, CustomRedirect, DEFAULT_API_BASE_URL, DEFAULT_INTERNAL_API_BASE_URL, MenuItem, Playlist, Portal, PortalDisplay, PortalHero, PortalLayout, PortalNavigation, PortalTheme, RecommendOptions, RecommendResponse, Recommendation, RecommendationVideo, RecommendationsOptions, RecommendationsResponse, SearchOptions, Segment, Settings, Source, ThemeColors, ThemeConfig, Video, VideoAttachment, VideoDownloadUrls, VideoMetadata, VideoSubtitles, VideoTranscript, createClient };
package/dist/index.js CHANGED
@@ -283,6 +283,21 @@ async function jsonRequest(path, body, config) {
283
283
  const raw = await response.json();
284
284
  return camelizeKeys(raw);
285
285
  }
286
+ async function getRequest(path, config) {
287
+ const url = buildURL(config.baseURL, path);
288
+ const response = await fetch(url, {
289
+ method: "GET",
290
+ headers: {
291
+ "Accept": "application/json",
292
+ ...config.headers
293
+ }
294
+ });
295
+ if (!response.ok) {
296
+ throw new Error(`AI request failed: ${response.status} ${response.statusText}`);
297
+ }
298
+ const raw = await response.json();
299
+ return camelizeKeys(raw);
300
+ }
286
301
  function createAI(config) {
287
302
  async function chat(options) {
288
303
  const isVideoScoped = !!options.videoId;
@@ -349,13 +364,20 @@ function createAI(config) {
349
364
  async function recommend(options) {
350
365
  return recommendations(options);
351
366
  }
367
+ async function getConversation(conversationId) {
368
+ if (!conversationId) {
369
+ throw new Error("conversationId is required");
370
+ }
371
+ return getRequest(`ai/chat/${conversationId}`, config);
372
+ }
352
373
  return {
353
374
  chat,
354
375
  ask,
355
376
  coach,
356
377
  search,
357
378
  recommendations,
358
- recommend
379
+ recommend,
380
+ getConversation
359
381
  };
360
382
  }
361
383
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@boldvideo/bold-js",
3
3
  "license": "MIT",
4
- "version": "1.13.0",
4
+ "version": "1.15.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",