@thoughtspot/visual-embed-sdk 1.39.2-alpha.1 → 1.39.2-spotter-agent

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 (125) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/config.spec.js +9 -0
  3. package/cjs/src/config.spec.js.map +1 -1
  4. package/cjs/src/embed/bodyless-conversation.d.ts +19 -7
  5. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  6. package/cjs/src/embed/bodyless-conversation.js +24 -4
  7. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  8. package/cjs/src/embed/bodyless-conversation.spec.js +8 -190
  9. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  10. package/cjs/src/embed/conversation.d.ts +2 -60
  11. package/cjs/src/embed/conversation.d.ts.map +1 -1
  12. package/cjs/src/embed/conversation.js +1 -9
  13. package/cjs/src/embed/conversation.js.map +1 -1
  14. package/cjs/src/embed/conversation.spec.js +0 -102
  15. package/cjs/src/embed/conversation.spec.js.map +1 -1
  16. package/cjs/src/errors.d.ts +1 -0
  17. package/cjs/src/errors.d.ts.map +1 -1
  18. package/cjs/src/errors.js +1 -0
  19. package/cjs/src/errors.js.map +1 -1
  20. package/cjs/src/pages/embed-test.page.d.ts +8 -0
  21. package/cjs/src/pages/embed-test.page.d.ts.map +1 -0
  22. package/cjs/src/pages/embed-test.page.js +20 -0
  23. package/cjs/src/pages/embed-test.page.js.map +1 -0
  24. package/cjs/src/pages/home.page.d.ts +6 -0
  25. package/cjs/src/pages/home.page.d.ts.map +1 -0
  26. package/cjs/src/pages/home.page.js +12 -0
  27. package/cjs/src/pages/home.page.js.map +1 -0
  28. package/cjs/src/pages/login.page.d.ts +15 -0
  29. package/cjs/src/pages/login.page.d.ts.map +1 -0
  30. package/cjs/src/pages/login.page.js +22 -0
  31. package/cjs/src/pages/login.page.js.map +1 -0
  32. package/cjs/src/react/all-types-export.d.ts +1 -1
  33. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  34. package/cjs/src/react/all-types-export.js +3 -2
  35. package/cjs/src/react/all-types-export.js.map +1 -1
  36. package/cjs/src/react/index.d.ts +71 -20
  37. package/cjs/src/react/index.d.ts.map +1 -1
  38. package/cjs/src/react/index.js +79 -42
  39. package/cjs/src/react/index.js.map +1 -1
  40. package/cjs/src/react/index.spec.js +436 -100
  41. package/cjs/src/react/index.spec.js.map +1 -1
  42. package/cjs/src/tests/auth.test.d.ts +1 -0
  43. package/cjs/src/tests/auth.test.d.ts.map +1 -0
  44. package/cjs/src/tests/auth.test.js +1 -0
  45. package/cjs/src/tests/auth.test.js.map +1 -0
  46. package/cjs/src/tests/e2e/auth.spec.d.ts +2 -0
  47. package/cjs/src/tests/e2e/auth.spec.d.ts.map +1 -0
  48. package/cjs/src/tests/e2e/auth.spec.js +54 -0
  49. package/cjs/src/tests/e2e/auth.spec.js.map +1 -0
  50. package/cjs/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  51. package/cjs/src/utils/graphql/nlsService/conversation-service.js +2 -0
  52. package/cjs/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  53. package/cjs/src/utils.spec.js +25 -0
  54. package/cjs/src/utils.spec.js.map +1 -1
  55. package/dist/index-2QHwuA-G.js +7371 -0
  56. package/dist/{index-DeFzsyFF.js → index-Cj4BVGHL.js} +1 -1
  57. package/dist/{index-UuEbsISo.js → index-DUaG1OG2.js} +1 -1
  58. package/dist/{index-CmEQfuE3.js → index-DnIvX1FR.js} +1 -1
  59. package/dist/{index-Dpf0rd6w.js → index-Fhk1V_Gw.js} +1 -1
  60. package/dist/index-OuiZF3zE.js +7371 -0
  61. package/dist/src/embed/bodyless-conversation.d.ts +19 -7
  62. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  63. package/dist/src/embed/conversation.d.ts +2 -60
  64. package/dist/src/embed/conversation.d.ts.map +1 -1
  65. package/dist/src/errors.d.ts +1 -0
  66. package/dist/src/errors.d.ts.map +1 -1
  67. package/dist/src/react/all-types-export.d.ts +1 -1
  68. package/dist/src/react/all-types-export.d.ts.map +1 -1
  69. package/dist/src/react/index.d.ts +71 -20
  70. package/dist/src/react/index.d.ts.map +1 -1
  71. package/dist/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  72. package/dist/tsembed-react.es.js +112 -63
  73. package/dist/tsembed-react.js +112 -61
  74. package/dist/tsembed.es.js +29 -15
  75. package/dist/tsembed.js +28 -14
  76. package/dist/visual-embed-sdk-react-full.d.ts +90 -85
  77. package/dist/visual-embed-sdk-react.d.ts +90 -85
  78. package/dist/visual-embed-sdk.d.ts +20 -66
  79. package/lib/package.json +1 -1
  80. package/lib/src/config.spec.js +9 -0
  81. package/lib/src/config.spec.js.map +1 -1
  82. package/lib/src/embed/bodyless-conversation.d.ts +19 -7
  83. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  84. package/lib/src/embed/bodyless-conversation.js +23 -4
  85. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  86. package/lib/src/embed/bodyless-conversation.spec.js +9 -191
  87. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  88. package/lib/src/embed/conversation.d.ts +2 -60
  89. package/lib/src/embed/conversation.d.ts.map +1 -1
  90. package/lib/src/embed/conversation.js +2 -10
  91. package/lib/src/embed/conversation.js.map +1 -1
  92. package/lib/src/embed/conversation.spec.js +2 -104
  93. package/lib/src/embed/conversation.spec.js.map +1 -1
  94. package/lib/src/errors.d.ts +1 -0
  95. package/lib/src/errors.d.ts.map +1 -1
  96. package/lib/src/errors.js +1 -0
  97. package/lib/src/errors.js.map +1 -1
  98. package/lib/src/react/all-types-export.d.ts +1 -1
  99. package/lib/src/react/all-types-export.d.ts.map +1 -1
  100. package/lib/src/react/all-types-export.js +1 -1
  101. package/lib/src/react/all-types-export.js.map +1 -1
  102. package/lib/src/react/index.d.ts +71 -20
  103. package/lib/src/react/index.d.ts.map +1 -1
  104. package/lib/src/react/index.js +79 -43
  105. package/lib/src/react/index.js.map +1 -1
  106. package/lib/src/react/index.spec.js +439 -103
  107. package/lib/src/react/index.spec.js.map +1 -1
  108. package/lib/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  109. package/lib/src/utils/graphql/nlsService/conversation-service.js +2 -0
  110. package/lib/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  111. package/lib/src/utils.spec.js +26 -1
  112. package/lib/src/utils.spec.js.map +1 -1
  113. package/lib/src/visual-embed-sdk.d.ts +21 -67
  114. package/package.json +1 -1
  115. package/src/config.spec.ts +11 -0
  116. package/src/embed/bodyless-conversation.spec.ts +9 -203
  117. package/src/embed/bodyless-conversation.ts +24 -10
  118. package/src/embed/conversation.spec.ts +5 -131
  119. package/src/embed/conversation.ts +10 -82
  120. package/src/errors.ts +1 -0
  121. package/src/react/all-types-export.ts +2 -1
  122. package/src/react/index.spec.tsx +556 -157
  123. package/src/react/index.tsx +117 -51
  124. package/src/utils/graphql/nlsService/conversation-service.ts +2 -0
  125. package/src/utils.spec.ts +29 -0
