@looker/extension-sdk 22.20.0 → 22.20.2-alpha.1647

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +9 -1
  3. package/lib/connect/extension_host_api.d.ts +14 -3
  4. package/lib/connect/extension_host_api.js +111 -23
  5. package/lib/connect/extension_host_api.js.map +1 -1
  6. package/lib/connect/global_listener.js +4 -2
  7. package/lib/connect/global_listener.js.map +1 -1
  8. package/lib/connect/index.d.ts +2 -0
  9. package/lib/connect/index.js +29 -1
  10. package/lib/connect/index.js.map +1 -1
  11. package/lib/connect/tile/index.d.ts +1 -0
  12. package/lib/connect/tile/index.js +19 -0
  13. package/lib/connect/tile/index.js.map +1 -0
  14. package/lib/connect/tile/tile_sdk.d.ts +24 -0
  15. package/lib/connect/tile/tile_sdk.js +153 -0
  16. package/lib/connect/tile/tile_sdk.js.map +1 -0
  17. package/lib/connect/tile/types.d.ts +84 -0
  18. package/lib/connect/tile/types.js +15 -0
  19. package/lib/connect/tile/types.js.map +1 -0
  20. package/lib/connect/types.d.ts +50 -7
  21. package/lib/connect/types.js +23 -1
  22. package/lib/connect/types.js.map +1 -1
  23. package/lib/connect/visualization/index.d.ts +2 -0
  24. package/lib/connect/visualization/index.js +32 -0
  25. package/lib/connect/visualization/index.js.map +1 -0
  26. package/lib/connect/visualization/types.d.ts +62 -0
  27. package/lib/connect/visualization/types.js +2 -0
  28. package/lib/connect/visualization/types.js.map +1 -0
  29. package/lib/connect/visualization/visualization_sdk.d.ts +36 -0
  30. package/lib/connect/visualization/visualization_sdk.js +166 -0
  31. package/lib/connect/visualization/visualization_sdk.js.map +1 -0
  32. package/lib/esm/connect/extension_host_api.js +109 -24
  33. package/lib/esm/connect/extension_host_api.js.map +1 -1
  34. package/lib/esm/connect/global_listener.js +4 -2
  35. package/lib/esm/connect/global_listener.js.map +1 -1
  36. package/lib/esm/connect/index.js +2 -0
  37. package/lib/esm/connect/index.js.map +1 -1
  38. package/lib/esm/connect/tile/index.js +2 -0
  39. package/lib/esm/connect/tile/index.js.map +1 -0
  40. package/lib/esm/connect/tile/tile_sdk.js +140 -0
  41. package/lib/esm/connect/tile/tile_sdk.js.map +1 -0
  42. package/lib/esm/connect/tile/types.js +8 -0
  43. package/lib/esm/connect/tile/types.js.map +1 -0
  44. package/lib/esm/connect/types.js +21 -0
  45. package/lib/esm/connect/types.js.map +1 -1
  46. package/lib/esm/connect/visualization/index.js +3 -0
  47. package/lib/esm/connect/visualization/index.js.map +1 -0
  48. package/lib/esm/connect/visualization/types.js +2 -0
  49. package/lib/esm/connect/visualization/types.js.map +1 -0
  50. package/lib/esm/connect/visualization/visualization_sdk.js +156 -0
  51. package/lib/esm/connect/visualization/visualization_sdk.js.map +1 -0
  52. package/lib/esm/index.js +3 -0
  53. package/lib/esm/index.js.map +1 -1
  54. package/lib/esm/util/errors.js +2 -0
  55. package/lib/esm/util/errors.js.map +1 -0
  56. package/lib/esm/util/index.js +3 -0
  57. package/lib/esm/util/index.js.map +1 -0
  58. package/lib/esm/util/logger.js +15 -0
  59. package/lib/esm/util/logger.js.map +1 -0
  60. package/lib/index.d.ts +3 -0
  61. package/lib/index.js +40 -1
  62. package/lib/index.js.map +1 -1
  63. package/lib/util/errors.d.ts +1 -0
  64. package/lib/util/errors.js +9 -0
  65. package/lib/util/errors.js.map +1 -0
  66. package/lib/util/index.d.ts +2 -0
  67. package/lib/util/index.js +32 -0
  68. package/lib/util/index.js.map +1 -0
  69. package/lib/util/logger.d.ts +2 -0
  70. package/lib/util/logger.js +27 -0
  71. package/lib/util/logger.js.map +1 -0
  72. package/package.json +5 -5
