@looker/api-explorer 0.9.35 → 0.9.37
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 +56 -1
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/e2e/MethodScene.spec.ts +80 -0
- package/e2e/diffScene.spec.ts +28 -20
- package/e2e/e2e.spec.ts +45 -7
- package/lib/ApiExplorer.js +24 -5
- package/lib/ApiExplorer.js.map +1 -1
- package/lib/components/DocMarkdown/DocMarkdown.js +9 -7
- package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/components/DocSDKs/DocDeclarations.js +10 -15
- package/lib/components/DocSDKs/DocDeclarations.js.map +1 -1
- package/lib/components/SelectorContainer/ApiSpecSelector.js +6 -2
- package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SdkLanguageSelector.js +20 -21
- package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SelectorContainer.js +4 -1
- package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/components/SelectorContainer/utils.d.ts +2 -0
- package/lib/components/SelectorContainer/utils.js +32 -0
- package/lib/components/SelectorContainer/utils.js.map +1 -0
- package/lib/components/SideNav/SideNav.js +37 -16
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/SideNav/SideNavMethods.js +9 -6
- package/lib/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/components/SideNav/SideNavTypes.js +7 -4
- package/lib/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -8
- package/lib/components/index.js.map +1 -1
- package/lib/esm/ApiExplorer.js +26 -7
- package/lib/esm/ApiExplorer.js.map +1 -1
- package/lib/esm/components/DocMarkdown/DocMarkdown.js +6 -4
- package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
- package/lib/esm/components/DocSDKs/DocDeclarations.js +9 -14
- package/lib/esm/components/DocSDKs/DocDeclarations.js.map +1 -1
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +6 -3
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +16 -18
- package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SelectorContainer.js +5 -2
- package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/esm/components/SelectorContainer/utils.js +22 -0
- package/lib/esm/components/SelectorContainer/utils.js.map +1 -0
- package/lib/esm/components/SideNav/SideNav.js +40 -20
- package/lib/esm/components/SideNav/SideNav.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavMethods.js +9 -6
- package/lib/esm/components/SideNav/SideNavMethods.js.map +1 -1
- package/lib/esm/components/SideNav/SideNavTypes.js +9 -6
- package/lib/esm/components/SideNav/SideNavTypes.js.map +1 -1
- package/lib/esm/components/index.js +0 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/routes/AppRouter.js +6 -4
- package/lib/esm/routes/AppRouter.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DiffScene.js +11 -9
- package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +5 -4
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js +31 -0
- package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
- package/lib/esm/scenes/ErrorDetailScene/index.js +2 -0
- package/lib/esm/scenes/ErrorDetailScene/index.js.map +1 -0
- package/lib/esm/scenes/MethodScene/MethodScene.js +30 -10
- package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +1 -1
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js +73 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
- package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
- package/lib/esm/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
- package/lib/esm/scenes/MethodScene/components/index.js +1 -0
- package/lib/esm/scenes/MethodScene/components/index.js.map +1 -1
- package/lib/esm/scenes/MethodTagScene/MethodTagScene.js +38 -10
- package/lib/esm/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
- package/lib/esm/scenes/TypeScene/TypeScene.js +7 -1
- package/lib/esm/scenes/TypeScene/TypeScene.js.map +1 -1
- package/lib/esm/scenes/TypeTagScene/TypeTagScene.js +39 -12
- package/lib/esm/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
- package/lib/esm/scenes/index.js +1 -0
- package/lib/esm/scenes/index.js.map +1 -1
- package/lib/esm/scenes/utils/hooks/index.js +2 -0
- package/lib/esm/scenes/utils/hooks/index.js.map +1 -0
- package/lib/esm/scenes/utils/hooks/tagStoreSync.js +37 -0
- package/lib/esm/scenes/utils/hooks/tagStoreSync.js.map +1 -0
- package/lib/esm/scenes/utils/index.js +2 -0
- package/lib/esm/scenes/utils/index.js.map +1 -0
- package/lib/esm/state/settings/selectors.js +1 -0
- package/lib/esm/state/settings/selectors.js.map +1 -1
- package/lib/esm/state/settings/slice.js +6 -1
- package/lib/esm/state/settings/slice.js.map +1 -1
- package/lib/esm/utils/hooks/globalStoreSync.js +53 -0
- package/lib/esm/utils/hooks/globalStoreSync.js.map +1 -0
- package/lib/esm/utils/hooks/index.js +4 -0
- package/lib/esm/utils/hooks/index.js.map +1 -0
- package/lib/esm/utils/hooks/navigation.js +72 -0
- package/lib/esm/utils/hooks/navigation.js.map +1 -0
- package/lib/esm/utils/hooks/useQuery.js +9 -0
- package/lib/esm/utils/hooks/useQuery.js.map +1 -0
- package/lib/esm/utils/index.js +2 -0
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/path.js +23 -2
- package/lib/esm/utils/path.js.map +1 -1
- package/lib/esm/utils/sdkLanguage.js +42 -0
- package/lib/esm/utils/sdkLanguage.js.map +1 -0
- package/lib/routes/AppRouter.d.ts +1 -2
- package/lib/routes/AppRouter.js +5 -3
- package/lib/routes/AppRouter.js.map +1 -1
- package/lib/scenes/DiffScene/DiffScene.d.ts +0 -2
- package/lib/scenes/DiffScene/DiffScene.js +8 -6
- package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js +4 -4
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.d.ts +7 -0
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js +47 -0
- package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
- package/lib/scenes/ErrorDetailScene/index.d.ts +1 -0
- package/lib/scenes/ErrorDetailScene/index.js +14 -0
- package/lib/{components/DocResponses → scenes/ErrorDetailScene}/index.js.map +1 -1
- package/lib/scenes/MethodScene/MethodScene.js +25 -5
- package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.d.ts +2 -2
- package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +2 -2
- package/lib/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.d.ts +9 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js +93 -0
- package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/index.d.ts +0 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
- package/lib/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.d.ts +0 -0
- package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
- package/lib/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
- package/lib/scenes/MethodScene/components/index.d.ts +1 -0
- package/lib/scenes/MethodScene/components/index.js +8 -0
- package/lib/scenes/MethodScene/components/index.js.map +1 -1
- package/lib/scenes/MethodTagScene/MethodTagScene.js +42 -11
- package/lib/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
- package/lib/scenes/TypeScene/TypeScene.js +8 -1
- package/lib/scenes/TypeScene/TypeScene.js.map +1 -1
- package/lib/scenes/TypeTagScene/TypeTagScene.js +42 -12
- package/lib/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
- package/lib/scenes/index.d.ts +1 -0
- package/lib/scenes/index.js +8 -0
- package/lib/scenes/index.js.map +1 -1
- package/lib/scenes/utils/hooks/index.d.ts +1 -0
- package/lib/scenes/utils/hooks/index.js +14 -0
- package/lib/scenes/utils/hooks/index.js.map +1 -0
- package/lib/scenes/utils/hooks/tagStoreSync.d.ts +1 -0
- package/lib/scenes/utils/hooks/tagStoreSync.js +51 -0
- package/lib/scenes/utils/hooks/tagStoreSync.js.map +1 -0
- package/lib/scenes/utils/index.d.ts +1 -0
- package/lib/scenes/utils/index.js +14 -0
- package/lib/scenes/utils/index.js.map +1 -0
- package/lib/state/settings/selectors.d.ts +2 -1
- package/lib/state/settings/selectors.js +5 -1
- package/lib/state/settings/selectors.js.map +1 -1
- package/lib/state/settings/slice.d.ts +7 -1
- package/lib/state/settings/slice.js +6 -1
- package/lib/state/settings/slice.js.map +1 -1
- package/lib/test-data/index.d.ts +1 -0
- package/lib/test-data/index.js +14 -0
- package/lib/test-data/index.js.map +1 -1
- package/lib/test-data/sdkLanguages.d.ts +10 -0
- package/lib/test-data/sdkLanguages.js +19 -0
- package/lib/test-data/sdkLanguages.js.map +1 -0
- package/lib/utils/hooks/globalStoreSync.d.ts +1 -0
- package/lib/utils/hooks/globalStoreSync.js +67 -0
- package/lib/utils/hooks/globalStoreSync.js.map +1 -0
- package/lib/utils/hooks/index.d.ts +3 -0
- package/lib/utils/hooks/index.js +30 -0
- package/lib/utils/hooks/index.js.map +1 -0
- package/lib/utils/hooks/navigation.d.ts +11 -0
- package/lib/utils/hooks/navigation.js +83 -0
- package/lib/utils/hooks/navigation.js.map +1 -0
- package/lib/utils/hooks/useQuery.d.ts +1 -0
- package/lib/utils/hooks/useQuery.js +20 -0
- package/lib/utils/hooks/useQuery.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +38 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/path.d.ts +6 -2
- package/lib/utils/path.js +34 -3
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/sdkLanguage.d.ts +6 -0
- package/lib/utils/sdkLanguage.js +59 -0
- package/lib/utils/sdkLanguage.js.map +1 -0
- package/package.json +14 -14
- package/src/ApiExplorer.tsx +18 -7
- package/src/components/DocMarkdown/DocMarkdown.tsx +4 -4
- package/src/components/DocSDKs/DocDeclarations.tsx +11 -22
- package/src/components/DocSDKs/DocSDKs.spec.tsx +4 -1
- package/src/components/Header/Header.spec.tsx +1 -1
- package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +5 -2
- package/src/components/SelectorContainer/ApiSpecSelector.tsx +4 -3
- package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +60 -33
- package/src/components/SelectorContainer/SdkLanguageSelector.tsx +15 -22
- package/src/components/SelectorContainer/SelectorContainer.spec.tsx +1 -1
- package/src/components/SelectorContainer/SelectorContainer.tsx +18 -15
- package/src/components/SelectorContainer/utils.ts +45 -0
- package/src/components/SideNav/SideNav.spec.tsx +39 -5
- package/src/components/SideNav/SideNav.tsx +42 -29
- package/src/components/SideNav/SideNavMethods.spec.tsx +5 -0
- package/src/components/SideNav/SideNavMethods.tsx +11 -8
- package/src/components/SideNav/SideNavTypes.spec.tsx +9 -2
- package/src/components/SideNav/SideNavTypes.tsx +10 -8
- package/src/components/index.ts +0 -1
- package/src/routes/AppRouter.tsx +7 -5
- package/src/scenes/DiffScene/DiffScene.tsx +10 -10
- package/src/scenes/DiffScene/DocDiff/DiffItem.spec.tsx +4 -3
- package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +3 -4
- package/src/scenes/DiffScene/DocDiff/DocDiff.spec.tsx +73 -2
- package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +4 -4
- package/src/scenes/ErrorDetailScene/ErrorDetailScene.tsx +72 -0
- package/src/scenes/ErrorDetailScene/index.ts +26 -0
- package/src/scenes/MethodScene/MethodScene.tsx +23 -8
- package/src/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.tsx +3 -6
- package/src/scenes/MethodScene/components/DocResponses/DocResponses.spec.tsx +153 -0
- package/src/scenes/MethodScene/components/DocResponses/DocResponses.tsx +103 -0
- package/src/{components → scenes/MethodScene/components}/DocResponses/index.ts +0 -0
- package/src/{components → scenes/MethodScene/components}/DocResponses/utils.spec.ts +1 -1
- package/src/{components → scenes/MethodScene/components}/DocResponses/utils.ts +0 -0
- package/src/scenes/MethodScene/components/index.ts +1 -0
- package/src/scenes/MethodTagScene/MethodTagScene.spec.tsx +25 -14
- package/src/scenes/MethodTagScene/MethodTagScene.tsx +42 -10
- package/src/scenes/TypeScene/TypeScene.tsx +8 -2
- package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +21 -11
- package/src/scenes/TypeTagScene/TypeTagScene.tsx +46 -13
- package/src/scenes/index.ts +1 -0
- package/src/scenes/utils/hooks/index.ts +27 -0
- package/src/scenes/utils/hooks/tagStoreSync.spec.ts +102 -0
- package/src/scenes/utils/hooks/tagStoreSync.ts +68 -0
- package/src/scenes/utils/index.ts +27 -0
- package/src/state/settings/selectors.spec.ts +5 -1
- package/src/state/settings/selectors.ts +3 -0
- package/src/state/settings/slice.ts +6 -0
- package/src/test-data/index.ts +1 -0
- package/src/test-data/sdkLanguages.ts +36 -0
- package/src/utils/hooks/globalStoreSync.spec.tsx +146 -0
- package/src/utils/hooks/globalStoreSync.ts +77 -0
- package/src/utils/hooks/index.ts +28 -0
- package/src/utils/hooks/navigation.spec.ts +118 -0
- package/src/utils/hooks/navigation.ts +121 -0
- package/src/utils/hooks/useQuery.ts +36 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/path.spec.ts +92 -3
- package/src/utils/path.ts +46 -4
- package/src/utils/sdkLanguage.spec.ts +69 -0
- package/src/utils/sdkLanguage.ts +63 -0
- package/lib/components/DocResponses/DocResponseTypes.js.map +0 -1
- package/lib/components/DocResponses/DocResponses.d.ts +0 -8
- package/lib/components/DocResponses/DocResponses.js +0 -46
- package/lib/components/DocResponses/DocResponses.js.map +0 -1
- package/lib/components/DocResponses/utils.js.map +0 -1
- package/lib/esm/components/DocResponses/DocResponseTypes.js.map +0 -1
- package/lib/esm/components/DocResponses/DocResponses.js +0 -30
- package/lib/esm/components/DocResponses/DocResponses.js.map +0 -1
- package/lib/esm/components/DocResponses/index.js.map +0 -1
- package/lib/esm/components/DocResponses/utils.js.map +0 -1
- package/src/components/DocResponses/DocResponses.spec.tsx +0 -60
- package/src/components/DocResponses/DocResponses.tsx +0 -69
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
import { useHistory } from 'react-router-dom'
|
|
27
|
+
|
|
28
|
+
const GLOBAL_PARAMS = ['s', 'sdk']
|
|
29
|
+
|
|
30
|
+
interface QueryParamProps {
|
|
31
|
+
/** Search Query **/
|
|
32
|
+
s?: string | null
|
|
33
|
+
/** Chosen SDK Language **/
|
|
34
|
+
sdk?: string | null
|
|
35
|
+
/** Tag Scene Filter **/
|
|
36
|
+
t?: string | null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Hook for navigating to given route with query params
|
|
41
|
+
*/
|
|
42
|
+
export const useNavigation = () => {
|
|
43
|
+
const history = useHistory()
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Navigates to path including provided search parameters
|
|
47
|
+
*
|
|
48
|
+
* @param path Pathname to navigate to
|
|
49
|
+
* @param queryParams Hash of query param name/value pairs to include in the destination url
|
|
50
|
+
*/
|
|
51
|
+
const navigate = (path: string, queryParams?: QueryParamProps | null) => {
|
|
52
|
+
const urlParams = new URLSearchParams(history.location.search)
|
|
53
|
+
|
|
54
|
+
if (queryParams === undefined) {
|
|
55
|
+
// if params passed in is undefined, maintain existing parameters in the URL
|
|
56
|
+
history.push({ pathname: path, search: urlParams.toString() })
|
|
57
|
+
} else if (queryParams === null) {
|
|
58
|
+
// if params passed in is null, remove all parameters from the URL
|
|
59
|
+
history.push({ pathname: path })
|
|
60
|
+
} else {
|
|
61
|
+
// push each key as new param to URL, excluding entries with value null
|
|
62
|
+
Object.keys(queryParams).forEach((key) => {
|
|
63
|
+
if (queryParams[key] === null || queryParams[key] === '') {
|
|
64
|
+
urlParams.delete(key)
|
|
65
|
+
} else {
|
|
66
|
+
urlParams.set(key, queryParams[key])
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
history.push({ pathname: path, search: urlParams.toString() })
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Builds path to a scene and removes any scene-specific URL parameters
|
|
75
|
+
*
|
|
76
|
+
* @param path the destination path
|
|
77
|
+
* @param otherParams other query parameters to append to url
|
|
78
|
+
* @returns a path excluding scene-specific search parameters
|
|
79
|
+
*/
|
|
80
|
+
const buildPathWithGlobalParams = (path: string, otherParams = {}) => {
|
|
81
|
+
const params = new URLSearchParams(history.location.search)
|
|
82
|
+
|
|
83
|
+
for (const key of params.keys()) {
|
|
84
|
+
if (!GLOBAL_PARAMS.includes(key)) {
|
|
85
|
+
params.delete(key)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const globalParams = params.toString()
|
|
89
|
+
|
|
90
|
+
let additionalParams = ''
|
|
91
|
+
Object.entries(otherParams).forEach(([key, value]) => {
|
|
92
|
+
additionalParams += `${key}=${value}`
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
let queryString = ''
|
|
96
|
+
if (globalParams) {
|
|
97
|
+
queryString = globalParams
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (additionalParams) {
|
|
101
|
+
queryString += globalParams ? `&${additionalParams}` : additionalParams
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return `${path}${queryString ? `?${queryString}` : ''}`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Navigates to a scene removing any scene-specific URL parameters
|
|
109
|
+
*
|
|
110
|
+
* @param path Pathname to navigate to
|
|
111
|
+
*/
|
|
112
|
+
const navigateWithGlobalParams = (path: string) => {
|
|
113
|
+
history.push(buildPathWithGlobalParams(path))
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
navigate,
|
|
118
|
+
navigateWithGlobalParams,
|
|
119
|
+
buildPathWithGlobalParams,
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
import { useMemo } from 'react'
|
|
27
|
+
import { useLocation } from 'react-router-dom'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Hook for retrieving query params
|
|
31
|
+
*/
|
|
32
|
+
export const useQuery = () => {
|
|
33
|
+
const { search } = useLocation()
|
|
34
|
+
|
|
35
|
+
return useMemo(() => new URLSearchParams(search), [search])
|
|
36
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
*/
|
|
26
26
|
export { highlightHTML } from './highlight'
|
|
27
27
|
export * from './path'
|
|
28
|
+
export * from './sdkLanguage'
|
|
28
29
|
export { getLoded } from './lodeUtils'
|
|
29
30
|
export { useWindowSize } from './useWindowSize'
|
|
30
31
|
export * from './apixAdaptor'
|
|
31
32
|
export * from './adaptorUtils'
|
|
33
|
+
export { useNavigation, useGlobalStoreSync, useQuery } from './hooks'
|
package/src/utils/path.spec.ts
CHANGED
|
@@ -25,19 +25,48 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { api } from '../test-data'
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
buildMethodPath,
|
|
30
|
+
buildPath,
|
|
31
|
+
buildTypePath,
|
|
32
|
+
getSceneType,
|
|
33
|
+
isValidFilter,
|
|
34
|
+
} from './path'
|
|
29
35
|
|
|
30
36
|
describe('path utils', () => {
|
|
37
|
+
const testParam = 's=test'
|
|
31
38
|
describe('buildMethodPath', () => {
|
|
32
39
|
test('it builds a method path', () => {
|
|
33
40
|
const path = buildMethodPath('3.1', 'Dashboard', 'create_dashboard')
|
|
34
41
|
expect(path).toEqual('/3.1/methods/Dashboard/create_dashboard')
|
|
35
42
|
})
|
|
43
|
+
test('it builds a method path with params', () => {
|
|
44
|
+
const path = buildMethodPath(
|
|
45
|
+
'3.1',
|
|
46
|
+
'Dashboard',
|
|
47
|
+
'create_dashboard',
|
|
48
|
+
testParam
|
|
49
|
+
)
|
|
50
|
+
expect(path).toEqual(
|
|
51
|
+
`/3.1/methods/Dashboard/create_dashboard?${testParam}`
|
|
52
|
+
)
|
|
53
|
+
})
|
|
36
54
|
})
|
|
37
55
|
|
|
38
56
|
describe('buildTypePath', () => {
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
test('it builds a type path', () => {
|
|
58
|
+
const path = buildTypePath('3.1', 'Dashboard', 'WriteDashboard')
|
|
59
|
+
expect(path).toEqual('/3.1/types/Dashboard/WriteDashboard')
|
|
60
|
+
})
|
|
61
|
+
test('it builds a type path with params', () => {
|
|
62
|
+
const path = buildTypePath(
|
|
63
|
+
'3.1',
|
|
64
|
+
'Dashboard',
|
|
65
|
+
'create_dashboard',
|
|
66
|
+
testParam
|
|
67
|
+
)
|
|
68
|
+
expect(path).toEqual(`/3.1/types/Dashboard/create_dashboard?${testParam}`)
|
|
69
|
+
})
|
|
41
70
|
})
|
|
42
71
|
|
|
43
72
|
describe('buildPath', () => {
|
|
@@ -51,4 +80,64 @@ describe('path utils', () => {
|
|
|
51
80
|
expect(path).toEqual('/3.1/types/Dashboard/Dashboard')
|
|
52
81
|
})
|
|
53
82
|
})
|
|
83
|
+
|
|
84
|
+
describe('getSceneType', () => {
|
|
85
|
+
test('returns correct scene type given location with pathname', () => {
|
|
86
|
+
const methodPath = '/3.1/methods/RandomMethod'
|
|
87
|
+
const typePath = '/3.1/types/RandomType'
|
|
88
|
+
expect(getSceneType(methodPath)).toEqual('methods')
|
|
89
|
+
expect(getSceneType(typePath)).toEqual('types')
|
|
90
|
+
})
|
|
91
|
+
test('returns empty string if there is no scene type', () => {
|
|
92
|
+
const noSceneTypePath = '/'
|
|
93
|
+
expect(getSceneType(noSceneTypePath)).toEqual('')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
describe('isValidFilter', () => {
|
|
98
|
+
const methodPath = '/3.1/methods/RandomMethod'
|
|
99
|
+
const typePath = '/3.1/types/RandomType'
|
|
100
|
+
|
|
101
|
+
test("validates 'all' as a valid filter for methods and types", () => {
|
|
102
|
+
expect(isValidFilter(methodPath, 'ALL')).toBe(true)
|
|
103
|
+
expect(isValidFilter(typePath, 'ALL')).toBe(true)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const methodFilters = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
|
|
107
|
+
const typeFilters = ['SPECIFICATION', 'WRITE', 'REQUEST', 'ENUMERATED']
|
|
108
|
+
|
|
109
|
+
test.each(methodFilters)(
|
|
110
|
+
'validates %s as a valid method filter',
|
|
111
|
+
(filter) => {
|
|
112
|
+
expect(isValidFilter(methodPath, filter)).toBe(true)
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
test.each(methodFilters)(
|
|
117
|
+
'invalidates %s when containing extra characters',
|
|
118
|
+
(filter) => {
|
|
119
|
+
expect(isValidFilter(methodPath, filter + 'x')).toBe(false)
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
test.each(typeFilters)('validates %s as a valid type filter', (filter) => {
|
|
124
|
+
expect(isValidFilter(typePath, filter)).toBe(true)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
test.each(typeFilters)(
|
|
128
|
+
'invalidates %s when containing extra characters',
|
|
129
|
+
(filter) => {
|
|
130
|
+
expect(isValidFilter(typePath, filter + 'x')).toBe(false)
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
test('invalidates wrong parameter for methods and types', () => {
|
|
135
|
+
expect(isValidFilter(methodPath, 'INVALID')).toBe(false)
|
|
136
|
+
expect(isValidFilter(typePath, 'INVALID')).toBe(false)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
test.each(typeFilters)('validates %s as a valid type filter', (filter) => {
|
|
140
|
+
expect(isValidFilter(typePath, filter)).toBe(true)
|
|
141
|
+
})
|
|
142
|
+
})
|
|
54
143
|
})
|
package/src/utils/path.ts
CHANGED
|
@@ -27,29 +27,40 @@
|
|
|
27
27
|
import type { ApiModel, IMethod, IType } from '@looker/sdk-codegen'
|
|
28
28
|
import { firstMethodRef } from '@looker/sdk-codegen'
|
|
29
29
|
import type { Location as HLocation } from 'history'
|
|
30
|
+
import { matchPath } from 'react-router'
|
|
31
|
+
|
|
32
|
+
export const methodFilterOptions = /GET$|POST$|PUT$|PATCH$|DELETE$/i
|
|
33
|
+
export const typeFilterOptions = /SPECIFICATION$|WRITE$|REQUEST$|ENUMERATED$/i
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* Builds a path matching the route used by MethodScene
|
|
33
37
|
* @param specKey A string to identify the spec in the URL
|
|
34
38
|
* @param tag Corresponding method tag
|
|
35
39
|
* @param methodName A method name
|
|
40
|
+
* @param params Hash of query param name/value pairs to include in the destination url
|
|
36
41
|
* @returns a Method path
|
|
37
42
|
*/
|
|
38
43
|
export const buildMethodPath = (
|
|
39
44
|
specKey: string,
|
|
40
45
|
tag: string,
|
|
41
|
-
methodName: string
|
|
42
|
-
|
|
46
|
+
methodName: string,
|
|
47
|
+
params?: string
|
|
48
|
+
) => `/${specKey}/methods/${tag}/${methodName}${params ? `?${params}` : ''}`
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* Builds a path matching the route used by TypeScene
|
|
46
52
|
* @param specKey A string to identify the spec in the URL
|
|
47
53
|
* @param tag Corresponding type tag
|
|
48
54
|
* @param typeName A type name
|
|
55
|
+
* @param params Hash of query param name/value pairs to include in the destination url
|
|
49
56
|
* @returns a Type path
|
|
50
57
|
*/
|
|
51
|
-
export const buildTypePath = (
|
|
52
|
-
|
|
58
|
+
export const buildTypePath = (
|
|
59
|
+
specKey: string,
|
|
60
|
+
tag: string,
|
|
61
|
+
typeName: string,
|
|
62
|
+
params?: string
|
|
63
|
+
) => `/${specKey}/types/${tag}/${typeName}${params ? `?${params}` : ''}`
|
|
53
64
|
|
|
54
65
|
export const diffPath = 'diff'
|
|
55
66
|
export const oAuthPath = 'oauth'
|
|
@@ -121,3 +132,34 @@ export const getSpecKey = (location: HLocation | Location): string | null => {
|
|
|
121
132
|
}
|
|
122
133
|
return match?.groups?.specKey || null
|
|
123
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Gets the scene type of the current page
|
|
138
|
+
* @param path path of browser location
|
|
139
|
+
* @returns string representing the scene type
|
|
140
|
+
*/
|
|
141
|
+
export const getSceneType = (path: string) => {
|
|
142
|
+
const match = matchPath<{ tagType: string }>(path, {
|
|
143
|
+
path: '/:specKey/:tagType',
|
|
144
|
+
})
|
|
145
|
+
return match ? match!.params.tagType : ''
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Confirms if filter is valid for a given method/type tag
|
|
150
|
+
* @param path browser location pathname
|
|
151
|
+
* @param filter filter tag for page
|
|
152
|
+
*/
|
|
153
|
+
export const isValidFilter = (path: string, filter: string) => {
|
|
154
|
+
let isValid
|
|
155
|
+
const sceneType = getSceneType(path)
|
|
156
|
+
if (!sceneType) isValid = false
|
|
157
|
+
else if (!filter.localeCompare('all', 'en', { sensitivity: 'base' }))
|
|
158
|
+
isValid = true
|
|
159
|
+
else if (sceneType === 'methods') {
|
|
160
|
+
isValid = methodFilterOptions.test(filter)
|
|
161
|
+
} else {
|
|
162
|
+
isValid = typeFilterOptions.test(filter)
|
|
163
|
+
}
|
|
164
|
+
return isValid
|
|
165
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2022 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { codeGenerators } from '@looker/sdk-codegen'
|
|
28
|
+
import { allSdkLanguages, findSdk } from '../utils'
|
|
29
|
+
import { sdkLanguageMapping } from '../test-data'
|
|
30
|
+
|
|
31
|
+
describe('SDK Language Utils', () => {
|
|
32
|
+
test('allSdkLanguages gets all sdk languages', () => {
|
|
33
|
+
const actual = allSdkLanguages()
|
|
34
|
+
const aliases = Object.keys(actual)
|
|
35
|
+
expect(Object.keys(actual)).toHaveLength(codeGenerators.length + 1)
|
|
36
|
+
aliases.forEach((alias) =>
|
|
37
|
+
expect(actual[alias]).toEqual(sdkLanguageMapping[alias])
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('findSdk', () => {
|
|
42
|
+
test('it is not case sensitive', () => {
|
|
43
|
+
const actual = findSdk('pY')
|
|
44
|
+
expect(actual.language).toEqual('Python')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test("it returns 'All' option if provided bogus input", () => {
|
|
48
|
+
const actual = findSdk('random')
|
|
49
|
+
expect(actual.language).toEqual('All')
|
|
50
|
+
expect(actual.alias).toEqual('all')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test.each(Object.entries(sdkLanguageMapping))(
|
|
54
|
+
`it finds language for alias %s`,
|
|
55
|
+
(alias, language) => {
|
|
56
|
+
const actual = findSdk(alias)
|
|
57
|
+
expect(actual.language).toEqual(language)
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
test.each(Object.entries(sdkLanguageMapping))(
|
|
62
|
+
`it finds alias for language %s`,
|
|
63
|
+
(alias, language) => {
|
|
64
|
+
const actual = findSdk(language)
|
|
65
|
+
expect(actual.alias).toEqual(alias)
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2021 Looker Data Sciences, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { codeGenerators } from '@looker/sdk-codegen'
|
|
28
|
+
|
|
29
|
+
export const allAlias = 'all'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Gets all supported sdk languages
|
|
33
|
+
* @returns mapping of sdk language aliases to name
|
|
34
|
+
*/
|
|
35
|
+
export const allSdkLanguages = (): Record<string, string> => {
|
|
36
|
+
const languages = {}
|
|
37
|
+
codeGenerators.forEach((gen) => {
|
|
38
|
+
const alias = gen.extension.toString().match(/\.(\w+)\b/)![1]
|
|
39
|
+
languages[alias] = gen.language
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
return { ...languages, [allAlias]: 'All' }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Searches for sdk language details given label
|
|
47
|
+
* @param label label to search by
|
|
48
|
+
* @returns language name and alias
|
|
49
|
+
*/
|
|
50
|
+
export const findSdk = (label: string) => {
|
|
51
|
+
const languages = allSdkLanguages()
|
|
52
|
+
let match = { alias: allAlias, language: languages[allAlias] }
|
|
53
|
+
for (const [alias, language] of Object.entries(languages)) {
|
|
54
|
+
if (
|
|
55
|
+
!label.localeCompare(alias, 'en', { sensitivity: 'base' }) ||
|
|
56
|
+
!label.localeCompare(language, 'en', { sensitivity: 'base' })
|
|
57
|
+
) {
|
|
58
|
+
match = { alias, language }
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return match
|
|
63
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DocResponses/DocResponseTypes.tsx"],"names":["DocResponseTypes","api","responses","mediaTypes","Object","keys","selectedMediaType","setSelectedMediaType","resps","setResps","map","mediaType","overflow","type"],"mappings":";;;;;;;AA2BA;;AACA;;AAOA;;;;;;AAYO,IAAMA,gBAA2C,GAAG,QAGrD;AAAA,MAHsD;AAC1DC,IAAAA,GAD0D;AAE1DC,IAAAA;AAF0D,GAGtD;AACJ,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYH,SAAZ,CAAnB;AACA,MAAM,CAACI,iBAAD,EAAoBC,oBAApB,IAA4C,qBAASJ,UAAU,CAAC,CAAD,CAAnB,CAAlD;AACA,MAAM,CAACK,KAAD,EAAQC,QAAR,IAAoB,qBAASP,SAAT,CAA1B;AAEA,wBAAU,MAAM;AAEdK,IAAAA,oBAAoB,CAACJ,UAAU,CAAC,CAAD,CAAX,CAApB;AACAM,IAAAA,QAAQ,CAACP,SAAD,CAAR;AACD,GAJD,EAIG,CAACA,SAAD,EAAYC,UAAZ,CAJH;AAOA,SACE,4DACE,6BAAC,wBAAD;AACE,IAAA,KAAK,EAAEG,iBADT;AAEE,IAAA,QAAQ,EAAEC,oBAFZ;AAGE,IAAA,EAAE,EAAC,OAHL;AAIE,IAAA,EAAE,EAAC;AAJL,KAMGJ,UAAU,CAACO,GAAX,CAAgBC,SAAD,IACd,6BAAC,sBAAD;AAAY,IAAA,GAAG,EAAEA;AAAjB,KAA6BA,SAA7B,CADD,CANH,CADF,EAWE;AAAK,IAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAZ;AAAZ,KACE,6BAAC,aAAD;AACE,IAAA,GAAG,EAAEX,GADP;AAEE,IAAA,GAAG,EAAEK,iBAFP;AAGE,IAAA,IAAI,EAAEE,KAAK,CAACF,iBAAD,CAAL,CAAyBO,IAHjC;AAIE,IAAA,IAAI,EAAE,IAJR;AAKE,IAAA,QAAQ,EAAE;AALZ,IADF,CAXF,CADF;AAuBD,CAtCM","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, { useState, useEffect } from 'react'\nimport { ButtonToggle, ButtonItem } from '@looker/components'\nimport type {\n ApiModel,\n KeyedCollection,\n IMethodResponse,\n} from '@looker/sdk-codegen'\n\nimport { ExploreType } from '..'\n\ninterface DocResponseTypesProps {\n api: ApiModel\n responses: KeyedCollection<IMethodResponse>\n}\n\n/**\n * Given a collection of media types (keys) and responses (values) for a response code, generate a group of buttons for\n * toggling media type and render the response\n * @param response\n */\nexport const DocResponseTypes: FC<DocResponseTypesProps> = ({\n api,\n responses,\n}) => {\n const mediaTypes = Object.keys(responses)\n const [selectedMediaType, setSelectedMediaType] = useState(mediaTypes[0])\n const [resps, setResps] = useState(responses)\n\n useEffect(() => {\n /** When new responses are passed, update the default selected media type */\n setSelectedMediaType(mediaTypes[0])\n setResps(responses)\n }, [responses, mediaTypes])\n\n // TODO: Account for endpoints with no responses (e.g. delete a custom cmd)\n return (\n <>\n <ButtonToggle\n value={selectedMediaType}\n onChange={setSelectedMediaType}\n mt=\"large\"\n mb=\"large\"\n >\n {mediaTypes.map((mediaType) => (\n <ButtonItem key={mediaType}>{mediaType}</ButtonItem>\n ))}\n </ButtonToggle>\n <div style={{ overflow: 'auto' }}>\n <ExploreType\n api={api}\n key={selectedMediaType}\n type={resps[selectedMediaType].type}\n link={true}\n maxDepth={2}\n />\n </div>\n </>\n )\n}\n"],"file":"DocResponseTypes.js"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DocResponses = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _components = require("@looker/components");
|
|
11
|
-
|
|
12
|
-
var _runIt = require("@looker/run-it");
|
|
13
|
-
|
|
14
|
-
var _DocResponseTypes = require("./DocResponseTypes");
|
|
15
|
-
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
22
|
-
var DocResponses = _ref => {
|
|
23
|
-
var {
|
|
24
|
-
api,
|
|
25
|
-
responses
|
|
26
|
-
} = _ref;
|
|
27
|
-
var tabs = (0, _components.useTabs)();
|
|
28
|
-
if (responses.length === 0) return _react.default.createElement(_react.default.Fragment, null);
|
|
29
|
-
var responseTree = (0, _utils.buildResponseTree)(responses);
|
|
30
|
-
return _react.default.createElement(_runIt.CollapserCard, {
|
|
31
|
-
heading: "Response Models",
|
|
32
|
-
id: "response models"
|
|
33
|
-
}, _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_components.TabList, tabs, Object.keys(responseTree).map((statusCode, index) => _react.default.createElement(_components.Tab, {
|
|
34
|
-
key: index
|
|
35
|
-
}, statusCode))), _react.default.createElement(_components.TabPanels, _extends({}, tabs, {
|
|
36
|
-
pt: "0"
|
|
37
|
-
}), Object.values(responseTree).map((responses, index) => _react.default.createElement(_components.TabPanel, {
|
|
38
|
-
key: index
|
|
39
|
-
}, _react.default.createElement(_DocResponseTypes.DocResponseTypes, {
|
|
40
|
-
api: api,
|
|
41
|
-
responses: responses
|
|
42
|
-
}))))));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
exports.DocResponses = DocResponses;
|
|
46
|
-
//# sourceMappingURL=DocResponses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DocResponses/DocResponses.tsx"],"names":["DocResponses","api","responses","tabs","length","responseTree","Object","keys","map","statusCode","index","values"],"mappings":";;;;;;;AA2BA;;AACA;;AAGA;;AACA;;AACA;;;;;;AAUO,IAAMA,YAAmC,GAAG,QAAwB;AAAA,MAAvB;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAuB;AACzE,MAAMC,IAAI,GAAG,0BAAb;AAEA,MAAID,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B,OAAO,2DAAP;AAE5B,MAAMC,YAAY,GAAG,8BAAkBH,SAAlB,CAArB;AAEA,SACE,6BAAC,oBAAD;AAAe,IAAA,OAAO,EAAC,iBAAvB;AAAyC,IAAA,EAAE,EAAC;AAA5C,KACE,4DACE,6BAAC,mBAAD,EAAaC,IAAb,EACGG,MAAM,CAACC,IAAP,CAAYF,YAAZ,EAA0BG,GAA1B,CAA8B,CAACC,UAAD,EAAaC,KAAb,KAC7B,6BAAC,eAAD;AAAK,IAAA,GAAG,EAAEA;AAAV,KAAkBD,UAAlB,CADD,CADH,CADF,EAME,6BAAC,qBAAD,eAAeN,IAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,MACGG,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BG,GAA5B,CAAgC,CAACN,SAAD,EAAYQ,KAAZ,KAC/B,6BAAC,oBAAD;AAAU,IAAA,GAAG,EAAEA;AAAf,KACE,6BAAC,kCAAD;AAAkB,IAAA,GAAG,EAAET,GAAvB;AAA4B,IAAA,SAAS,EAAEC;AAAvC,IADF,CADD,CADH,CANF,CADF,CADF;AAkBD,CAzBM","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 from 'react'\nimport { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components'\nimport type { IMethodResponse, ApiModel } from '@looker/sdk-codegen'\n\nimport { CollapserCard } from '@looker/run-it'\nimport { DocResponseTypes } from './DocResponseTypes'\nimport { buildResponseTree } from './utils'\n\ninterface DocResponsesProps {\n responses: IMethodResponse[]\n api: ApiModel\n}\n\n/**\n * Renders a tab list and tab panels for different method response types\n */\nexport const DocResponses: FC<DocResponsesProps> = ({ api, responses }) => {\n const tabs = useTabs()\n\n if (responses.length === 0) return <></>\n\n const responseTree = buildResponseTree(responses)\n\n return (\n <CollapserCard heading=\"Response Models\" id=\"response models\">\n <>\n <TabList {...tabs}>\n {Object.keys(responseTree).map((statusCode, index) => (\n <Tab key={index}>{statusCode}</Tab>\n ))}\n </TabList>\n <TabPanels {...tabs} pt=\"0\">\n {Object.values(responseTree).map((responses, index) => (\n <TabPanel key={index}>\n <DocResponseTypes api={api} responses={responses} />\n </TabPanel>\n ))}\n </TabPanels>\n </>\n </CollapserCard>\n )\n}\n"],"file":"DocResponses.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DocResponses/utils.ts"],"names":["buildResponseTree","responses","tree","Object","values","forEach","response","node","statusCode","description","mediaType"],"mappings":";;;;;;;AAiCO,IAAMA,iBAAiB,GAC5BC,SAD+B,IAEuB;AACtD,MAAMC,IAAI,GAAG,EAAb;AACAC,EAAAA,MAAM,CAACC,MAAP,CAAcH,SAAd,EAAyBI,OAAzB,CAAkCC,QAAD,IAAc;AAC7C,QAAMC,IAAI,aAAMD,QAAQ,CAACE,UAAf,eAA8BF,QAAQ,CAACG,WAAvC,CAAV;AACA,QAAI,EAAEF,IAAI,IAAIL,IAAV,CAAJ,EAAqBA,IAAI,CAACK,IAAD,CAAJ,GAAa,EAAb;AACrBL,IAAAA,IAAI,CAACK,IAAD,CAAJ,CAAWD,QAAQ,CAACI,SAApB,IAAiCJ,QAAjC;AACD,GAJD;AAKA,SAAOJ,IAAP;AACD,CAVM","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 { IMethodResponse, KeyedCollection } from '@looker/sdk-codegen'\n\n/**\n * Given an array of method responses, group them by statusCode. The value of each status code is a collection of\n * media types (keys) and responses (values)\n * @param responses An array of method responses\n */\nexport const buildResponseTree = (\n responses: IMethodResponse[]\n): KeyedCollection<KeyedCollection<IMethodResponse>> => {\n const tree = {}\n Object.values(responses).forEach((response) => {\n const node = `${response.statusCode}: ${response.description}`\n if (!(node in tree)) tree[node] = {}\n tree[node][response.mediaType] = response\n })\n return tree\n}\n"],"file":"utils.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/DocResponses/DocResponseTypes.tsx"],"names":["React","useState","useEffect","ButtonToggle","ButtonItem","ExploreType","DocResponseTypes","api","responses","mediaTypes","Object","keys","selectedMediaType","setSelectedMediaType","resps","setResps","map","mediaType","overflow","type"],"mappings":"AA2BA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,oBAAzC;AAOA,SAASC,WAAT,QAA4B,IAA5B;AAYA,OAAO,IAAMC,gBAA2C,GAAG,QAGrD;AAAA,MAHsD;AAC1DC,IAAAA,GAD0D;AAE1DC,IAAAA;AAF0D,GAGtD;AACJ,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAP,CAAYH,SAAZ,CAAnB;AACA,MAAM,CAACI,iBAAD,EAAoBC,oBAApB,IAA4CZ,QAAQ,CAACQ,UAAU,CAAC,CAAD,CAAX,CAA1D;AACA,MAAM,CAACK,KAAD,EAAQC,QAAR,IAAoBd,QAAQ,CAACO,SAAD,CAAlC;AAEAN,EAAAA,SAAS,CAAC,MAAM;AAEdW,IAAAA,oBAAoB,CAACJ,UAAU,CAAC,CAAD,CAAX,CAApB;AACAM,IAAAA,QAAQ,CAACP,SAAD,CAAR;AACD,GAJQ,EAIN,CAACA,SAAD,EAAYC,UAAZ,CAJM,CAAT;AAOA,SACE,0CACE,oBAAC,YAAD;AACE,IAAA,KAAK,EAAEG,iBADT;AAEE,IAAA,QAAQ,EAAEC,oBAFZ;AAGE,IAAA,EAAE,EAAC,OAHL;AAIE,IAAA,EAAE,EAAC;AAJL,KAMGJ,UAAU,CAACO,GAAX,CAAgBC,SAAD,IACd,oBAAC,UAAD;AAAY,IAAA,GAAG,EAAEA;AAAjB,KAA6BA,SAA7B,CADD,CANH,CADF,EAWE;AAAK,IAAA,KAAK,EAAE;AAAEC,MAAAA,QAAQ,EAAE;AAAZ;AAAZ,KACE,oBAAC,WAAD;AACE,IAAA,GAAG,EAAEX,GADP;AAEE,IAAA,GAAG,EAAEK,iBAFP;AAGE,IAAA,IAAI,EAAEE,KAAK,CAACF,iBAAD,CAAL,CAAyBO,IAHjC;AAIE,IAAA,IAAI,EAAE,IAJR;AAKE,IAAA,QAAQ,EAAE;AALZ,IADF,CAXF,CADF;AAuBD,CAtCM","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, { useState, useEffect } from 'react'\nimport { ButtonToggle, ButtonItem } from '@looker/components'\nimport type {\n ApiModel,\n KeyedCollection,\n IMethodResponse,\n} from '@looker/sdk-codegen'\n\nimport { ExploreType } from '..'\n\ninterface DocResponseTypesProps {\n api: ApiModel\n responses: KeyedCollection<IMethodResponse>\n}\n\n/**\n * Given a collection of media types (keys) and responses (values) for a response code, generate a group of buttons for\n * toggling media type and render the response\n * @param response\n */\nexport const DocResponseTypes: FC<DocResponseTypesProps> = ({\n api,\n responses,\n}) => {\n const mediaTypes = Object.keys(responses)\n const [selectedMediaType, setSelectedMediaType] = useState(mediaTypes[0])\n const [resps, setResps] = useState(responses)\n\n useEffect(() => {\n /** When new responses are passed, update the default selected media type */\n setSelectedMediaType(mediaTypes[0])\n setResps(responses)\n }, [responses, mediaTypes])\n\n // TODO: Account for endpoints with no responses (e.g. delete a custom cmd)\n return (\n <>\n <ButtonToggle\n value={selectedMediaType}\n onChange={setSelectedMediaType}\n mt=\"large\"\n mb=\"large\"\n >\n {mediaTypes.map((mediaType) => (\n <ButtonItem key={mediaType}>{mediaType}</ButtonItem>\n ))}\n </ButtonToggle>\n <div style={{ overflow: 'auto' }}>\n <ExploreType\n api={api}\n key={selectedMediaType}\n type={resps[selectedMediaType].type}\n link={true}\n maxDepth={2}\n />\n </div>\n </>\n )\n}\n"],"file":"DocResponseTypes.js"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components';
|
|
5
|
-
import { CollapserCard } from '@looker/run-it';
|
|
6
|
-
import { DocResponseTypes } from './DocResponseTypes';
|
|
7
|
-
import { buildResponseTree } from './utils';
|
|
8
|
-
export var DocResponses = _ref => {
|
|
9
|
-
var {
|
|
10
|
-
api,
|
|
11
|
-
responses
|
|
12
|
-
} = _ref;
|
|
13
|
-
var tabs = useTabs();
|
|
14
|
-
if (responses.length === 0) return React.createElement(React.Fragment, null);
|
|
15
|
-
var responseTree = buildResponseTree(responses);
|
|
16
|
-
return React.createElement(CollapserCard, {
|
|
17
|
-
heading: "Response Models",
|
|
18
|
-
id: "response models"
|
|
19
|
-
}, React.createElement(React.Fragment, null, React.createElement(TabList, tabs, Object.keys(responseTree).map((statusCode, index) => React.createElement(Tab, {
|
|
20
|
-
key: index
|
|
21
|
-
}, statusCode))), React.createElement(TabPanels, _extends({}, tabs, {
|
|
22
|
-
pt: "0"
|
|
23
|
-
}), Object.values(responseTree).map((responses, index) => React.createElement(TabPanel, {
|
|
24
|
-
key: index
|
|
25
|
-
}, React.createElement(DocResponseTypes, {
|
|
26
|
-
api: api,
|
|
27
|
-
responses: responses
|
|
28
|
-
}))))));
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=DocResponses.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/DocResponses/DocResponses.tsx"],"names":["React","Tab","TabList","TabPanel","TabPanels","useTabs","CollapserCard","DocResponseTypes","buildResponseTree","DocResponses","api","responses","tabs","length","responseTree","Object","keys","map","statusCode","index","values"],"mappings":";;AA2BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,GAAT,EAAcC,OAAd,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,OAA5C,QAA2D,oBAA3D;AAGA,SAASC,aAAT,QAA8B,gBAA9B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,iBAAT,QAAkC,SAAlC;AAUA,OAAO,IAAMC,YAAmC,GAAG,QAAwB;AAAA,MAAvB;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAuB;AACzE,MAAMC,IAAI,GAAGP,OAAO,EAApB;AAEA,MAAIM,SAAS,CAACE,MAAV,KAAqB,CAAzB,EAA4B,OAAO,yCAAP;AAE5B,MAAMC,YAAY,GAAGN,iBAAiB,CAACG,SAAD,CAAtC;AAEA,SACE,oBAAC,aAAD;AAAe,IAAA,OAAO,EAAC,iBAAvB;AAAyC,IAAA,EAAE,EAAC;AAA5C,KACE,0CACE,oBAAC,OAAD,EAAaC,IAAb,EACGG,MAAM,CAACC,IAAP,CAAYF,YAAZ,EAA0BG,GAA1B,CAA8B,CAACC,UAAD,EAAaC,KAAb,KAC7B,oBAAC,GAAD;AAAK,IAAA,GAAG,EAAEA;AAAV,KAAkBD,UAAlB,CADD,CADH,CADF,EAME,oBAAC,SAAD,eAAeN,IAAf;AAAqB,IAAA,EAAE,EAAC;AAAxB,MACGG,MAAM,CAACK,MAAP,CAAcN,YAAd,EAA4BG,GAA5B,CAAgC,CAACN,SAAD,EAAYQ,KAAZ,KAC/B,oBAAC,QAAD;AAAU,IAAA,GAAG,EAAEA;AAAf,KACE,oBAAC,gBAAD;AAAkB,IAAA,GAAG,EAAET,GAAvB;AAA4B,IAAA,SAAS,EAAEC;AAAvC,IADF,CADD,CADH,CANF,CADF,CADF;AAkBD,CAzBM","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 from 'react'\nimport { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components'\nimport type { IMethodResponse, ApiModel } from '@looker/sdk-codegen'\n\nimport { CollapserCard } from '@looker/run-it'\nimport { DocResponseTypes } from './DocResponseTypes'\nimport { buildResponseTree } from './utils'\n\ninterface DocResponsesProps {\n responses: IMethodResponse[]\n api: ApiModel\n}\n\n/**\n * Renders a tab list and tab panels for different method response types\n */\nexport const DocResponses: FC<DocResponsesProps> = ({ api, responses }) => {\n const tabs = useTabs()\n\n if (responses.length === 0) return <></>\n\n const responseTree = buildResponseTree(responses)\n\n return (\n <CollapserCard heading=\"Response Models\" id=\"response models\">\n <>\n <TabList {...tabs}>\n {Object.keys(responseTree).map((statusCode, index) => (\n <Tab key={index}>{statusCode}</Tab>\n ))}\n </TabList>\n <TabPanels {...tabs} pt=\"0\">\n {Object.values(responseTree).map((responses, index) => (\n <TabPanel key={index}>\n <DocResponseTypes api={api} responses={responses} />\n </TabPanel>\n ))}\n </TabPanels>\n </>\n </CollapserCard>\n )\n}\n"],"file":"DocResponses.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/DocResponses/index.ts"],"names":["DocResponses"],"mappings":"AAyBA,SAASA,YAAT,QAA6B,gBAA7B","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 */\nexport { DocResponses } from './DocResponses'\n"],"file":"index.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/DocResponses/utils.ts"],"names":["buildResponseTree","responses","tree","Object","values","forEach","response","node","statusCode","description","mediaType"],"mappings":"AAiCA,OAAO,IAAMA,iBAAiB,GAC5BC,SAD+B,IAEuB;AACtD,MAAMC,IAAI,GAAG,EAAb;AACAC,EAAAA,MAAM,CAACC,MAAP,CAAcH,SAAd,EAAyBI,OAAzB,CAAkCC,QAAD,IAAc;AAC7C,QAAMC,IAAI,aAAMD,QAAQ,CAACE,UAAf,eAA8BF,QAAQ,CAACG,WAAvC,CAAV;AACA,QAAI,EAAEF,IAAI,IAAIL,IAAV,CAAJ,EAAqBA,IAAI,CAACK,IAAD,CAAJ,GAAa,EAAb;AACrBL,IAAAA,IAAI,CAACK,IAAD,CAAJ,CAAWD,QAAQ,CAACI,SAApB,IAAiCJ,QAAjC;AACD,GAJD;AAKA,SAAOJ,IAAP;AACD,CAVM","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 { IMethodResponse, KeyedCollection } from '@looker/sdk-codegen'\n\n/**\n * Given an array of method responses, group them by statusCode. The value of each status code is a collection of\n * media types (keys) and responses (values)\n * @param responses An array of method responses\n */\nexport const buildResponseTree = (\n responses: IMethodResponse[]\n): KeyedCollection<KeyedCollection<IMethodResponse>> => {\n const tree = {}\n Object.values(responses).forEach((response) => {\n const node = `${response.statusCode}: ${response.description}`\n if (!(node in tree)) tree[node] = {}\n tree[node][response.mediaType] = response\n })\n return tree\n}\n"],"file":"utils.js"}
|