@@ -233,33 +233,42 @@ export const SpotterEmbed: React.ForwardRefExoticComponent<SpotterEmbedProps & R
233
233
  * ```
234
234
  */
235
235
  export const ConversationEmbed: React.ForwardRefExoticComponent<ConversationEmbedProps & React.RefAttributes<_ConversationEmbed>>;
236
- interface SpotterAgentEmbedProps extends EmbedProps, SpotterAgentEmbedViewConfig {
236
+ /**
237
+ * React component for individual conversation messages from SpotterAgent.
238
+ * This component is used internally by the useSpotterAgent hook.
239
+ * @version SDK: 1.37.0 | ThoughtSpot: 10.9.0.cl
240
+ */
241
+ interface ConversationMessageProps extends EmbedProps, SpotterAgentMessageViewConfig {
237
242
  }
243
+ export const ConversationMessage: React.ForwardRefExoticComponent<ConversationMessageProps & React.RefAttributes<_ConversationMessage>>;
238
244
  /**
239
- * React component for SpotterAgent embed, which can be integrated inside
240
- * chatbots or other conversational interfaces.
245
+ * React component for displaying individual conversation messages from SpotterAgent.
246
+ *
247
+ * This component renders a single message response from your ThoughtSpot conversation,
248
+ * showing charts, visualizations, or text responses based on the user's query.
249
+ *
241
250
  * @example
242
251
  * ```tsx
