@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.
Files changed (100) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +1 -9
  3. package/lib/connect/connect_extension_host.js +5 -24
  4. package/lib/connect/connect_extension_host.js.map +1 -1
  5. package/lib/connect/extension_host_api.d.ts +3 -14
  6. package/lib/connect/extension_host_api.js +26 -230
  7. package/lib/connect/extension_host_api.js.map +1 -1
  8. package/lib/connect/fetch_proxy.js +0 -13
  9. package/lib/connect/fetch_proxy.js.map +1 -1
  10. package/lib/connect/global_listener.js +3 -17
  11. package/lib/connect/global_listener.js.map +1 -1
  12. package/lib/connect/index.d.ts +0 -2
  13. package/lib/connect/index.js +1 -34
  14. package/lib/connect/index.js.map +1 -1
  15. package/lib/connect/types.d.ts +7 -50
  16. package/lib/connect/types.js +1 -32
  17. package/lib/connect/types.js.map +1 -1
  18. package/lib/esm/connect/connect_extension_host.js +19 -25
  19. package/lib/esm/connect/connect_extension_host.js.map +1 -1
  20. package/lib/esm/connect/extension_host_api.js +71 -256
  21. package/lib/esm/connect/extension_host_api.js.map +1 -1
  22. package/lib/esm/connect/fetch_proxy.js +11 -12
  23. package/lib/esm/connect/fetch_proxy.js.map +1 -1
  24. package/lib/esm/connect/global_listener.js +11 -12
  25. package/lib/esm/connect/global_listener.js.map +1 -1
  26. package/lib/esm/connect/index.js +39 -5
  27. package/lib/esm/connect/index.js.map +1 -1
  28. package/lib/esm/connect/types.js +21 -40
  29. package/lib/esm/connect/types.js.map +1 -1
  30. package/lib/esm/index.js +82 -10
  31. package/lib/esm/index.js.map +1 -1
  32. package/lib/esm/sdk/extension_sdk.js +13 -9
  33. package/lib/esm/sdk/extension_sdk.js.map +1 -1
  34. package/lib/esm/sdk/extension_sdk_31.js +12 -6
  35. package/lib/esm/sdk/extension_sdk_31.js.map +1 -1
  36. package/lib/esm/sdk/extension_sdk_40.js +12 -6
  37. package/lib/esm/sdk/extension_sdk_40.js.map +1 -1
  38. package/lib/esm/sdk/index.js +16 -1
  39. package/lib/esm/sdk/index.js.map +1 -1
  40. package/lib/esm/sdk/sdk_connection.js +8 -9
  41. package/lib/esm/sdk/sdk_connection.js.map +1 -1
  42. package/lib/index.d.ts +0 -3
  43. package/lib/index.js +1 -54
  44. package/lib/index.js.map +1 -1
  45. package/lib/sdk/extension_sdk.js +0 -8
  46. package/lib/sdk/extension_sdk.js.map +1 -1
  47. package/lib/sdk/extension_sdk_31.js +0 -6
  48. package/lib/sdk/extension_sdk_31.js.map +1 -1
  49. package/lib/sdk/extension_sdk_40.js +0 -6
  50. package/lib/sdk/extension_sdk_40.js.map +1 -1
  51. package/lib/sdk/index.js +0 -2
  52. package/lib/sdk/index.js.map +1 -1
  53. package/lib/sdk/sdk_connection.js +0 -10
  54. package/lib/sdk/sdk_connection.js.map +1 -1
  55. package/package.json +4 -4
  56. package/lib/connect/tile/index.d.ts +0 -1
  57. package/lib/connect/tile/index.js +0 -19
  58. package/lib/connect/tile/index.js.map +0 -1
  59. package/lib/connect/tile/tile_sdk.d.ts +0 -24
  60. package/lib/connect/tile/tile_sdk.js +0 -153
  61. package/lib/connect/tile/tile_sdk.js.map +0 -1
  62. package/lib/connect/tile/types.d.ts +0 -86
  63. package/lib/connect/tile/types.js +0 -15
  64. package/lib/connect/tile/types.js.map +0 -1
  65. package/lib/connect/visualization/index.d.ts +0 -2
  66. package/lib/connect/visualization/index.js +0 -32
  67. package/lib/connect/visualization/index.js.map +0 -1
  68. package/lib/connect/visualization/types.d.ts +0 -62
  69. package/lib/connect/visualization/types.js +0 -2
  70. package/lib/connect/visualization/types.js.map +0 -1
  71. package/lib/connect/visualization/visualization_sdk.d.ts +0 -36
  72. package/lib/connect/visualization/visualization_sdk.js +0 -166
  73. package/lib/connect/visualization/visualization_sdk.js.map +0 -1
  74. package/lib/esm/connect/tile/index.js +0 -2
  75. package/lib/esm/connect/tile/index.js.map +0 -1
  76. package/lib/esm/connect/tile/tile_sdk.js +0 -140
  77. package/lib/esm/connect/tile/tile_sdk.js.map +0 -1
  78. package/lib/esm/connect/tile/types.js +0 -8
  79. package/lib/esm/connect/tile/types.js.map +0 -1
  80. package/lib/esm/connect/visualization/index.js +0 -3
  81. package/lib/esm/connect/visualization/index.js.map +0 -1
  82. package/lib/esm/connect/visualization/types.js +0 -2
  83. package/lib/esm/connect/visualization/types.js.map +0 -1
  84. package/lib/esm/connect/visualization/visualization_sdk.js +0 -156
  85. package/lib/esm/connect/visualization/visualization_sdk.js.map +0 -1
  86. package/lib/esm/util/errors.js +0 -2
  87. package/lib/esm/util/errors.js.map +0 -1
  88. package/lib/esm/util/index.js +0 -3
  89. package/lib/esm/util/index.js.map +0 -1
  90. package/lib/esm/util/logger.js +0 -15
  91. package/lib/esm/util/logger.js.map +0 -1
  92. package/lib/util/errors.d.ts +0 -1
  93. package/lib/util/errors.js +0 -9
  94. package/lib/util/errors.js.map +0 -1
  95. package/lib/util/index.d.ts +0 -2
  96. package/lib/util/index.js +0 -32
  97. package/lib/util/index.js.map +0 -1
  98. package/lib/util/logger.d.ts +0 -2
  99. package/lib/util/logger.js +0 -27
  100. package/lib/util/logger.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ 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
