@looker/extension-sdk 23.14.1 → 23.18.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 (69) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +0 -1
  3. package/lib/connect/connect_extension_host.js.map +1 -1
  4. package/lib/connect/extension_host_api.js.map +1 -1
  5. package/lib/connect/fetch_proxy.js.map +1 -1
  6. package/lib/connect/global_listener.js.map +1 -1
  7. package/lib/connect/tile/tile_sdk.js.map +1 -1
  8. package/lib/connect/types.d.ts +0 -1
  9. package/lib/connect/types.js +0 -1
  10. package/lib/connect/types.js.map +1 -1
  11. package/lib/connect/visualization/types.d.ts +28 -1
  12. package/lib/connect/visualization/types.js.map +1 -1
  13. package/lib/connect/visualization/visualization_sdk.d.ts +3 -2
  14. package/lib/connect/visualization/visualization_sdk.js +9 -3
  15. package/lib/connect/visualization/visualization_sdk.js.map +1 -1
  16. package/lib/esm/connect/connect_extension_host.js +8 -15
  17. package/lib/esm/connect/connect_extension_host.js.map +1 -1
  18. package/lib/esm/connect/extension_host_api.js +49 -58
  19. package/lib/esm/connect/extension_host_api.js.map +1 -1
  20. package/lib/esm/connect/fetch_proxy.js +3 -11
  21. package/lib/esm/connect/fetch_proxy.js.map +1 -1
  22. package/lib/esm/connect/global_listener.js +5 -13
  23. package/lib/esm/connect/global_listener.js.map +1 -1
  24. package/lib/esm/connect/index.js +5 -63
  25. package/lib/esm/connect/index.js.map +1 -1
  26. package/lib/esm/connect/tile/index.js +1 -16
  27. package/lib/esm/connect/tile/index.js.map +1 -1
  28. package/lib/esm/connect/tile/tile_sdk.js +23 -30
  29. package/lib/esm/connect/tile/tile_sdk.js.map +1 -1
  30. package/lib/esm/connect/tile/types.js +1 -8
  31. package/lib/esm/connect/tile/types.js.map +1 -1
  32. package/lib/esm/connect/types.js +6 -19
  33. package/lib/esm/connect/types.js.map +1 -1
  34. package/lib/esm/connect/visualization/index.js +2 -27
  35. package/lib/esm/connect/visualization/index.js.map +1 -1
  36. package/lib/esm/connect/visualization/types.js.map +1 -1
  37. package/lib/esm/connect/visualization/visualization_sdk.js +14 -15
  38. package/lib/esm/connect/visualization/visualization_sdk.js.map +1 -1
  39. package/lib/esm/index.js +9 -115
  40. package/lib/esm/index.js.map +1 -1
  41. package/lib/esm/sdk/extension_sdk.js +6 -16
  42. package/lib/esm/sdk/extension_sdk.js.map +1 -1
  43. package/lib/esm/sdk/extension_sdk_40.js +5 -12
  44. package/lib/esm/sdk/extension_sdk_40.js.map +1 -1
  45. package/lib/esm/sdk/index.js +1 -16
  46. package/lib/esm/sdk/index.js.map +1 -1
  47. package/lib/esm/sdk/sdk_connection.js +1 -8
  48. package/lib/esm/sdk/sdk_connection.js.map +1 -1
  49. package/lib/esm/util/errors.js +1 -8
  50. package/lib/esm/util/errors.js.map +1 -1
  51. package/lib/esm/util/index.js +2 -27
  52. package/lib/esm/util/index.js.map +1 -1
  53. package/lib/esm/util/logger.js +2 -10
  54. package/lib/esm/util/logger.js.map +1 -1
  55. package/lib/index.d.ts +0 -1
  56. package/lib/index.js +1 -12
  57. package/lib/index.js.map +1 -1
  58. package/lib/sdk/extension_sdk.d.ts +2 -3
  59. package/lib/sdk/extension_sdk.js +1 -4
  60. package/lib/sdk/extension_sdk.js.map +1 -1
  61. package/lib/sdk/extension_sdk_40.js.map +1 -1
  62. package/lib/sdk/sdk_connection.js.map +1 -1
  63. package/lib/util/errors.js.map +1 -1
  64. package/package.json +3 -3
  65. package/lib/esm/sdk/extension_sdk_31.js +0 -16
  66. package/lib/esm/sdk/extension_sdk_31.js.map +0 -1
  67. package/lib/sdk/extension_sdk_31.d.ts +0 -5
  68. package/lib/sdk/extension_sdk_31.js +0 -16
  69. package/lib/sdk/extension_sdk_31.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/connect/visualization/types.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Row } from '../tile'\n\n/**\n * Callback that is invoked when visualization data is received\n * <code>Looker >=22.8</code>\n */\nexport type VisualizationDataReceivedCallback = (\n visualizationData: RawVisualizationData\n) => void\n\n/**\n * Raw visualization data. Basic typing for configuration data\n * and query data.\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisualizationData {\n visConfig: RawVisConfig\n queryResponse: RawVisQueryResponse\n}\n\n/**\n * Visualization configuration. Configuration data set in the\n * explore.\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisConfig {\n [key: string]: RawVisConfigValue\n}\n\nexport type RawVisConfigValue = any\n\n/**\n * Query response data\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisQueryResponse {\n [key: string]: any\n data: RawVisData\n fields: {\n [key: string]: any[]\n }\n pivots: RawPivotConfig[]\n}\n\nexport type RawVisData = Row[]\n\nexport interface RawPivotConfig {\n key: string\n is_total: boolean\n data: { [key: string]: string }\n metadata: { [key: string]: { [key: string]: string } }\n}\n\nexport interface Measure extends RawVisConfig {\n [key: string]: any\n}\n\nexport interface Dimension extends RawVisConfig {\n [key: string]: any\n}\n\nexport interface TableCalculation {\n [key: string]: any\n}\n\nexport interface PivotConfig extends RawPivotConfig {\n [key: string]: any\n}\n\nexport interface VisualizationConfig {\n queryFieldMeasures: Measure[]\n queryFieldDimensions: Dimension[]\n queryFieldTableCalculations: TableCalculation[]\n queryFieldPivots: PivotConfig[]\n visConfig: RawVisConfig\n}\n\nexport interface QueryResponse {\n data: Row[]\n fieldMeasures: Measure[]\n fieldDimensions: Dimension[]\n fieldTableCalculations: TableCalculation[]\n fieldPivots: PivotConfig[]\n fieldMeasureLike: Measure[]\n fieldDimensionLike: Dimension[]\n}\n\n/**\n * Extension visualization SDK\n */\nexport interface VisualizationSDK {\n visualizationData?: RawVisualizationData\n visConfig: VisualizationConfig\n queryResponse: QueryResponse\n updateVisData: (rawVisData: RawVisualizationData) => void\n configureVisualization: (options: RawVisConfig) => void\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/connect/visualization/types.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Row } from '../tile'\n\n/**\n * Callback that is invoked when visualization data is received\n * <code>Looker >=22.8</code>\n */\nexport type VisualizationDataReceivedCallback = (\n visualizationData: RawVisualizationData\n) => void\n\n/**\n * Raw visualization data. Basic typing for configuration data\n * and query data.\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisualizationData {\n visConfig: RawVisConfig\n queryResponse: RawVisQueryResponse\n}\n\n/**\n * Visualization configuration. Configuration data set in the\n * explore.\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisConfig {\n [key: string]: RawVisConfigValue\n}\n\nexport type RawVisConfigValue = any\n\n/**\n * Query response data\n * <code>Looker >=22.8</code>\n */\nexport interface RawVisQueryResponse {\n [key: string]: any\n data: RawVisData\n fields: {\n [key: string]: any[]\n }\n pivots: RawPivotConfig[]\n}\n\nexport type RawVisData = Row[]\n\nexport interface RawPivotConfig {\n key: string\n is_total: boolean\n data: { [key: string]: string }\n metadata: { [key: string]: { [key: string]: string } }\n}\n\nexport interface Measure extends RawVisConfig {\n [key: string]: any\n}\n\nexport interface Dimension extends RawVisConfig {\n [key: string]: any\n}\n\nexport interface TableCalculation {\n [key: string]: any\n}\n\nexport interface PivotConfig extends RawPivotConfig {\n [key: string]: any\n}\n\nexport interface VisualizationConfig {\n queryFieldMeasures: Measure[]\n queryFieldDimensions: Dimension[]\n queryFieldTableCalculations: TableCalculation[]\n queryFieldPivots: PivotConfig[]\n visConfig: RawVisConfig\n}\n\nexport interface QueryResponse {\n data: Row[]\n fieldMeasures: Measure[]\n fieldDimensions: Dimension[]\n fieldTableCalculations: TableCalculation[]\n fieldPivots: PivotConfig[]\n fieldMeasureLike: Measure[]\n fieldDimensionLike: Dimension[]\n}\n\n/**\n * Extension visualization SDK\n */\nexport interface VisualizationSDK {\n visualizationData?: RawVisualizationData\n visConfig: VisualizationConfig\n queryResponse: QueryResponse\n updateVisData: (rawVisData: RawVisualizationData) => void\n configureVisualization: (options: VisOptions) => void\n setVisConfig: (config: RawVisConfig) => void\n}\n\nexport interface VisOptionValue {\n [label: string]: string\n}\n\nexport interface VisOption {\n type: string\n values?: VisOptionValue[]\n display?: string\n default?: any\n label?: string\n section?: string\n placeholder?: string\n display_size?: 'half' | 'third' | 'normal'\n order?: number\n hidden?: (setOptions: RawVisConfig) => boolean\n disabledReason?: (\n setOptions: RawVisConfig,\n queryResponse: QueryResponse\n ) => string | null\n min?: number\n max?: number\n required?: boolean\n words?: VisOptionValue[]\n supports?: string[]\n color_application?: string\n sublabel?: string\n}\n\nexport interface VisOptions {\n [optionName: string]: VisOption\n}\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import type { ExtensionHostApiImpl } from '../extension_host_api';
