@looker/extension-sdk 22.20.2-alpha.1650 → 23.2.0
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/CHANGELOG.md +30 -1
- package/README.md +1 -9
- package/lib/connect/connect_extension_host.js +5 -24
- package/lib/connect/connect_extension_host.js.map +1 -1
- package/lib/connect/extension_host_api.d.ts +3 -14
- package/lib/connect/extension_host_api.js +26 -230
- package/lib/connect/extension_host_api.js.map +1 -1
- package/lib/connect/fetch_proxy.js +0 -13
- package/lib/connect/fetch_proxy.js.map +1 -1
- package/lib/connect/global_listener.js +3 -17
- package/lib/connect/global_listener.js.map +1 -1
- package/lib/connect/index.d.ts +0 -2
- package/lib/connect/index.js +1 -34
- package/lib/connect/index.js.map +1 -1
- package/lib/connect/types.d.ts +7 -51
- package/lib/connect/types.js +1 -33
- package/lib/connect/types.js.map +1 -1
- package/lib/esm/connect/connect_extension_host.js +19 -25
- package/lib/esm/connect/connect_extension_host.js.map +1 -1
- package/lib/esm/connect/extension_host_api.js +71 -256
- package/lib/esm/connect/extension_host_api.js.map +1 -1
- package/lib/esm/connect/fetch_proxy.js +11 -12
- package/lib/esm/connect/fetch_proxy.js.map +1 -1
- package/lib/esm/connect/global_listener.js +11 -12
- package/lib/esm/connect/global_listener.js.map +1 -1
- package/lib/esm/connect/index.js +39 -5
- package/lib/esm/connect/index.js.map +1 -1
- package/lib/esm/connect/types.js +21 -41
- package/lib/esm/connect/types.js.map +1 -1
- package/lib/esm/index.js +82 -10
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/sdk/extension_sdk.js +13 -9
- package/lib/esm/sdk/extension_sdk.js.map +1 -1
- package/lib/esm/sdk/extension_sdk_31.js +12 -6
- package/lib/esm/sdk/extension_sdk_31.js.map +1 -1
- package/lib/esm/sdk/extension_sdk_40.js +12 -6
- package/lib/esm/sdk/extension_sdk_40.js.map +1 -1
- package/lib/esm/sdk/index.js +16 -1
- package/lib/esm/sdk/index.js.map +1 -1
- package/lib/esm/sdk/sdk_connection.js +8 -9
- package/lib/esm/sdk/sdk_connection.js.map +1 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.js +1 -54
- package/lib/index.js.map +1 -1
- package/lib/sdk/extension_sdk.js +0 -8
- package/lib/sdk/extension_sdk.js.map +1 -1
- package/lib/sdk/extension_sdk_31.js +0 -6
- package/lib/sdk/extension_sdk_31.js.map +1 -1
- package/lib/sdk/extension_sdk_40.js +0 -6
- package/lib/sdk/extension_sdk_40.js.map +1 -1
- package/lib/sdk/index.js +0 -2
- package/lib/sdk/index.js.map +1 -1
- package/lib/sdk/sdk_connection.js +0 -10
- package/lib/sdk/sdk_connection.js.map +1 -1
- package/package.json +4 -4
- package/lib/connect/tile/index.d.ts +0 -1
- package/lib/connect/tile/index.js +0 -19
- package/lib/connect/tile/index.js.map +0 -1
- package/lib/connect/tile/tile_sdk.d.ts +0 -24
- package/lib/connect/tile/tile_sdk.js +0 -153
- package/lib/connect/tile/tile_sdk.js.map +0 -1
- package/lib/connect/tile/types.d.ts +0 -86
- package/lib/connect/tile/types.js +0 -15
- package/lib/connect/tile/types.js.map +0 -1
- package/lib/connect/visualization/index.d.ts +0 -2
- package/lib/connect/visualization/index.js +0 -32
- package/lib/connect/visualization/index.js.map +0 -1
- package/lib/connect/visualization/types.d.ts +0 -62
- package/lib/connect/visualization/types.js +0 -2
- package/lib/connect/visualization/types.js.map +0 -1
- package/lib/connect/visualization/visualization_sdk.d.ts +0 -36
- package/lib/connect/visualization/visualization_sdk.js +0 -166
- package/lib/connect/visualization/visualization_sdk.js.map +0 -1
- package/lib/esm/connect/tile/index.js +0 -2
- package/lib/esm/connect/tile/index.js.map +0 -1
- package/lib/esm/connect/tile/tile_sdk.js +0 -140
- package/lib/esm/connect/tile/tile_sdk.js.map +0 -1
- package/lib/esm/connect/tile/types.js +0 -8
- package/lib/esm/connect/tile/types.js.map +0 -1
- package/lib/esm/connect/visualization/index.js +0 -3
- package/lib/esm/connect/visualization/index.js.map +0 -1
- package/lib/esm/connect/visualization/types.js +0 -2
- package/lib/esm/connect/visualization/types.js.map +0 -1
- package/lib/esm/connect/visualization/visualization_sdk.js +0 -156
- package/lib/esm/connect/visualization/visualization_sdk.js.map +0 -1
- package/lib/esm/util/errors.js +0 -2
- package/lib/esm/util/errors.js.map +0 -1
- package/lib/esm/util/index.js +0 -3
- package/lib/esm/util/index.js.map +0 -1
- package/lib/esm/util/logger.js +0 -15
- package/lib/esm/util/logger.js.map +0 -1
- package/lib/util/errors.d.ts +0 -1
- package/lib/util/errors.js +0 -9
- package/lib/util/errors.js.map +0 -1
- package/lib/util/index.d.ts +0 -2
- package/lib/util/index.js +0 -32
- package/lib/util/index.js.map +0 -1
- package/lib/util/logger.d.ts +0 -2
- package/lib/util/logger.js +0 -27
- package/lib/util/logger.js.map +0 -1
|
@@ -1,206 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ExtensionHostApiImpl = exports.EXTENSION_SDK_VERSION = void 0;
|
|
7
|
+
var _intersects = _interopRequireDefault(require("semver/ranges/intersects"));
|
|
8
|
+
var _fetch_proxy = require("./fetch_proxy");
|
|
9
|
+
var _types = require("./types");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
|
|
3
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { TileSDKImpl } from './tile/tile_sdk';
|
|
11
|
-
import { FetchProxyImpl } from './fetch_proxy';
|
|
12
|
-
import { ExtensionEvent, ExtensionNotificationType, ExtensionRequestType, MountPoint } from './types';
|
|
13
|
-
export var EXTENSION_SDK_VERSION = '0.10.5';
|
|
14
|
-
export class ExtensionHostApiImpl {
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
var EXTENSION_SDK_VERSION = '0.10.5';
|
|
17
|
+
exports.EXTENSION_SDK_VERSION = EXTENSION_SDK_VERSION;
|
|
18
|
+
class ExtensionHostApiImpl {
|
|
15
19
|
constructor(configuration) {
|
|
16
20
|
_defineProperty(this, "_configuration", void 0);
|
|
17
|
-
|
|
18
21
|
_defineProperty(this, "_lookerHostData", void 0);
|
|
19
|
-
|
|
20
22
|
_defineProperty(this, "chattyHost", void 0);
|
|
21
|
-
|
|
22
23
|
_defineProperty(this, "setInitialRoute", void 0);
|
|
23
|
-
|
|
24
24
|
_defineProperty(this, "hostChangedRoute", void 0);
|
|
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
|
-
|
|
34
25
|
_defineProperty(this, "contextData", void 0);
|
|
35
|
-
|
|
36
26
|
this._configuration = configuration;
|
|
37
27
|
var {
|
|
38
28
|
chattyHost,
|
|
39
29
|
setInitialRoute,
|
|
40
|
-
hostChangedRoute
|
|
41
|
-
visualizationDataReceivedCallback,
|
|
42
|
-
tileHostDataChangedCallback
|
|
30
|
+
hostChangedRoute
|
|
43
31
|
} = this._configuration;
|
|
44
32
|
this.chattyHost = chattyHost;
|
|
45
33
|
this.setInitialRoute = setInitialRoute;
|
|
46
34
|
this.hostChangedRoute = hostChangedRoute;
|
|
47
|
-
this.visualizationDataReceivedCallback = visualizationDataReceivedCallback;
|
|
48
|
-
this.tileHostDataChangedCallback = tileHostDataChangedCallback;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get isDashboardMountSupported() {
|
|
52
|
-
var _this$_lookerHostData, _this$lookerHostData, _this$lookerHostData2, _this$lookerHostData3;
|
|
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 || ((_this$lookerHostData3 = this.lookerHostData) === null || _this$lookerHostData3 === void 0 ? void 0 : _this$lookerHostData3.mountPoint) === MountPoint.dashboardTilePopup);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get visualizationSDK() {
|
|
58
|
-
if (!this._visualizationSDK) {
|
|
59
|
-
this._visualizationSDK = new VisualizationSDKImpl(this);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return this._visualizationSDK;
|
|
63
35
|
}
|
|
64
|
-
|
|
65
|
-
get tileSDK() {
|
|
66
|
-
if (!this._tileSDK) {
|
|
67
|
-
this._tileSDK = new TileSDKImpl(this);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return this._tileSDK;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
36
|
get lookerHostData() {
|
|
74
37
|
return this._lookerHostData;
|
|
75
38
|
}
|
|
76
|
-
|
|
77
39
|
handleNotification(message) {
|
|
78
40
|
var {
|
|
79
|
-
type
|
|
80
|
-
|
|
81
|
-
|
|
41
|
+
type,
|
|
42
|
+
payload
|
|
43
|
+
} = message || {};
|
|
82
44
|
switch (type) {
|
|
83
|
-
case ExtensionNotificationType.ROUTE_CHANGED:
|
|
84
|
-
{
|
|
85
|
-
var {
|
|
86
|
-
payload
|
|
87
|
-
} = message;
|
|
88
|
-
|
|
89
|
-
if (this.hostChangedRoute && payload) {
|
|
90
|
-
var {
|
|
91
|
-
route: _route,
|
|
92
|
-
routeState: _routeState
|
|
93
|
-
} = payload;
|
|
94
|
-
|
|
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);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
case ExtensionNotificationType.TILE_HOST_DATA:
|
|
118
|
-
{
|
|
45
|
+
case _types.ExtensionNotificationType.ROUTE_CHANGED:
|
|
46
|
+
if (this.hostChangedRoute && payload) {
|
|
119
47
|
var {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.tileHostDataChangedCallback(_payload2);
|
|
48
|
+
route: _route,
|
|
49
|
+
routeState: _routeState
|
|
50
|
+
} = payload;
|
|
51
|
+
if (_route) {
|
|
52
|
+
this.hostChangedRoute(_route, _routeState);
|
|
126
53
|
}
|
|
127
|
-
|
|
128
|
-
return undefined;
|
|
129
54
|
}
|
|
130
|
-
|
|
131
|
-
case ExtensionNotificationType.INITIALIZE:
|
|
55
|
+
return undefined;
|
|
56
|
+
case _types.ExtensionNotificationType.INITIALIZE:
|
|
132
57
|
{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var lookerHostData = _payload3 || {};
|
|
137
|
-
|
|
138
|
-
if (!lookerHostData.mountPoint) {
|
|
139
|
-
lookerHostData.mountPoint = MountPoint.standalone;
|
|
58
|
+
this._lookerHostData = payload;
|
|
59
|
+
if (this._lookerHostData) {
|
|
60
|
+
this.contextData = this._lookerHostData.contextData;
|
|
140
61
|
}
|
|
141
|
-
|
|
142
|
-
this._lookerHostData = lookerHostData;
|
|
143
|
-
this.contextData = lookerHostData.contextData;
|
|
144
62
|
var errorMessage;
|
|
145
|
-
|
|
146
|
-
if (this._configuration.requiredLookerVersion && lookerHostData.lookerVersion) {
|
|
63
|
+
if (this._configuration.requiredLookerVersion && this._lookerHostData && this._lookerHostData.lookerVersion) {
|
|
147
64
|
errorMessage = this.verifyLookerVersion(this._configuration.requiredLookerVersion);
|
|
148
|
-
|
|
149
65
|
if (errorMessage) {
|
|
150
|
-
|
|
66
|
+
console.error(errorMessage);
|
|
151
67
|
}
|
|
152
68
|
}
|
|
153
|
-
|
|
154
|
-
if (this.setInitialRoute && _payload3) {
|
|
69
|
+
if (this.setInitialRoute && payload) {
|
|
155
70
|
var {
|
|
156
71
|
route: _route2,
|
|
157
72
|
routeState: _routeState2
|
|
158
|
-
} =
|
|
159
|
-
|
|
73
|
+
} = payload;
|
|
160
74
|
if (_route2) {
|
|
161
75
|
this.setInitialRoute(_route2, _routeState2);
|
|
162
76
|
}
|
|
163
77
|
}
|
|
164
|
-
|
|
165
78
|
return {
|
|
166
79
|
extensionSdkVersion: EXTENSION_SDK_VERSION,
|
|
167
80
|
errorMessage
|
|
168
81
|
};
|
|
169
82
|
}
|
|
170
|
-
|
|
171
83
|
default:
|
|
172
|
-
|
|
84
|
+
console.error('Unrecognized extension notification', message);
|
|
173
85
|
throw new Error("Unrecognized extension notification type ".concat(type));
|
|
174
86
|
}
|
|
175
87
|
}
|
|
176
|
-
|
|
177
88
|
createSecretKeyTag(keyName) {
|
|
178
89
|
var errorMessage = this.verifyLookerVersion('>=7.11');
|
|
179
|
-
|
|
180
90
|
if (errorMessage) {
|
|
181
91
|
throw new Error(errorMessage);
|
|
182
92
|
}
|
|
183
|
-
|
|
184
93
|
if (!keyName.match(/^[A-Za-z0-9_.]+$/)) {
|
|
185
94
|
throw new Error('Unsupported characters in key name');
|
|
186
95
|
}
|
|
187
|
-
|
|
188
96
|
return "{{".concat(this._lookerHostData.extensionId.replace(/::|-/g, '_'), "_").concat(keyName, "}}");
|
|
189
97
|
}
|
|
190
|
-
|
|
191
98
|
verifyHostConnection() {
|
|
192
99
|
var _this = this;
|
|
193
|
-
|
|
194
100
|
return _asyncToGenerator(function* () {
|
|
195
|
-
return _this.sendAndReceive(ExtensionRequestType.VERIFY_HOST);
|
|
101
|
+
return _this.sendAndReceive(_types.ExtensionRequestType.VERIFY_HOST);
|
|
196
102
|
})();
|
|
197
103
|
}
|
|
198
|
-
|
|
199
104
|
invokeCoreSdk(httpMethod, path, params, body, authenticator, options, apiVersion) {
|
|
200
105
|
var _this2 = this;
|
|
201
|
-
|
|
202
106
|
return _asyncToGenerator(function* () {
|
|
203
|
-
return _this2.sendAndReceive(ExtensionRequestType.INVOKE_CORE_SDK, {
|
|
107
|
+
return _this2.sendAndReceive(_types.ExtensionRequestType.INVOKE_CORE_SDK, {
|
|
204
108
|
httpMethod,
|
|
205
109
|
path,
|
|
206
110
|
params,
|
|
@@ -211,12 +115,10 @@ export class ExtensionHostApiImpl {
|
|
|
211
115
|
});
|
|
212
116
|
})();
|
|
213
117
|
}
|
|
214
|
-
|
|
215
118
|
invokeCoreSdkRaw(httpMethod, path, params, body, apiVersion) {
|
|
216
119
|
var _this3 = this;
|
|
217
|
-
|
|
218
120
|
return _asyncToGenerator(function* () {
|
|
219
|
-
return _this3.sendAndReceive(ExtensionRequestType.RAW_INVOKE_CORE_SDK, {
|
|
121
|
+
return _this3.sendAndReceive(_types.ExtensionRequestType.RAW_INVOKE_CORE_SDK, {
|
|
220
122
|
httpMethod,
|
|
221
123
|
path,
|
|
222
124
|
params,
|
|
@@ -225,191 +127,150 @@ export class ExtensionHostApiImpl {
|
|
|
225
127
|
});
|
|
226
128
|
})();
|
|
227
129
|
}
|
|
228
|
-
|
|
229
130
|
updateTitle(title) {
|
|
230
|
-
this.send(ExtensionRequestType.UPDATE_TITLE, {
|
|
131
|
+
this.send(_types.ExtensionRequestType.UPDATE_TITLE, {
|
|
231
132
|
title
|
|
232
133
|
});
|
|
233
134
|
}
|
|
234
|
-
|
|
235
135
|
updateLocation(url, state, target) {
|
|
236
|
-
this.send(ExtensionRequestType.UPDATE_LOCATION, {
|
|
136
|
+
this.send(_types.ExtensionRequestType.UPDATE_LOCATION, {
|
|
237
137
|
url,
|
|
238
138
|
state,
|
|
239
139
|
target
|
|
240
140
|
});
|
|
241
141
|
}
|
|
242
|
-
|
|
243
142
|
spartanLogout() {
|
|
244
|
-
this.send(ExtensionRequestType.SPARTAN_LOGOUT);
|
|
143
|
+
this.send(_types.ExtensionRequestType.SPARTAN_LOGOUT);
|
|
245
144
|
}
|
|
246
|
-
|
|
247
145
|
openBrowserWindow(url, target) {
|
|
248
|
-
this.send(ExtensionRequestType.UPDATE_LOCATION, {
|
|
146
|
+
this.send(_types.ExtensionRequestType.UPDATE_LOCATION, {
|
|
249
147
|
url,
|
|
250
148
|
undefined,
|
|
251
149
|
target: target || '_blank'
|
|
252
150
|
});
|
|
253
151
|
}
|
|
254
|
-
|
|
255
152
|
closeHostPopovers() {
|
|
256
|
-
this.send(ExtensionRequestType.CLOSE_HOST_POPOVERS);
|
|
153
|
+
this.send(_types.ExtensionRequestType.CLOSE_HOST_POPOVERS);
|
|
257
154
|
}
|
|
258
|
-
|
|
259
155
|
clientRouteChanged(route, routeState) {
|
|
260
|
-
this.send(ExtensionRequestType.ROUTE_CHANGED, {
|
|
156
|
+
this.send(_types.ExtensionRequestType.ROUTE_CHANGED, {
|
|
261
157
|
route,
|
|
262
158
|
routeState
|
|
263
159
|
});
|
|
264
160
|
}
|
|
265
|
-
|
|
266
161
|
localStorageSetItem(name) {
|
|
267
162
|
var _arguments = arguments,
|
|
268
|
-
|
|
269
|
-
|
|
163
|
+
_this4 = this;
|
|
270
164
|
return _asyncToGenerator(function* () {
|
|
271
165
|
var value = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : '';
|
|
272
|
-
|
|
273
166
|
if (_this4._lookerHostData && !_this4._lookerHostData.lookerVersion) {
|
|
274
167
|
return Promise.reject(new Error('localStorageSetItem not supported by the current Looker host'));
|
|
275
168
|
}
|
|
276
|
-
|
|
277
|
-
return _this4.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
|
|
169
|
+
return _this4.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
|
|
278
170
|
type: 'set',
|
|
279
171
|
name,
|
|
280
172
|
value
|
|
281
173
|
});
|
|
282
174
|
})();
|
|
283
175
|
}
|
|
284
|
-
|
|
285
176
|
localStorageGetItem(name) {
|
|
286
177
|
var _this5 = this;
|
|
287
|
-
|
|
288
178
|
return _asyncToGenerator(function* () {
|
|
289
179
|
if (_this5._lookerHostData && !_this5._lookerHostData.lookerVersion) {
|
|
290
180
|
return Promise.reject(new Error('localStorageGetItem not supported by the current Looker host'));
|
|
291
181
|
}
|
|
292
|
-
|
|
293
|
-
return _this5.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
|
|
182
|
+
return _this5.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
|
|
294
183
|
type: 'get',
|
|
295
184
|
name
|
|
296
185
|
});
|
|
297
186
|
})();
|
|
298
187
|
}
|
|
299
|
-
|
|
300
188
|
localStorageRemoveItem(name) {
|
|
301
189
|
var _this6 = this;
|
|
302
|
-
|
|
303
190
|
return _asyncToGenerator(function* () {
|
|
304
191
|
if (_this6._lookerHostData && !_this6._lookerHostData.lookerVersion) {
|
|
305
192
|
return Promise.reject(new Error('localStorageRemoveItem not supported by the current Looker host'));
|
|
306
193
|
}
|
|
307
|
-
|
|
308
|
-
return _this6.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
|
|
194
|
+
return _this6.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
|
|
309
195
|
type: 'remove',
|
|
310
196
|
name
|
|
311
197
|
});
|
|
312
198
|
})();
|
|
313
199
|
}
|
|
314
|
-
|
|
315
200
|
clipboardWrite(value) {
|
|
316
201
|
var _this7 = this;
|
|
317
|
-
|
|
318
202
|
return _asyncToGenerator(function* () {
|
|
319
203
|
var errorMessage = _this7.verifyLookerVersion('>=21.7');
|
|
320
|
-
|
|
321
204
|
if (errorMessage) {
|
|
322
205
|
return Promise.reject(new Error(errorMessage));
|
|
323
206
|
}
|
|
324
|
-
|
|
325
|
-
return _this7.sendAndReceive(ExtensionRequestType.CLIPBOARD, {
|
|
207
|
+
return _this7.sendAndReceive(_types.ExtensionRequestType.CLIPBOARD, {
|
|
326
208
|
type: 'write',
|
|
327
209
|
value
|
|
328
210
|
});
|
|
329
211
|
})();
|
|
330
212
|
}
|
|
331
|
-
|
|
332
213
|
userAttributeSetItem(name) {
|
|
333
214
|
var _arguments2 = arguments,
|
|
334
|
-
|
|
335
|
-
|
|
215
|
+
_this8 = this;
|
|
336
216
|
return _asyncToGenerator(function* () {
|
|
337
217
|
var value = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : '';
|
|
338
|
-
|
|
339
218
|
var errorMessage = _this8.verifyLookerVersion('>=7.15');
|
|
340
|
-
|
|
341
219
|
if (errorMessage) {
|
|
342
220
|
return Promise.reject(new Error(errorMessage));
|
|
343
221
|
}
|
|
344
|
-
|
|
345
|
-
return _this8.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
|
|
222
|
+
return _this8.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
|
|
346
223
|
type: 'set',
|
|
347
224
|
name,
|
|
348
225
|
value
|
|
349
226
|
});
|
|
350
227
|
})();
|
|
351
228
|
}
|
|
352
|
-
|
|
353
229
|
userAttributeGetItem(name) {
|
|
354
230
|
var _this9 = this;
|
|
355
|
-
|
|
356
231
|
return _asyncToGenerator(function* () {
|
|
357
232
|
var errorMessage = _this9.verifyLookerVersion('>=7.15');
|
|
358
|
-
|
|
359
233
|
if (errorMessage) {
|
|
360
234
|
return Promise.reject(new Error(errorMessage));
|
|
361
235
|
}
|
|
362
|
-
|
|
363
|
-
return _this9.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
|
|
236
|
+
return _this9.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
|
|
364
237
|
type: 'get',
|
|
365
238
|
name
|
|
366
239
|
});
|
|
367
240
|
})();
|
|
368
241
|
}
|
|
369
|
-
|
|
370
242
|
userAttributeResetItem(name) {
|
|
371
243
|
var _this10 = this;
|
|
372
|
-
|
|
373
244
|
return _asyncToGenerator(function* () {
|
|
374
245
|
var errorMessage = _this10.verifyLookerVersion('>=7.15');
|
|
375
|
-
|
|
376
246
|
if (errorMessage) {
|
|
377
247
|
return Promise.reject(new Error(errorMessage));
|
|
378
248
|
}
|
|
379
|
-
|
|
380
|
-
return _this10.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
|
|
249
|
+
return _this10.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
|
|
381
250
|
type: 'reset',
|
|
382
251
|
name
|
|
383
252
|
});
|
|
384
253
|
})();
|
|
385
254
|
}
|
|
386
|
-
|
|
387
255
|
getContextData() {
|
|
388
256
|
var errorMessage = this.verifyLookerVersion('>=7.13');
|
|
389
|
-
|
|
390
257
|
if (errorMessage) {
|
|
391
258
|
throw new Error(errorMessage);
|
|
392
259
|
}
|
|
393
|
-
|
|
394
260
|
if (this.contextData) {
|
|
395
261
|
return JSON.parse(this.contextData);
|
|
396
262
|
} else {
|
|
397
263
|
return undefined;
|
|
398
264
|
}
|
|
399
265
|
}
|
|
400
|
-
|
|
401
266
|
saveContextData(context) {
|
|
402
267
|
var _this11 = this;
|
|
403
|
-
|
|
404
268
|
return _asyncToGenerator(function* () {
|
|
405
269
|
var errorMessage = _this11.verifyLookerVersion('>=7.13');
|
|
406
|
-
|
|
407
270
|
if (errorMessage) {
|
|
408
271
|
return Promise.reject(new Error(errorMessage));
|
|
409
272
|
}
|
|
410
|
-
|
|
411
273
|
var contextData;
|
|
412
|
-
|
|
413
274
|
if (context) {
|
|
414
275
|
try {
|
|
415
276
|
contextData = JSON.stringify(context);
|
|
@@ -419,40 +280,33 @@ export class ExtensionHostApiImpl {
|
|
|
419
280
|
} else {
|
|
420
281
|
contextData = undefined;
|
|
421
282
|
}
|
|
422
|
-
|
|
423
|
-
yield _this11.sendAndReceive(ExtensionRequestType.CONTEXT_DATA, {
|
|
283
|
+
yield _this11.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
|
|
424
284
|
type: 'save',
|
|
425
285
|
contextData
|
|
426
286
|
});
|
|
427
287
|
return _this11.getContextData();
|
|
428
288
|
})();
|
|
429
289
|
}
|
|
430
|
-
|
|
431
290
|
refreshContextData() {
|
|
432
291
|
var _this12 = this;
|
|
433
|
-
|
|
434
292
|
return _asyncToGenerator(function* () {
|
|
435
293
|
var errorMessage = _this12.verifyLookerVersion('>=7.13');
|
|
436
|
-
|
|
437
294
|
if (errorMessage) {
|
|
438
295
|
return Promise.reject(new Error(errorMessage));
|
|
439
296
|
}
|
|
440
|
-
|
|
441
|
-
_this12.contextData = yield _this12.sendAndReceive(ExtensionRequestType.CONTEXT_DATA, {
|
|
297
|
+
_this12.contextData = yield _this12.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
|
|
442
298
|
type: 'refresh'
|
|
443
299
|
});
|
|
444
300
|
return _this12.getContextData();
|
|
445
301
|
})();
|
|
446
302
|
}
|
|
447
|
-
|
|
448
303
|
track(name, trackAction, attributes) {
|
|
449
|
-
this.send(ExtensionRequestType.TRACK_ACTION, {
|
|
304
|
+
this.send(_types.ExtensionRequestType.TRACK_ACTION, {
|
|
450
305
|
name,
|
|
451
306
|
trackAction,
|
|
452
307
|
attributes
|
|
453
308
|
});
|
|
454
309
|
}
|
|
455
|
-
|
|
456
310
|
error(errorEvent) {
|
|
457
311
|
if (this._lookerHostData) {
|
|
458
312
|
var {
|
|
@@ -462,7 +316,7 @@ export class ExtensionHostApiImpl {
|
|
|
462
316
|
colno,
|
|
463
317
|
error
|
|
464
318
|
} = errorEvent || {};
|
|
465
|
-
this.send(ExtensionRequestType.ERROR_EVENT, {
|
|
319
|
+
this.send(_types.ExtensionRequestType.ERROR_EVENT, {
|
|
466
320
|
message,
|
|
467
321
|
filename,
|
|
468
322
|
lineno,
|
|
@@ -470,29 +324,23 @@ export class ExtensionHostApiImpl {
|
|
|
470
324
|
error: error && error.toString ? error.toString() : error
|
|
471
325
|
});
|
|
472
326
|
} else {
|
|
473
|
-
|
|
327
|
+
console.error('Unhandled error but Looker host connection not established', errorEvent);
|
|
474
328
|
}
|
|
475
329
|
}
|
|
476
|
-
|
|
477
330
|
unloaded() {
|
|
478
|
-
this.send(ExtensionRequestType.EXTENSION_UNLOADED, {});
|
|
331
|
+
this.send(_types.ExtensionRequestType.EXTENSION_UNLOADED, {});
|
|
479
332
|
}
|
|
480
|
-
|
|
481
333
|
createFetchProxy(baseUrl, init, responseBodyType) {
|
|
482
|
-
return new FetchProxyImpl(this, baseUrl, init, responseBodyType);
|
|
334
|
+
return new _fetch_proxy.FetchProxyImpl(this, baseUrl, init, responseBodyType);
|
|
483
335
|
}
|
|
484
|
-
|
|
485
336
|
fetchProxy(resource, init, responseBodyType) {
|
|
486
337
|
var _this13 = this;
|
|
487
|
-
|
|
488
338
|
return _asyncToGenerator(function* () {
|
|
489
339
|
var errorMessage = _this13.verifyLookerVersion('>=7.9');
|
|
490
|
-
|
|
491
340
|
if (errorMessage) {
|
|
492
341
|
return Promise.reject(new Error(errorMessage));
|
|
493
342
|
}
|
|
494
|
-
|
|
495
|
-
return _this13.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
343
|
+
return _this13.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
496
344
|
type: 'fetch',
|
|
497
345
|
payload: {
|
|
498
346
|
resource,
|
|
@@ -502,18 +350,14 @@ export class ExtensionHostApiImpl {
|
|
|
502
350
|
});
|
|
503
351
|
})();
|
|
504
352
|
}
|
|
505
|
-
|
|
506
353
|
serverProxy(resource, init, responseBodyType) {
|
|
507
354
|
var _this14 = this;
|
|
508
|
-
|
|
509
355
|
return _asyncToGenerator(function* () {
|
|
510
356
|
var errorMessage = _this14.verifyLookerVersion('>=7.11');
|
|
511
|
-
|
|
512
357
|
if (errorMessage) {
|
|
513
358
|
return Promise.reject(new Error(errorMessage));
|
|
514
359
|
}
|
|
515
|
-
|
|
516
|
-
return _this14.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
360
|
+
return _this14.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
517
361
|
type: 'server-proxy',
|
|
518
362
|
payload: {
|
|
519
363
|
resource,
|
|
@@ -523,27 +367,20 @@ export class ExtensionHostApiImpl {
|
|
|
523
367
|
});
|
|
524
368
|
})();
|
|
525
369
|
}
|
|
526
|
-
|
|
527
370
|
oauth2Authenticate(authEndpoint, authParameters) {
|
|
528
371
|
var _arguments3 = arguments,
|
|
529
|
-
|
|
530
|
-
|
|
372
|
+
_this15 = this;
|
|
531
373
|
return _asyncToGenerator(function* () {
|
|
532
374
|
var httpMethod = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : 'POST';
|
|
533
|
-
|
|
534
375
|
var errorMessage = _this15.verifyLookerVersion('>=7.9');
|
|
535
|
-
|
|
536
376
|
if (errorMessage) {
|
|
537
377
|
return Promise.reject(new Error(errorMessage));
|
|
538
378
|
}
|
|
539
|
-
|
|
540
379
|
errorMessage = _this15.validateAuthParameters(authParameters);
|
|
541
|
-
|
|
542
380
|
if (errorMessage) {
|
|
543
381
|
return Promise.reject(new Error(errorMessage));
|
|
544
382
|
}
|
|
545
|
-
|
|
546
|
-
return _this15.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
383
|
+
return _this15.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
547
384
|
type: 'oauth2_authenticate',
|
|
548
385
|
payload: {
|
|
549
386
|
authEndpoint,
|
|
@@ -555,18 +392,14 @@ export class ExtensionHostApiImpl {
|
|
|
555
392
|
});
|
|
556
393
|
})();
|
|
557
394
|
}
|
|
558
|
-
|
|
559
395
|
oauth2ExchangeCodeForToken(authEndpoint, authParameters) {
|
|
560
396
|
var _this16 = this;
|
|
561
|
-
|
|
562
397
|
return _asyncToGenerator(function* () {
|
|
563
398
|
var errorMessage = _this16.verifyLookerVersion('>=7.11');
|
|
564
|
-
|
|
565
399
|
if (errorMessage) {
|
|
566
400
|
return Promise.reject(new Error(errorMessage));
|
|
567
401
|
}
|
|
568
|
-
|
|
569
|
-
return _this16.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
402
|
+
return _this16.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
570
403
|
type: 'oauth2_exchange_code',
|
|
571
404
|
payload: {
|
|
572
405
|
authEndpoint,
|
|
@@ -575,66 +408,48 @@ export class ExtensionHostApiImpl {
|
|
|
575
408
|
});
|
|
576
409
|
})();
|
|
577
410
|
}
|
|
578
|
-
|
|
579
|
-
rendered(failureMessage) {
|
|
580
|
-
this.send(ExtensionRequestType.RENDERED, {
|
|
581
|
-
failureMessage
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
|
|
585
411
|
sendAndReceive(type, payload, options) {
|
|
586
412
|
var _this17 = this;
|
|
587
|
-
|
|
588
413
|
return _asyncToGenerator(function* () {
|
|
589
414
|
if (!_this17._lookerHostData) {
|
|
590
415
|
return Promise.reject(new Error('Looker host connection not established'));
|
|
591
416
|
}
|
|
592
|
-
|
|
593
417
|
var messagePayload = {
|
|
594
418
|
type,
|
|
595
419
|
payload
|
|
596
420
|
};
|
|
597
421
|
var chattyPayload = options ? [messagePayload, options] : [messagePayload];
|
|
598
|
-
return _this17.chattyHost.sendAndReceive(ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
|
|
422
|
+
return _this17.chattyHost.sendAndReceive(_types.ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
|
|
599
423
|
})();
|
|
600
424
|
}
|
|
601
|
-
|
|
602
425
|
send(type, payload) {
|
|
603
426
|
if (!this._lookerHostData) {
|
|
604
427
|
throw new Error('Looker host connection not established');
|
|
605
428
|
}
|
|
606
|
-
|
|
607
|
-
this.chattyHost.send(ExtensionEvent.EXTENSION_API_REQUEST, {
|
|
429
|
+
this.chattyHost.send(_types.ExtensionEvent.EXTENSION_API_REQUEST, {
|
|
608
430
|
type,
|
|
609
431
|
payload
|
|
610
432
|
});
|
|
611
433
|
}
|
|
612
|
-
|
|
613
434
|
verifyLookerVersion(version) {
|
|
614
435
|
var lookerVersion = this._lookerHostData ? this._lookerHostData.lookerVersion || '7.0' : '7.0';
|
|
615
|
-
|
|
616
|
-
if (!this._lookerHostData || !intersects(version, lookerVersion, true)) {
|
|
436
|
+
if (!this._lookerHostData || !(0, _intersects.default)(version, lookerVersion, true)) {
|
|
617
437
|
return "Extension requires Looker version ".concat(version, ", got ").concat(lookerVersion);
|
|
618
438
|
}
|
|
619
|
-
|
|
620
439
|
return undefined;
|
|
621
440
|
}
|
|
622
|
-
|
|
623
441
|
validateAuthParameters(authParameters) {
|
|
624
442
|
if (!authParameters.client_id) {
|
|
625
443
|
return 'client_id missing';
|
|
626
444
|
}
|
|
627
|
-
|
|
628
445
|
if (authParameters.redirect_uri) {
|
|
629
446
|
return 'redirect_uri must NOT be included';
|
|
630
447
|
}
|
|
631
|
-
|
|
632
448
|
if (authParameters.response_type !== 'token' && authParameters.response_type !== 'id_token' && authParameters.response_type !== 'code') {
|
|
633
449
|
return "invalid response_type, must be token, id_token or code, ".concat(authParameters.response_type);
|
|
634
450
|
}
|
|
635
|
-
|
|
636
451
|
return undefined;
|
|
637
452
|
}
|
|
638
|
-
|
|
639
453
|
}
|
|
454
|
+
exports.ExtensionHostApiImpl = ExtensionHostApiImpl;
|
|
640
455
|
//# sourceMappingURL=extension_host_api.js.map
|