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