@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.
Files changed (266) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.map +1 -1
  4. package/e2e/MethodScene.spec.ts +80 -0
  5. package/e2e/diffScene.spec.ts +28 -20
  6. package/e2e/e2e.spec.ts +45 -7
  7. package/lib/ApiExplorer.js +24 -5
  8. package/lib/ApiExplorer.js.map +1 -1
  9. package/lib/components/DocMarkdown/DocMarkdown.js +9 -7
  10. package/lib/components/DocMarkdown/DocMarkdown.js.map +1 -1
  11. package/lib/components/DocSDKs/DocDeclarations.js +10 -15
  12. package/lib/components/DocSDKs/DocDeclarations.js.map +1 -1
  13. package/lib/components/SelectorContainer/ApiSpecSelector.js +6 -2
  14. package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  15. package/lib/components/SelectorContainer/SdkLanguageSelector.js +20 -21
  16. package/lib/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  17. package/lib/components/SelectorContainer/SelectorContainer.js +4 -1
  18. package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
  19. package/lib/components/SelectorContainer/utils.d.ts +2 -0
  20. package/lib/components/SelectorContainer/utils.js +32 -0
  21. package/lib/components/SelectorContainer/utils.js.map +1 -0
  22. package/lib/components/SideNav/SideNav.js +37 -16
  23. package/lib/components/SideNav/SideNav.js.map +1 -1
  24. package/lib/components/SideNav/SideNavMethods.js +9 -6
  25. package/lib/components/SideNav/SideNavMethods.js.map +1 -1
  26. package/lib/components/SideNav/SideNavTypes.js +7 -4
  27. package/lib/components/SideNav/SideNavTypes.js.map +1 -1
  28. package/lib/components/index.d.ts +0 -1
  29. package/lib/components/index.js +0 -8
  30. package/lib/components/index.js.map +1 -1
  31. package/lib/esm/ApiExplorer.js +26 -7
  32. package/lib/esm/ApiExplorer.js.map +1 -1
  33. package/lib/esm/components/DocMarkdown/DocMarkdown.js +6 -4
  34. package/lib/esm/components/DocMarkdown/DocMarkdown.js.map +1 -1
  35. package/lib/esm/components/DocSDKs/DocDeclarations.js +9 -14
  36. package/lib/esm/components/DocSDKs/DocDeclarations.js.map +1 -1
  37. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +6 -3
  38. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  39. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js +16 -18
  40. package/lib/esm/components/SelectorContainer/SdkLanguageSelector.js.map +1 -1
  41. package/lib/esm/components/SelectorContainer/SelectorContainer.js +5 -2
  42. package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
  43. package/lib/esm/components/SelectorContainer/utils.js +22 -0
  44. package/lib/esm/components/SelectorContainer/utils.js.map +1 -0
  45. package/lib/esm/components/SideNav/SideNav.js +40 -20
  46. package/lib/esm/components/SideNav/SideNav.js.map +1 -1
  47. package/lib/esm/components/SideNav/SideNavMethods.js +9 -6
  48. package/lib/esm/components/SideNav/SideNavMethods.js.map +1 -1
  49. package/lib/esm/components/SideNav/SideNavTypes.js +9 -6
  50. package/lib/esm/components/SideNav/SideNavTypes.js.map +1 -1
  51. package/lib/esm/components/index.js +0 -1
  52. package/lib/esm/components/index.js.map +1 -1
  53. package/lib/esm/routes/AppRouter.js +6 -4
  54. package/lib/esm/routes/AppRouter.js.map +1 -1
  55. package/lib/esm/scenes/DiffScene/DiffScene.js +11 -9
  56. package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
  57. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +5 -4
  58. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  59. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
  60. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  61. package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js +31 -0
  62. package/lib/esm/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
  63. package/lib/esm/scenes/ErrorDetailScene/index.js +2 -0
  64. package/lib/esm/scenes/ErrorDetailScene/index.js.map +1 -0
  65. package/lib/esm/scenes/MethodScene/MethodScene.js +30 -10
  66. package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
  67. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +1 -1
  68. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
  69. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js +73 -0
  70. package/lib/esm/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
  71. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
  72. package/lib/esm/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
  73. package/lib/esm/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
  74. package/lib/esm/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
  75. package/lib/esm/scenes/MethodScene/components/index.js +1 -0
  76. package/lib/esm/scenes/MethodScene/components/index.js.map +1 -1
  77. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js +38 -10
  78. package/lib/esm/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  79. package/lib/esm/scenes/TypeScene/TypeScene.js +7 -1
  80. package/lib/esm/scenes/TypeScene/TypeScene.js.map +1 -1
  81. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js +39 -12
  82. package/lib/esm/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  83. package/lib/esm/scenes/index.js +1 -0
  84. package/lib/esm/scenes/index.js.map +1 -1
  85. package/lib/esm/scenes/utils/hooks/index.js +2 -0
  86. package/lib/esm/scenes/utils/hooks/index.js.map +1 -0
  87. package/lib/esm/scenes/utils/hooks/tagStoreSync.js +37 -0
  88. package/lib/esm/scenes/utils/hooks/tagStoreSync.js.map +1 -0
  89. package/lib/esm/scenes/utils/index.js +2 -0
  90. package/lib/esm/scenes/utils/index.js.map +1 -0
  91. package/lib/esm/state/settings/selectors.js +1 -0
  92. package/lib/esm/state/settings/selectors.js.map +1 -1
  93. package/lib/esm/state/settings/slice.js +6 -1
  94. package/lib/esm/state/settings/slice.js.map +1 -1
  95. package/lib/esm/utils/hooks/globalStoreSync.js +53 -0
  96. package/lib/esm/utils/hooks/globalStoreSync.js.map +1 -0
  97. package/lib/esm/utils/hooks/index.js +4 -0
  98. package/lib/esm/utils/hooks/index.js.map +1 -0
  99. package/lib/esm/utils/hooks/navigation.js +72 -0
  100. package/lib/esm/utils/hooks/navigation.js.map +1 -0
  101. package/lib/esm/utils/hooks/useQuery.js +9 -0
  102. package/lib/esm/utils/hooks/useQuery.js.map +1 -0
  103. package/lib/esm/utils/index.js +2 -0
  104. package/lib/esm/utils/index.js.map +1 -1
  105. package/lib/esm/utils/path.js +23 -2
  106. package/lib/esm/utils/path.js.map +1 -1
  107. package/lib/esm/utils/sdkLanguage.js +42 -0
  108. package/lib/esm/utils/sdkLanguage.js.map +1 -0
  109. package/lib/routes/AppRouter.d.ts +1 -2
  110. package/lib/routes/AppRouter.js +5 -3
  111. package/lib/routes/AppRouter.js.map +1 -1
  112. package/lib/scenes/DiffScene/DiffScene.d.ts +0 -2
  113. package/lib/scenes/DiffScene/DiffScene.js +8 -6
  114. package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
  115. package/lib/scenes/DiffScene/DocDiff/DiffItem.js +4 -4
  116. package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  117. package/lib/scenes/DiffScene/DocDiff/DocDiff.js +4 -4
  118. package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  119. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.d.ts +7 -0
  120. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js +47 -0
  121. package/lib/scenes/ErrorDetailScene/ErrorDetailScene.js.map +1 -0
  122. package/lib/scenes/ErrorDetailScene/index.d.ts +1 -0
  123. package/lib/scenes/ErrorDetailScene/index.js +14 -0
  124. package/lib/{components/DocResponses → scenes/ErrorDetailScene}/index.js.map +1 -1
  125. package/lib/scenes/MethodScene/MethodScene.js +25 -5
  126. package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
  127. package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.d.ts +2 -2
  128. package/lib/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.js +2 -2
  129. package/lib/scenes/MethodScene/components/DocResponses/DocResponseTypes.js.map +1 -0
  130. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.d.ts +9 -0
  131. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js +93 -0
  132. package/lib/scenes/MethodScene/components/DocResponses/DocResponses.js.map +1 -0
  133. package/lib/{components → scenes/MethodScene/components}/DocResponses/index.d.ts +0 -0
  134. package/lib/{components → scenes/MethodScene/components}/DocResponses/index.js +0 -0
  135. package/lib/scenes/MethodScene/components/DocResponses/index.js.map +1 -0
  136. package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.d.ts +0 -0
  137. package/lib/{components → scenes/MethodScene/components}/DocResponses/utils.js +0 -0
  138. package/lib/scenes/MethodScene/components/DocResponses/utils.js.map +1 -0
  139. package/lib/scenes/MethodScene/components/index.d.ts +1 -0
  140. package/lib/scenes/MethodScene/components/index.js +8 -0
  141. package/lib/scenes/MethodScene/components/index.js.map +1 -1
  142. package/lib/scenes/MethodTagScene/MethodTagScene.js +42 -11
  143. package/lib/scenes/MethodTagScene/MethodTagScene.js.map +1 -1
  144. package/lib/scenes/TypeScene/TypeScene.js +8 -1
  145. package/lib/scenes/TypeScene/TypeScene.js.map +1 -1
  146. package/lib/scenes/TypeTagScene/TypeTagScene.js +42 -12
  147. package/lib/scenes/TypeTagScene/TypeTagScene.js.map +1 -1
  148. package/lib/scenes/index.d.ts +1 -0
  149. package/lib/scenes/index.js +8 -0
  150. package/lib/scenes/index.js.map +1 -1
  151. package/lib/scenes/utils/hooks/index.d.ts +1 -0
  152. package/lib/scenes/utils/hooks/index.js +14 -0
  153. package/lib/scenes/utils/hooks/index.js.map +1 -0
  154. package/lib/scenes/utils/hooks/tagStoreSync.d.ts +1 -0
  155. package/lib/scenes/utils/hooks/tagStoreSync.js +51 -0
  156. package/lib/scenes/utils/hooks/tagStoreSync.js.map +1 -0
  157. package/lib/scenes/utils/index.d.ts +1 -0
  158. package/lib/scenes/utils/index.js +14 -0
  159. package/lib/scenes/utils/index.js.map +1 -0
  160. package/lib/state/settings/selectors.d.ts +2 -1
  161. package/lib/state/settings/selectors.js +5 -1
  162. package/lib/state/settings/selectors.js.map +1 -1
  163. package/lib/state/settings/slice.d.ts +7 -1
  164. package/lib/state/settings/slice.js +6 -1
  165. package/lib/state/settings/slice.js.map +1 -1
  166. package/lib/test-data/index.d.ts +1 -0
  167. package/lib/test-data/index.js +14 -0
  168. package/lib/test-data/index.js.map +1 -1
  169. package/lib/test-data/sdkLanguages.d.ts +10 -0
  170. package/lib/test-data/sdkLanguages.js +19 -0
  171. package/lib/test-data/sdkLanguages.js.map +1 -0
  172. package/lib/utils/hooks/globalStoreSync.d.ts +1 -0
  173. package/lib/utils/hooks/globalStoreSync.js +67 -0
  174. package/lib/utils/hooks/globalStoreSync.js.map +1 -0
  175. package/lib/utils/hooks/index.d.ts +3 -0
  176. package/lib/utils/hooks/index.js +30 -0
  177. package/lib/utils/hooks/index.js.map +1 -0
  178. package/lib/utils/hooks/navigation.d.ts +11 -0
  179. package/lib/utils/hooks/navigation.js +83 -0
  180. package/lib/utils/hooks/navigation.js.map +1 -0
  181. package/lib/utils/hooks/useQuery.d.ts +1 -0
  182. package/lib/utils/hooks/useQuery.js +20 -0
  183. package/lib/utils/hooks/useQuery.js.map +1 -0
  184. package/lib/utils/index.d.ts +2 -0
  185. package/lib/utils/index.js +38 -1
  186. package/lib/utils/index.js.map +1 -1
  187. package/lib/utils/path.d.ts +6 -2
  188. package/lib/utils/path.js +34 -3
  189. package/lib/utils/path.js.map +1 -1
  190. package/lib/utils/sdkLanguage.d.ts +6 -0
  191. package/lib/utils/sdkLanguage.js +59 -0
  192. package/lib/utils/sdkLanguage.js.map +1 -0
  193. package/package.json +14 -14
  194. package/src/ApiExplorer.tsx +18 -7
  195. package/src/components/DocMarkdown/DocMarkdown.tsx +4 -4
  196. package/src/components/DocSDKs/DocDeclarations.tsx +11 -22
  197. package/src/components/DocSDKs/DocSDKs.spec.tsx +4 -1
  198. package/src/components/Header/Header.spec.tsx +1 -1
  199. package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +5 -2
  200. package/src/components/SelectorContainer/ApiSpecSelector.tsx +4 -3
  201. package/src/components/SelectorContainer/SdkLanguageSelector.spec.tsx +60 -33
  202. package/src/components/SelectorContainer/SdkLanguageSelector.tsx +15 -22
  203. package/src/components/SelectorContainer/SelectorContainer.spec.tsx +1 -1
  204. package/src/components/SelectorContainer/SelectorContainer.tsx +18 -15
  205. package/src/components/SelectorContainer/utils.ts +45 -0
  206. package/src/components/SideNav/SideNav.spec.tsx +39 -5
  207. package/src/components/SideNav/SideNav.tsx +42 -29
  208. package/src/components/SideNav/SideNavMethods.spec.tsx +5 -0
  209. package/src/components/SideNav/SideNavMethods.tsx +11 -8
  210. package/src/components/SideNav/SideNavTypes.spec.tsx +9 -2
  211. package/src/components/SideNav/SideNavTypes.tsx +10 -8
  212. package/src/components/index.ts +0 -1
  213. package/src/routes/AppRouter.tsx +7 -5
  214. package/src/scenes/DiffScene/DiffScene.tsx +10 -10
  215. package/src/scenes/DiffScene/DocDiff/DiffItem.spec.tsx +4 -3
  216. package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +3 -4
  217. package/src/scenes/DiffScene/DocDiff/DocDiff.spec.tsx +73 -2
  218. package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +4 -4
  219. package/src/scenes/ErrorDetailScene/ErrorDetailScene.tsx +72 -0
  220. package/src/scenes/ErrorDetailScene/index.ts +26 -0
  221. package/src/scenes/MethodScene/MethodScene.tsx +23 -8
  222. package/src/{components → scenes/MethodScene/components}/DocResponses/DocResponseTypes.tsx +3 -6
  223. package/src/scenes/MethodScene/components/DocResponses/DocResponses.spec.tsx +153 -0
  224. package/src/scenes/MethodScene/components/DocResponses/DocResponses.tsx +103 -0
  225. package/src/{components → scenes/MethodScene/components}/DocResponses/index.ts +0 -0
  226. package/src/{components → scenes/MethodScene/components}/DocResponses/utils.spec.ts +1 -1
  227. package/src/{components → scenes/MethodScene/components}/DocResponses/utils.ts +0 -0
  228. package/src/scenes/MethodScene/components/index.ts +1 -0
  229. package/src/scenes/MethodTagScene/MethodTagScene.spec.tsx +25 -14
  230. package/src/scenes/MethodTagScene/MethodTagScene.tsx +42 -10
  231. package/src/scenes/TypeScene/TypeScene.tsx +8 -2
  232. package/src/scenes/TypeTagScene/TypeTagScene.spec.tsx +21 -11
  233. package/src/scenes/TypeTagScene/TypeTagScene.tsx +46 -13
  234. package/src/scenes/index.ts +1 -0
  235. package/src/scenes/utils/hooks/index.ts +27 -0
  236. package/src/scenes/utils/hooks/tagStoreSync.spec.ts +102 -0
  237. package/src/scenes/utils/hooks/tagStoreSync.ts +68 -0
  238. package/src/scenes/utils/index.ts +27 -0
  239. package/src/state/settings/selectors.spec.ts +5 -1
  240. package/src/state/settings/selectors.ts +3 -0
  241. package/src/state/settings/slice.ts +6 -0
  242. package/src/test-data/index.ts +1 -0
  243. package/src/test-data/sdkLanguages.ts +36 -0
  244. package/src/utils/hooks/globalStoreSync.spec.tsx +146 -0
  245. package/src/utils/hooks/globalStoreSync.ts +77 -0
  246. package/src/utils/hooks/index.ts +28 -0
  247. package/src/utils/hooks/navigation.spec.ts +118 -0
  248. package/src/utils/hooks/navigation.ts +121 -0
  249. package/src/utils/hooks/useQuery.ts +36 -0
  250. package/src/utils/index.ts +2 -0
  251. package/src/utils/path.spec.ts +92 -3
  252. package/src/utils/path.ts +46 -4
  253. package/src/utils/sdkLanguage.spec.ts +69 -0
  254. package/src/utils/sdkLanguage.ts +63 -0
  255. package/lib/components/DocResponses/DocResponseTypes.js.map +0 -1
  256. package/lib/components/DocResponses/DocResponses.d.ts +0 -8
  257. package/lib/components/DocResponses/DocResponses.js +0 -46
  258. package/lib/components/DocResponses/DocResponses.js.map +0 -1
  259. package/lib/components/DocResponses/utils.js.map +0 -1
  260. package/lib/esm/components/DocResponses/DocResponseTypes.js.map +0 -1
  261. package/lib/esm/components/DocResponses/DocResponses.js +0 -30
  262. package/lib/esm/components/DocResponses/DocResponses.js.map +0 -1
  263. package/lib/esm/components/DocResponses/index.js.map +0 -1
  264. package/lib/esm/components/DocResponses/utils.js.map +0 -1
  265. package/src/components/DocResponses/DocResponses.spec.tsx +0 -60
  266. package/src/components/DocResponses/DocResponses.tsx +0 -69
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  var _exportNames = {
7
7
  highlightHTML: true,
8
8
  getLoded: true,
9
- useWindowSize: true
9
+ useWindowSize: true,
10
+ useNavigation: true,
11
+ useGlobalStoreSync: true,
12
+ useQuery: true
10
13
  };
