@looker/extension-utils 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/lib/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/APIErrorDisplay/utils.js.map +1 -1
- package/lib/ExtMarkdown.js.map +1 -1
- package/lib/OAuthForm/src/components/CollapserCard.js.map +1 -1
- package/lib/OAuthForm/src/components/ConfigHeading.js.map +1 -1
- package/lib/OAuthForm/src/components/OAuthForm.js.map +1 -1
- package/lib/OAuthForm/src/state/sagas.js.map +1 -1
- package/lib/OAuthForm/src/state/slice.js.map +1 -1
- package/lib/OAuthForm/src/utils.js.map +1 -1
- package/lib/OAuthScene.js.map +1 -1
- package/lib/adaptorUtils.js.map +1 -1
- package/lib/authUtils.js.map +1 -1
- package/lib/browserAdaptor.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorContent.js +16 -25
- package/lib/esm/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js +13 -21
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js +10 -18
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js +7 -15
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js +7 -15
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/esm/APIErrorDisplay/index.js +3 -39
- package/lib/esm/APIErrorDisplay/index.js.map +1 -1
- package/lib/esm/APIErrorDisplay/utils.js +2 -10
- package/lib/esm/APIErrorDisplay/utils.js.map +1 -1
- package/lib/esm/ExtMarkdown.js +6 -14
- package/lib/esm/ExtMarkdown.js.map +1 -1
- package/lib/esm/OAuthForm/index.js +1 -16
- package/lib/esm/OAuthForm/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/CollapserCard.js +13 -21
- package/lib/esm/OAuthForm/src/components/CollapserCard.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/ConfigHeading.js +3 -11
- package/lib/esm/OAuthForm/src/components/ConfigHeading.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/OAuthForm.js +41 -51
- package/lib/esm/OAuthForm/src/components/OAuthForm.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/index.js +1 -12
- package/lib/esm/OAuthForm/src/components/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/index.js +2 -27
- package/lib/esm/OAuthForm/src/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/index.js +1 -12
- package/lib/esm/OAuthForm/src/state/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/sagas.js +38 -44
- package/lib/esm/OAuthForm/src/state/sagas.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/slice.js +11 -24
- package/lib/esm/OAuthForm/src/state/slice.js.map +1 -1
- package/lib/esm/OAuthForm/src/utils.js +6 -15
- package/lib/esm/OAuthForm/src/utils.js.map +1 -1
- package/lib/esm/OAuthScene.js +14 -23
- package/lib/esm/OAuthScene.js.map +1 -1
- package/lib/esm/adaptorUtils.js +9 -22
- package/lib/esm/adaptorUtils.js.map +1 -1
- package/lib/esm/authUtils.js +2 -9
- package/lib/esm/authUtils.js.map +1 -1
- package/lib/esm/browserAdaptor.js +4 -12
- package/lib/esm/browserAdaptor.js.map +1 -1
- package/lib/esm/extensionAdaptor.js +4 -12
- package/lib/esm/extensionAdaptor.js.map +1 -1
- package/lib/esm/index.js +8 -93
- package/lib/esm/index.js.map +1 -1
- package/lib/extensionAdaptor.js.map +1 -1
- package/package.json +5 -5
package/lib/adaptorUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adaptorUtils.js","names":["_browserAdaptor","require","hostedInternally","hostname","endsWith","startsWith","exports","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk","BrowserAdaptor","appPath","location","newPath","reactPath","pathname","wloc","window","base","origin","wpath","result","concat","substring","indexOf"],"sources":["../src/adaptorUtils.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 type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type { Location as HLocation } from 'history'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n\n/**\n * Get new application-level base path for react application\n * This function compares the react-based location with the browser window location\n * pathname to ensure that the newPath variable is assigned at the root of the\n * React app path rather than potentially recursive nesting\n *\n * @param location which is usually from useLocation()\n * @param newPath new path to assign, like `/oauth`\n */\nexport const appPath = (location: HLocation, newPath: string) => {\n const reactPath = location.pathname\n const wloc = (window as any).location\n const base = wloc.origin\n const wpath = wloc.pathname\n const result = `${base}${wpath.substring(\n 0,\n wpath.indexOf(reactPath)\n )}${newPath}`\n return result\n}\n"],"mappings":";;;;;;AA6BA,IAAAA,eAAA,GAAAC,OAAA;AAoDO,IAAMC,gBAAgB,GAAIC,QAAgB,IAC/CA,QAAQ,CAACC,QAAQ,CAAC,aAAa,CAAC,IAChCD,QAAQ,CAACC,QAAQ,CAAC,aAAa,CAAC,IAChCD,QAAQ,KAAK,WAAW,IAIvBA,QAAQ,CAACE,UAAU,CAAC,yBAAyB,CAAC,IAC7CF,QAAQ,CAACC,QAAQ,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ACrC,IAAMM,IAAI,GAAGF,IAAI,CAACG,MAAM;EACxB,IAAMC,KAAK,GAAGJ,IAAI,CAACD,QAAQ;EAC3B,IAAMM,MAAM,MAAAC,MAAA,CAAMJ,IAAI,EAAAI,MAAA,CAAGF,KAAK,CAACG,SAAS,CACtC,CAAC,EACDH,KAAK,CAACI,OAAO,CAACV,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"adaptorUtils.js","names":["_browserAdaptor","require","hostedInternally","hostname","endsWith","startsWith","exports","getThemeOverrides","internalTheming","loadGoogleFonts","themeCustomizations","fontFamilies","brand","colors","key","extensionAdaptor","registerEnvAdaptor","adaptor","unregisterEnvAdaptor","undefined","getEnvAdaptor","Error","registerTestEnvAdaptor","mockSdk","BrowserAdaptor","appPath","location","newPath","reactPath","pathname","wloc","window","base","origin","wpath","result","concat","substring","indexOf"],"sources":["../src/adaptorUtils.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 type { ThemeCustomizations } from '@looker/design-tokens'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type { Location as HLocation } from 'history'\nimport { BrowserAdaptor } from './browserAdaptor'\n\nexport interface IAuthAdaptor {\n /** Method for retrieving an instantiated SDK */\n get sdk(): IAPIMethods\n /** Method for authenticating against the API server. Auth mechanism is dependent on the authSession implementation\n * used for the sdk. */\n login(): Promise<boolean>\n}\n\n/**\n * NOTE: This interface should describe all methods that require an adaptor when running in standalone vs extension mode\n * Examples include: local storage operations and various link navigation functions\n */\nexport interface IEnvironmentAdaptor extends IAuthAdaptor {\n /** Copy page URL to clipboard */\n copyToClipboard: (location?: {\n pathname: string\n search: string\n }) => Promise<void>\n /** Method for determining whether running in a browser or extension environment */\n isExtension(): boolean\n /** Method for retrieving a keyed value from local storage */\n localStorageGetItem(key: string): Promise<string | null>\n /** Method for setting a keyed value in local storage */\n localStorageSetItem(key: string, value: string): void\n /** Method for removing a keyed value from local storage */\n localStorageRemoveItem(key: string): void\n /** Theme settings for extension */\n themeOverrides(): ThemeOverrides\n /** Open a new browser window with the given url and target */\n openBrowserWindow: (url: string, target?: string) => void\n /** error logger */\n logError: (error: Error, componentStack: string) => void\n}\n\n/**\n * Theme overrides used to load google fonts in Google environments only.\n * Google fonts should NOT be used when it is not obvious that a Google\n * system is being used (for example an embedded extension).\n */\nexport interface ThemeOverrides {\n /** Should Google-specific fonts be used for the theme? */\n loadGoogleFonts?: boolean\n /** Property bag overrides for Looker component theming */\n themeCustomizations?: ThemeCustomizations\n}\n\n/**\n * Is this an \"internal\" host that will use internal branding?\n * @param hostname to check\n */\nexport const hostedInternally = (hostname: string): boolean =>\n hostname.endsWith('.looker.com') ||\n hostname.endsWith('.google.com') ||\n hostname === 'localhost' ||\n // Include firebase staging dev portal for now. Can be removed\n // when dev portal gets its own APIX project. Also includes\n // PRs.\n (hostname.startsWith('looker-developer-portal') &&\n hostname.endsWith('.web.app'))\n\n/**\n * Return theme overrides that make apply \"internal\" or external theming\n * @param internalTheming true if \"internal\" theme should be used\n */\nexport const getThemeOverrides = (internalTheming: boolean): ThemeOverrides =>\n internalTheming\n ? {\n loadGoogleFonts: true,\n themeCustomizations: {\n fontFamilies: { brand: 'Google Sans' },\n colors: { key: '#1A73E8' },\n },\n }\n : {\n themeCustomizations: {\n colors: { key: '#1A73E8' },\n },\n }\n\nlet extensionAdaptor: IEnvironmentAdaptor | undefined\n\n/**\n * Register the environment adaptor. Used when initializing the application\n * @param adaptor to register\n */\nexport const registerEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor: T\n) => {\n extensionAdaptor = adaptor\n}\n\n/**\n * Unregister the environment adaptor. Extensions should call this when unmounted\n */\nexport const unregisterEnvAdaptor = () => {\n extensionAdaptor = undefined\n}\n\n/**\n * Global access to the environment adaptor. An error will be thrown if accessed prematurely.\n */\nexport const getEnvAdaptor = () => {\n if (!extensionAdaptor) {\n throw new Error('Environment adaptor not initialized.')\n }\n return extensionAdaptor\n}\n\n/**\n * Used by some unit tests\n * @param adaptor to use for testing\n */\nexport const registerTestEnvAdaptor = <T extends IEnvironmentAdaptor>(\n adaptor?: T\n) => {\n const mockSdk = {} as unknown as IAPIMethods\n registerEnvAdaptor(adaptor || new BrowserAdaptor(mockSdk))\n}\n\n/**\n * Get new application-level base path for react application\n * This function compares the react-based location with the browser window location\n * pathname to ensure that the newPath variable is assigned at the root of the\n * React app path rather than potentially recursive nesting\n *\n * @param location which is usually from useLocation()\n * @param newPath new path to assign, like `/oauth`\n */\nexport const appPath = (location: HLocation, newPath: string) => {\n const reactPath = location.pathname\n const wloc = (window as any).location\n const base = wloc.origin\n const wpath = wloc.pathname\n const result = `${base}${wpath.substring(\n 0,\n wpath.indexOf(reactPath)\n )}${newPath}`\n return result\n}\n"],"mappings":";;;;;;AA6BA,IAAAA,eAAA,GAAAC,OAAA;AAoDO,IAAMC,gBAAgB,GAAIC,QAAgB,IAC/CA,QAAQ,CAACC,QAAQ,CAAC,aAAa,CAAC,IAChC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MG,OAAO,GAAGA,CAACC,QAAmB,EAAEC,OAAe,KAAK;EAC/D,IAAMC,SAAS,GAAGF,QAAQ,CAACG,QAAQ;EACnC,IAAMC,IAAI,GAAIC,MAAM,CAASL,QAAQ;EACrC,IAAMM,IAAI,GAAGF,IAAI,CAACG,MAAM;EACxB,IAAMC,KAAK,GAAGJ,IAAI,CAACD,QAAQ;EAC3B,IAAMM,MAAM,MAAAC,MAAA,CAAMJ,IAAI,EAAAI,MAAA,CAAGF,KAAK,CAACG,SAAS,CACtC,CAAC,EACDH,KAAK,CAACI,OAAO,CAACV,SAAS,CACzB,CAAC,EAAAQ,MAAA,CAAGT,OAAO,CAAE;EACb,OAAOQ,MAAM;AACf,CAAC;AAAA7B,OAAA,CAAAmB,OAAA,GAAAA,OAAA"}
|
package/lib/authUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authUtils.js","names":["_sdkRtl","require","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","OAuthConfigProvider","ApiSettings","constructor","settings","oauthClientId","configKey","getStorage","defaultValue","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","client_id","redirect_uri","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","concat","protocol","hostname","window","origin","exports"],"sources":["../src/authUtils.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 */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n oauthClientId: string\n constructor(\n settings: Partial<IApiSettings>,\n oauthClientId: string,\n private readonly configKey: string\n ) {\n super(settings)\n this.oauthClientId = oauthClientId\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = {\n base_url: '',\n looker_url: '',\n client_id: '',\n redirect_uri: '',\n }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n client_id: this.oauthClientId,\n redirect_uri: `${window.location.origin}/oauth`,\n }\n }\n\n const { base_url, looker_url, client_id, redirect_uri } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id,\n redirect_uri,\n },\n }\n }\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,OAAA;AAA6C,SAAAC,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,C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E,UAAUA,CAAC7B,GAAW,EAAoC;IAAA,IAAlC8B,YAAY,GAAAlC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAsB,SAAA,GAAAtB,SAAA,MAAG,EAAE;IAC/C,IAAIU,KAAK,GAAGyB,cAAc,CAACC,OAAO,CAAChC,GAAG,CAAC;IACvC,IAAIM,KAAK,EAAE;MACT,OAAO;QACL2B,QAAQ,EAAE,SAAS;QACnB3B;MACF,CAAC;IACH;IACAA,KAAK,GAAG4B,YAAY,CAACF,OAAO,CAAChC,GAAG,CAAC;IACjC,IAAIM,KAAK,EAAE;MACT,OAAO;QACL2B,QAAQ,EAAE,OAAO;QACjB3B;MACF,CAAC;IACH;IACA,OAAO;MACL2B,QAAQ,EAAE,SAAS;MACnB3B,KAAK,EAAEwB;IACT,CAAC;EACH;EAEAK,YAAYA,CAAA,EAAY;IAEtB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,IAAMC,OAAO,GAAG,IAAI,CAACR,UAAU,CAAC,IAAI,CAACD,SAAS,CAAC;IAC/C,IAAIU,MAAM,GAAG;MACXC,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,EAAE;MACdC,SAAS,EAAE,EAAE;MACbC,YAAY,EAAE;IAChB,CAAC;IACD,IAAIL,OAAO,CAAC/B,KAAK,EAAE;MACjBgC,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACP,OAAO,CAAC/B,KAAK,CAAC;IACpC;IACA,OAAOgC,MAAM;EACf;EAEAO,gBAAgBA,CAAA,EAAY;IAC1B,IAAMP,MAAM,GAAG,IAAI,CAACF,eAAe,
|
|
1
|
+
{"version":3,"file":"authUtils.js","names":["_sdkRtl","require","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","OAuthConfigProvider","ApiSettings","constructor","settings","oauthClientId","configKey","getStorage","defaultValue","sessionStorage","getItem","location","localStorage","isConfigured","getStoredConfig","storage","config","base_url","looker_url","client_id","redirect_uri","JSON","parse","authIsConfigured","readConfig","_section","url","URL","authServer","concat","protocol","hostname","window","origin","exports"],"sources":["../src/authUtils.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 */\nimport type { IApiSection, IApiSettings } from '@looker/sdk-rtl'\nimport { ApiSettings } from '@looker/sdk-rtl'\n\nexport type StorageLocation = 'session' | 'local'\n\n/** Object returned from storage service */\nexport interface IStorageValue {\n /** Location of the stored object */\n location: StorageLocation\n /** Stored string representation of the value (usually JSON) */\n value: string\n}\n\n/**\n * An OAuth Session configuration provider\n */\nexport class OAuthConfigProvider extends ApiSettings {\n oauthClientId: string\n constructor(\n settings: Partial<IApiSettings>,\n oauthClientId: string,\n private readonly configKey: string\n ) {\n super(settings)\n this.oauthClientId = oauthClientId\n }\n\n private getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n isConfigured(): boolean {\n // Required to be true otherwise SDK initialization fails\n return true\n }\n\n getStoredConfig() {\n const storage = this.getStorage(this.configKey)\n let config = {\n base_url: '',\n looker_url: '',\n client_id: '',\n redirect_uri: '',\n }\n if (storage.value) {\n config = JSON.parse(storage.value)\n }\n return config\n }\n\n authIsConfigured(): boolean {\n const config = this.getStoredConfig()\n return config.base_url !== '' && config.looker_url !== ''\n }\n\n readConfig(_section?: string): IApiSection {\n // Read server url values from storage\n let config = this.getStoredConfig()\n if (!this.authIsConfigured()) {\n // derive Looker server URL from base_url\n const url = new URL(this.base_url)\n const authServer = `${url.protocol}//${url.hostname}`\n config = {\n base_url: this.base_url,\n looker_url: `${authServer}:9999`,\n client_id: this.oauthClientId,\n redirect_uri: `${window.location.origin}/oauth`,\n }\n }\n\n const { base_url, looker_url, client_id, redirect_uri } = config\n /* update base_url to the dynamically determined value for standard transport requests */\n this.base_url = base_url\n return {\n ...super.readConfig(_section),\n ...{\n base_url,\n looker_url,\n client_id,\n redirect_uri,\n },\n }\n }\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,OAAA;AAA6C,SAAAC,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,EAAA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
|
1
|
-
{"version":3,"file":"browserAdaptor.js","names":["_adaptorUtils","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","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","arguments","apply","err","BrowserAuthAdaptor","constructor","sdk","login","_this","token","settings","authSession","authIsConfigured","exports","BrowserAdaptor","hostname","location","_themeOverrides","getThemeOverrides","hostedInternally","copyToClipboard","navigator","clipboard","writeText","href","isExtension","localStorageGetItem","localStorage","getItem","localStorageSetItem","setItem","localStorageRemoveItem","removeItem","themeOverrides","openBrowserWindow","url","target","window","open","logError","_error","_componentStack"],"sources":["../src/browserAdaptor.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 type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IAuthAdaptor,\n IEnvironmentAdaptor,\n ThemeOverrides,\n} from './adaptorUtils'\nimport { getThemeOverrides, hostedInternally } from './adaptorUtils'\nimport type { OAuthConfigProvider } from './authUtils'\n\nexport class BrowserAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n let token\n const settings = this.sdk.authSession.settings as OAuthConfigProvider\n if (settings.authIsConfigured()) {\n token = await this.sdk.authSession.login()\n }\n return !!token\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when not running in an extension\n */\nexport class BrowserAdaptor\n extends BrowserAuthAdaptor\n implements IEnvironmentAdaptor\n{\n private _themeOverrides: ThemeOverrides\n\n constructor(sdk: IAPIMethods) {\n super(sdk)\n const { hostname } = location\n this._themeOverrides = getThemeOverrides(hostedInternally(hostname))\n }\n\n async copyToClipboard() {\n await navigator.clipboard.writeText(location.href)\n }\n\n isExtension() {\n return false\n }\n\n async localStorageGetItem(key: string) {\n return localStorage.getItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await localStorage.setItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await localStorage.removeItem(key)\n }\n\n themeOverrides() {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n window.open(url, target)\n }\n\n logError(_error: Error, _componentStack: string): void {\n // noop - error logging for standalone applications TBD\n }\n}\n"],"mappings":";;;;;;AAgCA,IAAAA,aAAA,GAAAC,OAAA;AAAoE,SAAAC,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,GA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G7D,MAAMuB,kBAAkB,CAAyB;EACtDC,WAAWA,CAAiBC,GAAgB,EAAE;IAAA,KAAlBA,GAAgB,GAAhBA,GAAgB;EAAG;EAEzCC,KAAKA,CAAA,EAAG;IAAA,IAAAC,KAAA;IAAA,OAAAX,iBAAA;MACZ,IAAIY,KAAK;MACT,IAAMC,QAAQ,GAAGF,KAAI,CAACF,GAAG,CAACK,WAAW,CAACD,QAA+B;MACrE,IAAIA,QAAQ,CAACE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"browserAdaptor.js","names":["_adaptorUtils","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","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","arguments","apply","err","BrowserAuthAdaptor","constructor","sdk","login","_this","token","settings","authSession","authIsConfigured","exports","BrowserAdaptor","hostname","location","_themeOverrides","getThemeOverrides","hostedInternally","copyToClipboard","navigator","clipboard","writeText","href","isExtension","localStorageGetItem","localStorage","getItem","localStorageSetItem","setItem","localStorageRemoveItem","removeItem","themeOverrides","openBrowserWindow","url","target","window","open","logError","_error","_componentStack"],"sources":["../src/browserAdaptor.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 type { IAPIMethods } from '@looker/sdk-rtl'\nimport type {\n IAuthAdaptor,\n IEnvironmentAdaptor,\n ThemeOverrides,\n} from './adaptorUtils'\nimport { getThemeOverrides, hostedInternally } from './adaptorUtils'\nimport type { OAuthConfigProvider } from './authUtils'\n\nexport class BrowserAuthAdaptor implements IAuthAdaptor {\n constructor(public readonly sdk: IAPIMethods) {}\n\n async login() {\n let token\n const settings = this.sdk.authSession.settings as OAuthConfigProvider\n if (settings.authIsConfigured()) {\n token = await this.sdk.authSession.login()\n }\n return !!token\n }\n}\n\n/**\n * An adaptor class for interacting with browser APIs when not running in an extension\n */\nexport class BrowserAdaptor\n extends BrowserAuthAdaptor\n implements IEnvironmentAdaptor\n{\n private _themeOverrides: ThemeOverrides\n\n constructor(sdk: IAPIMethods) {\n super(sdk)\n const { hostname } = location\n this._themeOverrides = getThemeOverrides(hostedInternally(hostname))\n }\n\n async copyToClipboard() {\n await navigator.clipboard.writeText(location.href)\n }\n\n isExtension() {\n return false\n }\n\n async localStorageGetItem(key: string) {\n return localStorage.getItem(key)\n }\n\n async localStorageSetItem(key: string, value: string) {\n await localStorage.setItem(key, value)\n }\n\n async localStorageRemoveItem(key: string) {\n await localStorage.removeItem(key)\n }\n\n themeOverrides() {\n return this._themeOverrides\n }\n\n openBrowserWindow(url: string, target?: string) {\n window.open(url, target)\n }\n\n logError(_error: Error, _componentStack: string): void {\n // noop - error logging for standalone applications TBD\n }\n}\n"],"mappings":";;;;;;AAgCA,IAAAA,aAAA,GAAAC,OAAA;AAAoE,SAAAC,gBAAAC,GAAA,EAAAC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,KAAK;EACd;EAEMC,mBAAmBA,CAAC7D,GAAW,EAAE;IAAA,OAAAgC,iBAAA;MACrC,OAAO8B,YAAY,CAACC,OAAO,CAAC/D,GAAG,CAAC;IAAA;EAClC;EAEMgE,mBAAmBA,CAAChE,GAAW,EAAEC,KAAa,EAAE;IAAA,OAAA+B,iBAAA;MACpD,MAAM8B,YAAY,CAACG,OAAO,CAACjE,GAAG,EAAEC,KAAK,CAAC;IAAA;EACxC;EAEMiE,sBAAsBA,CAAClE,GAAW,EAAE;IAAA,OAAAgC,iBAAA;MACxC,MAAM8B,YAAY,CAACK,UAAU,CAACnE,GAAG,CAAC;IAAA;EACpC;EAEAoE,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAAChB,eAAe;EAC7B;EAEAiB,iBAAiBA,CAACC,GAAW,EAAEC,MAAe,EAAE;IAC9CC,MAAM,CAACC,IAAI,CAACH,GAAG,EAAEC,MAAM,CAAC;EAC1B;EAEAG,QAAQA,CAACC,MAAa,EAAEC,eAAuB,EAAQ,CAEvD;AACF;AAAC5B,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
|
|
@@ -1,49 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.APIErrorContent = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _sdkRtl = require("@looker/sdk-rtl");
|
|
9
|
-
var _adaptorUtils = require("../adaptorUtils");
|
|
10
|
-
var _ExtMarkdown = require("../ExtMarkdown");
|
|
11
|
-
var _APIErrorDetails = require("./APIErrorDetails");
|
|
12
|
-
var _APIErrorDocLink = require("./APIErrorDocLink");
|
|
13
|
-
var _utils = require("./utils");
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
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); } }
|
|
17
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); }); }; }
|
|
18
|
-
|
|
3
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { ErrorDoc } from '@looker/sdk-rtl';
|
|
5
|
+
import { getEnvAdaptor } from '../adaptorUtils';
|
|
6
|
+
import { ExtMarkdown } from '../ExtMarkdown';
|
|
7
|
+
import { APIErrorDetails } from './APIErrorDetails';
|
|
8
|
+
import { APIErrorDocLink } from './APIErrorDocLink';
|
|
9
|
+
import { apiErrorDisplayFetch } from './utils';
|
|
10
|
+
export var APIErrorContent = _ref => {
|
|
19
11
|
var _error$documentation_;
|
|
20
12
|
var {
|
|
21
13
|
error,
|
|
22
14
|
showDoc
|
|
23
15
|
} = _ref;
|
|
24
|
-
var [doc, setDoc] =
|
|
25
|
-
var getDoc =
|
|
16
|
+
var [doc, setDoc] = useState('');
|
|
17
|
+
var getDoc = useCallback(function () {
|
|
26
18
|
var _ref2 = _asyncToGenerator(function* (docUrl) {
|
|
27
|
-
var adaptor =
|
|
28
|
-
var errDoc = new
|
|
19
|
+
var adaptor = getEnvAdaptor();
|
|
20
|
+
var errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch);
|
|
29
21
|
setDoc(yield errDoc.content(docUrl));
|
|
30
22
|
});
|
|
31
23
|
return function (_x) {
|
|
32
24
|
return _ref2.apply(this, arguments);
|
|
33
25
|
};
|
|
34
26
|
}(), [error]);
|
|
35
|
-
|
|
27
|
+
useEffect(() => {
|
|
36
28
|
if (showDoc && error && error.documentation_url) {
|
|
37
29
|
getDoc(error.documentation_url);
|
|
38
30
|
}
|
|
39
31
|
}, [error, showDoc]);
|
|
40
|
-
return
|
|
32
|
+
return React.createElement(React.Fragment, null, React.createElement(APIErrorDetails, {
|
|
41
33
|
error: error
|
|
42
|
-
}), !showDoc &&
|
|
34
|
+
}), !showDoc && React.createElement(APIErrorDocLink, {
|
|
43
35
|
docUrl: (_error$documentation_ = error.documentation_url) !== null && _error$documentation_ !== void 0 ? _error$documentation_ : ''
|
|
44
|
-
}), showDoc && doc &&
|
|
36
|
+
}), showDoc && doc && React.createElement(ExtMarkdown, {
|
|
45
37
|
source: doc
|
|
46
38
|
}));
|
|
47
39
|
};
|
|
48
|
-
exports.APIErrorContent = APIErrorContent;
|
|
49
40
|
//# sourceMappingURL=APIErrorContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIErrorContent.js","names":["
|
|
1
|
+
{"version":3,"file":"APIErrorContent.js","names":["React","useCallback","useEffect","useState","ErrorDoc","getEnvAdaptor","ExtMarkdown","APIErrorDetails","APIErrorDocLink","apiErrorDisplayFetch","APIErrorContent","_ref","_error$documentation_","error","showDoc","doc","setDoc","getDoc","_ref2","_asyncToGenerator","docUrl","adaptor","errDoc","sdk","content","_x","apply","arguments","documentation_url","createElement","Fragment","source"],"sources":["../../../src/APIErrorDisplay/APIErrorContent.tsx"],"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 React, { useCallback, useEffect, useState } from 'react'\nimport { ErrorDoc } from '@looker/sdk-rtl'\nimport { getEnvAdaptor } from '../adaptorUtils'\nimport { ExtMarkdown } from '../ExtMarkdown'\nimport { APIErrorDetails } from './APIErrorDetails'\nimport { APIErrorDocLink } from './APIErrorDocLink'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { apiErrorDisplayFetch } from './utils'\n\n/**\n * Shows available content of an API Error response\n * @param error to display\n * @param showDoc true to retrieve the corresponding error markdown\n */\nexport const APIErrorContent = ({ error, showDoc }: APIErrorDisplayProps) => {\n const [doc, setDoc] = useState<string>('')\n const getDoc = useCallback(\n async (docUrl: string) => {\n const adaptor = getEnvAdaptor()\n const errDoc = new ErrorDoc(adaptor.sdk, apiErrorDisplayFetch)\n setDoc(await errDoc.content(docUrl))\n },\n [error]\n )\n\n useEffect(() => {\n if (showDoc && error && error.documentation_url) {\n getDoc(error.documentation_url)\n }\n }, [error, showDoc])\n\n return (\n <>\n <APIErrorDetails error={error} />\n {!showDoc && <APIErrorDocLink docUrl={error.documentation_url ?? ''} />}\n {showDoc && doc && <ExtMarkdown source={doc} />}\n </>\n )\n}\n"],"mappings":";;AA0BA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,oBAAoB,QAAQ,SAAS;AAO9C,OAAO,IAAMC,eAAe,GAAGC,IAAA,IAA8C;EAAA,IAAAC,qBAAA;EAAA,IAA7C;IAAEC,KAAK;IAAEC;EAA8B,CAAC,GAAAH,IAAA;EACtE,IAAM,CAACI,GAAG,EAAEC,MAAM,CAAC,GAAGb,QAAQ,CAAS,EAAE,CAAC;EAC1C,IAAMc,MAAM,GAAGhB,WAAW;IAAA,IAAAiB,KAAA,GAAAC,iBAAA,CACxB,WAAOC,MAAc,EAAK;MACxB,IAAMC,OAAO,GAAGhB,aAAa,CAAC,CAAC;MAC/B,IAAMiB,MAAM,GAAG,IAAIlB,QAAQ,CAACiB,OAAO,CAACE,GAAG,EAAEd,oBAAoB,CAAC;MAC9DO,MAAM,OAAOM,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAAC;IACtC,CAAC;IAAA,iBAAAK,EAAA;MAAA,OAAAP,KAAA,CAAAQ,KAAA,OAAAC,SAAA;IAAA;EAAA,KACD,CAACd,KAAK,CACR,CAAC;EAEDX,SAAS,CAAC,MAAM;IACd,IAAIY,OAAO,IAAID,KAAK,IAAIA,KAAK,CAACe,iBAAiB,EAAE;MAC/CX,MAAM,CAACJ,KAAK,CAACe,iBAAiB,CAAC;IACjC;EACF,CAAC,EAAE,CAACf,KAAK,EAAEC,OAAO,CAAC,CAAC;EAEpB,OACEd,KAAA,CAAA6B,aAAA,CAAA7B,KAAA,CAAA8B,QAAA,QACE9B,KAAA,CAAA6B,aAAA,CAACtB,eAAe;IAACM,KAAK,EAAEA;EAAM,CAAE,CAAC,EAChC,CAACC,OAAO,IAAId,KAAA,CAAA6B,aAAA,CAACrB,eAAe;IAACY,MAAM,GAAAR,qBAAA,GAAEC,KAAK,CAACe,iBAAiB,cAAAhB,qBAAA,cAAAA,qBAAA,GAAI;EAAG,CAAE,CAAC,EACtEE,OAAO,IAAIC,GAAG,IAAIf,KAAA,CAAA6B,aAAA,CAACvB,WAAW;IAACyB,MAAM,EAAEhB;EAAI,CAAE,CAC9C,CAAC;AAEP,CAAC"}
|
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.APIErrorDetails = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _components = require("@looker/components");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
var APIErrorDetails = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Span, Table, TableBody, TableDataCell, TableHead, TableHeaderCell, TableRow } from '@looker/components';
|
|
3
|
+
export var APIErrorDetails = _ref => {
|
|
11
4
|
var {
|
|
12
5
|
error
|
|
13
6
|
} = _ref;
|
|
14
|
-
if (!(error !== null && error !== void 0 && error.errors)) return
|
|
15
|
-
return
|
|
7
|
+
if (!(error !== null && error !== void 0 && error.errors)) return React.createElement(React.Fragment, null);
|
|
8
|
+
return React.createElement(Table, null, React.createElement(TableHead, null, React.createElement(TableRow, null, React.createElement(TableHeaderCell, {
|
|
16
9
|
p: "xsmall"
|
|
17
|
-
}, "Field"),
|
|
10
|
+
}, "Field"), React.createElement(TableHeaderCell, {
|
|
18
11
|
p: "xsmall"
|
|
19
|
-
}, "Code"),
|
|
12
|
+
}, "Code"), React.createElement(TableHeaderCell, {
|
|
20
13
|
p: "xsmall"
|
|
21
|
-
}, "Message"))),
|
|
14
|
+
}, "Message"))), React.createElement(TableBody, null, error.errors.map((_ref2, index) => {
|
|
22
15
|
var {
|
|
23
16
|
field,
|
|
24
17
|
code,
|
|
25
18
|
message
|
|
26
19
|
} = _ref2;
|
|
27
|
-
return
|
|
20
|
+
return React.createElement(TableRow, {
|
|
28
21
|
key: "".concat(field).concat(index)
|
|
29
|
-
},
|
|
22
|
+
}, React.createElement(TableDataCell, {
|
|
30
23
|
p: "xsmall"
|
|
31
|
-
}, field),
|
|
24
|
+
}, field), React.createElement(TableDataCell, {
|
|
32
25
|
p: "xsmall"
|
|
33
|
-
}, code),
|
|
26
|
+
}, code), React.createElement(TableDataCell, {
|
|
34
27
|
p: "xsmall"
|
|
35
|
-
},
|
|
28
|
+
}, React.createElement(Span, null, message)));
|
|
36
29
|
})));
|
|
37
30
|
};
|
|
38
|
-
exports.APIErrorDetails = APIErrorDetails;
|
|
39
31
|
//# sourceMappingURL=APIErrorDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIErrorDetails.js","names":["
|
|
1
|
+
{"version":3,"file":"APIErrorDetails.js","names":["React","Span","Table","TableBody","TableDataCell","TableHead","TableHeaderCell","TableRow","APIErrorDetails","_ref","error","errors","createElement","Fragment","p","map","_ref2","index","field","code","message","key","concat"],"sources":["../../../src/APIErrorDisplay/APIErrorDetails.tsx"],"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 { LookerSDKError } from '@looker/sdk-rtl'\nimport React from 'react'\nimport {\n Span,\n Table,\n TableBody,\n TableDataCell,\n TableHead,\n TableHeaderCell,\n TableRow,\n} from '@looker/components'\n\ninterface APIErrorDetailsProps {\n error: LookerSDKError\n}\n\n/**\n * Shows the detailed API errors table\n *\n * Because documentation_url is currently identical with the main documentation_url\n * it is not included in the table\n *\n * @param error to display\n */\nexport const APIErrorDetails = ({ error }: APIErrorDetailsProps) => {\n if (!error?.errors) return <></>\n\n return (\n <Table>\n <TableHead>\n <TableRow>\n <TableHeaderCell p=\"xsmall\">Field</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Code</TableHeaderCell>\n <TableHeaderCell p=\"xsmall\">Message</TableHeaderCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {error.errors.map(({ field, code, message }, index) => (\n <TableRow key={`${field}${index}`}>\n <TableDataCell p=\"xsmall\">{field}</TableDataCell>\n <TableDataCell p=\"xsmall\">{code}</TableDataCell>\n <TableDataCell p=\"xsmall\">\n <Span>{message}</Span>\n </T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MAACU,CAAC,EAAC;IAAQ,GAAEK,IAAoB,CAAC,EAChDnB,KAAA,CAAAY,aAAA,CAACR,aAAa;MAACU,CAAC,EAAC;IAAQ,GACvBd,KAAA,CAAAY,aAAA,CAACX,IAAI,QAAEmB,OAAc,CACR,CACP,CAAC;EAAA,CACZ,CACQ,CACN,CAAC;AAEZ,CAAC"}
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.APIErrorDialog = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _components = require("@looker/components");
|
|
9
|
-
var _APIErrorContent = require("./APIErrorContent");
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
var APIErrorDialog = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Dialog, DialogLayout } from '@looker/components';
|
|
3
|
+
import { APIErrorContent } from './APIErrorContent';
|
|
4
|
+
import { errorHeading } from './utils';
|
|
5
|
+
export var APIErrorDialog = _ref => {
|
|
13
6
|
var {
|
|
14
7
|
error,
|
|
15
8
|
isOpen,
|
|
16
9
|
setOpen,
|
|
17
10
|
showDoc = false
|
|
18
11
|
} = _ref;
|
|
19
|
-
return
|
|
12
|
+
return React.createElement(Dialog, {
|
|
20
13
|
isOpen: isOpen,
|
|
21
|
-
content:
|
|
22
|
-
header:
|
|
23
|
-
footer:
|
|
14
|
+
content: React.createElement(DialogLayout, {
|
|
15
|
+
header: errorHeading(error),
|
|
16
|
+
footer: React.createElement(Button, {
|
|
24
17
|
size: "xsmall",
|
|
25
18
|
onClick: () => setOpen && setOpen(false)
|
|
26
19
|
}, "OK")
|
|
27
|
-
},
|
|
20
|
+
}, React.createElement(APIErrorContent, {
|
|
28
21
|
error: error,
|
|
29
22
|
showDoc: showDoc
|
|
30
23
|
}))
|
|
31
24
|
});
|
|
32
25
|
};
|
|
33
|
-
exports.APIErrorDialog = APIErrorDialog;
|
|
34
26
|
//# sourceMappingURL=APIErrorDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIErrorDialog.js","names":["
|
|
1
|
+
{"version":3,"file":"APIErrorDialog.js","names":["React","Button","Dialog","DialogLayout","APIErrorContent","errorHeading","APIErrorDialog","_ref","error","isOpen","setOpen","showDoc","createElement","content","header","footer","size","onClick"],"sources":["../../../src/APIErrorDisplay/APIErrorDialog.tsx"],"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 React from 'react'\nimport { Button, Dialog, DialogLayout } from '@looker/components'\nimport type { APIErrorDisplayProps } from './APIErrorDisplay'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\ninterface APIErrorDialogProps extends APIErrorDisplayProps {\n /** toggle for dialog being open */\n isOpen: boolean\n /** callback for toggling the dialog display */\n setOpen: (open: boolean) => void\n}\n\nexport const APIErrorDialog = ({\n error,\n isOpen,\n setOpen,\n showDoc = false,\n}: APIErrorDialogProps) => (\n <Dialog\n isOpen={isOpen}\n content={\n <DialogLayout\n header={errorHeading(error)}\n footer={\n <Button size=\"xsmall\" onClick={() => setOpen && setOpen(false)}>\n OK\n </Button>\n }\n >\n <APIErrorContent error={error} showDoc={showDoc} />\n </DialogLayout>\n }\n />\n)\n"],"mappings":"AA0BA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,EAAEC,MAAM,EAAEC,YAAY,QAAQ,oBAAoB;AAEjE,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,SAAS;AAStC,OAAO,IAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAC7BC,KAAK;IACLC,MAAM;IACNC,OAAO;IACPC,OAAO,GAAG;EACS,CAAC,GAAAJ,IAAA;EAAA,OACpBP,KAAA,CAAAY,aAAA,CAACV,MAAM;IACLO,MAAM,EAAEA,MAAO;IACfI,OAAO,EACLb,KAAA,CAAAY,aAAA,CAACT,YAAY;MACXW,MAAM,EAAET,YAAY,CAACG,KAAK,CAAE;MAC5BO,MAAM,EACJf,KAAA,CAAAY,aAAA,CAACX,MAAM;QAACe,IAAI,EAAC,QAAQ;QAACC,OAAO,EAAEA,CAAA,KAAMP,OAAO,IAAIA,OAAO,CAAC,KAAK;MAAE,GAAC,IAExD;IACT,GAEDV,KAAA,CAAAY,aAAA,CAACR,eAAe;MAACI,KAAK,EAAEA,KAAM;MAACG,OAAO,EAAEA;IAAQ,CAAE,CACtC;EACf,CACF,CAAC;AAAA,CACH"}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.APIErrorDisplay = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _components = require("@looker/components");
|
|
9
|
-
var _APIErrorContent = require("./APIErrorContent");
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
var APIErrorDisplay = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Heading, SpaceVertical } from '@looker/components';
|
|
3
|
+
import { APIErrorContent } from './APIErrorContent';
|
|
4
|
+
import { errorHeading } from './utils';
|
|
5
|
+
export var APIErrorDisplay = _ref => {
|
|
13
6
|
var {
|
|
14
7
|
error,
|
|
15
8
|
showDoc = false
|
|
16
9
|
} = _ref;
|
|
17
|
-
return
|
|
10
|
+
return React.createElement(React.Fragment, null, error && React.createElement(SpaceVertical, null, React.createElement(Heading, {
|
|
18
11
|
type: "h2"
|
|
19
|
-
},
|
|
12
|
+
}, errorHeading(error)), React.createElement(APIErrorContent, {
|
|
20
13
|
error: error,
|
|
21
14
|
showDoc: showDoc
|
|
22
15
|
})));
|
|
23
16
|
};
|
|
24
|
-
exports.APIErrorDisplay = APIErrorDisplay;
|
|
25
17
|
//# sourceMappingURL=APIErrorDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIErrorDisplay.js","names":["
|
|
1
|
+
{"version":3,"file":"APIErrorDisplay.js","names":["React","Heading","SpaceVertical","APIErrorContent","errorHeading","APIErrorDisplay","_ref","error","showDoc","createElement","Fragment","type"],"sources":["../../../src/APIErrorDisplay/APIErrorDisplay.tsx"],"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 React from 'react'\nimport type { LookerSDKError } from '@looker/sdk-rtl'\nimport { Heading, SpaceVertical } from '@looker/components'\nimport { APIErrorContent } from './APIErrorContent'\nimport { errorHeading } from './utils'\n\nexport interface APIErrorDisplayProps {\n /** Populated SDK error information, which may contain detailed errors */\n error: LookerSDKError\n /** true to retrieve the markdown error document from the CDN and display it instead of a link */\n showDoc?: boolean\n}\n\n/**\n * Show API error information in the parent React component\n * @param error to display\n * @param showDoc true to fetch the error document markdown. false for a clickable link\n */\nexport const APIErrorDisplay = ({\n error,\n showDoc = false,\n}: APIErrorDisplayProps) => {\n return (\n <>\n {error && (\n <SpaceVertical>\n <Heading type=\"h2\">{errorHeading(error)}</Heading>\n <APIErrorContent error={error} showDoc={showDoc} />\n </SpaceVertical>\n )}\n </>\n )\n}\n"],"mappings":"AA0BA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,OAAO,EAAEC,aAAa,QAAQ,oBAAoB;AAC3D,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,SAAS;AActC,OAAO,IAAMC,eAAe,GAAGC,IAAA,IAGH;EAAA,IAHI;IAC9BC,KAAK;IACLC,OAAO,GAAG;EACU,CAAC,GAAAF,IAAA;EACrB,OACEN,KAAA,CAAAS,aAAA,CAAAT,KAAA,CAAAU,QAAA,QACGH,KAAK,IACJP,KAAA,CAAAS,aAAA,CAACP,aAAa,QACZF,KAAA,CAAAS,aAAA,CAACR,OAAO;IAACU,IAAI,EAAC;EAAI,GAAEP,YAAY,CAACG,KAAK,CAAW,CAAC,EAClDP,KAAA,CAAAS,aAAA,CAACN,eAAe;IAACI,KAAK,EAAEA,KAAM;IAACC,OAAO,EAAEA;EAAQ,CAAE,CACrC,CAEjB,CAAC;AAEP,CAAC"}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.APIErrorDocLink = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _components = require("@looker/components");
|
|
9
|
-
var _adaptorUtils = require("../adaptorUtils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var APIErrorDocLink = _ref => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from '@looker/components';
|
|
3
|
+
import { getEnvAdaptor } from '../adaptorUtils';
|
|
4
|
+
export var APIErrorDocLink = _ref => {
|
|
12
5
|
var {
|
|
13
6
|
docUrl
|
|
14
7
|
} = _ref;
|
|
15
8
|
var onClick = e => {
|
|
16
9
|
e.preventDefault();
|
|
17
|
-
var adaptor =
|
|
10
|
+
var adaptor = getEnvAdaptor();
|
|
18
11
|
adaptor.openBrowserWindow(e.currentTarget.href);
|
|
19
12
|
};
|
|
20
|
-
if (!docUrl) return
|
|
21
|
-
return
|
|
13
|
+
if (!docUrl) return React.createElement(React.Fragment, null);
|
|
14
|
+
return React.createElement(Link, {
|
|
22
15
|
href: docUrl,
|
|
23
16
|
key: docUrl,
|
|
24
17
|
onClick: onClick
|
|
25
18
|
}, "More information");
|
|
26
19
|
};
|
|
27
|
-
exports.APIErrorDocLink = APIErrorDocLink;
|
|
28
20
|
//# sourceMappingURL=APIErrorDocLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIErrorDocLink.js","names":["
|
|
1
|
+
{"version":3,"file":"APIErrorDocLink.js","names":["React","Link","getEnvAdaptor","APIErrorDocLink","_ref","docUrl","onClick","e","preventDefault","adaptor","openBrowserWindow","currentTarget","href","createElement","Fragment","key"],"sources":["../../../src/APIErrorDisplay/APIErrorDocLink.tsx"],"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 React from 'react'\nimport { Link } from '@looker/components'\nimport { getEnvAdaptor } from '../adaptorUtils'\n\ninterface APIErrorDocLinkProps {\n docUrl?: string\n}\n\nexport const APIErrorDocLink = ({ docUrl }: APIErrorDocLinkProps) => {\n const onClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault()\n const adaptor = getEnvAdaptor()\n adaptor.openBrowserWindow(e.currentTarget.href)\n }\n\n if (!docUrl) return <></>\n return (\n <Link href={docUrl} key={docUrl} onClick={onClick}>\n More information\n </Link>\n )\n}\n"],"mappings":"AA0BA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,oBAAoB;AACzC,SAASC,aAAa,QAAQ,iBAAiB;AAM/C,OAAO,IAAMC,eAAe,GAAGC,IAAA,IAAsC;EAAA,IAArC;IAAEC;EAA6B,CAAC,GAAAD,IAAA;EAC9D,IAAME,OAAO,GAAIC,CAAsC,IAAK;IAC1DA,CAAC,CAACC,cAAc,CAAC,CAAC;IAClB,IAAMC,OAAO,GAAGP,aAAa,CAAC,CAAC;IAC/BO,OAAO,CAACC,iBAAiB,CAACH,CAAC,CAACI,aAAa,CAACC,IAAI,CAAC;EACjD,CAAC;EAED,IAAI,CAACP,MAAM,EAAE,OAAOL,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAc,QAAA,MAAI,CAAC;EACzB,OACEd,KAAA,CAAAa,aAAA,CAACZ,IAAI;IAACW,IAAI,EAAEP,MAAO;IAACU,GAAG,EAAEV,MAAO;IAACC,OAAO,EAAEA;EAAQ,GAAC,kBAE7C,CAAC;AAEX,CAAC"}
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
apiErrorDisplayFetch: true
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "apiErrorDisplayFetch", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function get() {
|
|
12
|
-
return _utils.apiErrorDisplayFetch;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
var _APIErrorDialog = require("./APIErrorDialog");
|
|
16
|
-
Object.keys(_APIErrorDialog).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _APIErrorDialog[key]) return;
|
|
20
|
-
Object.defineProperty(exports, key, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _APIErrorDialog[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _APIErrorDisplay = require("./APIErrorDisplay");
|
|
28
|
-
Object.keys(_APIErrorDisplay).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _APIErrorDisplay[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _APIErrorDisplay[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _utils = require("./utils");
|
|
1
|
+
export * from './APIErrorDialog';
|
|
2
|
+
export * from './APIErrorDisplay';
|
|
3
|
+
export { apiErrorDisplayFetch } from './utils';
|
|
40
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["apiErrorDisplayFetch"],"sources":["../../../src/APIErrorDisplay/index.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\nexport * from './APIErrorDialog'\nexport * from './APIErrorDisplay'\nexport { apiErrorDisplayFetch } from './utils'\n"],"mappings":"AA0BA,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,SAASA,oBAAoB,QAAQ,SAAS"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.errorHeading = exports.apiErrorDisplayFetch = void 0;
|
|
7
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); } }
|
|
8
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); }); }; }
|
|
9
|
-
var errorHeading = error => error.message || 'Unknown error';
|
|
10
|
-
|
|
11
|
-
var apiErrorDisplayFetch = function () {
|
|
3
|
+
export var errorHeading = error => error.message || 'Unknown error';
|
|
4
|
+
export var apiErrorDisplayFetch = function () {
|
|
12
5
|
var _ref = _asyncToGenerator(function* (_sdk, url) {
|
|
13
6
|
var fetched = yield fetch(url, {
|
|
14
7
|
mode: 'cors'
|
|
@@ -24,5 +17,4 @@ var apiErrorDisplayFetch = function () {
|
|
|
24
17
|
return _ref.apply(this, arguments);
|
|
25
18
|
};
|
|
26
19
|
}();
|
|
27
|
-
exports.apiErrorDisplayFetch = apiErrorDisplayFetch;
|
|
28
20
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["errorHeading","error","message","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["errorHeading","error","message","apiErrorDisplayFetch","_ref","_asyncToGenerator","_sdk","url","fetched","fetch","mode","result","text","stop","indexOf","substring","trim","_x","_x2","apply","arguments"],"sources":["../../../src/APIErrorDisplay/utils.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 { LookerSDKError, IAPIMethods } from '@looker/sdk-rtl'\n\n/**\n * Default the heading to 'Unknown error' if error.message is blank for any reason\n * @param error for heading\n */\nexport const errorHeading = (error: LookerSDKError) =>\n error.message || 'Unknown error'\n\n/**\n * this callback function used by the ErrorDoc constructor gets and truncates\n * API error documents for use within API Explorer\n * @param _sdk required as a parameter, but it's ignored in this function\n * @param url of document (either index.json or md) to fetch\n */\nexport const apiErrorDisplayFetch = async (_sdk: IAPIMethods, url: string) => {\n const fetched = await fetch(url, { mode: 'cors' })\n let result = await fetched.text()\n const stop = result.indexOf('## API Response Type')\n if (stop > 0) {\n result = result.substring(0, stop - 1).trim()\n }\n return result\n}\n"],"mappings":";;AAgCA,OAAO,IAAMA,YAAY,GAAIC,KAAqB,IAChDA,KAAK,CAACC,OAAO,IAAI,eAAe;AAQlC,OAAO,IAAMC,oBAAoB;EAAA,IAAAC,IAAA,GAAAC,iBAAA,CAAG,WAAOC,IAAiB,EAAEC,GAAW,EAAK;IAC5E,IAAMC,OAAO,SAASC,KAAK,CAACF,GAAG,EAAE;MAAEG,IAAI,EAAE;IAAO,CAAC,CAAC;IAClD,IAAIC,MAAM,SAASH,OAAO,CAACI,IAAI,CAAC,CAAC;IACjC,IAAMC,IAAI,GAAGF,MAAM,CAACG,OAAO,CAAC,sBAAsB,CAAC;IACnD,IAAID,IAAI,GAAG,CAAC,EAAE;MACZF,MAAM,GAAGA,MAAM,CAACI,SAAS,CAAC,CAAC,EAAEF,IAAI,GAAG,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC;IAC/C;IACA,OAAOL,MAAM;EACf,CAAC;EAAA,gBARYR,oBAAoBA,CAAAc,EAAA,EAAAC,GAAA;IAAA,OAAAd,IAAA,CAAAe,KAAA,OAAAC,SAAA;EAAA;AAAA,GAQhC"}
|