@looker/extension-sdk 26.6.0 → 26.8.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 +29 -0
- package/lib/connect/connect_extension_host.js +66 -65
- package/lib/connect/connect_extension_host.js.map +1 -1
- package/lib/connect/extension_host_api.js +40 -40
- package/lib/connect/extension_host_api.js.map +1 -1
- package/lib/connect/fetch_proxy.js +3 -3
- package/lib/connect/fetch_proxy.js.map +1 -1
- package/lib/connect/global_listener.js.map +1 -1
- package/lib/connect/index.js.map +1 -1
- package/lib/connect/tile/index.js.map +1 -1
- package/lib/connect/tile/tile_sdk.js +2 -2
- package/lib/connect/tile/tile_sdk.js.map +1 -1
- package/lib/connect/tile/types.js.map +1 -1
- package/lib/connect/types.js.map +1 -1
- package/lib/connect/visualization/index.js.map +1 -1
- package/lib/connect/visualization/types.js +4 -0
- package/lib/connect/visualization/types.js.map +1 -1
- package/lib/connect/visualization/visualization_sdk.js +6 -6
- package/lib/connect/visualization/visualization_sdk.js.map +1 -1
- package/lib/esm/connect/connect_extension_host.js +66 -65
- package/lib/esm/connect/connect_extension_host.js.map +1 -1
- package/lib/esm/connect/extension_host_api.js +39 -39
- package/lib/esm/connect/extension_host_api.js.map +1 -1
- package/lib/esm/connect/fetch_proxy.js +2 -2
- package/lib/esm/connect/fetch_proxy.js.map +1 -1
- package/lib/esm/connect/global_listener.js.map +1 -1
- package/lib/esm/connect/index.js.map +1 -1
- package/lib/esm/connect/tile/index.js.map +1 -1
- package/lib/esm/connect/tile/tile_sdk.js +2 -2
- package/lib/esm/connect/tile/tile_sdk.js.map +1 -1
- package/lib/esm/connect/tile/types.js.map +1 -1
- package/lib/esm/connect/types.js.map +1 -1
- package/lib/esm/connect/visualization/index.js.map +1 -1
- package/lib/esm/connect/visualization/types.js +1 -1
- package/lib/esm/connect/visualization/types.js.map +1 -1
- package/lib/esm/connect/visualization/visualization_sdk.js +6 -6
- package/lib/esm/connect/visualization/visualization_sdk.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/sdk/extension_sdk.js.map +1 -1
- package/lib/esm/sdk/index.js.map +1 -1
- package/lib/esm/sdk/sdk_connection.js +2 -2
- package/lib/esm/sdk/sdk_connection.js.map +1 -1
- package/lib/esm/util/errors.js.map +1 -1
- package/lib/esm/util/index.js.map +1 -1
- package/lib/esm/util/logger.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/sdk/extension_sdk.js.map +1 -1
- package/lib/sdk/index.js.map +1 -1
- package/lib/sdk/sdk_connection.js +2 -2
- package/lib/sdk/sdk_connection.js.map +1 -1
- package/lib/util/errors.js.map +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/logger.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [26.8.0](https://github.com/looker-open-source/sdk-codegen/compare/extension-sdk-v26.6.1...extension-sdk-v26.8.0) (2026-05-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Miscellaneous Chores
|
|
12
|
+
|
|
13
|
+
* **extension-sdk:** Synchronize undefined versions
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @looker/sdk bumped from 26.6.1 to 26.8.0
|
|
21
|
+
|
|
22
|
+
## [26.6.1](https://github.com/looker-open-source/sdk-codegen/compare/extension-sdk-v26.6.0...extension-sdk-v26.6.1) (2026-03-25)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Miscellaneous Chores
|
|
26
|
+
|
|
27
|
+
* **extension-sdk:** Synchronize undefined versions
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* The following workspace dependencies were updated
|
|
33
|
+
* dependencies
|
|
34
|
+
* @looker/sdk bumped from 26.6.0 to 26.6.1
|
|
35
|
+
* @looker/sdk-rtl bumped from 21.6.4 to 21.6.5
|
|
36
|
+
|
|
8
37
|
## [26.6.0](https://github.com/looker-open-source/sdk-codegen/compare/extension-sdk-v26.4.0...extension-sdk-v26.6.0) (2026-03-20)
|
|
9
38
|
|
|
10
39
|
|
|
@@ -10,82 +10,83 @@ var _global_listener = require("./global_listener");
|
|
|
10
10
|
var _types = require("./types");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i :
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
15
15
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
function asyncGeneratorStep(
|
|
17
|
-
function _asyncToGenerator(
|
|
16
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
17
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
18
18
|
var connectExtensionHost = exports.connectExtensionHost = function () {
|
|
19
19
|
var _ref = _asyncToGenerator(function* () {
|
|
20
20
|
var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
21
|
-
return new Promise(function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
return (new Promise(function () {
|
|
22
|
+
var _ref2 = _asyncToGenerator(function* (resolve, reject) {
|
|
23
|
+
var initializationTimer = window.setTimeout(() => reject(new Error('Failed to establish communication with Looker host')), 30000);
|
|
24
|
+
var {
|
|
25
|
+
initializedCallback,
|
|
26
|
+
chattyTimeout
|
|
27
|
+
} = configuration;
|
|
28
|
+
var extensionHost;
|
|
29
|
+
var targetOrigin;
|
|
30
|
+
var initialized = initializationResponse => {
|
|
31
|
+
if (initializationResponse) {
|
|
32
|
+
var {
|
|
33
|
+
errorMessage
|
|
34
|
+
} = initializationResponse;
|
|
35
|
+
if (initializedCallback) {
|
|
36
|
+
initializedCallback(errorMessage);
|
|
37
|
+
}
|
|
38
|
+
if (errorMessage) {
|
|
39
|
+
reject(new Error(errorMessage));
|
|
40
|
+
} else {
|
|
41
|
+
resolve(extensionHost);
|
|
42
|
+
}
|
|
40
43
|
} else {
|
|
41
|
-
|
|
44
|
+
reject(new Error('Unexpected response from initialization'));
|
|
42
45
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
targetOrigin = window.parent.location.origin;
|
|
49
|
+
} catch (err) {
|
|
50
|
+
targetOrigin = '*';
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
initialized(messageResponse);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
reject(error);
|
|
52
|
+
try {
|
|
53
|
+
var chattyHost = yield _chatty.Chatty.createClient().on(_types.ExtensionEvent.EXTENSION_HOST_NOTIFICATION, message => {
|
|
54
|
+
var messageResponse;
|
|
55
|
+
if (message) {
|
|
56
|
+
if (initializationTimer) {
|
|
57
|
+
window.clearTimeout(initializationTimer);
|
|
58
|
+
initializationTimer = undefined;
|
|
59
|
+
if (extensionHost) {
|
|
60
|
+
try {
|
|
61
|
+
messageResponse = extensionHost.handleNotification(message);
|
|
62
|
+
initialized(messageResponse);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
reject(error);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
reject(new Error('Extension host not created'));
|
|
65
68
|
}
|
|
66
69
|
} else {
|
|
67
|
-
|
|
70
|
+
messageResponse = extensionHost.handleNotification(message);
|
|
68
71
|
}
|
|
69
|
-
} else {
|
|
70
|
-
messageResponse = extensionHost.handleNotification(message);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
73
|
+
return messageResponse;
|
|
74
|
+
}).withTargetOrigin(targetOrigin).withDefaultTimeout(chattyTimeout || 30000).build().connect();
|
|
75
|
+
extensionHost = new _extension_host_api.ExtensionHostApiImpl(_objectSpread({
|
|
76
|
+
chattyHost
|
|
77
|
+
}, configuration));
|
|
78
|
+
(0, _global_listener.registerHostApi)(extensionHost);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
window.clearTimeout(initializationTimer);
|
|
81
|
+
initializationTimer = undefined;
|
|
82
|
+
reject(error);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return function (_x, _x2) {
|
|
86
|
+
return _ref2.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}())
|
|
89
|
+
);
|
|
89
90
|
});
|
|
90
91
|
return function connectExtensionHost() {
|
|
91
92
|
return _ref.apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect_extension_host.js","names":["_chatty","require","_extension_host_api","_global_listener","_types","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","connectExtensionHost","exports","_ref","configuration","_ref2","initializationTimer","window","setTimeout","Error","initializedCallback","chattyTimeout","extensionHost","targetOrigin","initialized","initializationResponse","errorMessage","parent","location","origin","chattyHost","Chatty","createClient","on","ExtensionEvent","EXTENSION_HOST_NOTIFICATION","message","messageResponse","clearTimeout","handleNotification","withTargetOrigin","withDefaultTimeout","build","connect","ExtensionHostApiImpl","registerHostApi","_x","_x2"],"sources":["../../src/connect/connect_extension_host.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 { Chatty } from '@looker/chatty';\nimport { ExtensionHostApiImpl } from './extension_host_api';\nimport { registerHostApi } from './global_listener';\nimport type {\n ExtensionHostApi,\n ExtensionHostConfiguration,\n ExtensionInitializationResponse,\n ExtensionNotification,\n} from './types';\nimport { ExtensionEvent } from './types';\n\n/**\n * Connect extension to Looker host. React extensions using the extension-sdk-react\n * package and ExtensionProvider do not need to call this as the ExtensionProvider\n * sets up the connection.\n * @param configuration\n */\nexport const connectExtensionHost = async (\n configuration: ExtensionHostConfiguration = {}\n): Promise<ExtensionHostApi> =>\n // eslint-disable-next-line no-async-promise-executor\n new Promise(async (resolve, reject) => {\n // Timer to handle the unlikely event that an initialization message\n // is not received from the host. If this happens it's a bug in the\n // host code.\n let initializationTimer: number | undefined = window.setTimeout(\n () =>\n reject(new Error('Failed to establish communication with Looker host')),\n 30000\n );\n // Legacy callback to indicate that connection is established\n const { initializedCallback, chattyTimeout } = configuration;\n let extensionHost: ExtensionHostApi;\n let targetOrigin;\n // The initialized function replaces the need the legacy callback as it\n // resolves/rejects the promise that now wraps the chatty promise that\n // was originally returned.\n const initialized = (\n initializationResponse?: ExtensionInitializationResponse\n ) => {\n // An initialization response is expected but the handle notification\n // method can return undefined.\n if (initializationResponse) {\n // The initialization can fail, for example, Looker host is not\n // at the right version.\n const { errorMessage } = initializationResponse;\n if (initializedCallback) {\n initializedCallback(errorMessage);\n }\n if (errorMessage) {\n reject(new Error(errorMessage));\n } else {\n resolve(extensionHost);\n }\n } else {\n reject(new Error('Unexpected response from initialization'));\n }\n };\n try {\n // if extension is not sandboxed the following will succeed\n targetOrigin = window.parent.location.origin;\n } catch (err) {\n // failure indicates running in a sandboxed environment\n targetOrigin = '*';\n }\n try {\n const chattyHost = await Chatty.createClient()\n .on(\n ExtensionEvent.EXTENSION_HOST_NOTIFICATION,\n (\n message?: ExtensionNotification\n ): ExtensionInitializationResponse | undefined => {\n // Handle messages from the looker host. The first message should\n // be an initialization message containing information about the host\n // and host extension (looker version, extension id for example).\n let messageResponse: ExtensionInitializationResponse | undefined;\n if (message) {\n if (initializationTimer) {\n // The initialization timer is present so assume this is an initialization\n // message. The initialization timer is now cleared.\n window.clearTimeout(initializationTimer);\n initializationTimer = undefined;\n if (extensionHost) {\n try {\n messageResponse = extensionHost.handleNotification(message);\n initialized(messageResponse);\n } catch (error) {\n // Handle invalid extension host initialization failure\n reject(error);\n }\n } else {\n // The extension host should be initialized if we get here\n // so this should never happen.\n reject(new Error('Extension host not created'));\n }\n } else {\n // All other extension host messages\n messageResponse = extensionHost.handleNotification(message);\n }\n }\n return messageResponse;\n }\n )\n .withTargetOrigin(targetOrigin)\n .withDefaultTimeout(chattyTimeout || 30000)\n .build()\n .connect();\n // Create the extension host (a extension specific wrapper around the\n // chatty host)\n extensionHost = new ExtensionHostApiImpl({\n chattyHost,\n ...configuration,\n });\n // Register the extension host so that global event listeners can send\n // messages to the looker host (for example beforeUnload event).\n registerHostApi(extensionHost);\n } catch (error) {\n window.clearTimeout(initializationTimer);\n initializationTimer = undefined;\n reject(error);\n }\n });\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAOA,IAAAG,MAAA,GAAAH,OAAA;AAAyC,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WA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YACtC2D;UAAU,GACPhB,aAAa,CACjB,CAAC;UAGF,IAAA+B,gCAAe,EAACvB,aAAa,CAAC;QAChC,CAAC,CAAC,OAAOrB,KAAK,EAAE;UACdgB,MAAM,CAACqB,YAAY,CAACtB,mBAAmB,CAAC;UACxCA,mBAAmB,GAAGN,SAAS;UAC/Bd,MAAM,CAACK,KAAK,CAAC;QACf;MACF,CAAC;MAAA,iBAAA6C,EAAA,EAAAC,GAAA;QAAA,OAAAhC,KAAA,CAAA7C,KAAA,OAAAE,SAAA;MAAA;IAAA,IAAC;EAAA;EAAA,gBAxGSuC,oBAAoBA,CAAA;IAAA,OAAAE,IAAA,CAAA3C,KAAA,OAAAE,SAAA;EAAA;AAAA,GAwG7B"}
|
|
1
|
+
{"version":3,"file":"connect_extension_host.js","names":["_chatty","require","_extension_host_api","_global_listener","_types","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","asyncGeneratorStep","n","a","c","u","done","Promise","resolve","then","_asyncToGenerator","_next","_throw","connectExtensionHost","exports","_ref","configuration","undefined","_ref2","reject","initializationTimer","window","setTimeout","Error","initializedCallback","chattyTimeout","extensionHost","targetOrigin","initialized","initializationResponse","errorMessage","parent","location","origin","err","chattyHost","Chatty","createClient","on","ExtensionEvent","EXTENSION_HOST_NOTIFICATION","message","messageResponse","clearTimeout","handleNotification","error","withTargetOrigin","withDefaultTimeout","build","connect","ExtensionHostApiImpl","registerHostApi","_x","_x2"],"sources":["../../src/connect/connect_extension_host.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 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 { Chatty } from '@looker/chatty';\nimport { ExtensionHostApiImpl } from './extension_host_api';\nimport { registerHostApi } from './global_listener';\nimport type {\n ExtensionHostApi,\n ExtensionHostConfiguration,\n ExtensionInitializationResponse,\n ExtensionNotification,\n} from './types';\nimport { ExtensionEvent } from './types';\n\n/**\n * Connect extension to Looker host. React extensions using the extension-sdk-react\n * package and ExtensionProvider do not need to call this as the ExtensionProvider\n * sets up the connection.\n * @param configuration\n */\nexport const connectExtensionHost = async (\n configuration: ExtensionHostConfiguration = {}\n): Promise<ExtensionHostApi> =>\n // eslint-disable-next-line no-async-promise-executor\n new Promise(async (resolve, reject) => {\n // Timer to handle the unlikely event that an initialization message\n // is not received from the host. If this happens it's a bug in the\n // host code.\n let initializationTimer: number | undefined = window.setTimeout(\n () =>\n reject(new Error('Failed to establish communication with Looker host')),\n 30000\n );\n // Legacy callback to indicate that connection is established\n const { initializedCallback, chattyTimeout } = configuration;\n let extensionHost: ExtensionHostApi;\n let targetOrigin;\n // The initialized function replaces the need the legacy callback as it\n // resolves/rejects the promise that now wraps the chatty promise that\n // was originally returned.\n const initialized = (\n initializationResponse?: ExtensionInitializationResponse\n ) => {\n // An initialization response is expected but the handle notification\n // method can return undefined.\n if (initializationResponse) {\n // The initialization can fail, for example, Looker host is not\n // at the right version.\n const { errorMessage } = initializationResponse;\n if (initializedCallback) {\n initializedCallback(errorMessage);\n }\n if (errorMessage) {\n reject(new Error(errorMessage));\n } else {\n resolve(extensionHost);\n }\n } else {\n reject(new Error('Unexpected response from initialization'));\n }\n };\n try {\n // if extension is not sandboxed the following will succeed\n targetOrigin = window.parent.location.origin;\n } catch (err) {\n // failure indicates running in a sandboxed environment\n targetOrigin = '*';\n }\n try {\n const chattyHost = await Chatty.createClient()\n .on(\n ExtensionEvent.EXTENSION_HOST_NOTIFICATION,\n (\n message?: ExtensionNotification\n ): ExtensionInitializationResponse | undefined => {\n // Handle messages from the looker host. The first message should\n // be an initialization message containing information about the host\n // and host extension (looker version, extension id for example).\n let messageResponse: ExtensionInitializationResponse | undefined;\n if (message) {\n if (initializationTimer) {\n // The initialization timer is present so assume this is an initialization\n // message. The initialization timer is now cleared.\n window.clearTimeout(initializationTimer);\n initializationTimer = undefined;\n if (extensionHost) {\n try {\n messageResponse = extensionHost.handleNotification(message);\n initialized(messageResponse);\n } catch (error) {\n // Handle invalid extension host initialization failure\n reject(error);\n }\n } else {\n // The extension host should be initialized if we get here\n // so this should never happen.\n reject(new Error('Extension host not created'));\n }\n } else {\n // All other extension host messages\n messageResponse = extensionHost.handleNotification(message);\n }\n }\n return messageResponse;\n }\n )\n .withTargetOrigin(targetOrigin)\n .withDefaultTimeout(chattyTimeout || 30000)\n .build()\n .connect();\n // Create the extension host (a extension specific wrapper around the\n // chatty host)\n extensionHost = new ExtensionHostApiImpl({\n chattyHost,\n ...configuration,\n });\n // Register the extension host so that global event listeners can send\n // messages to the looker host (for example beforeUnload event).\n registerHostApi(extensionHost);\n } catch (error) {\n window.clearTimeout(initializationTimer);\n initializationTimer = undefined;\n reject(error);\n }\n });\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,OAAA;AACA,IA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C,KAAA,OAAAE,SAAA;QAAA;MAAA;IAAC;EAAA;EAAA,gBAxGS+B,oBAAoBA,CAAA;IAAA,OAAAE,IAAA,CAAAnC,KAAA,OAAAE,SAAA;EAAA;AAAA,GAwG7B","ignoreList":[]}
|
|
@@ -10,11 +10,11 @@ var _visualization_sdk = require("./visualization/visualization_sdk");
|
|
|
10
10
|
var _tile_sdk = require("./tile/tile_sdk");
|
|
11
11
|
var _fetch_proxy = require("./fetch_proxy");
|
|
12
12
|
var _types = require("./types");
|
|
13
|
-
function _interopRequireDefault(
|
|
14
|
-
function asyncGeneratorStep(
|
|
15
|
-
function _asyncToGenerator(
|
|
16
|
-
function _defineProperty(
|
|
17
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i :
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
15
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
19
|
var EXTENSION_SDK_VERSION = exports.EXTENSION_SDK_VERSION = '0.10.5';
|
|
20
20
|
class ExtensionHostApiImpl {
|
|
@@ -74,11 +74,11 @@ class ExtensionHostApiImpl {
|
|
|
74
74
|
} = message;
|
|
75
75
|
if (this.hostChangedRoute && payload) {
|
|
76
76
|
var {
|
|
77
|
-
route
|
|
78
|
-
routeState
|
|
77
|
+
route,
|
|
78
|
+
routeState
|
|
79
79
|
} = payload;
|
|
80
|
-
if (
|
|
81
|
-
this.hostChangedRoute(
|
|
80
|
+
if (route) {
|
|
81
|
+
this.hostChangedRoute(route, routeState);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
return undefined;
|
|
@@ -125,11 +125,11 @@ class ExtensionHostApiImpl {
|
|
|
125
125
|
}
|
|
126
126
|
if (this.setInitialRoute && _payload3) {
|
|
127
127
|
var {
|
|
128
|
-
route:
|
|
129
|
-
routeState:
|
|
128
|
+
route: _route,
|
|
129
|
+
routeState: _routeState
|
|
130
130
|
} = _payload3;
|
|
131
|
-
if (
|
|
132
|
-
this.setInitialRoute(
|
|
131
|
+
if (_route) {
|
|
132
|
+
this.setInitialRoute(_route, _routeState);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
@@ -297,13 +297,13 @@ class ExtensionHostApiImpl {
|
|
|
297
297
|
})();
|
|
298
298
|
}
|
|
299
299
|
userAttributeResetItem(name) {
|
|
300
|
-
var
|
|
300
|
+
var _this0 = this;
|
|
301
301
|
return _asyncToGenerator(function* () {
|
|
302
|
-
var errorMessage =
|
|
302
|
+
var errorMessage = _this0.verifyLookerVersion('>=7.15');
|
|
303
303
|
if (errorMessage) {
|
|
304
304
|
return Promise.reject(new Error(errorMessage));
|
|
305
305
|
}
|
|
306
|
-
return
|
|
306
|
+
return _this0.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
|
|
307
307
|
type: 'reset',
|
|
308
308
|
name
|
|
309
309
|
});
|
|
@@ -321,9 +321,9 @@ class ExtensionHostApiImpl {
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
saveContextData(context) {
|
|
324
|
-
var
|
|
324
|
+
var _this1 = this;
|
|
325
325
|
return _asyncToGenerator(function* () {
|
|
326
|
-
var errorMessage =
|
|
326
|
+
var errorMessage = _this1.verifyLookerVersion('>=7.13');
|
|
327
327
|
if (errorMessage) {
|
|
328
328
|
return Promise.reject(new Error(errorMessage));
|
|
329
329
|
}
|
|
@@ -337,24 +337,24 @@ class ExtensionHostApiImpl {
|
|
|
337
337
|
} else {
|
|
338
338
|
contextData = undefined;
|
|
339
339
|
}
|
|
340
|
-
yield
|
|
340
|
+
yield _this1.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
|
|
341
341
|
type: 'save',
|
|
342
342
|
contextData
|
|
343
343
|
});
|
|
344
|
-
return
|
|
344
|
+
return _this1.getContextData();
|
|
345
345
|
})();
|
|
346
346
|
}
|
|
347
347
|
refreshContextData() {
|
|
348
|
-
var
|
|
348
|
+
var _this10 = this;
|
|
349
349
|
return _asyncToGenerator(function* () {
|
|
350
|
-
var errorMessage =
|
|
350
|
+
var errorMessage = _this10.verifyLookerVersion('>=7.13');
|
|
351
351
|
if (errorMessage) {
|
|
352
352
|
return Promise.reject(new Error(errorMessage));
|
|
353
353
|
}
|
|
354
|
-
|
|
354
|
+
_this10.contextData = yield _this10.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
|
|
355
355
|
type: 'refresh'
|
|
356
356
|
});
|
|
357
|
-
return
|
|
357
|
+
return _this10.getContextData();
|
|
358
358
|
})();
|
|
359
359
|
}
|
|
360
360
|
track(name, trackAction, attributes) {
|
|
@@ -391,13 +391,13 @@ class ExtensionHostApiImpl {
|
|
|
391
391
|
return new _fetch_proxy.FetchProxyImpl(this, baseUrl, init, responseBodyType);
|
|
392
392
|
}
|
|
393
393
|
fetchProxy(resource, init, responseBodyType) {
|
|
394
|
-
var
|
|
394
|
+
var _this11 = this;
|
|
395
395
|
return _asyncToGenerator(function* () {
|
|
396
|
-
var errorMessage =
|
|
396
|
+
var errorMessage = _this11.verifyLookerVersion('>=7.9');
|
|
397
397
|
if (errorMessage) {
|
|
398
398
|
return Promise.reject(new Error(errorMessage));
|
|
399
399
|
}
|
|
400
|
-
return
|
|
400
|
+
return _this11.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
401
401
|
type: 'fetch',
|
|
402
402
|
payload: {
|
|
403
403
|
resource,
|
|
@@ -408,13 +408,13 @@ class ExtensionHostApiImpl {
|
|
|
408
408
|
})();
|
|
409
409
|
}
|
|
410
410
|
serverProxy(resource, init, responseBodyType) {
|
|
411
|
-
var
|
|
411
|
+
var _this12 = this;
|
|
412
412
|
return _asyncToGenerator(function* () {
|
|
413
|
-
var errorMessage =
|
|
413
|
+
var errorMessage = _this12.verifyLookerVersion('>=7.11');
|
|
414
414
|
if (errorMessage) {
|
|
415
415
|
return Promise.reject(new Error(errorMessage));
|
|
416
416
|
}
|
|
417
|
-
return
|
|
417
|
+
return _this12.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
418
418
|
type: 'server-proxy',
|
|
419
419
|
payload: {
|
|
420
420
|
resource,
|
|
@@ -426,18 +426,18 @@ class ExtensionHostApiImpl {
|
|
|
426
426
|
}
|
|
427
427
|
oauth2Authenticate(authEndpoint, authParameters) {
|
|
428
428
|
var _arguments3 = arguments,
|
|
429
|
-
|
|
429
|
+
_this13 = this;
|
|
430
430
|
return _asyncToGenerator(function* () {
|
|
431
431
|
var httpMethod = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : 'POST';
|
|
432
|
-
var errorMessage =
|
|
432
|
+
var errorMessage = _this13.verifyLookerVersion('>=7.9');
|
|
433
433
|
if (errorMessage) {
|
|
434
434
|
return Promise.reject(new Error(errorMessage));
|
|
435
435
|
}
|
|
436
|
-
errorMessage =
|
|
436
|
+
errorMessage = _this13.validateAuthParameters(authParameters);
|
|
437
437
|
if (errorMessage) {
|
|
438
438
|
return Promise.reject(new Error(errorMessage));
|
|
439
439
|
}
|
|
440
|
-
return
|
|
440
|
+
return _this13.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
441
441
|
type: 'oauth2_authenticate',
|
|
442
442
|
payload: {
|
|
443
443
|
authEndpoint,
|
|
@@ -450,13 +450,13 @@ class ExtensionHostApiImpl {
|
|
|
450
450
|
})();
|
|
451
451
|
}
|
|
452
452
|
oauth2ExchangeCodeForToken(authEndpoint, authParameters) {
|
|
453
|
-
var
|
|
453
|
+
var _this14 = this;
|
|
454
454
|
return _asyncToGenerator(function* () {
|
|
455
|
-
var errorMessage =
|
|
455
|
+
var errorMessage = _this14.verifyLookerVersion('>=7.11');
|
|
456
456
|
if (errorMessage) {
|
|
457
457
|
return Promise.reject(new Error(errorMessage));
|
|
458
458
|
}
|
|
459
|
-
return
|
|
459
|
+
return _this14.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
|
|
460
460
|
type: 'oauth2_exchange_code',
|
|
461
461
|
payload: {
|
|
462
462
|
authEndpoint,
|
|
@@ -471,9 +471,9 @@ class ExtensionHostApiImpl {
|
|
|
471
471
|
});
|
|
472
472
|
}
|
|
473
473
|
sendAndReceive(type, payload, options) {
|
|
474
|
-
var
|
|
474
|
+
var _this15 = this;
|
|
475
475
|
return _asyncToGenerator(function* () {
|
|
476
|
-
if (!
|
|
476
|
+
if (!_this15._lookerHostData) {
|
|
477
477
|
return Promise.reject(new Error('Looker host connection not established'));
|
|
478
478
|
}
|
|
479
479
|
var messagePayload = {
|
|
@@ -481,7 +481,7 @@ class ExtensionHostApiImpl {
|
|
|
481
481
|
payload
|
|
482
482
|
};
|
|
483
483
|
var chattyPayload = options ? [messagePayload, options] : [messagePayload];
|
|
484
|
-
return
|
|
484
|
+
return _this15.chattyHost.sendAndReceive(_types.ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
|
|
485
485
|
})();
|
|
486
486
|
}
|
|
487
487
|
send(type, payload) {
|