@looker/extension-utils 0.1.32 → 0.1.34
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 +178 -199
- package/README.md +21 -21
- package/lib/APIErrorDisplay/APIErrorContent.d.ts +2 -2
- package/lib/APIErrorDisplay/APIErrorContent.js +2 -2
- package/lib/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDetails.d.ts +2 -2
- package/lib/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDialog.d.ts +2 -2
- package/lib/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDisplay.d.ts +2 -2
- package/lib/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/APIErrorDisplay/APIErrorDocLink.d.ts +2 -2
- package/lib/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/APIErrorDisplay/index.js.map +1 -1
- package/lib/APIErrorDisplay/utils.d.ts +1 -1
- package/lib/APIErrorDisplay/utils.js +1 -2
- package/lib/APIErrorDisplay/utils.js.map +1 -1
- package/lib/ExtMarkdown.js.map +1 -1
- package/lib/OAuthForm/index.js.map +1 -1
- package/lib/OAuthForm/src/components/CollapserCard.js.map +1 -1
- package/lib/OAuthForm/src/components/ConfigHeading.js +1 -2
- package/lib/OAuthForm/src/components/ConfigHeading.js.map +1 -1
- package/lib/OAuthForm/src/components/OAuthForm.d.ts +2 -1
- package/lib/OAuthForm/src/components/OAuthForm.js +3 -4
- package/lib/OAuthForm/src/components/OAuthForm.js.map +1 -1
- package/lib/OAuthForm/src/components/index.js.map +1 -1
- package/lib/OAuthForm/src/index.js.map +1 -1
- package/lib/OAuthForm/src/state/index.js.map +1 -1
- package/lib/OAuthForm/src/state/sagas.js.map +1 -1
- package/lib/OAuthForm/src/state/slice.js +8 -12
- package/lib/OAuthForm/src/state/slice.js.map +1 -1
- package/lib/OAuthForm/src/utils.d.ts +1 -1
- package/lib/OAuthForm/src/utils.js +6 -8
- package/lib/OAuthForm/src/utils.js.map +1 -1
- package/lib/OAuthScene.js +2 -2
- package/lib/OAuthScene.js.map +1 -1
- package/lib/adaptorUtils.js.map +1 -1
- package/lib/authUtils.d.ts +1 -1
- package/lib/authUtils.js +4 -4
- package/lib/authUtils.js.map +1 -1
- package/lib/browserAdaptor.js +2 -2
- package/lib/browserAdaptor.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorContent.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDetails.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDialog.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDisplay.js.map +1 -1
- package/lib/esm/APIErrorDisplay/APIErrorDocLink.js.map +1 -1
- package/lib/esm/APIErrorDisplay/index.js.map +1 -1
- package/lib/esm/APIErrorDisplay/utils.js.map +1 -1
- package/lib/esm/ExtMarkdown.js.map +1 -1
- package/lib/esm/OAuthForm/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/CollapserCard.js +2 -2
- package/lib/esm/OAuthForm/src/components/CollapserCard.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/ConfigHeading.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/OAuthForm.js +1 -1
- package/lib/esm/OAuthForm/src/components/OAuthForm.js.map +1 -1
- package/lib/esm/OAuthForm/src/components/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/index.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/sagas.js +2 -2
- package/lib/esm/OAuthForm/src/state/sagas.js.map +1 -1
- package/lib/esm/OAuthForm/src/state/slice.js +4 -4
- package/lib/esm/OAuthForm/src/state/slice.js.map +1 -1
- package/lib/esm/OAuthForm/src/utils.js +4 -4
- package/lib/esm/OAuthForm/src/utils.js.map +1 -1
- package/lib/esm/OAuthScene.js.map +1 -1
- package/lib/esm/adaptorUtils.js.map +1 -1
- package/lib/esm/authUtils.js +4 -4
- package/lib/esm/authUtils.js.map +1 -1
- package/lib/esm/browserAdaptor.js +2 -2
- package/lib/esm/browserAdaptor.js.map +1 -1
- package/lib/esm/extensionAdaptor.js +2 -2
- package/lib/esm/extensionAdaptor.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/extensionAdaptor.d.ts +1 -1
- package/lib/extensionAdaptor.js +2 -2
- package/lib/extensionAdaptor.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +18 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sagas.js","names":["_typedReduxSaga","require","_utils","_slice","getLocalStorageConfig","configKey","EmptyConfig","base_url","looker_url","data","localStorage","getItem","result","JSON","parse","initSaga","action","initSuccessAction","setFailureAction","OAuthFormActions","call","payload","put","error","message","setUrlSaga","updateValidationMessages","setUrlActionSuccess","url","validateUrl","value","Error","concat","elementName","name","newMessage","type","clearConfigSaga","clearConfigActionSuccess","updateMessageBarAction","setHasConfig","isAuthenticated","removeItem","intent","text","verifyConfigSaga","apiServerUrl","select","storeState","formState","OAuthFormSlice","verifyConfigActionFailure","verifyConfigActionSuccess","clearMessageBarAction","versionsUrl","versions","getVersions","web_server_url","saveConfigSaga","saveConfigActionSuccess","client_id","redirect_uri","api_server_url","setItem","stringify","saga","initAction","setUrlAction","clearConfigAction","verifyConfigAction","saveConfigAction","takeEvery"],"sources":["../../../../src/OAuthForm/src/state/sagas.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 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 { PayloadAction } from '@reduxjs/toolkit'\nimport { takeEvery, put, call, select } from 'typed-redux-saga'\nimport type { ConfigValues } from '../utils'\nimport { getVersions, validateUrl } from '../utils'\nimport type {\n ClearConfigActionPayload,\n SetUrlActionPayload,\n OAuthFormState,\n SaveConfigPayload,\n} from './slice'\nimport { OAuthFormSlice, OAuthFormActions } from './slice'\n\n/**\n * get saved configData from localStorage key\n * @param configKey key that config will be saved under in local storage\n * @returns\n */\nconst getLocalStorageConfig = (configKey: string): ConfigValues => {\n const EmptyConfig = {\n base_url: '',\n looker_url: '',\n }\n const data = localStorage.getItem(configKey)\n const result = data ? JSON.parse(data) : EmptyConfig\n\n return result\n}\n\n/**\n * checks for saved configData in localStorage\n */\nfunction* initSaga(action: PayloadAction<string>) {\n const { initSuccessAction, setFailureAction } = OAuthFormActions\n try {\n const result = yield* call(getLocalStorageConfig, action.payload)\n yield* put(initSuccessAction(result))\n } catch (error: any) {\n yield* put(setFailureAction(error.message))\n }\n}\n\n/**\n * updates the new url and adds or removes form validation message\n * @param action containing name and value of form element changed\n */\nfunction* setUrlSaga(action: PayloadAction<SetUrlActionPayload>) {\n const { updateValidationMessages, setUrlActionSuccess } = OAuthFormActions\n try {\n const url = validateUrl(action.payload.value)\n if (!url) throw new Error(`${action.payload.value} is not a valid url`)\n\n // clear the error message if one was there\n yield* put(\n updateValidationMessages({\n elementName: action.payload.name,\n newMessage: null,\n })\n )\n } catch (error: any) {\n yield* put(\n updateValidationMessages({\n elementName: action.payload.name,\n newMessage: {\n message: error.message,\n type: 'error',\n },\n })\n )\n } finally {\n // update the form element\n const url = validateUrl(action.payload.value)\n yield* put(setUrlActionSuccess(url || action.payload.value))\n }\n}\n\n/**\n * clears form, removes local storage config key and triggers callback function\n * @param action containing the localstorage key to clear, a callback function, and if the user is already authenticated\n */\nfunction* clearConfigSaga(action: PayloadAction<ClearConfigActionPayload>) {\n const { clearConfigActionSuccess, setFailureAction, updateMessageBarAction } =\n OAuthFormActions\n try {\n const { configKey, setHasConfig, isAuthenticated } = action.payload\n localStorage.removeItem(configKey)\n if (setHasConfig) setHasConfig(false)\n if (isAuthenticated) {\n yield* put(\n updateMessageBarAction({\n intent: 'warn',\n text: 'Please reload the browser page to log out',\n })\n )\n }\n yield* put(clearConfigActionSuccess())\n } catch (error: any) {\n yield* put(setFailureAction(error.message))\n }\n}\n\n/**\n * verify button clicked, verifies apiServerUrl and populates OAuth server URL if valid\n */\nfunction* verifyConfigSaga() {\n const apiServerUrl = yield* select((storeState) => {\n const formState: OAuthFormState = storeState[OAuthFormSlice.name]\n return formState.apiServerUrl\n })\n const {\n verifyConfigActionFailure,\n verifyConfigActionSuccess,\n clearMessageBarAction,\n } = OAuthFormActions\n\n try {\n yield* put(clearMessageBarAction())\n const versionsUrl = `${apiServerUrl}/versions`\n\n const versions = yield* call(getVersions, versionsUrl)\n if (!versions) throw new Error()\n\n yield* put(verifyConfigActionSuccess(versions.web_server_url))\n } catch (error: any) {\n yield* put(verifyConfigActionFailure(error.message))\n }\n}\n\n/**\n * save button clicked, verify api server url and if valid save config data to localstorage\n * @param action containing configKey, callback function, client_id and redirect_uri\n */\nfunction* saveConfigSaga(action: PayloadAction<SaveConfigPayload>) {\n const apiServerUrl = yield* select((storeState) => {\n const formState: OAuthFormState = storeState[OAuthFormSlice.name]\n return formState.apiServerUrl\n })\n const {\n verifyConfigActionFailure,\n clearMessageBarAction,\n saveConfigActionSuccess,\n } = OAuthFormActions\n const { configKey, setHasConfig, client_id, redirect_uri } = action.payload\n\n try {\n yield* put(clearMessageBarAction())\n const versionsUrl = `${apiServerUrl}/versions`\n\n const versions = yield* call(getVersions, versionsUrl)\n if (!versions) throw new Error()\n\n const data = {\n base_url: versions.api_server_url,\n looker_url: versions.web_server_url,\n client_id,\n redirect_uri,\n }\n localStorage.setItem(configKey, JSON.stringify(data))\n if (setHasConfig) setHasConfig(true)\n\n yield* put(\n saveConfigActionSuccess({\n base_url: versions.api_server_url,\n looker_url: versions.web_server_url,\n })\n )\n } catch (error: any) {\n yield* put(verifyConfigActionFailure(error.message))\n }\n}\n\nexport function* saga() {\n const {\n initAction,\n setUrlAction,\n clearConfigAction,\n verifyConfigAction,\n saveConfigAction,\n } = OAuthFormActions\n yield* takeEvery(initAction, initSaga)\n yield* takeEvery(setUrlAction, setUrlSaga)\n yield* takeEvery(clearConfigAction, clearConfigSaga)\n yield* takeEvery(verifyConfigAction, verifyConfigSaga)\n yield* takeEvery(saveConfigAction, saveConfigSaga)\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AAOA,IAAMG,qBAAqB,GAAIC,SAAiB,IAAmB;EACjE,IAAMC,WAAW,GAAG;IAClBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACD,IAAMC,IAAI,GAAGC,YAAY,CAACC,OAAO,CAACN,SAAS,CAAC;EAC5C,IAAMO,MAAM,GAAGH,IAAI,GAAGI,IAAI,CAACC,KAAK,CAACL,IAAI,CAAC,GAAGH,WAAW;EAEpD,OAAOM,MAAM;AACf,CAAC;AAKD,UAAUG,QAAQA,CAACC,MAA6B,EAAE;EAChD,IAAM;IAAEC,iBAAiB;IAAEC;EAAiB,CAAC,GAAGC,uBAAgB;EAChE,IAAI;IACF,IA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QAAQ,CAACE;IACvB,CAAC,CACH,CAAC;EACH,CAAC,CAAC,OAAOlC,KAAU,EAAE;IACnB,OAAO,IAAAD,mBAAG,EAAC6B,yBAAyB,CAAC5B,KAAK,CAACC,OAAO,CAAC,CAAC;EACtD;AACF;AAEO,UAAUyC,IAAIA,CAAA,EAAG;EACtB,IAAM;IACJC,UAAU;IACVC,YAAY;IACZC,iBAAiB;IACjBC,kBAAkB;IAClBC;EACF,CAAC,GAAGnD,uBAAgB;EACpB,OAAO,IAAAoD,yBAAS,EAACL,UAAU,EAAEnD,QAAQ,CAAC;EACtC,OAAO,IAAAwD,yBAAS,EAACJ,YAAY,EAAE1C,UAAU,CAAC;EAC1C,OAAO,IAAA8C,yBAAS,EAACH,iBAAiB,EAAE/B,eAAe,CAAC;EACpD,OAAO,IAAAkC,yBAAS,EAACF,kBAAkB,EAAExB,gBAAgB,CAAC;EACtD,OAAO,IAAA0B,yBAAS,EAACD,gBAAgB,EAAEZ,cAAc,CAAC;AACpD"}
|
|
1
|
+
{"version":3,"file":"sagas.js","names":["_typedReduxSaga","require","_utils","_slice","getLocalStorageConfig","configKey","EmptyConfig","base_url","looker_url","data","localStorage","getItem","result","JSON","parse","initSaga","action","initSuccessAction","setFailureAction","OAuthFormActions","call","payload","put","error","message","setUrlSaga","updateValidationMessages","setUrlActionSuccess","url","validateUrl","value","Error","concat","elementName","name","newMessage","type","clearConfigSaga","clearConfigActionSuccess","updateMessageBarAction","setHasConfig","isAuthenticated","removeItem","intent","text","verifyConfigSaga","apiServerUrl","select","storeState","formState","OAuthFormSlice","verifyConfigActionFailure","verifyConfigActionSuccess","clearMessageBarAction","versionsUrl","versions","getVersions","web_server_url","saveConfigSaga","saveConfigActionSuccess","client_id","redirect_uri","api_server_url","setItem","stringify","saga","initAction","setUrlAction","clearConfigAction","verifyConfigAction","saveConfigAction","takeEvery"],"sources":["../../../../src/OAuthForm/src/state/sagas.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 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 { PayloadAction } from '@reduxjs/toolkit';\nimport { call, put, select, takeEvery } from 'typed-redux-saga';\nimport type { ConfigValues } from '../utils';\nimport { getVersions, validateUrl } from '../utils';\nimport type {\n ClearConfigActionPayload,\n OAuthFormState,\n SaveConfigPayload,\n SetUrlActionPayload,\n} from './slice';\nimport { OAuthFormActions, OAuthFormSlice } from './slice';\n\n/**\n * get saved configData from localStorage key\n * @param configKey key that config will be saved under in local storage\n * @returns\n */\nconst getLocalStorageConfig = (configKey: string): ConfigValues => {\n const EmptyConfig = {\n base_url: '',\n looker_url: '',\n };\n const data = localStorage.getItem(configKey);\n const result = data ? JSON.parse(data) : EmptyConfig;\n\n return result;\n};\n\n/**\n * checks for saved configData in localStorage\n */\nfunction* initSaga(action: PayloadAction<string>) {\n const { initSuccessAction, setFailureAction } = OAuthFormActions;\n try {\n const result = yield* call(getLocalStorageConfig, action.payload);\n yield* put(initSuccessAction(result));\n } catch (error: any) {\n yield* put(setFailureAction(error.message));\n }\n}\n\n/**\n * updates the new url and adds or removes form validation message\n * @param action containing name and value of form element changed\n */\nfunction* setUrlSaga(action: PayloadAction<SetUrlActionPayload>) {\n const { updateValidationMessages, setUrlActionSuccess } = OAuthFormActions;\n try {\n const url = validateUrl(action.payload.value);\n if (!url) throw new Error(`${action.payload.value} is not a valid url`);\n\n // clear the error message if one was there\n yield* put(\n updateValidationMessages({\n elementName: action.payload.name,\n newMessage: null,\n })\n );\n } catch (error: any) {\n yield* put(\n updateValidationMessages({\n elementName: action.payload.name,\n newMessage: {\n message: error.message,\n type: 'error',\n },\n })\n );\n } finally {\n // update the form element\n const url = validateUrl(action.payload.value);\n yield* put(setUrlActionSuccess(url || action.payload.value));\n }\n}\n\n/**\n * clears form, removes local storage config key and triggers callback function\n * @param action containing the localstorage key to clear, a callback function, and if the user is already authenticated\n */\nfunction* clearConfigSaga(action: PayloadAction<ClearConfigActionPayload>) {\n const { clearConfigActionSuccess, setFailureAction, updateMessageBarAction } =\n OAuthFormActions;\n try {\n const { configKey, setHasConfig, isAuthenticated } = action.payload;\n localStorage.removeItem(configKey);\n if (setHasConfig) setHasConfig(false);\n if (isAuthenticated) {\n yield* put(\n updateMessageBarAction({\n intent: 'warn',\n text: 'Please reload the browser page to log out',\n })\n );\n }\n yield* put(clearConfigActionSuccess());\n } catch (error: any) {\n yield* put(setFailureAction(error.message));\n }\n}\n\n/**\n * verify button clicked, verifies apiServerUrl and populates OAuth server URL if valid\n */\nfunction* verifyConfigSaga() {\n const apiServerUrl = yield* select((storeState) => {\n const formState: OAuthFormState = storeState[OAuthFormSlice.name];\n return formState.apiServerUrl;\n });\n const {\n verifyConfigActionFailure,\n verifyConfigActionSuccess,\n clearMessageBarAction,\n } = OAuthFormActions;\n\n try {\n yield* put(clearMessageBarAction());\n const versionsUrl = `${apiServerUrl}/versions`;\n\n const versions = yield* call(getVersions, versionsUrl);\n if (!versions) throw new Error();\n\n yield* put(verifyConfigActionSuccess(versions.web_server_url));\n } catch (error: any) {\n yield* put(verifyConfigActionFailure(error.message));\n }\n}\n\n/**\n * save button clicked, verify api server url and if valid save config data to localstorage\n * @param action containing configKey, callback function, client_id and redirect_uri\n */\nfunction* saveConfigSaga(action: PayloadAction<SaveConfigPayload>) {\n const apiServerUrl = yield* select((storeState) => {\n const formState: OAuthFormState = storeState[OAuthFormSlice.name];\n return formState.apiServerUrl;\n });\n const {\n verifyConfigActionFailure,\n clearMessageBarAction,\n saveConfigActionSuccess,\n } = OAuthFormActions;\n const { configKey, setHasConfig, client_id, redirect_uri } = action.payload;\n\n try {\n yield* put(clearMessageBarAction());\n const versionsUrl = `${apiServerUrl}/versions`;\n\n const versions = yield* call(getVersions, versionsUrl);\n if (!versions) throw new Error();\n\n const data = {\n base_url: versions.api_server_url,\n looker_url: versions.web_server_url,\n client_id,\n redirect_uri,\n };\n localStorage.setItem(configKey, JSON.stringify(data));\n if (setHasConfig) setHasConfig(true);\n\n yield* put(\n saveConfigActionSuccess({\n base_url: versions.api_server_url,\n looker_url: versions.web_server_url,\n })\n );\n } catch (error: any) {\n yield* put(verifyConfigActionFailure(error.message));\n }\n}\n\nexport function* saga() {\n const {\n initAction,\n setUrlAction,\n clearConfigAction,\n verifyConfigAction,\n saveConfigAction,\n } = OAuthFormActions;\n yield* takeEvery(initAction, initSaga);\n yield* takeEvery(setUrlAction, setUrlSaga);\n yield* takeEvery(clearConfigAction, clearConfigSaga);\n yield* takeEvery(verifyConfigAction, verifyConfigSaga);\n yield* takeEvery(saveConfigAction, saveConfigSaga);\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AAOA,IAAMG,qBAAqB,GAAIC,SAAiB,IAAmB;EACjE,IAAMC,WAAW,GAAG;IAClBC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACD,IAAMC,IAAI,GAAGC,YAAY,CAACC,OA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AC;IACDnD,YAAY,CAACqD,OAAO,CAAC1D,SAAS,EAAEQ,IAAI,CAACmD,SAAS,CAACvD,IAAI,CAAC,CAAC;IACrD,IAAI+B,YAAY,EAAEA,YAAY,CAAC,IAAI,CAAC;IAEpC,OAAO,IAAAlB,mBAAG,EACRqC,uBAAuB,CAAC;MACtBpD,QAAQ,EAAEgD,QAAQ,CAACO,cAAc;MACjCtD,UAAU,EAAE+C,QAAQ,CAACE;IACvB,CAAC,CACH,CAAC;EACH,CAAC,CAAC,OAAOlC,KAAU,EAAE;IACnB,OAAO,IAAAD,mBAAG,EAAC6B,yBAAyB,CAAC5B,KAAK,CAACC,OAAO,CAAC,CAAC;EACtD;AACF;AAEO,UAAUyC,IAAIA,CAAA,EAAG;EACtB,IAAM;IACJC,UAAU;IACVC,YAAY;IACZC,iBAAiB;IACjBC,kBAAkB;IAClBC;EACF,CAAC,GAAGnD,uBAAgB;EACpB,OAAO,IAAAoD,yBAAS,EAACL,UAAU,EAAEnD,QAAQ,CAAC;EACtC,OAAO,IAAAwD,yBAAS,EAACJ,YAAY,EAAE1C,UAAU,CAAC;EAC1C,OAAO,IAAA8C,yBAAS,EAACH,iBAAiB,EAAE/B,eAAe,CAAC;EACpD,OAAO,IAAAkC,yBAAS,EAACF,kBAAkB,EAAExB,gBAAgB,CAAC;EACtD,OAAO,IAAA0B,yBAAS,EAACD,gBAAgB,EAAEZ,cAAc,CAAC;AACpD"}
|
|
@@ -9,14 +9,13 @@ var _toolkit = require("@reduxjs/toolkit");
|
|
|
9
9
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
10
10
|
var _sagas = require("./sagas");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function ownKeys(
|
|
13
|
-
function _objectSpread(
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
14
|
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
|
-
function _toPropertyKey(
|
|
16
|
-
function _toPrimitive(
|
|
17
|
-
var SLICE_NAME = 'OAuthForm';
|
|
18
|
-
exports.
|
|
19
|
-
var defaultOAuthFormState = {
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
var SLICE_NAME = exports.SLICE_NAME = 'OAuthForm';
|
|
18
|
+
var defaultOAuthFormState = exports.defaultOAuthFormState = {
|
|
20
19
|
apiServerUrl: '',
|
|
21
20
|
fetchedUrl: '',
|
|
22
21
|
webUrl: '',
|
|
@@ -30,8 +29,7 @@ var defaultOAuthFormState = {
|
|
|
30
29
|
looker_url: ''
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
|
-
exports.
|
|
34
|
-
var OAuthFormSlice = (0, _toolkit.createSlice)({
|
|
32
|
+
var OAuthFormSlice = exports.OAuthFormSlice = (0, _toolkit.createSlice)({
|
|
35
33
|
name: SLICE_NAME,
|
|
36
34
|
initialState: defaultOAuthFormState,
|
|
37
35
|
reducers: {
|
|
@@ -104,9 +102,7 @@ var OAuthFormSlice = (0, _toolkit.createSlice)({
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
});
|
|
107
|
-
exports.
|
|
108
|
-
var OAuthFormActions = OAuthFormSlice.actions;
|
|
109
|
-
exports.OAuthFormActions = OAuthFormActions;
|
|
105
|
+
var OAuthFormActions = exports.OAuthFormActions = OAuthFormSlice.actions;
|
|
110
106
|
var {
|
|
111
107
|
useActions: useOAuthFormActions,
|
|
112
108
|
useStoreState: useOAuthFormState
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.js","names":["_redux","require","_toolkit","_omit","_interopRequireDefault","_sagas","obj","__esModule","default","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","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","SLICE_NAME","exports","defaultOAuthFormState","apiServerUrl","fetchedUrl","webUrl","messageBar","text","intent","validationMessages","savedConfig","base_url","looker_url","OAuthFormSlice","createSlice","name","initialState","reducers","initAction","_state","_action","initSuccessAction","state","action","payload","setUrlAction","setUrlActionSuccess","updateValidationMessages","newValidationMessages","newMessage","elementName","omit","clearConfigAction","clearConfigActionSuccess","verifyConfigAction","concat","verifyConfigActionSuccess","verifyConfigActionFailure","saveConfigAction","saveConfigActionSuccess","clearMessageBarAction","updateMessageBarAction","setFailureAction","OAuthFormActions","actions","useActions","useOAuthFormActions","useStoreState","useOAuthFormState","createSliceHooks","saga"],"sources":["../../../../src/OAuthForm/src/state/slice.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 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 { Dispatch } from 'react'\nimport { createSliceHooks } from '@looker/redux'\nimport { createSlice } from '@reduxjs/toolkit'\nimport type { PayloadAction } from '@reduxjs/toolkit'\nimport type {\n MessageBarIntent,\n ValidationMessageProps,\n ValidationMessages,\n} from '@looker/components'\nimport omit from 'lodash/omit'\nimport type { ConfigValues } from '../utils'\nimport { saga } from './sagas'\n\nexport const SLICE_NAME = 'OAuthForm'\nexport interface MessageBarData {\n intent: MessageBarIntent\n text: string\n}\n\nexport interface OAuthFormState {\n apiServerUrl: string\n fetchedUrl: string\n webUrl: string\n messageBar: MessageBarData\n validationMessages: ValidationMessages\n savedConfig: ConfigValues\n}\n\nexport const defaultOAuthFormState: OAuthFormState = {\n apiServerUrl: '',\n fetchedUrl: '',\n webUrl: '',\n messageBar: {\n text: '',\n intent: 'positive',\n },\n validationMessages: {},\n savedConfig: { base_url: '', looker_url: '' },\n}\n\nexport interface ClearConfigActionPayload {\n configKey: string\n setHasConfig?: Dispatch<boolean>\n isAuthenticated: boolean\n}\n\nexport interface SetUrlActionPayload {\n name: string\n value: string\n}\n\ninterface UpdateValidationMessagesPayload {\n elementName: string\n newMessage: ValidationMessageProps | null\n}\n\nexport interface SaveConfigPayload {\n configKey: string\n setHasConfig?: Dispatch<boolean>\n client_id: string\n redirect_uri: string\n}\n\nexport interface SaveConfigSuccessPayload {\n base_url: string\n looker_url: string\n}\n\nexport const OAuthFormSlice = createSlice({\n name: SLICE_NAME,\n initialState: defaultOAuthFormState,\n reducers: {\n initAction(_state, _action: PayloadAction<string>) {\n // noop\n },\n initSuccessAction(state, action: PayloadAction<ConfigValues>) {\n state.apiServerUrl = action.payload.base_url\n state.webUrl = action.payload.looker_url\n },\n setUrlAction(_state, _action: PayloadAction<SetUrlActionPayload>) {\n // noop\n },\n setUrlActionSuccess(state, action: PayloadAction<string>) {\n state.apiServerUrl = action.payload\n state.webUrl = ''\n },\n updateValidationMessages(\n state,\n action: PayloadAction<UpdateValidationMessagesPayload>\n ) {\n let newValidationMessages = state.validationMessages\n\n if (action.payload.newMessage !== null) {\n newValidationMessages[action.payload.elementName] =\n action.payload.newMessage\n } else {\n newValidationMessages = omit(\n newValidationMessages,\n action.payload.elementName\n )\n }\n state.validationMessages = newValidationMessages\n },\n clearConfigAction(\n _state,\n _action: PayloadAction<ClearConfigActionPayload>\n ) {\n // noop\n },\n clearConfigActionSuccess() {\n return { ...defaultOAuthFormState }\n },\n verifyConfigAction(state) {\n state.fetchedUrl = `${state.apiServerUrl}/versions`\n },\n verifyConfigActionSuccess(state, action: PayloadAction<string>) {\n state.messageBar = {\n intent: 'positive',\n text: `Configuration is valid`,\n }\n state.webUrl = action.payload\n },\n verifyConfigActionFailure(state, action: PayloadAction<string>) {\n state.messageBar = { intent: 'critical', text: action.payload }\n state.webUrl = ''\n },\n saveConfigAction(_state, _action: PayloadAction<SaveConfigPayload>) {\n // noop\n },\n saveConfigActionSuccess(\n state,\n action: PayloadAction<SaveConfigSuccessPayload>\n ) {\n const { base_url, looker_url } = action.payload\n state.savedConfig = {\n base_url,\n looker_url,\n }\n state.messageBar = {\n intent: 'positive',\n text: `Saved ${looker_url} as OAuth server`,\n }\n },\n clearMessageBarAction(state) {\n state.messageBar.text = ''\n },\n updateMessageBarAction(state, action: PayloadAction<MessageBarData>) {\n state.messageBar = action.payload\n },\n setFailureAction(state, action: PayloadAction<string>) {\n state.messageBar = { intent: 'critical', text: action.payload }\n },\n },\n})\n\nexport const OAuthFormActions = OAuthFormSlice.actions\nexport const {\n useActions: useOAuthFormActions,\n useStoreState: useOAuthFormState,\n} = createSliceHooks(OAuthFormSlice, saga)\n"],"mappings":";;;;;;AA0BA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA8B,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,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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AC5B,CAAC;IACDkC,sBAAsBA,CAACnB,KAAK,EAAEC,MAAqC,EAAE;MACnED,KAAK,CAAChB,UAAU,GAAGiB,MAAM,CAACC,OAAO;IACnC,CAAC;IACDkB,gBAAgBA,CAACpB,KAAK,EAAEC,MAA6B,EAAE;MACrDD,KAAK,CAAChB,UAAU,GAAG;QAAEE,MAAM,EAAE,UAAU;QAAED,IAAI,EAAEgB,MAAM,CAACC;MAAQ,CAAC;IACjE;EACF;AACF,CAAC,CAAC;AAAAvB,OAAA,CAAAY,cAAA,GAAAA,cAAA;AAEK,IAAM8B,gBAAgB,GAAG9B,cAAc,CAAC+B,OAAO;AAAA3C,OAAA,CAAA0C,gBAAA,GAAAA,gBAAA;AAC/C,IAAM;EACXE,UAAU,EAAEC,mBAAmB;EAC/BC,aAAa,EAAEC;AACjB,CAAC,GAAG,IAAAC,uBAAgB,EAACpC,cAAc,EAAEqC,WAAI,CAAC;AAAAjD,OAAA,CAAA+C,iBAAA,GAAAA,iBAAA;AAAA/C,OAAA,CAAA6C,mBAAA,GAAAA,mBAAA"}
|
|
1
|
+
{"version":3,"file":"slice.js","names":["_redux","require","_toolkit","_omit","_interopRequireDefault","_sagas","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","SLICE_NAME","exports","defaultOAuthFormState","apiServerUrl","fetchedUrl","webUrl","messageBar","text","intent","validationMessages","savedConfig","base_url","looker_url","OAuthFormSlice","createSlice","name","initialState","reducers","initAction","_state","_action","initSuccessAction","state","action","payload","setUrlAction","setUrlActionSuccess","updateValidationMessages","newValidationMessages","newMessage","elementName","omit","clearConfigAction","clearConfigActionSuccess","verifyConfigAction","concat","verifyConfigActionSuccess","verifyConfigActionFailure","saveConfigAction","saveConfigActionSuccess","clearMessageBarAction","updateMessageBarAction","setFailureAction","OAuthFormActions","actions","useActions","useOAuthFormActions","useStoreState","useOAuthFormState","createSliceHooks","saga"],"sources":["../../../../src/OAuthForm/src/state/slice.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 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 { Dispatch } from 'react';\nimport { createSliceHooks } from '@looker/redux';\nimport { createSlice } from '@reduxjs/toolkit';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport type {\n MessageBarIntent,\n ValidationMessageProps,\n ValidationMessages,\n} from '@looker/components';\nimport omit from 'lodash/omit';\nimport type { ConfigValues } from '../utils';\nimport { saga } from './sagas';\n\nexport const SLICE_NAME = 'OAuthForm';\nexport interface MessageBarData {\n intent: MessageBarIntent;\n text: string;\n}\n\nexport interface OAuthFormState {\n apiServerUrl: string;\n fetchedUrl: string;\n webUrl: string;\n messageBar: MessageBarData;\n validationMessages: ValidationMessages;\n savedConfig: ConfigValues;\n}\n\nexport const defaultOAuthFormState: OAuthFormState = {\n apiServerUrl: '',\n fetchedUrl: '',\n webUrl: '',\n messageBar: {\n text: '',\n intent: 'positive',\n },\n validationMessages: {},\n savedConfig: { base_url: '', looker_url: '' },\n};\n\nexport interface ClearConfigActionPayload {\n configKey: string;\n setHasConfig?: Dispatch<boolean>;\n isAuthenticated: boolean;\n}\n\nexport interface SetUrlActionPayload {\n name: string;\n value: string;\n}\n\ninterface UpdateValidationMessagesPayload {\n elementName: string;\n newMessage: ValidationMessageProps | null;\n}\n\nexport interface SaveConfigPayload {\n configKey: string;\n setHasConfig?: Dispatch<boolean>;\n client_id: string;\n redirect_uri: string;\n}\n\nexport interface SaveConfigSuccessPayload {\n base_url: string;\n looker_url: string;\n}\n\nexport const OAuthFormSlice = createSlice({\n name: SLICE_NAME,\n initialState: defaultOAuthFormState,\n reducers: {\n initAction(_state, _action: PayloadAction<string>) {\n // noop\n },\n initSuccessAction(state, action: PayloadAction<ConfigValues>) {\n state.apiServerUrl = action.payload.base_url;\n state.webUrl = action.payload.looker_url;\n },\n setUrlAction(_state, _action: PayloadAction<SetUrlActionPayload>) {\n // noop\n },\n setUrlActionSuccess(state, action: PayloadAction<string>) {\n state.apiServerUrl = action.payload;\n state.webUrl = '';\n },\n updateValidationMessages(\n state,\n action: PayloadAction<UpdateValidationMessagesPayload>\n ) {\n let newValidationMessages = state.validationMessages;\n\n if (action.payload.newMessage !== null) {\n newValidationMessages[action.payload.elementName] =\n action.payload.newMessage;\n } else {\n newValidationMessages = omit(\n newValidationMessages,\n action.payload.elementName\n );\n }\n state.validationMessages = newValidationMessages;\n },\n clearConfigAction(\n _state,\n _action: PayloadAction<ClearConfigActionPayload>\n ) {\n // noop\n },\n clearConfigActionSuccess() {\n return { ...defaultOAuthFormState };\n },\n verifyConfigAction(state) {\n state.fetchedUrl = `${state.apiServerUrl}/versions`;\n },\n verifyConfigActionSuccess(state, action: PayloadAction<string>) {\n state.messageBar = {\n intent: 'positive',\n text: `Configuration is valid`,\n };\n state.webUrl = action.payload;\n },\n verifyConfigActionFailure(state, action: PayloadAction<string>) {\n state.messageBar = { intent: 'critical', text: action.payload };\n state.webUrl = '';\n },\n saveConfigAction(_state, _action: PayloadAction<SaveConfigPayload>) {\n // noop\n },\n saveConfigActionSuccess(\n state,\n action: PayloadAction<SaveConfigSuccessPayload>\n ) {\n const { base_url, looker_url } = action.payload;\n state.savedConfig = {\n base_url,\n looker_url,\n };\n state.messageBar = {\n intent: 'positive',\n text: `Saved ${looker_url} as OAuth server`,\n };\n },\n clearMessageBarAction(state) {\n state.messageBar.text = '';\n },\n updateMessageBarAction(state, action: PayloadAction<MessageBarData>) {\n state.messageBar = action.payload;\n },\n setFailureAction(state, action: PayloadAction<string>) {\n state.messageBar = { intent: 'critical', text: action.payload };\n },\n },\n});\n\nexport const OAuthFormActions = OAuthFormSlice.actions;\nexport const {\n useActions: useOAuthFormActions,\n useStoreState: useOAuthFormState,\n} = createSliceHooks(OAuthFormSlice, saga);\n"],"mappings":";;;;;;AA0BA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAA+B,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,C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AK,CAACZ,WAAW,GAAG;QAClBC,QAAQ;QACRC;MACF,CAAC;MACDU,KAAK,CAAChB,UAAU,GAAG;QACjBE,MAAM,EAAE,UAAU;QAClBD,IAAI,WAAA4B,MAAA,CAAWvB,UAAU;MAC3B,CAAC;IACH,CAAC;IACD4B,qBAAqBA,CAAClB,KAAK,EAAE;MAC3BA,KAAK,CAAChB,UAAU,CAACC,IAAI,GAAG,EAAE;IAC5B,CAAC;IACDkC,sBAAsBA,CAACnB,KAAK,EAAEC,MAAqC,EAAE;MACnED,KAAK,CAAChB,UAAU,GAAGiB,MAAM,CAACC,OAAO;IACnC,CAAC;IACDkB,gBAAgBA,CAACpB,KAAK,EAAEC,MAA6B,EAAE;MACrDD,KAAK,CAAChB,UAAU,GAAG;QAAEE,MAAM,EAAE,UAAU;QAAED,IAAI,EAAEgB,MAAM,CAACC;MAAQ,CAAC;IACjE;EACF;AACF,CAAC,CAAC;AAEK,IAAMmB,gBAAgB,GAAA1C,OAAA,CAAA0C,gBAAA,GAAG9B,cAAc,CAAC+B,OAAO;AAC/C,IAAM;EACXC,UAAU,EAAEC,mBAAmB;EAC/BC,aAAa,EAAEC;AACjB,CAAC,GAAG,IAAAC,uBAAgB,EAACpC,cAAc,EAAEqC,WAAI,CAAC;AAACjD,OAAA,CAAA+C,iBAAA,GAAAA,iBAAA;AAAA/C,OAAA,CAAA6C,mBAAA,GAAAA,mBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ILookerVersions } from '@looker/sdk-codegen';
|
|
2
|
-
export
|
|
2
|
+
export type ConfigValues = Record<string, any>;
|
|
3
3
|
export declare const getUrl: (url: string) => Promise<string | ConfigValues>;
|
|
4
4
|
export declare const getVersions: (versionsUrl: string) => Promise<ILookerVersions | undefined>;
|
|
5
5
|
export declare const validateUrl: (url: string) => string;
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.validateUrl = exports.getVersions = exports.getUrl = void 0;
|
|
7
7
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
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; }
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
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); } }
|
|
14
14
|
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); }); }; }
|
|
15
|
-
var getUrl = function () {
|
|
15
|
+
var getUrl = exports.getUrl = function () {
|
|
16
16
|
var _ref = _asyncToGenerator(function* (url) {
|
|
17
17
|
var settings = _objectSpread(_objectSpread({}, (0, _sdkRtl.DefaultSettings)()), {
|
|
18
18
|
base_url: url,
|
|
@@ -26,8 +26,7 @@ var getUrl = function () {
|
|
|
26
26
|
return _ref.apply(this, arguments);
|
|
27
27
|
};
|
|
28
28
|
}();
|
|
29
|
-
exports.
|
|
30
|
-
var getVersions = function () {
|
|
29
|
+
var getVersions = exports.getVersions = function () {
|
|
31
30
|
var _ref2 = _asyncToGenerator(function* (versionsUrl) {
|
|
32
31
|
var versions;
|
|
33
32
|
try {
|
|
@@ -42,7 +41,6 @@ var getVersions = function () {
|
|
|
42
41
|
return _ref2.apply(this, arguments);
|
|
43
42
|
};
|
|
44
43
|
}();
|
|
45
|
-
exports.getVersions = getVersions;
|
|
46
44
|
var validateUrl = url => {
|
|
47
45
|
try {
|
|
48
46
|
var result = new URL(url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_sdkRtl","require","ownKeys","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_sdkRtl","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","getUrl","exports","_ref","url","settings","DefaultSettings","base_url","verify_ssl","xp","BrowserTransport","response","rawRequest","body","_x","getVersions","_ref2","versionsUrl","versions","content","JSON","parse","_unused","Error","_x2","validateUrl","result","URL","endsWith","origin","_unused2"],"sources":["../../../src/OAuthForm/src/utils.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2023 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 { BrowserTransport, DefaultSettings } from '@looker/sdk-rtl';\nimport type { ILookerVersions } from '@looker/sdk-codegen';\n\nexport type ConfigValues = Record<string, any>;\n\n/**\n * Use the browser transport to GET a url\n * @param url to fetch\n */\nexport const getUrl = async (url: string): Promise<string | ConfigValues> => {\n const settings = {\n ...DefaultSettings(),\n ...{ base_url: url, verify_ssl: false },\n };\n const xp = new BrowserTransport(settings);\n const response = await xp.rawRequest('GET', url);\n return response.body;\n};\n\n/**\n * Gets the versions payload given a versions url\n * @param versionsUrl\n */\nexport const getVersions = async (\n versionsUrl: string\n): Promise<ILookerVersions | undefined> => {\n let versions;\n try {\n const content = await getUrl(versionsUrl);\n versions = typeof content === 'string' ? JSON.parse(content) : content;\n } catch {\n throw new Error('Invalid server configuration');\n }\n return versions;\n};\n\n/**\n * Validates URL and standardizes it\n * @param url to validate\n * @returns the standardized url.origin if it's valid, or an empty string if it's not\n */\nexport const validateUrl = (url: string): string => {\n try {\n const result = new URL(url);\n if (url.endsWith(':')) return url;\n return result.origin;\n } catch {\n return '';\n }\n};\n"],"mappings":";;;;;;AAyBA,IAAAA,OAAA,GAAAC,OAAA;AAAoE,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAE,MAAA,CAAAgB,cAAA,CAAAnB,CAAA,EAAAC,CAAA,EAAAE,MAAA,CAAAK,wBAAA,CAAAN,CAAA,EAAAD,CAAA,iBAAAD,CAAA;AAAA,SAAAgB,gBAAAI,GAAA,E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AAOL,QAAQ;EACjB,CAAC;EAAA,gBAXYH,WAAWA,CAAAS,GAAA;IAAA,OAAAR,KAAA,CAAAxD,KAAA,OAAAE,SAAA;EAAA;AAAA,GAWvB;AAOM,IAAM+D,WAAW,GAAIrB,GAAW,IAAa;EAClD,IAAI;IACF,IAAMsB,MAAM,GAAG,IAAIC,GAAG,CAACvB,GAAG,CAAC;IAC3B,IAAIA,GAAG,CAACwB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAOxB,GAAG;IACjC,OAAOsB,MAAM,CAACG,MAAM;EACtB,CAAC,CAAC,OAAAC,QAAA,EAAM;IACN,OAAO,EAAE;EACX;AACF,CAAC;AAAC5B,OAAA,CAAAuB,WAAA,GAAAA,WAAA"}
|
package/lib/OAuthScene.js
CHANGED
|
@@ -8,8 +8,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _components = require("@looker/components");
|
|
9
9
|
var _reactRouter = require("react-router");
|
|
10
10
|
var _reactRouterDom = require("react-router-dom");
|
|
11
|
-
function _getRequireWildcardCache(
|
|
12
|
-
function _interopRequireWildcard(
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
13
|
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); } }
|
|
14
14
|
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); }); }; }
|
|
15
15
|
var OAuthScene = _ref => {
|
package/lib/OAuthScene.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthScene.js","names":["_react","_interopRequireWildcard","require","_components","_reactRouter","_reactRouterDom","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"file":"OAuthScene.js","names":["_react","_interopRequireWildcard","require","_components","_reactRouter","_reactRouterDom","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","OAuthScene","_ref","_authSession$returnUr","adaptor","history","useHistory","location","useLocation","reactPath","pathname","fullPath","window","extraPath","substr","indexOf","authSession","sdk","retPath","returnUrl","oldUrl","replace","useEffect","maybeLogin","_ref2","token","login","console","push","themeOverrides","createElement","ComponentsProvider","loadGoogleFonts","themeCustomizations","Flex","flexDirection","justifyContent","mt","FlexItem","alignSelf","ProgressCircular","size","Heading","color","as","concat","exports"],"sources":["../src/OAuthScene.tsx"],"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 { FC } from 'react';\nimport React, { useEffect } from 'react';\nimport type { BrowserSession } from '@looker/sdk-rtl';\nimport {\n ComponentsProvider,\n Flex,\n FlexItem,\n Heading,\n ProgressCircular,\n} from '@looker/components';\nimport { useHistory } from 'react-router';\nimport { useLocation } from 'react-router-dom';\nimport type { IEnvironmentAdaptor } from './adaptorUtils';\n\ninterface OAuthSceneProps {\n adaptor: IEnvironmentAdaptor;\n}\n\n/**\n * OAuth scene for sdk session handling and redirection to OAuth flow initiation\n * route\n */\nexport const OAuthScene: FC<OAuthSceneProps> = ({ adaptor }) => {\n const history = useHistory();\n const location = useLocation();\n const reactPath = location.pathname;\n const fullPath = (window as any).location.pathname;\n const extraPath = fullPath.substr(0, fullPath.indexOf(reactPath));\n const authSession = adaptor.sdk.authSession as BrowserSession;\n const retPath = authSession.returnUrl ?? '/';\n /** If this is a nested React app, remove extraPath to prevent recursive return pathing */\n const oldUrl = retPath.replace(extraPath, '');\n\n useEffect(() => {\n const maybeLogin = async () => {\n const token = await adaptor.login();\n if (token) {\n console.error({ push: oldUrl, retPath, extraPath, location });\n history.push(oldUrl);\n }\n };\n maybeLogin();\n }, []);\n\n const themeOverrides = adaptor.themeOverrides();\n return (\n <ComponentsProvider\n loadGoogleFonts={themeOverrides.loadGoogleFonts}\n themeCustomizations={themeOverrides.themeCustomizations}\n >\n <Flex flexDirection=\"column\" justifyContent=\"center\" mt=\"25%\">\n <FlexItem alignSelf=\"center\">\n <ProgressCircular size=\"large\" />\n </FlexItem>\n <FlexItem mt=\"large\" alignSelf=\"center\">\n <Heading color=\"key\" as=\"h2\">\n {`Returning to ${oldUrl} after OAuth login ...`}\n </Heading>\n </FlexItem>\n </Flex>\n </ComponentsProvider>\n );\n};\n"],"mappings":";;;;;;AA2BA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAOA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAA+C,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAA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eAAgB;IAChDC,mBAAmB,EAAEJ,cAAc,CAACI;EAAoB,GAExDjF,MAAA,CAAAY,OAAA,CAAAkE,aAAA,CAAC3E,WAAA,CAAA+E,IAAI;IAACC,aAAa,EAAC,QAAQ;IAACC,cAAc,EAAC,QAAQ;IAACC,EAAE,EAAC;EAAK,GAC3DrF,MAAA,CAAAY,OAAA,CAAAkE,aAAA,CAAC3E,WAAA,CAAAmF,QAAQ;IAACC,SAAS,EAAC;EAAQ,GAC1BvF,MAAA,CAAAY,OAAA,CAAAkE,aAAA,CAAC3E,WAAA,CAAAqF,gBAAgB;IAACC,IAAI,EAAC;EAAO,CAAE,CACxB,CAAC,EACXzF,MAAA,CAAAY,OAAA,CAAAkE,aAAA,CAAC3E,WAAA,CAAAmF,QAAQ;IAACD,EAAE,EAAC,OAAO;IAACE,SAAS,EAAC;EAAQ,GACrCvF,MAAA,CAAAY,OAAA,CAAAkE,aAAA,CAAC3E,WAAA,CAAAuF,OAAO;IAACC,KAAK,EAAC,KAAK;IAACC,EAAE,EAAC;EAAI,mBAAAC,MAAA,CACTzB,MAAM,2BAChB,CACD,CACN,CACY,CAAC;AAEzB,CAAC;AAAC0B,OAAA,CAAA7C,UAAA,GAAAA,UAAA"}
|
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'
|
|
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,CAAC,UAAU,CAAE;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAM5B,IAAMK,iBAAiB,GAAIC,eAAwB,IACxDA,eAAe,GACX;EACEC,eAAe,EAAE,IAAI;EACrBC,mBAAmB,EAAE;IACnBC,YAAY,EAAE;MAAEC,KAAK,EAAE;IAAc,CAAC;IACtCC,MAAM,EAAE;MAAEC,GAAG,EAAE;IAAU;EAC3B;AACF,CAAC,GACD;EACEJ,mBAAmB,EAAE;IACnBG,MAAM,EAAE;MAAEC,GAAG,EAAE;IAAU;EAC3B;AACF,CAAC;AAACR,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAER,IAAIQ,gBAAiD;AAM9C,IAAMC,kBAAkB,GAC7BC,OAAU,IACP;EACHF,gBAAgB,GAAGE,OAAO;AAC5B,CAAC;AAACX,OAAA,CAAAU,kBAAA,GAAAA,kBAAA;AAKK,IAAME,oBAAoB,GAAGA,CAAA,KAAM;EACxCH,gBAAgB,GAAGI,SAAS;AAC9B,CAAC;AAACb,OAAA,CAAAY,oBAAA,GAAAA,oBAAA;AAKK,IAAME,aAAa,GAAGA,CAAA,KAAM;EACjC,IAAI,CAACL,gBAAgB,EAAE;IACrB,MAAM,IAAIM,KAAK,CAAC,sCAAsC,CAAC;EACzD;EACA,OAAON,gBAAgB;AACzB,CAAC;AAACT,OAAA,CAAAc,aAAA,GAAAA,aAAA;AAMK,IAAME,sBAAsB,GACjCL,OAAW,IACR;EACH,IAAMM,OAAO,GAAG,CAAC,CAA2B;EAC5CP,kBAAkB,CAACC,OAAO,IAAI,IAAIO,8BAAc,CAACD,OAAO,CAAC,CAAC;AAC5D,CAAC;AAACjB,OAAA,CAAAgB,sBAAA,GAAAA,sBAAA;AAWK,IAAMG,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;AAAC7B,OAAA,CAAAmB,OAAA,GAAAA,OAAA"}
|
package/lib/authUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IApiSection, IApiSettings } from '@looker/sdk-rtl';
|
|
2
2
|
import { ApiSettings } from '@looker/sdk-rtl';
|
|
3
|
-
export
|
|
3
|
+
export type StorageLocation = 'session' | 'local';
|
|
4
4
|
export interface IStorageValue {
|
|
5
5
|
location: StorageLocation;
|
|
6
6
|
value: string;
|
package/lib/authUtils.js
CHANGED
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.OAuthConfigProvider = void 0;
|
|
7
7
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
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; }
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
class OAuthConfigProvider extends _sdkRtl.ApiSettings {
|
|
14
14
|
constructor(settings, oauthClientId, configKey) {
|
|
15
15
|
super(settings);
|
package/lib/authUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authUtils.js","names":["_sdkRtl","require","ownKeys","
|
|
1
|
+
{"version":3,"file":"authUtils.js","names":["_sdkRtl","require","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","OAuthConfigProvider","ApiSettings","constructor","settings","oauthClientId","configKey","getStorage","defaultValue","undefined","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;AAA8C,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAA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AACC,QAAQ,CAAC,GAC1B;MACDR,QAAQ;MACRC,UAAU;MACVC,SAAS;MACTC;IACF,CAAC;EAEL;AACF;AAACc,OAAA,CAAAlC,mBAAA,GAAAA,mBAAA"}
|
package/lib/browserAdaptor.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BrowserAuthAdaptor = exports.BrowserAdaptor = void 0;
|
|
7
7
|
var _adaptorUtils = require("./adaptorUtils");
|
|
8
8
|
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; }
|
|
9
|
-
function _toPropertyKey(
|
|
10
|
-
function _toPrimitive(
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
class BrowserAuthAdaptor {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserAdaptor.js","names":["_adaptorUtils","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","
|
|
1
|
+
{"version":3,"file":"browserAdaptor.js","names":["_adaptorUtils","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","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;AAAqE,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,CAAA,QAAAC,CAAA,GAA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IAAA,OAAA+B,iBAAA;MACxC,MAAM+B,YAAY,CAACK,UAAU,CAACnE,GAAG,CAAC;IAAC;EACrC;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 +1 @@
|
|
|
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'
|
|
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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