11
14
  Object.defineProperty(exports, "highlightHTML", {
12
15
  enumerable: true,
@@ -26,6 +29,24 @@ Object.defineProperty(exports, "useWindowSize", {
26
29
  return _useWindowSize.useWindowSize;
27
30
  }
28
31
  });
32
+ Object.defineProperty(exports, "useNavigation", {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _hooks.useNavigation;
36
+ }
37
+ });
38
+ Object.defineProperty(exports, "useGlobalStoreSync", {
39
+ enumerable: true,
40
+ get: function get() {
41
+ return _hooks.useGlobalStoreSync;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "useQuery", {
45
+ enumerable: true,
46
+ get: function get() {
47
+ return _hooks.useQuery;
48
+ }
49
+ });
29
50
 
30
51
  var _highlight = require("./highlight");
31
52
 
@@ -43,6 +64,20 @@ Object.keys(_path).forEach(function (key) {
43
64
  });
44
65
  });
45
66
 
67
+ var _sdkLanguage = require("./sdkLanguage");
68
+
69
+ Object.keys(_sdkLanguage).forEach(function (key) {
70
+ if (key === "default" || key === "__esModule") return;
71
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
+ if (key in exports && exports[key] === _sdkLanguage[key]) return;
73
+ Object.defineProperty(exports, key, {
74
+ enumerable: true,
75
+ get: function get() {
76
+ return _sdkLanguage[key];
77
+ }
78
+ });
79
+ });
80
+
46
81
  var _lodeUtils = require("./lodeUtils");
