@looker/api-explorer 0.9.39 → 0.9.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +43 -1
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.map +1 -1
  4. package/lib/components/DocMethodSummary/utils.d.ts +1 -1
  5. package/lib/components/DocMethodSummary/utils.js +3 -0
  6. package/lib/components/DocMethodSummary/utils.js.map +1 -1
  7. package/lib/components/SelectorContainer/SdkLanguageSelector.js +3 -0
  8. package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  9. package/lib/esm/components/DocMethodSummary/utils.js +3 -0
  10. package/lib/esm/components/DocMethodSummary/utils.js.map +1 -1
  11. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +2 -0
  12. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  13. package/lib/esm/scenes/MethodScene/MethodScene.js +1 -1
  14. package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
  15. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js +2 -1
  16. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  17. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js +2 -1
  18. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  19. package/lib/esm/state/specs/sagas.js +1 -1
  20. package/lib/esm/state/specs/sagas.js.map +1 -1
  21. package/lib/esm/utils/adaptorUtils.js.map +1 -1
  22. package/lib/esm/utils/path.js +2 -1
  23. package/lib/esm/utils/path.js.map +1 -1
  24. package/lib/scenes/MethodScene/MethodScene.js +1 -1
  25. package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
  26. package/lib/scenes/MethodTagScene/MethodTagScene.js +1 -0
  27. package/lib/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  28. package/lib/scenes/TypeTagScene/TypeTagScene.js +1 -0
  29. package/lib/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  30. package/lib/state/specs/sagas.js +1 -1
  31. package/lib/state/specs/sagas.js.map +1 -1
  32. package/lib/utils/adaptorUtils.js.map +1 -1
  33. package/lib/utils/path.js +2 -1
  34. package/lib/utils/path.js.map +1 -1
  35. package/package.json +10 -10
  36. package/src/components/DocMethodSummary/utils.spec.tsx +1 -0
  37. package/src/components/DocMethodSummary/utils.tsx +2 -0
  38. package/src/components/SelectorContainer/SdkLanguageSelector.tsx +2 -0
  39. package/src/scenes/MethodScene/MethodScene.tsx +1 -1
  40. package/src/scenes/MethodTagScene/MethodTagScene.spec.tsx +10 -7
  41. package/src/scenes/MethodTagScene/MethodTagScene.tsx +2 -1
  42. package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +14 -8
  43. package/src/scenes/TypeTagScene/TypeTagScene.tsx +2 -1
  44. package/src/state/specs/sagas.ts +2 -1
  45. package/src/utils/adaptorUtils.ts +1 -1
  46. package/src/utils/path.ts +2 -1
@@ -35,6 +35,7 @@ var MethodTagScene = _ref => {
35
35
  specKey,
36
36
  methodTag
37
37
  } = (0, _reactRouterDom.useParams)();
38
+ var location = (0, _reactRouterDom.useLocation)();
38
39
  var history = (0, _reactRouterDom.useHistory)();
39
40
  var methods = api.tags[methodTag];
40
41
  var {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/scenes/MethodTagScene/MethodTagScene.tsx"],"names":["MethodTagScene","api","specKey","methodTag","history","methods","tags","navigate","buildPathWithGlobalParams","navigateWithGlobalParams","selectedTagFilter","selectTagFilter","setTagFilterAction","tagFilter","setTagFilter","handleChange","filter","location","pathname","t","toLowerCase","searchParams","URLSearchParams","search","verbParam","get","toUpperCase","tag","Object","values","spec","find","name","operations","description","map","op","method","index","httpMethod"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAWO,IAAMA,cAAuC,GAAG,QAAa;AAAA,MAAZ;AAAEC,IAAAA;AAAF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;AAAM,IAAA,OAAO,EAAE,CAAf;AAAkB,IAAA,EAAE,EAAC;AAArB,KACE,6BAAC,6BAAD;AAAkB,IAAA,GAAG,EAAEM,KAAvB;AAA8B,IAAA,MAAM,EAAED;AAAtC,IADF,CANF,CAJL,CAjBH,CADF;AAoCD,CAjFM","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 { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport { useHistory, useParams } from 'react-router-dom'\nimport { Grid, ButtonToggle, ButtonItem } from '@looker/components'\nimport type { ApiModel } from '@looker/sdk-codegen'\nimport { useSelector } from 'react-redux'\nimport { ApixSection, DocTitle, DocMethodSummary, Link } from '../../components'\nimport { buildMethodPath, isValidFilter, useNavigation } from '../../utils'\nimport { selectTagFilter, useSettingActions } from '../../state'\nimport { useTagStoreSync } from '../utils'\nimport { getOperations } from './utils'\n\ninterface MethodTagSceneProps {\n api: ApiModel\n}\n\ninterface MethodTagSceneParams {\n specKey: string\n methodTag: string\n}\n\nexport const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {\n const { specKey, methodTag } = useParams<MethodTagSceneParams>()\n const history = useHistory()\n const methods = api.tags[methodTag]\n const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =\n useNavigation()\n const selectedTagFilter = useSelector(selectTagFilter)\n const { setTagFilterAction } = useSettingActions()\n const [tagFilter, setTagFilter] = useState(selectedTagFilter)\n useTagStoreSync()\n\n const handleChange = (filter: string) => {\n navigate(location.pathname, {\n t: filter === 'ALL' ? null : filter.toLowerCase(),\n })\n }\n\n useEffect(() => {\n const searchParams = new URLSearchParams(location.search)\n let verbParam = searchParams.get('t') || 'ALL'\n verbParam = isValidFilter(location.pathname, verbParam)\n ? verbParam.toUpperCase()\n : 'ALL'\n setTagFilterAction({\n tagFilter: verbParam,\n })\n }, [location.search])\n\n useEffect(() => {\n setTagFilter(selectedTagFilter)\n }, [selectedTagFilter])\n\n useEffect(() => {\n if (!methods) {\n navigateWithGlobalParams(`/${specKey}/methods`)\n }\n }, [history, methods])\n if (!methods) {\n return <></>\n }\n const tag = Object.values(api.spec.tags!).find(\n (tag) => tag.name === methodTag\n )!\n const operations = getOperations(methods)\n\n return (\n <ApixSection>\n <DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>\n <ButtonToggle\n mb=\"small\"\n mt=\"xlarge\"\n value={tagFilter}\n onChange={handleChange}\n >\n <ButtonItem key=\"ALL\" px=\"large\" py=\"xsmall\">\n ALL\n </ButtonItem>\n {operations.map((op) => (\n <ButtonItem key={op} px=\"large\" py=\"xsmall\">\n {op}\n </ButtonItem>\n ))}\n </ButtonToggle>\n {Object.values(methods).map(\n (method, index) =>\n (selectedTagFilter === 'ALL' ||\n selectedTagFilter === method.httpMethod) && (\n <Link\n key={index}\n to={buildPathWithGlobalParams(\n buildMethodPath(specKey, tag.name, method.name)\n )}\n >\n <Grid columns={1} py=\"xsmall\">\n <DocMethodSummary key={index} method={method} />\n </Grid>\n </Link>\n )\n )}\n </ApixSection>\n )\n}\n"],"file":"MethodTagScene.js"}
