@thoughtspot/visual-embed-sdk 1.42.1-alpha.7 → 1.42.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 +4 -3
- package/cjs/src/embed/app.d.ts +20 -0
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +5 -4
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +32 -0
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +1 -11
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js +0 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -3
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +6 -6
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +1 -3
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -3
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +16 -44
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +0 -2
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +3 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +1 -2
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -2
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +3 -3
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/all-types-export.spec.js +0 -8
- package/cjs/src/react/all-types-export.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +1 -2
- 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/util.d.ts +1 -0
- package/cjs/src/react/util.d.ts.map +1 -1
- package/cjs/src/types.d.ts +105 -143
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +103 -98
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processData.d.ts +1 -1
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +8 -8
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +2 -1
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +4 -2
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/dist/{index-DvNA626T.js → index-CWQnMX2L.js} +1 -1
- package/dist/src/embed/app.d.ts +20 -0
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +1 -11
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -3
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -3
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -2
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -2
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/util.d.ts +1 -0
- package/dist/src/react/util.d.ts.map +1 -1
- package/dist/src/types.d.ts +105 -143
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +2 -1
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +157 -280
- package/dist/tsembed-react.js +301 -500
- package/dist/tsembed.es.js +156 -280
- package/dist/tsembed.js +299 -499
- package/dist/visual-embed-sdk-react-full.d.ts +129 -160
- package/dist/visual-embed-sdk-react.d.ts +129 -157
- package/dist/visual-embed-sdk.d.ts +129 -160
- package/lib/package.json +4 -3
- package/lib/src/embed/app.d.ts +20 -0
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +5 -4
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +32 -0
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +1 -11
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js +0 -1
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -3
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +6 -6
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +1 -3
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -3
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +16 -44
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +0 -2
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- 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/react/all-types-export.d.ts +1 -2
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +2 -2
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/all-types-export.spec.js +0 -8
- package/lib/src/react/all-types-export.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +1 -2
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +4 -3
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/util.d.ts +1 -0
- package/lib/src/react/util.d.ts.map +1 -1
- package/lib/src/types.d.ts +105 -143
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +102 -97
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processData.d.ts +1 -1
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +8 -8
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +2 -1
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +4 -2
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/package.json +4 -3
- package/src/embed/app.spec.ts +45 -0
- package/src/embed/app.ts +26 -4
- package/src/embed/hostEventClient/contracts.ts +0 -10
- package/src/embed/hostEventClient/host-event-client.ts +7 -3
- package/src/embed/search.ts +1 -3
- package/src/embed/ts-embed.spec.ts +7 -9
- package/src/embed/ts-embed.ts +33 -68
- package/src/index.ts +3 -4
- package/src/react/all-types-export.spec.ts +1 -9
- package/src/react/all-types-export.ts +6 -10
- package/src/react/index.tsx +130 -155
- package/src/types.ts +104 -145
- package/src/utils/processData.spec.ts +1 -0
- package/src/utils/processData.ts +11 -11
- package/src/utils/processTrigger.ts +5 -2
- package/cjs/src/api-intercept.d.ts +0 -31
- package/cjs/src/api-intercept.d.ts.map +0 -1
- package/cjs/src/api-intercept.js +0 -119
- package/cjs/src/api-intercept.js.map +0 -1
- package/cjs/src/api-intercept.spec.d.ts +0 -2
- package/cjs/src/api-intercept.spec.d.ts.map +0 -1
- package/cjs/src/api-intercept.spec.js +0 -122
- package/cjs/src/api-intercept.spec.js.map +0 -1
- package/dist/index-BCC3Z072.js +0 -7371
- package/dist/index-BEzW4MDA.js +0 -7371
- package/dist/index-BaESA9rq.js +0 -7371
- package/dist/index-CFNZIcKr.js +0 -7447
- package/dist/index-CqKTa1Fe.js +0 -7447
- package/dist/index-DFnPKcjZ.js +0 -7447
- package/dist/index-DhFH7b7U.js +0 -7447
- package/dist/src/api-intercept.d.ts +0 -31
- package/dist/src/api-intercept.d.ts.map +0 -1
- package/dist/src/api-intercept.spec.d.ts +0 -2
- package/dist/src/api-intercept.spec.d.ts.map +0 -1
- package/lib/src/api-intercept.d.ts +0 -31
- package/lib/src/api-intercept.d.ts.map +0 -1
- package/lib/src/api-intercept.js +0 -112
- package/lib/src/api-intercept.js.map +0 -1
- package/lib/src/api-intercept.spec.d.ts +0 -2
- package/lib/src/api-intercept.spec.d.ts.map +0 -1
- package/lib/src/api-intercept.spec.js +0 -119
- package/lib/src/api-intercept.spec.js.map +0 -1
- package/src/api-intercept.ts +0 -139
package/src/types.ts
CHANGED
|
@@ -329,7 +329,7 @@ export interface CustomisationsInterface {
|
|
|
329
329
|
* if a trusted authentication server is used.
|
|
330
330
|
* @group Authentication / Init
|
|
331
331
|
*/
|
|
332
|
-
export interface EmbedConfig
|
|
332
|
+
export interface EmbedConfig {
|
|
333
333
|
/**
|
|
334
334
|
* The ThoughtSpot cluster hostname or IP address.
|
|
335
335
|
*/
|
|
@@ -726,7 +726,7 @@ export interface FrameParams {
|
|
|
726
726
|
/**
|
|
727
727
|
* The common configuration object for an embedded view.
|
|
728
728
|
*/
|
|
729
|
-
export interface BaseViewConfig
|
|
729
|
+
export interface BaseViewConfig {
|
|
730
730
|
/**
|
|
731
731
|
* @hidden
|
|
732
732
|
*/
|
|
@@ -1835,7 +1835,7 @@ export enum EmbedEvent {
|
|
|
1835
1835
|
*/
|
|
1836
1836
|
Load = 'load',
|
|
1837
1837
|
/**
|
|
1838
|
-
* Data pertaining to an Answer or
|
|
1838
|
+
* Data pertaining to an Answer, Liveboard or Spotter visualization is received.
|
|
1839
1839
|
* The event payload includes the raw data of the object.
|
|
1840
1840
|
* @return data - Answer of Liveboard data
|
|
1841
1841
|
* @version SDK: 1.1.0 | ThoughtSpot: ts7.may.cl, 8.4.1.sw
|
|
@@ -2920,21 +2920,6 @@ export enum EmbedEvent {
|
|
|
2920
2920
|
* @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
|
|
2921
2921
|
*/
|
|
2922
2922
|
OrgSwitched = 'orgSwitched',
|
|
2923
|
-
/**
|
|
2924
|
-
* Emitted when the user intercepts a URL.
|
|
2925
|
-
*
|
|
2926
|
-
* Supported on all embed types.
|
|
2927
|
-
*
|
|
2928
|
-
* @example
|
|
2929
|
-
* ```js
|
|
2930
|
-
* embed.on(EmbedEvent.ApiIntercept, (payload) => {
|
|
2931
|
-
* console.log('payload', payload);
|
|
2932
|
-
* })
|
|
2933
|
-
* ```
|
|
2934
|
-
*
|
|
2935
|
-
* @version SDK: 1.42.0 | ThoughtSpot: 10.14.0.cl
|
|
2936
|
-
*/
|
|
2937
|
-
ApiIntercept = 'ApiIntercept',
|
|
2938
2923
|
}
|
|
2939
2924
|
|
|
2940
2925
|
/**
|
|
@@ -3224,7 +3209,7 @@ export enum HostEvent {
|
|
|
3224
3209
|
* the following parameters:
|
|
3225
3210
|
*
|
|
3226
3211
|
* @param
|
|
3227
|
-
* `vizId`- GUID of the saved Answer or visualization to pin to a Liveboard.
|
|
3212
|
+
* `vizId`- GUID of the saved Answer or Spotter visualization ID to pin to a Liveboard.
|
|
3228
3213
|
* Optional when pinning a new chart or table generated from a Search query.
|
|
3229
3214
|
* **Required** in Spotter Embed.
|
|
3230
3215
|
* @param
|
|
@@ -3276,10 +3261,16 @@ export enum HostEvent {
|
|
|
3276
3261
|
* ```
|
|
3277
3262
|
* @example
|
|
3278
3263
|
* ```js
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3264
|
+
|
|
3265
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in Pin host event.
|
|
3266
|
+
* let latestSpotterVizId = '';
|
|
3267
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3268
|
+
* latestSpotterVizId = payload.data.id;
|
|
3269
|
+
* });
|
|
3270
|
+
*
|
|
3271
|
+
* spotterEmbed.trigger(HostEvent.Pin, { vizId: latestSpotterVizId });
|
|
3272
|
+
* ```
|
|
3273
|
+
*
|
|
3283
3274
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3284
3275
|
*/
|
|
3285
3276
|
Pin = 'pin',
|
|
@@ -3354,10 +3345,15 @@ export enum HostEvent {
|
|
|
3354
3345
|
* ```
|
|
3355
3346
|
* @example
|
|
3356
3347
|
* ```js
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3348
|
+
|
|
3349
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in DownloadAsPdf host event.
|
|
3350
|
+
* let latestSpotterVizId = '';
|
|
3351
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3352
|
+
* latestSpotterVizId = payload.data.id;
|
|
3353
|
+
* });
|
|
3354
|
+
*
|
|
3355
|
+
* spotterEmbed.trigger(HostEvent.DownloadAsPdf, { vizId: latestSpotterVizId });
|
|
3356
|
+
* ```
|
|
3361
3357
|
*
|
|
3362
3358
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3363
3359
|
*/
|
|
@@ -3384,10 +3380,14 @@ export enum HostEvent {
|
|
|
3384
3380
|
* ```
|
|
3385
3381
|
* @example
|
|
3386
3382
|
* ```js
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3383
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in MakeACopy host event.
|
|
3384
|
+
* let latestSpotterVizId = '';
|
|
3385
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3386
|
+
* latestSpotterVizId = payload.data.id;
|
|
3387
|
+
* });
|
|
3388
|
+
*
|
|
3389
|
+
* spotterEmbed.trigger(HostEvent.MakeACopy, { vizId: latestSpotterVizId });
|
|
3390
|
+
* ```
|
|
3391
3391
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3392
3392
|
*/
|
|
3393
3393
|
MakeACopy = 'makeACopy',
|
|
@@ -3472,15 +3472,7 @@ export enum HostEvent {
|
|
|
3472
3472
|
* ```
|
|
3473
3473
|
* @example
|
|
3474
3474
|
* ```js
|
|
3475
|
-
*
|
|
3476
|
-
* vizId:'730496d6-6903-4601-937e-2c691821af3c'
|
|
3477
|
-
* });
|
|
3478
|
-
* ```
|
|
3479
|
-
* @example
|
|
3480
|
-
* ```js
|
|
3481
|
-
* const editResponse = await spotterEmbed.trigger(HostEvent.Edit, {
|
|
3482
|
-
* vizId:'730496d6-6903-4601-937e-2c691821af3c'
|
|
3483
|
-
* });
|
|
3475
|
+
* spotterEmbed.trigger(HostEvent.Edit);
|
|
3484
3476
|
* ```
|
|
3485
3477
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3486
3478
|
*/
|
|
@@ -3529,16 +3521,23 @@ export enum HostEvent {
|
|
|
3529
3521
|
* );
|
|
3530
3522
|
* })
|
|
3531
3523
|
* ```
|
|
3532
|
-
* @example
|
|
3524
|
+
* * @example
|
|
3533
3525
|
* ```js
|
|
3534
|
-
|
|
3535
|
-
|
|
3526
|
+
|
|
3527
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in Pin host event.
|
|
3528
|
+
* let latestSpotterVizId = '';
|
|
3529
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3530
|
+
* latestSpotterVizId = payload.data.id;
|
|
3531
|
+
* });
|
|
3532
|
+
*
|
|
3533
|
+
* spotterEmbed.trigger(HostEvent.GetTML, {
|
|
3534
|
+
* vizId: latestSpotterVizId
|
|
3536
3535
|
* }).then((tml) => {
|
|
3537
3536
|
* console.log(
|
|
3538
3537
|
* tml.answer.search_query // TML representation of the search query
|
|
3539
3538
|
* );
|
|
3540
3539
|
* })
|
|
3541
|
-
|
|
3540
|
+
* ```
|
|
3542
3541
|
* @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1.sw
|
|
3543
3542
|
* @important
|
|
3544
3543
|
*/
|
|
@@ -3602,7 +3601,7 @@ export enum HostEvent {
|
|
|
3602
3601
|
/**
|
|
3603
3602
|
* Trigger the **Download** action on charts in
|
|
3604
3603
|
* the embedded view.
|
|
3605
|
-
* @param - `vizId` refers to the
|
|
3604
|
+
* @param - `vizId` refers to the Visualization ID in Spotter embed and is required in Spotter embed.
|
|
3606
3605
|
* @example
|
|
3607
3606
|
* ```js
|
|
3608
3607
|
* liveboardEmbed.trigger(HostEvent.Download, {vizId:
|
|
@@ -3612,10 +3611,14 @@ export enum HostEvent {
|
|
|
3612
3611
|
* embed.trigger(HostEvent.Download)
|
|
3613
3612
|
* ```
|
|
3614
3613
|
* ```js
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3614
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in Download host event.
|
|
3615
|
+
* let latestSpotterVizId = '';
|
|
3616
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3617
|
+
* latestSpotterVizId = payload.data.id;
|
|
3618
|
+
* });
|
|
3619
|
+
*
|
|
3620
|
+
* spotterEmbed.trigger(HostEvent.Download, { vizId: latestSpotterVizId });
|
|
3621
|
+
* ```
|
|
3619
3622
|
* @deprecated from SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl ,9.4.1.sw
|
|
3620
3623
|
* Use {@link DownloadAsPng}
|
|
3621
3624
|
* @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.sw
|
|
@@ -3633,9 +3636,13 @@ export enum HostEvent {
|
|
|
3633
3636
|
*
|
|
3634
3637
|
* searchEmbed.trigger(HostEvent.DownloadAsPng)
|
|
3635
3638
|
*
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in DownloadAsPng host event.
|
|
3640
|
+
* let latestSpotterVizId = '';
|
|
3641
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3642
|
+
* latestSpotterVizId = payload.data.id;
|
|
3643
|
+
* });
|
|
3644
|
+
*
|
|
3645
|
+
* spotterEmbed.trigger(HostEvent.DownloadAsPng, { vizId: latestSpotterVizId });
|
|
3639
3646
|
* ```
|
|
3640
3647
|
*
|
|
3641
3648
|
* @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.4.1.sw
|
|
@@ -3644,7 +3651,7 @@ export enum HostEvent {
|
|
|
3644
3651
|
/**
|
|
3645
3652
|
* Trigger the **Download** > **CSV** action on tables in
|
|
3646
3653
|
* the embedded view.
|
|
3647
|
-
* @param - `vizId` refers to the
|
|
3654
|
+
* @param - `vizId` refers to the Visualization ID in Spotter embed and is required in Spotter embed.
|
|
3648
3655
|
* @example
|
|
3649
3656
|
* ```js
|
|
3650
3657
|
* liveboardEmbed.trigger(HostEvent.DownloadAsCsv, {vizId:
|
|
@@ -3657,9 +3664,13 @@ export enum HostEvent {
|
|
|
3657
3664
|
* searchEmbed.trigger(HostEvent.DownloadAsCsv)
|
|
3658
3665
|
* ```
|
|
3659
3666
|
* ```js
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3667
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in DownloadAsCsv host event.
|
|
3668
|
+
* let latestSpotterVizId = '';
|
|
3669
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3670
|
+
* latestSpotterVizId = payload.data.id;
|
|
3671
|
+
* });
|
|
3672
|
+
*
|
|
3673
|
+
* spotterEmbed.trigger(HostEvent.DownloadAsCsv, { vizId: latestSpotterVizId });
|
|
3663
3674
|
* ```
|
|
3664
3675
|
* @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.sw
|
|
3665
3676
|
*/
|
|
@@ -3667,7 +3678,7 @@ export enum HostEvent {
|
|
|
3667
3678
|
/**
|
|
3668
3679
|
* Trigger the **Download** > **XLSX** action on tables
|
|
3669
3680
|
* in the embedded view.
|
|
3670
|
-
* @param - `vizId` refers to the
|
|
3681
|
+
* @param - `vizId` refers to the Visualization ID in Spotter embed and is required in Spotter embed.
|
|
3671
3682
|
* @example
|
|
3672
3683
|
* ```js
|
|
3673
3684
|
* liveboardEmbed.trigger(HostEvent.DownloadAsXlsx, {vizId:
|
|
@@ -3680,9 +3691,13 @@ export enum HostEvent {
|
|
|
3680
3691
|
* searchEmbed.trigger(HostEvent.DownloadAsXlsx)
|
|
3681
3692
|
* ```
|
|
3682
3693
|
* ```js
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3694
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in DownloadAsXlsx host event.
|
|
3695
|
+
* let latestSpotterVizId = '';
|
|
3696
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
3697
|
+
* latestSpotterVizId = payload.data.id;
|
|
3698
|
+
* });
|
|
3699
|
+
*
|
|
3700
|
+
* spotterEmbed.trigger(HostEvent.DownloadAsXlsx, { vizId: latestSpotterVizId });
|
|
3686
3701
|
* ```
|
|
3687
3702
|
* @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.sw
|
|
3688
3703
|
*/
|
|
@@ -3719,7 +3734,7 @@ export enum HostEvent {
|
|
|
3719
3734
|
* ```
|
|
3720
3735
|
*
|
|
3721
3736
|
* ```js
|
|
3722
|
-
* // Save
|
|
3737
|
+
* // Save a Visualization in Spotter (requires vizId)
|
|
3723
3738
|
* spotterEmbed.trigger(HostEvent.Save, {
|
|
3724
3739
|
* vizId: "730496d6-6903-4601-937e-2c691821af3c"
|
|
3725
3740
|
* })
|
|
@@ -4041,11 +4056,13 @@ export enum HostEvent {
|
|
|
4041
4056
|
* });
|
|
4042
4057
|
*```
|
|
4043
4058
|
*```js
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4059
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in GetParameters host event.
|
|
4060
|
+
* let latestSpotterVizId = '';
|
|
4061
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
4062
|
+
* latestSpotterVizId = payload.data.id;
|
|
4063
|
+
* });
|
|
4064
|
+
*
|
|
4065
|
+
* spotterEmbed.trigger(HostEvent.GetParameters, { vizId: latestSpotterVizId });
|
|
4049
4066
|
*```
|
|
4050
4067
|
* @version SDK: 1.29.0 | ThoughtSpot: 10.1.0.cl, 10.1.0.sw
|
|
4051
4068
|
*/
|
|
@@ -4088,11 +4105,13 @@ export enum HostEvent {
|
|
|
4088
4105
|
* ```
|
|
4089
4106
|
* @example
|
|
4090
4107
|
* ```js
|
|
4091
|
-
*
|
|
4092
|
-
*
|
|
4093
|
-
*
|
|
4094
|
-
*
|
|
4108
|
+
* // You can use the Data event dispatched on each answer creation to get the vizId and use in SaveAnswer host event.
|
|
4109
|
+
* let latestSpotterVizId = '';
|
|
4110
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
4111
|
+
* latestSpotterVizId = payload.data.id;
|
|
4095
4112
|
* });
|
|
4113
|
+
*
|
|
4114
|
+
* spotterEmbed.trigger(HostEvent.SaveAnswer, { vizId: latestSpotterVizId });
|
|
4096
4115
|
* ```
|
|
4097
4116
|
* @version SDK: 1.36.0 | ThoughtSpot: 10.6.0.cl
|
|
4098
4117
|
*/
|
|
@@ -4176,12 +4195,15 @@ export enum HostEvent {
|
|
|
4176
4195
|
DeleteLastPrompt = 'DeleteLastPrompt',
|
|
4177
4196
|
/**
|
|
4178
4197
|
* Toggle the visualization to chart or table view.
|
|
4179
|
-
* @param - `vizId ` refers to the
|
|
4198
|
+
* @param - `vizId ` refers to the Visualization ID in Spotter embed and is required.
|
|
4180
4199
|
* @example
|
|
4181
4200
|
* ```js
|
|
4182
|
-
*
|
|
4183
|
-
*
|
|
4201
|
+
* let latestSpotterVizId = '';
|
|
4202
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
4203
|
+
* latestSpotterVizId = payload.data.id;
|
|
4184
4204
|
* });
|
|
4205
|
+
*
|
|
4206
|
+
* spotterEmbed.trigger(HostEvent.AnswerChartSwitcher, { vizId: latestSpotterVizId });
|
|
4185
4207
|
*```
|
|
4186
4208
|
* @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
|
|
4187
4209
|
*/
|
|
@@ -4210,12 +4232,16 @@ export enum HostEvent {
|
|
|
4210
4232
|
*/
|
|
4211
4233
|
VisibleEmbedCoordinates = 'visibleEmbedCoordinates',
|
|
4212
4234
|
/**
|
|
4213
|
-
* Trigger the *
|
|
4214
|
-
* @param - `vizId` refers to the
|
|
4235
|
+
* Trigger the *Spotter* action for visualizations present on the liveboard's vizzes.
|
|
4236
|
+
* @param - `vizId` refers to the Visualization ID in Spotter embed and is required.
|
|
4215
4237
|
* @example
|
|
4216
4238
|
* ```js
|
|
4217
|
-
*
|
|
4218
|
-
* {
|
|
4239
|
+
* let latestSpotterVizId = '';
|
|
4240
|
+
* spotterEmbed.on(EmbedEvent.Data, (payload) => {
|
|
4241
|
+
* latestSpotterVizId = payload.data.id;
|
|
4242
|
+
* });
|
|
4243
|
+
*
|
|
4244
|
+
* spotterEmbed.trigger(HostEvent.AskSpotter, { vizId: latestSpotterVizId });
|
|
4219
4245
|
* ```
|
|
4220
4246
|
* @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
|
|
4221
4247
|
*/
|
|
@@ -4276,6 +4302,7 @@ export enum Param {
|
|
|
4276
4302
|
HideResult = 'hideResult',
|
|
4277
4303
|
UseLastSelectedDataSource = 'useLastSelectedSources',
|
|
4278
4304
|
Tag = 'tag',
|
|
4305
|
+
HideTagFilterChips = 'hideTagFilterChips',
|
|
4279
4306
|
AutoLogin = 'autoLogin',
|
|
4280
4307
|
searchTokenString = 'searchTokenString',
|
|
4281
4308
|
executeSearch = 'executeSearch',
|
|
@@ -5911,71 +5938,3 @@ export interface DefaultAppInitData {
|
|
|
5911
5938
|
hiddenListColumns: ListPageColumns[];
|
|
5912
5939
|
customActions: CustomAction[];
|
|
5913
5940
|
}
|
|
5914
|
-
|
|
5915
|
-
/**
|
|
5916
|
-
* Enum for the type of API intercepted
|
|
5917
|
-
*/
|
|
5918
|
-
export enum InterceptedApiType {
|
|
5919
|
-
/**
|
|
5920
|
-
* The apis that are use to get the metadata for the embed
|
|
5921
|
-
*/
|
|
5922
|
-
METADATA = 'METADATA',
|
|
5923
|
-
/**
|
|
5924
|
-
* The apis that are use to get the data for the embed
|
|
5925
|
-
*/
|
|
5926
|
-
ANSWER_DATA = 'ANSWER_DATA',
|
|
5927
|
-
/**
|
|
5928
|
-
* This will intercept all the apis
|
|
5929
|
-
*/
|
|
5930
|
-
ALL = 'ALL',
|
|
5931
|
-
/**
|
|
5932
|
-
* The apis that are use to get the data for the liveboard
|
|
5933
|
-
*/
|
|
5934
|
-
LIVEBOARD_DATA = 'LIVEBOARD_DATA',
|
|
5935
|
-
}
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
export type InterceptV2Flags = {
|
|
5939
|
-
/**
|
|
5940
|
-
* Enable intercepting the apis
|
|
5941
|
-
*
|
|
5942
|
-
* @example
|
|
5943
|
-
* ```js
|
|
5944
|
-
* const embed = new LiveboardEmbed('#embed', {
|
|
5945
|
-
* ...viewConfig,
|
|
5946
|
-
* enableApiIntercept: true,
|
|
5947
|
-
* interceptUrls: [InterceptedApiType.DATA],
|
|
5948
|
-
* })
|
|
5949
|
-
* ```
|
|
5950
|
-
*
|
|
5951
|
-
*/
|
|
5952
|
-
enableApiIntercept?: boolean;
|
|
5953
|
-
/**
|
|
5954
|
-
* The apis to intercept
|
|
5955
|
-
*
|
|
5956
|
-
* @example
|
|
5957
|
-
* ```js
|
|
5958
|
-
* const embed = new LiveboardEmbed('#embed', {
|
|
5959
|
-
* ...viewConfig,
|
|
5960
|
-
* enableApiIntercept: true,
|
|
5961
|
-
* interceptUrls: [InterceptedApiType.DATA],
|
|
5962
|
-
* })
|
|
5963
|
-
* ```
|
|
5964
|
-
*/
|
|
5965
|
-
interceptUrls?: (string | InterceptedApiType)[];
|
|
5966
|
-
/**
|
|
5967
|
-
* The timeout for the intercept, default is 30000ms
|
|
5968
|
-
* the api will error out if the timeout is reached
|
|
5969
|
-
*
|
|
5970
|
-
* @example
|
|
5971
|
-
* ```js
|
|
5972
|
-
* const embed = new LiveboardEmbed('#embed', {
|
|
5973
|
-
* ...viewConfig,
|
|
5974
|
-
* enableApiIntercept: true,
|
|
5975
|
-
* interceptUrls: [InterceptedApiType.ALL],
|
|
5976
|
-
* interceptTimeout: 1000,
|
|
5977
|
-
* })
|
|
5978
|
-
* ```
|
|
5979
|
-
*/
|
|
5980
|
-
interceptTimeout?: number;
|
|
5981
|
-
}
|
package/src/utils/processData.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { AuthType, CustomActionPayload, EmbedEvent } from '../types';
|
|
|
10
10
|
import { AnswerService } from './graphql/answerService/answerService';
|
|
11
11
|
import { resetCachedAuthToken } from '../authToken';
|
|
12
12
|
import { ERROR_MESSAGE } from '../errors';
|
|
13
|
+
import { logger } from '../utils/logger';
|
|
13
14
|
import { handleExitPresentMode } from '../utils';
|
|
14
15
|
import { resetCachedPreauthInfo, resetCachedSessionInfo } from './sessionInfoService';
|
|
15
|
-
import { processApiIntercept } from '../api-intercept';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Process the ExitPresentMode event and handle default fullscreen exit
|
|
@@ -21,7 +21,7 @@ import { processApiIntercept } from '../api-intercept';
|
|
|
21
21
|
function processExitPresentMode(e: any) {
|
|
22
22
|
const embedConfig = getEmbedConfig();
|
|
23
23
|
const disableFullscreenPresentation = embedConfig?.disableFullscreenPresentation ?? true;
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
if (!disableFullscreenPresentation) {
|
|
26
26
|
handleExitPresentMode();
|
|
27
27
|
}
|
|
@@ -103,7 +103,7 @@ export function processAuthFailure(e: any, containerEl: Element) {
|
|
|
103
103
|
const {
|
|
104
104
|
loginFailedMessage, authType, disableLoginFailurePage, autoLogin,
|
|
105
105
|
} = getEmbedConfig();
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
const isEmbeddedSSO = authType === AuthType.EmbeddedSSO;
|
|
108
108
|
const isTrustedAuth = authType === AuthType.TrustedAuthToken || authType === AuthType.TrustedAuthTokenCookieless;
|
|
109
109
|
const isEmbeddedSSOInfoFailure = isEmbeddedSSO && e?.data?.type === AuthFailureType.UNAUTHENTICATED_FAILURE;
|
|
@@ -144,26 +144,26 @@ function processAuthLogout(e: any, containerEl: Element) {
|
|
|
144
144
|
*/
|
|
145
145
|
export function processEventData(
|
|
146
146
|
type: EmbedEvent,
|
|
147
|
-
|
|
147
|
+
e: any,
|
|
148
148
|
thoughtSpotHost: string,
|
|
149
149
|
containerEl: Element,
|
|
150
150
|
): any {
|
|
151
151
|
switch (type) {
|
|
152
152
|
case EmbedEvent.CustomAction:
|
|
153
|
-
return processCustomAction(
|
|
153
|
+
return processCustomAction(e, thoughtSpotHost);
|
|
154
154
|
case EmbedEvent.AuthInit:
|
|
155
|
-
return processAuthInit(
|
|
155
|
+
return processAuthInit(e);
|
|
156
156
|
case EmbedEvent.NoCookieAccess:
|
|
157
|
-
return processNoCookieAccess(
|
|
157
|
+
return processNoCookieAccess(e, containerEl);
|
|
158
158
|
case EmbedEvent.AuthFailure:
|
|
159
|
-
return processAuthFailure(
|
|
159
|
+
return processAuthFailure(e, containerEl);
|
|
160
160
|
case EmbedEvent.AuthLogout:
|
|
161
|
-
return processAuthLogout(
|
|
161
|
+
return processAuthLogout(e, containerEl);
|
|
162
162
|
case EmbedEvent.ExitPresentMode:
|
|
163
|
-
return processExitPresentMode(
|
|
163
|
+
return processExitPresentMode(e);
|
|
164
164
|
case EmbedEvent.CLEAR_INFO_CACHE:
|
|
165
165
|
return processClearInfoCache();
|
|
166
166
|
default:
|
|
167
167
|
}
|
|
168
|
-
return
|
|
168
|
+
return e;
|
|
169
169
|
}
|
|
@@ -22,12 +22,13 @@ export const reload = (iFrame: HTMLIFrameElement) => {
|
|
|
22
22
|
* @param message
|
|
23
23
|
* @param message.type
|
|
24
24
|
* @param message.data
|
|
25
|
+
* @param message.context
|
|
25
26
|
* @param thoughtSpotHost
|
|
26
27
|
* @param channel
|
|
27
28
|
*/
|
|
28
29
|
function postIframeMessage(
|
|
29
30
|
iFrame: HTMLIFrameElement,
|
|
30
|
-
message: { type: HostEvent; data: any },
|
|
31
|
+
message: { type: HostEvent; data: any, context?: any },
|
|
31
32
|
thoughtSpotHost: string,
|
|
32
33
|
channel?: MessageChannel,
|
|
33
34
|
) {
|
|
@@ -42,12 +43,14 @@ export const TRIGGER_TIMEOUT = 30000;
|
|
|
42
43
|
* @param messageType
|
|
43
44
|
* @param thoughtSpotHost
|
|
44
45
|
* @param data
|
|
46
|
+
* @param context
|
|
45
47
|
*/
|
|
46
48
|
export function processTrigger(
|
|
47
49
|
iFrame: HTMLIFrameElement,
|
|
48
50
|
messageType: HostEvent,
|
|
49
51
|
thoughtSpotHost: string,
|
|
50
52
|
data: any,
|
|
53
|
+
context?: any,
|
|
51
54
|
): Promise<any> {
|
|
52
55
|
return new Promise<any>((res, rej) => {
|
|
53
56
|
if (messageType === HostEvent.Reload) {
|
|
@@ -83,6 +86,6 @@ export function processTrigger(
|
|
|
83
86
|
res(new Error(ERROR_MESSAGE.TRIGGER_TIMED_OUT));
|
|
84
87
|
}, TRIGGER_TIMEOUT);
|
|
85
88
|
|
|
86
|
-
return postIframeMessage(iFrame, { type: messageType, data }, thoughtSpotHost, channel);
|
|
89
|
+
return postIframeMessage(iFrame, { type: messageType, data, context }, thoughtSpotHost, channel);
|
|
87
90
|
});
|
|
88
91
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BaseViewConfig, EmbedConfig, InterceptV2Flags, EmbedEvent } from "./types";
|
|
2
|
-
export declare const processApiIntercept: (eventData: any) => Promise<any>;
|
|
3
|
-
export declare const getInterceptInitData: (embedConfig: EmbedConfig, viewConfig: BaseViewConfig) => InterceptV2Flags;
|
|
4
|
-
export declare const handleInterceptEvent: (params: {
|
|
5
|
-
eventData: any;
|
|
6
|
-
executeEvent: (eventType: EmbedEvent, data: any) => void;
|
|
7
|
-
embedConfig: EmbedConfig;
|
|
8
|
-
viewConfig: BaseViewConfig;
|
|
9
|
-
getUnsavedAnswerTml: (props: {
|
|
10
|
-
sessionId?: string;
|
|
11
|
-
vizId?: string;
|
|
12
|
-
}) => Promise<{
|
|
13
|
-
tml: string;
|
|
14
|
-
}>;
|
|
15
|
-
}) => Promise<void>;
|
|
16
|
-
export declare const processLegacyInterceptResponse: (payload: any) => {
|
|
17
|
-
data: {
|
|
18
|
-
execute: any;
|
|
19
|
-
response: {
|
|
20
|
-
body: {
|
|
21
|
-
errors: {
|
|
22
|
-
title: any;
|
|
23
|
-
description: any;
|
|
24
|
-
isUserError: boolean;
|
|
25
|
-
}[];
|
|
26
|
-
data: {};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=api-intercept.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-intercept.d.ts","sourceRoot":"","sources":["../../src/api-intercept.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAwBxG,eAAO,MAAM,mBAAmB,cAAqB,GAAG,iBAGvD,CAAA;AAeD,eAAO,MAAM,oBAAoB,gBAAiB,WAAW,cAAc,cAAc,KAAG,gBAwB3F,CAAA;AAoBD,eAAO,MAAM,oBAAoB;eAA+B,GAAG;8BAA4B,UAAU,QAAQ,GAAG,KAAK,IAAI;iBAAe,WAAW;gBAAc,cAAc;iCAA+B;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,QAAQ;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;mBAyBpR,CAAA;AAED,eAAO,MAAM,8BAA8B,YAAa,GAAG;;;;;;;;;;;;;;CAuB1D,CAAA"}
|
package/cjs/src/api-intercept.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processLegacyInterceptResponse = exports.handleInterceptEvent = exports.getInterceptInitData = exports.processApiIntercept = void 0;
|
|
4
|
-
const config_1 = require("./config");
|
|
5
|
-
const embedConfig_1 = require("./embed/embedConfig");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
|
-
const logger_1 = require("./utils/logger");
|
|
8
|
-
const defaultUrls = {
|
|
9
|
-
[types_1.InterceptedApiType.METADATA]: [
|
|
10
|
-
'/prism/?op=CreateAnswerSession',
|
|
11
|
-
'/prism/?op=GetV2SourceDetail',
|
|
12
|
-
],
|
|
13
|
-
[types_1.InterceptedApiType.ANSWER_DATA]: [
|
|
14
|
-
'/prism/?op=GetChartWithData',
|
|
15
|
-
'/prism/?op=GetTableWithHeadlineData',
|
|
16
|
-
],
|
|
17
|
-
[types_1.InterceptedApiType.LIVEBOARD_DATA]: [
|
|
18
|
-
'/prism/?op=LoadContextBook'
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
const formatInterceptUrl = (url) => {
|
|
22
|
-
const host = (0, config_1.getThoughtSpotHost)((0, embedConfig_1.getEmbedConfig)());
|
|
23
|
-
if (url.startsWith('/'))
|
|
24
|
-
return `${host}${url}`;
|
|
25
|
-
return url;
|
|
26
|
-
};
|
|
27
|
-
const processApiIntercept = async (eventData) => {
|
|
28
|
-
return JSON.parse(eventData.data);
|
|
29
|
-
};
|
|
30
|
-
exports.processApiIntercept = processApiIntercept;
|
|
31
|
-
const processInterceptUrls = (interceptUrls) => {
|
|
32
|
-
let processedUrls = [...interceptUrls];
|
|
33
|
-
Object.entries(defaultUrls).forEach(([apiType, apiTypeUrls]) => {
|
|
34
|
-
if (!processedUrls.includes(apiType))
|
|
35
|
-
return;
|
|
36
|
-
processedUrls = processedUrls.filter(url => url !== apiType);
|
|
37
|
-
processedUrls = [...processedUrls, ...apiTypeUrls];
|
|
38
|
-
});
|
|
39
|
-
return processedUrls.map(url => formatInterceptUrl(url));
|
|
40
|
-
};
|
|
41
|
-
const getInterceptInitData = (embedConfig, viewConfig) => {
|
|
42
|
-
const enableApiIntercept = (embedConfig.enableApiIntercept || viewConfig.enableApiIntercept) && (viewConfig.enableApiIntercept !== false);
|
|
43
|
-
if (!enableApiIntercept)
|
|
44
|
-
return {
|
|
45
|
-
enableApiIntercept: false,
|
|
46
|
-
};
|
|
47
|
-
const combinedUrls = [...(embedConfig.interceptUrls || []), ...(viewConfig.interceptUrls || [])];
|
|
48
|
-
if (viewConfig.isOnBeforeGetVizDataInterceptEnabled) {
|
|
49
|
-
combinedUrls.push(types_1.InterceptedApiType.ANSWER_DATA);
|
|
50
|
-
}
|
|
51
|
-
const shouldInterceptAll = combinedUrls.includes(types_1.InterceptedApiType.ALL);
|
|
52
|
-
const interceptUrls = shouldInterceptAll ? [types_1.InterceptedApiType.ALL] : processInterceptUrls(combinedUrls);
|
|
53
|
-
const interceptTimeout = embedConfig.interceptTimeout || viewConfig.interceptTimeout;
|
|
54
|
-
return {
|
|
55
|
-
interceptUrls,
|
|
56
|
-
interceptTimeout,
|
|
57
|
-
enableApiIntercept,
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
exports.getInterceptInitData = getInterceptInitData;
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
* @param fetchInit
|
|
64
|
-
*/
|
|
65
|
-
const parseInterceptData = (eventDataString) => {
|
|
66
|
-
try {
|
|
67
|
-
const { input, init } = JSON.parse(eventDataString);
|
|
68
|
-
init.body = JSON.parse(init.body);
|
|
69
|
-
const parsedInit = { input, init };
|
|
70
|
-
return [parsedInit, null];
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return [null, error];
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const handleInterceptEvent = async (params) => {
|
|
77
|
-
var _a, _b, _c, _d, _e;
|
|
78
|
-
const { eventData, executeEvent, viewConfig, getUnsavedAnswerTml } = params;
|
|
79
|
-
const [interceptData, bodyParseError] = parseInterceptData(eventData.data);
|
|
80
|
-
if (bodyParseError) {
|
|
81
|
-
executeEvent(types_1.EmbedEvent.Error, {
|
|
82
|
-
error: 'Error parsing api intercept body',
|
|
83
|
-
});
|
|
84
|
-
logger_1.logger.error('Error parsing request body', bodyParseError);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const { input: requestUrl, init } = interceptData;
|
|
88
|
-
const sessionId = (_c = (_b = (_a = init === null || init === void 0 ? void 0 : init.body) === null || _a === void 0 ? void 0 : _a.variables) === null || _b === void 0 ? void 0 : _b.session) === null || _c === void 0 ? void 0 : _c.sessionId;
|
|
89
|
-
const vizId = (_e = (_d = init === null || init === void 0 ? void 0 : init.body) === null || _d === void 0 ? void 0 : _d.variables) === null || _e === void 0 ? void 0 : _e.contextBookId;
|
|
90
|
-
if (defaultUrls.ANSWER_DATA.includes(requestUrl) && viewConfig.isOnBeforeGetVizDataInterceptEnabled) {
|
|
91
|
-
const answerTml = await getUnsavedAnswerTml({ sessionId, vizId });
|
|
92
|
-
executeEvent(types_1.EmbedEvent.OnBeforeGetVizDataIntercept, { data: { data: answerTml } });
|
|
93
|
-
}
|
|
94
|
-
executeEvent(types_1.EmbedEvent.ApiIntercept, interceptData);
|
|
95
|
-
};
|
|
96
|
-
exports.handleInterceptEvent = handleInterceptEvent;
|
|
97
|
-
const processLegacyInterceptResponse = (payload) => {
|
|
98
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
99
|
-
const errorText = ((_a = payload === null || payload === void 0 ? void 0 : payload.data) === null || _a === void 0 ? void 0 : _a.errorText) || ((_c = (_b = payload === null || payload === void 0 ? void 0 : payload.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.errorText);
|
|
100
|
-
const errorDescription = ((_d = payload === null || payload === void 0 ? void 0 : payload.data) === null || _d === void 0 ? void 0 : _d.errorDescription) || ((_f = (_e = payload === null || payload === void 0 ? void 0 : payload.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.errorDescription);
|
|
101
|
-
const payloadToSend = {
|
|
102
|
-
execute: (_g = payload === null || payload === void 0 ? void 0 : payload.data) === null || _g === void 0 ? void 0 : _g.execute,
|
|
103
|
-
response: {
|
|
104
|
-
body: {
|
|
105
|
-
errors: [
|
|
106
|
-
{
|
|
107
|
-
title: errorText,
|
|
108
|
-
description: errorDescription,
|
|
109
|
-
isUserError: true,
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
data: {},
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
return { data: payloadToSend };
|
|
117
|
-
};
|
|
118
|
-
exports.processLegacyInterceptResponse = processLegacyInterceptResponse;
|
|
119
|
-
//# sourceMappingURL=api-intercept.js.map
|