2
2
  import type { Row } from '../tile';
3
- import type { VisualizationSDK, RawVisualizationData, RawVisConfig, VisualizationConfig, QueryResponse, Measure, Dimension, TableCalculation, PivotConfig, RawVisQueryResponse } from './types';
3
+ import type { VisualizationSDK, RawVisualizationData, RawVisConfig, VisualizationConfig, QueryResponse, Measure, Dimension, TableCalculation, PivotConfig, RawVisQueryResponse, VisOptions } from './types';
4
4
  declare class QueryResponseImpl implements QueryResponse {
5
5
  _queryResponse?: RawVisQueryResponse;
6
6
  constructor(queryResponse?: RawVisQueryResponse);
@@ -30,7 +30,8 @@ export declare class VisualizationSDKImpl implements VisualizationSDK {
30
30
  _queryResponse?: QueryResponseImpl;
31
31
  constructor(hostApi: ExtensionHostApiImpl);
32
32
  updateVisData(visualizationData: RawVisualizationData): void;
33
- configureVisualization(options: RawVisConfig): void;
33
+ configureVisualization(options: VisOptions): void;
34
+ setVisConfig(config: RawVisConfig): void;
34
35
  get visConfig(): VisualizationConfig;
35
36
  get queryResponse(): QueryResponse;
36
37
  }
@@ -87,9 +87,6 @@ class VisualizationSDKImpl {
87
87
  this.visualizationData = visualizationData;
88
88
  if (this.visConfig && this._visConfig) {
89
89
  this._visConfig.update(this.visualizationData.visConfig);
90
- this.hostApi.send(_types.ExtensionRequestType.VIS_CONFIG_UPDATE, {
91
- updatedConfig: this.visualizationData.visConfig
92
- });
93
90
  }
94
91
  if (this.queryResponse && this._queryResponse) {
95
92
  this._queryResponse.update(this.visualizationData.queryResponse);
@@ -105,6 +102,15 @@ class VisualizationSDKImpl {
105
102
  throw _errors.NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR;
106
103
  }
107
104
  }
105
+ setVisConfig(config) {
106
+ if (this.hostApi.isDashboardMountSupported) {
107
+ this.hostApi.send(_types.ExtensionRequestType.VIS_CONFIG_UPDATE, {
108
+ updatedConfig: config
109
+ });
110
+ } else {
111
+ throw _errors.NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR;
112
+ }
113
+ }
108
114
  get visConfig() {
109
115
  if (!this._visConfig) {
110
116
  var _this$visualizationDa;
@@ -1 +1 @@
1
- {"version":3,"file":"visualization_sdk.js","names":["_errors","require","_types","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","QueryResponseImpl","constructor","queryResponse","_queryResponse","update","fieldMeasures","_this$_queryResponse","_this$_queryResponse$","fields","measures","fieldDimensions","_this$_queryResponse2","_this$_queryResponse3","dimensions","fieldTableCalculations","_this$_queryResponse4","_this$_queryResponse5","table_calculations","fieldPivots","_this$_queryResponse6","_this$_queryResponse7","pivots","fieldMeasureLike","_this$_queryResponse8","_this$_queryResponse9","measure_like","fieldDimensionLike","_this$_queryResponse10","_this$_queryResponse11","dimension_like","data","_this$_queryResponse12","VisualizationConfigImpl","visConfig","_visConfig","queryFieldMeasures","_this$_visConfig","_this$_visConfig$quer","query_fields","queryFieldDimensions","_this$_visConfig2","_this$_visConfig2$que","queryFieldTableCalculations","_this$_visConfig3","_this$_visConfig3$que","queryFieldPivots","_this$_visConfig4","_this$_visConfig4$que","VisualizationSDKImpl","hostApi","updateVisData","visualizationData","isDashboardMountSupported","send","ExtensionRequestType","VIS_CONFIG_UPDATE","updatedConfig","configureVisualization","options","VIS_DEFAULT_CONFIG","NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR","_this$visualizationDa","_this$visualizationDa2","exports"],"sources":["../../../src/connect/visualization/visualization_sdk.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR } from '../../util/errors'\nimport type { ExtensionHostApiImpl } from '../extension_host_api'\nimport { ExtensionRequestType } from '../types'\nimport type { Row } from '../tile'\nimport type {\n VisualizationSDK,\n RawVisualizationData,\n RawVisConfig,\n VisualizationConfig,\n QueryResponse,\n Measure,\n Dimension,\n TableCalculation,\n PivotConfig,\n RawVisQueryResponse,\n} from './types'\n\nclass QueryResponseImpl implements QueryResponse {\n _queryResponse?: RawVisQueryResponse\n\n constructor(queryResponse?: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n update(queryResponse: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n get fieldMeasures(): Measure[] {\n return this._queryResponse?.fields?.measures || []\n }\n\n get fieldDimensions(): Dimension[] {\n return this._queryResponse?.fields?.dimensions || []\n }\n\n get fieldTableCalculations(): TableCalculation[] {\n return this._queryResponse?.fields?.table_calculations || []\n }\n\n get fieldPivots(): PivotConfig[] {\n return this._queryResponse?.fields?.pivots || []\n }\n\n get fieldMeasureLike(): Measure[] {\n return this._queryResponse?.fields?.measure_like || []\n }\n\n get fieldDimensionLike(): Dimension[] {\n return this._queryResponse?.fields?.dimension_like || []\n }\n\n get data(): Row[] {\n return this._queryResponse?.data || []\n }\n}\n\nclass VisualizationConfigImpl implements VisualizationConfig {\n _visConfig?: RawVisConfig\n\n constructor(visConfig?: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n update(visConfig: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n get visConfig(): RawVisConfig {\n return this._visConfig || {}\n }\n\n get queryFieldMeasures(): Measure[] {\n return this._visConfig?.query_fields?.measures || []\n }\n\n get queryFieldDimensions(): Dimension[] {\n return this._visConfig?.query_fields?.dimensions || []\n }\n\n get queryFieldTableCalculations(): TableCalculation[] {\n return this._visConfig?.query_fields?.table_calculations || []\n }\n\n get queryFieldPivots(): PivotConfig[] {\n return this._visConfig?.query_fields?.pivots || []\n }\n}\n\nexport class VisualizationSDKImpl implements VisualizationSDK {\n hostApi: ExtensionHostApiImpl\n visualizationData?: RawVisualizationData\n _visConfig?: VisualizationConfigImpl\n _queryResponse?: QueryResponseImpl\n\n constructor(hostApi: ExtensionHostApiImpl) {\n this.hostApi = hostApi\n }\n\n updateVisData(visualizationData: RawVisualizationData) {\n // Ignore update messages if dashboard mounts not supported.\n // Should never happen.\n if (this.hostApi.isDashboardMountSupported) {\n this.visualizationData = visualizationData\n if (this.visConfig && this._visConfig) {\n this._visConfig.update(this.visualizationData.visConfig)\n this.hostApi.send(ExtensionRequestType.VIS_CONFIG_UPDATE, {\n updatedConfig: this.visualizationData.visConfig,\n })\n }\n if (this.queryResponse && this._queryResponse) {\n this._queryResponse.update(this.visualizationData.queryResponse)\n }\n }\n }\n\n configureVisualization(options: RawVisConfig): void {\n if (this.hostApi.isDashboardMountSupported) {\n this.hostApi.send(ExtensionRequestType.VIS_DEFAULT_CONFIG, { options })\n } else {\n throw NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR\n }\n }\n\n get visConfig(): VisualizationConfig {\n if (!this._visConfig) {\n this._visConfig = new VisualizationConfigImpl(\n this.visualizationData?.visConfig\n )\n }\n return this._visConfig\n }\n\n get queryResponse(): QueryResponse {\n if (!this._queryResponse) {\n this._queryResponse = new QueryResponseImpl(\n this.visualizationData?.queryResponse\n )\n }\n return this._queryResponse\n }\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAA+C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,G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D,IAAI,CAACgB,OAAO,CAACI,IAAI,CAACC,2BAAoB,CAACC,iBAAiB,EAAE;UACxDC,aAAa,EAAE,IAAI,CAACL,iBAAiB,CAAClB;QACxC,CAAC,CAAC;MACJ;MACA,IAAI,IAAI,CAAC/B,aAAa,IAAI,IAAI,CAACC,cAAc,EAAE;QAC7C,IAAI,CAACA,cAAc,CAACC,MAAM,CAAC,IAAI,CAAC+C,iBAAiB,CAACjD,aAAa,CAAC;MAClE;IACF;EACF;EAEAuD,sBAAsBA,CAACC,OAAqB,EAAQ;IAClD,IAAI,IAAI,CAACT,OAAO,CAACG,yBAAyB,EAAE;MAC1C,IAAI,CAACH,OAAO,CAACI,IAAI,CAACC,2BAAoB,CAACK,kBAAkB,EAAE;QAAED;MAAQ,CAAC,CAAC;IACzE,CAAC,MAAM;MACL,MAAME,+CAAuC;IAC/C;EACF;EAEA,IAAI3B,SAASA,CAAA,EAAwB;IACnC,IAAI,CAAC,IAAI,CAACC,UAAU,EAAE;MAAA,IAAA2B,qBAAA;MACpB,IAAI,CAAC3B,UAAU,GAAG,IAAIF,uBAAuB,EAAA6B,qBAAA,GAC3C,IAAI,CAACV,iBAAiB,cAAAU,qBAAA,uBAAtBA,qBAAA,CAAwB5B,SAAS,CAClC;IACH;IACA,OAAO,IAAI,CAACC,UAAU;EACxB;EAEA,IAAIhC,aAAaA,CAAA,EAAkB;IACjC,IAAI,CAAC,IAAI,CAACC,cAAc,EAAE;MAAA,IAAA2D,sBAAA;MACxB,IAAI,CAAC3D,cAAc,GAAG,IAAIH,iBAAiB,EAAA8D,sBAAA,GACzC,IAAI,CAACX,iBAAiB,cAAAW,sBAAA,uBAAtBA,sBAAA,CAAwB5D,aAAa,CACtC;IACH;IACA,OAAO,IAAI,CAACC,cAAc;EAC5B;AACF;AAAC4D,OAAA,CAAAf,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"file":"visualization_sdk.js","names":["_errors","require","_types","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","QueryResponseImpl","constructor","queryResponse","_queryResponse","update","fieldMeasures","_this$_queryResponse","_this$_queryResponse$","fields","measures","fieldDimensions","_this$_queryResponse2","_this$_queryResponse3","dimensions","fieldTableCalculations","_this$_queryResponse4","_this$_queryResponse5","table_calculations","fieldPivots","_this$_queryResponse6","_this$_queryResponse7","pivots","fieldMeasureLike","_this$_queryResponse8","_this$_queryResponse9","measure_like","fieldDimensionLike","_this$_queryResponse10","_this$_queryResponse11","dimension_like","data","_this$_queryResponse12","VisualizationConfigImpl","visConfig","_visConfig","queryFieldMeasures","_this$_visConfig","_this$_visConfig$quer","query_fields","queryFieldDimensions","_this$_visConfig2","_this$_visConfig2$que","queryFieldTableCalculations","_this$_visConfig3","_this$_visConfig3$que","queryFieldPivots","_this$_visConfig4","_this$_visConfig4$que","VisualizationSDKImpl","hostApi","updateVisData","visualizationData","isDashboardMountSupported","configureVisualization","options","send","ExtensionRequestType","VIS_DEFAULT_CONFIG","NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR","setVisConfig","config","VIS_CONFIG_UPDATE","updatedConfig","_this$visualizationDa","_this$visualizationDa2","exports"],"sources":["../../../src/connect/visualization/visualization_sdk.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR } from '../../util/errors'\nimport type { ExtensionHostApiImpl } from '../extension_host_api'\nimport { ExtensionRequestType } from '../types'\nimport type { Row } from '../tile'\nimport type {\n VisualizationSDK,\n RawVisualizationData,\n RawVisConfig,\n VisualizationConfig,\n QueryResponse,\n Measure,\n Dimension,\n TableCalculation,\n PivotConfig,\n RawVisQueryResponse,\n VisOptions,\n} from './types'\n\nclass QueryResponseImpl implements QueryResponse {\n _queryResponse?: RawVisQueryResponse\n\n constructor(queryResponse?: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n update(queryResponse: RawVisQueryResponse) {\n this._queryResponse = queryResponse\n }\n\n get fieldMeasures(): Measure[] {\n return this._queryResponse?.fields?.measures || []\n }\n\n get fieldDimensions(): Dimension[] {\n return this._queryResponse?.fields?.dimensions || []\n }\n\n get fieldTableCalculations(): TableCalculation[] {\n return this._queryResponse?.fields?.table_calculations || []\n }\n\n get fieldPivots(): PivotConfig[] {\n return this._queryResponse?.fields?.pivots || []\n }\n\n get fieldMeasureLike(): Measure[] {\n return this._queryResponse?.fields?.measure_like || []\n }\n\n get fieldDimensionLike(): Dimension[] {\n return this._queryResponse?.fields?.dimension_like || []\n }\n\n get data(): Row[] {\n return this._queryResponse?.data || []\n }\n}\n\nclass VisualizationConfigImpl implements VisualizationConfig {\n _visConfig?: RawVisConfig\n\n constructor(visConfig?: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n update(visConfig: RawVisConfig) {\n this._visConfig = visConfig\n }\n\n get visConfig(): RawVisConfig {\n return this._visConfig || {}\n }\n\n get queryFieldMeasures(): Measure[] {\n return this._visConfig?.query_fields?.measures || []\n }\n\n get queryFieldDimensions(): Dimension[] {\n return this._visConfig?.query_fields?.dimensions || []\n }\n\n get queryFieldTableCalculations(): TableCalculation[] {\n return this._visConfig?.query_fields?.table_calculations || []\n }\n\n get queryFieldPivots(): PivotConfig[] {\n return this._visConfig?.query_fields?.pivots || []\n }\n}\n\nexport class VisualizationSDKImpl implements VisualizationSDK {\n hostApi: ExtensionHostApiImpl\n visualizationData?: RawVisualizationData\n _visConfig?: VisualizationConfigImpl\n _queryResponse?: QueryResponseImpl\n\n constructor(hostApi: ExtensionHostApiImpl) {\n this.hostApi = hostApi\n }\n\n updateVisData(visualizationData: RawVisualizationData) {\n // Ignore update messages if dashboard mounts not supported.\n // Should never happen.\n if (this.hostApi.isDashboardMountSupported) {\n this.visualizationData = visualizationData\n if (this.visConfig && this._visConfig) {\n this._visConfig.update(this.visualizationData.visConfig)\n }\n if (this.queryResponse && this._queryResponse) {\n this._queryResponse.update(this.visualizationData.queryResponse)\n }\n }\n }\n\n configureVisualization(options: VisOptions): void {\n if (this.hostApi.isDashboardMountSupported) {\n this.hostApi.send(ExtensionRequestType.VIS_DEFAULT_CONFIG, { options })\n } else {\n throw NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR\n }\n }\n\n setVisConfig(config: RawVisConfig) {\n if (this.hostApi.isDashboardMountSupported) {\n this.hostApi.send(ExtensionRequestType.VIS_CONFIG_UPDATE, {\n updatedConfig: config,\n })\n } else {\n throw NOT_DASHBOARD_MOUNT_NOT_SUPPORTED_ERROR\n }\n }\n\n get visConfig(): VisualizationConfig {\n if (!this._visConfig) {\n this._visConfig = new VisualizationConfigImpl(\n this.visualizationData?.visConfig\n )\n }\n return this._visConfig\n }\n\n get queryResponse(): QueryResponse {\n if (!this._queryResponse) {\n this._queryResponse = new QueryResponseImpl(\n this.visualizationData?.queryResponse\n )\n }\n return this._queryResponse\n }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AE;QACxDC,aAAa,EAAEF;MACjB,CAAC,CAAC;IACJ,CAAC,MAAM;MACL,MAAMF,+CAAuC;IAC/C;EACF;EAEA,IAAIzB,SAASA,CAAA,EAAwB;IACnC,IAAI,CAAC,IAAI,CAACC,UAAU,EAAE;MAAA,IAAA6B,qBAAA;MACpB,IAAI,CAAC7B,UAAU,GAAG,IAAIF,uBAAuB,EAAA+B,qBAAA,GAC3C,IAAI,CAACZ,iBAAiB,cAAAY,qBAAA,uBAAtBA,qBAAA,CAAwB9B,SAC1B,CAAC;IACH;IACA,OAAO,IAAI,CAACC,UAAU;EACxB;EAEA,IAAIhC,aAAaA,CAAA,EAAkB;IACjC,IAAI,CAAC,IAAI,CAACC,cAAc,EAAE;MAAA,IAAA6D,sBAAA;MACxB,IAAI,CAAC7D,cAAc,GAAG,IAAIH,iBAAiB,EAAAgE,sBAAA,GACzC,IAAI,CAACb,iBAAiB,cAAAa,sBAAA,uBAAtBA,sBAAA,CAAwB9D,aAC1B,CAAC;IACH;IACA,OAAO,IAAI,CAACC,cAAc;EAC5B;AACF;AAAC8D,OAAA,CAAAjB,oBAAA,GAAAA,oBAAA"}
@@ -1,13 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.connectExtensionHost = void 0;
7
- var _chatty = require("@looker/chatty");
8
- var _extension_host_api = require("./extension_host_api");
9
- var _global_listener = require("./global_listener");
10
- var _types = require("./types");
11
1
  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
2
  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
3
  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; }
@@ -15,7 +5,11 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
15
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
6
  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); } }
17
7
  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); }); }; }