1
+ {"version":3,"sources":["../../../src/scenes/MethodTagScene/MethodTagScene.tsx"],"names":["MethodTagScene","api","specKey","methodTag","location","history","methods","tags","navigate","buildPathWithGlobalParams","navigateWithGlobalParams","selectedTagFilter","selectTagFilter","setTagFilterAction","tagFilter","setTagFilter","handleChange","filter","pathname","t","toLowerCase","searchParams","URLSearchParams","search","verbParam","get","toUpperCase","tag","Object","values","spec","find","name","operations","description","map","op","method","index","httpMethod"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAWO,IAAMA,cAAuC,GAAG,QAAa;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAClE,MAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAyB,gCAA/B;AACA,MAAMC,QAAQ,GAAG,kCAAjB;AACA,MAAMC,OAAO,GAAG,iCAAhB;AACA,MAAMC,OAAO,GAAGL,GAAG,CAACM,IAAJ,CAASJ,SAAT,CAAhB;AACA,MAAM;AAAEK,IAAAA,QAAF;AAAYC,IAAAA,yBAAZ;AAAuCC,IAAAA;AAAvC,MACJ,2BADF;AAEA,MAAMC,iBAAiB,GAAG,6BAAYC,sBAAZ,CAA1B;AACA,MAAM;AAAEC,IAAAA;AAAF,MAAyB,+BAA/B;AACA,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,qBAASJ,iBAAT,CAAlC;AACA;;AAEA,MAAMK,YAAY,GAAIC,MAAD,IAAoB;AACvCT,IAAAA,QAAQ,CAACJ,QAAQ,CAACc,QAAV,EAAoB;AAC1BC,MAAAA,CAAC,EAAEF,MAAM,KAAK,KAAX,GAAmB,IAAnB,GAA0BA,MAAM,CAACG,WAAP;AADH,KAApB,CAAR;AAGD,GAJD;;AAMA,wBAAU,MAAM;AACd,QAAMC,YAAY,GAAG,IAAIC,eAAJ,CAAoBl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CAACE,GAAX,CAAgBC,EAAD,IACd,6BAAC,sBAAD;AAAY,IAAA,GAAG,EAAEA,EAAjB;AAAqB,IAAA,EAAE,EAAC,OAAxB;AAAgC,IAAA,EAAE,EAAC;AAAnC,KACGA,EADH,CADD,CATH,CAFF,EAiBGR,MAAM,CAACC,MAAP,CAAcvB,OAAd,EAAuB6B,GAAvB,CACC,CAACE,MAAD,EAASC,KAAT,KACE,CAAC3B,iBAAiB,KAAK,KAAtB,IACCA,iBAAiB,KAAK0B,MAAM,CAACE,UAD/B,KAEE,6BAAC,iBAAD;AACE,IAAA,GAAG,EAAED,KADP;AAEE,IAAA,EAAE,EAAE7B,yBAAyB,CAC3B,4BAAgBP,OAAhB,EAAyByB,GAAG,CAACK,IAA7B,EAAmCK,MAAM,CAACL,IAA1C,CAD2B;AAF/B,KAME,6BAAC,gBAAD;AAAM,IAAA,OAAO,EAAE,CAAf;AAAkB,IAAA,EAAE,EAAC;AAArB,KACE,6BAAC,6BAAD;AAAkB,IAAA,GAAG,EAAEM,KAAvB;AAA8B,IAAA,MAAM,EAAED;AAAtC,IADF,CANF,CAJL,CAjBH,CADF;AAoCD,CAlFM","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 { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport { useHistory, useLocation, useParams } from 'react-router-dom'\nimport { Grid, ButtonToggle, ButtonItem } from '@looker/components'\nimport type { ApiModel } from '@looker/sdk-codegen'\nimport { useSelector } from 'react-redux'\nimport { ApixSection, DocTitle, DocMethodSummary, Link } from '../../components'\nimport { buildMethodPath, isValidFilter, useNavigation } from '../../utils'\nimport { selectTagFilter, useSettingActions } from '../../state'\nimport { useTagStoreSync } from '../utils'\nimport { getOperations } from './utils'\n\ninterface MethodTagSceneProps {\n api: ApiModel\n}\n\ninterface MethodTagSceneParams {\n specKey: string\n methodTag: string\n}\n\nexport const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {\n const { specKey, methodTag } = useParams<MethodTagSceneParams>()\n const location = useLocation()\n const history = useHistory()\n const methods = api.tags[methodTag]\n const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =\n useNavigation()\n const selectedTagFilter = useSelector(selectTagFilter)\n const { setTagFilterAction } = useSettingActions()\n const [tagFilter, setTagFilter] = useState(selectedTagFilter)\n useTagStoreSync()\n\n const handleChange = (filter: string) => {\n navigate(location.pathname, {\n t: filter === 'ALL' ? null : filter.toLowerCase(),\n })\n }\n\n useEffect(() => {\n const searchParams = new URLSearchParams(location.search)\n let verbParam = searchParams.get('t') || 'ALL'\n verbParam = isValidFilter(location.pathname, verbParam)\n ? verbParam.toUpperCase()\n : 'ALL'\n setTagFilterAction({\n tagFilter: verbParam,\n })\n }, [location.search])\n\n useEffect(() => {\n setTagFilter(selectedTagFilter)\n }, [selectedTagFilter])\n\n useEffect(() => {\n if (!methods) {\n navigateWithGlobalParams(`/${specKey}/methods`)\n }\n }, [history, methods])\n if (!methods) {\n return <></>\n }\n const tag = Object.values(api.spec.tags!).find(\n (tag) => tag.name === methodTag\n )!\n const operations = getOperations(methods)\n\n return (\n <ApixSection>\n <DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>\n <ButtonToggle\n mb=\"small\"\n mt=\"xlarge\"\n value={tagFilter}\n onChange={handleChange}\n >\n <ButtonItem key=\"ALL\" px=\"large\" py=\"xsmall\">\n ALL\n </ButtonItem>\n {operations.map((op) => (\n <ButtonItem key={op} px=\"large\" py=\"xsmall\">\n {op}\n </ButtonItem>\n ))}\n </ButtonToggle>\n {Object.values(methods).map(\n (method, index) =>\n (selectedTagFilter === 'ALL' ||\n selectedTagFilter === method.httpMethod) && (\n <Link\n key={index}\n to={buildPathWithGlobalParams(\n buildMethodPath(specKey, tag.name, method.name)\n )}\n >\n <Grid columns={1} py=\"xsmall\">\n <DocMethodSummary key={index} method={method} />\n </Grid>\n </Link>\n )\n )}\n </ApixSection>\n )\n}\n"],"file":"MethodTagScene.js"}
@@ -35,6 +35,7 @@ var TypeTagScene = _ref => {
35
35
  specKey,
36
36
  typeTag
37
37
  } = (0, _reactRouterDom.useParams)();
38
+ var location = (0, _reactRouterDom.useLocation)();
38
39
  var {
39
40
  navigate,
40
41
  buildPathWithGlobalParams,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/scenes/TypeTagScene/TypeTagScene.tsx"],"names":["TypeTagScene","api","specKey","typeTag","navigate","buildPathWithGlobalParams","navigateWithGlobalParams","selectedTagFilter","selectTagFilter","setTagFilterAction","tagFilter","setTagFilter","handleChange","filter","location","pathname","t","toLowerCase","searchParams","URLSearchParams","search","verbParam","get","toUpperCase","types","typeTags","tag","Object","values","spec","tags","find","name","metaTypes","description","map","op","type","index","metaType","toString"],"mappings":";;;;;;;AA0BA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAWO,IAAMA,YAAmC,GAAG,QAAa;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAC9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,CAAf;AAAkB,IAAA,EAAE,EAAC;AAArB,KACE,6BAAC,2BAAD;AAAgB,IAAA,GAAG,EAAEM,KAArB;AAA4B,IAAA,IAAI,EAAED;AAAlC,IADF,CANF,CAJL,CAjBH,CADF;AAoCD,CA/EM","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 { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport { Grid, ButtonToggle, ButtonItem } from '@looker/components'\nimport type { ApiModel } from '@looker/sdk-codegen'\nimport { useParams } from 'react-router-dom'\nimport { useSelector } from 'react-redux'\nimport { ApixSection, DocTitle, DocTypeSummary, Link } from '../../components'\nimport { buildTypePath, isValidFilter, useNavigation } from '../../utils'\nimport { selectTagFilter, useSettingActions } from '../../state'\nimport { useTagStoreSync } from '../utils'\nimport { getMetaTypes } from './utils'\n\ninterface TypeTagSceneProps {\n api: ApiModel\n}\n\ninterface TypeTagSceneParams {\n specKey: string\n typeTag: string\n}\n\nexport const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {\n const { specKey, typeTag } = useParams<TypeTagSceneParams>()\n const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =\n useNavigation()\n const selectedTagFilter = useSelector(selectTagFilter)\n const { setTagFilterAction } = useSettingActions()\n const [tagFilter, setTagFilter] = useState(selectedTagFilter)\n useTagStoreSync()\n\n const handleChange = (filter: string) => {\n navigate(location.pathname, {\n t: filter === 'ALL' ? null : filter.toLowerCase(),\n })\n }\n\n useEffect(() => {\n const searchParams = new URLSearchParams(location.search)\n let verbParam = searchParams.get('t') || 'ALL'\n verbParam = isValidFilter(location.pathname, verbParam)\n ? verbParam.toUpperCase()\n : 'ALL'\n setTagFilterAction({\n tagFilter: verbParam,\n })\n }, [location.search])\n\n const types = api.typeTags[typeTag]\n useEffect(() => {\n if (!types) {\n navigateWithGlobalParams(`/${specKey}/types`)\n }\n }, [types])\n\n useEffect(() => {\n setTagFilter(selectedTagFilter)\n }, [selectedTagFilter])\n\n if (!types) {\n return <></>\n }\n\n const tag = Object.values(api.spec.tags!).find((tag) => tag.name === typeTag)!\n const metaTypes = getMetaTypes(types)\n return (\n <ApixSection>\n <DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>\n <ButtonToggle\n mb=\"small\"\n mt=\"xlarge\"\n value={tagFilter}\n onChange={handleChange}\n >\n <ButtonItem key=\"ALL\" px=\"large\" py=\"xsmall\">\n ALL\n </ButtonItem>\n {metaTypes.map((op) => (\n <ButtonItem key={op} px=\"large\" py=\"xsmall\">\n {op}\n </ButtonItem>\n ))}\n </ButtonToggle>\n {Object.values(types).map(\n (type, index) =>\n (selectedTagFilter === 'ALL' ||\n selectedTagFilter === type.metaType.toString().toUpperCase()) && (\n <Link\n key={index}\n to={buildPathWithGlobalParams(\n buildTypePath(specKey, tag.name, type.name)\n )}\n >\n <Grid columns={1} py=\"xsmall\">\n <DocTypeSummary key={index} type={type} />\n </Grid>\n </Link>\n )\n )}\n </ApixSection>\n )\n}\n"],"file":"TypeTagScene.js"}
1
+ {"version":3,"sources":["../../../src/scenes/TypeTagScene/TypeTagScene.tsx"],"names":["TypeTagScene","api","specKey","typeTag","location","navigate","buildPathWithGlobalParams","navigateWithGlobalParams","selectedTagFilter","selectTagFilter","setTagFilterAction","tagFilter","setTagFilter","handleChange","filter","pathname","t","toLowerCase","searchParams","URLSearchParams","search","verbParam","get","toUpperCase","types","typeTags","tag","Object","values","spec","tags","find","name","metaTypes","description","map","op","type","index","metaType","toString"],"mappings":";;;;;;;AA0BA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAWO,IAAMA,YAAmC,GAAG,QAAa;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAC9D,MAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAuB,gCAA7B;AACA,MAAMC,QAAQ,GAAG,kCAAjB;AACA,MAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,yBAAZ;AAAuCC,IAAAA;AAAvC,MACJ,2BADF;AAEA,MAAMC,iBAAiB,GAAG,6BAAYC,sBAAZ,CAA1B;AACA,MAAM;AAAEC,IAAAA;AAAF,MAAyB,+BAA/B;AACA,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,qBAASJ,iBAAT,CAAlC;AACA;;AAEA,MAAMK,YAAY,GAAIC,MAAD,IAAoB;AACvCT,IAAAA,QAAQ,CAACD,QAAQ,CAACW,QAAV,EAAoB;AAC1BC,MAAAA,CAAC,EAAEF,MAAM,KAAK,KAAX,GAAmB,IAAnB,GAA0BA,MAAM,CAACG,WAAP;AADH,KAApB,CAAR;AAGD,GAJD;;AAMA,wBAAU,MAAM;AACd,QAAMC,YAAY,GAAG,IAAIC,eAAJ,CAAoBf,QAAQ,CAACgB,MAA7B,CAArB;AACA,QAAIC,SAAS,GAAGH,YAAY,CAACI,GAAb,CAAiB,GAAjB,KAAyB,KAAzC;AACAD,IAAAA,SAAS,GA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AjB;AAAqB,IAAA,EAAE,EAAC,OAAxB;AAAgC,IAAA,EAAE,EAAC;AAAnC,KACGA,EADH,CADD,CATH,CAFF,EAiBGT,MAAM,CAACC,MAAP,CAAcJ,KAAd,EAAqBW,GAArB,CACC,CAACE,IAAD,EAAOC,KAAP,KACE,CAAC9B,iBAAiB,KAAK,KAAtB,IACCA,iBAAiB,KAAK6B,IAAI,CAACE,QAAL,CAAcC,QAAd,GAAyBjB,WAAzB,EADxB,KAEE,6BAAC,iBAAD;AACE,IAAA,GAAG,EAAEe,KADP;AAEE,IAAA,EAAE,EAAEhC,yBAAyB,CAC3B,0BAAcJ,OAAd,EAAuBwB,GAAG,CAACM,IAA3B,EAAiCK,IAAI,CAACL,IAAtC,CAD2B;AAF/B,KAME,6BAAC,gBAAD;AAAM,IAAA,OAAO,EAAE,CAAf;AAAkB,IAAA,EAAE,EAAC;AAArB,KACE,6BAAC,2BAAD;AAAgB,IAAA,GAAG,EAAEM,KAArB;AAA4B,IAAA,IAAI,EAAED;AAAlC,IADF,CANF,CAJL,CAjBH,CADF;AAoCD,CAhFM","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 { FC } from 'react'\nimport React, { useEffect, useState } from 'react'\nimport { Grid, ButtonToggle, ButtonItem } from '@looker/components'\nimport type { ApiModel } from '@looker/sdk-codegen'\nimport { useLocation, useParams } from 'react-router-dom'\nimport { useSelector } from 'react-redux'\nimport { ApixSection, DocTitle, DocTypeSummary, Link } from '../../components'\nimport { buildTypePath, isValidFilter, useNavigation } from '../../utils'\nimport { selectTagFilter, useSettingActions } from '../../state'\nimport { useTagStoreSync } from '../utils'\nimport { getMetaTypes } from './utils'\n\ninterface TypeTagSceneProps {\n api: ApiModel\n}\n\ninterface TypeTagSceneParams {\n specKey: string\n typeTag: string\n}\n\nexport const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {\n const { specKey, typeTag } = useParams<TypeTagSceneParams>()\n const location = useLocation()\n const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =\n useNavigation()\n const selectedTagFilter = useSelector(selectTagFilter)\n const { setTagFilterAction } = useSettingActions()\n const [tagFilter, setTagFilter] = useState(selectedTagFilter)\n useTagStoreSync()\n\n const handleChange = (filter: string) => {\n navigate(location.pathname, {\n t: filter === 'ALL' ? null : filter.toLowerCase(),\n })\n }\n\n useEffect(() => {\n const searchParams = new URLSearchParams(location.search)\n let verbParam = searchParams.get('t') || 'ALL'\n verbParam = isValidFilter(location.pathname, verbParam)\n ? verbParam.toUpperCase()\n : 'ALL'\n setTagFilterAction({\n tagFilter: verbParam,\n })\n }, [location.search])\n\n const types = api.typeTags[typeTag]\n useEffect(() => {\n if (!types) {\n navigateWithGlobalParams(`/${specKey}/types`)\n }\n }, [types])\n\n useEffect(() => {\n setTagFilter(selectedTagFilter)\n }, [selectedTagFilter])\n\n if (!types) {\n return <></>\n }\n\n const tag = Object.values(api.spec.tags!).find((tag) => tag.name === typeTag)!\n const metaTypes = getMetaTypes(types)\n return (\n <ApixSection>\n <DocTitle>{`${tag.name}: ${tag.description}`}</DocTitle>\n <ButtonToggle\n mb=\"small\"\n mt=\"xlarge\"\n value={tagFilter}\n onChange={handleChange}\n >\n <ButtonItem key=\"ALL\" px=\"large\" py=\"xsmall\">\n ALL\n </ButtonItem>\n {metaTypes.map((op) => (\n <ButtonItem key={op} px=\"large\" py=\"xsmall\">\n {op}\n </ButtonItem>\n ))}\n </ButtonToggle>\n {Object.values(types).map(\n (type, index) =>\n (selectedTagFilter === 'ALL' ||\n selectedTagFilter === type.metaType.toString().toUpperCase()) && (\n <Link\n key={index}\n to={buildPathWithGlobalParams(\n buildTypePath(specKey, tag.name, type.name)\n )}\n >\n <Grid columns={1} py=\"xsmall\">\n <DocTypeSummary key={index} type={type} />\n </Grid>\n </Link>\n )\n )}\n </ApixSection>\n )\n}\n"],"file":"TypeTagScene.js"}
@@ -22,7 +22,7 @@ function* initSaga(action) {
22
22
  var specs = yield* (0, _typedReduxSaga.call)([adaptor, 'fetchSpecList']);
23
23
  var currentSpecKey = action.payload.specKey;
24
24
 
25
- if (!currentSpecKey) {
25
+ if (!currentSpecKey || !specs[currentSpecKey]) {
26
26
  currentSpecKey = Object.values(specs).find(spec => spec.status === 'current').key;
27
27
  }
28
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/state/specs/sagas.ts"],"names":["initSaga","action","initSpecsSuccessAction","initSpecsFailureAction","specActions","adaptor","specs","currentSpecKey","payload","specKey","Object","values","find","spec","status","key","error","Error","message","setCurrentSpecSaga","setCurrentSpecSuccessAction","setCurrentSpecFailureAction","state","newSpec","api","saga","initSpecsAction","setCurrentSpecAction"],"mappings":";;;;;;;AA0BA;;AAGA;;AAGA;;AAEA,UAAUA,QAAV,CAAmBC,MAAnB,EAA2D;AACzD,MAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA;AAA1B,MAAqDC,kBAA3D;AACA,MAAMC,OAAO,GAAG,4BAAhB;;A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P,CAAeD;AAFL,KAAD,CADtB,CAAP;AAMD,GARD,CAQE,OAAOS,KAAP,EAAmB;AACnB,UAAM,yBAAIK,2BAA2B,CAAC,IAAIJ,KAAJ,CAAUD,KAAK,CAACE,OAAhB,CAAD,CAA/B,CAAN;AACD;AACF;;AAEM,UAAUO,IAAV,GAAiB;AACtB,MAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAA4CvB,kBAAlD;AAEA,SAAO,+BAAUsB,eAAV,EAA2B1B,QAA3B,CAAP;AACA,SAAO,+BAAU2B,oBAAV,EAAgCR,kBAAhC,CAAP;AACD","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 { SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { call, put, takeEvery, select } from 'typed-redux-saga'\nimport type { PayloadAction } from '@reduxjs/toolkit'\n\nimport { getApixAdaptor } from '../../utils'\nimport type { RootState } from '../store'\nimport type { InitSpecsAction, SetCurrentSpecAction } from './slice'\nimport { specActions } from './slice'\n\nfunction* initSaga(action: PayloadAction<InitSpecsAction>) {\n const { initSpecsSuccessAction, initSpecsFailureAction } = specActions\n const adaptor = getApixAdaptor()\n\n try {\n const specs: SpecList = yield* call([adaptor, 'fetchSpecList'])\n let currentSpecKey = action.payload.specKey\n if (!currentSpecKey) {\n currentSpecKey = Object.values(specs).find(\n (spec) => spec.status === 'current'\n )!.key\n }\n const spec = yield* call([adaptor, 'fetchSpec'], specs[currentSpecKey])\n specs[currentSpecKey] = spec\n yield* put(initSpecsSuccessAction({ specs, currentSpecKey }))\n } catch (error: any) {\n yield* put(initSpecsFailureAction(new Error(error.message)))\n }\n}\n\nfunction* setCurrentSpecSaga(action: PayloadAction<SetCurrentSpecAction>) {\n const { setCurrentSpecSuccessAction, setCurrentSpecFailureAction } =\n specActions\n const adaptor = getApixAdaptor()\n const spec: SpecItem = yield* select(\n (state: RootState) => state.specs.specs[action.payload.currentSpecKey]\n )\n\n try {\n const newSpec = yield* call([adaptor, 'fetchSpec'], spec)\n yield* put(\n setCurrentSpecSuccessAction({\n api: newSpec.api!,\n currentSpecKey: action.payload.currentSpecKey,\n })\n )\n } catch (error: any) {\n yield put(setCurrentSpecFailureAction(new Error(error.message)))\n }\n}\n\nexport function* saga() {\n const { initSpecsAction, setCurrentSpecAction } = specActions\n\n yield* takeEvery(initSpecsAction, initSaga)\n yield* takeEvery(setCurrentSpecAction, setCurrentSpecSaga)\n}\n"],"file":"sagas.js"}
1
+ {"version":3,"sources":["../../../src/state/specs/sagas.ts"],"names":["initSaga","action","initSpecsSuccessAction","initSpecsFailureAction","specActions","adaptor","specs","currentSpecKey","payload","specKey","Object","values","find","spec","status","key","error","Error","message","setCurrentSpecSaga","setCurrentSpecSuccessAction","setCurrentSpecFailureAction","state","newSpec","api","saga","initSpecsAction","setCurrentSpecAction"],"mappings":";;;;;;;AA0BA;;AAGA;;AAGA;;AAEA,UAAUA,QAAV,CAAmBC,MAAnB,EAA2D;A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EAA6BQ,IAA7B,CAAvB;AACA,WAAO,yBACLO,2BAA2B,CAAC;AAC1BI,MAAAA,GAAG,EAAED,OAAO,CAACC,GADa;AAE1BjB,MAAAA,cAAc,EAAEN,MAAM,CAACO,OAAP,CAAeD;AAFL,KAAD,CADtB,CAAP;AAMD,GARD,CAQE,OAAOS,KAAP,EAAmB;AACnB,UAAM,yBAAIK,2BAA2B,CAAC,IAAIJ,KAAJ,CAAUD,KAAK,CAACE,OAAhB,CAAD,CAA/B,CAAN;AACD;AACF;;AAEM,UAAUO,IAAV,GAAiB;AACtB,MAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAA4CvB,kBAAlD;AAEA,SAAO,+BAAUsB,eAAV,EAA2B1B,QAA3B,CAAP;AACA,SAAO,+BAAU2B,oBAAV,EAAgCR,kBAAhC,CAAP;AACD","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 { SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { call, put, takeEvery, select } from 'typed-redux-saga'\nimport type { PayloadAction } from '@reduxjs/toolkit'\n\nimport { getApixAdaptor } from '../../utils'\nimport type { RootState } from '../store'\nimport type { InitSpecsAction, SetCurrentSpecAction } from './slice'\nimport { specActions } from './slice'\n\nfunction* initSaga(action: PayloadAction<InitSpecsAction>) {\n const { initSpecsSuccessAction, initSpecsFailureAction } = specActions\n const adaptor = getApixAdaptor()\n\n try {\n const specs: SpecList = yield* call([adaptor, 'fetchSpecList'])\n let currentSpecKey = action.payload.specKey\n if (!currentSpecKey || !specs[currentSpecKey]) {\n // if current spec key is invalid or not assigned, default to the first \"current\" spec\n currentSpecKey = Object.values(specs).find(\n (spec) => spec.status === 'current'\n )!.key\n }\n const spec = yield* call([adaptor, 'fetchSpec'], specs[currentSpecKey])\n specs[currentSpecKey] = spec\n yield* put(initSpecsSuccessAction({ specs, currentSpecKey }))\n } catch (error: any) {\n yield* put(initSpecsFailureAction(new Error(error.message)))\n }\n}\n\nfunction* setCurrentSpecSaga(action: PayloadAction<SetCurrentSpecAction>) {\n const { setCurrentSpecSuccessAction, setCurrentSpecFailureAction } =\n specActions\n const adaptor = getApixAdaptor()\n const spec: SpecItem = yield* select(\n (state: RootState) => state.specs.specs[action.payload.currentSpecKey]\n )\n\n try {\n const newSpec = yield* call([adaptor, 'fetchSpec'], spec)\n yield* put(\n setCurrentSpecSuccessAction({\n api: newSpec.api!,\n currentSpecKey: action.payload.currentSpecKey,\n })\n )\n } catch (error: any) {\n yield put(setCurrentSpecFailureAction(new Error(error.message)))\n }\n}\n\nexport function* saga() {\n const { initSpecsAction, setCurrentSpecAction } = specActions\n\n yield* takeEvery(initSpecsAction, initSaga)\n yield* takeEvery(setCurrentSpecAction, setCurrentSpecSaga)\n}\n"],"file":"sagas.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/adaptorUtils.ts"],"names":["makeApi","content","json","JSON","parse","ApiModel","fromJson","fullify","uri","baseUrl","match","url","URL","toString","apiSpecBits","spec","specURL","split","slice","funFetch","version","name","sdk","ok","specUrlFetch","error","undefined","sdkSpecFetch","fetcher","api","fallbackFetch","console","authed","authSession","isAuthenticated","login"],"mappings":";;;;;;;AA2BA;;AACA;;AACA;;AAEA;;;;;;AAmDA,IAAMA,OAAO,GAAIC,OAAD,IAAmC;AACjD,MAAIC,IAAJ;;AACA,MAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;AAC/BC,IAAAA,IAAI,GAAGC,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAP;AACD,GAFD,MAEO;AACLC,IAAAA,IAAI,GAAGD,OAAP;AACD;;AACDC,EAAAA,IAAI,GAAG,mCAAkBA,IAAlB,CAAP;AACA,SAAOG,qBAASC,QAAT,CAAkBJ,IAAlB,CAAP;AACD,CATD;;AAgBO,IAAMK,OAAO,GAAG,CAACC,GAAD,EAAcC,OAAd,KAA0C;AAC/D,MAAID,GAAG,CAACE,KAAJ,CAAU,UAAV,CAAJ,EAA2B;AACzB,WAAOF,GAAP;AACD;;AACD,MAAMG,GAAG,GAAG,IAAIC,GAAJ,CAAQJ,GAAR,EAAaC,OAAb,CAAZ;AACA,SAAOE,GAAG,CAACE,QAAJ,EAAP;AACD,CANM;;;;AAWP,IAAMC,WAAW,GAAIC,IAAD;AAAA;;AAAA,SAClB,kBAAAA,IAAI,CAACC,OAAL,gEAAcC,KAAd,CAAoB,GAApB,EAAyBC,KAAzB,CAA+B,CAAC,CAAhC,MAAsC,EADpB;AAAA,CAApB;;AAQO,IAAMC,QAAQ,GAAG,CAACC,OAAD,EAAkBC,IAAlB,KAAoD;AAC1E,MAAMC,GAAG,GAAG,qCAAgBA,GAA5B;AACA,SAAOA,GAAG,CAACC,EAAJ,CAAO,mBAASD,GAAT,EAAcF,OAAd,EAAuBC,IAAvB,CAAP,CAAP;AACD,CAHM;;;;AASA,IAAMG,YAAY;AAAA,+BAAG,WAAOb,GAAP,EAA4C;AACtE,QAAI;AACF,UAAMV,OA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AACD;;AACDN,MAAAA,GAAG,SAASF,YAAY,CAACZ,IAAD,EAAOa,OAAP,CAAxB;AACD;;AACD,WAAOC,GAAP;AACD,GArByB;;AAAA,kBAAbC,aAAa;AAAA;AAAA;AAAA,GAAnB","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 { ILookerVersions, SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { ApiModel, upgradeSpecObject } from '@looker/sdk-codegen'\nimport { api_spec } from '@looker/sdk'\nimport { getEnvAdaptor } from '@looker/extension-utils'\nimport type { RunItValues } from '@looker/run-it'\nimport { getUrl } from '@looker/run-it'\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/** function to retrieve a spec based on version and name */\nexport type ApiSpecFetcher = (\n version: string,\n name: string\n) => Promise<string | RunItValues>\n\n/** Either the spec is parsed or it's undefined */\nexport type ParsedSpec = ApiModel | undefined\n\n/** service abstraction for extension and browser based usage */\nexport interface RunItConfigurator {\n getStorage: (key: string, defaultValue?: string) => IStorageValue\n setStorage(key: string, value: string, location: 'local' | 'session'): string\n removeStorage(key: string): void\n}\n\n/** Processed specifications */\nexport interface ILoadedSpecs {\n /** API server url */\n baseUrl: string\n /** Web server url */\n webUrl: string\n /** should APIX run headless? */\n headless: boolean\n /** loaded specifications */\n specs: SpecList\n /** communication errors */\n fetchResult: string\n}\n\n/** Extends versions payload with headless toggle for API Explorer */\nexport interface IAPIXConfig extends ILookerVersions {\n headless?: boolean\n}\n\n/**\n * Convert content into an ApiModel\n * @param content to convert\n */\nconst makeApi = (content: string | RunItValues) => {\n let json\n if (typeof content === 'string') {\n json = JSON.parse(content)\n } else {\n json = content\n }\n json = upgradeSpecObject(json)\n return ApiModel.fromJson(json)\n}\n\n/**\n * Ensure the URI is a full URL\n * @param uri possible relative path\n * @param baseUrl base url for qualifying full path\n */\nexport const fullify = (uri: string, baseUrl: string): string => {\n if (uri.match(/^https?:/)) {\n return uri\n }\n const url = new URL(uri, baseUrl)\n return url.toString()\n}\n/**\n * parse spec url into version and name for api_spec cccall\n * @param spec to parse\n */\nconst apiSpecBits = (spec: SpecItem): string[] =>\n spec.specURL?.split('/').slice(-2) || []\n\n/**\n * Use the functional api_spec fetch\n * @param version to retrieve\n * @param name to retrieve\n */\nexport const funFetch = (version: string, name: string): Promise<string> => {\n const sdk = getEnvAdaptor().sdk\n return sdk.ok(api_spec(sdk, version, name))\n}\n\n/**\n * try to fetch a spec by URL, trap any errors and return undefined\n * @param url to convert to an API spec\n */\nexport const specUrlFetch = async (url: string): Promise<ParsedSpec> => {\n try {\n const content = await getUrl(url)\n return makeApi(content)\n } catch (error) {\n return undefined\n }\n}\n\n/**\n * fetch and compile an API specification to an ApiModel if it's not already available\n *\n * **NOTE**: This uses Looker API 4.0 to fetch the specification so fetch works with CORS\n *\n * @param spec to fetch and compile\n * @param fetcher function to retrieve API spec content\n */\nexport const sdkSpecFetch = async (\n spec: SpecItem,\n fetcher: ApiSpecFetcher\n): Promise<ParsedSpec> => {\n if (spec.api) return spec.api\n if (!spec.specURL) return undefined\n const [version, name] = apiSpecBits(spec)\n const content = await fetcher(version, name)\n return makeApi(content)\n}\n\n/** Attempt to retrieve spec by URL, then api_spec SDK call\n *\n * @param spec to fetch\n * @param fetcher function to retrieve and parse spec\n */\nexport const fallbackFetch = async (\n spec: SpecItem,\n fetcher: ApiSpecFetcher\n): Promise<ParsedSpec> => {\n if (spec.api) return spec.api\n if (!spec.specURL) return undefined\n let api: ParsedSpec\n try {\n api = await specUrlFetch(spec.specURL)\n } catch (error) {\n console.error({ error })\n }\n if (!api) {\n const sdk = getEnvAdaptor().sdk\n const authed = sdk.authSession.isAuthenticated()\n if (!authed) {\n await sdk.authSession.login()\n }\n api = await sdkSpecFetch(spec, fetcher)\n }\n return api\n}\n"],"file":"adaptorUtils.js"}
1
+ {"version":3,"sources":["../../src/utils/adaptorUtils.ts"],"names":["makeApi","content","json","JSON","parse","ApiModel","fromJson","fullify","uri","baseUrl","match","url","URL","toString","apiSpecBits","spec","specURL","split","slice","funFetch","version","name","sdk","ok","specUrlFetch","error","undefined","sdkSpecFetch","fetcher","api","fallbackFetch","console","authed","authSession","isAuthenticated","login"],"mappings":";;;;;;;AA2BA;;AACA;;AACA;;AAEA;;;;;;AAmDA,IAAMA,OAAO,GAAIC,OAAD,IAAmC;AACjD,MAAIC,IAAJ;;AACA,MAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;AAC/BC,IAAAA,IAAI,GAAGC,IAAI,CAACC,KAAL,CAAWH,OAAX,CAAP;AACD,GAFD,MAEO;AACLC,IAAAA,IAAI,GAAGD,OAAP;AACD;;AACDC,EAAAA,IAAI,GAAG,mCAAkBA,IAAlB,CAAP;AACA,SAAOG,qBAASC,QAAT,CAAkBJ,IAAlB,CAAP;AACD,CATD;;AAgBO,IAAMK,OA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AAOrB,OAAO,CAACC,OAAD,CAAd;AACD,GATwB;;AAAA,kBAAZ0B,YAAY;AAAA;AAAA;AAAA,GAAlB;;;;AAgBA,IAAMG,aAAa;AAAA,gCAAG,WAC3Bf,IAD2B,EAE3Ba,OAF2B,EAGH;AACxB,QAAIb,IAAI,CAACc,GAAT,EAAc,OAAOd,IAAI,CAACc,GAAZ;AACd,QAAI,CAACd,IAAI,CAACC,OAAV,EAAmB,OAAOU,SAAP;AACnB,QAAIG,GAAJ;;AACA,QAAI;AACFA,MAAAA,GAAG,SAASL,YAAY,CAACT,IAAI,CAACC,OAAN,CAAxB;AACD,KAFD,CAEE,OAAOS,KAAP,EAAc;AACdM,MAAAA,OAAO,CAACN,KAAR,CAAc;AAAEA,QAAAA;AAAF,OAAd;AACD;;AACD,QAAI,CAACI,GAAL,EAAU;AACR,UAAMP,GAAG,GAAG,qCAAgBA,GAA5B;AACA,UAAMU,MAAM,GAAGV,GAAG,CAACW,WAAJ,CAAgBC,eAAhB,EAAf;;AACA,UAAI,CAACF,MAAL,EAAa;AACX,cAAMV,GAAG,CAACW,WAAJ,CAAgBE,KAAhB,EAAN;AACD;;AACDN,MAAAA,GAAG,SAASF,YAAY,CAACZ,IAAD,EAAOa,OAAP,CAAxB;AACD;;AACD,WAAOC,GAAP;AACD,GArByB;;AAAA,kBAAbC,aAAa;AAAA;AAAA;AAAA,GAAnB","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 { ILookerVersions, SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { ApiModel, upgradeSpecObject } from '@looker/sdk-codegen'\nimport { api_spec } from '@looker/sdk'\nimport { getEnvAdaptor } from '@looker/extension-utils'\nimport type { RunItValues } from '@looker/run-it'\nimport { getUrl } from '@looker/run-it'\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/** function to retrieve a spec based on version and name */\nexport type ApiSpecFetcher = (\n version: string,\n name: string\n) => Promise<string | RunItValues>\n\n/** Either the spec is parsed or it's undefined */\nexport type ParsedSpec = ApiModel | undefined\n\n/** service abstraction for extension and browser based usage */\nexport interface RunItConfigurator {\n getStorage: (key: string, defaultValue?: string) => IStorageValue\n setStorage(key: string, value: string, location: 'local' | 'session'): string\n removeStorage(key: string): void\n}\n\n/** Processed specifications */\nexport interface ILoadedSpecs {\n /** API server url */\n baseUrl: string\n /** Web server url */\n webUrl: string\n /** should APIX run headless? */\n headless: boolean\n /** loaded specifications */\n specs: SpecList\n /** communication errors */\n fetchResult: string\n}\n\n/** Extends versions payload with headless toggle for API Explorer */\nexport interface IAPIXConfig extends ILookerVersions {\n headless?: boolean\n}\n\n/**\n * Convert content into an ApiModel\n * @param content to convert\n */\nconst makeApi = (content: string | RunItValues) => {\n let json\n if (typeof content === 'string') {\n json = JSON.parse(content)\n } else {\n json = content\n }\n json = upgradeSpecObject(json)\n return ApiModel.fromJson(json)\n}\n\n/**\n * Ensure the URI is a full URL\n * @param uri possible relative path\n * @param baseUrl base url for qualifying full path\n */\nexport const fullify = (uri: string, baseUrl: string): string => {\n if (uri.match(/^https?:/)) {\n return uri\n }\n const url = new URL(uri, baseUrl)\n return url.toString()\n}\n/**\n * parse spec url into version and name for api_spec call\n * @param spec to parse\n */\nconst apiSpecBits = (spec: SpecItem): string[] =>\n spec.specURL?.split('/').slice(-2) || []\n\n/**\n * Use the functional api_spec fetch\n * @param version to retrieve\n * @param name to retrieve\n */\nexport const funFetch = (version: string, name: string): Promise<string> => {\n const sdk = getEnvAdaptor().sdk\n return sdk.ok(api_spec(sdk, version, name))\n}\n\n/**\n * try to fetch a spec by URL, trap any errors and return undefined\n * @param url to convert to an API spec\n */\nexport const specUrlFetch = async (url: string): Promise<ParsedSpec> => {\n try {\n const content = await getUrl(url)\n return makeApi(content)\n } catch (error) {\n return undefined\n }\n}\n\n/**\n * fetch and compile an API specification to an ApiModel if it's not already available\n *\n * **NOTE**: This uses Looker API 4.0 to fetch the specification so fetch works with CORS\n *\n * @param spec to fetch and compile\n * @param fetcher function to retrieve API spec content\n */\nexport const sdkSpecFetch = async (\n spec: SpecItem,\n fetcher: ApiSpecFetcher\n): Promise<ParsedSpec> => {\n if (spec.api) return spec.api\n if (!spec.specURL) return undefined\n const [version, name] = apiSpecBits(spec)\n const content = await fetcher(version, name)\n return makeApi(content)\n}\n\n/** Attempt to retrieve spec by URL, then api_spec SDK call\n *\n * @param spec to fetch\n * @param fetcher function to retrieve and parse spec\n */\nexport const fallbackFetch = async (\n spec: SpecItem,\n fetcher: ApiSpecFetcher\n): Promise<ParsedSpec> => {\n if (spec.api) return spec.api\n if (!spec.specURL) return undefined\n let api: ParsedSpec\n try {\n api = await specUrlFetch(spec.specURL)\n } catch (error) {\n console.error({ error })\n }\n if (!api) {\n const sdk = getEnvAdaptor().sdk\n const authed = sdk.authSession.isAuthenticated()\n if (!authed) {\n await sdk.authSession.login()\n }\n api = await sdkSpecFetch(spec, fetcher)\n }\n return api\n}\n"],"file":"adaptorUtils.js"}
package/lib/utils/path.js CHANGED
@@ -83,7 +83,8 @@ var getSpecKey = location => {
83
83
  }));
84
84
  }