47
82
 
48
83
  var _useWindowSize = require("./useWindowSize");
@@ -74,4 +109,6 @@ Object.keys(_adaptorUtils).forEach(function (key) {
74
109
  }
75
110
  });
76
111
  });
112
+
113
+ var _hooks = require("./hooks");
77
114
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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 { highlightHTML } from './highlight'\nexport * from './path'\nexport { getLoded } from './lodeUtils'\nexport { useWindowSize } from './useWindowSize'\nexport * from './apixAdaptor'\nexport * from './adaptorUtils'\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA","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 { highlightHTML } from './highlight'\nexport * from './path'\nexport * from './sdkLanguage'\nexport { getLoded } from './lodeUtils'\nexport { useWindowSize } from './useWindowSize'\nexport * from './apixAdaptor'\nexport * from './adaptorUtils'\nexport { useNavigation, useGlobalStoreSync, useQuery } from './hooks'\n"],"file":"index.js"}
@@ -1,9 +1,13 @@
1
1
  import type { ApiModel, IMethod, IType } from '@looker/sdk-codegen';
2
2
  import type { Location as HLocation } from 'history';
3
- export declare const buildMethodPath: (specKey: string, tag: string, methodName: string) => string;
4
- export declare const buildTypePath: (specKey: string, tag: string, typeName: string) => string;
3
+ export declare const methodFilterOptions: RegExp;
4
+ export declare const typeFilterOptions: RegExp;
5
+ export declare const buildMethodPath: (specKey: string, tag: string, methodName: string, params?: string | undefined) => string;
6
+ export declare const buildTypePath: (specKey: string, tag: string, typeName: string, params?: string | undefined) => string;
5
7
  export declare const diffPath = "diff";