243
- * function SpotterAgent() {
244
- * const ref = useRef();
252
+ * const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
253
+ * const result = await sendMessage('show me sales by region');
245
254
  *
246
- * const handleSendMessage = async () => {
247
- * const { container, error } = await ref.current.sendMessage('show me sales by region');
248
- * if (container) {
249
- * document.body.appendChild(container);
250
- * }
251
- * };
255
+ * if (!result.error) {
256
+ * // Simple usage - just pass the message data
257
+ * <SpotterMessage message={result.message} />
252
258
  *
253
- * return (
254
- * <div>
255
- * <SpotterAgentEmbed ref={ref} worksheetId="worksheetId" />
256
- * <button onClick={handleSendMessage}>Send Message</button>
257
- * </div>
258
- * );
259
+ * // With optional query for context
260
+ * <SpotterMessage
261
+ * message={result.message}
262
+ * query={result.query}
263
+ * />
259
264
  * }
260
265
  * ```
266
+ * @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
261
267
  */
262
- export const SpotterAgentEmbed: React.ForwardRefExoticComponent<SpotterAgentEmbedProps & React.RefAttributes<_SpotterAgentEmbed>>;
268
+ export const SpotterMessage: React.ForwardRefExoticComponent<{
269
+ message: SpotterAgentMessageViewConfig;
270
+ query?: string;
271
+ } & Omit<EmbedProps, keyof SpotterAgentMessageViewConfig> & React.RefAttributes<_ConversationMessage>>;
263
272
  /**
264
273
  * React component for PreRendered Conversation embed.
265
274
  *
@@ -279,7 +288,7 @@ export const SpotterAgentEmbed: React.ForwardRefExoticComponent<SpotterAgentEmbe
279
288
  * ```
280
289
  */
281
290
  export const PreRenderedConversationEmbed: React.ForwardRefExoticComponent<SpotterEmbedProps & PreRenderProps & React.RefAttributes<_SpotterEmbed>>;
282
- type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmbed | typeof SearchBarEmbed | typeof SageEmbed | typeof SpotterAgentEmbed | typeof SpotterEmbed | typeof ConversationEmbed;
291
+ type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmbed | typeof SearchBarEmbed | typeof SageEmbed | typeof ConversationMessage | typeof SpotterMessage | typeof SpotterEmbed | typeof ConversationEmbed;
283
292
  /**
284
293
  * Get a reference to the embed component to trigger events on the component.
285
294
  * @example
@@ -311,6 +320,48 @@ export function useEmbedRef<T extends EmbedComponent>(): React.MutableRefObject<
311
320
  * @version SDK: 1.36.2 | ThoughtSpot: *
312
321
  */
313
322
  export function useInit(config: EmbedConfig): React.MutableRefObject<AuthEventEmitter>;
323
+ /**
324
+ * React hook for interacting with SpotterAgent AI conversations.
325
+ *
326
+ * This hook provides a sendMessage function that allows you to send natural language
327
+ * queries to your data and get back AI-generated responses with visualizations.
328
+ *
329
+ * @param config - Configuration object containing worksheetId and other options
330
+ * @returns Object with sendMessage function that returns conversation results
331
+ * @example
332
+ * ```tsx
333
+ * const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
334
+ *
335
+ * const handleQuery = async () => {
336
+ * const result = await sendMessage('show me sales by region');
337
+ *
338
+ * if (!result.error) {
339
+ * // Display the message response
340
+ * <SpotterMessage message={result.message} />
341
+ * } else {
342
+ * console.error('Error:', result.error);
343
+ * }
344
+ * };
345
+ * ```
346
+ * @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
347
+ */
348
+ export function useSpotterAgent(config: SpotterAgentEmbedViewConfig): {
349
+ sendMessage: (query: string) => Promise<{
350
+ error: any;
351
+ query?: undefined;
352
+ message?: undefined;
353
+ } | {
354
+ query: string;
355
+ message: {
356
+ worksheetId: string;
357
+ sessionId: any;
358
+ genNo: any;
359
+ acSessionId: any;
360
+ acGenNo: any;
361
+ };
362
+ error?: undefined;
363
+ }>;
364
+ };
314
365
 
315
366
  /**
316
367
  * Copyright (c) 2023
@@ -2027,10 +2078,6 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
2027
2078
  * The ID of the worksheet to use for the conversation.
2028
2079
  */
2029
2080
  worksheetId: string;
2030
- /**
2031
- * Optional CSS class name to add to the container div.
2032
- */
2033
- containerClassName?: string;
2034
2081
  }