@@ -0,0 +1,62 @@
1
+ import type { Row } from '../tile';
2
+ export declare type VisualizationDataReceivedCallback = (visualizationData: RawVisualizationData) => void;
3
+ export interface RawVisualizationData {
4
+ visConfig: RawVisConfig;
5
+ queryResponse: RawVisQueryResponse;
6
+ }
7
+ export interface RawVisConfig {
8
+ [key: string]: RawVisConfigValue;
9
+ }
10
+ export declare type RawVisConfigValue = any;
11
+ export interface RawVisQueryResponse {
12
+ [key: string]: any;
13
+ data: RawVisData;
14
+ fields: {
15
+ [key: string]: any[];
16
+ };
17
+ pivots: RawPivotConfig[];
18
+ }
19
+ export declare type RawVisData = Row[];
20
+ export interface RawPivotConfig {
21
+ key: string;
22
+ is_total: boolean;
23
+ data: {
24
+ [key: string]: string;
25
+ };
26
+ metadata: {
27
+ [key: string]: {
28
+ [key: string]: string;
29
+ };
30
+ };
31
+ }
32
+ export interface Measure extends RawVisConfig {
33
+ }
34
+ export interface Dimension extends RawVisConfig {
35
+ [key: string]: any;
36
+ }
37
+ export interface TableCalculation {
38
+ }
39
+ export interface PivotConfig extends RawPivotConfig {
40
+ }
41
+ export interface VisualizationConfig {
42
+ queryFieldMeasures: Measure[];
43
+ queryFieldDimensions: Dimension[];
44
+ queryFieldTableCalculations: TableCalculation[];
45
+ queryFieldPivots: PivotConfig[];
46
+ }
47
+ export interface QueryResponse {
48
+ data: Row[];
49
+ fieldMeasures: Measure[];
50
+ fieldDimensions: Dimension[];
51
+ fieldTableCalculations: TableCalculation[];
52
+ fieldPivots: PivotConfig[];
53
+ fieldMeasureLike: Measure[];
54
+ fieldDimensionLike: Dimension[];
55
+ }
56
+ export interface VisualizationSDK {
57
+ visualizationData?: RawVisualizationData;
58
+ visConfig: VisualizationConfig;
59
+ queryResponse: QueryResponse;
60
+ updateVisData: (rawVisData: RawVisualizationData) => void;
61
+ configureVisualization: (options: RawVisConfig) => void;
62
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
@@ -0,0 +1,36 @@
1
+ import type { ExtensionHostApiImpl } from '../extension_host_api';
2
+ import type { Row } from '../tile';
3
+ import type { VisualizationSDK, RawVisualizationData, RawVisConfig, VisualizationConfig, QueryResponse, Measure, Dimension, TableCalculation, PivotConfig, RawVisQueryResponse } from './types';
4
+ declare class QueryResponseImpl implements QueryResponse {
5
+ _queryResponse?: RawVisQueryResponse;
6
+ constructor(queryResponse?: RawVisQueryResponse);
7
+ update(queryResponse: RawVisQueryResponse): void;
8
+ get fieldMeasures(): Measure[];
9
+ get fieldDimensions(): Dimension[];
10
+ get fieldTableCalculations(): TableCalculation[];
11
+ get fieldPivots(): PivotConfig[];
12
+ get fieldMeasureLike(): Measure[];
13
+ get fieldDimensionLike(): Dimension[];
14
+ get data(): Row[];
15
+ }
16
+ declare class VisualizationConfigImpl implements VisualizationConfig {
17
+ _visConfig?: RawVisConfig;
18
+ constructor(visConfig?: RawVisConfig);
19
+ update(visConfig: RawVisConfig): void;
20
+ get queryFieldMeasures(): Measure[];
21
+ get queryFieldDimensions(): Dimension[];
22
+ get queryFieldTableCalculations(): TableCalculation[];
23
+ get queryFieldPivots(): PivotConfig[];
24
+ }
25
+ export declare class VisualizationSDKImpl implements VisualizationSDK {
26
+ hostApi: ExtensionHostApiImpl;
27
+ visualizationData?: RawVisualizationData;
28
+ _visConfig?: VisualizationConfigImpl;
29
+ _queryResponse?: QueryResponseImpl;
30
+ constructor(hostApi: ExtensionHostApiImpl);
31
+ updateVisData(visualizationData: RawVisualizationData): void;
32
+ configureVisualization(options: RawVisConfig): void;
33
+ get visConfig(): VisualizationConfig;
34
+ get queryResponse(): QueryResponse;
35
+ }
36
+ export {};
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VisualizationSDKImpl = void 0;
7
+
8
+ var _errors = require("../../util/errors");
9
+
10
+ var _types = require("../types");
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ class QueryResponseImpl {
15
+ constructor(queryResponse) {
16
+ _defineProperty(this, "_queryResponse", void 0);
17
+
18
+ this._queryResponse = queryResponse;
19
+ }
20
+
21
+ update(queryResponse) {
22
+ this._queryResponse = queryResponse;
23
+ }
24
+
25
+ get fieldMeasures() {
26
+ var _this$_queryResponse, _this$_queryResponse$;
27
+
28
+ return ((_this$_queryResponse = this._queryResponse) === null || _this$_queryResponse === void 0 ? void 0 : (_this$_queryResponse$ = _this$_queryResponse.fields) === null || _this$_queryResponse$ === void 0 ? void 0 : _this$_queryResponse$.measures) || [];
29
+ }
30
+
31
+ get fieldDimensions() {
32
+ var _this$_queryResponse2, _this$_queryResponse3;
33
+
34
+ return ((_this$_queryResponse2 = this._queryResponse) === null || _this$_queryResponse2 === void 0 ? void 0 : (_this$_queryResponse3 = _this$_queryResponse2.fields) === null || _this$_queryResponse3 === void 0 ? void 0 : _this$_queryResponse3.dimensions) || [];
35
+ }
36
+
37
+ get fieldTableCalculations() {
38
+ var _this$_queryResponse4, _this$_queryResponse5;
39
+
40
+ return ((_this$_queryResponse4 = this._queryResponse) === null || _this$_queryResponse4 === void 0 ? void 0 : (_this$_queryResponse5 = _this$_queryResponse4.fields) === null || _this$_queryResponse5 === void 0 ? void 0 : _this$_queryResponse5.table_calculations) || [];
41
+ }
42
+
43
+ get fieldPivots() {
44
+ var _this$_queryResponse6, _this$_queryResponse7;
45
+
46
+ return ((_this$_queryResponse6 = this._queryResponse) === null || _this$_queryResponse6 === void 0 ? void 0 : (_this$_queryResponse7 = _this$_queryResponse6.fields) === null || _this$_queryResponse7 === void 0 ? void 0 : _this$_queryResponse7.pivots) || [];
47
+ }
48
+
49
+ get fieldMeasureLike() {
50
+ var _this$_queryResponse8, _this$_queryResponse9;
51
+
52
+ return ((_this$_queryResponse8 = this._queryResponse) === null || _this$_queryResponse8 === void 0 ? void 0 : (_this$_queryResponse9 = _this$_queryResponse8.fields) === null || _this$_queryResponse9 === void 0 ? void 0 : _this$_queryResponse9.measure_like) || [];
53
+ }
54
+
55
+ get fieldDimensionLike() {
56
+ var _this$_queryResponse10, _this$_queryResponse11;
57
+
58
+ return ((_this$_queryResponse10 = this._queryResponse) === null || _this$_queryResponse10 === void 0 ? void 0 : (_this$_queryResponse11 = _this$_queryResponse10.fields) === null || _this$_queryResponse11 === void 0 ? void 0 : _this$_queryResponse11.dimension_like) || [];
59
+ }
60
+
61
+ get data() {
62
+ var _this$_queryResponse12;
63
+
64
+ return ((_this$_queryResponse12 = this._queryResponse) === null || _this$_queryResponse12 === void 0 ? void 0 : _this$_queryResponse12.data) || [];
65
+ }
66
+
67
+ }
68
+
69
+ class VisualizationConfigImpl {
70
+ constructor(visConfig) {
71
+ _defineProperty(this, "_visConfig", void 0);
72
+
73
+ this._visConfig = visConfig;
74
+ }
75
+
76
+ update(visConfig) {
77
+ this._visConfig = visConfig;
78
+ }
79
+
80
+ get queryFieldMeasures() {
81
+ var _this$_visConfig, _this$_visConfig$quer;
82
+
83
+ return ((_this$_visConfig = this._visConfig) === null || _this$_visConfig === void 0 ? void 0 : (_this$_visConfig$quer = _this$_visConfig.query_fields) === null || _this$_visConfig$quer === void 0 ? void 0 : _this$_visConfig$quer.measures) || [];
84
+ }
85
+
86
+ get queryFieldDimensions() {
87
+ var _this$_visConfig2, _this$_visConfig2$que;
88
+
89
+ return ((_this$_visConfig2 = this._visConfig) === null || _this$_visConfig2 === void 0 ? void 0 : (_this$_visConfig2$que = _this$_visConfig2.query_fields) === null || _this$_visConfig2$que === void 0 ? void 0 : _this$_visConfig2$que.dimensions) || [];
90
+ }
91
+
92
+ get queryFieldTableCalculations() {
93
+ var _this$_visConfig3, _this$_visConfig3$que;
94
+
95
+ return ((_this$_visConfig3 = this._visConfig) === null || _this$_visConfig3 === void 0 ? void 0 : (_this$_visConfig3$que = _this$_visConfig3.query_fields) === null || _this$_visConfig3$que === void 0 ? void 0 : _this$_visConfig3$que.table_calculations) || [];
96
+ }
97
+
98
+ get queryFieldPivots() {
99
+ var _this$_visConfig4, _this$_visConfig4$que;
100
+
101
+ return ((_this$_visConfig4 = this._visConfig) === null || _this$_visConfig4 === void 0 ? void 0 : (_this$_visConfig4$que = _this$_visConfig4.query_fields) === null || _this$_visConfig4$que === void 0 ? void 0 : _this$_visConfig4$que.pivots) || [];
102
+ }
103
+
104
+ }
105
+
106
+ class VisualizationSDKImpl {
107
+ constructor(hostApi) {
108
+ _defineProperty(this, "hostApi", void 0);
109
+
110
+ _defineProperty(this, "visualizationData", void 0);
111
+
112
+ _defineProperty(this, "_visConfig", void 0);
113
+
114
+ _defineProperty(this, "_queryResponse", void 0);
115
+
116
+ this.hostApi = hostApi;
117
+ }
118
+
119
+ updateVisData(visualizationData) {
120
+ if (this.hostApi.isDashboardMountSupported) {
121
+ this.visualizationData = visualizationData;
122
+
123
+ if (this._visConfig) {
124
+ this._visConfig.update(this.visualizationData.visConfig);
125
+ }
126
+
127
+ if (this._queryResponse) {
128
+ this._queryResponse.update(this.visualizationData.queryResponse);
129
+ }
130
+ }
131
+ }
132
+
133
+ configureVisualization(options) {
134
+ if (this.hostApi.isDashboardMountSupported) {
135
+ this.hostApi.send(_types.ExtensionRequestType.VIS_DEFAULT_CONFIG, {
136
+ options
137
+ });
138
+ } else {
139
+ throw _errors.NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR;
140
+ }
141
+ }
142
+
143
+ get visConfig() {
144
+ if (!this._visConfig) {
145
+ var _this$visualizationDa;
146
+
147
+ this._visConfig = new VisualizationConfigImpl((_this$visualizationDa = this.visualizationData) === null || _this$visualizationDa === void 0 ? void 0 : _this$visualizationDa.visConfig);
148
+ }
149
+
150
+ return this._visConfig;
151
+ }
152
+
153
+ get queryResponse() {
154
+ if (!this._queryResponse) {
155
+ var _this$visualizationDa2;
156
+
157
+ this._queryResponse = new QueryResponseImpl((_this$visualizationDa2 = this.visualizationData) === null || _this$visualizationDa2 === void 0 ? void 0 : _this$visualizationDa2.queryResponse);
158
+ }
159
+
160
+ return this._queryResponse;
161
+ }
162
+
163
+ }
164
+
165
+ exports.VisualizationSDKImpl = VisualizationSDKImpl;
166
+ //# sourceMappingURL=visualization_sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/connect/visualization/visualization_sdk.ts"],"names":["QueryResponseImpl","constructor","queryResponse","_queryResponse","update","fieldMeasures","fields","measures","fieldDimensions","dimensions","fieldTableCalculations","table_calculations","fieldPivots","pivots","fieldMeasureLike","measure_like","fieldDimensionLike","dimension_like","data","VisualizationConfigImpl","visConfig","_visConfig","queryFieldMeasures","query_fields","queryFieldDimensions","queryFieldTableCalculations","queryFieldPivots","VisualizationSDKImpl","hostApi","updateVisData","visualizationData","isDashboardMountSupported","configureVisualization","options","send","ExtensionRequestType","VIS_DEFAULT_CONFIG","NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR"],"mappings":"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","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR } from '../../util/errors'\nimport type { ExtensionHostApiImpl } from '../extension_host_api'\nimport { ExtensionRequestType } from '../types'\nimport type { Row } from '../tile'\nimport type {\n VisualizationSDK,\n RawVisualizationData,\n RawVisConfig,\n VisualizationConfig,\n QueryResponse,\n Measure,\n Dimension,\n TableCalculation,\n PivotConfig,\n RawVisQueryResponse,\n} from './types'\n\nclass QueryResponseImpl implements QueryResponse {\n _queryResponse?: RawVisQueryResponse\n\n constructor(queryResponse?: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n update(queryResponse: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n get fieldMeasures(): Measure[] {\n return this._queryResponse?.fields?.measures || []\n }\n\n get fieldDimensions(): Dimension[] {\n return this._queryResponse?.fields?.dimensions || []\n }\n\n get fieldTableCalculations(): TableCalculation[] {\n return this._queryResponse?.fields?.table_calculations || []\n }\n\n get fieldPivots(): PivotConfig[] {\n return this._queryResponse?.fields?.pivots || []\n }\n\n get fieldMeasureLike(): Measure[] {\n return this._queryResponse?.fields?.measure_like || []\n }\n\n get fieldDimensionLike(): Dimension[] {\n return this._queryResponse?.fields?.dimension_like || []\n }\n\n get data(): Row[] {\n return this._queryResponse?.data || []\n }\n}\n\nclass VisualizationConfigImpl implements VisualizationConfig {\n _visConfig?: RawVisConfig\n\n constructor(visConfig?: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n update(visConfig: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n get queryFieldMeasures(): Measure[] {\n return this._visConfig?.query_fields?.measures || []\n }\n\n get queryFieldDimensions(): Dimension[] {\n return this._visConfig?.query_fields?.dimensions || []\n }\n\n get queryFieldTableCalculations(): TableCalculation[] {\n return this._visConfig?.query_fields?.table_calculations || []\n }\n\n get queryFieldPivots(): PivotConfig[] {\n return this._visConfig?.query_fields?.pivots || []\n }\n}\n\nexport class VisualizationSDKImpl implements VisualizationSDK {\n hostApi: ExtensionHostApiImpl\n visualizationData?: RawVisualizationData\n _visConfig?: VisualizationConfigImpl\n _queryResponse?: QueryResponseImpl\n\n constructor(hostApi: ExtensionHostApiImpl) {\n this.hostApi = hostApi\n }\n\n updateVisData(visualizationData: RawVisualizationData) {\n // Ignore update messages if dashboard mounts not supported.\n // Should never happen.\n if (this.hostApi.isDashboardMountSupported) {\n this.visualizationData = visualizationData\n if (this._visConfig) {\n this._visConfig.update(this.visualizationData.visConfig)\n }\n if (this._queryResponse) {\n this._queryResponse.update(this.visualizationData.queryResponse)\n }\n }\n }\n\n configureVisualization(options: RawVisConfig): void {\n if (this.hostApi.isDashboardMountSupported) {\n this.hostApi.send(ExtensionRequestType.VIS_DEFAULT_CONFIG, { options })\n } else {\n throw NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR\n }\n }\n\n get visConfig(): VisualizationConfig {\n if (!this._visConfig) {\n this._visConfig = new VisualizationConfigImpl(\n this.visualizationData?.visConfig\n )\n }\n return this._visConfig\n }\n\n get queryResponse(): QueryResponse {\n if (!this._queryResponse) {\n this._queryResponse = new QueryResponseImpl(\n this.visualizationData?.queryResponse\n )\n }\n return this._queryResponse\n }\n}\n"],"file":"visualization_sdk.js"}
@@ -5,8 +5,11 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
7
  import intersects from 'semver/ranges/intersects';
8
+ import { logError } from '../util';
9
+ import { VisualizationSDKImpl } from './visualization/visualization_sdk';
10
+ import { TileSDKImpl } from './tile/tile_sdk';
8
11
  import { FetchProxyImpl } from './fetch_proxy';
9
- import { ExtensionEvent, ExtensionNotificationType, ExtensionRequestType } from './types';
12
+ import { ExtensionEvent, ExtensionNotificationType, ExtensionRequestType, MountPoint } from './types';
10
13
  export var EXTENSION_SDK_VERSION = '0.10.5';
11
14
  export class ExtensionHostApiImpl {
12
15
  constructor(configuration) {
@@ -20,17 +23,51 @@ export class ExtensionHostApiImpl {
20
23
 
21
24
  _defineProperty(this, "hostChangedRoute", void 0);
22
25
 
26
+ _defineProperty(this, "visualizationDataReceivedCallback", void 0);
27
+
28
+ _defineProperty(this, "tileHostDataChangedCallback", void 0);
29
+
30
+ _defineProperty(this, "_visualizationSDK", void 0);
31
+
32
+ _defineProperty(this, "_tileSDK", void 0);
33
+
23
34
  _defineProperty(this, "contextData", void 0);
24
35
 
25
36
  this._configuration = configuration;
26
37
  var {
27
38
  chattyHost,
28
39
  setInitialRoute,
29
- hostChangedRoute
40
+ hostChangedRoute,
41
+ visualizationDataReceivedCallback,
42
+ tileHostDataChangedCallback
30
43
  } = this._configuration;
31
44
  this.chattyHost = chattyHost;
32
45
  this.setInitialRoute = setInitialRoute;
33
46
  this.hostChangedRoute = hostChangedRoute;
47
+ this.visualizationDataReceivedCallback = visualizationDataReceivedCallback;
48
+ this.tileHostDataChangedCallback = tileHostDataChangedCallback;
49
+ }
50
+
51
+ get isDashboardMountSupported() {
52
+ var _this$_lookerHostData, _this$lookerHostData, _this$lookerHostData2;
53
+
54
+ return !!((_this$_lookerHostData = this._lookerHostData) !== null && _this$_lookerHostData !== void 0 && _this$_lookerHostData.extensionDashboardTileEnabled) && (((_this$lookerHostData = this.lookerHostData) === null || _this$lookerHostData === void 0 ? void 0 : _this$lookerHostData.mountPoint) === MountPoint.dashboardTile || ((_this$lookerHostData2 = this.lookerHostData) === null || _this$lookerHostData2 === void 0 ? void 0 : _this$lookerHostData2.mountPoint) === MountPoint.dashboardVisualization);
55
+ }
56
+
57
+ get visualizationSDK() {
58
+ if (!this._visualizationSDK) {
59
+ this._visualizationSDK = new VisualizationSDKImpl(this);
60
+ }
61
+
62
+ return this._visualizationSDK;
63
+ }
64
+
65
+ get tileSDK() {
66
+ if (!this._tileSDK) {
67
+ this._tileSDK = new TileSDKImpl(this);
68
+ }
69
+
70
+ return this._tileSDK;
34
71
  }
35
72
 
36
73
  get lookerHostData() {
@@ -39,48 +76,86 @@ export class ExtensionHostApiImpl {
39
76
 
40
77
  handleNotification(message) {
41
78
  var {
42
- type,
43
- payload
44
- } = message || {};
79
+ type
80
+ } = message;
45
81
 
46
82
  switch (type) {
47
83
  case ExtensionNotificationType.ROUTE_CHANGED:
48
- if (this.hostChangedRoute && payload) {
84
+ {
49
85
  var {
50
- route: _route,
51
- routeState: _routeState
52
- } = payload;
86
+ payload
87
+ } = message;
88
+
89
+ if (this.hostChangedRoute && payload) {
90
+ var {
91
+ route: _route,
92
+ routeState: _routeState
93
+ } = payload;
53
94
 
54
- if (_route) {
55
- this.hostChangedRoute(_route, _routeState);
95
+ if (_route) {
96
+ this.hostChangedRoute(_route, _routeState);
97
+ }
98
+ }
99
+
100
+ return undefined;
101
+ }
102
+
103
+ case ExtensionNotificationType.VISUALIZATION_DATA:
104
+ {
105
+ var {
106
+ payload: _payload
107
+ } = message;
108
+ this.visualizationSDK.updateVisData(_payload);
109
+
110
+ if (this.visualizationDataReceivedCallback) {
111
+ this.visualizationDataReceivedCallback(_payload);
56
112
  }
113
+
114
+ return undefined;
57
115
  }
58
116
 
59
- return undefined;
117
+ case ExtensionNotificationType.TILE_HOST_DATA:
118
+ {
119
+ var {
120
+ payload: _payload2
121
+ } = message;
122
+ this.tileSDK.tileHostDataChanged(_payload2);
123
+
124
+ if (this.tileHostDataChangedCallback) {
125
+ this.tileHostDataChangedCallback(_payload2);
126
+ }
127
+
128
+ return undefined;
129
+ }
60
130
 
61
131
  case ExtensionNotificationType.INITIALIZE:
62
132
  {
63
- this._lookerHostData = payload;
133
+ var {
134
+ payload: _payload3
135
+ } = message;
136
+ var lookerHostData = _payload3 || {};
64
137
 
65
- if (this._lookerHostData) {
66
- this.contextData = this._lookerHostData.contextData;
138
+ if (!lookerHostData.mountPoint) {
139
+ lookerHostData.mountPoint = MountPoint.standalone;
67
140
  }
68
141
 
142
+ this._lookerHostData = lookerHostData;
143
+ this.contextData = lookerHostData.contextData;
69
144
  var errorMessage;
70
145
 
71
- if (this._configuration.requiredLookerVersion && this._lookerHostData && this._lookerHostData.lookerVersion) {
146
+ if (this._configuration.requiredLookerVersion && lookerHostData.lookerVersion) {
72
147
  errorMessage = this.verifyLookerVersion(this._configuration.requiredLookerVersion);
73
148
 
74
149
  if (errorMessage) {
75
- console.error(errorMessage);
150
+ logError(errorMessage);
76
151
  }
77
152
  }
78
153
 
79
- if (this.setInitialRoute && payload) {
154
+ if (this.setInitialRoute && _payload3) {
80
155
  var {
81
156
  route: _route2,
82
157
  routeState: _routeState2
83
- } = payload;
158
+ } = _payload3;
84
159
 
85
160
  if (_route2) {
86
161
  this.setInitialRoute(_route2, _routeState2);
@@ -94,7 +169,7 @@ export class ExtensionHostApiImpl {
94
169
  }
95
170
 
96
171
  default:
97
- console.error('Unrecognized extension notification', message);
172
+ logError('Unrecognized extension notification', message);
98
173
  throw new Error("Unrecognized extension notification type ".concat(type));
99
174
  }
100
175
  }
@@ -395,7 +470,7 @@ export class ExtensionHostApiImpl {
395
470
  error: error && error.toString ? error.toString() : error
396
471
  });
397
472
  } else {
398
- console.error('Unhandled error but Looker host connection not established', errorEvent);
473
+ logError('Unhandled error but Looker host connection not established', errorEvent);
399
474
  }
400
475
  }
401
476
 
@@ -475,6 +550,8 @@ export class ExtensionHostApiImpl {
475
550
  authParameters,
476
551
  httpMethod
477
552
  }
553
+ }, {
554
+ signal: new AbortController().signal
478
555
  });
479
556
  })();
480
557
  }
@@ -499,7 +576,13 @@ export class ExtensionHostApiImpl {
499
576
  })();
500
577
  }
501
578
 
502
- sendAndReceive(type, payload) {
579
+ rendered(failureMessage) {
580
+ this.send(ExtensionRequestType.RENDERED, {
581
+ failureMessage
582
+ });
583
+ }
584
+
585
+ sendAndReceive(type, payload, options) {
503
586
  var _this17 = this;
504
587
 
505
588
  return _asyncToGenerator(function* () {
@@ -507,10 +590,12 @@ export class ExtensionHostApiImpl {
507
590
  return Promise.reject(new Error('Looker host connection not established'));
508
591
  }
509
592
 
510
- return _this17.chattyHost.sendAndReceive(ExtensionEvent.EXTENSION_API_REQUEST, {
593
+ var messagePayload = {
511
594
  type,
512
595
  payload
513
- }).then(values => values[0]);
596
+ };
597
+ var chattyPayload = options ? [messagePayload, options] : [messagePayload];
598
+ return _this17.chattyHost.sendAndReceive(ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
514
599
  })();
515
600
  }
516
601