/
types.ts
619 lines (534 loc) · 13.3 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
/*
MIT License
Copyright (c) 2019 Looker Data Sciences, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import type { LookerEmbedBase } from './embed_base'
import type { LookerEmbedDashboard } from './dashboard_client'
import type { LookerEmbedLook } from './look_client'
/**
* Auth server configuration
*/
export interface LookerAuthConfig {
url: string
headers?: Array<{ name: string; value: string }>
params?: Array<{ name: string; value: string }>
withCredentials?: boolean
}
/**
* Cookieless request init
* Looker 22.20+
*/
export interface CookielessRequestInit extends RequestInit {
url: string
}
/**
* Cookieless request callback function
* Looker 22.20+
*/
export type CookielessCallback = () => Promise<LookerEmbedCookielessSessionData>
/**
* Cookieless session data
* Looker 23.0+
*/
export interface LookerEmbedCookielessSessionData {
/**
* One time use token used to establish the cookieless embed session.
*/
authentication_token?: string | null
/**
* Authentication token time to live in seconds.
*/
authentication_token_ttl?: number | null
/**
* Token used to load and navigate between pages in the embedded session. This token is appended to the embed iframe url.
*/
navigation_token?: string | null
/**
* Navigation token time to live in seconds.
*/
navigation_token_ttl?: number | null
/**
* Token to used to call Looker APIs. The host application MUST send the api token to the embedded Looker application. Do not expose the token in the dom.
*/
api_token?: string | null
/**
* api_token time to live in seconds.
*/
api_token_ttl?: number | null
/**
* Session time to live in seconds.
*/
session_reference_token_ttl?: number | null
}
/**
* Data structure for filters.
*/
export interface LookerEmbedFilterParams {
[key: string]: string
}
/**
* Dashboard Layout
*
* Contains details of dashboard layout.
*/
export interface DashboardLayout {
id: string
dashboard_id: string
type: 'newspaper'
active: boolean
column_width: number
width: number | null
deleted: boolean
dashboard_layout_components: DashboardLayoutComponent[]
}
/**
* Dashboard Layout Component
*
* Contains details of individual dashboard element layout.
*/
export interface DashboardLayoutComponent {
id: string
dashboard_layout_id: string
dashboard_element_id: string
row: number
column: number
width: number
height: number
deleted: boolean
}
/**
* Visualization Config interface
*/
export interface VisConfig {
type: string
[key: string]: any
}
/**
* Element Options interface
*/
export interface ElementOptionItems {
title?: string | null
title_hidden?: boolean
vis_config?: VisConfig | null
}
/**
* Element to element options mapping interface
*/
export interface ElementOptions {
[id: string]: ElementOptionItems
}
/**
* Options interface
*/
export interface LookerDashboardOptions {
elements?: ElementOptions
layouts?: DashboardLayout[]
}
/**
* A generic Looker embed event
*/
export interface LookerEmbedEvent {
type: string
[key: string]: any
}
/**
* A generic Looker event detail
*/
export interface EventDetail {
[key: string]: any
}
/**
* Cookieless embed session token request
* Looker 22.20+
*/
export type SessionTokenRequest = EventDetail
/**
* Cookieless session status event
* Looker 23.0+
*/
export interface SessionStatus extends EventDetail {
/**
* Session time to live in seconds
*/
session_ttl: number
/**
* Session expired when true
*/
expired: boolean
/**
* Session interrupted when true. This means new
* tokens could not be retrieved in a timely manner.
* Can happen if server is temporarily unavailable
* for some reason
*/
interrupted: boolean
/**
* Interrupted session can be recovered. When false
* session cannot continue. This is most likely
* a problem with the embedding application.
*/
recoverable?: boolean
}
/**
* Detailed dashboard data returned by dashboard events
*/
export interface DashboardEventDetail extends EventDetail {
id: string | number
title: string
canEdit: boolean
dashboard_filters: LookerEmbedFilterParams
absoluteUrl: string
url: string
options: LookerDashboardOptions
}
/**
* Detailed tile data returned by dashboard events
*/
export interface DashboardTileEventDetail extends EventDetail {
id: string | number
title: string
listen: Record<string, string | null>
}
/**
* Dashboard tile status
*
* Available on Dashboards Next
*
* Requires Looker 21.14
*/
export interface TileStatus {
tileId: string
status: 'error' | 'complete'
errors?: Array<QueryError>
}
/**
* Dashboard event
*/
export interface DashboardEvent extends LookerEmbedEvent {
dashboard: DashboardEventDetail
/// Available on Dashboards Next
status?: 'complete' | 'error' | 'stopped'
/// Available on Dashboards Next
/// Requires Looker 21.14
tileStatuses: Array<TileStatus>
}
/**
* Query error detail
*
* Requires Looker 21.14
*/
export interface QueryError {
message: string | null
message_details: string | null
params: string | null
error_pos: string | null
level: string
fatal?: boolean
sql_error_loc: {
[key: string]: any
}
}
/**
* Dashboard tile event
*/
export interface DashboardTileEvent {
dashboard: DashboardEventDetail
tile: DashboardTileEventDetail
/// Available on Dashboards Next
status?: 'complete' | 'error'
/// Available on Dashboards Next
truncated?: boolean
/// Available on Dashboards Next
/// Requires Looker 21.14
errors?: Array<QueryError>
}
/**
* Dashboard tile download event
*/
export interface DashboardTileDownloadEvent extends DashboardTileEvent {
fileFormat: string
}
/**
* Dashboard tile Explore from Here event
*
* Requires Looker 6.20
*/
export interface DashboardTileExploreEvent extends DashboardTileEvent {
label: string
url: string
}
/**
* Dashboard tile View Original Look event
*
* Requires Looker 6.20
*/
export interface DashboardTileViewEvent extends DashboardTileEvent {
label: string
url: string
}
/**
* Drill menu addFilterJson data
*/
export interface AddFilterJson {
rendered: string
field: string
add: string
}
/**
* Drill menu event
*/
export interface DrillMenuEvent extends LookerEmbedEvent {
label: string
link_type: string
url: string
modal: boolean
context: string
addFilterJson: AddFilterJson
}
/**
* Drill Modal Explore from Here event
*
* Requires Looker 6.20
*/
export interface DrillModalExploreEvent extends LookerEmbedEvent {
label: string
url: string
}
/**
* Look page event details
*/
export interface LookEventDetail extends EventDetail {
absoluteUrl: string
url: string
}
/**
* Look page event
*/
export interface LookEvent extends LookerEmbedEvent {
look: LookEventDetail
}
/**
* Look save event details
* Looker version 21.6+
*/
export interface LookSaveEventDetail extends LookEventDetail {
/**
* Folder Look is associated with
* Looker version 21.8+
*/
spaceId: number
}
/**
* Look save event
* Looker version 21.6+
*/
export interface LookSaveEvent extends LookerEmbedEvent {
look: LookSaveEventDetail
}
/**
* Explore page event details
*/
export interface ExploreEventDetail extends EventDetail {
absoluteUrl: string
url: string
}
/**
* Explore page event.
*/
export interface ExploreEvent extends LookerEmbedEvent {
explore: ExploreEventDetail
}
/**
* Page changed event details
*/
export interface PageChangedEventDetail extends EventDetail {
type: string
url: string
absoluteUrl: string
}
/**
* Page changed event. These are generated when navigating from one page to another.
*/
export interface PageChangedEvent extends LookerEmbedEvent {
page: PageChangedEventDetail
}
/**
* Page properties changed event. These are generated when a significant property changes on a page,
* like when a dashboard's height changes.
*/
export interface PagePropertiesChangedEvent extends LookerEmbedEvent {
height?: number
}
/**
* Cancellable event response
*/
export interface CancellableEventResponse {
cancel: boolean
}
/**
* Host scroll event data. Provides information to the Looker client
* about the current scroll state. This allows the Looker client to
* position dialogs within the users view port.
*
* Looker 23.6+
*/
export interface EnvHostScrollEvent extends LookerEmbedEvent {
scrollY: number
scrollX: number
offsetTop: number
offsetLeft: number
}
/**
* Client dialog data. Provides information about Looker dialogs that
* are being displayed. Information is only provided for those dialogs
* that might require some viewport adjustment on the part of the
* hosting application.
*
* Looker 23.6+
*/
export interface EnvClientDialogEvent extends LookerEmbedEvent {
open: boolean
placement: 'cover' | 'top' | 'center'
dialogType: string
}
/**
* Current Looker embed events as of version 6.20 (except where stated)
*/
export interface LookerEmbedEventMap {
'dashboard:run:start': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
'dashboard:run:complete': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
'dashboard:filters:changed': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
/**
* Dashboard editing started event.
* Not available to legacy dashboards.
* Looker 22.20+
*/
'dashboard:edit:start': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
/**
* Dashboard editing cancelled event.
* Not available to legacy dashboards.
* Looker 22.20+
*/
'dashboard:edit:cancel': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
/**
* Dashboard saved event. Fired when a dashboard
* being edited is saved. Use in conjunction with
* `dashboard:edit:start` and `dashboard:edit:save`.
* Looker 21.6+
*/
'dashboard:save:complete': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
/**
* Dashboard deleted event
* Looker 21.6+
*/
'dashboard:delete:complete': (
this: LookerEmbedDashboard,
event: DashboardEvent
) => void
'dashboard:tile:start': (
this: LookerEmbedDashboard,
event: DashboardTileEvent
) => void
'dashboard:tile:complete': (
this: LookerEmbedDashboard,
event: DashboardTileEvent
) => void
'dashboard:tile:download': (
this: LookerEmbedDashboard,
event: DashboardTileDownloadEvent
) => void
'dashboard:tile:explore': (
this: LookerEmbedDashboard,
event: DashboardTileExploreEvent
) => CancellableEventResponse | undefined
'dashboard:tile:view': (
this: LookerEmbedDashboard,
event: DashboardTileViewEvent
) => CancellableEventResponse | undefined
'drillmenu:click': (
this: LookerEmbedBase,
event: DrillMenuEvent
) => CancellableEventResponse | undefined
'drillmodal:explore': (
this: LookerEmbedBase,
event: DrillModalExploreEvent
) => CancellableEventResponse | undefined
'explore:run:start': (this: LookerEmbedLook, event: ExploreEvent) => void
'explore:run:complete': (this: LookerEmbedLook, event: ExploreEvent) => void
'explore:ready': (this: LookerEmbedLook, event: ExploreEvent) => void
'explore:state:changed': (this: LookerEmbedLook, event: ExploreEvent) => void
'look:run:start': (this: LookerEmbedLook, event: LookEvent) => void
'look:run:complete': (this: LookerEmbedLook, event: LookEvent) => void
/**
* Look saved event
* Looker 21.6+
*/
'look:save:complete': (this: LookerEmbedLook, event: LookSaveEvent) => void
/**
* Look deleted event
* Looker 21.6+
*/
'look:delete:complete': (this: LookerEmbedLook, event: LookSaveEvent) => void
'look:ready': (this: LookerEmbedLook, event: LookEvent) => void
'look:state:changed': (this: LookerEmbedLook, event: LookEvent) => void
'page:changed': (this: LookerEmbedBase, event: PageChangedEvent) => void
'page:properties:changed': (
this: LookerEmbedBase,
event: PagePropertiesChangedEvent
) => void
/**
* Cookieless embed session tokens request event
* Looker 22.20+
*/
'session:token:request': (
this: LookerEmbedBase,
event: SessionTokenRequest
) => void
/**
* Cookieless embed session status event
* Looker 23.0+
*/
'session:status': (this: LookerEmbedBase, event: SessionStatus) => void
/**
* Environment client dialog event
* Looker 23.6+
*/
'env:client:dialog': (
this: LookerEmbedBase,
event: EnvClientDialogEvent
) => void
[key: string]: any
}