@looker/api-explorer 0.9.26 → 0.9.29

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 (220) hide show
  1. package/CHANGELOG.md +80 -1
  2. package/e2e/e2e.spec.ts +1 -1
  3. package/lib/ApiExplorer.d.ts +2 -6
  4. package/lib/ApiExplorer.js +53 -74
  5. package/lib/ApiExplorer.js.map +1 -1
  6. package/lib/StandaloneApiExplorer.js +35 -47
  7. package/lib/StandaloneApiExplorer.js.map +1 -1
  8. package/lib/components/Banner/Banner.d.ts +8 -0
  9. package/lib/components/Banner/Banner.js +70 -0
  10. package/lib/components/Banner/Banner.js.map +1 -0
  11. package/lib/components/Banner/index.d.ts +1 -0
  12. package/lib/components/Banner/index.js +14 -0
  13. package/lib/components/Banner/index.js.map +1 -0
  14. package/lib/components/DocPseudo/DocParam.js +3 -1
  15. package/lib/components/DocPseudo/DocParam.js.map +1 -1
  16. package/lib/components/DocSDKs/DocSDKs.js +3 -3
  17. package/lib/components/DocSDKs/DocSDKs.js.map +1 -1
  18. package/lib/components/ExploreType/ExploreType.js +3 -5
  19. package/lib/components/ExploreType/ExploreType.js.map +1 -1
  20. package/lib/components/Header/Header.d.ts +2 -5
  21. package/lib/components/Header/Header.js +1 -5
  22. package/lib/components/Header/Header.js.map +1 -1
  23. package/lib/components/SelectorContainer/ApiSpecSelector.d.ts +2 -5
  24. package/lib/components/SelectorContainer/ApiSpecSelector.js +5 -5
  25. package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  26. package/lib/components/SelectorContainer/SelectorContainer.d.ts +2 -5
  27. package/lib/components/SelectorContainer/SelectorContainer.js +3 -7
  28. package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
  29. package/lib/components/SideNav/SideNav.d.ts +2 -5
  30. package/lib/components/SideNav/SideNav.js.map +1 -1
  31. package/lib/components/index.d.ts +1 -0
  32. package/lib/components/index.js +8 -0
  33. package/lib/components/index.js.map +1 -1
  34. package/lib/esm/ApiExplorer.js +54 -74
  35. package/lib/esm/ApiExplorer.js.map +1 -1
  36. package/lib/esm/StandaloneApiExplorer.js +34 -48
  37. package/lib/esm/StandaloneApiExplorer.js.map +1 -1
  38. package/lib/esm/components/Banner/Banner.js +54 -0
  39. package/lib/esm/components/Banner/Banner.js.map +1 -0
  40. package/lib/esm/components/Banner/index.js +2 -0
  41. package/lib/esm/components/Banner/index.js.map +1 -0
  42. package/lib/esm/components/DocPseudo/DocParam.js +2 -1
  43. package/lib/esm/components/DocPseudo/DocParam.js.map +1 -1
  44. package/lib/esm/components/DocSDKs/DocSDKs.js +2 -2
  45. package/lib/esm/components/DocSDKs/DocSDKs.js.map +1 -1
  46. package/lib/esm/components/ExploreType/ExploreType.js +3 -4
  47. package/lib/esm/components/ExploreType/ExploreType.js.map +1 -1
  48. package/lib/esm/components/Header/Header.js +1 -5
  49. package/lib/esm/components/Header/Header.js.map +1 -1
  50. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +4 -5
  51. package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
  52. package/lib/esm/components/SelectorContainer/SelectorContainer.js +3 -7
  53. package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
  54. package/lib/esm/components/SideNav/SideNav.js.map +1 -1
  55. package/lib/esm/components/index.js +1 -0
  56. package/lib/esm/components/index.js.map +1 -1
  57. package/lib/esm/index.js +1 -0
  58. package/lib/esm/index.js.map +1 -1
  59. package/lib/esm/routes/AppRouter.js +3 -7
  60. package/lib/esm/routes/AppRouter.js.map +1 -1
  61. package/lib/esm/scenes/DiffScene/DiffScene.js +43 -99
  62. package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
  63. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
  64. package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  65. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
  66. package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  67. package/lib/esm/scenes/MethodScene/MethodScene.js +4 -5
  68. package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
  69. package/lib/esm/state/index.js +1 -0
  70. package/lib/esm/state/index.js.map +1 -1
  71. package/lib/esm/state/specs/index.js +3 -0
  72. package/lib/esm/state/specs/index.js.map +1 -0
  73. package/lib/esm/state/specs/sagas.js +58 -0
  74. package/lib/esm/state/specs/sagas.js.map +1 -0
  75. package/lib/esm/state/specs/selectors.js +8 -0
  76. package/lib/esm/state/specs/selectors.js.map +1 -0
  77. package/lib/esm/state/specs/slice.js +55 -0
  78. package/lib/esm/state/specs/slice.js.map +1 -0
  79. package/lib/esm/state/store.js +53 -2
  80. package/lib/esm/state/store.js.map +1 -1
  81. package/lib/esm/test-utils/redux.js +9 -5
  82. package/lib/esm/test-utils/redux.js.map +1 -1
  83. package/lib/esm/utils/adaptorUtils.js +101 -0
  84. package/lib/esm/utils/adaptorUtils.js.map +1 -0
  85. package/lib/esm/utils/apixAdaptor.js +48 -0
  86. package/lib/esm/utils/apixAdaptor.js.map +1 -0
  87. package/lib/esm/utils/index.js +3 -1
  88. package/lib/esm/utils/index.js.map +1 -1
  89. package/lib/esm/utils/path.js +27 -2
  90. package/lib/esm/utils/path.js.map +1 -1
  91. package/lib/index.d.ts +1 -0
  92. package/lib/index.js +13 -0
  93. package/lib/index.js.map +1 -1
  94. package/lib/routes/AppRouter.d.ts +1 -5
  95. package/lib/routes/AppRouter.js +3 -7
  96. package/lib/routes/AppRouter.js.map +1 -1
  97. package/lib/scenes/DiffScene/DiffScene.js +45 -100
  98. package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
  99. package/lib/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
  100. package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
  101. package/lib/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
  102. package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
  103. package/lib/scenes/MethodScene/MethodScene.d.ts +0 -4
  104. package/lib/scenes/MethodScene/MethodScene.js +5 -5
  105. package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
  106. package/lib/state/index.d.ts +1 -0
  107. package/lib/state/index.js +13 -0
  108. package/lib/state/index.js.map +1 -1
  109. package/lib/state/settings/selectors.d.ts +1 -1
  110. package/lib/state/settings/slice.d.ts +1 -1
  111. package/lib/state/specs/index.d.ts +2 -0
  112. package/lib/state/specs/index.js +32 -0
  113. package/lib/state/specs/index.js.map +1 -0
  114. package/lib/state/specs/sagas.d.ts +1 -0
  115. package/lib/state/specs/sagas.js +67 -0
  116. package/lib/state/specs/sagas.js.map +1 -0
  117. package/lib/state/specs/selectors.d.ts +4 -0
  118. package/lib/state/specs/selectors.js +20 -0
  119. package/lib/state/specs/selectors.js.map +1 -0
  120. package/lib/state/specs/slice.d.ts +49 -0
  121. package/lib/state/specs/slice.js +70 -0
  122. package/lib/state/specs/slice.js.map +1 -0
  123. package/lib/state/store.d.ts +3 -0
  124. package/lib/state/store.js +56 -2
  125. package/lib/state/store.js.map +1 -1
  126. package/lib/test-data/declarations.d.ts +2 -0
  127. package/lib/test-data/examples.d.ts +2 -0
  128. package/lib/test-data/index.d.ts +3 -0
  129. package/lib/test-data/index.js +12 -42
  130. package/lib/test-data/index.js.map +1 -1
  131. package/lib/test-data/specs.d.ts +10 -0
  132. package/lib/test-data/specs.js +6 -6
  133. package/lib/test-data/specs.js.map +1 -1
  134. package/lib/test-utils/redux.d.ts +2 -1
  135. package/lib/test-utils/redux.js +9 -4
  136. package/lib/test-utils/redux.js.map +1 -1
  137. package/lib/utils/adaptorUtils.d.ts +30 -0
  138. package/lib/utils/adaptorUtils.js +124 -0
  139. package/lib/utils/adaptorUtils.js.map +1 -0
  140. package/lib/utils/apixAdaptor.d.ts +15 -0
  141. package/lib/utils/apixAdaptor.js +67 -0
  142. package/lib/utils/apixAdaptor.js.map +1 -0
  143. package/lib/utils/index.d.ts +3 -1
  144. package/lib/utils/index.js +45 -30
  145. package/lib/utils/index.js.map +1 -1
  146. package/lib/utils/path.d.ts +3 -0
  147. package/lib/utils/path.js +32 -2
  148. package/lib/utils/path.js.map +1 -1
  149. package/package.json +10 -10
  150. package/src/ApiExplorer.tsx +47 -74
  151. package/src/StandaloneApiExplorer.tsx +37 -52
  152. package/src/components/Banner/Banner.spec.tsx +99 -0
  153. package/src/components/Banner/Banner.tsx +87 -0
  154. package/src/{reducers → components/Banner}/index.ts +1 -1
  155. package/src/components/DocPseudo/DocParam.spec.tsx +2 -1
  156. package/src/components/DocPseudo/DocParam.tsx +2 -1
  157. package/src/components/DocSDKs/DocSDKs.tsx +4 -5
  158. package/src/components/ExploreType/ExploreType.spec.tsx +0 -23
  159. package/src/components/ExploreType/ExploreType.tsx +5 -6
  160. package/src/components/ExploreType/exploreUtils.spec.tsx +1 -1
  161. package/src/components/Header/Header.spec.tsx +9 -30
  162. package/src/components/Header/Header.tsx +3 -10
  163. package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +31 -44
  164. package/src/components/SelectorContainer/ApiSpecSelector.tsx +6 -12
  165. package/src/components/SelectorContainer/SelectorContainer.spec.tsx +7 -26
  166. package/src/components/SelectorContainer/SelectorContainer.tsx +4 -10
  167. package/src/components/SideNav/SideNav.spec.tsx +12 -45
  168. package/src/components/SideNav/SideNav.tsx +1 -7
  169. package/src/components/index.ts +1 -0
  170. package/src/index.ts +1 -0
  171. package/src/routes/AppRouter.tsx +25 -37
  172. package/src/scenes/DiffScene/DiffScene.tsx +47 -84
  173. package/src/scenes/DiffScene/DocDiff/DiffItem.spec.tsx +9 -16
  174. package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +11 -12
  175. package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +2 -2
  176. package/src/scenes/MethodScene/MethodScene.tsx +4 -10
  177. package/src/state/index.ts +1 -0
  178. package/src/{reducers/spec → state/specs}/index.ts +2 -3
  179. package/src/state/specs/sagas.spec.ts +135 -0
  180. package/src/state/specs/sagas.ts +81 -0
  181. package/src/{reducers/spec/actions.spec.ts → state/specs/selectors.ts} +12 -11
  182. package/src/state/specs/slice.ts +109 -0
  183. package/src/state/store.ts +58 -0
  184. package/src/test-data/index.ts +1 -8
  185. package/src/test-data/specs.ts +6 -6
  186. package/src/test-utils/redux.tsx +15 -4
  187. package/src/utils/adaptorUtils.ts +181 -0
  188. package/src/utils/apixAdaptor.ts +72 -0
  189. package/src/utils/index.ts +3 -7
  190. package/src/utils/path.ts +25 -2
  191. package/lib/esm/reducers/index.js +0 -2
  192. package/lib/esm/reducers/index.js.map +0 -1
  193. package/lib/esm/reducers/spec/actions.js +0 -19
  194. package/lib/esm/reducers/spec/actions.js.map +0 -1
  195. package/lib/esm/reducers/spec/index.js +0 -4
  196. package/lib/esm/reducers/spec/index.js.map +0 -1
  197. package/lib/esm/reducers/spec/reducer.js +0 -62
  198. package/lib/esm/reducers/spec/reducer.js.map +0 -1
  199. package/lib/esm/reducers/spec/utils.js +0 -74
  200. package/lib/esm/reducers/spec/utils.js.map +0 -1
  201. package/lib/reducers/index.d.ts +0 -1
  202. package/lib/reducers/index.js +0 -19
  203. package/lib/reducers/index.js.map +0 -1
  204. package/lib/reducers/spec/actions.d.ts +0 -20
  205. package/lib/reducers/spec/actions.js +0 -31
  206. package/lib/reducers/spec/actions.js.map +0 -1
  207. package/lib/reducers/spec/index.d.ts +0 -3
  208. package/lib/reducers/spec/index.js +0 -45
  209. package/lib/reducers/spec/index.js.map +0 -1
  210. package/lib/reducers/spec/reducer.d.ts +0 -7
  211. package/lib/reducers/spec/reducer.js +0 -73
  212. package/lib/reducers/spec/reducer.js.map +0 -1
  213. package/lib/reducers/spec/utils.d.ts +0 -7
  214. package/lib/reducers/spec/utils.js +0 -91
  215. package/lib/reducers/spec/utils.js.map +0 -1
  216. package/src/reducers/spec/actions.ts +0 -62
  217. package/src/reducers/spec/reducer.spec.ts +0 -44
  218. package/src/reducers/spec/reducer.ts +0 -69
  219. package/src/reducers/spec/utils.spec.ts +0 -138
  220. package/src/reducers/spec/utils.ts +0 -123
