@thoughtspot/visual-embed-sdk 1.51.2 → 1.52.1
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 +9 -1
- package/cjs/src/api-intercept.d.ts.map +1 -1
- package/cjs/src/api-intercept.js +1 -0
- package/cjs/src/api-intercept.js.map +1 -1
- package/cjs/src/contracts/contracts.spec.d.ts +2 -0
- package/cjs/src/contracts/contracts.spec.d.ts.map +1 -0
- package/cjs/src/contracts/contracts.spec.js +345 -0
- package/cjs/src/contracts/contracts.spec.js.map +1 -0
- package/cjs/src/contracts/embed-event-payloads.d.ts +73 -0
- package/cjs/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/cjs/src/contracts/embed-event-payloads.js +3 -0
- package/cjs/src/contracts/embed-event-payloads.js.map +1 -0
- package/cjs/src/contracts/host-event-contracts.d.ts +378 -0
- package/cjs/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/cjs/src/contracts/host-event-contracts.js +3 -0
- package/cjs/src/contracts/host-event-contracts.js.map +1 -0
- package/cjs/src/contracts/index.d.ts +22 -0
- package/cjs/src/contracts/index.d.ts.map +1 -0
- package/cjs/src/contracts/index.js +33 -0
- package/cjs/src/contracts/index.js.map +1 -0
- package/cjs/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/cjs/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/cjs/src/{embed/hostEventClient/contracts.js → contracts/ui-passthrough-contracts.js} +6 -2
- package/cjs/src/contracts/ui-passthrough-contracts.js.map +1 -0
- package/cjs/src/css-variables.d.ts +1 -1
- package/cjs/src/embed/app.d.ts +17 -140
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +20 -120
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +70 -26
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +5 -5
- package/cjs/src/embed/events.spec.js +12 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +23 -18
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +36 -36
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.d.ts +1 -1
- package/cjs/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.js +3 -3
- package/cjs/src/embed/hostEventClient/utils.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +9 -161
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +68 -135
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +215 -32
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/search.d.ts +14 -0
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -1
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +65 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +21 -25
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +105 -72
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +380 -33
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/full-height.d.ts +137 -0
- package/cjs/src/full-height.d.ts.map +1 -0
- package/cjs/src/full-height.js +272 -0
- package/cjs/src/full-height.js.map +1 -0
- package/cjs/src/full-height.spec.d.ts +2 -0
- package/cjs/src/full-height.spec.d.ts.map +1 -0
- package/cjs/src/full-height.spec.js +835 -0
- package/cjs/src/full-height.spec.js.map +1 -0
- package/cjs/src/index.d.ts +4 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +5 -4
- 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 +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/all-types-export.parity.spec.js +55 -3
- package/cjs/src/react/all-types-export.parity.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +8 -8
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +1 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +7 -7
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +664 -39
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +406 -13
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +3 -1
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +19 -51
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/cjs/src/utils/transport/iframe-transport.d.ts +55 -0
- package/cjs/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.js +108 -0
- package/cjs/src/utils/transport/iframe-transport.js.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/cjs/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.spec.js +140 -0
- package/cjs/src/utils/transport/iframe-transport.spec.js.map +1 -0
- package/cjs/src/utils.d.ts +18 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +39 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +62 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-D8_Zs-Nr.js → index-C1pmYb5H.js} +1 -1
- package/dist/src/api-intercept.d.ts.map +1 -1
- package/dist/src/contracts/contracts.spec.d.ts +2 -0
- package/dist/src/contracts/contracts.spec.d.ts.map +1 -0
- package/dist/src/contracts/embed-event-payloads.d.ts +73 -0
- package/dist/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/dist/src/contracts/host-event-contracts.d.ts +378 -0
- package/dist/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/dist/src/contracts/index.d.ts +22 -0
- package/dist/src/contracts/index.d.ts.map +1 -0
- package/dist/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/dist/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/dist/src/css-variables.d.ts +1 -1
- package/dist/src/embed/app.d.ts +17 -140
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +5 -5
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/utils.d.ts +1 -1
- package/dist/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +9 -161
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +14 -0
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +21 -25
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/full-height.d.ts +137 -0
- package/dist/src/full-height.d.ts.map +1 -0
- package/dist/src/full-height.spec.d.ts +2 -0
- package/dist/src/full-height.spec.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -3
- 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 +8 -8
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +664 -39
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +3 -1
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils/transport/iframe-transport.d.ts +55 -0
- package/dist/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/dist/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/dist/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1031 -392
- package/dist/tsembed-react.js +1030 -391
- package/dist/tsembed.es.js +1031 -392
- package/dist/tsembed.js +1029 -390
- package/dist/visual-embed-sdk-react-full.d.ts +1483 -693
- package/dist/visual-embed-sdk-react.d.ts +1364 -647
- package/dist/visual-embed-sdk.d.ts +1426 -659
- package/lib/package.json +9 -1
- package/lib/src/api-intercept.d.ts.map +1 -1
- package/lib/src/api-intercept.js +2 -1
- package/lib/src/api-intercept.js.map +1 -1
- package/lib/src/contracts/contracts.spec.d.ts +2 -0
- package/lib/src/contracts/contracts.spec.d.ts.map +1 -0
- package/lib/src/contracts/contracts.spec.js +342 -0
- package/lib/src/contracts/contracts.spec.js.map +1 -0
- package/lib/src/contracts/embed-event-payloads.d.ts +73 -0
- package/lib/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/lib/src/contracts/embed-event-payloads.js +2 -0
- package/lib/src/contracts/embed-event-payloads.js.map +1 -0
- package/lib/src/contracts/host-event-contracts.d.ts +378 -0
- package/lib/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/lib/src/contracts/host-event-contracts.js +2 -0
- package/lib/src/contracts/host-event-contracts.js.map +1 -0
- package/lib/src/contracts/index.d.ts +22 -0
- package/lib/src/contracts/index.d.ts.map +1 -0
- package/lib/src/contracts/index.js +22 -0
- package/lib/src/contracts/index.js.map +1 -0
- package/lib/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/lib/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/lib/src/{embed/hostEventClient/contracts.js → contracts/ui-passthrough-contracts.js} +6 -2
- package/lib/src/contracts/ui-passthrough-contracts.js.map +1 -0
- package/lib/src/css-variables.d.ts +1 -1
- package/lib/src/embed/app.d.ts +17 -140
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +22 -122
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +70 -26
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +5 -5
- package/lib/src/embed/events.spec.js +12 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +6 -1
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/utils.d.ts +1 -1
- package/lib/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/utils.js +1 -1
- package/lib/src/embed/hostEventClient/utils.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +9 -161
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +70 -137
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +215 -32
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +14 -0
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +4 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +65 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +21 -25
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +106 -73
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +378 -31
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/full-height.d.ts +137 -0
- package/lib/src/full-height.d.ts.map +1 -0
- package/lib/src/full-height.js +268 -0
- package/lib/src/full-height.js.map +1 -0
- package/lib/src/full-height.spec.d.ts +2 -0
- package/lib/src/full-height.spec.d.ts.map +1 -0
- package/lib/src/full-height.spec.js +833 -0
- package/lib/src/full-height.spec.js.map +1 -0
- package/lib/src/index.d.ts +4 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +3 -3
- 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/all-types-export.parity.spec.js +55 -3
- package/lib/src/react/all-types-export.parity.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +8 -8
- 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 +7 -7
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +664 -39
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +405 -12
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +3 -1
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +19 -51
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils/transport/iframe-transport.d.ts +55 -0
- package/lib/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/lib/src/utils/transport/iframe-transport.js +101 -0
- package/lib/src/utils/transport/iframe-transport.js.map +1 -0
- package/lib/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/lib/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/lib/src/utils/transport/iframe-transport.spec.js +138 -0
- package/lib/src/utils/transport/iframe-transport.spec.js.map +1 -0
- package/lib/src/utils.d.ts +18 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +37 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +63 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +1426 -659
- package/package.json +9 -1
- package/src/api-intercept.ts +2 -1
- package/src/contracts/contracts.spec.ts +392 -0
- package/src/contracts/embed-event-payloads.ts +83 -0
- package/src/contracts/host-event-contracts.ts +456 -0
- package/src/contracts/index.ts +53 -0
- package/src/contracts/ui-passthrough-contracts.ts +301 -0
- package/src/css-variables.ts +1 -1
- package/src/embed/app.spec.ts +86 -34
- package/src/embed/app.ts +37 -264
- package/src/embed/conversation.ts +5 -5
- package/src/embed/events.spec.ts +14 -2
- package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
- package/src/embed/hostEventClient/host-event-client.ts +18 -5
- package/src/embed/hostEventClient/utils.ts +2 -1
- package/src/embed/liveboard.spec.ts +261 -42
- package/src/embed/liveboard.ts +78 -297
- package/src/embed/search.spec.ts +80 -0
- package/src/embed/search.ts +20 -0
- package/src/embed/ts-embed.spec.ts +518 -31
- package/src/embed/ts-embed.ts +133 -82
- package/src/full-height.spec.ts +1008 -0
- package/src/full-height.ts +361 -0
- package/src/index.ts +95 -5
- package/src/react/all-types-export.parity.spec.ts +63 -3
- package/src/react/all-types-export.ts +46 -0
- package/src/react/index.spec.tsx +7 -7
- package/src/react/index.tsx +9 -9
- package/src/types.ts +665 -37
- package/src/utils/processTrigger.ts +28 -58
- package/src/utils/transport/iframe-transport.spec.ts +177 -0
- package/src/utils/transport/iframe-transport.ts +122 -0
- package/src/utils.spec.ts +71 -0
- package/src/utils.ts +38 -0
- package/cjs/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +0 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/lib/src/embed/hostEventClient/contracts.js.map +0 -1
- package/src/embed/hostEventClient/contracts.ts +0 -262
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025
|
|
3
|
+
*
|
|
4
|
+
* Full-height support for the Liveboard and app embeds.
|
|
5
|
+
* @summary Full height
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
BaseViewConfig,
|
|
10
|
+
EmbedEvent,
|
|
11
|
+
FullHeightViewConfig,
|
|
12
|
+
HostEvent,
|
|
13
|
+
MessageCallback,
|
|
14
|
+
MessagePayload,
|
|
15
|
+
Param,
|
|
16
|
+
QueryParams,
|
|
17
|
+
} from './types';
|
|
18
|
+
import {
|
|
19
|
+
calculateElementCenter,
|
|
20
|
+
calculateVisibleElementData,
|
|
21
|
+
getEffectiveClippingAncestors,
|
|
22
|
+
getScrollableAncestors,
|
|
23
|
+
isValidCssMargin,
|
|
24
|
+
} from './utils';
|
|
25
|
+
import { logger } from './utils/logger';
|
|
26
|
+
import { DEFAULT_LAZY_LOADING_MARGIN } from './config';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The height the embed falls back to when the host app has not configured
|
|
30
|
+
* `minimumHeight` or `defaultHeight`.
|
|
31
|
+
*/
|
|
32
|
+
const DEFAULT_MINIMUM_HEIGHT = 500;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Routes that are part of the Liveboard experience itself. Navigating between
|
|
36
|
+
* these does not reset the frame height, because the ThoughtSpot app keeps
|
|
37
|
+
* reporting a height of its own for them.
|
|
38
|
+
*/
|
|
39
|
+
const LIVEBOARD_RELATED_ROUTES = [
|
|
40
|
+
'/pinboard/',
|
|
41
|
+
'/insights/pinboard/',
|
|
42
|
+
'/schedules/',
|
|
43
|
+
'/embed/viz/',
|
|
44
|
+
'/embed/insights/viz/',
|
|
45
|
+
'/liveboard/',
|
|
46
|
+
'/insights/liveboard/',
|
|
47
|
+
'/tsl-editor/PINBOARD_ANSWER_BOOK/',
|
|
48
|
+
'/import-tsl/PINBOARD_ANSWER_BOOK/',
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The slice of an embed's view config the full-height controller reads.
|
|
53
|
+
*/
|
|
54
|
+
export type FullHeightControllerViewConfig = FullHeightViewConfig &
|
|
55
|
+
Pick<BaseViewConfig, 'frameParams'>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The subset of the embed the full-height controller drives. Keeping this
|
|
59
|
+
* narrow lets the controller stay independent of the embed class hierarchy.
|
|
60
|
+
*/
|
|
61
|
+
export interface FullHeightEmbedHost {
|
|
62
|
+
/**
|
|
63
|
+
* Returns the embedded iframe. The iframe only exists once the embed has
|
|
64
|
+
* rendered, so this is a callback rather than a value.
|
|
65
|
+
*/
|
|
66
|
+
getIframe: () => HTMLIFrameElement;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the height of the embed container.
|
|
69
|
+
*/
|
|
70
|
+
setFrameHeight: (height: number | string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Registers an SDK-owned handler for an embed event.
|
|
73
|
+
*/
|
|
74
|
+
on: (eventType: EmbedEvent, callback: MessageCallback) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Sends a host event to the embedded ThoughtSpot app.
|
|
77
|
+
*/
|
|
78
|
+
trigger: (hostEvent: HostEvent, data: unknown) => void;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Owns every piece of full-height behavior for an embed: the height
|
|
83
|
+
* negotiation with the ThoughtSpot app, the query parameters that switch the
|
|
84
|
+
* feature on, and the viewport listeners that drive lazy loading.
|
|
85
|
+
*
|
|
86
|
+
* The controller is inert unless `fullHeight` is enabled, so embeds can create
|
|
87
|
+
* one unconditionally.
|
|
88
|
+
*/
|
|
89
|
+
export class FullHeightController {
|
|
90
|
+
private scrollContainers: HTMLElement[] = [];
|
|
91
|
+
|
|
92
|
+
private resizeObserver: ResizeObserver | undefined;
|
|
93
|
+
|
|
94
|
+
private config: FullHeightControllerViewConfig;
|
|
95
|
+
|
|
96
|
+
constructor(
|
|
97
|
+
viewConfig: FullHeightControllerViewConfig,
|
|
98
|
+
private readonly host: FullHeightEmbedHost,
|
|
99
|
+
) {
|
|
100
|
+
this.config = FullHeightController.withLazyLoadingDefaults(viewConfig);
|
|
101
|
+
this.registerEventHandlers();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The view config the controller runs on: the host app's own config with
|
|
106
|
+
* the lazy-loading defaults filled in. Read-only, so the only way to change
|
|
107
|
+
* it is through the setter, which re-resolves the defaults.
|
|
108
|
+
*/
|
|
109
|
+
public get viewConfig(): Readonly<FullHeightControllerViewConfig> {
|
|
110
|
+
return this.config;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Replaces the view config the controller runs on and re-resolves the
|
|
115
|
+
* lazy-loading defaults against it. The config the caller passes is never
|
|
116
|
+
* written to; the controller keeps a copy of its own.
|
|
117
|
+
*/
|
|
118
|
+
public set viewConfig(viewConfig: Readonly<FullHeightControllerViewConfig>) {
|
|
119
|
+
this.config = FullHeightController.withLazyLoadingDefaults(viewConfig);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The view config with the lazy-loading settings the embed falls back to
|
|
124
|
+
* when the host app has not chosen its own.
|
|
125
|
+
*
|
|
126
|
+
* Pure by design: it returns a new config rather than writing to the one it
|
|
127
|
+
* is given, so the host app's object is left untouched.
|
|
128
|
+
* @param viewConfig The embed's view config
|
|
129
|
+
* @returns A copy with the defaults filled in, host app choices preserved
|
|
130
|
+
*/
|
|
131
|
+
private static withLazyLoadingDefaults(
|
|
132
|
+
viewConfig: Readonly<FullHeightControllerViewConfig>,
|
|
133
|
+
): FullHeightControllerViewConfig {
|
|
134
|
+
return {
|
|
135
|
+
...viewConfig,
|
|
136
|
+
lazyLoadingForFullHeight:
|
|
137
|
+
viewConfig.lazyLoadingForFullHeight === undefined
|
|
138
|
+
? true
|
|
139
|
+
: viewConfig.lazyLoadingForFullHeight,
|
|
140
|
+
enableScrollableContainerLazyLoading:
|
|
141
|
+
viewConfig.enableScrollableContainerLazyLoading === undefined
|
|
142
|
+
? true
|
|
143
|
+
: viewConfig.enableScrollableContainerLazyLoading,
|
|
144
|
+
lazyLoadingMargin:
|
|
145
|
+
viewConfig.lazyLoadingMargin === undefined
|
|
146
|
+
? DEFAULT_LAZY_LOADING_MARGIN
|
|
147
|
+
: viewConfig.lazyLoadingMargin,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Whether the host app asked for a full-height embed.
|
|
153
|
+
*/
|
|
154
|
+
private get isEnabled(): boolean {
|
|
155
|
+
return this.config.fullHeight === true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Whether visualizations should load as they scroll into view, which
|
|
160
|
+
* requires the SDK to report the visible region of the embed.
|
|
161
|
+
*/
|
|
162
|
+
private get isLazyLoadEnabled(): boolean {
|
|
163
|
+
return this.isEnabled && !!this.config.lazyLoadingForFullHeight;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The floor for the frame height. `defaultHeight` is the deprecated
|
|
168
|
+
* spelling of `minimumHeight` and is still honored for compatibility.
|
|
169
|
+
*/
|
|
170
|
+
public get minimumHeight(): number {
|
|
171
|
+
const { minimumHeight, defaultHeight } = this.config;
|
|
172
|
+
return minimumHeight || defaultHeight || DEFAULT_MINIMUM_HEIGHT;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Registers the embed event handlers the feature depends on. Called from
|
|
177
|
+
* the constructor, so the handlers are in place before `render`.
|
|
178
|
+
*/
|
|
179
|
+
private registerEventHandlers(): void {
|
|
180
|
+
if (!this.isEnabled) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
this.host.on(EmbedEvent.RouteChange, this.handleRouteChange);
|
|
184
|
+
this.host.on(EmbedEvent.EmbedHeight, this.handleEmbedHeight);
|
|
185
|
+
this.host.on(EmbedEvent.EmbedIframeCenter, this.handleEmbedIframeCenter);
|
|
186
|
+
this.host.on(
|
|
187
|
+
EmbedEvent.RequestVisibleEmbedCoordinates,
|
|
188
|
+
this.handleRequestVisibleCoordinates,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Adds the full-height query parameters to the embed URL params.
|
|
194
|
+
* @param params The query parameters being built by the embed
|
|
195
|
+
*/
|
|
196
|
+
public addQueryParams(params: QueryParams): void {
|
|
197
|
+
if (!this.isEnabled) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
params[Param.fullHeight] = true;
|
|
201
|
+
if (!this.config.lazyLoadingForFullHeight) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
params[Param.IsLazyLoadingForEmbedEnabled] = true;
|
|
205
|
+
if (isValidCssMargin(this.config.lazyLoadingMargin)) {
|
|
206
|
+
params[Param.RootMarginForLazyLoad] = this.config.lazyLoadingMargin;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Attaches the viewport listeners that keep lazy loading in sync. Call this
|
|
212
|
+
* once the embed has rendered and the iframe exists.
|
|
213
|
+
*/
|
|
214
|
+
public onRender(): void {
|
|
215
|
+
this.registerLazyLoadListeners();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Detaches every listener and observer owned by the controller.
|
|
220
|
+
*/
|
|
221
|
+
public destroy(): void {
|
|
222
|
+
this.unregisterLazyLoadListeners();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Sets the frame height to the height reported by the ThoughtSpot app,
|
|
227
|
+
* never going below the configured minimum.
|
|
228
|
+
*/
|
|
229
|
+
private handleEmbedHeight = (payload: MessagePayload): void => {
|
|
230
|
+
const height = Number(payload?.data);
|
|
231
|
+
if (!isNaN(height)) {
|
|
232
|
+
this.host.setFrameHeight(Math.max(height, this.minimumHeight));
|
|
233
|
+
}
|
|
234
|
+
this.sendVisibleCoordinates();
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Answers the app's request for the center of the visible embed region.
|
|
239
|
+
*/
|
|
240
|
+
private handleEmbedIframeCenter = (
|
|
241
|
+
payload: MessagePayload,
|
|
242
|
+
responder?: (data: any) => void,
|
|
243
|
+
): void => {
|
|
244
|
+
const iframe = this.host.getIframe();
|
|
245
|
+
if (!iframe) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
responder?.({
|
|
249
|
+
type: EmbedEvent.EmbedIframeCenter,
|
|
250
|
+
data: calculateElementCenter(iframe),
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Answers the app's request for the currently visible embed coordinates.
|
|
256
|
+
*/
|
|
257
|
+
private handleRequestVisibleCoordinates = (
|
|
258
|
+
payload: MessagePayload,
|
|
259
|
+
responder?: (data: any) => void,
|
|
260
|
+
): void => {
|
|
261
|
+
logger.info('Sending RequestVisibleEmbedCoordinates', payload);
|
|
262
|
+
responder?.({
|
|
263
|
+
type: EmbedEvent.RequestVisibleEmbedCoordinates,
|
|
264
|
+
data: this.getVisibleCoordinates(),
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Resets the frame height when the app navigates away from a Liveboard,
|
|
270
|
+
* since only Liveboard routes report a height of their own.
|
|
271
|
+
*/
|
|
272
|
+
private handleRouteChange = (payload: MessagePayload): void => {
|
|
273
|
+
const currentPath: string = payload?.data?.currentPath;
|
|
274
|
+
if (!currentPath) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (LIVEBOARD_RELATED_ROUTES.some((route) => currentPath.startsWith(route))) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
this.host.setFrameHeight(this.config.frameParams?.height || this.minimumHeight);
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Pushes the visible embed region to the app so it can decide which
|
|
285
|
+
* visualizations to load.
|
|
286
|
+
*/
|
|
287
|
+
private sendVisibleCoordinates = (): void => {
|
|
288
|
+
if (!this.isLazyLoadEnabled) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const coordinates = this.getVisibleCoordinates();
|
|
292
|
+
if (coordinates) {
|
|
293
|
+
this.host.trigger(HostEvent.VisibleEmbedCoordinates, coordinates);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
private getVisibleCoordinates() {
|
|
298
|
+
const iframe = this.host.getIframe();
|
|
299
|
+
if (!iframe) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
return calculateVisibleElementData(
|
|
303
|
+
iframe,
|
|
304
|
+
this.config.enableScrollableContainerLazyLoading,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private registerLazyLoadListeners(): void {
|
|
309
|
+
if (!this.isLazyLoadEnabled || !this.host.getIframe()) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
// Re-registering is safe: drop whatever a previous render attached.
|
|
313
|
+
this.unregisterLazyLoadListeners();
|
|
314
|
+
// TODO: Use passive: true, install modernizr to check for passive
|
|
315
|
+
window.addEventListener('resize', this.sendVisibleCoordinates);
|
|
316
|
+
window.addEventListener('scroll', this.sendVisibleCoordinates, true);
|
|
317
|
+
if (!this.config.enableScrollableContainerLazyLoading) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.observeScrollableContainers();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Tracks the ancestors that can scroll or clip the embed, so the visible
|
|
325
|
+
* region stays correct when the embed lives inside its own scroll
|
|
326
|
+
* container rather than the page.
|
|
327
|
+
*/
|
|
328
|
+
private observeScrollableContainers(): void {
|
|
329
|
+
const iFrame = this.host.getIframe();
|
|
330
|
+
this.scrollContainers = getScrollableAncestors(iFrame);
|
|
331
|
+
this.scrollContainers.forEach((scrollContainer) => {
|
|
332
|
+
scrollContainer.addEventListener('scroll', this.sendVisibleCoordinates);
|
|
333
|
+
});
|
|
334
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const resizeTargets = new Set(
|
|
338
|
+
[iFrame.parentElement, ...getEffectiveClippingAncestors(iFrame)].filter(
|
|
339
|
+
Boolean,
|
|
340
|
+
) as HTMLElement[],
|
|
341
|
+
);
|
|
342
|
+
this.resizeObserver = new ResizeObserver(this.sendVisibleCoordinates);
|
|
343
|
+
resizeTargets.forEach((resizeTarget) => {
|
|
344
|
+
this.resizeObserver.observe(resizeTarget);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
private unregisterLazyLoadListeners(): void {
|
|
349
|
+
if (!this.isLazyLoadEnabled) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
window.removeEventListener('resize', this.sendVisibleCoordinates);
|
|
353
|
+
window.removeEventListener('scroll', this.sendVisibleCoordinates, true);
|
|
354
|
+
this.resizeObserver?.disconnect();
|
|
355
|
+
this.resizeObserver = undefined;
|
|
356
|
+
this.scrollContainers.forEach((scrollContainer) => {
|
|
357
|
+
scrollContainer.removeEventListener('scroll', this.sendVisibleCoordinates);
|
|
358
|
+
});
|
|
359
|
+
this.scrollContainers = [];
|
|
360
|
+
}
|
|
361
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -64,11 +64,13 @@ import {
|
|
|
64
64
|
VizPoint,
|
|
65
65
|
CustomActionPayload,
|
|
66
66
|
ListPageColumns,
|
|
67
|
+
CustomAction,
|
|
67
68
|
CustomActionsPosition,
|
|
68
69
|
CustomActionTarget,
|
|
69
70
|
InterceptedApiType,
|
|
70
71
|
EmbedErrorCodes,
|
|
71
72
|
EmbedErrorDetailsEvent,
|
|
73
|
+
EmbedErrorSeverity,
|
|
72
74
|
ErrorDetailsTypes,
|
|
73
75
|
ContextType,
|
|
74
76
|
AutoMCPFrameRendererViewConfig,
|
|
@@ -94,10 +96,6 @@ import {
|
|
|
94
96
|
UIPassthroughRequest,
|
|
95
97
|
UIPassthroughResponse,
|
|
96
98
|
UIPassthroughArrayResponse,
|
|
97
|
-
HostEventRequest,
|
|
98
|
-
HostEventResponse,
|
|
99
|
-
TriggerPayload,
|
|
100
|
-
TriggerResponse,
|
|
101
99
|
LiveboardTab,
|
|
102
100
|
LiveboardGroup,
|
|
103
101
|
ApplicabilityLevel,
|
|
@@ -105,7 +103,54 @@ import {
|
|
|
105
103
|
FilterUpdate,
|
|
106
104
|
LiveboardFilter,
|
|
107
105
|
LiveboardParameter,
|
|
108
|
-
|
|
106
|
+
PinAnswerToLiveboardRequest,
|
|
107
|
+
PinAnswerToLiveboardResponse,
|
|
108
|
+
SaveAnswerRequest,
|
|
109
|
+
SaveAnswerResponse,
|
|
110
|
+
GetDiscoverabilityStatusResponse,
|
|
111
|
+
GetAvailableUIPassthroughsResponse,
|
|
112
|
+
GetAnswerConfigRequest,
|
|
113
|
+
GetUnsavedAnswerTMLRequest,
|
|
114
|
+
GetUnsavedAnswerTMLResponse,
|
|
115
|
+
GetAnswerSessionRequest,
|
|
116
|
+
GetAnswerSessionResponse,
|
|
117
|
+
GetFiltersRequest,
|
|
118
|
+
GetFiltersResponse,
|
|
119
|
+
GetIframeUrlResponse,
|
|
120
|
+
GetParametersResponse,
|
|
121
|
+
GetTMLRequest,
|
|
122
|
+
GetTabsResponse,
|
|
123
|
+
GetGroupsResponse,
|
|
124
|
+
GetExportRequestForCurrentPinboardResponse,
|
|
125
|
+
UpdateFiltersPassthroughRequest,
|
|
126
|
+
DrilldownRequest,
|
|
127
|
+
} from './contracts/ui-passthrough-contracts';
|
|
128
|
+
import {
|
|
129
|
+
HostEventRequest,
|
|
130
|
+
HostEventResponse,
|
|
131
|
+
TriggerPayload,
|
|
132
|
+
TriggerResponse,
|
|
133
|
+
TriggerData,
|
|
134
|
+
VizScopedRequest,
|
|
135
|
+
RequiredVizRequest,
|
|
136
|
+
ConversationScopedRequest,
|
|
137
|
+
OpenFilterRequest,
|
|
138
|
+
OpenFilterLiveboardRequest,
|
|
139
|
+
OpenFilterSpotterRequest,
|
|
140
|
+
OpenFilterSearchRequest,
|
|
141
|
+
DrillDownRequest,
|
|
142
|
+
OpenParameterRequest,
|
|
143
|
+
SearchRequest,
|
|
144
|
+
SpotterSearchRequest,
|
|
145
|
+
CrossFilterCondition,
|
|
146
|
+
UpdateCrossFilterRequest,
|
|
147
|
+
HostFilterUpdate,
|
|
148
|
+
UpdateFiltersRequest,
|
|
149
|
+
PersonalisedViewRequest,
|
|
150
|
+
ScheduleEmailRequest,
|
|
151
|
+
NavigateRequest,
|
|
152
|
+
SetActiveTabRequest,
|
|
153
|
+
} from './contracts/host-event-contracts';
|
|
109
154
|
|
|
110
155
|
export {
|
|
111
156
|
init,
|
|
@@ -190,6 +235,7 @@ export {
|
|
|
190
235
|
HomePage,
|
|
191
236
|
ListPage,
|
|
192
237
|
VizPoint,
|
|
238
|
+
CustomAction,
|
|
193
239
|
CustomActionPayload,
|
|
194
240
|
UIPassthroughEvent,
|
|
195
241
|
// Host event payload / response contracts. These describe what to send with
|
|
@@ -204,12 +250,55 @@ export {
|
|
|
204
250
|
HostEventResponse,
|
|
205
251
|
TriggerPayload,
|
|
206
252
|
TriggerResponse,
|
|
253
|
+
// Host event contract shapes, map and trigger() data type — see /contracts.
|
|
254
|
+
TriggerData,
|
|
255
|
+
VizScopedRequest,
|
|
256
|
+
RequiredVizRequest,
|
|
257
|
+
ConversationScopedRequest,
|
|
258
|
+
OpenFilterRequest,
|
|
259
|
+
OpenFilterLiveboardRequest,
|
|
260
|
+
OpenFilterSpotterRequest,
|
|
261
|
+
OpenFilterSearchRequest,
|
|
262
|
+
DrillDownRequest,
|
|
263
|
+
OpenParameterRequest,
|
|
264
|
+
SearchRequest,
|
|
265
|
+
SpotterSearchRequest,
|
|
266
|
+
CrossFilterCondition,
|
|
267
|
+
UpdateCrossFilterRequest,
|
|
268
|
+
HostFilterUpdate,
|
|
269
|
+
UpdateFiltersRequest,
|
|
270
|
+
PersonalisedViewRequest,
|
|
271
|
+
ScheduleEmailRequest,
|
|
272
|
+
NavigateRequest,
|
|
273
|
+
SetActiveTabRequest,
|
|
207
274
|
LiveboardTab,
|
|
208
275
|
LiveboardGroup,
|
|
209
276
|
ApplicabilityLevel,
|
|
210
277
|
Applicability,
|
|
211
278
|
FilterUpdate,
|
|
212
279
|
LiveboardFilter,
|
|
280
|
+
// UI passthrough request/response shapes (see UIPassthroughContractBase).
|
|
281
|
+
PinAnswerToLiveboardRequest,
|
|
282
|
+
PinAnswerToLiveboardResponse,
|
|
283
|
+
SaveAnswerRequest,
|
|
284
|
+
SaveAnswerResponse,
|
|
285
|
+
GetDiscoverabilityStatusResponse,
|
|
286
|
+
GetAvailableUIPassthroughsResponse,
|
|
287
|
+
GetAnswerConfigRequest,
|
|
288
|
+
GetUnsavedAnswerTMLRequest,
|
|
289
|
+
GetUnsavedAnswerTMLResponse,
|
|
290
|
+
GetAnswerSessionRequest,
|
|
291
|
+
GetAnswerSessionResponse,
|
|
292
|
+
GetFiltersRequest,
|
|
293
|
+
GetFiltersResponse,
|
|
294
|
+
GetIframeUrlResponse,
|
|
295
|
+
GetParametersResponse,
|
|
296
|
+
GetTMLRequest,
|
|
297
|
+
GetTabsResponse,
|
|
298
|
+
GetGroupsResponse,
|
|
299
|
+
GetExportRequestForCurrentPinboardResponse,
|
|
300
|
+
UpdateFiltersPassthroughRequest,
|
|
301
|
+
DrilldownRequest,
|
|
213
302
|
LiveboardParameter,
|
|
214
303
|
ListPageColumns,
|
|
215
304
|
DataPanelCustomColumnGroupsAccordionState,
|
|
@@ -218,6 +307,7 @@ export {
|
|
|
218
307
|
InterceptedApiType,
|
|
219
308
|
EmbedErrorCodes,
|
|
220
309
|
EmbedErrorDetailsEvent,
|
|
310
|
+
EmbedErrorSeverity,
|
|
221
311
|
ErrorDetailsTypes,
|
|
222
312
|
AutoMCPFrameRendererViewConfig,
|
|
223
313
|
VisualizationOverrides,
|
|
@@ -16,6 +16,39 @@ import * as path from 'path';
|
|
|
16
16
|
|
|
17
17
|
const INDEX_PATH = path.join(__dirname, '..', 'index.ts');
|
|
18
18
|
const REACT_EXPORT_PATH = path.join(__dirname, 'all-types-export.ts');
|
|
19
|
+
const TYPES_PATH = path.join(__dirname, '..', 'types.ts');
|
|
20
|
+
const HOST_EVENT_CONTRACTS_PATH = path.join(
|
|
21
|
+
__dirname, '..', 'contracts', 'host-event-contracts.ts',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// Payload/request/response types named by `{@link X}` in a doc comment that a
|
|
25
|
+
// customer is meant to import. Enums and internal resolver/map mechanics are
|
|
26
|
+
// referenced by docs too but are not part of this exported-payload contract.
|
|
27
|
+
const NON_PAYLOAD_LINK_TARGETS = new Set([
|
|
28
|
+
'HostEvent', 'EmbedEvent', 'ContextType', 'RuntimeFilterOp',
|
|
29
|
+
'HostEventRequest', 'HostEventResponse', 'HostEventRequestMap',
|
|
30
|
+
'HostEventContextRequestMap', 'DefaultHostEventRequest',
|
|
31
|
+
'EmbedApiHostEventMapping', 'TriggerData', 'TriggerResponse',
|
|
32
|
+
'TriggerPayload', 'DeepPartial', 'UIPassthroughRequest',
|
|
33
|
+
'UIPassthroughResponse', 'HostEventName',
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
// Extract the payload types named by `{@link X}` (bare identifier, not a member
|
|
37
|
+
// access like `HostEvent.Foo`) inside the `*Request`/`*Response` docs and
|
|
38
|
+
// the HostEvent enum docs — the links a customer follows to a payload type.
|
|
39
|
+
const extractPayloadLinkTargets = (source: string): Set<string> => {
|
|
40
|
+
const targets = new Set<string>();
|
|
41
|
+
const linkRe = /\{@link\s+([A-Za-z_$][\w$]*)(?:\.[\w$]+)?\s*\}/g;
|
|
42
|
+
let m = linkRe.exec(source);
|
|
43
|
+
while (m !== null) {
|
|
44
|
+
const name = m[1];
|
|
45
|
+
// Member access (`HostEvent.OpenFilter`) captured `HostEvent` — that is
|
|
46
|
+
// an enum, filtered below. A payload type ends in Request/Response.
|
|
47
|
+
if (/(?:Request|Response)$/.test(name)) targets.add(name);
|
|
48
|
+
m = linkRe.exec(source);
|
|
49
|
+
}
|
|
50
|
+
return targets;
|
|
51
|
+
};
|
|
19
52
|
|
|
20
53
|
/**
|
|
21
54
|
* Symbols intentionally absent from the React surface.
|
|
@@ -45,8 +78,8 @@ const REACT_EXEMPT = new Set<string>([
|
|
|
45
78
|
/**
|
|
46
79
|
* PRE-EXISTING gaps, discovered when this spec was introduced. These are
|
|
47
80
|
* symbols React consumers cannot import today — most look like oversights
|
|
48
|
-
* rather than deliberate omissions (e.g. `ContextType`, `
|
|
49
|
-
*
|
|
81
|
+
* rather than deliberate omissions (e.g. `ContextType`, `VizPoint`,
|
|
82
|
+
* the Spotter view configs).
|
|
50
83
|
*
|
|
51
84
|
* This list may only ever SHRINK. Do not add to it — a new entry means a
|
|
52
85
|
* symbol was added to `src/index.ts` without adding it to the React surface,
|
|
@@ -64,7 +97,6 @@ const KNOWN_REACT_GAPS = new Set<string>([
|
|
|
64
97
|
'ContextMenuTriggerOptions',
|
|
65
98
|
'ContextType',
|
|
66
99
|
'ConversationViewConfig',
|
|
67
|
-
'CustomActionPayload',
|
|
68
100
|
'DataLabelFilterOperator',
|
|
69
101
|
'EmbedErrorCodes',
|
|
70
102
|
'EmbedErrorDetailsEvent',
|
|
@@ -203,6 +235,34 @@ describe('react/all-types-export parity with index', () => {
|
|
|
203
235
|
'HostEventResponse',
|
|
204
236
|
'TriggerPayload',
|
|
205
237
|
'TriggerResponse',
|
|
238
|
+
'TriggerData',
|
|
239
|
+
'UpdateFiltersRequest',
|
|
240
|
+
'NavigateRequest',
|
|
206
241
|
].forEach((name) => expect(reactNames.has(name)).toBe(true));
|
|
207
242
|
});
|
|
243
|
+
|
|
244
|
+
// Docs and types must not diverge: a `{@link SomethingRequest}` in a doc
|
|
245
|
+
// comment promises the reader can reach that type. If generation renames
|
|
246
|
+
// or drops a payload type, or an export is removed, the link dangles. This
|
|
247
|
+
// or drops a payload type, or an export is removed, the link dangles. It
|
|
248
|
+
it('every payload type linked from docs is exported from both entry points', () => {
|
|
249
|
+
const indexNames = extractExportedNames(fs.readFileSync(INDEX_PATH, 'utf8'));
|
|
250
|
+
const reactNames = extractExportedNames(fs.readFileSync(REACT_EXPORT_PATH, 'utf8'));
|
|
251
|
+
const linked = new Set<string>([
|
|
252
|
+
...extractPayloadLinkTargets(fs.readFileSync(TYPES_PATH, 'utf8')),
|
|
253
|
+
...extractPayloadLinkTargets(
|
|
254
|
+
fs.readFileSync(HOST_EVENT_CONTRACTS_PATH, 'utf8'),
|
|
255
|
+
),
|
|
256
|
+
]);
|
|
257
|
+
|
|
258
|
+
// Sanity: the doc scan found the payload links we added.
|
|
259
|
+
expect(linked.has('OpenFilterLiveboardRequest')).toBe(true);
|
|
260
|
+
expect(linked.has('DrillDownRequest')).toBe(true);
|
|
261
|
+
expect(linked.size).toBeGreaterThan(5);
|
|
262
|
+
|
|
263
|
+
const dangling = [...linked]
|
|
264
|
+
.filter((name) => !NON_PAYLOAD_LINK_TARGETS.has(name))
|
|
265
|
+
.filter((name) => !indexNames.has(name) || !reactNames.has(name));
|
|
266
|
+
expect(dangling).toEqual([]);
|
|
267
|
+
});
|
|
208
268
|
});
|
|
@@ -66,15 +66,61 @@ export {
|
|
|
66
66
|
HostEventResponse,
|
|
67
67
|
TriggerPayload,
|
|
68
68
|
TriggerResponse,
|
|
69
|
+
// Host event contract shapes, map and trigger() data type — see /contracts.
|
|
70
|
+
TriggerData,
|
|
71
|
+
VizScopedRequest,
|
|
72
|
+
RequiredVizRequest,
|
|
73
|
+
ConversationScopedRequest,
|
|
74
|
+
OpenFilterRequest,
|
|
75
|
+
OpenFilterLiveboardRequest,
|
|
76
|
+
OpenFilterSpotterRequest,
|
|
77
|
+
OpenFilterSearchRequest,
|
|
78
|
+
DrillDownRequest,
|
|
79
|
+
OpenParameterRequest,
|
|
80
|
+
SearchRequest,
|
|
81
|
+
SpotterSearchRequest,
|
|
82
|
+
CrossFilterCondition,
|
|
83
|
+
UpdateCrossFilterRequest,
|
|
84
|
+
HostFilterUpdate,
|
|
85
|
+
UpdateFiltersRequest,
|
|
86
|
+
PersonalisedViewRequest,
|
|
87
|
+
ScheduleEmailRequest,
|
|
88
|
+
NavigateRequest,
|
|
89
|
+
SetActiveTabRequest,
|
|
69
90
|
LiveboardTab,
|
|
70
91
|
LiveboardGroup,
|
|
71
92
|
ApplicabilityLevel,
|
|
72
93
|
Applicability,
|
|
73
94
|
FilterUpdate,
|
|
74
95
|
LiveboardFilter,
|
|
96
|
+
// UI passthrough request/response shapes (see UIPassthroughContractBase).
|
|
97
|
+
PinAnswerToLiveboardRequest,
|
|
98
|
+
PinAnswerToLiveboardResponse,
|
|
99
|
+
SaveAnswerRequest,
|
|
100
|
+
SaveAnswerResponse,
|
|
101
|
+
GetDiscoverabilityStatusResponse,
|
|
102
|
+
GetAvailableUIPassthroughsResponse,
|
|
103
|
+
GetAnswerConfigRequest,
|
|
104
|
+
GetUnsavedAnswerTMLRequest,
|
|
105
|
+
GetUnsavedAnswerTMLResponse,
|
|
106
|
+
GetAnswerSessionRequest,
|
|
107
|
+
GetAnswerSessionResponse,
|
|
108
|
+
GetFiltersRequest,
|
|
109
|
+
GetFiltersResponse,
|
|
110
|
+
GetIframeUrlResponse,
|
|
111
|
+
GetParametersResponse,
|
|
112
|
+
GetTMLRequest,
|
|
113
|
+
GetTabsResponse,
|
|
114
|
+
GetGroupsResponse,
|
|
115
|
+
GetExportRequestForCurrentPinboardResponse,
|
|
116
|
+
UpdateFiltersPassthroughRequest,
|
|
117
|
+
DrilldownRequest,
|
|
75
118
|
LiveboardParameter,
|
|
76
119
|
DataPanelCustomColumnGroupsAccordionState,
|
|
77
120
|
InterceptedApiType,
|
|
121
|
+
EmbedErrorSeverity,
|
|
122
|
+
CustomAction,
|
|
123
|
+
CustomActionPayload,
|
|
78
124
|
CustomActionsPosition,
|
|
79
125
|
CustomActionTarget,
|
|
80
126
|
SpotterAnalystConfig,
|