85
85
 
86
- return ((_match = match) === null || _match === void 0 ? void 0 : (_match$groups = _match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.specKey) || null;
86
+ var result = ((_match = match) === null || _match === void 0 ? void 0 : (_match$groups = _match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.specKey) || null;
87
+ return result;
87
88
  };
88
89
 
89
90
  exports.getSpecKey = getSpecKey;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/path.ts"],"names":["methodFilterOptions","typeFilterOptions","buildMethodPath","specKey","tag","methodName","params","buildTypePath","typeName","diffPath","oAuthPath","getMethodTag","api","Object","entries","tags","filter","methods","map","methodTag","isMethod","item","getTypeTag","type","method","name","buildPath","path","getSpecKey","location","pathname","match","startsWith","pattern","RegExp","groups","getSceneType","tagType","isValidFilter","isValid","sceneType","localeCompare","sensitivity","test"],"mappings":";;;;;;;AA2BA;;AAEA;;;;;;;;AAEO,IAAMA,mBAAmB,GAAG,iCAA5B;;AACA,IAAMC,iBAAiB,GAAG,6CAA1B;;;AAUA,IAAMC,eAAe,GAAG,CAC7BC,OAD6B,EAE7BC,GAF6B,EAG7BC,UAH6B,EAI7BC,MAJ6B,gBAKtBH,OALsB,sBAKHC,GALG,cAKIC,UALJ,SAKiBC,MAAM,cAAOA,MAAP,IAAkB,EALzC,CAAxB;;;;AAeA,IAAMC,aAAa,GAAG,CAC3BJ,OAD2B,EAE3BC,GAF2B,EAG3BI,QAH2B,EAI3BF,MAJ2B,gBAKpBH,OALoB,oBAKHC,GALG,cAKII,QALJ,SAKeF,MAAM,cAAOA,MAAP,IAAkB,EALvC,CAAtB;;;AAOA,IAAMG,QAAQ,GAAG,MAAjB;;AACA,IAAMC,SAAS,GAAG,OAAlB;;;AAQ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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 { ApiModel, IMethod, IType } from '@looker/sdk-codegen'\nimport { firstMethodRef } from '@looker/sdk-codegen'\nimport type { Location as HLocation } from 'history'\nimport { matchPath } from 'react-router'\n\nexport const methodFilterOptions = /GET$|POST$|PUT$|PATCH$|DELETE$/i\nexport const typeFilterOptions = /SPECIFICATION$|WRITE$|REQUEST$|ENUMERATED$/i\n\n/**\n * Builds a path matching the route used by MethodScene\n * @param specKey A string to identify the spec in the URL\n * @param tag Corresponding method tag\n * @param methodName A method name\n * @param params Hash of query param name/value pairs to include in the destination url\n * @returns a Method path\n */\nexport const buildMethodPath = (\n specKey: string,\n tag: string,\n methodName: string,\n params?: string\n) => `/${specKey}/methods/${tag}/${methodName}${params ? `?${params}` : ''}`\n\n/**\n * Builds a path matching the route used by TypeScene\n * @param specKey A string to identify the spec in the URL\n * @param tag Corresponding type tag\n * @param typeName A type name\n * @param params Hash of query param name/value pairs to include in the destination url\n * @returns a Type path\n */\nexport const buildTypePath = (\n specKey: string,\n tag: string,\n typeName: string,\n params?: string\n) => `/${specKey}/types/${tag}/${typeName}${params ? `?${params}` : ''}`\n\nexport const diffPath = 'diff'\nexport const oAuthPath = 'oauth'\n\n/**\n * Returns the tag for a given method name\n * @param api Parsed api\n * @param methodName SDK method name\n * @returns Corresponding tag\n */\nconst getMethodTag = (api: ApiModel, methodName: string) => {\n // Find tag containing methodName\n return Object.entries(api.tags)\n .filter(([, methods]) => methodName in methods)\n .map(([methodTag]) => methodTag)[0]\n}\n\n/**\n * Is this item a method? Check without requiring `instanceof Method`\n * @param item to check for method or type\n */\nexport const isMethod = (item: IMethod | IType) => 'params' in item\n\n/**\n * Return the tag for a give type\n * @param api Parsed api\n * @param type to tag\n */\nconst getTypeTag = (api: ApiModel, type: IType) => {\n const method = firstMethodRef(api, type)\n return getMethodTag(api, method.name)\n}\n\n/**\n * Builds a path matching MethodScene or TypeScene route\n * @param api parsed api\n * @param item A method or type item\n * @param specKey A string to identify the spec in the url\n * @returns a method or type path\n */\nexport const buildPath = (\n api: ApiModel,\n item: IMethod | IType,\n specKey: string\n) => {\n let path\n if (isMethod(item)) {\n const tag = getMethodTag(api, item.name)\n path = buildMethodPath(specKey, tag, item.name)\n } else {\n const tag = getTypeTag(api, item as IType)\n path = buildTypePath(specKey, tag, item.name)\n }\n return path\n}\n\n/**\n * Determine API specification keys from URL pattern\n * @param location service to examine\n */\nexport const getSpecKey = (location: HLocation | Location): string | null => {\n const pathname = location.pathname\n let match\n if (pathname.startsWith(`/${diffPath}`)) {\n const pattern = new RegExp(`(?:/${diffPath})/(?<specKey>\\\\w+.\\\\w+)`)\n match = pathname.match(pattern)\n } else {\n match = pathname.match(/\\/(?<specKey>\\w+\\.\\w+).*/)\n }\n return match?.groups?.specKey || null\n}\n\n/**\n * Gets the scene type of the current page\n * @param path path of browser location\n * @returns string representing the scene type\n */\nexport const getSceneType = (path: string) => {\n const match = matchPath<{ tagType: string }>(path, {\n path: '/:specKey/:tagType',\n })\n return match ? match!.params.tagType : ''\n}\n\n/**\n * Confirms if filter is valid for a given method/type tag\n * @param path browser location pathname\n * @param filter filter tag for page\n */\nexport const isValidFilter = (path: string, filter: string) => {\n let isValid\n const sceneType = getSceneType(path)\n if (!sceneType) isValid = false\n else if (!filter.localeCompare('all', 'en', { sensitivity: 'base' }))\n isValid = true\n else if (sceneType === 'methods') {\n isValid = methodFilterOptions.test(filter)\n } else {\n isValid = typeFilterOptions.test(filter)\n }\n return isValid\n}\n"],"file":"path.js"}
1
+ {"version":3,"sources":["../../src/utils/path.ts"],"names":["methodFilterOptions","typeFilterOptions","buildMethodPath","specKey","tag","methodName","params","buildTypePath","typeName","diffPath","oAuthPath","getMethodTag","api","Object","entries","tags","filter","methods","map","methodTag","isMethod","item","getTypeTag","type","method","name","buildPath","path","getSpecKey","location","pathname","match","startsWith","pattern","RegExp","result","groups","getSceneType","tagType","isValidFilter","isValid","sceneType","localeCompare","sensitivity","test"],"mappings":";;;;;;;AA2BA;;AAEA;;;;;;;;AAEO,IAAMA,mBAAmB,GAAG,iCAA5B;;AACA,IAAMC,iBAAiB,GAAG,6CAA1B;;;AAUA,IAAMC,eAAe,GAAG,CAC7BC,OAD6B,EAE7BC,GAF6B,EAG7BC,UAH6B,EAI7BC,MAJ6B,gBAKtBH,OALsB,sBAKHC,GALG,cAKIC,UALJ,SAKiBC,MAAM,cAAOA,MAAP,IAAkB,EALzC,CAAxB;;;;AAeA,IAAMC,aAAa,GAAG,CAC3BJ,OAD2B,EAE3BC,GAF2B,EAG3BI,QAH2B,EAI3BF,MAJ2B,gBAKpBH,OALoB,oBAKHC,GALG,cAKII,QALJ,SAKeF,MAAM,cAAOA,MAAP,IAAkB,EALvC,CAAtB;;;AAOA,IAAMG,QAAQ,GAAG,MAAjB;;AACA,IAAMC,SAAS,GAAG,OAAlB;;;AAQP,IAAMC,YAAY,GAAG,CAACC,GAAD,EAAgBP,UAAhB,KAAuC;AAE1D,SAAOQ,MAAM,CAACC,OAAP,CAAeF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AAJ,eAAkBzB,QAAlB,6BAAhB;AACAsB,IAAAA,KAAK,GAAGD,QAAQ,CAACC,KAAT,CAAeE,OAAf,CAAR;AACD,GAHD,MAGO;AACLF,IAAAA,KAAK,GAAGD,QAAQ,CAACC,KAAT,aAAe,oCAAf;AAAA;AAAA,OAAR;AACD;;AACD,MAAMI,MAAM,GAAG,WAAAJ,KAAK,UAAL,yDAAOK,MAAP,gEAAejC,OAAf,KAA0B,IAAzC;AACA,SAAOgC,MAAP;AACD,CAXM;;;;AAkBA,IAAME,YAAY,GAAIV,IAAD,IAAkB;AAC5C,MAAMI,KAAK,GAAG,4BAA+BJ,IAA/B,EAAqC;AACjDA,IAAAA,IAAI,EAAE;AAD2C,GAArC,CAAd;AAGA,SAAOI,KAAK,GAAGA,KAAK,CAAEzB,MAAP,CAAcgC,OAAjB,GAA2B,EAAvC;AACD,CALM;;;;AAYA,IAAMC,aAAa,GAAG,CAACZ,IAAD,EAAeX,MAAf,KAAkC;AAC7D,MAAIwB,OAAJ;AACA,MAAMC,SAAS,GAAGJ,YAAY,CAACV,IAAD,CAA9B;AACA,MAAI,CAACc,SAAL,EAAgBD,OAAO,GAAG,KAAV,CAAhB,KACK,IAAI,CAACxB,MAAM,CAAC0B,aAAP,CAAqB,KAArB,EAA4B,IAA5B,EAAkC;AAAEC,IAAAA,WAAW,EAAE;AAAf,GAAlC,CAAL,EACHH,OAAO,GAAG,IAAV,CADG,KAEA,IAAIC,SAAS,KAAK,SAAlB,EAA6B;AAChCD,IAAAA,OAAO,GAAGxC,mBAAmB,CAAC4C,IAApB,CAAyB5B,MAAzB,CAAV;AACD,GAFI,MAEE;AACLwB,IAAAA,OAAO,GAAGvC,iBAAiB,CAAC2C,IAAlB,CAAuB5B,MAAvB,CAAV;AACD;AACD,SAAOwB,OAAP;AACD,CAZM","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 { ApiModel, IMethod, IType } from '@looker/sdk-codegen'\nimport { firstMethodRef } from '@looker/sdk-codegen'\nimport type { Location as HLocation } from 'history'\nimport { matchPath } from 'react-router'\n\nexport const methodFilterOptions = /GET$|POST$|PUT$|PATCH$|DELETE$/i\nexport const typeFilterOptions = /SPECIFICATION$|WRITE$|REQUEST$|ENUMERATED$/i\n\n/**\n * Builds a path matching the route used by MethodScene\n * @param specKey A string to identify the spec in the URL\n * @param tag Corresponding method tag\n * @param methodName A method name\n * @param params Hash of query param name/value pairs to include in the destination url\n * @returns a Method path\n */\nexport const buildMethodPath = (\n specKey: string,\n tag: string,\n methodName: string,\n params?: string\n) => `/${specKey}/methods/${tag}/${methodName}${params ? `?${params}` : ''}`\n\n/**\n * Builds a path matching the route used by TypeScene\n * @param specKey A string to identify the spec in the URL\n * @param tag Corresponding type tag\n * @param typeName A type name\n * @param params Hash of query param name/value pairs to include in the destination url\n * @returns a Type path\n */\nexport const buildTypePath = (\n specKey: string,\n tag: string,\n typeName: string,\n params?: string\n) => `/${specKey}/types/${tag}/${typeName}${params ? `?${params}` : ''}`\n\nexport const diffPath = 'diff'\nexport const oAuthPath = 'oauth'\n\n/**\n * Returns the tag for a given method name\n * @param api Parsed api\n * @param methodName SDK method name\n * @returns Corresponding tag\n */\nconst getMethodTag = (api: ApiModel, methodName: string) => {\n // Find tag containing methodName\n return Object.entries(api.tags)\n .filter(([, methods]) => methodName in methods)\n .map(([methodTag]) => methodTag)[0]\n}\n\n/**\n * Is this item a method? Check without requiring `instanceof Method`\n * @param item to check for method or type\n */\nexport const isMethod = (item: IMethod | IType) => 'params' in item\n\n/**\n * Return the tag for a give type\n * @param api Parsed api\n * @param type to tag\n */\nconst getTypeTag = (api: ApiModel, type: IType) => {\n const method = firstMethodRef(api, type)\n return getMethodTag(api, method.name)\n}\n\n/**\n * Builds a path matching MethodScene or TypeScene route\n * @param api parsed api\n * @param item A method or type item\n * @param specKey A string to identify the spec in the url\n * @returns a method or type path\n */\nexport const buildPath = (\n api: ApiModel,\n item: IMethod | IType,\n specKey: string\n) => {\n let path\n if (isMethod(item)) {\n const tag = getMethodTag(api, item.name)\n path = buildMethodPath(specKey, tag, item.name)\n } else {\n const tag = getTypeTag(api, item as IType)\n path = buildTypePath(specKey, tag, item.name)\n }\n return path\n}\n\n/**\n * Determine API specification keys from URL pattern\n * @param location service to examine\n */\nexport const getSpecKey = (location: HLocation | Location): string | null => {\n const pathname = location.pathname\n let match\n if (pathname.startsWith(`/${diffPath}`)) {\n const pattern = new RegExp(`(?:/${diffPath})/(?<specKey>\\\\w+.\\\\w+)`)\n match = pathname.match(pattern)\n } else {\n match = pathname.match(/\\/(?<specKey>\\w+\\.\\w+).*/)\n }\n const result = match?.groups?.specKey || null\n return result\n}\n\n/**\n * Gets the scene type of the current page\n * @param path path of browser location\n * @returns string representing the scene type\n */\nexport const getSceneType = (path: string) => {\n const match = matchPath<{ tagType: string }>(path, {\n path: '/:specKey/:tagType',\n })\n return match ? match!.params.tagType : ''\n}\n\n/**\n * Confirms if filter is valid for a given method/type tag\n * @param path browser location pathname\n * @param filter filter tag for page\n */\nexport const isValidFilter = (path: string, filter: string) => {\n let isValid\n const sceneType = getSceneType(path)\n if (!sceneType) isValid = false\n else if (!filter.localeCompare('all', 'en', { sensitivity: 'base' }))\n isValid = true\n else if (sceneType === 'methods') {\n isValid = methodFilterOptions.test(filter)\n } else {\n isValid = typeFilterOptions.test(filter)\n }\n return isValid\n}\n"],"file":"path.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/api-explorer",
3
- "version": "0.9.39",
3
+ "version": "0.9.41",
4
4
  "description": "Looker API Explorer",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@looker/components-test-utils": "^1.5.26",
36
- "@looker/sdk-codegen-scripts": "^21.4.5",
37
- "@looker/sdk-node": "^22.16.0",
36
+ "@looker/sdk-codegen-scripts": "^21.4.7",
37
+ "@looker/sdk-node": "^22.20.0",
38
38
  "@styled-icons/styled-icon": "^10.6.3",
39
39
  "@testing-library/jest-dom": "^5.11.6",
40
40
  "@testing-library/react": "^11.2.2",
@@ -64,19 +64,19 @@
64
64
  "style-loader": "^1.1.3",
65
65
  "webpack-bundle-analyzer": "^4.2.0",
66
66
  "webpack-cli": "^4.6.0",
67
- "webpack-dev-server": "^3.11.2",
67
+ "webpack-dev-server": "^4.8.1",
68
68
  "webpack-merge": "^5.7.3"
69
69
  },
70
70
  "dependencies": {
71
- "@looker/code-editor": "^0.1.24",
71
+ "@looker/code-editor": "^0.1.26",
72
72
  "@looker/components": "^3.0.8",
73
73
  "@looker/design-tokens": "^2.7.21",
74
- "@looker/extension-utils": "^0.1.16",
74
+ "@looker/extension-utils": "^0.1.18",
75
75
  "@looker/icons": "^1.5.3",
76
76
  "@looker/redux": "0.0.0",
77
- "@looker/run-it": "^0.9.39",
78
- "@looker/sdk": "^22.16.0",
79
- "@looker/sdk-codegen": "^21.7.1",
77
+ "@looker/run-it": "^0.9.41",
78
+ "@looker/sdk": "^22.20.0",
79
+ "@looker/sdk-codegen": "^21.7.3",
80
80
  "@looker/sdk-rtl": "^21.4.0",
81
81
  "@reduxjs/toolkit": "^1.6.2",
82
82
  "@styled-icons/material": "^10.28.0",
@@ -96,5 +96,5 @@
96
96
  "ts-jest": "^26.2.0",
97
97
  "typed-redux-saga": "^1.3.1"
98
98
  },
99
- "gitHead": "2e6e19e72048e88be93af11e6de5e92cee92fed0"
99
+ "gitHead": "9c51de7916a40fd112b88db56f3ab9fc075a84d0"
100
100
  }
