@thoughtspot/visual-embed-sdk 1.37.1 → 1.38.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/cjs/package.json +1 -1
- package/cjs/src/embed/bodyless-conversation.d.ts +44 -9
- package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/cjs/src/embed/bodyless-conversation.js +35 -5
- package/cjs/src/embed/bodyless-conversation.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +290 -5
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +40 -11
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +29 -4
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +7 -7
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +4 -4
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +5 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +3 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/index.d.ts +53 -5
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +73 -4
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +94 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +2 -1
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +1 -0
- package/cjs/src/types.js.map +1 -1
- package/dist/{index-m9UtENc9.js → index-BIcnpmMY.js} +1 -1
- package/dist/src/embed/bodyless-conversation.d.ts +44 -9
- package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +40 -11
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +53 -5
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +2 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +562 -10
- package/dist/tsembed-react.js +562 -8
- package/dist/tsembed.es.js +65 -11
- package/dist/tsembed.js +71 -15
- package/dist/visual-embed-sdk-react-full.d.ts +184 -72
- package/dist/visual-embed-sdk-react.d.ts +184 -72
- package/dist/visual-embed-sdk.d.ts +87 -22
- package/lib/package.json +1 -1
- package/lib/src/embed/bodyless-conversation.d.ts +44 -9
- package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/lib/src/embed/bodyless-conversation.js +33 -4
- package/lib/src/embed/bodyless-conversation.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +292 -7
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +40 -11
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +27 -3
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +8 -8
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +4 -4
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +4 -4
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/index.d.ts +53 -5
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +73 -4
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +96 -2
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +2 -1
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +1 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +90 -25
- package/package.json +1 -1
- package/src/embed/bodyless-conversation.spec.ts +314 -7
- package/src/embed/bodyless-conversation.ts +53 -8
- package/src/embed/conversation.spec.ts +16 -16
- package/src/embed/conversation.ts +44 -11
- package/src/embed/ts-embed.spec.ts +0 -2
- package/src/index.ts +16 -5
- package/src/react/all-types-export.ts +2 -0
- package/src/react/index.spec.tsx +157 -1
- package/src/react/index.tsx +98 -11
- package/src/types.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'jest-fetch-mock';
|
|
2
|
-
import {
|
|
2
|
+
import { SpotterAgentEmbed, SpotterAgentEmbedViewConfig } from './bodyless-conversation';
|
|
3
3
|
import * as authInstance from '../auth';
|
|
4
4
|
import { init } from '../index';
|
|
5
5
|
import { Action, AuthType, RuntimeFilterOp } from '../types';
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
expectUrlToHaveParamsWithValues,
|
|
15
15
|
} from '../test/test-utils';
|
|
16
16
|
|
|
17
|
-
describe('
|
|
17
|
+
describe('SpotterAgentEmbed', () => {
|
|
18
18
|
const thoughtSpotHost = 'tshost';
|
|
19
19
|
|
|
20
20
|
beforeAll(() => {
|
|
@@ -31,7 +31,7 @@ describe('BodylessConversation', () => {
|
|
|
31
31
|
fetchMock.resetMocks();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
test('should render the
|
|
34
|
+
test('should render the SpotterAgent embed', async () => {
|
|
35
35
|
fetchMock.mockResponses(
|
|
36
36
|
JSON.stringify({
|
|
37
37
|
data: {
|
|
@@ -117,12 +117,12 @@ describe('BodylessConversation', () => {
|
|
|
117
117
|
},
|
|
118
118
|
}),
|
|
119
119
|
);
|
|
120
|
-
const viewConfig:
|
|
120
|
+
const viewConfig: SpotterAgentEmbedViewConfig = {
|
|
121
121
|
worksheetId: 'worksheetId',
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
const
|
|
125
|
-
const result = await
|
|
124
|
+
const spotterEmbed = new SpotterAgentEmbed(viewConfig);
|
|
125
|
+
const result = await spotterEmbed.sendMessage('userMessage');
|
|
126
126
|
const iframeSrc = getIFrameSrc(result.container);
|
|
127
127
|
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
128
128
|
sessionId: 'sessionId',
|
|
@@ -134,7 +134,314 @@ describe('BodylessConversation', () => {
|
|
|
134
134
|
fetchMock.mockRejectOnce(
|
|
135
135
|
new Error('error'),
|
|
136
136
|
);
|
|
137
|
-
const errorResult = await
|
|
137
|
+
const errorResult = await spotterEmbed.sendMessage('userMessage');
|
|
138
138
|
expect(errorResult.error instanceof Error).toBeTruthy();
|
|
139
139
|
});
|
|
140
|
+
|
|
141
|
+
test('should apply containerClassName to the container element', async () => {
|
|
142
|
+
fetchMock.mockResponses(
|
|
143
|
+
JSON.stringify({
|
|
144
|
+
data: {
|
|
145
|
+
ConvAssist__createConversation: {
|
|
146
|
+
convId: 'conversationId',
|
|
147
|
+
initialCtx: {
|
|
148
|
+
type: 'TS_ANSWER',
|
|
149
|
+
tsAnsCtx: {
|
|
150
|
+
sessionId: 'sessionId',
|
|
151
|
+
genNo: 1,
|
|
152
|
+
stateKey: {
|
|
153
|
+
transactionId: 'transactionId',
|
|
154
|
+
generationNumber: 1,
|
|
155
|
+
},
|
|
156
|
+
worksheet: {
|
|
157
|
+
worksheetId: 'worksheetId',
|
|
158
|
+
worksheetName: 'GTM',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
JSON.stringify({
|
|
166
|
+
data: {
|
|
167
|
+
ConvAssist__sendMessage: {
|
|
168
|
+
responses: [
|
|
169
|
+
{
|
|
170
|
+
msgId: 'msgId',
|
|
171
|
+
data: {
|
|
172
|
+
asstRespData: {
|
|
173
|
+
tool: 'TS_NLS',
|
|
174
|
+
asstRespText: '',
|
|
175
|
+
nlsAnsData: {
|
|
176
|
+
sageQuerySuggestions: [
|
|
177
|
+
{
|
|
178
|
+
llmReasoning: {
|
|
179
|
+
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
|
|
180
|
+
clarifications: '',
|
|
181
|
+
interpretation: '',
|
|
182
|
+
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
|
|
183
|
+
},
|
|
184
|
+
tokens: [
|
|
185
|
+
'sum sales',
|
|
186
|
+
"item type = 'jackets'",
|
|
187
|
+
"date = 'this year'",
|
|
188
|
+
],
|
|
189
|
+
tmlTokens: [
|
|
190
|
+
'sum [sales]',
|
|
191
|
+
"[date] = [date].'this year'",
|
|
192
|
+
"[item type] = [item type].'jackets'",
|
|
193
|
+
],
|
|
194
|
+
worksheetId: 'worksheetId',
|
|
195
|
+
description: '',
|
|
196
|
+
title: '',
|
|
197
|
+
cached: false,
|
|
198
|
+
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
|
|
199
|
+
sessionId: 'sessionId',
|
|
200
|
+
genNo: 2,
|
|
201
|
+
formulaInfo: [],
|
|
202
|
+
tmlPhrases: [],
|
|
203
|
+
stateKey: {
|
|
204
|
+
transactionId: 'transactionId',
|
|
205
|
+
generationNumber: 1,
|
|
206
|
+
__typename: 'sage_auto_complete_v2_ACStateKey',
|
|
207
|
+
},
|
|
208
|
+
__typename: 'eureka_SageQuerySuggestion',
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
responseType: 'ANSWER',
|
|
212
|
+
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
|
|
213
|
+
},
|
|
214
|
+
__typename: 'convassist_AsstResponseData',
|
|
215
|
+
},
|
|
216
|
+
__typename: 'convassist_MessageData',
|
|
217
|
+
},
|
|
218
|
+
type: 'ASST_RESPONSE',
|
|
219
|
+
__typename: 'convassist_MessagePayload',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
__typename: 'convassist_SendMessageResponse',
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
const viewConfig: SpotterAgentEmbedViewConfig = {
|
|
229
|
+
worksheetId: 'worksheetId',
|
|
230
|
+
containerClassName: 'custom-conversation-container',
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
|
|
234
|
+
const result = await spotterAgentEmbed.sendMessage('userMessage');
|
|
235
|
+
|
|
236
|
+
// Verify that the container has the custom class name
|
|
237
|
+
expect(result.container.className).toBe('custom-conversation-container');
|
|
238
|
+
|
|
239
|
+
// Also verify the iframe src is correct
|
|
240
|
+
const iframeSrc = getIFrameSrc(result.container);
|
|
241
|
+
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
242
|
+
sessionId: 'sessionId',
|
|
243
|
+
genNo: 2,
|
|
244
|
+
acSessionId: 'transactionId',
|
|
245
|
+
acGenNo: 1,
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test('should not set className when containerClassName is not provided', async () => {
|
|
250
|
+
fetchMock.mockResponses(
|
|
251
|
+
JSON.stringify({
|
|
252
|
+
data: {
|
|
253
|
+
ConvAssist__createConversation: {
|
|
254
|
+
convId: 'conversationId',
|
|
255
|
+
initialCtx: {
|
|
256
|
+
type: 'TS_ANSWER',
|
|
257
|
+
tsAnsCtx: {
|
|
258
|
+
sessionId: 'sessionId',
|
|
259
|
+
genNo: 1,
|
|
260
|
+
stateKey: {
|
|
261
|
+
transactionId: 'transactionId',
|
|
262
|
+
generationNumber: 1,
|
|
263
|
+
},
|
|
264
|
+
worksheet: {
|
|
265
|
+
worksheetId: 'worksheetId',
|
|
266
|
+
worksheetName: 'GTM',
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
}),
|
|
273
|
+
JSON.stringify({
|
|
274
|
+
data: {
|
|
275
|
+
ConvAssist__sendMessage: {
|
|
276
|
+
responses: [
|
|
277
|
+
{
|
|
278
|
+
msgId: 'msgId',
|
|
279
|
+
data: {
|
|
280
|
+
asstRespData: {
|
|
281
|
+
tool: 'TS_NLS',
|
|
282
|
+
asstRespText: '',
|
|
283
|
+
nlsAnsData: {
|
|
284
|
+
sageQuerySuggestions: [
|
|
285
|
+
{
|
|
286
|
+
llmReasoning: {
|
|
287
|
+
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
|
|
288
|
+
clarifications: '',
|
|
289
|
+
interpretation: '',
|
|
290
|
+
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
|
|
291
|
+
},
|
|
292
|
+
tokens: [
|
|
293
|
+
'sum sales',
|
|
294
|
+
"item type = 'jackets'",
|
|
295
|
+
"date = 'this year'",
|
|
296
|
+
],
|
|
297
|
+
tmlTokens: [
|
|
298
|
+
'sum [sales]',
|
|
299
|
+
"[date] = [date].'this year'",
|
|
300
|
+
"[item type] = [item type].'jackets'",
|
|
301
|
+
],
|
|
302
|
+
worksheetId: 'worksheetId',
|
|
303
|
+
description: '',
|
|
304
|
+
title: '',
|
|
305
|
+
cached: false,
|
|
306
|
+
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
|
|
307
|
+
sessionId: 'sessionId',
|
|
308
|
+
genNo: 2,
|
|
309
|
+
formulaInfo: [],
|
|
310
|
+
tmlPhrases: [],
|
|
311
|
+
stateKey: {
|
|
312
|
+
transactionId: 'transactionId',
|
|
313
|
+
generationNumber: 1,
|
|
314
|
+
__typename: 'sage_auto_complete_v2_ACStateKey',
|
|
315
|
+
},
|
|
316
|
+
__typename: 'eureka_SageQuerySuggestion',
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
responseType: 'ANSWER',
|
|
320
|
+
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
|
|
321
|
+
},
|
|
322
|
+
__typename: 'convassist_AsstResponseData',
|
|
323
|
+
},
|
|
324
|
+
__typename: 'convassist_MessageData',
|
|
325
|
+
},
|
|
326
|
+
type: 'ASST_RESPONSE',
|
|
327
|
+
__typename: 'convassist_MessagePayload',
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
__typename: 'convassist_SendMessageResponse',
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
}),
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const viewConfig: SpotterAgentEmbedViewConfig = {
|
|
337
|
+
worksheetId: 'worksheetId',
|
|
338
|
+
// No containerClassName provided
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
|
|
342
|
+
const result = await spotterAgentEmbed.sendMessage('userMessage');
|
|
343
|
+
|
|
344
|
+
// Verify that the container has no class name (empty string)
|
|
345
|
+
expect(result.container.className).toBe('');
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
test('should handle hideActions parameter correctly', async () => {
|
|
349
|
+
fetchMock.mockResponses(
|
|
350
|
+
JSON.stringify({
|
|
351
|
+
data: {
|
|
352
|
+
ConvAssist__createConversation: {
|
|
353
|
+
convId: 'conversationId',
|
|
354
|
+
initialCtx: {
|
|
355
|
+
type: 'TS_ANSWER',
|
|
356
|
+
tsAnsCtx: {
|
|
357
|
+
sessionId: 'sessionId',
|
|
358
|
+
genNo: 1,
|
|
359
|
+
stateKey: {
|
|
360
|
+
transactionId: 'transactionId',
|
|
361
|
+
generationNumber: 1,
|
|
362
|
+
},
|
|
363
|
+
worksheet: {
|
|
364
|
+
worksheetId: 'worksheetId',
|
|
365
|
+
worksheetName: 'GTM',
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
}),
|
|
372
|
+
JSON.stringify({
|
|
373
|
+
data: {
|
|
374
|
+
ConvAssist__sendMessage: {
|
|
375
|
+
responses: [
|
|
376
|
+
{
|
|
377
|
+
msgId: 'msgId',
|
|
378
|
+
data: {
|
|
379
|
+
asstRespData: {
|
|
380
|
+
tool: 'TS_NLS',
|
|
381
|
+
asstRespText: '',
|
|
382
|
+
nlsAnsData: {
|
|
383
|
+
sageQuerySuggestions: [
|
|
384
|
+
{
|
|
385
|
+
llmReasoning: {
|
|
386
|
+
assumptions: 'You want the total [COL|sales] for [COL|item_type] [VAL|jackets] for [VAL|this year].',
|
|
387
|
+
clarifications: '',
|
|
388
|
+
interpretation: '',
|
|
389
|
+
__typename: 'eureka_SageQuerySuggestion_LLMReasoning',
|
|
390
|
+
},
|
|
391
|
+
tokens: [
|
|
392
|
+
'sum sales',
|
|
393
|
+
"item type = 'jackets'",
|
|
394
|
+
"date = 'this year'",
|
|
395
|
+
],
|
|
396
|
+
tmlTokens: [
|
|
397
|
+
'sum [sales]',
|
|
398
|
+
"[date] = [date].'this year'",
|
|
399
|
+
"[item type] = [item type].'jackets'",
|
|
400
|
+
],
|
|
401
|
+
worksheetId: 'worksheetId',
|
|
402
|
+
description: '',
|
|
403
|
+
title: '',
|
|
404
|
+
cached: false,
|
|
405
|
+
sqlQuery: "SELECT SUM(sales) FROM __Sample_Retail_Apparel WHERE item_type = 'jackets' AND date = _this_year();",
|
|
406
|
+
sessionId: 'sessionId',
|
|
407
|
+
genNo: 2,
|
|
408
|
+
formulaInfo: [],
|
|
409
|
+
tmlPhrases: [],
|
|
410
|
+
stateKey: {
|
|
411
|
+
transactionId: 'transactionId',
|
|
412
|
+
generationNumber: 1,
|
|
413
|
+
__typename: 'sage_auto_complete_v2_ACStateKey',
|
|
414
|
+
},
|
|
415
|
+
__typename: 'eureka_SageQuerySuggestion',
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
responseType: 'ANSWER',
|
|
419
|
+
__typename: 'convassist_nls_tool_NLSToolAsstRespData',
|
|
420
|
+
},
|
|
421
|
+
__typename: 'convassist_AsstResponseData',
|
|
422
|
+
},
|
|
423
|
+
__typename: 'convassist_MessageData',
|
|
424
|
+
},
|
|
425
|
+
type: 'ASST_RESPONSE',
|
|
426
|
+
__typename: 'convassist_MessagePayload',
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
__typename: 'convassist_SendMessageResponse',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
}),
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
const viewConfig: SpotterAgentEmbedViewConfig = {
|
|
436
|
+
worksheetId: 'worksheetId',
|
|
437
|
+
hiddenActions: [Action.Download, Action.Save], // This should trigger the HideActions branch
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const spotterAgentEmbed = new SpotterAgentEmbed(viewConfig);
|
|
441
|
+
const result = await spotterAgentEmbed.sendMessage('userMessage');
|
|
442
|
+
|
|
443
|
+
// Verify the iframe src contains the hideActions parameter
|
|
444
|
+
const iframeSrc = getIFrameSrc(result.container);
|
|
445
|
+
expect(iframeSrc).toContain('hideAction');
|
|
446
|
+
});
|
|
140
447
|
});
|
|
@@ -8,14 +8,28 @@ import { getQueryParamString } from '../utils';
|
|
|
8
8
|
* Configuration for bodyless conversation options.
|
|
9
9
|
* @group Embed components
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
11
|
+
export interface SpotterAgentEmbedViewConfig extends ViewConfig {
|
|
12
12
|
/**
|
|
13
13
|
* The ID of the worksheet to use for the conversation.
|
|
14
14
|
*/
|
|
15
15
|
worksheetId: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Optional CSS class name to add to the container div.
|
|
19
|
+
*/
|
|
20
|
+
containerClassName?: string;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for conversation options.
|
|
25
|
+
* @deprecated from SDK: 1.38.0 | ThoughtSpot: 10.10.0.cl
|
|
26
|
+
* Use {@link SpotterAgentEmbedViewConfig} instead
|
|
27
|
+
* @group Embed components
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
30
|
+
export interface BodylessConversationViewConfig extends SpotterAgentEmbedViewConfig {}
|
|
31
|
+
|
|
32
|
+
interface SpotterAgentMessageViewConfig extends SpotterAgentEmbedViewConfig {
|
|
19
33
|
sessionId: string;
|
|
20
34
|
genNo: number;
|
|
21
35
|
acSessionId: string;
|
|
@@ -23,7 +37,7 @@ interface ConversationMessageViewConfig extends BodylessConversationViewConfig {
|
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
class ConversationMessage extends TsEmbed {
|
|
26
|
-
constructor(container: HTMLElement, protected viewConfig:
|
|
40
|
+
constructor(container: HTMLElement, protected viewConfig: SpotterAgentMessageViewConfig) {
|
|
27
41
|
viewConfig.embedComponentType = 'bodyless-conversation';
|
|
28
42
|
super(container, viewConfig);
|
|
29
43
|
}
|
|
@@ -39,6 +53,7 @@ class ConversationMessage extends TsEmbed {
|
|
|
39
53
|
const queryParams = this.getBaseQueryParams();
|
|
40
54
|
|
|
41
55
|
queryParams[Param.HideActions] = [...(queryParams[Param.HideActions] ?? [])];
|
|
56
|
+
queryParams[Param.isSpotterAgentEmbed] = true;
|
|
42
57
|
let query = '';
|
|
43
58
|
const queryParamsString = getQueryParamString(queryParams, true);
|
|
44
59
|
if (queryParamsString) {
|
|
@@ -68,9 +83,9 @@ class ConversationMessage extends TsEmbed {
|
|
|
68
83
|
* chatbots or other conversational interfaces.
|
|
69
84
|
* @example
|
|
70
85
|
* ```js
|
|
71
|
-
* import {
|
|
86
|
+
* import { SpotterAgentEmbed } from '@thoughtspot/visual-embed-sdk';
|
|
72
87
|
*
|
|
73
|
-
* const conversation = new
|
|
88
|
+
* const conversation = new SpotterAgentEmbed({
|
|
74
89
|
* worksheetId: 'worksheetId',
|
|
75
90
|
* });
|
|
76
91
|
*
|
|
@@ -80,12 +95,12 @@ class ConversationMessage extends TsEmbed {
|
|
|
80
95
|
* document.body.appendChild(container); // or to any other element
|
|
81
96
|
* ```
|
|
82
97
|
* @group Embed components
|
|
83
|
-
* @version SDK: 1.
|
|
98
|
+
* @version SDK: 1.37.0 | ThoughtSpot: 10.9.0.cl
|
|
84
99
|
*/
|
|
85
|
-
export class
|
|
100
|
+
export class SpotterAgentEmbed {
|
|
86
101
|
private conversationService: ConversationService;
|
|
87
102
|
|
|
88
|
-
constructor(private viewConfig:
|
|
103
|
+
constructor(private viewConfig: SpotterAgentEmbedViewConfig) {
|
|
89
104
|
const embedConfig = getEmbedConfig();
|
|
90
105
|
|
|
91
106
|
this.conversationService = new ConversationService(
|
|
@@ -101,6 +116,10 @@ export class BodylessConversation {
|
|
|
101
116
|
}
|
|
102
117
|
|
|
103
118
|
const container = document.createElement('div');
|
|
119
|
+
if (this.viewConfig.containerClassName) {
|
|
120
|
+
container.className = this.viewConfig.containerClassName;
|
|
121
|
+
}
|
|
122
|
+
|
|
104
123
|
const embed = new ConversationMessage(container, {
|
|
105
124
|
...this.viewConfig,
|
|
106
125
|
sessionId: data.sessionId,
|
|
@@ -112,3 +131,29 @@ export class BodylessConversation {
|
|
|
112
131
|
return { container, viz: embed };
|
|
113
132
|
}
|
|
114
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Create a conversation embed, which can be integrated inside
|
|
137
|
+
* chatbots or other conversational interfaces.
|
|
138
|
+
* @deprecated from SDK: 1.38.0 | ThoughtSpot: 10.10.0.cl
|
|
139
|
+
* Use {@link SpotterAgentEmbed} instead
|
|
140
|
+
* @example
|
|
141
|
+
* ```js
|
|
142
|
+
* import { SpotterAgentEmbed } from '@thoughtspot/visual-embed-sdk';
|
|
143
|
+
*
|
|
144
|
+
* const conversation = new SpotterAgentEmbed({
|
|
145
|
+
* worksheetId: 'worksheetId',
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* const { container, error } = await conversation.sendMessage('show me sales by region');
|
|
149
|
+
*
|
|
150
|
+
* // append the container to the DOM
|
|
151
|
+
* document.body.appendChild(container); // or to any other element
|
|
152
|
+
* ```
|
|
153
|
+
* @group Embed components
|
|
154
|
+
*/
|
|
155
|
+
export class BodylessConversation extends SpotterAgentEmbed {
|
|
156
|
+
constructor(viewConfig: BodylessConversationViewConfig) {
|
|
157
|
+
super(viewConfig);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
SpotterEmbed,
|
|
3
|
+
SpotterEmbedViewConfig,
|
|
4
4
|
} from './conversation';
|
|
5
5
|
import * as authInstance from '../auth';
|
|
6
6
|
import { init } from '../index';
|
|
@@ -28,14 +28,14 @@ beforeAll(() => {
|
|
|
28
28
|
|
|
29
29
|
describe('ConversationEmbed', () => {
|
|
30
30
|
it('should render the conversation embed', async () => {
|
|
31
|
-
const viewConfig:
|
|
31
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
32
32
|
worksheetId: 'worksheetId',
|
|
33
33
|
searchOptions: {
|
|
34
34
|
searchQuery: 'searchQuery',
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const conversationEmbed = new
|
|
38
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
39
39
|
await conversationEmbed.render();
|
|
40
40
|
expectUrlMatchesWithParams(
|
|
41
41
|
getIFrameSrc(),
|
|
@@ -44,7 +44,7 @@ describe('ConversationEmbed', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('should render the conversation embed with worksheets disabled', async () => {
|
|
47
|
-
const viewConfig:
|
|
47
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
48
48
|
worksheetId: 'worksheetId',
|
|
49
49
|
searchOptions: {
|
|
50
50
|
searchQuery: 'searchQuery',
|
|
@@ -52,7 +52,7 @@ describe('ConversationEmbed', () => {
|
|
|
52
52
|
disableSourceSelection: true,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const conversationEmbed = new
|
|
55
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
56
56
|
await conversationEmbed.render();
|
|
57
57
|
expectUrlMatchesWithParams(
|
|
58
58
|
getIFrameSrc(),
|
|
@@ -61,7 +61,7 @@ describe('ConversationEmbed', () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('should render the conversation embed with spotter limitations text if flag is set', async () => {
|
|
64
|
-
const viewConfig:
|
|
64
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
65
65
|
worksheetId: 'worksheetId',
|
|
66
66
|
searchOptions: {
|
|
67
67
|
searchQuery: 'searchQuery',
|
|
@@ -69,7 +69,7 @@ describe('ConversationEmbed', () => {
|
|
|
69
69
|
showSpotterLimitations: true,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
const conversationEmbed = new
|
|
72
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
73
73
|
await conversationEmbed.render();
|
|
74
74
|
expectUrlMatchesWithParams(
|
|
75
75
|
getIFrameSrc(),
|
|
@@ -78,7 +78,7 @@ describe('ConversationEmbed', () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it('should render the conversation embed with sample questions hidden', async () => {
|
|
81
|
-
const viewConfig:
|
|
81
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
82
82
|
worksheetId: 'worksheetId',
|
|
83
83
|
searchOptions: {
|
|
84
84
|
searchQuery: 'searchQuery',
|
|
@@ -86,7 +86,7 @@ describe('ConversationEmbed', () => {
|
|
|
86
86
|
hideSampleQuestions: true,
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
const conversationEmbed = new
|
|
89
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
90
90
|
await conversationEmbed.render();
|
|
91
91
|
expectUrlMatchesWithParams(
|
|
92
92
|
getIFrameSrc(),
|
|
@@ -95,7 +95,7 @@ describe('ConversationEmbed', () => {
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('should render the conversation embed with worksheets hidden', async () => {
|
|
98
|
-
const viewConfig:
|
|
98
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
99
99
|
worksheetId: 'worksheetId',
|
|
100
100
|
searchOptions: {
|
|
101
101
|
searchQuery: 'searchQuery',
|
|
@@ -103,7 +103,7 @@ describe('ConversationEmbed', () => {
|
|
|
103
103
|
hideSourceSelection: true,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
const conversationEmbed = new
|
|
106
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
107
107
|
await conversationEmbed.render();
|
|
108
108
|
expectUrlMatchesWithParams(
|
|
109
109
|
getIFrameSrc(),
|
|
@@ -112,13 +112,13 @@ describe('ConversationEmbed', () => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
it('should handle error when worksheetId is not provided', async () => {
|
|
115
|
-
const viewConfig:
|
|
115
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
116
116
|
worksheetId: '',
|
|
117
117
|
searchOptions: {
|
|
118
118
|
searchQuery: 'searchQuery',
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
|
-
const conversationEmbed = new
|
|
121
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
122
122
|
(conversationEmbed as any).handleError = jest.fn();
|
|
123
123
|
await conversationEmbed.render();
|
|
124
124
|
expect((conversationEmbed as any).handleError).toHaveBeenCalledWith(
|
|
@@ -127,7 +127,7 @@ describe('ConversationEmbed', () => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('should render the conversation embed if data panel v2 flag is true', async () => {
|
|
130
|
-
const viewConfig:
|
|
130
|
+
const viewConfig: SpotterEmbedViewConfig = {
|
|
131
131
|
worksheetId: 'worksheetId',
|
|
132
132
|
searchOptions: {
|
|
133
133
|
searchQuery: 'searchQuery',
|
|
@@ -135,7 +135,7 @@ describe('ConversationEmbed', () => {
|
|
|
135
135
|
dataPanelV2: true,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
const conversationEmbed = new
|
|
138
|
+
const conversationEmbed = new SpotterEmbed(getRootEl(), viewConfig);
|
|
139
139
|
await conversationEmbed.render();
|
|
140
140
|
expectUrlMatchesWithParams(
|
|
141
141
|
getIFrameSrc(),
|