@thoughtspot/visual-embed-sdk 1.35.1 → 1.35.2
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 +3 -15
- package/cjs/src/utils/processData.spec.js +0 -33
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +0 -15
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +3 -24
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +0 -132
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-BXczdQc7.js → index-DoPTJLbd.js} +1 -1
- package/dist/src/utils.d.ts +0 -15
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +3 -3
- package/dist/tsembed-react.js +2 -2
- package/dist/tsembed.es.js +3 -3
- package/dist/tsembed.js +2 -2
- package/lib/package.json +3 -15
- package/lib/src/utils/processData.spec.js +0 -33
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +0 -15
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +2 -20
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +1 -133
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +3 -15
- package/src/utils/processData.spec.ts +0 -42
- package/src/utils.spec.ts +1 -147
- package/src/utils.ts +2 -25
- package/cjs/src/embed/base.native.d.ts +0 -1
- package/cjs/src/embed/base.native.d.ts.map +0 -1
- package/cjs/src/embed/base.native.js +0 -1
- package/cjs/src/embed/base.native.js.map +0 -1
- package/cjs/src/embed/hello.d.ts +0 -2
- package/cjs/src/embed/hello.d.ts.map +0 -1
- package/cjs/src/embed/hello.js +0 -6
- package/cjs/src/embed/hello.js.map +0 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +0 -104
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
- package/cjs/src/native/LiveboardEmbed.d.ts +0 -13
- package/cjs/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/cjs/src/native/LiveboardEmbed.js +0 -146
- package/cjs/src/native/LiveboardEmbed.js.map +0 -1
- package/cjs/src/native/commonUtils.d.ts +0 -20
- package/cjs/src/native/commonUtils.d.ts.map +0 -1
- package/cjs/src/native/commonUtils.js +0 -175
- package/cjs/src/native/commonUtils.js.map +0 -1
- package/cjs/src/native/commonUtils.spec.d.ts +0 -2
- package/cjs/src/native/commonUtils.spec.d.ts.map +0 -1
- package/cjs/src/native/commonUtils.spec.js +0 -127
- package/cjs/src/native/commonUtils.spec.js.map +0 -1
- package/cjs/src/native/embedConfig.d.ts +0 -10
- package/cjs/src/native/embedConfig.d.ts.map +0 -1
- package/cjs/src/native/embedConfig.js +0 -12
- package/cjs/src/native/embedConfig.js.map +0 -1
- package/cjs/src/native/index.d.ts +0 -2
- package/cjs/src/native/index.d.ts.map +0 -1
- package/cjs/src/native/index.js +0 -7
- package/cjs/src/native/index.js.map +0 -1
- package/cjs/src/native/types.d.ts +0 -10
- package/cjs/src/native/types.d.ts.map +0 -1
- package/cjs/src/native/types.js +0 -3
- package/cjs/src/native/types.js.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.js +0 -60
- package/cjs/src/parsers/filtersToRuntimeFilters.js.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js +0 -205
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js.map +0 -1
- package/cjs/src/parsers/index.d.ts +0 -2
- package/cjs/src/parsers/index.d.ts.map +0 -1
- package/cjs/src/parsers/index.js +0 -6
- package/cjs/src/parsers/index.js.map +0 -1
- package/cjs/src/parsers/index.spec.d.ts +0 -2
- package/cjs/src/parsers/index.spec.d.ts.map +0 -1
- package/cjs/src/parsers/index.spec.js +0 -9
- package/cjs/src/parsers/index.spec.js.map +0 -1
- package/cjs/src/react-native/Liveboard.d.ts +0 -1
- package/cjs/src/react-native/Liveboard.d.ts.map +0 -1
- package/cjs/src/react-native/Liveboard.js +0 -1
- package/cjs/src/react-native/Liveboard.js.map +0 -1
- package/dist/index-Bh8kjZh8.js +0 -7370
- package/dist/src/embed/hello.d.ts +0 -2
- package/dist/src/embed/hello.d.ts.map +0 -1
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/dist/src/native/LiveboardEmbed.d.ts +0 -13
- package/dist/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/dist/src/native/commonUtils.d.ts +0 -20
- package/dist/src/native/commonUtils.d.ts.map +0 -1
- package/dist/src/native/commonUtils.spec.d.ts +0 -2
- package/dist/src/native/commonUtils.spec.d.ts.map +0 -1
- package/dist/src/native/embedConfig.d.ts +0 -10
- package/dist/src/native/embedConfig.d.ts.map +0 -1
- package/dist/src/native/index.d.ts +0 -2
- package/dist/src/native/index.d.ts.map +0 -1
- package/dist/src/native/types.d.ts +0 -10
- package/dist/src/native/types.d.ts.map +0 -1
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/dist/src/parsers/index.d.ts +0 -2
- package/dist/src/parsers/index.d.ts.map +0 -1
- package/dist/src/parsers/index.spec.d.ts +0 -2
- package/dist/src/parsers/index.spec.d.ts.map +0 -1
- package/dist/tsembed-parsers.es.js +0 -3831
- package/dist/tsembed-parsers.js +0 -3840
- package/lib/src/embed/base.native.d.ts +0 -1
- package/lib/src/embed/base.native.d.ts.map +0 -1
- package/lib/src/embed/base.native.js +0 -1
- package/lib/src/embed/base.native.js.map +0 -1
- package/lib/src/embed/hello.d.ts +0 -2
- package/lib/src/embed/hello.d.ts.map +0 -1
- package/lib/src/embed/hello.js +0 -2
- package/lib/src/embed/hello.js.map +0 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +0 -101
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
- package/lib/src/native/LiveboardEmbed.d.ts +0 -13
- package/lib/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/lib/src/native/LiveboardEmbed.js +0 -141
- package/lib/src/native/LiveboardEmbed.js.map +0 -1
- package/lib/src/native/commonUtils.d.ts +0 -20
- package/lib/src/native/commonUtils.d.ts.map +0 -1
- package/lib/src/native/commonUtils.js +0 -169
- package/lib/src/native/commonUtils.js.map +0 -1
- package/lib/src/native/commonUtils.spec.d.ts +0 -2
- package/lib/src/native/commonUtils.spec.d.ts.map +0 -1
- package/lib/src/native/commonUtils.spec.js +0 -124
- package/lib/src/native/commonUtils.spec.js.map +0 -1
- package/lib/src/native/embedConfig.d.ts +0 -10
- package/lib/src/native/embedConfig.d.ts.map +0 -1
- package/lib/src/native/embedConfig.js +0 -7
- package/lib/src/native/embedConfig.js.map +0 -1
- package/lib/src/native/index.d.ts +0 -2
- package/lib/src/native/index.d.ts.map +0 -1
- package/lib/src/native/index.js +0 -2
- package/lib/src/native/index.js.map +0 -1
- package/lib/src/native/types.d.ts +0 -10
- package/lib/src/native/types.d.ts.map +0 -1
- package/lib/src/native/types.js +0 -2
- package/lib/src/native/types.js.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.js +0 -55
- package/lib/src/parsers/filtersToRuntimeFilters.js.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js +0 -203
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js.map +0 -1
- package/lib/src/parsers/index.d.ts +0 -2
- package/lib/src/parsers/index.d.ts.map +0 -1
- package/lib/src/parsers/index.js +0 -2
- package/lib/src/parsers/index.js.map +0 -1
- package/lib/src/parsers/index.spec.d.ts +0 -2
- package/lib/src/parsers/index.spec.d.ts.map +0 -1
- package/lib/src/parsers/index.spec.js +0 -7
- package/lib/src/parsers/index.spec.js.map +0 -1
- package/lib/src/react-native/Liveboard.d.ts +0 -1
- package/lib/src/react-native/Liveboard.d.ts.map +0 -1
- package/lib/src/react-native/Liveboard.js +0 -1
- package/lib/src/react-native/Liveboard.js.map +0 -1
- package/src/native/commonUtils.spec.tsx +0 -161
- package/src/native/commonUtils.ts +0 -183
- package/src/native/index.ts +0 -1
- package/src/native/types.ts +0 -10
|
@@ -188,46 +188,4 @@ describe('Unit test for process data', () => {
|
|
|
188
188
|
expect(base.notifyAuthFailure).not.toBeCalled();
|
|
189
189
|
expect(el.innerHTML).not.toBe('Hello');
|
|
190
190
|
});
|
|
191
|
-
|
|
192
|
-
test('should return the event if type is unknown (default branch)', () => {
|
|
193
|
-
const unknownEvent = { type: 'SomeRandomEvent' };
|
|
194
|
-
const result = processDataInstance.processEventData(
|
|
195
|
-
'SomeRandomEvent' as any,
|
|
196
|
-
unknownEvent,
|
|
197
|
-
thoughtSpotHost,
|
|
198
|
-
null,
|
|
199
|
-
);
|
|
200
|
-
expect(result).toBe(unknownEvent);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test('processAuthInit uses e.payload.userGUID if e.data.userGUID is missing', () => {
|
|
204
|
-
const e = {
|
|
205
|
-
type: EmbedEvent.AuthInit,
|
|
206
|
-
payload: { userGUID: 'payload-guid' },
|
|
207
|
-
data: {},
|
|
208
|
-
};
|
|
209
|
-
jest.spyOn(base, 'notifyAuthSuccess').mockImplementation(() => {});
|
|
210
|
-
const result = processDataInstance.processEventData(e.type, e, '', null);
|
|
211
|
-
expect(result.data.userGUID).toBe('payload-guid');
|
|
212
|
-
expect(base.notifyAuthSuccess).toHaveBeenCalled();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test('NoCookieAccess with suppressErrorAlerts=true does not alert', () => {
|
|
216
|
-
const e = { type: EmbedEvent.NoCookieAccess };
|
|
217
|
-
const el: any = {};
|
|
218
|
-
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
219
|
-
loginFailedMessage: 'Cookie blocked!',
|
|
220
|
-
suppressNoCookieAccessAlert: false,
|
|
221
|
-
suppressErrorAlerts: true,
|
|
222
|
-
ignoreNoCookieAccess: false,
|
|
223
|
-
});
|
|
224
|
-
jest.spyOn(window, 'alert').mockImplementation(() => {});
|
|
225
|
-
jest.spyOn(base, 'notifyAuthFailure');
|
|
226
|
-
|
|
227
|
-
const result = processDataInstance.processEventData(e.type, e, '', el);
|
|
228
|
-
expect(result).toEqual({ type: e.type });
|
|
229
|
-
expect(window.alert).not.toHaveBeenCalled();
|
|
230
|
-
expect(el.innerHTML).toBe('Cookie blocked!');
|
|
231
|
-
expect(base.notifyAuthFailure).toHaveBeenCalled();
|
|
232
|
-
});
|
|
233
191
|
});
|
package/src/utils.spec.ts
CHANGED
|
@@ -11,10 +11,8 @@ import {
|
|
|
11
11
|
removeStyleProperties,
|
|
12
12
|
setStyleProperties,
|
|
13
13
|
isUndefined,
|
|
14
|
-
getCustomisationsMobileEmbed,
|
|
15
14
|
} from './utils';
|
|
16
|
-
import {
|
|
17
|
-
import { WebViewConfig } from './native/types';
|
|
15
|
+
import { RuntimeFilterOp } from './types';
|
|
18
16
|
|
|
19
17
|
describe('unit test for utils', () => {
|
|
20
18
|
test('getQueryParamString', () => {
|
|
@@ -275,147 +273,3 @@ describe('unit test for utils', () => {
|
|
|
275
273
|
expect(isUndefined({})).toBe(false);
|
|
276
274
|
});
|
|
277
275
|
});
|
|
278
|
-
|
|
279
|
-
describe('getCustomisationsMobileEmbed', () => {
|
|
280
|
-
it('should return empty style and content if no customizations are defined', () => {
|
|
281
|
-
const embedConfig: Partial<WebViewConfig> = {};
|
|
282
|
-
|
|
283
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
284
|
-
expect(result).toEqual({
|
|
285
|
-
style: {
|
|
286
|
-
customCSS: {},
|
|
287
|
-
customCSSUrl: undefined,
|
|
288
|
-
},
|
|
289
|
-
content: {},
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('should use embedConfig.customizations when present', () => {
|
|
294
|
-
const embedConfig: Partial<WebViewConfig> = {
|
|
295
|
-
customizations: {
|
|
296
|
-
style: {
|
|
297
|
-
customCSS: {
|
|
298
|
-
rules_UNSTABLE: {
|
|
299
|
-
'.title': { fontSize: '20px' },
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
customCSSUrl: 'http://example.com/styles.css',
|
|
303
|
-
},
|
|
304
|
-
content: {
|
|
305
|
-
headerText: 'Hello World',
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
311
|
-
expect(result).toEqual({
|
|
312
|
-
style: {
|
|
313
|
-
customCSS: {
|
|
314
|
-
rules_UNSTABLE: {
|
|
315
|
-
'.title': { fontSize: '20px' },
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
customCSSUrl: 'http://example.com/styles.css',
|
|
319
|
-
},
|
|
320
|
-
content: {
|
|
321
|
-
headerText: 'Hello World',
|
|
322
|
-
},
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('should fallback to embedConfig.customisations if customizations is undefined', () => {
|
|
327
|
-
const embedConfig: Partial<WebViewConfig> = {
|
|
328
|
-
customizations: {
|
|
329
|
-
style: {
|
|
330
|
-
backgroundColor: 'green',
|
|
331
|
-
customCSS: { '.anotherClass': { color: 'white' } },
|
|
332
|
-
},
|
|
333
|
-
content: {
|
|
334
|
-
footerText: 'Footer content',
|
|
335
|
-
},
|
|
336
|
-
} as CustomisationsInterface,
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
340
|
-
expect(result).toEqual({
|
|
341
|
-
style: {
|
|
342
|
-
backgroundColor: 'green',
|
|
343
|
-
customCSS: { '.anotherClass': { color: 'white' } },
|
|
344
|
-
customCSSUrl: undefined,
|
|
345
|
-
},
|
|
346
|
-
content: {
|
|
347
|
-
footerText: 'Footer content',
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('should merge style objects correctly (customCSS stays as an object)', () => {
|
|
353
|
-
const embedConfig: Partial<WebViewConfig> = {
|
|
354
|
-
customizations: {
|
|
355
|
-
style: {
|
|
356
|
-
customCSS: {
|
|
357
|
-
rules_UNSTABLE: {
|
|
358
|
-
'.title': { fontSize: '20px' },
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
customCSSUrl: 'http://example.com/old-styles.css',
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
367
|
-
expect(result).toEqual({
|
|
368
|
-
style: {
|
|
369
|
-
customCSS: {
|
|
370
|
-
rules_UNSTABLE: {
|
|
371
|
-
'.title': { fontSize: '20px' },
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
customCSSUrl: 'http://example.com/old-styles.css',
|
|
375
|
-
},
|
|
376
|
-
content: {},
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it('should handle missing style or content keys gracefully', () => {
|
|
381
|
-
const embedConfig: Partial<WebViewConfig> = {
|
|
382
|
-
customizations: {
|
|
383
|
-
style: undefined, // style is missing
|
|
384
|
-
content: undefined, // content is missing
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
389
|
-
expect(result).toEqual({
|
|
390
|
-
style: {
|
|
391
|
-
customCSS: {},
|
|
392
|
-
customCSSUrl: undefined,
|
|
393
|
-
},
|
|
394
|
-
content: {},
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it('should override customCSSUrl with embedConfig.customizations.style.customCSSUrl if defined', () => {
|
|
399
|
-
const embedConfig: Partial<WebViewConfig> = {
|
|
400
|
-
customizations: {
|
|
401
|
-
style: {
|
|
402
|
-
customCSSUrl: 'http://example.com/custom.css',
|
|
403
|
-
customCSS: {
|
|
404
|
-
rules_UNSTABLE: {
|
|
405
|
-
'.title': { fontSize: '20px' },
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
const result = getCustomisationsMobileEmbed(embedConfig as WebViewConfig);
|
|
413
|
-
expect(result.style?.customCSSUrl).toBe('http://example.com/custom.css');
|
|
414
|
-
expect(result.style?.customCSS).toEqual({
|
|
415
|
-
rules_UNSTABLE: {
|
|
416
|
-
'.title': { fontSize: '20px' },
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
|
package/src/utils.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
ViewConfig,
|
|
17
17
|
RuntimeParameter,
|
|
18
18
|
} from './types';
|
|
19
|
-
import { WebViewConfig } from './native/types';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Construct a runtime filters query string from the given filters.
|
|
@@ -74,7 +73,7 @@ export const getRuntimeParameters = (runtimeParameters: RuntimeParameter[]): str
|
|
|
74
73
|
* parameter to the ThoughtSpot app.
|
|
75
74
|
* @param value Any parameter value
|
|
76
75
|
*/
|
|
77
|
-
|
|
76
|
+
const serializeParam = (value: any) => {
|
|
78
77
|
// do not serialize primitive types
|
|
79
78
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
80
79
|
return value;
|
|
@@ -89,7 +88,7 @@ export const serializeParam = (value: any) => {
|
|
|
89
88
|
* in case of any other type, we directly return the value.
|
|
90
89
|
* @param value
|
|
91
90
|
*/
|
|
92
|
-
|
|
91
|
+
const paramToString = (value: any) => (Array.isArray(value) ? value.join(',') : value);
|
|
93
92
|
|
|
94
93
|
/**
|
|
95
94
|
* Return a query param string composed from the given params object
|
|
@@ -243,28 +242,6 @@ export const getCustomisations = (
|
|
|
243
242
|
return customizations;
|
|
244
243
|
};
|
|
245
244
|
|
|
246
|
-
export const getCustomisationsMobileEmbed = (
|
|
247
|
-
embedConfig: WebViewConfig,
|
|
248
|
-
): CustomisationsInterface => {
|
|
249
|
-
const customizationsFromEmbedConfig = embedConfig.customizations
|
|
250
|
-
|| ((embedConfig as any).customisations as CustomisationsInterface);
|
|
251
|
-
|
|
252
|
-
const customizations: CustomisationsInterface = {
|
|
253
|
-
style: {
|
|
254
|
-
...customizationsFromEmbedConfig?.style,
|
|
255
|
-
customCSS: {
|
|
256
|
-
...customizationsFromEmbedConfig?.style?.customCSS,
|
|
257
|
-
},
|
|
258
|
-
customCSSUrl:
|
|
259
|
-
customizationsFromEmbedConfig?.style?.customCSSUrl,
|
|
260
|
-
},
|
|
261
|
-
content: {
|
|
262
|
-
...customizationsFromEmbedConfig?.content,
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
return customizations;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
245
|
export const getRuntimeFilters = (runtimefilters: any) => getFilterQuery(runtimefilters || []);
|
|
269
246
|
|
|
270
247
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=base.native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.native.d.ts","sourceRoot":"","sources":["../../../src/embed/base.native.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=base.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.native.js","sourceRoot":"","sources":["../../../src/embed/base.native.ts"],"names":[],"mappings":""}
|
package/cjs/src/embed/hello.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../../src/embed/hello.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAAO,MAAgB,CAAC"}
|
package/cjs/src/embed/hello.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hello.js","sourceRoot":"","sources":["../../../src/embed/hello.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,GAAW,EAAE,CAAC,MAAM,CAAC;AAArC,QAAA,aAAa,iBAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchEmbed-basic-auth.spec.d.ts","sourceRoot":"","sources":["../../../src/embed/searchEmbed-basic-auth.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const search_1 = require("./search");
|
|
5
|
-
const baseInstance = tslib_1.__importStar(require("./base"));
|
|
6
|
-
const authService = tslib_1.__importStar(require("../utils/authService"));
|
|
7
|
-
const authInstance = tslib_1.__importStar(require("../auth"));
|
|
8
|
-
const config = tslib_1.__importStar(require("../config"));
|
|
9
|
-
const embedConfigInstance = tslib_1.__importStar(require("./embedConfig"));
|
|
10
|
-
const index_1 = require("../index");
|
|
11
|
-
const types_1 = require("../types");
|
|
12
|
-
const test_utils_1 = require("../test/test-utils");
|
|
13
|
-
const auth_spec_1 = require("../auth.spec");
|
|
14
|
-
const thoughtSpotHost = 'tshost';
|
|
15
|
-
(0, index_1.init)({
|
|
16
|
-
thoughtSpotHost,
|
|
17
|
-
authType: types_1.AuthType.Basic,
|
|
18
|
-
username: 'tsadmin',
|
|
19
|
-
password: 'admin',
|
|
20
|
-
});
|
|
21
|
-
describe('Search embed tests when authType is Basic', () => {
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param version
|
|
25
|
-
*/
|
|
26
|
-
function setupVersion(version) {
|
|
27
|
-
jest.spyOn(window, 'addEventListener').mockImplementation((event, handler, options) => {
|
|
28
|
-
handler({
|
|
29
|
-
data: {
|
|
30
|
-
type: 'xyz',
|
|
31
|
-
},
|
|
32
|
-
ports: [3000],
|
|
33
|
-
source: null,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
37
|
-
json: () => ({
|
|
38
|
-
...auth_spec_1.mockSessionInfo,
|
|
39
|
-
releaseVersion: version,
|
|
40
|
-
}),
|
|
41
|
-
status: 200,
|
|
42
|
-
}));
|
|
43
|
-
jest.spyOn(authInstance, 'getReleaseVersion').mockReturnValue(version);
|
|
44
|
-
}
|
|
45
|
-
beforeEach(() => {
|
|
46
|
-
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
|
|
47
|
-
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValue(true);
|
|
48
|
-
});
|
|
49
|
-
afterEach(() => {
|
|
50
|
-
jest.clearAllMocks();
|
|
51
|
-
});
|
|
52
|
-
test('when releaseVersion is empty', async () => {
|
|
53
|
-
setupVersion('');
|
|
54
|
-
const mockAlert = spyOn(window, 'alert');
|
|
55
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
56
|
-
await searchEmbed.render();
|
|
57
|
-
expect(mockAlert).not.toBeCalled();
|
|
58
|
-
});
|
|
59
|
-
test("when releaseVersion is '7.0.1.cl' ", async () => {
|
|
60
|
-
setupVersion('7.0.1.cl');
|
|
61
|
-
const mockAlert = jest.spyOn(window, 'alert');
|
|
62
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
63
|
-
await searchEmbed.render();
|
|
64
|
-
expect(mockAlert).not.toBeCalled();
|
|
65
|
-
});
|
|
66
|
-
test('when releaseVersion is above 8.4.0.sw', async () => {
|
|
67
|
-
setupVersion('8.4.0.sw');
|
|
68
|
-
const mockAlert = jest.spyOn(window, 'alert');
|
|
69
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
70
|
-
await searchEmbed.render();
|
|
71
|
-
expect(mockAlert).not.toBeCalled();
|
|
72
|
-
});
|
|
73
|
-
test('releaseVersion is above 8.4.0.sw', async () => {
|
|
74
|
-
setupVersion('8.8.0.sw');
|
|
75
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
76
|
-
const mockAlert = jest.spyOn(window, 'alert');
|
|
77
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
78
|
-
await searchEmbed.render();
|
|
79
|
-
expect(mockAlert).not.toBeCalled();
|
|
80
|
-
});
|
|
81
|
-
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is ts7.dec.cl', async () => {
|
|
82
|
-
setupVersion('ts7.dec.cl');
|
|
83
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
84
|
-
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
85
|
-
suppressSearchEmbedBetaWarning: true,
|
|
86
|
-
});
|
|
87
|
-
const mockAlert = jest.spyOn(window, 'alert');
|
|
88
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
89
|
-
await searchEmbed.render();
|
|
90
|
-
expect(mockAlert).not.toBeCalled();
|
|
91
|
-
});
|
|
92
|
-
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is 8.4.0.sw', async () => {
|
|
93
|
-
setupVersion('8.4.0.sw');
|
|
94
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
95
|
-
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
96
|
-
suppressSearchEmbedBetaWarning: true,
|
|
97
|
-
});
|
|
98
|
-
const mockAlert = jest.spyOn(window, 'alert');
|
|
99
|
-
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
100
|
-
await searchEmbed.render();
|
|
101
|
-
expect(mockAlert).not.toBeCalled();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
//# sourceMappingURL=searchEmbed-basic-auth.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchEmbed-basic-auth.spec.js","sourceRoot":"","sources":["../../../src/embed/searchEmbed-basic-auth.spec.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,6DAAuC;AACvC,0EAAoD;AACpD,8DAAwC;AACxC,0DAAoC;AACpC,2EAAqD;AAErD,oCAAgC;AAChC,oCAAoC;AACpC,mDAAgE;AAChE,4CAA+C;AAG/C,MAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAA,YAAI,EAAC;IACD,eAAe;IACf,QAAQ,EAAE,gBAAQ,CAAC,KAAK;IACxB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,OAAO;CACpB,CAAC,CAAC;AAEH,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACvD;;;OAGG;IACH,SAAS,YAAY,CAAC,OAAe;QACjC,IAAI,CAAC,K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D,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export type LiveboardEmbedProps = {
|
|
3
|
-
liveboardId: string;
|
|
4
|
-
getToken: () => Promise<string>;
|
|
5
|
-
};
|
|
6
|
-
export declare enum Param {
|
|
7
|
-
Version = "sdkVersion"
|
|
8
|
-
}
|
|
9
|
-
export type QueryParams = {
|
|
10
|
-
[key: string]: string | boolean | number;
|
|
11
|
-
};
|
|
12
|
-
export declare const LiveboardEmbed: React.FC<LiveboardEmbedProps>;
|
|
13
|
-
//# sourceMappingURL=LiveboardEmbed.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LiveboardEmbed.d.ts","sourceRoot":"","sources":["../../../src/native/LiveboardEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAS3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC;AAEF,oBAAY,KAAK;IACb,OAAO,eAAe;CACzB;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkKxD,CAAC"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LiveboardEmbed = exports.Param = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const react_native_webview_1 = tslib_1.__importDefault(require("react-native-webview"));
|
|
8
|
-
const embedConfig_1 = require("./embedConfig");
|
|
9
|
-
const auth_spec_1 = require("src/auth.spec");
|
|
10
|
-
const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
|
|
11
|
-
const utils_1 = require("src/utils");
|
|
12
|
-
const { version } = package_json_1.default;
|
|
13
|
-
var Param;
|
|
14
|
-
(function (Param) {
|
|
15
|
-
Param["Version"] = "sdkVersion";
|
|
16
|
-
})(Param = exports.Param || (exports.Param = {}));
|
|
17
|
-
const LiveboardEmbed = ({ liveboardId, getToken }) => {
|
|
18
|
-
const webViewRef = (0, react_1.useRef)(null);
|
|
19
|
-
const [embedUrl, setEmbedUrl] = (0, react_1.useState)("");
|
|
20
|
-
const [webViewLoaded, setWebViewLoaded] = (0, react_1.useState)(false);
|
|
21
|
-
const getEmbedParamsString = () => {
|
|
22
|
-
const queryparamsH = getBaseQueryParams();
|
|
23
|
-
return getQueryParamString(queryparamsH);
|
|
24
|
-
};
|
|
25
|
-
const getEmbedBasePath = (query) => {
|
|
26
|
-
let queryString = (query.startsWith('?')) ? query : `?${query}`;
|
|
27
|
-
queryString = `?base64UrlEncodedFlags=${(0, utils_1.getEncodedQueryParamsString)(queryString.substr(1))}`;
|
|
28
|
-
const basePath = [auth_spec_1.embedConfig === null || auth_spec_1.embedConfig === void 0 ? void 0 : auth_spec_1.embedConfig.host, queryString]
|
|
29
|
-
.filter((x) => x.length > 0)
|
|
30
|
-
.join('/');
|
|
31
|
-
return `${basePath}#`;
|
|
32
|
-
};
|
|
33
|
-
const getRootWebViewSrc = () => {
|
|
34
|
-
const query = getEmbedParamsString();
|
|
35
|
-
return getEmbedBasePath(query);
|
|
36
|
-
};
|
|
37
|
-
const getQueryParamString = (queryParams, shouldSerializeParamValues = false) => {
|
|
38
|
-
const qp = [];
|
|
39
|
-
const params = Object.keys(queryParams);
|
|
40
|
-
params.forEach((key) => {
|
|
41
|
-
const val = queryParams[key];
|
|
42
|
-
if (val !== undefined) {
|
|
43
|
-
const serializedValue = shouldSerializeParamValues
|
|
44
|
-
? (0, utils_1.serializeParam)(val)
|
|
45
|
-
: (0, utils_1.paramToString)(val);
|
|
46
|
-
qp.push(`${key}=${serializedValue}`);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
if (qp.length) {
|
|
50
|
-
return qp.join('&');
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
};
|
|
54
|
-
const getBaseQueryParams = (queryParams = {}) => {
|
|
55
|
-
var _a;
|
|
56
|
-
let hostAppUrl = ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) || '';
|
|
57
|
-
if (hostAppUrl.includes('localhost') || hostAppUrl.includes('127.0.0.1')) {
|
|
58
|
-
hostAppUrl = 'local-host';
|
|
59
|
-
}
|
|
60
|
-
queryParams[Param.Version] = version;
|
|
61
|
-
return queryParams;
|
|
62
|
-
};
|
|
63
|
-
const handleAppInit = async () => {
|
|
64
|
-
const authToken = await getToken();
|
|
65
|
-
const initPayload = {
|
|
66
|
-
type: "appInit",
|
|
67
|
-
data: {
|
|
68
|
-
host: auth_spec_1.embedConfig === null || auth_spec_1.embedConfig === void 0 ? void 0 : auth_spec_1.embedConfig.host,
|
|
69
|
-
authToken,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
const jsCode = `
|
|
73
|
-
window.postMessage(${JSON.stringify(initPayload)});
|
|
74
|
-
`;
|
|
75
|
-
if (webViewRef.current && webViewLoaded) {
|
|
76
|
-
webViewRef.current.injectJavaScript(jsCode);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
// Generate embed URL
|
|
80
|
-
const constructEmbedUrl = async () => {
|
|
81
|
-
const embedConfig = (0, embedConfig_1.getEmbedConfig)();
|
|
82
|
-
const host = (embedConfig === null || embedConfig === void 0 ? void 0 : embedConfig.host) || "";
|
|
83
|
-
const url = `${host}/?authType=AuthServerCookieless#/embed/liveboard/${liveboardId}`;
|
|
84
|
-
setEmbedUrl(url);
|
|
85
|
-
};
|
|
86
|
-
// Handle messages from the WebView
|
|
87
|
-
const handleOnMessage = (event) => {
|
|
88
|
-
try {
|
|
89
|
-
const message = JSON.parse(event.nativeEvent.data);
|
|
90
|
-
switch (message.type) {
|
|
91
|
-
case "AppInit":
|
|
92
|
-
handleAppInit();
|
|
93
|
-
break;
|
|
94
|
-
case "AuthExpiry" || "ThoughtspotAuthExpired":
|
|
95
|
-
handleAuthExpiry();
|
|
96
|
-
break;
|
|
97
|
-
case "CustomEvent":
|
|
98
|
-
console.log("Custom event received:", message.data);
|
|
99
|
-
break;
|
|
100
|
-
default:
|
|
101
|
-
console.warn("Unhandled message type:", message.type);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
console.error("Failed to handle message from WebView:", error);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
// Handle auth token expiry
|
|
109
|
-
const handleAuthExpiry = async () => {
|
|
110
|
-
var _a;
|
|
111
|
-
const authToken = await getToken();
|
|
112
|
-
const payload = {
|
|
113
|
-
type: "AuthExpiry",
|
|
114
|
-
data: { authToken },
|
|
115
|
-
};
|
|
116
|
-
(_a = webViewRef.current) === null || _a === void 0 ? void 0 : _a.injectJavaScript(`
|
|
117
|
-
window.postMessage(${JSON.stringify(payload)}, "*");
|
|
118
|
-
`);
|
|
119
|
-
};
|
|
120
|
-
(0, react_1.useEffect)(() => {
|
|
121
|
-
constructEmbedUrl();
|
|
122
|
-
}, []);
|
|
123
|
-
if (!embedUrl) {
|
|
124
|
-
return (react_1.default.createElement(react_native_1.View, { style: styles.loadingContainer },
|
|
125
|
-
react_1.default.createElement(react_native_1.Text, null, "Loading Liveboard...")));
|
|
126
|
-
}
|
|
127
|
-
return (react_1.default.createElement(react_native_webview_1.default, { ref: webViewRef, source: { uri: embedUrl }, style: styles.webview, onMessage: handleOnMessage, onLoadStart: () => console.log('WebView load started'), injectedJavaScriptBeforeContentLoaded: `
|
|
128
|
-
window.ReactNativeWebView = {
|
|
129
|
-
postMessage: function(data) {
|
|
130
|
-
window.postMessage(data, '*');
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
`, onLoad: () => setWebViewLoaded(true), javaScriptEnabled: true, domStorageEnabled: true, cacheEnabled: false, originWhitelist: ["*"], onHttpError: (event) => console.log("HTTP Error: ", event.nativeEvent), onError: (event) => console.error("WebView Error: ", event.nativeEvent) }));
|
|
134
|
-
};
|
|
135
|
-
exports.LiveboardEmbed = LiveboardEmbed;
|
|
136
|
-
const styles = react_native_1.StyleSheet.create({
|
|
137
|
-
webview: {
|
|
138
|
-
flex: 1,
|
|
139
|
-
},
|
|
140
|
-
loadingContainer: {
|
|
141
|
-
flex: 1,
|
|
142
|
-
justifyContent: "center",
|
|
143
|
-
alignItems: "center",
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
//# sourceMappingURL=LiveboardEmbed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LiveboardEmbed.js","sourceRoot":"","sources":["../../../src/native/LiveboardEmbed.tsx"],"names":[],"mappings":";;;;AAAA,uDAA2D;AAC3D,+CAAsD;AACtD,wFAAoE;AACpE,+CAA+C;AAC/C,6CAA4C;AAC5C,8EAAyC;AACzC,qCAAuF;AACvF,MAAM,EAAE,OAAO,EAAE,GAAG,sBAAO,CAAC;AAO5B,IAAY,KAEX;AAFD,WAAY,KAAK;IACb,+BAAsB,CAAA;AAC1B,CAAC,EAFW,KAAK,GAAL,aAAK,KAAL,aAAK,QAEhB;AAOM,MAAM,cAAc,GAAkC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,IAAA,cAAM,EAAU,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,I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;QAChB,IAAI,EAAE,CAAC;QACP,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { WebViewConfig } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* This method constructs the webview URL with given config.
|
|
4
|
-
* @param config To get the webviewURL pass the necessary config options.
|
|
5
|
-
* host: string;
|
|
6
|
-
* authType: AuthType;
|
|
7
|
-
* liveboardId: string;
|
|
8
|
-
* getAuthToken: () => Promise<string>;
|
|
9
|
-
* These four are necessary arguments.
|
|
10
|
-
* @returns The Promise for WebView URL.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getWebViewUrl: (config: WebViewConfig) => Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* setting up message handling for the message replies to TS instances.
|
|
15
|
-
* @param config The webview config
|
|
16
|
-
* @param event The message event from the WebView.
|
|
17
|
-
* @param WebViewRef Ref to use and inject javascript
|
|
18
|
-
*/
|
|
19
|
-
export declare const setupWebViewMessageHandler: (config: WebViewConfig, event: any, webViewRef: any) => Promise<void>;
|
|
20
|
-
//# sourceMappingURL=commonUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commonUtils.d.ts","sourceRoot":"","sources":["../../../src/native/commonUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,WAAkB,aAAa,KAAG,QAAQ,MAAM,CA+BzE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,WAC3B,aAAa,SACd,GAAG,cACE,GAAG,kBA2ElB,CAAC"}
|