@@ -28,6 +28,7 @@ import { pickTooltipContent } from './utils'
28
28
  describe('DocMethodSummary utils', () => {
29
29
  test.each`
30
30
  status | expected
31
+ ${'alpha'} | ${'This alpha item is either for internal use, or not fully developed and may be significantly changed or completely removed in future releases.'}
31
32
  ${'beta'} | ${'This beta item is under development and subject to change.'}
32
33
  ${'experimental'} | ${'This experimental item is not fully developed and may be significantly changed or completely removed in future releases.'}
33
34
  ${'deprecated'} | ${'This item has been deprecated and will be removed in the future.'}
@@ -68,6 +68,8 @@ export const pickStatus = (status: string) => {
68
68
  */
69
69
  export const pickTooltipContent = (status: string) => {
70
70
  switch (status.toLowerCase()) {
71
+ case 'alpha':
72
+ return 'This alpha item is either for internal use, or not fully developed and may be significantly changed or completely removed in future releases.'
71
73
  case 'beta':
72
74
  return 'This beta item is under development and subject to change.'
73
75
  case 'experimental':
@@ -27,6 +27,7 @@ import type { FC } from 'react'
27
27
  import React, { useEffect, useState } from 'react'
28
28
  import { Select } from '@looker/components'
29
29
  import { useSelector } from 'react-redux'
30
+ import { useLocation } from 'react-router-dom'
30
31
  import { selectSdkLanguage } from '../../state'
31
32
  import { allAlias, useNavigation } from '../../utils'
32
33
  import { allSdkLanguageOptions } from './utils'
@@ -35,6 +36,7 @@ import { allSdkLanguageOptions } from './utils'
35
36
  * Allows the user to select their preferred SDK language
36
37
  */
37
38
  export const SdkLanguageSelector: FC = () => {
39
+ const location = useLocation()
38
40
  const { navigate } = useNavigation()
39
41
  const selectedSdkLanguage = useSelector(selectSdkLanguage)
40
42
  const [language, setLanguage] = useState(selectedSdkLanguage)
@@ -119,7 +119,7 @@ export const MethodScene: FC<MethodSceneProps> = ({ api }) => {
119
119
  }, [adaptor, setOn])
120
120
 
121
121
  useEffect(() => {
122
- if (method.responses && errorCode) {
122
+ if (method?.responses && errorCode) {
123
123
  if (docResponsesRef.current) {
124
124
  window.setTimeout(() => {
125
125
  docResponsesRef.current!.scrollIntoView()
@@ -41,7 +41,9 @@ jest.mock('react-router-dom', () => {
41
41
  ...ReactRouterDOM,
42
42
  useHistory: () => ({
43
43
  push: mockHistoryPush,
44
- location,
44
+ location: {
45
+ pathname: '/4.0/methods/Look',
46
+ },
45
47
  }),
46
48
  }
47
49
  })
@@ -54,7 +56,7 @@ describe('MethodTagScene', () => {
54
56
  <Route path="/:specKey/methods/:methodTag">
55
57
  <MethodTagScene api={api} />
56
58
  </Route>,
57
- ['/3.1/methods/ColorCollection']
59
+ ['/4.0/methods/ColorCollection']
58
60
  )
59
61
  expect(
60
62
  screen.getAllByRole('button', {
@@ -68,7 +70,7 @@ describe('MethodTagScene', () => {
68
70
  screen.getByText('/color_collections/standard').closest('a')
69
71
  ).toHaveAttribute(
70
72
  'href',
71
- '/3.1/methods/ColorCollection/color_collections_standard'
73
+ '/4.0/methods/ColorCollection/color_collections_standard'
72
74
  )
73
75
  })
74
76
 
@@ -78,7 +80,7 @@ describe('MethodTagScene', () => {
78
80
  <Route path="/:specKey/methods/:methodTag">
79
81
  <MethodTagScene api={api} />
80
82
  </Route>,
81
- ['/3.1/methods/ApiAuth']
83
+ ['/4.0/methods/ApiAuth']
82
84
  )
83
85
  expect(
84
86
  screen.getAllByRole('button', {
@@ -88,17 +90,18 @@ describe('MethodTagScene', () => {
88
90
  })
89
91
 
90
92
  test('it pushes filter to URL on toggle', async () => {
93
+ const site = '/4.0/methods/Look'
91
94
  renderWithRouterAndReduxProvider(
92
95
  <Route path="/:specKey/methods/:methodTag">
93
96
  <MethodTagScene api={api} />
94
97
  </Route>,
95
- ['/3.1/methods/Look']
98
+ [site]
96
99
  )
97
100
  /** Filter by GET operation */
98
101
  userEvent.click(screen.getByRole('button', { name: 'GET' }))
99
102
  await waitFor(() => {
100
103
  expect(mockHistoryPush).toHaveBeenCalledWith({
101
- pathname: location.pathname,
104
+ pathname: site,
102
105
  search: 't=get',
103
106
  })
104
107
  })
@@ -107,7 +110,7 @@ describe('MethodTagScene', () => {
107
110
  await waitFor(() => {
108
111
  // eslint-disable-next-line jest-dom/prefer-in-document
109
112
  expect(mockHistoryPush).toHaveBeenCalledWith({
110
- pathname: location.pathname,
113
+ pathname: site,
111
114
  search: 't=delete',
112
115
  })
113
116
  })
@@ -25,7 +25,7 @@
25
25
  */
26
26
  import type { FC } from 'react'
27
27
  import React, { useEffect, useState } from 'react'
28
- import { useHistory, useParams } from 'react-router-dom'
28
+ import { useHistory, useLocation, useParams } from 'react-router-dom'
29
29
  import { Grid, ButtonToggle, ButtonItem } from '@looker/components'
30
30
  import type { ApiModel } from '@looker/sdk-codegen'
31
31
  import { useSelector } from 'react-redux'
@@ -46,6 +46,7 @@ interface MethodTagSceneParams {
46
46
 
47
47
  export const MethodTagScene: FC<MethodTagSceneProps> = ({ api }) => {
48
48
  const { specKey, methodTag } = useParams<MethodTagSceneParams>()
49
+ const location = useLocation()
49
50
  const history = useHistory()
50
51
  const methods = api.tags[methodTag]
51
52
  const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =
@@ -35,28 +35,33 @@ import { TypeTagScene } from './TypeTagScene'
35
35
  const opBtnNames = /ALL|SPECIFICATION|WRITE|REQUEST|ENUMERATED/
36
36
 
37
37
  const path = '/:specKey/types/:typeTag'
38
-
39
38
  const mockHistoryPush = jest.fn()
40
39
  jest.mock('react-router-dom', () => {
41
40
  const ReactRouterDOM = jest.requireActual('react-router-dom')
42
41
  return {
43
42
  ...ReactRouterDOM,
43
+ useLocation: () => ({
44
+ pathname: '/4.0/types/Look',
45
+ }),
44
46
  useHistory: () => ({
45
47
  push: mockHistoryPush,
46
- location,
48
+ location: {
49
+ pathname: '/4.0/types/Look',
50
+ },
47
51
  }),
48
52
  }
49
53
  })
50
54
 
51
55
  describe('TypeTagScene', () => {
52
56
  Element.prototype.scrollTo = jest.fn()
57
+ // const mockHistoryPush: jest.Mock = useHistory as jest.Mock
53
58
 
54
59
  test('it renders type buttons and all methods for a given type tag', () => {
55
60
  renderWithRouterAndReduxProvider(
56
61
  <Route path={path}>
57
62
  <TypeTagScene api={api} />
58
63
  </Route>,
59
- ['/3.1/types/Dashboard']
64
+ ['/4.0/types/Dashboard']
60
65
  )
61
66
  expect(
62
67
  screen.getAllByRole('button', {
@@ -68,7 +73,7 @@ describe('TypeTagScene', () => {
68
73
  )
69
74
  expect(screen.getByText('DashboardBase').closest('a')).toHaveAttribute(
70
75
  'href',
71
- '/3.1/types/Dashboard/DashboardBase'
76
+ '/4.0/types/Dashboard/DashboardBase'
72
77
  )
73
78
  })
74
79
 
@@ -77,7 +82,7 @@ describe('TypeTagScene', () => {
77
82
  <Route path={path}>
78
83
  <TypeTagScene api={api} />
79
84
  </Route>,
80
- ['/3.1/types/DataAction']
85
+ ['/4.0/types/DataAction']
81
86
  )
82
87
  expect(
83
88
  screen.getAllByRole('button', {
@@ -87,17 +92,18 @@ describe('TypeTagScene', () => {
87
92
  })
88
93
 
89
94
  test('it pushes filter to URL on toggle', async () => {
95
+ const site = '/4.0/types/Look'
90
96
  renderWithRouterAndReduxProvider(
91
97
  <Route path={path}>
92
98
  <TypeTagScene api={api} />
93
99
  </Route>,
94
- ['/3.1/types/Look']
100
+ [site]
95
101
  )
96
102
  /** Filter by SPECIFICATION */
97
103
  userEvent.click(screen.getByRole('button', { name: 'SPECIFICATION' }))
98
104
  await waitFor(() => {
99
105
  expect(mockHistoryPush).toHaveBeenCalledWith({
100
- pathname: location.pathname,
106
+ pathname: site,
101
107
  search: 't=specification',
102
108
  })
103
109
  })
@@ -105,7 +111,7 @@ describe('TypeTagScene', () => {
105
111
  userEvent.click(screen.getByRole('button', { name: 'REQUEST' }))
106
112
  await waitFor(() => {
107
113
  expect(mockHistoryPush).toHaveBeenCalledWith({
108
- pathname: location.pathname,
114
+ pathname: site,
109
115
  search: 't=request',
110
116
  })
111
117
  })
@@ -27,7 +27,7 @@ import type { FC } from 'react'
27
27
  import React, { useEffect, useState } from 'react'
28
28
  import { Grid, ButtonToggle, ButtonItem } from '@looker/components'
29
29
  import type { ApiModel } from '@looker/sdk-codegen'
30
- import { useParams } from 'react-router-dom'
30
+ import { useLocation, useParams } from 'react-router-dom'
31
31
  import { useSelector } from 'react-redux'
32
32
  import { ApixSection, DocTitle, DocTypeSummary, Link } from '../../components'
33
33
  import { buildTypePath, isValidFilter, useNavigation } from '../../utils'
@@ -46,6 +46,7 @@ interface TypeTagSceneParams {
46
46
 
47
47
  export const TypeTagScene: FC<TypeTagSceneProps> = ({ api }) => {
48
48
  const { specKey, typeTag } = useParams<TypeTagSceneParams>()
49
+ const location = useLocation()
49
50
  const { navigate, buildPathWithGlobalParams, navigateWithGlobalParams } =
50
51
  useNavigation()
51
52
  const selectedTagFilter = useSelector(selectTagFilter)
@@ -39,7 +39,8 @@ function* initSaga(action: PayloadAction<InitSpecsAction>) {
39
39
  try {
40
40
  const specs: SpecList = yield* call([adaptor, 'fetchSpecList'])
41
41
  let currentSpecKey = action.payload.specKey
42
- if (!currentSpecKey) {
42
+ if (!currentSpecKey || !specs[currentSpecKey]) {
43
+ // if current spec key is invalid or not assigned, default to the first "current" spec
43
44
  currentSpecKey = Object.values(specs).find(
44
45
  (spec) => spec.status === 'current'
45
46
  )!.key
@@ -104,7 +104,7 @@ export const fullify = (uri: string, baseUrl: string): string => {
104
104
  return url.toString()
105
105
  }
106
106
  /**
107
- * parse spec url into version and name for api_spec cccall
107
+ * parse spec url into version and name for api_spec call
108
108
  * @param spec to parse
109
109
  */
110
110
  const apiSpecBits = (spec: SpecItem): string[] =>
package/src/utils/path.ts CHANGED
@@ -130,7 +130,8 @@ export const getSpecKey = (location: HLocation | Location): string | null => {
130
130
  } else {
131
131
  match = pathname.match(/\/(?<specKey>\w+\.\w+).*/)
132
132
  }
133
- return match?.groups?.specKey || null
133
+ const result = match?.groups?.specKey || null
134
+ return result
134
135
  }
135
136
 
136
137
  /**