2035
2082
  /**
2036
2083
  * Configuration for conversation options.
@@ -2040,13 +2087,13 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
2040
2087
  */
2041
2088
  export interface BodylessConversationViewConfig extends SpotterAgentEmbedViewConfig {
2042
2089
  }
2043
- interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
2090
+ export interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
2044
2091
  sessionId: string;
2045
2092
  genNo: number;
2046
2093
  acSessionId: string;
2047
2094
  acGenNo: number;
2048
2095
  }
2049
- declare class ConversationMessage extends TsEmbed {
2096
+ export declare class ConversationMessage extends TsEmbed {
2050
2097
  protected viewConfig: SpotterAgentMessageViewConfig;
2051
2098
  constructor(container: HTMLElement, viewConfig: SpotterAgentMessageViewConfig);
2052
2099
  getIframeSrc(): string;
@@ -2082,6 +2129,23 @@ export declare class SpotterAgentEmbed {
2082
2129
  viz: ConversationMessage;
2083
2130
  error?: undefined;
2084
2131
  }>;
2132
+ /**
2133
+ * Send a message to the conversation service and return only the data.
2134
+ * @param userMessage - The message to send to the conversation service.
2135
+ * @returns The data from the conversation service.
2136
+ */
2137
+ sendMessageData(userMessage: string): Promise<{
2138
+ error: any;
2139
+ data?: undefined;
2140
+ } | {
2141
+ data: {
2142
+ sessionId: any;
2143
+ genNo: any;
2144
+ acSessionId: any;
2145
+ acGenNo: any;
2146
+ };
2147
+ error?: undefined;
2148
+ }>;
2085
2149
  }
2086
2150
  /**
2087
2151
  * Create a conversation embed, which can be integrated inside
@@ -2106,7 +2170,6 @@ export declare class SpotterAgentEmbed {
2106
2170
  export declare class BodylessConversation extends SpotterAgentEmbed {
2107
2171
  constructor(viewConfig: BodylessConversationViewConfig);
2108
2172
  }
2109
- export {};
2110
2173
 
2111
2174
  /**
2112
2175
  * Copyright (c) 2023
@@ -7383,8 +7446,7 @@ export interface SearchOptions {
7383
7446
  */
7384
7447
  export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAction'> {
7385
7448
  /**
7386
- * The ID of the data source object. For example, Model, View, or Table. Spotter uses
7387
- * this object to query data and generate Answers.
7449
+ * The ID of the data source object. For example, Model, View, or Table. Spotter uses this object to query data and generate Answers.
7388
7450
  */
7389
7451
  worksheetId: string;
7390
7452
  /**
@@ -7467,63 +7529,6 @@ export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAct
7467
7529
  * @version SDK: 1.36.0 | ThoughtSpot: 10.6.0.cl
7468
7530
  */
7469
7531
  hideSampleQuestions?: boolean;
7470
- /**
7471
- * The list of runtime filters to apply to a search Answer,
7472
- * visualization, or Liveboard.
7473
- *
7474
- * Supported embed types: `SpotterEmbed`
7475
- * @example
7476
- * ```js
7477
- * const embed = new SpotterEmbed('#tsEmbed', {
7478
- * ... // other embed view config
7479
- * runtimeFilters: [
7480
- * {
7481
- * columnName: 'value',
7482
- * operator: RuntimeFilterOp.EQ,
7483
- * values: ['string' | 123 | true],
7484
- * },
7485
- * ],
7486
- * })
7487
- * ```
7488
- */
7489
- runtimeFilters?: RuntimeFilter[];
7490
- /**
7491
- * Flag to control whether runtime filters should be included in the URL.
7492
- * If true, filters will be passed via app initialization payload instead.
7493
- * If false/undefined, filters will be added to URL (default behavior).
7494
- *
7495
- * Supported embed types: `SpotterEmbed`
7496
- * @default false
7497
- */
7498
- excludeRuntimeFiltersfromURL?: boolean;
7499
- /**
7500
- * The list of runtime parameters to apply to the conversation.
7501
- *
7502
- * Supported embed types: `SpotterEmbed`
7503
- * @example
7504
- * ```js
7505
- * const embed = new SpotterEmbed('#tsEmbed', {
7506
- * ... // other embed view config
7507
- * runtimeParameters: [
7508
- * {
7509
- * name: 'Parameter Name',
7510
- * value: 'Parameter Value',
7511
- * },
7512
- * ],
7513
- * })
7514
- * ```
7515
- */
7516
- runtimeParameters?: RuntimeParameter[];
7517
- /**
7518
- * Flag to control whether runtime parameters should be included in the URL.
7519
- * If true, parameters will be passed via app initialization payload instead.
7520
- * If false/undefined, parameters will be added to URL (default behavior).
7521
- *
7522
- * Supported embed types: `SpotterEmbed`
7523
- * @default false
7524
- *
7525
- */
7526
- excludeRuntimeParametersfromURL?: boolean;
7527
7532
  }
