@thoughtspot/visual-embed-sdk 1.27.0-alpha.2 → 1.27.0-alpha.4
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/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +5 -4
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +3 -2
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +5 -4
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +5 -2
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +3 -2
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +2 -1
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts +2 -1
- package/cjs/src/embed/embedConfig.d.ts.map +1 -1
- package/cjs/src/embed/embedConfig.js +2 -0
- package/cjs/src/embed/embedConfig.js.map +1 -1
- package/cjs/src/embed/events.spec.js +3 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +7 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +4 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +2 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +13 -10
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +27 -26
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +2 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +2 -1
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/react/index.d.ts +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +2 -2
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +66 -4
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +50 -1
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +3 -2
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +3 -2
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js +2 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +2 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/logger.d.ts +18 -0
- package/cjs/src/utils/logger.d.ts.map +1 -0
- package/cjs/src/utils/logger.js +80 -0
- package/cjs/src/utils/logger.js.map +1 -0
- package/cjs/src/utils/logger.spec.d.ts +25 -0
- package/cjs/src/utils/logger.spec.d.ts.map +1 -0
- package/cjs/src/utils/logger.spec.js +116 -0
- package/cjs/src/utils/logger.spec.js.map +1 -0
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts +2 -1
- package/dist/src/embed/embedConfig.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +7 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +66 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts +18 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.spec.d.ts +25 -0
- package/dist/src/utils/logger.spec.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +193 -48
- package/dist/tsembed-react.js +191 -47
- package/dist/tsembed.es.js +516 -365
- package/dist/tsembed.js +14959 -14809
- package/dist/visual-embed-sdk-react-full.d.ts +76 -6
- package/dist/visual-embed-sdk-react.d.ts +76 -6
- package/dist/visual-embed-sdk.d.ts +76 -6
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +5 -4
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +3 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +5 -4
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +6 -3
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +3 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts +2 -1
- package/lib/src/embed/embedConfig.d.ts.map +1 -1
- package/lib/src/embed/embedConfig.js +2 -0
- package/lib/src/embed/embedConfig.js.map +1 -1
- package/lib/src/embed/events.spec.js +3 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +7 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +4 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +2 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +13 -10
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +27 -26
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +2 -1
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/react/index.d.ts +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +1 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +2 -2
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +66 -4
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +49 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +3 -2
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +3 -2
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.js +2 -1
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +2 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/logger.d.ts +18 -0
- package/lib/src/utils/logger.d.ts.map +1 -0
- package/lib/src/utils/logger.js +74 -0
- package/lib/src/utils/logger.js.map +1 -0
- package/lib/src/utils/logger.spec.d.ts +25 -0
- package/lib/src/utils/logger.spec.d.ts.map +1 -0
- package/lib/src/utils/logger.spec.js +93 -0
- package/lib/src/utils/logger.spec.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +77 -7
- package/package.json +1 -1
- package/src/auth.ts +5 -4
- package/src/embed/app.spec.ts +5 -4
- package/src/embed/app.ts +3 -2
- package/src/embed/base.spec.ts +3 -2
- package/src/embed/base.ts +10 -3
- package/src/embed/embed.spec.ts +2 -1
- package/src/embed/embedConfig.ts +2 -0
- package/src/embed/events.spec.ts +3 -2
- package/src/embed/liveboard.spec.ts +2 -1
- package/src/embed/liveboard.ts +11 -0
- package/src/embed/ts-embed.spec.ts +27 -26
- package/src/embed/ts-embed.ts +20 -16
- package/src/index.ts +2 -0
- package/src/mixpanel-service.ts +2 -1
- package/src/react/index.spec.tsx +2 -2
- package/src/react/index.tsx +1 -0
- package/src/types.ts +65 -0
- package/src/utils/authService/authService.spec.ts +3 -2
- package/src/utils/authService/authService.ts +4 -2
- package/src/utils/authService/tokenizedAuthService.ts +2 -1
- package/src/utils/graphql/answerService/answerService.spec.ts +2 -0
- package/src/utils/graphql/answerService/answerService.ts +3 -1
- package/src/utils/logger.spec.ts +108 -0
- package/src/utils/logger.ts +88 -0
- package/cjs/.DS_Store +0 -0
- package/cjs/src/.DS_Store +0 -0
- package/cjs/src/utils/answerService.d.ts +0 -10
- package/cjs/src/utils/answerService.d.ts.map +0 -1
- package/cjs/src/utils/answerService.js +0 -61
- package/cjs/src/utils/answerService.js.map +0 -1
- package/cjs/src/utils/answerService.spec.d.ts +0 -2
- package/cjs/src/utils/answerService.spec.d.ts.map +0 -1
- package/cjs/src/utils/answerService.spec.js +0 -31
- package/cjs/src/utils/answerService.spec.js.map +0 -1
- package/cjs/src/utils/authService.d.ts +0 -37
- package/cjs/src/utils/authService.d.ts.map +0 -1
- package/cjs/src/utils/authService.js +0 -106
- package/cjs/src/utils/authService.js.map +0 -1
- package/cjs/src/utils/authService.spec.d.ts +0 -2
- package/cjs/src/utils/authService.spec.d.ts.map +0 -1
- package/cjs/src/utils/authService.spec.js +0 -72
- package/cjs/src/utils/authService.spec.js.map +0 -1
- package/dist/src/utils/answerService.d.ts +0 -10
- package/dist/src/utils/answerService.d.ts.map +0 -1
- package/dist/src/utils/answerService.spec.d.ts +0 -2
- package/dist/src/utils/answerService.spec.d.ts.map +0 -1
- package/dist/src/utils/authService.d.ts +0 -37
- package/dist/src/utils/authService.d.ts.map +0 -1
- package/dist/src/utils/authService.spec.d.ts +0 -2
- package/dist/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/.DS_Store +0 -0
- package/lib/src/.DS_Store +0 -0
- package/lib/src/utils/answerService.d.ts +0 -10
- package/lib/src/utils/answerService.d.ts.map +0 -1
- package/lib/src/utils/answerService.js +0 -57
- package/lib/src/utils/answerService.js.map +0 -1
- package/lib/src/utils/answerService.spec.d.ts +0 -2
- package/lib/src/utils/answerService.spec.d.ts.map +0 -1
- package/lib/src/utils/answerService.spec.js +0 -29
- package/lib/src/utils/answerService.spec.js.map +0 -1
- package/lib/src/utils/authService.d.ts +0 -37
- package/lib/src/utils/authService.d.ts.map +0 -1
- package/lib/src/utils/authService.js +0 -97
- package/lib/src/utils/authService.js.map +0 -1
- package/lib/src/utils/authService.spec.d.ts +0 -2
- package/lib/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/src/utils/authService.spec.js +0 -70
- package/lib/src/utils/authService.spec.js.map +0 -1
- package/src/.DS_Store +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
let logger;
|
|
2
|
+
let LogLevel;
|
|
3
|
+
let setGlobalLogLevelOverride;
|
|
4
|
+
const consoleErrorSpy = jest.spyOn(console, 'error');
|
|
5
|
+
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
6
|
+
const consoleInfoSpy = jest.spyOn(console, 'info');
|
|
7
|
+
const consoleDebugSpy = jest.spyOn(console, 'debug');
|
|
8
|
+
const consoleTraceSpy = jest.spyOn(console, 'trace');
|
|
9
|
+
describe('Logger', () => {
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
const a = await import('./logger');
|
|
12
|
+
logger = a.logger;
|
|
13
|
+
LogLevel = a.LogLevel;
|
|
14
|
+
setGlobalLogLevelOverride = a.setGlobalLogLevelOverride;
|
|
15
|
+
});
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
// Reset the logger's log level before each test
|
|
18
|
+
setGlobalLogLevelOverride(LogLevel.TRACE);
|
|
19
|
+
logger.setLogLevel(LogLevel.ERROR);
|
|
20
|
+
consoleErrorSpy.mockRestore();
|
|
21
|
+
consoleWarnSpy.mockRestore();
|
|
22
|
+
consoleInfoSpy.mockRestore();
|
|
23
|
+
consoleDebugSpy.mockRestore();
|
|
24
|
+
consoleTraceSpy.mockRestore();
|
|
25
|
+
});
|
|
26
|
+
it('should set the log level correctly', () => {
|
|
27
|
+
logger.setLogLevel(LogLevel.INFO);
|
|
28
|
+
expect(logger.getLogLevel()).toBe(LogLevel.INFO);
|
|
29
|
+
logger.setLogLevel(LogLevel.DEBUG);
|
|
30
|
+
expect(logger.getLogLevel()).toBe(LogLevel.DEBUG);
|
|
31
|
+
});
|
|
32
|
+
it('should log messages based on the log level', () => {
|
|
33
|
+
setGlobalLogLevelOverride(undefined);
|
|
34
|
+
logger.setLogLevel(LogLevel.SILENT);
|
|
35
|
+
logger.logMessages(['log me'], LogLevel.SILENT);
|
|
36
|
+
logger.error('Error message');
|
|
37
|
+
logger.warn('Warning message');
|
|
38
|
+
logger.debug('Debug message');
|
|
39
|
+
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
40
|
+
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
|
41
|
+
expect(consoleDebugSpy).not.toHaveBeenCalled();
|
|
42
|
+
logger.setLogLevel(LogLevel.ERROR);
|
|
43
|
+
logger.error('Error message');
|
|
44
|
+
logger.warn('Warning message');
|
|
45
|
+
logger.debug('Debug message');
|
|
46
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Error message');
|
|
47
|
+
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
|
48
|
+
expect(consoleDebugSpy).not.toHaveBeenCalled();
|
|
49
|
+
logger.error('Warning message');
|
|
50
|
+
logger.warn('Warning message');
|
|
51
|
+
logger.debug('Debug message');
|
|
52
|
+
expect(consoleTraceSpy).not.toHaveBeenCalled();
|
|
53
|
+
logger.setLogLevel(LogLevel.WARN);
|
|
54
|
+
logger.error('Warning message');
|
|
55
|
+
logger.warn('Warning message');
|
|
56
|
+
logger.debug('Debug message');
|
|
57
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Warning message');
|
|
58
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith('Warning message');
|
|
59
|
+
expect(consoleDebugSpy).not.toHaveBeenCalled();
|
|
60
|
+
logger.setLogLevel(LogLevel.DEBUG);
|
|
61
|
+
logger.error('Warning message');
|
|
62
|
+
logger.warn('Warning message');
|
|
63
|
+
logger.debug('Debug message');
|
|
64
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Warning message');
|
|
65
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith('Warning message');
|
|
66
|
+
expect(consoleDebugSpy).toHaveBeenCalledWith('Debug message');
|
|
67
|
+
});
|
|
68
|
+
it('should log messages with the global log level override', () => {
|
|
69
|
+
setGlobalLogLevelOverride(LogLevel.WARN);
|
|
70
|
+
logger.error('Error message');
|
|
71
|
+
logger.warn('Warn message');
|
|
72
|
+
logger.info('Info message');
|
|
73
|
+
logger.trace('Trace message');
|
|
74
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Error message');
|
|
75
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith('Warn message');
|
|
76
|
+
expect(consoleInfoSpy).not.toHaveBeenCalled();
|
|
77
|
+
expect(consoleDebugSpy).not.toHaveBeenCalled();
|
|
78
|
+
expect(consoleTraceSpy).not.toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
it('If global level is not set , default local level (error) should be used', () => {
|
|
81
|
+
setGlobalLogLevelOverride(undefined);
|
|
82
|
+
logger.error('Error message');
|
|
83
|
+
logger.warn('Warn message');
|
|
84
|
+
logger.info('Info message');
|
|
85
|
+
logger.trace('Trace message');
|
|
86
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Error message');
|
|
87
|
+
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
|
88
|
+
expect(consoleInfoSpy).not.toHaveBeenCalled();
|
|
89
|
+
expect(consoleDebugSpy).not.toHaveBeenCalled();
|
|
90
|
+
expect(consoleTraceSpy).not.toHaveBeenCalled();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=logger.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.spec.js","sourceRoot":"","sources":["../../../src/utils/logger.spec.ts"],"names":[],"mappings":"AAAA,IAAI,MAAW,CAAC;AAChB,IAAI,QAAa,CAAC;AAClB,IAAI,yBAA8B,CAAC;AAEnC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACrD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACnD,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,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CAAC;QAC5D,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QAC/E,yBAAyB,CAAC,SAAS,CAAC,CAAC;QAErC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC9B,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAC9D,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -18,12 +18,12 @@ declare module '@thoughtspot/visual-embed-sdk' {
|
|
|
18
18
|
import { SearchEmbed, SearchViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search';
|
|
19
19
|
import { SearchBarEmbed, SearchBarViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search-bar';
|
|
20
20
|
import { AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, getSessionInfo } from '@thoughtspot/visual-embed-sdk/auth';
|
|
21
|
-
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, PrefetchFeatures, FrameParams, DOMSelector, HomeLeftNavItem, HomepageModule, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, ContextMenuTriggerOptions, RuntimeParameter } from '@thoughtspot/visual-embed-sdk/types';
|
|
21
|
+
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, PrefetchFeatures, FrameParams, DOMSelector, HomeLeftNavItem, HomepageModule, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, ContextMenuTriggerOptions, RuntimeParameter, LogLevel } from '@thoughtspot/visual-embed-sdk/types';
|
|
22
22
|
import { CustomCssVariables } from '@thoughtspot/visual-embed-sdk/css-variables';
|
|
23
23
|
import { SageEmbed, SageViewConfig } from '@thoughtspot/visual-embed-sdk/embed/sage';
|
|
24
24
|
import { AnswerService } from '@thoughtspot/visual-embed-sdk/utils/graphql/answerService/answerService';
|
|
25
25
|
import { getEmbedConfig } from '@thoughtspot/visual-embed-sdk/embed/embedConfig';
|
|
26
|
-
export { init, logout, prefetch, executeTML, exportTML, executeTMLInput, exportTMLInput, getEmbedConfig as getInitConfig, getSessionInfo, SearchEmbed, SearchBarEmbed, PinboardEmbed, LiveboardEmbed, SageEmbed, AppEmbed, AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, AnswerService, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, ContextMenuTriggerOptions, EmbedConfig, SearchViewConfig, SearchBarViewConfig, LiveboardViewConfig, SageViewConfig, AppViewConfig, PrefetchFeatures, FrameParams, HomeLeftNavItem, HomepageModule, DOMSelector, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, CustomCssVariables, RuntimeParameter, };
|
|
26
|
+
export { init, logout, prefetch, executeTML, exportTML, executeTMLInput, exportTMLInput, getEmbedConfig as getInitConfig, getSessionInfo, SearchEmbed, SearchBarEmbed, PinboardEmbed, LiveboardEmbed, SageEmbed, AppEmbed, AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, AnswerService, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, ContextMenuTriggerOptions, EmbedConfig, SearchViewConfig, SearchBarViewConfig, LiveboardViewConfig, SageViewConfig, AppViewConfig, PrefetchFeatures, FrameParams, HomeLeftNavItem, HomepageModule, DOMSelector, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, CustomCssVariables, RuntimeParameter, LogLevel, };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
@@ -537,6 +537,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
537
537
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl, 9.8.0.sw
|
|
538
538
|
*/
|
|
539
539
|
isLiveboardHeaderSticky?: boolean;
|
|
540
|
+
/**
|
|
541
|
+
* enable or disable ask sage
|
|
542
|
+
*
|
|
543
|
+
* @version SDK: 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
544
|
+
* @default true
|
|
545
|
+
*/
|
|
546
|
+
enableAskSage?: boolean;
|
|
540
547
|
}
|
|
541
548
|
/**
|
|
542
549
|
* Embed a ThoughtSpot Liveboard or visualization. When rendered it already
|
|
@@ -1509,6 +1516,20 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
1509
1516
|
* @version SDK: 1.26.2 | ThoughtSpot: *
|
|
1510
1517
|
*/
|
|
1511
1518
|
suppressErrorAlerts?: boolean;
|
|
1519
|
+
/**
|
|
1520
|
+
* Log level for the SDK.
|
|
1521
|
+
* @default LogLevel.ERROR
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```js
|
|
1525
|
+
* init({
|
|
1526
|
+
* ...embedConfig,
|
|
1527
|
+
* logLevel: LogLevel.SILENT
|
|
1528
|
+
* })
|
|
1529
|
+
* ```
|
|
1530
|
+
* @version SDK: 1.26.5 | ThoughtSpot: 9.10.0.cl
|
|
1531
|
+
*/
|
|
1532
|
+
logLevel?: LogLevel;
|
|
1512
1533
|
}
|
|
1513
1534
|
export interface LayoutConfig {
|
|
1514
1535
|
}
|
|
@@ -2868,7 +2889,23 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
2868
2889
|
*
|
|
2869
2890
|
* @version SDK : 1.27.0 | Thoughtspot: 9.8.0.cl
|
|
2870
2891
|
*/
|
|
2871
|
-
CreateWorksheet = "createWorksheet"
|
|
2892
|
+
CreateWorksheet = "createWorksheet",
|
|
2893
|
+
/**
|
|
2894
|
+
* Emitted when Ask Sage is initialized.
|
|
2895
|
+
*
|
|
2896
|
+
* @returns viewName: string
|
|
2897
|
+
* @returns viewId: string
|
|
2898
|
+
* @returns liveboardId: string
|
|
2899
|
+
* @returns isPublic: boolean
|
|
2900
|
+
* @version SDK : 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
2901
|
+
*/
|
|
2902
|
+
AskSageInit = "AskSageInit",
|
|
2903
|
+
/**
|
|
2904
|
+
* Emitted when a LB/viz is renamed
|
|
2905
|
+
*
|
|
2906
|
+
* @version SDK : 1.28.0 | ThoughtSpot: 9.11.0.cl
|
|
2907
|
+
*/
|
|
2908
|
+
Rename = "renameModalTitleDescription"
|
|
2872
2909
|
}
|
|
2873
2910
|
/**
|
|
2874
2911
|
* Event types that can be triggered by the host application
|
|
@@ -3629,7 +3666,18 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3629
3666
|
* ```
|
|
3630
3667
|
* @version SDK: 1.26.0 | Thoughtspot: 9.10.0.cl
|
|
3631
3668
|
*/
|
|
3632
|
-
GetAnswerSession = "getAnswerSession"
|
|
3669
|
+
GetAnswerSession = "getAnswerSession",
|
|
3670
|
+
/**
|
|
3671
|
+
* Trigger Ask Sage for viz
|
|
3672
|
+
*
|
|
3673
|
+
* @example
|
|
3674
|
+
* ```js
|
|
3675
|
+
* liveboardEmbed.trigger(HostEvent.AskSage,
|
|
3676
|
+
* {vizId:'730496d6-6903-4601-937e-2c691821af3c'})
|
|
3677
|
+
* ```
|
|
3678
|
+
* @version SDK: 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
3679
|
+
*/
|
|
3680
|
+
AskSage = "AskSage"
|
|
3633
3681
|
}
|
|
3634
3682
|
/**
|
|
3635
3683
|
* The different visual modes that the data sources panel within
|
|
@@ -3722,7 +3770,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3722
3770
|
IsProductTour = "isProductTour",
|
|
3723
3771
|
HideSearchBarTitle = "hideSearchBarTitle",
|
|
3724
3772
|
HideSageAnswerHeader = "hideSageAnswerHeader",
|
|
3725
|
-
HideSearchBar = "hideSearchBar"
|
|
3773
|
+
HideSearchBar = "hideSearchBar",
|
|
3774
|
+
ClientLogLevel = "clientLogLevel",
|
|
3775
|
+
OverrideNativeConsole = "overrideConsoleLogs",
|
|
3776
|
+
enableAskSage = "enableAskSage"
|
|
3726
3777
|
}
|
|
3727
3778
|
/**
|
|
3728
3779
|
* ThoughtSpot application pages include actions and menu commands
|
|
@@ -4581,7 +4632,17 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4581
4632
|
* ```
|
|
4582
4633
|
* @version SDK: 1.29.0 | Thoughtspot: 9.10.0.cl
|
|
4583
4634
|
*/
|
|
4584
|
-
VerifiedLiveboard = "verifiedLiveboard"
|
|
4635
|
+
VerifiedLiveboard = "verifiedLiveboard",
|
|
4636
|
+
/**
|
|
4637
|
+
* Action ID for ask sage button
|
|
4638
|
+
*
|
|
4639
|
+
* @example
|
|
4640
|
+
* ```js
|
|
4641
|
+
* hiddenAction: [Action.AskAi]
|
|
4642
|
+
* ```
|
|
4643
|
+
* @version SDK: 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
4644
|
+
*/
|
|
4645
|
+
AskAi = "AskAi"
|
|
4585
4646
|
}
|
|
4586
4647
|
export interface AnswerServiceType {
|
|
4587
4648
|
getAnswer?: (offset: number, batchSize: number) => any;
|
|
@@ -4637,6 +4698,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4637
4698
|
session: SessionInterface;
|
|
4638
4699
|
vizId?: string;
|
|
4639
4700
|
}
|
|
4701
|
+
export enum LogLevel {
|
|
4702
|
+
SILENT = "SILENT",
|
|
4703
|
+
ERROR = "ERROR",
|
|
4704
|
+
WARN = "WARN",
|
|
4705
|
+
INFO = "INFO",
|
|
4706
|
+
DEBUG = "DEBUG",
|
|
4707
|
+
TRACE = "TRACE"
|
|
4708
|
+
}
|
|
4640
4709
|
}
|
|
4641
4710
|
|
|
4642
4711
|
declare module '@thoughtspot/visual-embed-sdk/css-variables' {
|
|
@@ -5236,12 +5305,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/embedConfig' {
|
|
|
5236
5305
|
export const getEmbedConfig: () => EmbedConfig;
|
|
5237
5306
|
/**
|
|
5238
5307
|
* Sets the configuration embed was initialized with.
|
|
5308
|
+
* And returns the new configuration.
|
|
5239
5309
|
*
|
|
5240
5310
|
* @param newConfig The configuration to set.
|
|
5241
5311
|
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
5242
5312
|
* @group Global methods
|
|
5243
5313
|
*/
|
|
5244
|
-
export const setEmbedConfig: (newConfig: EmbedConfig) =>
|
|
5314
|
+
export const setEmbedConfig: (newConfig: EmbedConfig) => EmbedConfig;
|
|
5245
5315
|
}
|
|
5246
5316
|
|
|
5247
5317
|
declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
EndPoints,
|
|
14
14
|
} from './utils/authService';
|
|
15
15
|
import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
|
|
16
|
+
import { logger } from './utils/logger';
|
|
16
17
|
|
|
17
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
18
19
|
export let loggedInStatus = false;
|
|
@@ -154,7 +155,7 @@ export function setAuthEE(eventEmitter: EventEmitter<AuthStatus | AuthEvent>): v
|
|
|
154
155
|
*/
|
|
155
156
|
export function notifyAuthSDKSuccess(): void {
|
|
156
157
|
if (!authEE) {
|
|
157
|
-
|
|
158
|
+
logger.error('SDK not initialized');
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
@@ -165,7 +166,7 @@ export function notifyAuthSDKSuccess(): void {
|
|
|
165
166
|
*/
|
|
166
167
|
export function notifyAuthSuccess(): void {
|
|
167
168
|
if (!authEE) {
|
|
168
|
-
|
|
169
|
+
logger.error('SDK not initialized');
|
|
169
170
|
return;
|
|
170
171
|
}
|
|
171
172
|
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
@@ -177,7 +178,7 @@ export function notifyAuthSuccess(): void {
|
|
|
177
178
|
*/
|
|
178
179
|
export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
179
180
|
if (!authEE) {
|
|
180
|
-
|
|
181
|
+
logger.error('SDK not initialized');
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
184
|
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
@@ -188,7 +189,7 @@ export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
|
188
189
|
*/
|
|
189
190
|
export function notifyLogout(): void {
|
|
190
191
|
if (!authEE) {
|
|
191
|
-
|
|
192
|
+
logger.error('SDK not initialized');
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
authEE.emit(AuthStatus.LOGOUT);
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { version } from '../../package.json';
|
|
19
19
|
import * as config from '../config';
|
|
20
20
|
import { TsEmbed, V1Embed } from './ts-embed';
|
|
21
|
+
import { logger } from '../utils/logger';
|
|
21
22
|
|
|
22
23
|
const defaultViewConfig = {
|
|
23
24
|
frameParams: {
|
|
@@ -463,15 +464,15 @@ describe('App embed tests', () => {
|
|
|
463
464
|
},
|
|
464
465
|
});
|
|
465
466
|
await appEmbed.render();
|
|
466
|
-
spyOn(
|
|
467
|
+
spyOn(logger, 'warn');
|
|
467
468
|
appEmbed.navigateToPage(-1);
|
|
468
|
-
expect(
|
|
469
|
+
expect(logger.warn).toHaveBeenCalledWith(
|
|
469
470
|
'Path can only by a string when triggered without noReload',
|
|
470
471
|
);
|
|
471
472
|
});
|
|
472
473
|
|
|
473
474
|
test('navigateToPage function use before render', async () => {
|
|
474
|
-
spyOn(
|
|
475
|
+
spyOn(logger, 'log');
|
|
475
476
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
476
477
|
frameParams: {
|
|
477
478
|
width: '100%',
|
|
@@ -480,7 +481,7 @@ describe('App embed tests', () => {
|
|
|
480
481
|
});
|
|
481
482
|
appEmbed.navigateToPage(path);
|
|
482
483
|
await appEmbed.render();
|
|
483
|
-
expect(
|
|
484
|
+
expect(logger.log).toHaveBeenCalledWith(
|
|
484
485
|
'Please call render before invoking this method',
|
|
485
486
|
);
|
|
486
487
|
});
|
package/src/embed/app.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { logger } from '../utils/logger';
|
|
12
13
|
import { getQueryParamString } from '../utils';
|
|
13
14
|
import {
|
|
14
15
|
Param, DOMSelector, HostEvent, ViewConfig, EmbedEvent, MessagePayload,
|
|
@@ -375,14 +376,14 @@ export class AppEmbed extends V1Embed {
|
|
|
375
376
|
*/
|
|
376
377
|
public navigateToPage(path: string | number, noReload = false): void {
|
|
377
378
|
if (!this.iFrame) {
|
|
378
|
-
|
|
379
|
+
logger.log('Please call render before invoking this method');
|
|
379
380
|
return;
|
|
380
381
|
}
|
|
381
382
|
if (noReload) {
|
|
382
383
|
this.trigger(HostEvent.Navigate, path);
|
|
383
384
|
} else {
|
|
384
385
|
if (typeof path !== 'string') {
|
|
385
|
-
|
|
386
|
+
logger.warn('Path can only by a string when triggered without noReload');
|
|
386
387
|
return;
|
|
387
388
|
}
|
|
388
389
|
const iframeSrc = this.iFrame.src;
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
getIFrameSrc,
|
|
18
18
|
} from '../test/test-utils';
|
|
19
19
|
import * as tokenizedFetchInstance from '../tokenizedFetch';
|
|
20
|
+
import { logger } from '../utils/logger';
|
|
20
21
|
|
|
21
22
|
const thoughtSpotHost = 'tshost';
|
|
22
23
|
let authEE: EventEmitter;
|
|
@@ -412,11 +413,11 @@ describe('Base TS Embed', () => {
|
|
|
412
413
|
describe('Base without init', () => {
|
|
413
414
|
test('notify should error when called without init', () => {
|
|
414
415
|
base.reset();
|
|
415
|
-
jest.spyOn(
|
|
416
|
+
jest.spyOn(logger, 'error').mockImplementation(() => undefined);
|
|
416
417
|
base.notifyAuthSuccess();
|
|
417
418
|
base.notifyAuthFailure(auth.AuthFailureType.SDK);
|
|
418
419
|
base.notifyLogout();
|
|
419
420
|
base.notifyAuthSDKSuccess();
|
|
420
|
-
expect(
|
|
421
|
+
expect(logger.error).toHaveBeenCalledTimes(4);
|
|
421
422
|
});
|
|
422
423
|
});
|
package/src/embed/base.ts
CHANGED
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import EventEmitter from 'eventemitter3';
|
|
12
12
|
import uniq from 'lodash/uniq';
|
|
13
|
+
import { logger, setGlobalLogLevelOverride } from '../utils/logger';
|
|
13
14
|
import { tokenizedFetch } from '../tokenizedFetch';
|
|
14
15
|
import { EndPoints } from '../utils/authService/authService';
|
|
15
16
|
import { getThoughtSpotHost } from '../config';
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
|
|
19
|
+
} from '../types';
|
|
17
20
|
import {
|
|
18
21
|
authenticate,
|
|
19
22
|
logout as _logout,
|
|
@@ -34,6 +37,7 @@ const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
|
34
37
|
loginFailedMessage: 'Not logged in',
|
|
35
38
|
authTriggerText: 'Authorize',
|
|
36
39
|
authType: AuthType.None,
|
|
40
|
+
logLevel: LogLevel.ERROR,
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export interface executeTMLInput {
|
|
@@ -100,7 +104,7 @@ const hostUrlToFeatureUrl = {
|
|
|
100
104
|
export const prefetch = (url?: string, prefetchFeatures?: PrefetchFeatures[]): void => {
|
|
101
105
|
if (url === '') {
|
|
102
106
|
// eslint-disable-next-line no-console
|
|
103
|
-
|
|
107
|
+
logger.warn('The prefetch method does not have a valid URL');
|
|
104
108
|
} else {
|
|
105
109
|
const features = prefetchFeatures || [PrefetchFeatures.FullApp];
|
|
106
110
|
let hostUrl = url || getEmbedConfig().thoughtSpotHost;
|
|
@@ -174,13 +178,16 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
|
|
|
174
178
|
*/
|
|
175
179
|
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
176
180
|
sanity(embedConfig);
|
|
177
|
-
setEmbedConfig(
|
|
181
|
+
embedConfig = setEmbedConfig(
|
|
178
182
|
backwardCompat({
|
|
179
183
|
...CONFIG_DEFAULTS,
|
|
180
184
|
...embedConfig,
|
|
181
185
|
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
182
186
|
}),
|
|
183
187
|
);
|
|
188
|
+
|
|
189
|
+
setGlobalLogLevelOverride(embedConfig.logLevel);
|
|
190
|
+
|
|
184
191
|
const authEE = new EventEmitter<AuthStatus | AuthEvent>();
|
|
185
192
|
setAuthEE(authEE);
|
|
186
193
|
handleAuth();
|
package/src/embed/embed.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../utils/logger';
|
|
1
2
|
import {
|
|
2
3
|
init, AuthType, SearchEmbed, EmbedEvent,
|
|
3
4
|
} from '../index';
|
|
@@ -51,7 +52,7 @@ describe('test view config', () => {
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
test('trying to register event handler after render should throw error', async () => {
|
|
54
|
-
spyOn(
|
|
55
|
+
spyOn(logger, 'error');
|
|
55
56
|
const onErrorSpy = jest.fn();
|
|
56
57
|
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
57
58
|
searchEmbed
|
package/src/embed/embedConfig.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const getEmbedConfig = (): EmbedConfig => config;
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Sets the configuration embed was initialized with.
|
|
16
|
+
* And returns the new configuration.
|
|
16
17
|
*
|
|
17
18
|
* @param newConfig The configuration to set.
|
|
18
19
|
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
@@ -20,4 +21,5 @@ export const getEmbedConfig = (): EmbedConfig => config;
|
|
|
20
21
|
*/
|
|
21
22
|
export const setEmbedConfig = (newConfig: EmbedConfig) => {
|
|
22
23
|
config = newConfig;
|
|
24
|
+
return newConfig;
|
|
23
25
|
};
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../utils/logger';
|
|
1
2
|
import {
|
|
2
3
|
init,
|
|
3
4
|
AuthType,
|
|
@@ -155,7 +156,7 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
155
156
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
156
157
|
} as LiveboardViewConfig);
|
|
157
158
|
liveboardEmbed.render();
|
|
158
|
-
const spy1 = jest.spyOn(
|
|
159
|
+
const spy1 = jest.spyOn(logger, 'log');
|
|
159
160
|
|
|
160
161
|
await executeAfterWait(() => {
|
|
161
162
|
const iframe = getIFrameEl();
|
|
@@ -173,7 +174,7 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
173
174
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
174
175
|
} as LiveboardViewConfig);
|
|
175
176
|
pinboardEmbed.render();
|
|
176
|
-
const spy1 = jest.spyOn(
|
|
177
|
+
const spy1 = jest.spyOn(logger, 'log');
|
|
177
178
|
|
|
178
179
|
await executeAfterWait(() => {
|
|
179
180
|
const iframe = getIFrameEl();
|
|
@@ -294,12 +294,13 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
294
294
|
liveboardV2: true,
|
|
295
295
|
defaultHeight: 100,
|
|
296
296
|
preventLiveboardFilterRemoval: true,
|
|
297
|
+
enableAskSage: true,
|
|
297
298
|
} as LiveboardViewConfig);
|
|
298
299
|
liveboardEmbed.render();
|
|
299
300
|
await executeAfterWait(() => {
|
|
300
301
|
expectUrlMatchesWithParams(
|
|
301
302
|
getIFrameSrc(),
|
|
302
|
-
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&preventPinboardFilterRemoval=true&isLiveboardEmbed=true&isPinboardV2Enabled=true#/embed/viz/${liveboardId}/tab/${activeTabId}`,
|
|
303
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&preventPinboardFilterRemoval=true&isLiveboardEmbed=true&isPinboardV2Enabled=true&enableAskSage=true#/embed/viz/${liveboardId}/tab/${activeTabId}`,
|
|
303
304
|
);
|
|
304
305
|
});
|
|
305
306
|
});
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -143,6 +143,13 @@ export interface LiveboardViewConfig extends Omit<ViewConfig, 'hiddenHomepageMod
|
|
|
143
143
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl, 9.8.0.sw
|
|
144
144
|
*/
|
|
145
145
|
isLiveboardHeaderSticky?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* enable or disable ask sage
|
|
148
|
+
*
|
|
149
|
+
* @version SDK: 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
150
|
+
* @default true
|
|
151
|
+
*/
|
|
152
|
+
enableAskSage?: boolean;
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
/**
|
|
@@ -198,6 +205,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
198
205
|
showLiveboardDescription,
|
|
199
206
|
showLiveboardTitle,
|
|
200
207
|
isLiveboardHeaderSticky = true,
|
|
208
|
+
enableAskSage,
|
|
201
209
|
} = this.viewConfig;
|
|
202
210
|
|
|
203
211
|
const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
|
|
@@ -237,6 +245,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
237
245
|
if (showLiveboardTitle) {
|
|
238
246
|
params[Param.ShowLiveboardTitle] = showLiveboardTitle;
|
|
239
247
|
}
|
|
248
|
+
if (enableAskSage) {
|
|
249
|
+
params[Param.enableAskSage] = enableAskSage;
|
|
250
|
+
}
|
|
240
251
|
|
|
241
252
|
params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
|
|
242
253
|
|