@@ -1,62 +0,0 @@
1
- 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; }
2
-
3
- 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; }
4
-
5
- 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; }
6
-
7
- import { ApiModel } from '@looker/sdk-codegen';
8
- import { Actions } from '.';
9
- export var specReducer = (state, action) => {
10
- var {
11
- type,
12
- payload
13
- } = action;
14
-
15
- switch (type) {
16
- case Actions.UPDATE_SPEC_API:
17
- {
18
- var specList = _objectSpread({}, state.specList);
19
-
20
- var {
21
- specKey,
22
- api
23
- } = payload;
24
- var spec = specList[specKey];
25
-
26
- if (spec) {
27
- spec = _objectSpread(_objectSpread({}, spec), {}, {
28
- api
29
- });
30
- specList[specKey] = spec;
31
- }
32
-
33
- return {
34
- specList,
35
- spec
36
- };
37
- }
38
-
39
- case 'SELECT_SPEC':
40
- {
41
- var newState = _objectSpread({}, state);
42
-
43
- var _spec = newState.specList[payload];
44
-
45
- if (_spec) {
46
- if (!_spec.api && _spec.specContent) {
47
- _spec.api = ApiModel.fromJson(_spec.specContent);
48
- }
49
-
50
- return _objectSpread(_objectSpread({}, state), {}, {
51
- spec: _spec
52
- });
53
- }
54
-
55
- return state;
56
- }
57
-
58
- default:
59
- return state;
60
- }
61
- };
62
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/reducers/spec/reducer.ts"],"names":["ApiModel","Actions","specReducer","state","action","type","payload","UPDATE_SPEC_API","specList","specKey","api","spec","newState","specContent","fromJson"],"mappings":";;;;;;AA2BA,SAASA,QAAT,QAAyB,qBAAzB;AAGA,SAASC,OAAT,QAAwB,GAAxB;AAOA,OAAO,IAAMC,WAAW,GAAG,CACzBC,KADyB,EAEzBC,MAFyB,KAGX;AACd,MAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAoBF,MAA1B;;AACA,UAAQC,IAAR;AACE,SAAKJ,OAAO,CAACM,eAAb;AAA8B;AAC5B,YAAMC,QAAQ,qBAAQL,KAAK,CAACK,QAAd,CAAd;;AACA,YAAM;AAAEC,UAAAA,OAAF;AAAWC,UAAAA;AAAX,YAAmBJ,OAAzB;AACA,YAAIK,IAAI,GAAGH,QAAQ,CAACC,OAAD,CAAnB;;AACA,YAAIE,IAAJ,EAAU;AACRA,UAAAA,IAAI,mCAAQA,IAAR;AAAcD,YAAAA;AAAd,YAAJ;AACAF,UAAAA,QAAQ,CAACC,OAAD,CAAR,GAAoBE,IAApB;AACD;;AACD,eAAO;AAAEH,UAAAA,QAAF;AAAYG,UAAAA;AAAZ,SAAP;AACD;;AACD,SAAK,aAAL;AAAoB;AAClB,YAAMC,QAAQ,qBAAQT,KAAR,CAAd;;AACA,YAAMQ,KAAI,GAAGC,QAAQ,CAACJ,QAAT,CAAkBF,OAAlB,CAAb;;AAEA,YAAIK,KAAJ,EAAU;AACR,cAAI,CAACA,KAAI,CAACD,GAAN,IAAaC,KAAI,CAACE,WAAtB,EAAmC;AACjCF,YAAAA,KAAI,CAACD,GAAL,GAAWV,QAAQ,CAACc,QAAT,CAAkBH,KAAI,CAACE,WAAvB,CAAX;AACD;;AACD,iDAAYV,KAAZ;AAAmBQ,YAAAA,IAAI,EAAJA;AAAnB;AACD;;AACD,eAAOR,KAAP;AACD;;AACD;AACE,aAAOA,KAAP;AAxBJ;AA0BD,CA/BM","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 { SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { ApiModel } from '@looker/sdk-codegen'\nimport type { ApiUpdatePayload } from './actions'\nimport type { SpecAction } from '.'\nimport { Actions } from '.'\n\nexport interface SpecState {\n specList: SpecList\n spec: SpecItem\n}\n\nexport const specReducer = (\n state: SpecState,\n action: SpecAction\n): SpecState => {\n const { type, payload } = action\n switch (type) {\n case Actions.UPDATE_SPEC_API: {\n const specList = { ...state.specList }\n const { specKey, api } = payload as ApiUpdatePayload\n let spec = specList[specKey]\n if (spec) {\n spec = { ...spec, api }\n specList[specKey] = spec\n }\n return { specList, spec }\n }\n case 'SELECT_SPEC': {\n const newState = { ...state }\n const spec = newState.specList[payload as string]\n // Does extension API Explorer needs this?\n if (spec) {\n if (!spec.api && spec.specContent) {\n spec.api = ApiModel.fromJson(spec.specContent)\n }\n return { ...state, spec }\n }\n return state\n }\n default:\n return state\n }\n}\n"],"file":"reducer.js"}
@@ -1,74 +0,0 @@
1
- import { OAuthSession } from '@looker/sdk-rtl';
2
- import { diffPath, oAuthPath } from '../../utils';
3
- export var getDefaultSpecKey = specs => {
4
- var items = Object.entries(specs);
5
-
6
- if (items.length === 0) {
7
- throw Error('No specs found.');
8
- }
9
-
10
- var specKey = '';
11
- items.forEach(_ref => {
12
- var [key, item] = _ref;
13
-
14
- if (item.isDefault) {
15
- specKey = key;
16
- }
17
- });
18
-
19
- if (!specKey) {
20
- items.forEach(_ref2 => {
21
- var [key, item] = _ref2;
22
-
23
- if (item.status === 'current') {
24
- specKey = key;
25
- }
26
- });
27
- }
28
-
29
- if (!specKey) {
30
- specKey = Object.keys(specs)[0];
31
- }
32
-
33
- if (!specKey) {
34
- throw Error('No specs found.');
35
- }
36
-
37
- return specKey;
38
- };
39
- export var getSpecKey = (location, specs) => {
40
- var pathName = location.pathname;
41
-
42
- if (pathName === "/".concat(oAuthPath)) {
43
- var returnUrl = sessionStorage.getItem(OAuthSession.returnUrlKey);
44
-
45
- if (returnUrl) {
46
- pathName = returnUrl;
47
- }
48
- }
49
-
50
- var pathNodes = pathName.split('/');
51
- var specKey = '';
52
-
53
- if (pathNodes.length > 1 && pathNodes[1] && pathNodes[1] !== oAuthPath && pathNodes[1] !== diffPath) {
54
- specKey = pathNodes[1];
55
- } else if (specs) {
56
- specKey = getDefaultSpecKey(specs);
57
- }
58
-
59
- return specKey;
60
- };
61
- export var initDefaultSpecState = (specList, location) => {
62
- var specKey = getSpecKey(location, specList);
63
- var spec = specList[specKey];
64
-
65
- if (!spec) {
66
- spec = specList['4.0'];
67
- }
68
-
69
- return {
70
- specList,
71
- spec
72
- };
73
- };
74
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/reducers/spec/utils.ts"],"names":["OAuthSession","diffPath","oAuthPath","getDefaultSpecKey","specs","items","Object","entries","length","Error","specKey","forEach","key","item","isDefault","status","keys","getSpecKey","location","pathName","pathname","returnUrl","sessionStorage","getItem","returnUrlKey","pathNodes","split","initDefaultSpecState","specList","spec"],"mappings":"AA4BA,SAASA,YAAT,QAA6B,iBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,aAApC;AAWA,OAAO,IAAMC,iBAAiB,GAAIC,KAAD,IAA6B;AAC5D,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAP,CAAeH,KAAf,CAAd;;AAEA,MAAIC,KAAK,CAACG,MAAN,KAAiB,CAArB,EAAwB;AACtB,UAAMC,KAAK,CAAC,iBAAD,CAAX;AACD;;AAED,MAAIC,OAAO,GAAG,EAAd;AACAL,EAAAA,KAAK,CAACM,OAAN,CAAc,QAAiB;AAAA,QAAhB,CAACC,GAAD,EAAMC,IAAN,CAAgB;;AAC7B,QAAIA,IAAI,CAACC,SAAT,EAAoB;AAClBJ,MAAAA,OAAO,GAAGE,GAAV;AACD;AACF,GAJD;;AAMA,MAAI,CAACF,OAAL,EAAc;AACZL,IAAAA,KAAK,CAACM,OAAN,CAAc,SAAiB;AAAA,UAAhB,CAACC,GAAD,EAAMC,IAAN,CAAgB;;AAC7B,UAAIA,IAAI,CAACE,MAAL,KAAgB,SAApB,EAA+B;AAC7BL,QAAAA,OAAO,GAAGE,GAAV;AACD;AACF,KAJD;AAKD;;AAED,MAAI,CAACF,OAAL,EAAc;AACZA,IAAAA,OAAO,GAAGJ,MAAM,CAACU,IAAP,CAAYZ,KAAZ,EAAmB,CAAnB,CAAV;AACD;;AAED,MAAI,CAACM,OAAL,EAAc;AACZ,UAAMD,KAAK,CAAC,iBAAD,CAAX;AACD;;AAED,SAAOC,OAAP;AACD,CA/BM;AAsCP,OAAO,IAAMO,UAAU,GAAG,CAACC,QAAD,EAA6Bd,KAA7B,KAAkD;AAC1E,MAAIe,QAAQ,GAAGD,QAAQ,CAACE,QAAxB;;AACA,MAAID,QAAQ,gBAASjB,SAAT,CAAZ,EAAkC;AAChC,QAAMmB,SAAS,GAAGC,cAAc,CAACC,OAAf,CAAuBvB,YAAY,CAACwB,YAApC,CAAlB;;AACA,QAAIH,SAAJ,EAAe;AACbF,MAAAA,QAAQ,GAAGE,SAAX;AACD;AACF;;AACD,MAAMI,SAAS,GAAGN,QAAQ,CAACO,KAAT,CAAe,GAAf,CAAlB;AACA,MAAIhB,OAAO,GAAG,EAAd;;AACA,MACEe,SAAS,CAACjB,MAAV,GAAmB,CAAnB,IACAiB,SAAS,CAAC,CAAD,CADT,IAEAA,SAAS,CAAC,CAAD,CAAT,KAAiBvB,SAFjB,IAGAuB,SAAS,CAAC,CAAD,CAAT,KAAiBxB,QAJnB,EAKE;AACAS,IAAAA,OAAO,GAAGe,SAAS,CAAC,CAAD,CAAnB;AACD,GAPD,MAOO,IAAIrB,KAAJ,EAAW;AAChBM,IAAAA,OAAO,GAAGP,iBAAiB,CAACC,KAAD,CAA3B;AACD;;AACD,SAAOM,OAAP;AACD,CArBM;AA8BP,OAAO,IAAMiB,oBAAoB,GAAG,CAClCC,QADkC,EAElCV,QAFkC,KAGpB;AACd,MAAMR,OAAO,GAAGO,UAAU,CAACC,QAAD,EAAWU,QAAX,CAA1B;AAEA,MAAIC,IAAI,GAAGD,QAAQ,CAAClB,OAAD,CAAnB;;AACA,MAAI,CAACmB,IAAL,EAAW;AACTA,IAAAA,IAAI,GAAGD,QAAQ,CAAC,KAAD,CAAf;AACD;;AACD,SAAO;AACLA,IAAAA,QADK;AAELC,IAAAA;AAFK,GAAP;AAID,CAdM","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 { SpecList } from '@looker/sdk-codegen'\nimport type { Location as HLocation } from 'history'\nimport { OAuthSession } from '@looker/sdk-rtl'\nimport { diffPath, oAuthPath } from '../../utils'\nimport type { SpecState } from './reducer'\n\nexport type AbstractLocation = HLocation | Location\n\n/**\n * Given a collection of specs, it returns the spec marked as default, the one\n * marked as current or the first one, in that order.\n * @param specs A collection of specs\n * @returns A spec\n */\nexport const getDefaultSpecKey = (specs: SpecList): string => {\n const items = Object.entries(specs)\n\n if (items.length === 0) {\n throw Error('No specs found.')\n }\n\n let specKey = ''\n items.forEach(([key, item]) => {\n if (item.isDefault) {\n specKey = key\n }\n })\n\n if (!specKey) {\n items.forEach(([key, item]) => {\n if (item.status === 'current') {\n specKey = key\n }\n })\n }\n\n if (!specKey) {\n specKey = Object.keys(specs)[0]\n }\n\n if (!specKey) {\n throw Error('No specs found.')\n }\n\n return specKey\n}\n\n/**\n * Determine the API specification key from URL pattern or default spec\n * @param location service to examine\n * @param specs to use to find the default spec key\n */\nexport const getSpecKey = (location: AbstractLocation, specs?: SpecList) => {\n let pathName = location.pathname\n if (pathName === `/${oAuthPath}`) {\n const returnUrl = sessionStorage.getItem(OAuthSession.returnUrlKey)\n if (returnUrl) {\n pathName = returnUrl\n }\n }\n const pathNodes = pathName.split('/')\n let specKey = ''\n if (\n pathNodes.length > 1 &&\n pathNodes[1] &&\n pathNodes[1] !== oAuthPath &&\n pathNodes[1] !== diffPath\n ) {\n specKey = pathNodes[1]\n } else if (specs) {\n specKey = getDefaultSpecKey(specs)\n }\n return specKey\n}\n\n/**\n * Creates a default state object with the spec matching the specKey defined\n * in the url or the default criteria in getDefaultSpecKey\n * @param specList A collection of specs\n * @param location Standalone or extension location\n * @returns An object to be used as default state\n */\nexport const initDefaultSpecState = (\n specList: SpecList,\n location: AbstractLocation\n): SpecState => {\n const specKey = getSpecKey(location, specList)\n // Handle bad spec in the URL. Fall back to 4.0\n let spec = specList[specKey]\n if (!spec) {\n spec = specList['4.0']\n }\n return {\n specList,\n spec,\n }\n}\n"],"file":"utils.js"}
@@ -1 +0,0 @@
1
- export * from './spec';
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _spec = require("./spec");
8
-
9
- Object.keys(_spec).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _spec[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function get() {
15
- return _spec[key];
16
- }
17
- });
18
- });
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/reducers/index.ts"],"names":[],"mappings":";;;;;;AAyBA;;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 * from './spec'\n"],"file":"index.js"}
@@ -1,20 +0,0 @@
1
- import type { ApiModel } from '@looker/sdk-codegen';
2
- export declare enum Actions {
3
- SELECT_SPEC = "SELECT_SPEC",
4
- UPDATE_SPEC_API = "UPDATE_SPEC_API"
5
- }
6
- export interface ApiUpdatePayload {
7
- specKey: string;
8
- api: ApiModel;
9
- }
10
- export interface UpdateSpecApiAction {
11
- type: Actions.UPDATE_SPEC_API;
12
- payload: ApiUpdatePayload;
13
- }
14
- export interface SelectSpecAction {
15
- type: Actions.SELECT_SPEC;
16
- payload: string;
17
- }
18
- export declare type SpecAction = SelectSpecAction | UpdateSpecApiAction;
19
- export declare const selectSpec: (specKey: string) => SelectSpecAction;
20
- export declare const updateSpecApi: (specKey: string, api: ApiModel) => UpdateSpecApiAction;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.updateSpecApi = exports.selectSpec = exports.Actions = void 0;
7
- var Actions;
8
- exports.Actions = Actions;
9
-
10
- (function (Actions) {
11
- Actions["SELECT_SPEC"] = "SELECT_SPEC";
12
- Actions["UPDATE_SPEC_API"] = "UPDATE_SPEC_API";
13
- })(Actions || (exports.Actions = Actions = {}));
14
-
15
- var selectSpec = specKey => ({
16
- type: Actions.SELECT_SPEC,
17
- payload: specKey
18
- });
19
-
20
- exports.selectSpec = selectSpec;
21
-
22
- var updateSpecApi = (specKey, api) => ({
23
- type: Actions.UPDATE_SPEC_API,
24
- payload: {
25
- specKey,
26
- api
27
- }
28
- });
29
-
30
- exports.updateSpecApi = updateSpecApi;
31
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/reducers/spec/actions.ts"],"names":["Actions","selectSpec","specKey","type","SELECT_SPEC","payload","updateSpecApi","api","UPDATE_SPEC_API"],"mappings":";;;;;;IA4BYA,O;;;WAAAA,O;AAAAA,EAAAA,O;AAAAA,EAAAA,O;GAAAA,O,uBAAAA,O;;AAsBL,IAAMC,UAAU,GAAIC,OAAD,KAAwC;AAChEC,EAAAA,IAAI,EAAEH,OAAO,CAACI,WADkD;AAEhEC,EAAAA,OAAO,EAAEH;AAFuD,CAAxC,CAAnB;;;;AAKA,IAAMI,aAAa,GAAG,CAC3BJ,OAD2B,EAE3BK,GAF2B,MAGF;AACzBJ,EAAAA,IAAI,EAAEH,OAAO,CAACQ,eADW;AAEzBH,EAAAA,OAAO,EAAE;AAAEH,IAAAA,OAAF;AAAWK,IAAAA;AAAX;AAFgB,CAHE,CAAtB","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 } from '@looker/sdk-codegen'\n\nexport enum Actions {\n SELECT_SPEC = 'SELECT_SPEC',\n UPDATE_SPEC_API = 'UPDATE_SPEC_API',\n}\n\nexport interface ApiUpdatePayload {\n specKey: string\n api: ApiModel\n}\n\nexport interface UpdateSpecApiAction {\n type: Actions.UPDATE_SPEC_API\n payload: ApiUpdatePayload\n}\n\nexport interface SelectSpecAction {\n type: Actions.SELECT_SPEC\n payload: string\n}\n\nexport type SpecAction = SelectSpecAction | UpdateSpecApiAction\n\nexport const selectSpec = (specKey: string): SelectSpecAction => ({\n type: Actions.SELECT_SPEC,\n payload: specKey,\n})\n\nexport const updateSpecApi = (\n specKey: string,\n api: ApiModel\n): UpdateSpecApiAction => ({\n type: Actions.UPDATE_SPEC_API,\n payload: { specKey, api },\n})\n"],"file":"actions.js"}
@@ -1,3 +0,0 @@
1
- export * from './utils';
2
- export * from './actions';
3
- export * from './reducer';
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _utils = require("./utils");
8
-
9
- Object.keys(_utils).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _utils[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function get() {
15
- return _utils[key];
16
- }
17
- });
18
- });
19
-
20
- var _actions = require("./actions");
21
-
22
- Object.keys(_actions).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _actions[key]) return;
25
- Object.defineProperty(exports, key, {
26
- enumerable: true,
27
- get: function get() {
28
- return _actions[key];
29
- }
30
- });
31
- });
32
-
33
- var _reducer = require("./reducer");
34
-
35
- Object.keys(_reducer).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _reducer[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function get() {
41
- return _reducer[key];
42
- }
43
- });
44
- });
45
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/reducers/spec/index.ts"],"names":[],"mappings":";;;;;;AAyBA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;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 * from './utils'\nexport * from './actions'\nexport * from './reducer'\n"],"file":"index.js"}
@@ -1,7 +0,0 @@
1
- import type { SpecItem, SpecList } from '@looker/sdk-codegen';
2
- import type { SpecAction } from '.';
3
- export interface SpecState {
4
- specList: SpecList;
5
- spec: SpecItem;
6
- }
7
- export declare const specReducer: (state: SpecState, action: SpecAction) => SpecState;
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.specReducer = void 0;
7
-
8
- var _sdkCodegen = require("@looker/sdk-codegen");
9
-
10
- var _ = require(".");
11
-
12
- 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; }
13
-
14
- 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; }
15
-
16
- 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; }
17
-
18
- var specReducer = (state, action) => {
19
- var {
20
- type,
21
- payload
22
- } = action;
23
-
24
- switch (type) {
25
- case _.Actions.UPDATE_SPEC_API:
26
- {
27
- var specList = _objectSpread({}, state.specList);
28
-
29
- var {
30
- specKey,
31
- api
32
- } = payload;
33
- var spec = specList[specKey];
34
-
35
- if (spec) {
36
- spec = _objectSpread(_objectSpread({}, spec), {}, {
37
- api
38
- });
39
- specList[specKey] = spec;
40
- }
41
-
42
- return {
43
- specList,
44
- spec
45
- };
46
- }
47
-
48
- case 'SELECT_SPEC':
49
- {
50
- var newState = _objectSpread({}, state);
51
-
52
- var _spec = newState.specList[payload];
53
-
54
- if (_spec) {
55
- if (!_spec.api && _spec.specContent) {
56
- _spec.api = _sdkCodegen.ApiModel.fromJson(_spec.specContent);
57
- }
58
-
59
- return _objectSpread(_objectSpread({}, state), {}, {
60
- spec: _spec
61
- });
62
- }
63
-
64
- return state;
65
- }
66
-
67
- default:
68
- return state;
69
- }
70
- };
71
-
72
- exports.specReducer = specReducer;
73
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/reducers/spec/reducer.ts"],"names":["specReducer","state","action","type","payload","Actions","UPDATE_SPEC_API","specList","specKey","api","spec","newState","specContent","ApiModel","fromJson"],"mappings":";;;;;;;AA2BA;;AAGA;;;;;;;;AAOO,IAAMA,WAAW,GAAG,CACzBC,KADyB,EAEzBC,MAFyB,KAGX;AACd,MAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAoBF,MAA1B;;AACA,UAAQC,IAAR;AACE,SAAKE,UAAQC,eAAb;AAA8B;AAC5B,YAAMC,QAAQ,qBAAQN,KAAK,CAACM,QAAd,CAAd;;AACA,YAAM;AAAEC,UAAAA,OAAF;AAAWC,UAAAA;AAAX,YAAmBL,OAAzB;AACA,YAAIM,IAAI,GAAGH,QAAQ,CAACC,OAAD,CAAnB;;AACA,YAAIE,IAAJ,EAAU;AACRA,UAAAA,IAAI,mCAAQA,IAAR;AAAcD,YAAAA;AAAd,YAAJ;AACAF,UAAAA,QAAQ,CAACC,OAAD,CAAR,GAAoBE,IAApB;AACD;;AACD,eAAO;AAAEH,UAAAA,QAAF;AAAYG,UAAAA;AAAZ,SAAP;AACD;;AACD,SAAK,aAAL;AAAoB;AAClB,YAAMC,QAAQ,qBAAQV,KAAR,CAAd;;AACA,YAAMS,KAAI,GAAGC,QAAQ,CAACJ,QAAT,CAAkBH,OAAlB,CAAb;;AAEA,YAAIM,KAAJ,EAAU;AACR,cAAI,CAACA,KAAI,CAACD,GAAN,IAAaC,KAAI,CAACE,WAAtB,EAAmC;AACjCF,YAAAA,KAAI,CAACD,GAAL,GAAWI,qBAASC,QAAT,CAAkBJ,KAAI,CAACE,WAAvB,CAAX;AACD;;AACD,iDAAYX,KAAZ;AAAmBS,YAAAA,IAAI,EAAJA;AAAnB;AACD;;AACD,eAAOT,KAAP;AACD;;AACD;AACE,aAAOA,KAAP;AAxBJ;AA0BD,CA/BM","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 { SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { ApiModel } from '@looker/sdk-codegen'\nimport type { ApiUpdatePayload } from './actions'\nimport type { SpecAction } from '.'\nimport { Actions } from '.'\n\nexport interface SpecState {\n specList: SpecList\n spec: SpecItem\n}\n\nexport const specReducer = (\n state: SpecState,\n action: SpecAction\n): SpecState => {\n const { type, payload } = action\n switch (type) {\n case Actions.UPDATE_SPEC_API: {\n const specList = { ...state.specList }\n const { specKey, api } = payload as ApiUpdatePayload\n let spec = specList[specKey]\n if (spec) {\n spec = { ...spec, api }\n specList[specKey] = spec\n }\n return { specList, spec }\n }\n case 'SELECT_SPEC': {\n const newState = { ...state }\n const spec = newState.specList[payload as string]\n // Does extension API Explorer needs this?\n if (spec) {\n if (!spec.api && spec.specContent) {\n spec.api = ApiModel.fromJson(spec.specContent)\n }\n return { ...state, spec }\n }\n return state\n }\n default:\n return state\n }\n}\n"],"file":"reducer.js"}
@@ -1,7 +0,0 @@
1
- import type { SpecList } from '@looker/sdk-codegen';
2
- import type { Location as HLocation } from 'history';
3
- import type { SpecState } from './reducer';
4
- export declare type AbstractLocation = HLocation | Location;
5
- export declare const getDefaultSpecKey: (specs: SpecList) => string;
6
- export declare const getSpecKey: (location: AbstractLocation, specs?: SpecList | undefined) => string;
7
- export declare const initDefaultSpecState: (specList: SpecList, location: AbstractLocation) => SpecState;
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.initDefaultSpecState = exports.getSpecKey = exports.getDefaultSpecKey = void 0;
7
-
8
- var _sdkRtl = require("@looker/sdk-rtl");
9
-
10
- var _utils = require("../../utils");
11
-
12
- var getDefaultSpecKey = specs => {
13
- var items = Object.entries(specs);
14
-
15
- if (items.length === 0) {
16
- throw Error('No specs found.');
17
- }
18
-
19
- var specKey = '';
20
- items.forEach(_ref => {
21
- var [key, item] = _ref;
22
-
23
- if (item.isDefault) {
24
- specKey = key;
25
- }
26
- });
27
-
28
- if (!specKey) {
29
- items.forEach(_ref2 => {
30
- var [key, item] = _ref2;
31
-
32
- if (item.status === 'current') {
33
- specKey = key;
34
- }
35
- });
36
- }
37
-
38
- if (!specKey) {
39
- specKey = Object.keys(specs)[0];
40
- }
41
-
42
- if (!specKey) {
43
- throw Error('No specs found.');
44
- }
45
-
46
- return specKey;
47
- };
48
-
49
- exports.getDefaultSpecKey = getDefaultSpecKey;
50
-
51
- var getSpecKey = (location, specs) => {
52
- var pathName = location.pathname;
53
-
54
- if (pathName === "/".concat(_utils.oAuthPath)) {
55
- var returnUrl = sessionStorage.getItem(_sdkRtl.OAuthSession.returnUrlKey);
56
-
57
- if (returnUrl) {
58
- pathName = returnUrl;
59
- }
60
- }
61
-
62
- var pathNodes = pathName.split('/');
63
- var specKey = '';
64
-
65
- if (pathNodes.length > 1 && pathNodes[1] && pathNodes[1] !== _utils.oAuthPath && pathNodes[1] !== _utils.diffPath) {
66
- specKey = pathNodes[1];
67
- } else if (specs) {
68
- specKey = getDefaultSpecKey(specs);
69
- }
70
-
71
- return specKey;
72
- };
73
-
74
- exports.getSpecKey = getSpecKey;
75
-
76
- var initDefaultSpecState = (specList, location) => {
77
- var specKey = getSpecKey(location, specList);
78
- var spec = specList[specKey];
79
-
80
- if (!spec) {
81
- spec = specList['4.0'];
82
- }
83
-
84
- return {
85
- specList,
86
- spec
87
- };
88
- };
89
-
90
- exports.initDefaultSpecState = initDefaultSpecState;
91
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/reducers/spec/utils.ts"],"names":["getDefaultSpecKey","specs","items","Object","entries","length","Error","specKey","forEach","key","item","isDefault","status","keys","getSpecKey","location","pathName","pathname","oAuthPath","returnUrl","sessionStorage","getItem","OAuthSession","returnUrlKey","pathNodes","split","diffPath","initDefaultSpecState","specList","spec"],"mappings":";;;;;;;AA4BA;;AACA;;AAWO,IAAMA,iBAAiB,GAAIC,KAAD,IAA6B;AAC5D,MAAMC,KAAK,GAAGC,MAAM,CAACC,OAAP,CAAeH,KAAf,CAAd;;AAEA,MAAIC,KAAK,CAACG,MAAN,KAAiB,CAArB,EAAwB;AACtB,UAAMC,KAAK,CAAC,iBAAD,CAAX;AACD;;AAED,MAAIC,OAAO,GAAG,EAAd;AACAL,EAAAA,KAAK,CAACM,OAAN,CAAc,QAAiB;AAAA,QAAhB,CAACC,GAAD,EAAMC,IAAN,CAAgB;;AAC7B,QAAIA,IAAI,CAACC,SAAT,EAAoB;AAClBJ,MAAAA,OAAO,GAAGE,GAAV;AACD;AACF,GAJD;;AAMA,MAAI,CAACF,OAAL,EAAc;AACZL,IAAAA,KAAK,CAACM,OAAN,CAAc,SAAiB;AAAA,UAAhB,CAACC,GAAD,EAAMC,IAAN,CAAgB;;AAC7B,UAAIA,IAAI,CAACE,MAAL,KAAgB,SAApB,EAA+B;AAC7BL,QAAAA,OAAO,GAAGE,GAAV;AACD;AACF,KAJD;AAKD;;AAED,MAAI,CAACF,OAAL,EAAc;AACZA,IAAAA,OAAO,GAAGJ,MAAM,CAACU,IAAP,CAAYZ,KAAZ,EAAmB,CAAnB,CAAV;AACD;;AAED,MAAI,CAACM,OAAL,EAAc;AACZ,UAAMD,KAAK,CAAC,iBAAD,CAAX;AACD;;AAED,SAAOC,OAAP;AACD,CA/BM;;;;AAsCA,IAAMO,UAAU,GAAG,CAACC,QAAD,EAA6Bd,KAA7B,KAAkD;AAC1E,MAAIe,QAAQ,GAAGD,QAAQ,CAACE,QAAxB;;AACA,MAAID,QAAQ,gBAASE,gBAAT,CAAZ,EAAkC;AAChC,QAAMC,SAAS,GAAGC,cAAc,CAACC,OAAf,CAAuBC,qBAAaC,YAApC,CAAlB;;AACA,QAAIJ,SAAJ,EAAe;AACbH,MAAAA,QAAQ,GAAGG,SAAX;AACD;AACF;;AACD,MAAMK,SAAS,GAAGR,QAAQ,CAACS,KAAT,CAAe,GAAf,CAAlB;AACA,MAAIlB,OAAO,GAAG,EAAd;;AACA,MACEiB,SAAS,CAACnB,MAAV,GAAmB,CAAnB,IACAmB,SAAS,CAAC,CAAD,CADT,IAEAA,SAAS,CAAC,CAAD,CAAT,KAAiBN,gBAFjB,IAGAM,SAAS,CAAC,CAAD,CAAT,KAAiBE,eAJnB,EAKE;AACAnB,IAAAA,OAAO,GAAGiB,SAAS,CAAC,CAAD,CAAnB;AACD,GAPD,MAOO,IAAIvB,KAAJ,EAAW;AAChBM,IAAAA,OAAO,GAAGP,iBAAiB,CAACC,KAAD,CAA3B;AACD;;AACD,SAAOM,OAAP;AACD,CArBM;;;;AA8BA,IAAMoB,oBAAoB,GAAG,CAClCC,QADkC,EAElCb,QAFkC,KAGpB;AACd,MAAMR,OAAO,GAAGO,UAAU,CAACC,QAAD,EAAWa,QAAX,CAA1B;AAEA,MAAIC,IAAI,GAAGD,QAAQ,CAACrB,OAAD,CAAnB;;AACA,MAAI,CAACsB,IAAL,EAAW;AACTA,IAAAA,IAAI,GAAGD,QAAQ,CAAC,KAAD,CAAf;AACD;;AACD,SAAO;AACLA,IAAAA,QADK;AAELC,IAAAA;AAFK,GAAP;AAID,CAdM","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 { SpecList } from '@looker/sdk-codegen'\nimport type { Location as HLocation } from 'history'\nimport { OAuthSession } from '@looker/sdk-rtl'\nimport { diffPath, oAuthPath } from '../../utils'\nimport type { SpecState } from './reducer'\n\nexport type AbstractLocation = HLocation | Location\n\n/**\n * Given a collection of specs, it returns the spec marked as default, the one\n * marked as current or the first one, in that order.\n * @param specs A collection of specs\n * @returns A spec\n */\nexport const getDefaultSpecKey = (specs: SpecList): string => {\n const items = Object.entries(specs)\n\n if (items.length === 0) {\n throw Error('No specs found.')\n }\n\n let specKey = ''\n items.forEach(([key, item]) => {\n if (item.isDefault) {\n specKey = key\n }\n })\n\n if (!specKey) {\n items.forEach(([key, item]) => {\n if (item.status === 'current') {\n specKey = key\n }\n })\n }\n\n if (!specKey) {\n specKey = Object.keys(specs)[0]\n }\n\n if (!specKey) {\n throw Error('No specs found.')\n }\n\n return specKey\n}\n\n/**\n * Determine the API specification key from URL pattern or default spec\n * @param location service to examine\n * @param specs to use to find the default spec key\n */\nexport const getSpecKey = (location: AbstractLocation, specs?: SpecList) => {\n let pathName = location.pathname\n if (pathName === `/${oAuthPath}`) {\n const returnUrl = sessionStorage.getItem(OAuthSession.returnUrlKey)\n if (returnUrl) {\n pathName = returnUrl\n }\n }\n const pathNodes = pathName.split('/')\n let specKey = ''\n if (\n pathNodes.length > 1 &&\n pathNodes[1] &&\n pathNodes[1] !== oAuthPath &&\n pathNodes[1] !== diffPath\n ) {\n specKey = pathNodes[1]\n } else if (specs) {\n specKey = getDefaultSpecKey(specs)\n }\n return specKey\n}\n\n/**\n * Creates a default state object with the spec matching the specKey defined\n * in the url or the default criteria in getDefaultSpecKey\n * @param specList A collection of specs\n * @param location Standalone or extension location\n * @returns An object to be used as default state\n */\nexport const initDefaultSpecState = (\n specList: SpecList,\n location: AbstractLocation\n): SpecState => {\n const specKey = getSpecKey(location, specList)\n // Handle bad spec in the URL. Fall back to 4.0\n let spec = specList[specKey]\n if (!spec) {\n spec = specList['4.0']\n }\n return {\n specList,\n spec,\n }\n}\n"],"file":"utils.js"}
@@ -1,62 +0,0 @@
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 type { ApiModel } from '@looker/sdk-codegen'
28
-
29
- export enum Actions {
30
- SELECT_SPEC = 'SELECT_SPEC',
31
- UPDATE_SPEC_API = 'UPDATE_SPEC_API',
32
- }
33
-
34
- export interface ApiUpdatePayload {
35
- specKey: string
36
- api: ApiModel
37
- }
38
-
39
- export interface UpdateSpecApiAction {
40
- type: Actions.UPDATE_SPEC_API
41
- payload: ApiUpdatePayload
42
- }
43
-
44
- export interface SelectSpecAction {
45
- type: Actions.SELECT_SPEC
46
- payload: string
47
- }
48
-
49
- export type SpecAction = SelectSpecAction | UpdateSpecApiAction
50
-
51
- export const selectSpec = (specKey: string): SelectSpecAction => ({
52
- type: Actions.SELECT_SPEC,
53
- payload: specKey,
54
- })
55
-
56
- export const updateSpecApi = (
57
- specKey: string,
58
- api: ApiModel
59
- ): UpdateSpecApiAction => ({
60
- type: Actions.UPDATE_SPEC_API,
61
- payload: { specKey, api },
62
- })
@@ -1,44 +0,0 @@
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
- import { ApiModel } from '@looker/sdk-codegen'
27
-
28
- import { specs } from '../../test-data'
29
- import type { SelectSpecAction } from '.'
30
- import { specReducer, initDefaultSpecState, Actions } from '.'
31
-
32
- describe('Spec Reducer', () => {
33
- test('it selects a spec', () => {
34
- const action: SelectSpecAction = {
35
- type: Actions.SELECT_SPEC,
36
- payload: '4.0',
37
- }
38
-
39
- const state = specReducer(initDefaultSpecState(specs, location), action)
40
- expect(state.spec.api).toBeInstanceOf(ApiModel)
41
- expect(state.spec.key).toEqual('4.0')
42
- expect(state.spec.status).toEqual(specs['4.0'].status)
43
- })
44
- })