7528
7533
  /**
7529
7534
  * The configuration for the embedded spotterEmbed options.
@@ -233,33 +233,42 @@ export const SpotterEmbed: React.ForwardRefExoticComponent<SpotterEmbedProps & R
233
233
  * ```
234
234
  */
235
235
  export const ConversationEmbed: React.ForwardRefExoticComponent<ConversationEmbedProps & React.RefAttributes<_ConversationEmbed>>;
236
- interface SpotterAgentEmbedProps extends EmbedProps, SpotterAgentEmbedViewConfig {
236
+ /**
237
+ * React component for individual conversation messages from SpotterAgent.
238
+ * This component is used internally by the useSpotterAgent hook.
239
+ * @version SDK: 1.37.0 | ThoughtSpot: 10.9.0.cl
240
+ */
241
+ interface ConversationMessageProps extends EmbedProps, SpotterAgentMessageViewConfig {
237
242
  }
243
+ export const ConversationMessage: React.ForwardRefExoticComponent<ConversationMessageProps & React.RefAttributes<_ConversationMessage>>;
238
244
  /**
239
- * React component for SpotterAgent embed, which can be integrated inside
240
- * chatbots or other conversational interfaces.
245
+ * React component for displaying individual conversation messages from SpotterAgent.
246
+ *
247
+ * This component renders a single message response from your ThoughtSpot conversation,
248
+ * showing charts, visualizations, or text responses based on the user's query.
249
+ *
241
250
  * @example
242
251
  * ```tsx
243
- * function SpotterAgent() {
244
- * const ref = useRef();
252
+ * const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
253
+ * const result = await sendMessage('show me sales by region');
245
254
  *
246
- * const handleSendMessage = async () => {
247
- * const { container, error } = await ref.current.sendMessage('show me sales by region');
248
- * if (container) {
249
- * document.body.appendChild(container);
250
- * }
251
- * };
255
+ * if (!result.error) {
256
+ * // Simple usage - just pass the message data
257
+ * <SpotterMessage message={result.message} />
252
258
  *
253
- * return (
254
- * <div>
255
- * <SpotterAgentEmbed ref={ref} worksheetId="worksheetId" />
256
- * <button onClick={handleSendMessage}>Send Message</button>
257
- * </div>
258
- * );
259
+ * // With optional query for context
260
+ * <SpotterMessage
261
+ * message={result.message}
262
+ * query={result.query}
263
+ * />
259
264
  * }
260
265
  * ```
266
+ * @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
261
267
  */
262
- export const SpotterAgentEmbed: React.ForwardRefExoticComponent<SpotterAgentEmbedProps & React.RefAttributes<_SpotterAgentEmbed>>;
268
+ export const SpotterMessage: React.ForwardRefExoticComponent<{
269
+ message: SpotterAgentMessageViewConfig;
270
+ query?: string;
271
+ } & Omit<EmbedProps, keyof SpotterAgentMessageViewConfig> & React.RefAttributes<_ConversationMessage>>;
263
272
  /**
264
273
  * React component for PreRendered Conversation embed.
265
274
  *
@@ -279,7 +288,7 @@ export const SpotterAgentEmbed: React.ForwardRefExoticComponent<SpotterAgentEmbe
279
288
  * ```
280
289
  */
281
290
  export const PreRenderedConversationEmbed: React.ForwardRefExoticComponent<SpotterEmbedProps & PreRenderProps & React.RefAttributes<_SpotterEmbed>>;
282
- type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmbed | typeof SearchBarEmbed | typeof SageEmbed | typeof SpotterAgentEmbed | typeof SpotterEmbed | typeof ConversationEmbed;
291
+ type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmbed | typeof SearchBarEmbed | typeof SageEmbed | typeof ConversationMessage | typeof SpotterMessage | typeof SpotterEmbed | typeof ConversationEmbed;
283
292
  /**
284
293
  * Get a reference to the embed component to trigger events on the component.
285
294
  * @example
@@ -311,6 +320,48 @@ export function useEmbedRef<T extends EmbedComponent>(): React.MutableRefObject<
311
320
  * @version SDK: 1.36.2 | ThoughtSpot: *
312
321
  */
313
322
  export function useInit(config: EmbedConfig): React.MutableRefObject<AuthEventEmitter>;
323
+ /**
324
+ * React hook for interacting with SpotterAgent AI conversations.
325
+ *
326
+ * This hook provides a sendMessage function that allows you to send natural language
327
+ * queries to your data and get back AI-generated responses with visualizations.
328
+ *
329
+ * @param config - Configuration object containing worksheetId and other options
330
+ * @returns Object with sendMessage function that returns conversation results
331
+ * @example
332
+ * ```tsx
333
+ * const { sendMessage } = useSpotterAgent({ worksheetId: 'worksheetId' });
334
+ *
335
+ * const handleQuery = async () => {
336
+ * const result = await sendMessage('show me sales by region');
337
+ *
338
+ * if (!result.error) {
339
+ * // Display the message response
340
+ * <SpotterMessage message={result.message} />
341
+ * } else {
342
+ * console.error('Error:', result.error);
343
+ * }
344
+ * };
345
+ * ```
346
+ * @version SDK: 1.39.0 | ThoughtSpot: 10.11.0.cl
347
+ */
348
+ export function useSpotterAgent(config: SpotterAgentEmbedViewConfig): {
349
+ sendMessage: (query: string) => Promise<{
350
+ error: any;
351
+ query?: undefined;
352
+ message?: undefined;
353
+ } | {
354
+ query: string;
355
+ message: {
356
+ worksheetId: string;
357
+ sessionId: any;
358
+ genNo: any;
359
+ acSessionId: any;
360
+ acGenNo: any;
361
+ };
362
+ error?: undefined;
363
+ }>;
364
+ };
314
365
 
315
366
  export declare let loggedInStatus: boolean;
316
367
  export declare let samlAuthWindow: Window;
@@ -2017,10 +2068,6 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
2017
2068
  * The ID of the worksheet to use for the conversation.
2018
2069
  */
2019
2070
  worksheetId: string;
2020
- /**
2021
- * Optional CSS class name to add to the container div.
2022
- */
2023
- containerClassName?: string;
2024
2071
  }