+ ## [23.0.0](https://github.com/looker-open-source/sdk-codegen/compare/extension-sdk-v22.20.1...extension-sdk-v23.0.0) (2023-02-22)
9
+
10
+
11
+ ### Features
12
+
13
+ * keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @looker/sdk bumped from ^22.20.1 to ^23.0.0
21
+ * @looker/sdk-rtl bumped from ^21.5.0 to ^21.6.0
22
+
8
23
  ### [22.20.1](https://www.github.com/looker-open-source/sdk-codegen/compare/extension-sdk-v22.20.0...extension-sdk-v22.20.1) (2022-12-09)
9
24
 
10
25
 
@@ -393,4 +408,4 @@ in extension builds.
393
408
 
394
409
  ## [21.0.5]
395
410
 
396
- Moved to the /looker-open-source/sdk-codegen github repository.
411
+ Moved to the /looker-open-source/sdk-codegen github repository.
package/README.md CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  connectExtensionHost,
34
34
  LookerExtensionSDK40,
35
35
  } from '@looker/extension-sdk'
36
+
36
37
  ;(async () => {
37
38
  // This `extensionSDK` can perform extension-specific actions
38
39
  const extensionSdk = await connectExtensionHost()
@@ -412,15 +413,6 @@ An extension can be viewed in full screen mode (no Looker chrome) at /spartan/{e
412
413
 
413
414
  **Note:** this call only works when the extension is running in /spartan mode.
414
415
 
415
- ## Mount Points
416
-
417
- Extensions can be mounted in the following locations:
418
-
419
- - Standalone.
420
- - Dashboard tile.
421
- - Explore visualization mounted as a dashboard tile.
422
- - Dashboard popup launched from a tile settings menu.
423
-
424
416
  ```ts
425
417
  extensionSDK.spartanLogout()
426
418
  ```
@@ -4,25 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.connectExtensionHost = void 0;
7
-
8
7
  var _chatty = require("@looker/chatty");
9
-
10
8
  var _extension_host_api = require("./extension_host_api");
11
-
12
9
  var _global_listener = require("./global_listener");
13
-
14
10
  var _types = require("./types");
15
-
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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); }
22
16
  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
17
  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
18
  var connectExtensionHost = function () {
27
19
  var _ref = _asyncToGenerator(function* () {
28
20
  var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -35,17 +27,14 @@ var connectExtensionHost = function () {
35
27
  } = configuration;
36
28
  var extensionHost;
37
29
  var targetOrigin;
38
-
39
30
  var initialized = initializationResponse => {
40
31
  if (initializationResponse) {
41
32
  var {
42
33
  errorMessage
43
34
  } = initializationResponse;
44
-
45
35
  if (initializedCallback) {
46
36
  initializedCallback(errorMessage);
47
37
  }
48
-
49
38
  if (errorMessage) {
50
39
  reject(new Error(errorMessage));
51
40
  } else {
@@ -55,22 +44,18 @@ var connectExtensionHost = function () {
55
44
  reject(new Error('Unexpected response from initialization'));
56
45
  }
57
46
  };
58
-
59
47
  try {
60
48
  targetOrigin = window.parent.location.origin;
61
49
  } catch (err) {
62
50
  targetOrigin = '*';
63
51
  }
64
-
65
52
  try {
66
53
  var chattyHost = yield _chatty.Chatty.createClient().on(_types.ExtensionEvent.EXTENSION_HOST_NOTIFICATION, message => {
67
54
  var messageResponse;
68
-
69
55
  if (message) {
70
56
  if (initializationTimer) {
71
57
  window.clearTimeout(initializationTimer);
72
58
  initializationTimer = undefined;
73
-
74
59
  if (extensionHost) {
75
60
  try {
76
61
  messageResponse = extensionHost.handleNotification(message);
@@ -85,7 +70,6 @@ var connectExtensionHost = function () {
85
70
  messageResponse = extensionHost.handleNotification(message);
86
71
  }
87
72
  }
88
-
89
73
  return messageResponse;
90
74
  }).withTargetOrigin(targetOrigin).withDefaultTimeout(chattyTimeout || 30000).build().connect();
91
75
  extensionHost = new _extension_host_api.ExtensionHostApiImpl(_objectSpread({
@@ -98,17 +82,14 @@ var connectExtensionHost = function () {
98
82
  reject(error);
99
83
  }
100
84
  });
101
-
102
85
  return function (_x, _x2) {
103
86
  return _ref2.apply(this, arguments);
104
87
  };
105
88
  }());
106
89
  });
107
-
108
90
  return function connectExtensionHost() {
109
91
  return _ref.apply(this, arguments);
110
92
  };
111
93
  }();
112
-
113
94
  exports.connectExtensionHost = connectExtensionHost;
114
95
  //# sourceMappingURL=connect_extension_host.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/connect/connect_extension_host.ts"],"names":["connectExtensionHost","configuration","Promise","resolve","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","undefined","handleNotification","error","withTargetOrigin","withDefaultTimeout","build","connect","ExtensionHostApiImpl"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AAOA;;;;;;;;;;;;AAQO,IAAMA,oBAAoB;AAAA,+BAAG;AAAA,QAClCC,aADkC,uEACU,EADV;AAAA,WAIlC,IAAIC,OAAJ;AAAA,oCAAY,WAAOC,OAAP,EAAgBC,MAAhB,EAA2B;AAIrC,YAAIC,mBAAuC,GAAGC,MAAM,CAACC,UAAP,CAC5C,MACEH,MAAM,CAAC,IAAII,KAAJ,CAAU,oDAAV,CAAD,CAFoC,EAG5C,KAH4C,CAA9C;AAMA,YAAM;AAAEC,UAAAA,mBAAF;AAAuBC,UAAAA;AAAvB,YAAyCT,aAA/C;AACA,YAAIU,aAAJ;AACA,YAAIC,YAAJ;;AAIA,YAAMC,WAAW,GACfC,sBADkB,IAEf;AAGH,cAAIA,sBAAJ,EAA4B;AAG1B,gBAAM;AAAEC,cAAAA;AAAF,gBAAmBD,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ACD,WAnCoB,EAqCtBK,gBArCsB,CAqCLpB,YArCK,EAsCtBqB,kBAtCsB,CAsCHvB,aAAa,IAAI,KAtCd,EAuCtBwB,KAvCsB,GAwCtBC,OAxCsB,EAAzB;AA2CAxB,UAAAA,aAAa,GAAG,IAAIyB,wCAAJ;AACdhB,YAAAA;AADc,aAEXnB,aAFW,EAAhB;AAMA,gDAAgBU,aAAhB;AACD,SAnDD,CAmDE,OAAOoB,KAAP,EAAc;AACdzB,UAAAA,MAAM,CAACsB,YAAP,CAAoBvB,mBAApB;AACAA,UAAAA,mBAAmB,GAAGwB,SAAtB;AACAzB,UAAAA,MAAM,CAAC2B,KAAD,CAAN;AACD;AACF,OApGD;;AAAA;AAAA;AAAA;AAAA,QAJkC;AAAA,GAAH;;AAAA,kBAApB/B,oBAAoB;AAAA;AAAA;AAAA,GAA1B","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"],"file":"connect_extension_host.js"}
1
+ {"version":3,"file":"connect_extension_host.js","names":["connectExtensionHost","configuration","Promise","resolve","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","undefined","handleNotification","error","withTargetOrigin","withDefaultTimeout","build","connect","ExtensionHostApiImpl","registerHostApi"],"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;AACA;AACA;AAOA;AAAwC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQjC,IAAMA,oBAAoB;EAAA,6BAAG;IAAA,IAClCC,aAAyC,uEAAG,CAAC,CAAC;IAAA,OAG9C,IAAIC,OAAO;M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ACc,eAAe,CAAC;kBAC9B,CAAC,CAAC,OAAOI,KAAK,EAAE;oBAEd3B,MAAM,CAAC2B,KAAK,CAAC;kBACf;gBACF,CAAC,MAAM;kBAGL3B,MAAM,CAAC,IAAII,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBACjD;cACF,CAAC,MAAM;gBAELmB,eAAe,GAAGhB,aAAa,CAACmB,kBAAkB,CAACJ,OAAO,CAAC;cAC7D;YACF;YACA,OAAOC,eAAe;UACxB,CAAC,CACF,CACAK,gBAAgB,CAACpB,YAAY,CAAC,CAC9BqB,kBAAkB,CAACvB,aAAa,IAAI,KAAK,CAAC,CAC1CwB,KAAK,EAAE,CACPC,OAAO,EAAE;UAGZxB,aAAa,GAAG,IAAIyB,wCAAoB;YACtChB;UAAU,GACPnB,aAAa,EAChB;UAGF,IAAAoC,gCAAe,EAAC1B,aAAa,CAAC;QAChC,CAAC,CAAC,OAAOoB,KAAK,EAAE;UACdzB,MAAM,CAACsB,YAAY,CAACvB,mBAAmB,CAAC;UACxCA,mBAAmB,GAAGwB,SAAS;UAC/BzB,MAAM,CAAC2B,KAAK,CAAC;QACf;MACF,CAAC;MAAA;QAAA;MAAA;IAAA,IAAC;EAAA;EAAA,gBAxGS/B,oBAAoB;IAAA;EAAA;AAAA,GAwG7B;AAAA"}
@@ -1,6 +1,3 @@
1
- import type { Options } from '@looker/chatty';
2
- import type { VisualizationSDK } from './visualization';
3
- import type { TileSDK } from './tile';
4
1
  import { FetchProxyImpl } from './fetch_proxy';
5
2
  import type { ExtensionInitializationResponse, ExtensionHostApi, ExtensionHostApiConfiguration, ExtensionNotification, FetchCustomParameters, FetchResponseBodyType, LookerHostData, ApiVersion } from './types';
6
3
  export declare const EXTENSION_SDK_VERSION = "0.10.5";
@@ -10,17 +7,10 @@ export declare class ExtensionHostApiImpl implements ExtensionHostApi {
10
7
  private chattyHost;
11
8
  private setInitialRoute?;
12
9
  private hostChangedRoute?;
13
- private visualizationDataReceivedCallback?;
14
- private tileHostDataChangedCallback?;
15
- private _visualizationSDK?;
16
- private _tileSDK?;
17
10
  private contextData?;
18
11
  constructor(configuration: ExtensionHostApiConfiguration);
19
- get isDashboardMountSupported(): boolean;
20
- get visualizationSDK(): VisualizationSDK;
21
- get tileSDK(): TileSDK;
22
12
  get lookerHostData(): Readonly<LookerHostData> | undefined;
23
- handleNotification(message: ExtensionNotification): ExtensionInitializationResponse | undefined;
13
+ handleNotification(message?: ExtensionNotification): ExtensionInitializationResponse | undefined;
24
14
  createSecretKeyTag(keyName: string): string;
25
15
  verifyHostConnection(): Promise<any>;
26
16
  invokeCoreSdk(httpMethod: string, path: string, params?: any, body?: any, authenticator?: any, options?: any, apiVersion?: ApiVersion): Promise<any>;
@@ -49,9 +39,8 @@ export declare class ExtensionHostApiImpl implements ExtensionHostApi {
49
39
  serverProxy(resource: string, init?: FetchCustomParameters, responseBodyType?: FetchResponseBodyType): Promise<any>;
50
40
  oauth2Authenticate(authEndpoint: string, authParameters: Record<string, string>, httpMethod?: string): Promise<any>;
51
41
  oauth2ExchangeCodeForToken(authEndpoint: string, authParameters: Record<string, string>): Promise<any>;
52
- rendered(failureMessage?: string): void;
53
- sendAndReceive(type: string, payload?: any, options?: Options): Promise<any>;
54
- send(type: string, payload?: any): void;
42
+ private sendAndReceive;
43
+ private send;
55
44
  private verifyLookerVersion;
56
45
  private validateAuthParameters;
57
46
  }