6
8
  export declare const oAuthPath = "oauth";
7
9
  export declare const isMethod: (item: IMethod | IType) => boolean;
8
10
  export declare const buildPath: (api: ApiModel, item: IMethod | IType, specKey: string) => string;
9
11
  export declare const getSpecKey: (location: HLocation | Location) => string | null;
12
+ export declare const getSceneType: (path: string) => string;
13
+ export declare const isValidFilter: (path: string, filter: string) => boolean;
package/lib/utils/path.js CHANGED
@@ -3,21 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getSpecKey = exports.buildPath = exports.isMethod = exports.oAuthPath = exports.diffPath = exports.buildTypePath = exports.buildMethodPath = void 0;
6
+ exports.isValidFilter = exports.getSceneType = exports.getSpecKey = exports.buildPath = exports.isMethod = exports.oAuthPath = exports.diffPath = exports.buildTypePath = exports.buildMethodPath = exports.typeFilterOptions = exports.methodFilterOptions = void 0;
7
7
 
8
8
  var _sdkCodegen = require("@looker/sdk-codegen");
9
9
 
10
+ var _reactRouter = require("react-router");
11
+
10
12
  function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); _groups.set(_this, groups || _groups.get(re)); return _setPrototypeOf(_this, BabelRegExp.prototype); } _inherits(BabelRegExp, RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; if (typeof args[args.length - 1] !== "object") { args = [].slice.call(args); args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
11
13
 
12
14
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13
15
 
14
16
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
17
 
16
- var buildMethodPath = (specKey, tag, methodName) => "/".concat(specKey, "/methods/").concat(tag, "/").concat(methodName);
18
+ var methodFilterOptions = /GET$|POST$|PUT$|PATCH$|DELETE$/i;
19
+ exports.methodFilterOptions = methodFilterOptions;
20
+ var typeFilterOptions = /SPECIFICATION$|WRITE$|REQUEST$|ENUMERATED$/i;
21
+ exports.typeFilterOptions = typeFilterOptions;
22
+
23
+ var buildMethodPath = (specKey, tag, methodName, params) => "/".concat(specKey, "/methods/").concat(tag, "/").concat(methodName).concat(params ? "?".concat(params) : '');
17
24
 
18
25
  exports.buildMethodPath = buildMethodPath;
19
26
 
20
- var buildTypePath = (specKey, tag, typeName) => "/".concat(specKey, "/types/").concat(tag, "/").concat(typeName);
27
+ var buildTypePath = (specKey, tag, typeName, params) => "/".concat(specKey, "/types/").concat(tag, "/").concat(typeName).concat(params ? "?".concat(params) : '');
21
28
 
22
29
  exports.buildTypePath = buildTypePath;
23
30
  var diffPath = 'diff';
@@ -80,4 +87,28 @@ var getSpecKey = location => {
80
87
  };
81
88
 
82
89
  exports.getSpecKey = getSpecKey;
90
+
91
+ var getSceneType = path => {
92
+ var match = (0, _reactRouter.matchPath)(path, {
93
+ path: '/:specKey/:tagType'
94
+ });
95
+ return match ? match.params.tagType : '';
96
+ };
97
+
98
+ exports.getSceneType = getSceneType;
99
+
100
+ var isValidFilter = (path, filter) => {
101
+ var isValid;
102
+ var sceneType = getSceneType(path);
103
+ if (!sceneType) isValid = false;else if (!filter.localeCompare('all', 'en', {
104
+ sensitivity: 'base'
105
+ })) isValid = true;else if (sceneType === 'methods') {
106
+ isValid = methodFilterOptions.test(filter);
107
+ } else {
108
+ isValid = typeFilterOptions.test(filter);
109
+ }
110
+ return isValid;
111
+ };
112
+
113
+ exports.isValidFilter = isValidFilter;
83
114
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/path.ts"],"names":["buildMethodPath","specKey","tag","methodName","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"],"mappings":";;;;;;;AA2BA;;;;;;;;AAUO,IAAMA,eAAe,GAAG,CAC7BC,OAD6B,EAE7BC,GAF6B,EAG7BC,UAH6B,gBAItBF,OAJsB,sBAIHC,GAJG,cAIIC,UAJJ,CAAxB;;;;AAaA,IAAMC,aAAa,GAAG,CAACH,OAAD,EAAkBC,GAAlB,EAA+BG,QAA/B,gBACvBJ,OADuB,oBACNC,GADM,cACCG,QADD,CAAtB;;;AAGA,IAAMC,QAAQ,GAAG,MAAjB;;AACA,IAAMC,SAAS,GAAG,OAAlB;;;AAQP,IAAMC,YAAY,GAAG,CAACC,GAAD,EAAgBN,UAAhB,KAAuC;AAE1D,SAAOO,MAAM,CAACC,OAAP,CAAeF,GAAG,CAACG,IAAnB,EACJC,MADI,CACG;AAAA,QAAC,GAAGC,OAAH,CAAD;AAAA,WAAiBX,UAAU,IAAIW,OAA/B;AAAA,GADH,EAEJC,GAFI,CAEA;AAAA,QAAC,CAACC,SAAD,CAAD;AAAA,WAAiBA,SAAjB;AAAA,GAFA,EAE4B,CAF5B,CAAP;AAGD,CALD;;AAWO,IAAMC,QAAQ,GAAIC,IAAD,IAA2B,YAAYA,IAAxD;;;;AAOP,IAAMC,UAAU,GAAG,CAACV,GAAD,EAAgBW,IAAhB,KAAgC;AACjD,MAAMC,MAAM,GAAG,gCAAeZ,GAAf,EAAoBW,IAApB,CAAf;AACA,SAAOZ,YAAY,CAACC,GAAD,EAAMY,MAAM,CAACC,IAAb,CAAnB;AACD,CAHD;;AAYO,IAAMC,SAAS,GAAG,CACvBd,GADuB,EAEvBS,IAFuB,EAGvBjB,OAHuB,KAIpB;AACH,MAAIuB,IAAJ;;AACA,MAAIP,QAAQ,CAACC,IAAD,CAAZ,EAAoB;AAClB,QAAMhB,GAAG,GAAGM,YAAY,CAACC,GAAD,EAAMS,IAAI,CAACI,IAAX,CAAxB;AACAE,IAAAA,IAAI,GAAGxB,eAAe,CAACC,OAAD,EAAUC,GAAV,EAAegB,IAAI,CAACI,IAApB,CAAtB;AACD,GAHD,MAGO;AACL,QAAMpB,IAAG,GAAGiB,UAAU,CAACV,GAAD,EAAMS,IAAN,CAAtB;;AACAM,IAAAA,IAAI,GAAGpB,aAAa,CAACH,OAAD,EAAUC,IAAV,EAAegB,IAAI,CAACI,IAApB,CAApB;AACD;;AACD,SAAOE,IAAP;AACD,CAdM;;;;AAoBA,IAAMC,UAAU,GAAIC,QAAD,IAAmD;AAAA;;AAC3E,MAAMC,QAAQ,GAAGD,QAAQ,CAACC,QAA1B;AACA,MAAIC,KAAJ;;AACA,MAAID,QAAQ,CAACE,UAAT,YAAwBvB,QAAxB,EAAJ,EAAyC;AACvC,QAAMwB,OAAO,GAAG,IAAIC,MAAJ,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,SAAO,WAAAA,KAAK,UAAL,yDAAOI,MAAP,gEAAe/B,OAAf,KAA0B,IAAjC;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 { ApiModel, IMethod, IType } from '@looker/sdk-codegen'\nimport { firstMethodRef } from '@looker/sdk-codegen'\nimport type { Location as HLocation } from 'history'\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 * @returns a Method path\n */\nexport const buildMethodPath = (\n specKey: string,\n tag: string,\n methodName: string\n) => `/${specKey}/methods/${tag}/${methodName}`\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 * @returns a Type path\n */\nexport const buildTypePath = (specKey: string, tag: string, typeName: string) =>\n `/${specKey}/types/${tag}/${typeName}`\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"],"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","groups","getSceneType","tagType","isValidFilter","isValid","sceneType","localeCompare","sensitivity","test"],"mappings":"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","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 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"}
@@ -0,0 +1,6 @@
1
+ export declare const allAlias = "all";
2
+ export declare const allSdkLanguages: () => Record<string, string>;
3
+ export declare const findSdk: (label: string) => {
4
+ alias: string;
5
+ language: string;
6
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findSdk = exports.allSdkLanguages = exports.allAlias = void 0;
7
+
8
+ var _sdkCodegen = require("@looker/sdk-codegen");
9
+
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11
+
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
+
14
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+
16
+ var allAlias = 'all';
17
+ exports.allAlias = allAlias;
18
+
19
+ var allSdkLanguages = () => {
20
+ var languages = {};
21
+
22
+ _sdkCodegen.codeGenerators.forEach(gen => {
23
+ var alias = gen.extension.toString().match(/\.(\w+)\b/)[1];
24
+ languages[alias] = gen.language;
25
+ });
26
+
27
+ return _objectSpread(_objectSpread({}, languages), {}, {
28
+ [allAlias]: 'All'
29
+ });
30
+ };
31
+
32
+ exports.allSdkLanguages = allSdkLanguages;
33
+
34
+ var findSdk = label => {
35
+ var languages = allSdkLanguages();
36
+ var match = {
37
+ alias: allAlias,
38
+ language: languages[allAlias]
39
+ };
40
+
41
+ for (var [alias, language] of Object.entries(languages)) {
42
+ if (!label.localeCompare(alias, 'en', {
43
+ sensitivity: 'base'
44
+ }) || !label.localeCompare(language, 'en', {
45
+ sensitivity: 'base'
46
+ })) {
47
+ match = {
48
+ alias,
49
+ language
50
+ };
51
+ break;
52
+ }
53
+ }
54
+
55
+ return match;
56
+ };
57
+
58
+ exports.findSdk = findSdk;
59
+ //# sourceMappingURL=sdkLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/sdkLanguage.ts"],"names":["allAlias","allSdkLanguages","languages","codeGenerators","forEach","gen","alias","extension","toString","match","language","findSdk","label","Object","entries","localeCompare","sensitivity"],"mappings":";;;;;;;AA0BA;;;;;;;;AAEO,IAAMA,QAAQ,GAAG,KAAjB;;;AAMA,IAAMC,eAAe,GAAG,MAA8B;AAC3D,MAAMC,SAAS,GAAG,EAAlB;;AACAC,6BAAeC,OAAf,CAAwBC,GAAD,IAAS;AAC9B,QAAMC,KAAK,GAAGD,GAAG,CAACE,SAAJ,CAAcC,QAAd,GAAyBC,KAAzB,CAA+B,WAA/B,EAA6C,CAA7C,CAAd;AACAP,IAAAA,SAAS,CAACI,KAAD,CAAT,GAAmBD,GAAG,CAACK,QAAvB;AACD,GAHD;;AAKA,yCAAYR,SAAZ;AAAuB,KAACF,QAAD,GAAY;AAAnC;AACD,CARM;;;;AAeA,IAAMW,OAAO,GAAIC,KAAD,IAAmB;AACxC,MAAMV,SAAS,GAAGD,eAAe,EAAjC;AACA,MAAIQ,KAAK,GAAG;AAAEH,IAAAA,KAAK,EAAEN,QAAT;AAAmBU,IAAAA,QAAQ,EAAER,SAAS,CAACF,QAAD;AAAtC,GAAZ;;AACA,OAAK,IAAM,CAACM,KAAD,EAAQI,QAAR,CAAX,IAAgCG,MAAM,CAACC,OAAP,CAAeZ,SAAf,CAAhC,EAA2D;AACzD,QACE,CAACU,KAAK,CAACG,aAAN,CAAoBT,KAApB,EAA2B,IAA3B,EAAiC;AAAEU,MAAAA,WAAW,EAAE;AAAf,KAAjC,CAAD,IACA,CAACJ,KAAK,CAACG,aAAN,CAAoBL,QAApB,EAA8B,IAA9B,EAAoC;AAAEM,MAAAA,WAAW,EAAE;AAAf,KAApC,CAFH,EAGE;AACAP,MAAAA,KAAK,GAAG;AAAEH,QAAAA,KAAF;AAASI,QAAAA;AAAT,OAAR;AACA;AACD;AACF;;AACD,SAAOD,KAAP;AACD,CAbM","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 { codeGenerators } from '@looker/sdk-codegen'\n\nexport const allAlias = 'all'\n\n/**\n * Gets all supported sdk languages\n * @returns mapping of sdk language aliases to name\n */\nexport const allSdkLanguages = (): Record<string, string> => {\n const languages = {}\n codeGenerators.forEach((gen) => {\n const alias = gen.extension.toString().match(/\\.(\\w+)\\b/)![1]\n languages[alias] = gen.language\n })\n\n return { ...languages, [allAlias]: 'All' }\n}\n\n/**\n * Searches for sdk language details given label\n * @param label label to search by\n * @returns language name and alias\n */\nexport const findSdk = (label: string) => {\n const languages = allSdkLanguages()\n let match = { alias: allAlias, language: languages[allAlias] }\n for (const [alias, language] of Object.entries(languages)) {\n if (\n !label.localeCompare(alias, 'en', { sensitivity: 'base' }) ||\n !label.localeCompare(language, 'en', { sensitivity: 'base' })\n ) {\n match = { alias, language }\n break\n }\n }\n return match\n}\n"],"file":"sdkLanguage.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/api-explorer",
3
- "version": "0.9.35",
3
+ "version": "0.9.37",
4
4
  "description": "Looker API Explorer",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -32,12 +32,13 @@
32
32
  "deploy-dev-portal": "rm -f ../../../developer-portal/static/apix/dist/*.js* && cp -R ./dist/*.js* ../../../developer-portal/static/apix/dist"
33
33
  },
34
34
  "devDependencies": {
35
- "@looker/components-test-utils": "^1.5.5",
36
- "@looker/sdk-codegen-scripts": "^21.4.1",
37
- "@looker/sdk-node": "^22.10.0",
35
+ "@looker/components-test-utils": "^1.5.26",
36
+ "@looker/sdk-codegen-scripts": "^21.4.3",
37
+ "@looker/sdk-node": "^22.12.1",
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",
41
+ "@testing-library/react-hooks": "^8.0.1",
41
42
  "@testing-library/user-event": "^12.6.0",
42
43
  "@types/expect-puppeteer": "^4.4.6",
43
44
  "@types/jest-environment-puppeteer": "^4.4.1",
@@ -67,17 +68,16 @@
67
68
  "webpack-merge": "^5.7.3"
68
69
  },
69
70
  "dependencies": {
70
- "@looker/code-editor": "^0.1.22",
71
- "@looker/components": "^2.8.1",
72
- "@looker/components-date": "^2.4.1",
73
- "@looker/design-tokens": "^2.7.1",
74
- "@looker/extension-utils": "^0.1.12",
71
+ "@looker/code-editor": "^0.1.24",
72
+ "@looker/components": "^3.0.8",
73
+ "@looker/design-tokens": "^2.7.21",
74
+ "@looker/extension-utils": "^0.1.14",
75
75
  "@looker/icons": "^1.5.3",
76
76
  "@looker/redux": "0.0.0",
77
- "@looker/run-it": "^0.9.35",
78
- "@looker/sdk": "^22.10.0",
79
- "@looker/sdk-codegen": "^21.6.0",
80
- "@looker/sdk-rtl": "^21.3.4",
77
+ "@looker/run-it": "^0.9.37",
78
+ "@looker/sdk": "^22.12.1",
79
+ "@looker/sdk-codegen": "^21.7.1",
80
+ "@looker/sdk-rtl": "^21.4.0",
81
81
  "@reduxjs/toolkit": "^1.6.2",
82
82
  "@styled-icons/material": "^10.28.0",
83
83
  "@styled-icons/material-outlined": "^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": "dd8c49742dcb8b92e6ad22252884eb6ca3a041ed"
99
+ "gitHead": "028fb6cd1f84c23fd10d42041f3d572f4f724195"
100
100
  }
@@ -60,15 +60,15 @@ import { AppRouter } from './routes'
60
60
  import { apixFilesHost } from './utils/lodeUtils'
61
61
  import {
62
62
  useSettingActions,
63
- useSettingStoreState,
64
63
  useLodeActions,
65
64
  useLodesStoreState,
66
65
  useSpecActions,
67
66
  useSpecStoreState,
68
67
  selectSpecs,
69
68
  selectCurrentSpec,
69
+ useSettingStoreState,
70
70
  } from './state'
71
- import { getSpecKey, diffPath } from './utils'
71
+ import { getSpecKey, findSdk, useGlobalStoreSync } from './utils'
72
72
 
73
73
  export interface ApiExplorerProps {
74
74
  adaptor: IApixAdaptor
@@ -85,16 +85,18 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
85
85
  declarationsLodeUrl = `${apixFilesHost}/declarationsIndex.json`,
86
86
  headless = false,
87
87
  }) => {
88
- useSettingStoreState()
89
88
  useLodesStoreState()
90
89
  const { working, description } = useSpecStoreState()
91
90
  const specs = useSelector(selectSpecs)
92
91
  const spec = useSelector(selectCurrentSpec)
93
92
  const { initLodesAction } = useLodeActions()
94
- const { initSettingsAction } = useSettingActions()
93
+ const { initialized } = useSettingStoreState()
94
+ const { initSettingsAction, setSearchPatternAction, setSdkLanguageAction } =
95
+ useSettingActions()
95
96
  const { initSpecsAction, setCurrentSpecAction } = useSpecActions()
96
97
 
97
98
  const location = useLocation()
99
+ useGlobalStoreSync()
98
100
  const [hasNavigation, setHasNavigation] = useState(true)
99
101
  const toggleNavigation = (target?: boolean) =>
100
102
  setHasNavigation(target || !hasNavigation)
@@ -118,11 +120,21 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
118
120
 
119
121
  useEffect(() => {
120
122
  const maybeSpec = location.pathname?.split('/')[1]
121
- if (spec && maybeSpec && maybeSpec !== diffPath && maybeSpec !== spec.key) {
123
+ if (spec && maybeSpec && maybeSpec !== spec.key) {
122
124
  setCurrentSpecAction({ currentSpecKey: maybeSpec })
123
125
  }
124
126
  }, [location.pathname, spec])
125
127
 
128
+ useEffect(() => {
129
+ if (!initialized) return
130
+ const searchParams = new URLSearchParams(location.search)
131
+ const searchPattern = searchParams.get('s') || ''
132
+ const sdkParam = searchParams.get('sdk') || 'all'
133
+ const { language: sdkLanguage } = findSdk(sdkParam)
134
+ setSearchPatternAction({ searchPattern })
135
+ setSdkLanguageAction({ sdkLanguage })
136
+ }, [location.search])
137
+
126
138
  useEffect(() => {
127
139
  if (headless) {
128
140
  window.addEventListener('message', hasNavigationToggle)
@@ -137,7 +149,7 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
137
149
  const themeOverrides = adaptor.themeOverrides()
138
150
 
139
151
  let neededSpec = location.pathname?.split('/')[1]
140
- if (!neededSpec || neededSpec === diffPath) {
152
+ if (!neededSpec) {
141
153
  neededSpec = spec?.key
142
154
  }
143
155
 
@@ -207,7 +219,6 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
207
219
  <AppRouter
208
220
  specKey={spec.key}
209
221
  api={spec.api!}
210
- specs={specs}
211
222
  toggleNavigation={toggleNavigation}
212
223
  />
213
224
  </Layout>
@@ -26,11 +26,11 @@
26
26
 
27
27
  import type { FC } from 'react'
28
28
  import React from 'react'
29
- import { useHistory } from 'react-router-dom'
30
29
  import { Markdown } from '@looker/code-editor'
31
30
  import { useSelector } from 'react-redux'
32
31
  import { getEnvAdaptor } from '@looker/extension-utils'
33
32
  import { selectSearchPattern } from '../../state'
33
+ import { useNavigation } from '../../utils'
34
34
  import { transformURL } from './utils'
35
35
 
36
36
  interface DocMarkdownProps {
@@ -40,13 +40,13 @@ interface DocMarkdownProps {
40
40
 
41
41
  export const DocMarkdown: FC<DocMarkdownProps> = ({ source, specKey }) => {
42
42
  const searchPattern = useSelector(selectSearchPattern)
43
- const history = useHistory()
43
+ const { navigate } = useNavigation()
44
44
 
45
45
  const linkClickHandler = (pathname: string, url: string) => {
46
46
  if (pathname.startsWith(`/${specKey}`)) {
47
- history.push(pathname)
47
+ navigate(pathname)
48
48
  } else if (url.startsWith(`/${specKey}`)) {
49
- history.push(url)
49
+ navigate(url)
50
50
  } else if (url.startsWith('https://')) {
51
51
  const adaptor = getEnvAdaptor()
52
52
  adaptor.openBrowserWindow(url)
@@ -23,10 +23,10 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- import { Tab, TabList, TabPanel, TabPanels, useTabs } from '@looker/components'
26
+ import React from 'react'
27
+ import { Tab2, Tabs2 } from '@looker/components'
27
28
  import type { KeyedCollection } from '@looker/sdk-codegen'
28
29
  import type { FC } from 'react'
29
- import React from 'react'
30
30
  import { DocCode } from '../DocCode'
31
31
 
32
32
  interface DocDeclarationsProps {
@@ -37,23 +37,12 @@ interface DocDeclarationsProps {
37
37
  * Renders all provided declarations
38
38
  * @param declarations A collection of SDK declarations in various languages
39
39
  */
40
- export const DocDeclarations: FC<DocDeclarationsProps> = ({ declarations }) => {
41
- const tabs = useTabs()
42
-
43
- return (
44
- <>
45
- <TabList {...tabs}>
46
- {Object.keys(declarations).map((language) => (
47
- <Tab key={language}>{language}</Tab>
48
- ))}
49
- </TabList>
50
- <TabPanels {...tabs} pt="0">
51
- {Object.entries(declarations).map(([language, code]) => (
52
- <TabPanel key={language}>
53
- <DocCode language={language} code={code} />
54
- </TabPanel>
55
- ))}
56
- </TabPanels>
57
- </>
58
- )
59
- }
40
+ export const DocDeclarations: FC<DocDeclarationsProps> = ({ declarations }) => (
41
+ <Tabs2>
42
+ {Object.entries(declarations).map(([language, code]) => (
43
+ <Tab2 key={language} id={language} label={language}>
44
+ <DocCode code={code} language={language} />
45
+ </Tab2>
46
+ ))}
47
+ </Tabs2>
48
+ )
@@ -66,7 +66,10 @@ describe('DocSDKs', () => {
66
66
  'it can render a %s method declaration',
67
67
  (sdkLanguage) => {
68
68
  store = createTestStore({
69
- settings: { initialized: false, sdkLanguage },
69
+ settings: {
70
+ initialized: false,
71
+ sdkLanguage: sdkLanguage,
72
+ },
70
73
  })
71
74
  renderWithReduxProvider(
72
75
  <DocSDKs api={api} method={api.methods.run_look} />,
@@ -93,6 +93,6 @@ describe('Header', () => {
93
93
  name: 'Compare Specifications',
94
94
  })
95
95
  .closest('a')
96
- ).toHaveAttribute('href', `/diff/${spec.key}/`)
96
+ ).toHaveAttribute('href', `/${spec.key}/diff`)
97
97
  })
98
98
  })
@@ -41,7 +41,7 @@ jest.mock('react-router-dom', () => {
41
41
  useLocation: () => ({
42
42
  pathname: '/4.0/methods/Dashboard/dashboard',
43
43
  }),
44
- useHistory: jest.fn().mockReturnValue({ push: jest.fn() }),
44
+ useHistory: jest.fn().mockReturnValue({ push: jest.fn(), location }),
45
45
  }
46
46
  })
47
47
 
@@ -83,6 +83,9 @@ describe('ApiSpecSelector', () => {
83
83
  })
84
84
  const button = screen.getByText('3.1')
85
85
  userEvent.click(button)
86
- expect(push).toHaveBeenCalledWith('/3.1/methods/Dashboard/dashboard')
86
+ expect(push).toHaveBeenCalledWith({
87
+ pathname: '/3.1/methods/Dashboard/dashboard',
88
+ search: '',
89
+ })
87
90
  })
88
91
  })
@@ -27,9 +27,10 @@
27
27
  import type { FC } from 'react'
28
28
  import React from 'react'
29
29
  import { Select } from '@looker/components'
30
- import { useHistory, useLocation } from 'react-router-dom'
30
+ import { useLocation } from 'react-router-dom'
31
31
  import type { SpecItem } from '@looker/sdk-codegen'
32
32
  import { useSelector } from 'react-redux'
33
+ import { useNavigation } from '../../utils'
33
34
 
34
35
  import { selectSpecs } from '../../state'
35
36
 
@@ -38,8 +39,8 @@ interface ApiSpecSelectorProps {
38
39
  }
39
40
 
40
41
  export const ApiSpecSelector: FC<ApiSpecSelectorProps> = ({ spec }) => {
41
- const history = useHistory()
42
42
  const location = useLocation()
43
+ const { navigate } = useNavigation()
43
44
  const specs = useSelector(selectSpecs)
44
45
  const options = Object.entries(specs).map(([key, spec]) => ({
45
46
  value: key,
@@ -49,7 +50,7 @@ export const ApiSpecSelector: FC<ApiSpecSelectorProps> = ({ spec }) => {
49
50
 
50
51
  const handleChange = (specKey: string) => {
51
52
  const matchPath = location.pathname.replace(`/${spec.key}`, `/${specKey}`)
52
- history.push(matchPath)
53
+ navigate(matchPath)
53
54
  }
54
55
 
55
56
  return (