18
- var connectExtensionHost = function () {
8
+ import { Chatty } from '@looker/chatty';
9
+ import { ExtensionHostApiImpl } from './extension_host_api';
10
+ import { registerHostApi } from './global_listener';
11
+ import { ExtensionEvent } from './types';
12
+ export var connectExtensionHost = function () {
19
13
  var _ref = _asyncToGenerator(function* () {
20
14
  var configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
15
  return new Promise(function () {
@@ -50,7 +44,7 @@ var connectExtensionHost = function () {
50
44
  targetOrigin = '*';
51
45
  }
52
46
  try {
53
- var chattyHost = yield _chatty.Chatty.createClient().on(_types.ExtensionEvent.EXTENSION_HOST_NOTIFICATION, message => {
47
+ var chattyHost = yield Chatty.createClient().on(ExtensionEvent.EXTENSION_HOST_NOTIFICATION, message => {
54
48
  var messageResponse;
55
49
  if (message) {
56
50
  if (initializationTimer) {
@@ -72,10 +66,10 @@ var connectExtensionHost = function () {
72
66
  }
73
67
  return messageResponse;
74
68
  }).withTargetOrigin(targetOrigin).withDefaultTimeout(chattyTimeout || 30000).build().connect();
75
- extensionHost = new _extension_host_api.ExtensionHostApiImpl(_objectSpread({
69
+ extensionHost = new ExtensionHostApiImpl(_objectSpread({
76
70
  chattyHost
77
71
  }, configuration));
78
- (0, _global_listener.registerHostApi)(extensionHost);
72
+ registerHostApi(extensionHost);
79
73
  } catch (error) {
80
74
  window.clearTimeout(initializationTimer);
81
75
  initializationTimer = undefined;
@@ -91,5 +85,4 @@ var connectExtensionHost = function () {
91
85
  return _ref.apply(this, arguments);
92
86
  };
93
87
  }();
94
- exports.connectExtensionHost = connectExtensionHost;
95
88
  //# sourceMappingURL=connect_extension_host.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connect_extension_host.js","names":["_chatty","require","_extension_host_api","_global_listener","_types","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","connectExtensionHost","_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","exports"],"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;AAAwC,SAAAI,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,IAAAC,eAAA,CAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAoB,cAAA,CAAAV,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,C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B,YAAY,CAACtB,mBAAmB,CAAC;UACxCA,mBAAmB,GAAGzB,SAAS;UAC/BQ,MAAM,CAACI,KAAK,CAAC;QACf;MACF,CAAC;MAAA,iBAAA2C,EAAA,EAAAC,GAAA;QAAA,OAAAhC,KAAA,CAAAlD,KAAA,OAAAI,SAAA;MAAA;IAAA,IAAC;EAAA;EAAA,gBAxGS2C,oBAAoBA,CAAA;IAAA,OAAAC,IAAA,CAAAhD,KAAA,OAAAI,SAAA;EAAA;AAAA,GAwG7B;AAAA+E,OAAA,CAAApC,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"file":"connect_extension_host.js","names":["Chatty","ExtensionHostApiImpl","registerHostApi","ExtensionEvent","connectExtensionHost","_ref","_asyncToGenerator","configuration","arguments","length","undefined","Promise","_ref2","resolve","reject","initializationTimer","window","setTimeout","Error","initializedCallback","chattyTimeout","extensionHost","targetOrigin","initialized","initializationResponse","errorMessage","parent","location","origin","err","chattyHost","createClient","on","EXTENSION_HOST_NOTIFICATION","message","messageResponse","clearTimeout","handleNotification","error","withTargetOrigin","withDefaultTimeout","build","connect","_objectSpread","_x","_x2","apply"],"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,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,oBAAoB,QAAQ,sBAAsB;AAC3D,SAASC,eAAe,QAAQ,mBAAmB;AAOnD,SAASC,cAAc,QAAQ,SAAS;AAQxC,OAAO,IAAMC,oBAAoB;EAAA,IAAAC,IAAA,GAAAC,iBAAA,CAAG;IAAA,IAClCC,aAAyC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,OAG9C,IAAIG,OAAO;MAAA,IAAAC,KAAA,GAAAN,iBAAA,CAAC,WAAOO,OAAO,E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9B,CAAC,CAAC,OAAOG,KAAK,EAAE;oBAEdxB,MAAM,CAACwB,KAAK,CAAC;kBACf;gBACF,CAAC,MAAM;kBAGLxB,MAAM,CAAC,IAAII,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBACjD;cACF,CAAC,MAAM;gBAELiB,eAAe,GAAGd,aAAa,CAACgB,kBAAkB,CAACH,OAAO,CAAC;cAC7D;YACF;YACA,OAAOC,eAAe;UACxB,CACF,CAAC,CACAI,gBAAgB,CAACjB,YAAY,CAAC,CAC9BkB,kBAAkB,CAACpB,aAAa,IAAI,KAAK,CAAC,CAC1CqB,KAAK,CAAC,CAAC,CACPC,OAAO,CAAC,CAAC;UAGZrB,aAAa,GAAG,IAAIpB,oBAAoB,CAAA0C,aAAA;YACtCb;UAAU,GACPvB,aAAa,CACjB,CAAC;UAGFL,eAAe,CAACmB,aAAa,CAAC;QAChC,CAAC,CAAC,OAAOiB,KAAK,EAAE;UACdtB,MAAM,CAACoB,YAAY,CAACrB,mBAAmB,CAAC;UACxCA,mBAAmB,GAAGL,SAAS;UAC/BI,MAAM,CAACwB,KAAK,CAAC;QACf;MACF,CAAC;MAAA,iBAAAM,EAAA,EAAAC,GAAA;QAAA,OAAAjC,KAAA,CAAAkC,KAAA,OAAAtC,SAAA;MAAA;IAAA,IAAC;EAAA;EAAA,gBAxGSJ,oBAAoBA,CAAA;IAAA,OAAAC,IAAA,CAAAyC,KAAA,OAAAtC,SAAA;EAAA;AAAA,GAwG7B"}
@@ -1,24 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ExtensionHostApiImpl = exports.EXTENSION_SDK_VERSION = void 0;
7
- var _intersects = _interopRequireDefault(require("semver/ranges/intersects"));
8
- var _util = require("../util");
9
- var _visualization_sdk = require("./visualization/visualization_sdk");
10
- var _tile_sdk = require("./tile/tile_sdk");
11
- var _fetch_proxy = require("./fetch_proxy");
12
- var _types = require("./types");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
1
  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); } }
15
2
  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); }); }; }
16
3
  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; }
17
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
5
  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); }
19
- var EXTENSION_SDK_VERSION = '0.10.5';
20
- exports.EXTENSION_SDK_VERSION = EXTENSION_SDK_VERSION;
21
- class ExtensionHostApiImpl {
6
+ import intersects from 'semver/ranges/intersects';
7
+ import { logError } from '../util';
8
+ import { VisualizationSDKImpl } from './visualization/visualization_sdk';
9
+ import { TileSDKImpl } from './tile/tile_sdk';
10
+ import { FetchProxyImpl } from './fetch_proxy';
11
+ import { ExtensionEvent, ExtensionNotificationType, ExtensionRequestType, MountPoint } from './types';
12
+ export var EXTENSION_SDK_VERSION = '0.10.5';
13
+ export class ExtensionHostApiImpl {
22
14
  constructor(configuration) {
23
15
  _defineProperty(this, "_configuration", void 0);
24
16
  _defineProperty(this, "_lookerHostData", void 0);
@@ -46,17 +38,17 @@ class ExtensionHostApiImpl {
46
38
  }
47
39
  get isDashboardMountSupported() {
48
40
  var _this$_lookerHostData, _this$lookerHostData, _this$lookerHostData2, _this$lookerHostData3;
49
- 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 || ((_this$lookerHostData3 = this.lookerHostData) === null || _this$lookerHostData3 === void 0 ? void 0 : _this$lookerHostData3.mountPoint) === _types.MountPoint.dashboardTilePopup);
41
+ return !!((_this$_lookerHostData = this._lookerHostData) !== null && _this$_lookerHostData !== void 0 && _this$_lookerHostData.extensionDashboardTileEnabled) && (((_this$lookerHostData = this.lookerHostData) === null || _this$lookerHostData === void 0 ? void 0 : _this$lookerHostData.mountPoint) === MountPoint.dashboardTile || ((_this$lookerHostData2 = this.lookerHostData) === null || _this$lookerHostData2 === void 0 ? void 0 : _this$lookerHostData2.mountPoint) === MountPoint.dashboardVisualization || ((_this$lookerHostData3 = this.lookerHostData) === null || _this$lookerHostData3 === void 0 ? void 0 : _this$lookerHostData3.mountPoint) === MountPoint.dashboardTilePopup);
50
42
  }
51
43
  get visualizationSDK() {
52
44
  if (!this._visualizationSDK) {
53
- this._visualizationSDK = new _visualization_sdk.VisualizationSDKImpl(this);
45
+ this._visualizationSDK = new VisualizationSDKImpl(this);
54
46
  }
55
47
  return this._visualizationSDK;
56
48
  }
57
49
  get tileSDK() {
58
50
  if (!this._tileSDK) {
59
- this._tileSDK = new _tile_sdk.TileSDKImpl(this);
51
+ this._tileSDK = new TileSDKImpl(this);
60
52
  }
61
53
  return this._tileSDK;
62
54
  }
@@ -68,7 +60,7 @@ class ExtensionHostApiImpl {
68
60
  type
69
61
  } = message;
70
62
  switch (type) {
71
- case _types.ExtensionNotificationType.ROUTE_CHANGED:
63
+ case ExtensionNotificationType.ROUTE_CHANGED:
72
64
  {
73
65
  var {
74
66
  payload
@@ -84,7 +76,7 @@ class ExtensionHostApiImpl {
84
76
  }
85
77
  return undefined;
86
78
  }
87
- case _types.ExtensionNotificationType.VISUALIZATION_DATA:
79
+ case ExtensionNotificationType.VISUALIZATION_DATA:
88
80
  {
89
81
  var {
90
82
  payload: _payload
@@ -95,7 +87,7 @@ class ExtensionHostApiImpl {
95
87
  }
96
88
  return undefined;
97
89
  }
98
- case _types.ExtensionNotificationType.TILE_HOST_DATA:
90
+ case ExtensionNotificationType.TILE_HOST_DATA:
99
91
  {
100
92
  var {
101
93
  payload: _payload2
@@ -106,14 +98,14 @@ class ExtensionHostApiImpl {
106
98
  }
107
99
  return undefined;
108
100
  }
109
- case _types.ExtensionNotificationType.INITIALIZE:
101
+ case ExtensionNotificationType.INITIALIZE:
110
102
  {
111
103
  var {
112
104
  payload: _payload3
113
105
  } = message;
114
106
  var lookerHostData = _payload3 || {};
115
107
  if (!lookerHostData.mountPoint) {
116
- lookerHostData.mountPoint = _types.MountPoint.standalone;
108
+ lookerHostData.mountPoint = MountPoint.standalone;
117
109
  }
118
110
  this._lookerHostData = lookerHostData;
119
111
  this.contextData = lookerHostData.contextData;
@@ -121,7 +113,7 @@ class ExtensionHostApiImpl {
121
113
  if (this._configuration.requiredLookerVersion && lookerHostData.lookerVersion) {
122
114
  errorMessage = this.verifyLookerVersion(this._configuration.requiredLookerVersion);
123
115
  if (errorMessage) {
124
- (0, _util.logError)(errorMessage);
116
+ logError(errorMessage);
125
117
  }
126
118
  }
127
119
  if (this.setInitialRoute && _payload3) {
@@ -139,7 +131,7 @@ class ExtensionHostApiImpl {
139
131
  };
140
132
  }
141
133
  default:
142
- (0, _util.logError)('Unrecognized extension notification', message);
134
+ logError('Unrecognized extension notification', message);
143
135
  throw new Error("Unrecognized extension notification type ".concat(type));
144
136
  }
145
137
  }
@@ -156,13 +148,13 @@ class ExtensionHostApiImpl {
156
148
  verifyHostConnection() {
157
149
  var _this = this;
158
150
  return _asyncToGenerator(function* () {
159
- return _this.sendAndReceive(_types.ExtensionRequestType.VERIFY_HOST);
151
+ return _this.sendAndReceive(ExtensionRequestType.VERIFY_HOST);
160
152
  })();
161
153
  }
162
154
  invokeCoreSdk(httpMethod, path, params, body, authenticator, options, apiVersion) {
163
155
  var _this2 = this;
164
156
  return _asyncToGenerator(function* () {
165
- return _this2.sendAndReceive(_types.ExtensionRequestType.INVOKE_CORE_SDK, {
157
+ return _this2.sendAndReceive(ExtensionRequestType.INVOKE_CORE_SDK, {
166
158
  httpMethod,
167
159
  path,
168
160
  params,
@@ -176,7 +168,7 @@ class ExtensionHostApiImpl {
176
168
  invokeCoreSdkRaw(httpMethod, path, params, body, apiVersion) {
177
169
  var _this3 = this;
178
170
  return _asyncToGenerator(function* () {
179
- return _this3.sendAndReceive(_types.ExtensionRequestType.RAW_INVOKE_CORE_SDK, {
171
+ return _this3.sendAndReceive(ExtensionRequestType.RAW_INVOKE_CORE_SDK, {
180
172
  httpMethod,
181
173
  path,
182
174
  params,
@@ -186,32 +178,32 @@ class ExtensionHostApiImpl {
186
178
  })();
187
179
  }
188
180
  updateTitle(title) {
189
- this.send(_types.ExtensionRequestType.UPDATE_TITLE, {
181
+ this.send(ExtensionRequestType.UPDATE_TITLE, {
190
182
  title
191
183
  });
192
184
  }
193
185
  updateLocation(url, state, target) {
194
- this.send(_types.ExtensionRequestType.UPDATE_LOCATION, {
186
+ this.send(ExtensionRequestType.UPDATE_LOCATION, {
195
187
  url,
196
188
  state,
197
189
  target
198
190
  });
199
191
  }
200
192
  spartanLogout() {
201
- this.send(_types.ExtensionRequestType.SPARTAN_LOGOUT);
193
+ this.send(ExtensionRequestType.SPARTAN_LOGOUT);
202
194
  }
203
195
  openBrowserWindow(url, target) {
204
- this.send(_types.ExtensionRequestType.UPDATE_LOCATION, {
196
+ this.send(ExtensionRequestType.UPDATE_LOCATION, {
205
197
  url,
206
198
  undefined,
207
199
  target: target || '_blank'
208
200
  });
209
201
  }
210
202
  closeHostPopovers() {
211
- this.send(_types.ExtensionRequestType.CLOSE_HOST_POPOVERS);
203
+ this.send(ExtensionRequestType.CLOSE_HOST_POPOVERS);
212
204
  }
213
205
  clientRouteChanged(route, routeState) {
214
- this.send(_types.ExtensionRequestType.ROUTE_CHANGED, {
206
+ this.send(ExtensionRequestType.ROUTE_CHANGED, {
215
207
  route,
216
208
  routeState
217
209
  });
@@ -224,7 +216,7 @@ class ExtensionHostApiImpl {
224
216
  if (_this4._lookerHostData && !_this4._lookerHostData.lookerVersion) {
225
217
  return Promise.reject(new Error('localStorageSetItem not supported by the current Looker host'));
226
218
  }
227
- return _this4.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
219
+ return _this4.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
228
220
  type: 'set',
229
221
  name,
230
222
  value
@@ -237,7 +229,7 @@ class ExtensionHostApiImpl {
237
229
  if (_this5._lookerHostData && !_this5._lookerHostData.lookerVersion) {
238
230
  return Promise.reject(new Error('localStorageGetItem not supported by the current Looker host'));
239
231
  }
240
- return _this5.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
232
+ return _this5.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
241
233
  type: 'get',
242
234
  name
243
235
  });
@@ -249,7 +241,7 @@ class ExtensionHostApiImpl {
249
241
  if (_this6._lookerHostData && !_this6._lookerHostData.lookerVersion) {
250
242
  return Promise.reject(new Error('localStorageRemoveItem not supported by the current Looker host'));
251
243
  }
252
- return _this6.sendAndReceive(_types.ExtensionRequestType.LOCAL_STORAGE, {
244
+ return _this6.sendAndReceive(ExtensionRequestType.LOCAL_STORAGE, {
253
245
  type: 'remove',
254
246
  name
255
247
  });
@@ -262,7 +254,7 @@ class ExtensionHostApiImpl {
262
254
  if (errorMessage) {
263
255
  return Promise.reject(new Error(errorMessage));
264
256
  }
265
- return _this7.sendAndReceive(_types.ExtensionRequestType.CLIPBOARD, {
257
+ return _this7.sendAndReceive(ExtensionRequestType.CLIPBOARD, {
266
258
  type: 'write',
267
259
  value
268
260
  });
@@ -277,7 +269,7 @@ class ExtensionHostApiImpl {
277
269
  if (errorMessage) {
278
270
  return Promise.reject(new Error(errorMessage));
279
271
  }
280
- return _this8.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
272
+ return _this8.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
281
273
  type: 'set',
282
274
  name,
283
275
  value
@@ -291,7 +283,7 @@ class ExtensionHostApiImpl {
291
283
  if (errorMessage) {
292
284
  return Promise.reject(new Error(errorMessage));
293
285
  }
294
- return _this9.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
286
+ return _this9.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
295
287
  type: 'get',
296
288
  name
297
289
  });
@@ -304,7 +296,7 @@ class ExtensionHostApiImpl {
304
296
  if (errorMessage) {
305
297
  return Promise.reject(new Error(errorMessage));
306
298
  }
307
- return _this10.sendAndReceive(_types.ExtensionRequestType.USER_ATTRIBUTE, {
299
+ return _this10.sendAndReceive(ExtensionRequestType.USER_ATTRIBUTE, {
308
300
  type: 'reset',
309
301
  name
310
302
  });
@@ -338,7 +330,7 @@ class ExtensionHostApiImpl {
338
330
  } else {
339
331
  contextData = undefined;
340
332
  }
341
- yield _this11.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
333
+ yield _this11.sendAndReceive(ExtensionRequestType.CONTEXT_DATA, {
342
334
  type: 'save',
343
335
  contextData
344
336
  });
@@ -352,14 +344,14 @@ class ExtensionHostApiImpl {
352
344
  if (errorMessage) {
353
345
  return Promise.reject(new Error(errorMessage));
354
346
  }
355
- _this12.contextData = yield _this12.sendAndReceive(_types.ExtensionRequestType.CONTEXT_DATA, {
347
+ _this12.contextData = yield _this12.sendAndReceive(ExtensionRequestType.CONTEXT_DATA, {
356
348
  type: 'refresh'
357
349
  });
358
350
  return _this12.getContextData();
359
351
  })();
360
352
  }
361
353
  track(name, trackAction, attributes) {
362
- this.send(_types.ExtensionRequestType.TRACK_ACTION, {
354
+ this.send(ExtensionRequestType.TRACK_ACTION, {
363
355
  name,
364
356
  trackAction,
365
357
  attributes
@@ -374,7 +366,7 @@ class ExtensionHostApiImpl {
374
366
  colno,
375
367
  error
376
368
  } = errorEvent || {};
377
- this.send(_types.ExtensionRequestType.ERROR_EVENT, {
369
+ this.send(ExtensionRequestType.ERROR_EVENT, {
378
370
  message,
379
371
  filename,
380
372
  lineno,
@@ -382,14 +374,14 @@ class ExtensionHostApiImpl {
382
374
  error: error && error.toString ? error.toString() : error
383
375
  });
384
376
  } else {
385
- (0, _util.logError)('Unhandled error but Looker host connection not established', errorEvent);
377
+ logError('Unhandled error but Looker host connection not established', errorEvent);
386
378
  }
387
379
  }
388
380
  unloaded() {
389
- this.send(_types.ExtensionRequestType.EXTENSION_UNLOADED, {});
381
+ this.send(ExtensionRequestType.EXTENSION_UNLOADED, {});
390
382
  }
391
383
  createFetchProxy(baseUrl, init, responseBodyType) {
392
- return new _fetch_proxy.FetchProxyImpl(this, baseUrl, init, responseBodyType);
384
+ return new FetchProxyImpl(this, baseUrl, init, responseBodyType);
393
385
  }
394
386
  fetchProxy(resource, init, responseBodyType) {
395
387
  var _this13 = this;
@@ -398,7 +390,7 @@ class ExtensionHostApiImpl {
398
390
  if (errorMessage) {
399
391
  return Promise.reject(new Error(errorMessage));
400
392
  }
401
- return _this13.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
393
+ return _this13.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
402
394
  type: 'fetch',
403
395
  payload: {
404
396
  resource,
@@ -415,7 +407,7 @@ class ExtensionHostApiImpl {
415
407
  if (errorMessage) {
416
408
  return Promise.reject(new Error(errorMessage));
417
409
  }
418
- return _this14.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
410
+ return _this14.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
419
411
  type: 'server-proxy',
420
412
  payload: {
421
413
  resource,
@@ -438,7 +430,7 @@ class ExtensionHostApiImpl {
438
430
  if (errorMessage) {
439
431
  return Promise.reject(new Error(errorMessage));
440
432
  }
441
- return _this15.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
433
+ return _this15.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
442
434
  type: 'oauth2_authenticate',
443
435
  payload: {
444
436
  authEndpoint,
@@ -457,7 +449,7 @@ class ExtensionHostApiImpl {
457
449
  if (errorMessage) {
458
450
  return Promise.reject(new Error(errorMessage));
459
451
  }
460
- return _this16.sendAndReceive(_types.ExtensionRequestType.INVOKE_EXTERNAL_API, {
452
+ return _this16.sendAndReceive(ExtensionRequestType.INVOKE_EXTERNAL_API, {
461
453
  type: 'oauth2_exchange_code',
462
454
  payload: {
463
455
  authEndpoint,
@@ -467,7 +459,7 @@ class ExtensionHostApiImpl {
467
459
  })();
468
460
  }
469
461
  rendered(failureMessage) {
470
- this.send(_types.ExtensionRequestType.RENDERED, {
462
+ this.send(ExtensionRequestType.RENDERED, {
471
463
  failureMessage
472
464
  });
473
465
  }
@@ -482,21 +474,21 @@ class ExtensionHostApiImpl {
482
474
  payload
483
475
  };
484
476
  var chattyPayload = options ? [messagePayload, options] : [messagePayload];
485
- return _this17.chattyHost.sendAndReceive(_types.ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
477
+ return _this17.chattyHost.sendAndReceive(ExtensionEvent.EXTENSION_API_REQUEST, ...chattyPayload).then(values => values[0]);
486
478
  })();
487
479
  }
488
480
  send(type, payload) {
489
481
  if (!this._lookerHostData) {
490
482
  throw new Error('Looker host connection not established');
491
483
  }
492
- this.chattyHost.send(_types.ExtensionEvent.EXTENSION_API_REQUEST, {
484
+ this.chattyHost.send(ExtensionEvent.EXTENSION_API_REQUEST, {
493
485
  type,
494
486
  payload
495
487
  });
496
488
  }
497
489
  verifyLookerVersion(version) {
498
490
  var lookerVersion = this._lookerHostData ? this._lookerHostData.lookerVersion || '7.0' : '7.0';
499
- if (!this._lookerHostData || !(0, _intersects.default)(version, lookerVersion, true)) {
491
+ if (!this._lookerHostData || !intersects(version, lookerVersion, true)) {
500
492
  return "Extension requires Looker version ".concat(version, ", got ").concat(lookerVersion);
501
493
  }
502
494
  return undefined;
@@ -514,5 +506,4 @@ class ExtensionHostApiImpl {
514
506
  return undefined;
515
507
  }
516
508
  }
517
- exports.ExtensionHostApiImpl = ExtensionHostApiImpl;
518
509
  //# sourceMappingURL=extension_host_api.js.map