2025
2072
  /**
2026
2073
  * Configuration for conversation options.
@@ -2030,13 +2077,13 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
2030
2077
  */
2031
2078
  export interface BodylessConversationViewConfig extends SpotterAgentEmbedViewConfig {
2032
2079
  }
2033
- interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
2080
+ export interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
2034
2081
  sessionId: string;
2035
2082
  genNo: number;
2036
2083
  acSessionId: string;
2037
2084
  acGenNo: number;
2038
2085
  }
2039
- declare class ConversationMessage extends TsEmbed {
2086
+ export declare class ConversationMessage extends TsEmbed {
2040
2087
  protected viewConfig: SpotterAgentMessageViewConfig;
2041
2088
  constructor(container: HTMLElement, viewConfig: SpotterAgentMessageViewConfig);
2042
2089
  getIframeSrc(): string;
@@ -2072,6 +2119,23 @@ export declare class SpotterAgentEmbed {
2072
2119
  viz: ConversationMessage;
2073
2120
  error?: undefined;
2074
2121
  }>;
2122
+ /**
2123
+ * Send a message to the conversation service and return only the data.
2124
+ * @param userMessage - The message to send to the conversation service.
2125
+ * @returns The data from the conversation service.
2126
+ */
2127
+ sendMessageData(userMessage: string): Promise<{
2128
+ error: any;
2129
+ data?: undefined;
2130
+ } | {
2131
+ data: {
2132
+ sessionId: any;
2133
+ genNo: any;
2134
+ acSessionId: any;
2135
+ acGenNo: any;
2136
+ };
2137
+ error?: undefined;
2138
+ }>;
2075
2139
  }
2076
2140
  /**
2077
2141
  * Create a conversation embed, which can be integrated inside
@@ -2096,7 +2160,6 @@ export declare class SpotterAgentEmbed {
2096
2160
  export declare class BodylessConversation extends SpotterAgentEmbed {
2097
2161
  constructor(viewConfig: BodylessConversationViewConfig);
2098
2162
  }
2099
- export {};
2100
2163
 
2101
2164
  /**
2102
2165
  * Copyright (c) 2023
@@ -7373,8 +7436,7 @@ export interface SearchOptions {
7373
7436
  */
7374
7437
  export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAction'> {
7375
7438
  /**
7376
- * The ID of the data source object. For example, Model, View, or Table. Spotter uses
7377
- * this object to query data and generate Answers.
7439
+ * The ID of the data source object. For example, Model, View, or Table. Spotter uses this object to query data and generate Answers.
7378
7440
  */
7379
7441
  worksheetId: string;
7380
7442
  /**
@@ -7457,63 +7519,6 @@ export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAct
7457
7519
  * @version SDK: 1.36.0 | ThoughtSpot: 10.6.0.cl
7458
7520
  */
7459
7521
  hideSampleQuestions?: boolean;
7460
- /**
7461
- * The list of runtime filters to apply to a search Answer,
7462
- * visualization, or Liveboard.
7463
- *
7464
- * Supported embed types: `SpotterEmbed`
7465
- * @example
7466
- * ```js
7467
- * const embed = new SpotterEmbed('#tsEmbed', {
7468
- * ... // other embed view config
7469
- * runtimeFilters: [
7470
- * {
7471
- * columnName: 'value',
7472
- * operator: RuntimeFilterOp.EQ,
7473
- * values: ['string' | 123 | true],
7474
- * },
7475
- * ],
7476
- * })
7477
- * ```
7478
- */
7479
- runtimeFilters?: RuntimeFilter[];
7480
- /**
7481
- * Flag to control whether runtime filters should be included in the URL.
7482
- * If true, filters will be passed via app initialization payload instead.
7483
- * If false/undefined, filters will be added to URL (default behavior).
7484
- *
7485
- * Supported embed types: `SpotterEmbed`
7486
- * @default false
7487
- */
7488
- excludeRuntimeFiltersfromURL?: boolean;
7489
- /**
7490
- * The list of runtime parameters to apply to the conversation.
7491
- *
7492
- * Supported embed types: `SpotterEmbed`
7493
- * @example
7494
- * ```js
7495
- * const embed = new SpotterEmbed('#tsEmbed', {
7496
- * ... // other embed view config
7497
- * runtimeParameters: [
7498
- * {
7499
- * name: 'Parameter Name',
7500
- * value: 'Parameter Value',
7501
- * },
7502
- * ],
7503
- * })
7504
- * ```
7505
- */
7506
- runtimeParameters?: RuntimeParameter[];
7507
- /**
7508
- * Flag to control whether runtime parameters should be included in the URL.
7509
- * If true, parameters will be passed via app initialization payload instead.
7510
- * If false/undefined, parameters will be added to URL (default behavior).
7511
- *
7512
- * Supported embed types: `SpotterEmbed`
7513
- * @default false
7514
- *
7515
- */
7516
- excludeRuntimeParametersfromURL?: boolean;
7517
7522
  }
7518
7523
  /**
7519
7524
  * The configuration for the embedded spotterEmbed options.
@@ -1519,10 +1519,6 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
1519
1519
  * The ID of the worksheet to use for the conversation.
1520
1520
  */
1521
1521
  worksheetId: string;
1522
- /**
1523
- * Optional CSS class name to add to the container div.
1524
- */
1525
- containerClassName?: string;
1526
1522
  }
1527
1523
  /**
1528
1524
  * Configuration for conversation options.
@@ -1532,13 +1528,13 @@ export interface SpotterAgentEmbedViewConfig extends Omit<BaseViewConfig, 'prima
1532
1528
  */
1533
1529
  export interface BodylessConversationViewConfig extends SpotterAgentEmbedViewConfig {
1534
1530
  }
1535
- interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
1531
+ export interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
1536
1532
  sessionId: string;
1537
1533
  genNo: number;
1538
1534
  acSessionId: string;
1539
1535
  acGenNo: number;
1540
1536
  }
1541
- class ConversationMessage extends TsEmbed {
1537
+ export class ConversationMessage extends TsEmbed {
1542
1538
  protected viewConfig: SpotterAgentMessageViewConfig;
1543
1539
  constructor(container: HTMLElement, viewConfig: SpotterAgentMessageViewConfig);
1544
1540
  getIframeSrc(): string;
@@ -1574,6 +1570,23 @@ export class SpotterAgentEmbed {
1574
1570
  viz: ConversationMessage;
1575
1571
  error?: undefined;
1576
1572
  }>;
1573
+ /**
1574
+ * Send a message to the conversation service and return only the data.
1575
+ * @param userMessage - The message to send to the conversation service.
1576
+ * @returns The data from the conversation service.
1577
+ */
1578
+ sendMessageData(userMessage: string): Promise<{
1579
+ error: any;
1580
+ data?: undefined;
1581
+ } | {
1582
+ data: {
1583
+ sessionId: any;
1584
+ genNo: any;
1585
+ acSessionId: any;
1586
+ acGenNo: any;
1587
+ };
1588
+ error?: undefined;
1589
+ }>;
1577
1590
  }
1578
1591
  /**
1579
1592
  * Create a conversation embed, which can be integrated inside
@@ -1598,7 +1611,6 @@ export class SpotterAgentEmbed {
1598
1611
  export class BodylessConversation extends SpotterAgentEmbed {
1599
1612
  constructor(viewConfig: BodylessConversationViewConfig);
1600
1613
  }
1601
- export {};
1602
1614
 
1603
1615
  /**
1604
1616
  * Configuration for search options
@@ -1615,8 +1627,7 @@ export interface SearchOptions {
1615
1627
  */
1616
1628
  export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAction'> {
1617
1629
  /**
1618
- * The ID of the data source object. For example, Model, View, or Table. Spotter uses
1619
- * this object to query data and generate Answers.
1630
+ * The ID of the data source object. For example, Model, View, or Table. Spotter uses this object to query data and generate Answers.
1620
1631
  */
1621
1632
  worksheetId: string;
1622
1633
  /**
@@ -1699,63 +1710,6 @@ export interface SpotterEmbedViewConfig extends Omit<BaseViewConfig, 'primaryAct
1699
1710
  * @version SDK: 1.36.0 | ThoughtSpot: 10.6.0.cl
1700
1711
  */
1701
1712
  hideSampleQuestions?: boolean;
1702
- /**
1703
- * The list of runtime filters to apply to a search Answer,
1704
- * visualization, or Liveboard.
1705
- *
1706
- * Supported embed types: `SpotterEmbed`
1707
- * @example
1708
- * ```js
1709
- * const embed = new SpotterEmbed('#tsEmbed', {
1710
- * ... // other embed view config
1711
- * runtimeFilters: [
1712
- * {
1713
- * columnName: 'value',
1714
- * operator: RuntimeFilterOp.EQ,
1715
- * values: ['string' | 123 | true],
1716
- * },
1717
- * ],
1718
- * })
1719
- * ```
1720
- */
1721
- runtimeFilters?: RuntimeFilter[];
1722
- /**
1723
- * Flag to control whether runtime filters should be included in the URL.
1724
- * If true, filters will be passed via app initialization payload instead.
1725
- * If false/undefined, filters will be added to URL (default behavior).
1726
- *
1727
- * Supported embed types: `SpotterEmbed`
1728
- * @default false
1729
- */
1730
- excludeRuntimeFiltersfromURL?: boolean;
1731
- /**
1732
- * The list of runtime parameters to apply to the conversation.
1733
- *
1734
- * Supported embed types: `SpotterEmbed`
1735
- * @example
1736
- * ```js
1737
- * const embed = new SpotterEmbed('#tsEmbed', {
1738
- * ... // other embed view config
1739
- * runtimeParameters: [
1740
- * {
1741
- * name: 'Parameter Name',
1742
- * value: 'Parameter Value',
1743
- * },
1744
- * ],
1745
- * })
1746
- * ```
1747
- */
1748
- runtimeParameters?: RuntimeParameter[];
1749
- /**
1750
- * Flag to control whether runtime parameters should be included in the URL.
1751
- * If true, parameters will be passed via app initialization payload instead.
1752
- * If false/undefined, parameters will be added to URL (default behavior).
1753
- *
1754
- * Supported embed types: `SpotterEmbed`
1755
- * @default false
1756
- *
1757
- */
1758
- excludeRuntimeParametersfromURL?: boolean;
1759
1713
  }
1760
1714
  /**
1761
1715
  * The configuration for the embedded spotterEmbed options.
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.39.2-alpha.1",
3
+ "version": "1.39.2-spotter-agent",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -16,6 +16,15 @@ describe('getThoughtSpotHost', () => {
16
16
  };
17
17
  expect(testFn).toThrow(Error);
18
18
  });
19
+ test('invalid URL format', () => {
20
+ const testFn = () => {
21
+ getThoughtSpotHost({
22
+ ...embedConfig,
23
+ thoughtSpotHost: '',
24
+ });
25
+ };
26
+ expect(testFn).toThrow('Error parsing ThoughtSpot host. Please provide a valid URL.');
27
+ });
19
28
  test('IP address/hostname only', () => {
20
29
  expect(getThoughtSpotHost({
21
30
  ...embedConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"config.spec.js","sourceRoot":"","sources":["../../src/config.spec.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,GAAG;IAChB,QAAQ,EAAE,QAAQ,CAAC,GAAG;CACzB,CAAC;AAEF,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACxB,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,kBAAkB,CAAC;gBACf,GAAG,WAAW;gBACd,eAAe,EAAE,IAAI;a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