@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.
- package/CHANGELOG.md +80 -1
- package/e2e/e2e.spec.ts +1 -1
- package/lib/ApiExplorer.d.ts +2 -6
- package/lib/ApiExplorer.js +53 -74
- package/lib/ApiExplorer.js.map +1 -1
- package/lib/StandaloneApiExplorer.js +35 -47
- package/lib/StandaloneApiExplorer.js.map +1 -1
- package/lib/components/Banner/Banner.d.ts +8 -0
- package/lib/components/Banner/Banner.js +70 -0
- package/lib/components/Banner/Banner.js.map +1 -0
- package/lib/components/Banner/index.d.ts +1 -0
- package/lib/components/Banner/index.js +14 -0
- package/lib/components/Banner/index.js.map +1 -0
- package/lib/components/DocPseudo/DocParam.js +3 -1
- package/lib/components/DocPseudo/DocParam.js.map +1 -1
- package/lib/components/DocSDKs/DocSDKs.js +3 -3
- package/lib/components/DocSDKs/DocSDKs.js.map +1 -1
- package/lib/components/ExploreType/ExploreType.js +3 -5
- package/lib/components/ExploreType/ExploreType.js.map +1 -1
- package/lib/components/Header/Header.d.ts +2 -5
- package/lib/components/Header/Header.js +1 -5
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/SelectorContainer/ApiSpecSelector.d.ts +2 -5
- package/lib/components/SelectorContainer/ApiSpecSelector.js +5 -5
- package/lib/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/components/SelectorContainer/SelectorContainer.d.ts +2 -5
- package/lib/components/SelectorContainer/SelectorContainer.js +3 -7
- package/lib/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/components/SideNav/SideNav.d.ts +2 -5
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +8 -0
- package/lib/components/index.js.map +1 -1
- package/lib/esm/ApiExplorer.js +54 -74
- package/lib/esm/ApiExplorer.js.map +1 -1
- package/lib/esm/StandaloneApiExplorer.js +34 -48
- package/lib/esm/StandaloneApiExplorer.js.map +1 -1
- package/lib/esm/components/Banner/Banner.js +54 -0
- package/lib/esm/components/Banner/Banner.js.map +1 -0
- package/lib/esm/components/Banner/index.js +2 -0
- package/lib/esm/components/Banner/index.js.map +1 -0
- package/lib/esm/components/DocPseudo/DocParam.js +2 -1
- package/lib/esm/components/DocPseudo/DocParam.js.map +1 -1
- package/lib/esm/components/DocSDKs/DocSDKs.js +2 -2
- package/lib/esm/components/DocSDKs/DocSDKs.js.map +1 -1
- package/lib/esm/components/ExploreType/ExploreType.js +3 -4
- package/lib/esm/components/ExploreType/ExploreType.js.map +1 -1
- package/lib/esm/components/Header/Header.js +1 -5
- package/lib/esm/components/Header/Header.js.map +1 -1
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js +4 -5
- package/lib/esm/components/SelectorContainer/ApiSpecSelector.js.map +1 -1
- package/lib/esm/components/SelectorContainer/SelectorContainer.js +3 -7
- package/lib/esm/components/SelectorContainer/SelectorContainer.js.map +1 -1
- package/lib/esm/components/SideNav/SideNav.js.map +1 -1
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/routes/AppRouter.js +3 -7
- package/lib/esm/routes/AppRouter.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DiffScene.js +43 -99
- package/lib/esm/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
- package/lib/esm/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
- package/lib/esm/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/esm/scenes/MethodScene/MethodScene.js +4 -5
- package/lib/esm/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/esm/state/index.js +1 -0
- package/lib/esm/state/index.js.map +1 -1
- package/lib/esm/state/specs/index.js +3 -0
- package/lib/esm/state/specs/index.js.map +1 -0
- package/lib/esm/state/specs/sagas.js +58 -0
- package/lib/esm/state/specs/sagas.js.map +1 -0
- package/lib/esm/state/specs/selectors.js +8 -0
- package/lib/esm/state/specs/selectors.js.map +1 -0
- package/lib/esm/state/specs/slice.js +55 -0
- package/lib/esm/state/specs/slice.js.map +1 -0
- package/lib/esm/state/store.js +53 -2
- package/lib/esm/state/store.js.map +1 -1
- package/lib/esm/test-utils/redux.js +9 -5
- package/lib/esm/test-utils/redux.js.map +1 -1
- package/lib/esm/utils/adaptorUtils.js +101 -0
- package/lib/esm/utils/adaptorUtils.js.map +1 -0
- package/lib/esm/utils/apixAdaptor.js +48 -0
- package/lib/esm/utils/apixAdaptor.js.map +1 -0
- package/lib/esm/utils/index.js +3 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/path.js +27 -2
- package/lib/esm/utils/path.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -1
- package/lib/routes/AppRouter.d.ts +1 -5
- package/lib/routes/AppRouter.js +3 -7
- package/lib/routes/AppRouter.js.map +1 -1
- package/lib/scenes/DiffScene/DiffScene.js +45 -100
- package/lib/scenes/DiffScene/DiffScene.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js +9 -13
- package/lib/scenes/DiffScene/DocDiff/DiffItem.js.map +1 -1
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js +2 -2
- package/lib/scenes/DiffScene/DocDiff/DocDiff.js.map +1 -1
- package/lib/scenes/MethodScene/MethodScene.d.ts +0 -4
- package/lib/scenes/MethodScene/MethodScene.js +5 -5
- package/lib/scenes/MethodScene/MethodScene.js.map +1 -1
- package/lib/state/index.d.ts +1 -0
- package/lib/state/index.js +13 -0
- package/lib/state/index.js.map +1 -1
- package/lib/state/settings/selectors.d.ts +1 -1
- package/lib/state/settings/slice.d.ts +1 -1
- package/lib/state/specs/index.d.ts +2 -0
- package/lib/state/specs/index.js +32 -0
- package/lib/state/specs/index.js.map +1 -0
- package/lib/state/specs/sagas.d.ts +1 -0
- package/lib/state/specs/sagas.js +67 -0
- package/lib/state/specs/sagas.js.map +1 -0
- package/lib/state/specs/selectors.d.ts +4 -0
- package/lib/state/specs/selectors.js +20 -0
- package/lib/state/specs/selectors.js.map +1 -0
- package/lib/state/specs/slice.d.ts +49 -0
- package/lib/state/specs/slice.js +70 -0
- package/lib/state/specs/slice.js.map +1 -0
- package/lib/state/store.d.ts +3 -0
- package/lib/state/store.js +56 -2
- package/lib/state/store.js.map +1 -1
- package/lib/test-data/declarations.d.ts +2 -0
- package/lib/test-data/examples.d.ts +2 -0
- package/lib/test-data/index.d.ts +3 -0
- package/lib/test-data/index.js +12 -42
- package/lib/test-data/index.js.map +1 -1
- package/lib/test-data/specs.d.ts +10 -0
- package/lib/test-data/specs.js +6 -6
- package/lib/test-data/specs.js.map +1 -1
- package/lib/test-utils/redux.d.ts +2 -1
- package/lib/test-utils/redux.js +9 -4
- package/lib/test-utils/redux.js.map +1 -1
- package/lib/utils/adaptorUtils.d.ts +30 -0
- package/lib/utils/adaptorUtils.js +124 -0
- package/lib/utils/adaptorUtils.js.map +1 -0
- package/lib/utils/apixAdaptor.d.ts +15 -0
- package/lib/utils/apixAdaptor.js +67 -0
- package/lib/utils/apixAdaptor.js.map +1 -0
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +45 -30
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/path.d.ts +3 -0
- package/lib/utils/path.js +32 -2
- package/lib/utils/path.js.map +1 -1
- package/package.json +10 -10
- package/src/ApiExplorer.tsx +47 -74
- package/src/StandaloneApiExplorer.tsx +37 -52
- package/src/components/Banner/Banner.spec.tsx +99 -0
- package/src/components/Banner/Banner.tsx +87 -0
- package/src/{reducers → components/Banner}/index.ts +1 -1
- package/src/components/DocPseudo/DocParam.spec.tsx +2 -1
- package/src/components/DocPseudo/DocParam.tsx +2 -1
- package/src/components/DocSDKs/DocSDKs.tsx +4 -5
- package/src/components/ExploreType/ExploreType.spec.tsx +0 -23
- package/src/components/ExploreType/ExploreType.tsx +5 -6
- package/src/components/ExploreType/exploreUtils.spec.tsx +1 -1
- package/src/components/Header/Header.spec.tsx +9 -30
- package/src/components/Header/Header.tsx +3 -10
- package/src/components/SelectorContainer/ApiSpecSelector.spec.tsx +31 -44
- package/src/components/SelectorContainer/ApiSpecSelector.tsx +6 -12
- package/src/components/SelectorContainer/SelectorContainer.spec.tsx +7 -26
- package/src/components/SelectorContainer/SelectorContainer.tsx +4 -10
- package/src/components/SideNav/SideNav.spec.tsx +12 -45
- package/src/components/SideNav/SideNav.tsx +1 -7
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/routes/AppRouter.tsx +25 -37
- package/src/scenes/DiffScene/DiffScene.tsx +47 -84
- package/src/scenes/DiffScene/DocDiff/DiffItem.spec.tsx +9 -16
- package/src/scenes/DiffScene/DocDiff/DiffItem.tsx +11 -12
- package/src/scenes/DiffScene/DocDiff/DocDiff.tsx +2 -2
- package/src/scenes/MethodScene/MethodScene.tsx +4 -10
- package/src/state/index.ts +1 -0
- package/src/{reducers/spec → state/specs}/index.ts +2 -3
- package/src/state/specs/sagas.spec.ts +135 -0
- package/src/state/specs/sagas.ts +81 -0
- package/src/{reducers/spec/actions.spec.ts → state/specs/selectors.ts} +12 -11
- package/src/state/specs/slice.ts +109 -0
- package/src/state/store.ts +58 -0
- package/src/test-data/index.ts +1 -8
- package/src/test-data/specs.ts +6 -6
- package/src/test-utils/redux.tsx +15 -4
- package/src/utils/adaptorUtils.ts +181 -0
- package/src/utils/apixAdaptor.ts +72 -0
- package/src/utils/index.ts +3 -7
- package/src/utils/path.ts +25 -2
- package/lib/esm/reducers/index.js +0 -2
- package/lib/esm/reducers/index.js.map +0 -1
- package/lib/esm/reducers/spec/actions.js +0 -19
- package/lib/esm/reducers/spec/actions.js.map +0 -1
- package/lib/esm/reducers/spec/index.js +0 -4
- package/lib/esm/reducers/spec/index.js.map +0 -1
- package/lib/esm/reducers/spec/reducer.js +0 -62
- package/lib/esm/reducers/spec/reducer.js.map +0 -1
- package/lib/esm/reducers/spec/utils.js +0 -74
- package/lib/esm/reducers/spec/utils.js.map +0 -1
- package/lib/reducers/index.d.ts +0 -1
- package/lib/reducers/index.js +0 -19
- package/lib/reducers/index.js.map +0 -1
- package/lib/reducers/spec/actions.d.ts +0 -20
- package/lib/reducers/spec/actions.js +0 -31
- package/lib/reducers/spec/actions.js.map +0 -1
- package/lib/reducers/spec/index.d.ts +0 -3
- package/lib/reducers/spec/index.js +0 -45
- package/lib/reducers/spec/index.js.map +0 -1
- package/lib/reducers/spec/reducer.d.ts +0 -7
- package/lib/reducers/spec/reducer.js +0 -73
- package/lib/reducers/spec/reducer.js.map +0 -1
- package/lib/reducers/spec/utils.d.ts +0 -7
- package/lib/reducers/spec/utils.js +0 -91
- package/lib/reducers/spec/utils.js.map +0 -1
- package/src/reducers/spec/actions.ts +0 -62
- package/src/reducers/spec/reducer.spec.ts +0 -44
- package/src/reducers/spec/reducer.ts +0 -69
- package/src/reducers/spec/utils.spec.ts +0 -138
- package/src/reducers/spec/utils.ts +0 -123
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ApixAdaptor = exports.getApixAdaptor = void 0;
|
|
7
|
+
|
|
8
|
+
var _extensionUtils = require("@looker/extension-utils");
|
|
9
|
+
|
|
10
|
+
var _sdkCodegen = require("@looker/sdk-codegen");
|
|
11
|
+
|
|
12
|
+
var _runIt = require("@looker/run-it");
|
|
13
|
+
|
|
14
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
15
|
+
|
|
16
|
+
var _adaptorUtils = require("./adaptorUtils");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
+
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
+
|
|
24
|
+
var getApixAdaptor = () => (0, _extensionUtils.getEnvAdaptor)();
|
|
25
|
+
|
|
26
|
+
exports.getApixAdaptor = getApixAdaptor;
|
|
27
|
+
|
|
28
|
+
class ApixAdaptor extends _extensionUtils.BrowserAdaptor {
|
|
29
|
+
constructor(sdk, fallbackVersionsUrl) {
|
|
30
|
+
super(sdk);
|
|
31
|
+
this.fallbackVersionsUrl = fallbackVersionsUrl;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fetchSpecList(versionsUrl) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
|
|
37
|
+
return _asyncToGenerator(function* () {
|
|
38
|
+
var data = yield _this.localStorageGetItem(_runIt.RunItConfigKey);
|
|
39
|
+
var config = data ? JSON.parse(data) : _runIt.RunItNoConfig;
|
|
40
|
+
var url;
|
|
41
|
+
|
|
42
|
+
if (versionsUrl) {
|
|
43
|
+
url = versionsUrl;
|
|
44
|
+
} else {
|
|
45
|
+
url = config.base_url ? "".concat(config.base_url, "/versions") : "".concat(_this.fallbackVersionsUrl, "/versions.json");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var versions = yield _this.sdk.authSession.transport.rawRequest('GET', url);
|
|
49
|
+
var specs = yield (0, _sdkCodegen.getSpecsFromVersions)(JSON.parse(versions.body));
|
|
50
|
+
return specs;
|
|
51
|
+
})();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fetchSpec(spec) {
|
|
55
|
+
return _asyncToGenerator(function* () {
|
|
56
|
+
var _spec = (0, _cloneDeep.default)(spec);
|
|
57
|
+
|
|
58
|
+
_spec.specURL = (0, _adaptorUtils.fullify)(spec.specURL, origin);
|
|
59
|
+
_spec.api = yield (0, _adaptorUtils.fallbackFetch)(_spec, _adaptorUtils.funFetch);
|
|
60
|
+
return _spec;
|
|
61
|
+
})();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.ApixAdaptor = ApixAdaptor;
|
|
67
|
+
//# sourceMappingURL=apixAdaptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/apixAdaptor.ts"],"names":["getApixAdaptor","ApixAdaptor","BrowserAdaptor","constructor","sdk","fallbackVersionsUrl","fetchSpecList","versionsUrl","data","localStorageGetItem","RunItConfigKey","config","JSON","parse","RunItNoConfig","url","base_url","versions","authSession","transport","rawRequest","specs","body","fetchSpec","spec","_spec","specURL","origin","api","funFetch"],"mappings":";;;;;;;AA0BA;;AAGA;;AACA;;AACA;;AAEA;;;;;;;;AAOO,IAAMA,cAAc,GAAG,MAAM,oCAA7B;;;;AAEA,MAAMC,WAAN,SAA0BC,8BAA1B,CAAiE;AACtEC,EAAAA,WAAW,CAACC,GAAD,EAAoCC,mBAApC,EAAiE;AAC1E,UAAMD,GAAN;AAD0E,SAA7BC,mBAA6B,GAA7BA,mBAA6B;AAE3E;;AAEKC,EAAAA,aAAa,CAACC,WAAD,EAA0C;AAAA;;AAAA;AAC3D,UAAMC,IAAI,SAAS,KAAI,CAACC,mBAAL,CAAyBC,qBAAzB,CAAnB;AACA,UAAMC,MAAM,GAAGH,IAAI,GAAGI,IAAI,CAACC,KAAL,CAAWL,IAAX,CAAH,GAAsBM,oBAAzC;AACA,UAAIC,GAAJ;;AAEA,UAAIR,WAAJ,EAAiB;AACfQ,QAAAA,GAAG,GAAGR,WAAN;AACD,OAFD,MAEO;AACLQ,QAAAA,GAAG,GAAGJ,MAAM,CAACK,QAAP,aACCL,MAAM,CAACK,QADR,2BAEC,KAAI,CAACX,mBAFN,mBAAN;AAGD;;AAED,UAAMY,QAAQ,SAAS,KAAI,CAACb,GAAL,CAASc,WAAT,CAAqBC,SAArB,CAA+BC,UAA/B,CAA0C,KAA1C,EAAiDL,GAAjD,CAAvB;AACA,UAAMM,KAAK,SAAS,sCAAqBT,IAAI,CAACC,KAAL,CAAWI,QAAQ,CAACK,IAApB,CAArB,CAApB;AACA,aAAOD,KAAP;AAf2D;AAgB5D;;AAEKE,EAAAA,SAAS,CAACC,IAAD,EAAoC;AAAA;AACjD,UAAMC,KAAK,GAAG,wBAAUD,IAAV,CAAd;;AACAC,MAAAA,KAAK,CAACC,OAAN,GAAgB,2BAAQF,IAAI,CAACE,OAAb,EAAuBC,MAAvB,CAAhB;AACAF,MAAAA,KAAK,CAACG,GAAN,SAAkB,iCAAcH,KAAd,EAAqBI,sBAArB,CAAlB;AACA,aAAOJ,KAAP;AAJiD;AAKlD;;AA5BqE","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { IEnvironmentAdaptor } from '@looker/extension-utils'\nimport { BrowserAdaptor, getEnvAdaptor } from '@looker/extension-utils'\nimport type { IAPIMethods } from '@looker/sdk-rtl'\nimport type { SpecItem, SpecList } from '@looker/sdk-codegen'\nimport { getSpecsFromVersions } from '@looker/sdk-codegen'\nimport { RunItConfigKey, RunItNoConfig } from '@looker/run-it'\nimport cloneDeep from 'lodash/cloneDeep'\n\nimport { fullify, fallbackFetch, funFetch } from './adaptorUtils'\n\nexport interface IApixAdaptor extends IEnvironmentAdaptor {\n fetchSpecList(versionsUrl?: string): Promise<SpecList>\n fetchSpec(spec: SpecItem): Promise<SpecItem>\n}\n\nexport const getApixAdaptor = () => getEnvAdaptor() as IApixAdaptor\n\nexport class ApixAdaptor extends BrowserAdaptor implements IApixAdaptor {\n constructor(sdk: IAPIMethods, private readonly fallbackVersionsUrl: string) {\n super(sdk)\n }\n\n async fetchSpecList(versionsUrl?: string): Promise<SpecList> {\n const data = await this.localStorageGetItem(RunItConfigKey)\n const config = data ? JSON.parse(data) : RunItNoConfig\n let url: string\n\n if (versionsUrl) {\n url = versionsUrl\n } else {\n url = config.base_url\n ? `${config.base_url}/versions`\n : `${this.fallbackVersionsUrl}/versions.json`\n }\n\n const versions = await this.sdk.authSession.transport.rawRequest('GET', url)\n const specs = await getSpecsFromVersions(JSON.parse(versions.body))\n return specs\n }\n\n async fetchSpec(spec: SpecItem): Promise<SpecItem> {\n const _spec = cloneDeep(spec)\n _spec.specURL = fullify(spec.specURL!, origin)\n _spec.api = await fallbackFetch(_spec, funFetch)\n return _spec\n }\n}\n"],"file":"apixAdaptor.js"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { highlightHTML } from './highlight';
|
|
2
|
-
export
|
|
2
|
+
export * from './path';
|
|
3
3
|
export { getLoded } from './lodeUtils';
|
|
4
4
|
export { useWindowSize } from './useWindowSize';
|
|
5
|
+
export * from './apixAdaptor';
|
|
6
|
+
export * from './adaptorUtils';
|
package/lib/utils/index.js
CHANGED
|
@@ -3,42 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
highlightHTML: true,
|
|
8
|
+
getLoded: true,
|
|
9
|
+
useWindowSize: true
|
|
10
|
+
};
|
|
6
11
|
Object.defineProperty(exports, "highlightHTML", {
|
|
7
12
|
enumerable: true,
|
|
8
13
|
get: function get() {
|
|
9
14
|
return _highlight.highlightHTML;
|
|
10
15
|
}
|
|
11
16
|
});
|
|
12
|
-
Object.defineProperty(exports, "buildPath", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _path.buildPath;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "buildMethodPath", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _path.buildMethodPath;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "buildTypePath", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _path.buildTypePath;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "diffPath", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _path.diffPath;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "oAuthPath", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _path.oAuthPath;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
17
|
Object.defineProperty(exports, "getLoded", {
|
|
43
18
|
enumerable: true,
|
|
44
19
|
get: function get() {
|
|
@@ -56,7 +31,47 @@ var _highlight = require("./highlight");
|
|
|
56
31
|
|
|
57
32
|
var _path = require("./path");
|
|
58
33
|
|
|
34
|
+
Object.keys(_path).forEach(function (key) {
|
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
|
+
if (key in exports && exports[key] === _path[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _path[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
59
46
|
var _lodeUtils = require("./lodeUtils");
|
|
60
47
|
|
|
61
48
|
var _useWindowSize = require("./useWindowSize");
|
|
49
|
+
|
|
50
|
+
var _apixAdaptor = require("./apixAdaptor");
|
|
51
|
+
|
|
52
|
+
Object.keys(_apixAdaptor).forEach(function (key) {
|
|
53
|
+
if (key === "default" || key === "__esModule") return;
|
|
54
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
55
|
+
if (key in exports && exports[key] === _apixAdaptor[key]) return;
|
|
56
|
+
Object.defineProperty(exports, key, {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return _apixAdaptor[key];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var _adaptorUtils = require("./adaptorUtils");
|
|
65
|
+
|
|
66
|
+
Object.keys(_adaptorUtils).forEach(function (key) {
|
|
67
|
+
if (key === "default" || key === "__esModule") return;
|
|
68
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
69
|
+
if (key in exports && exports[key] === _adaptorUtils[key]) return;
|
|
70
|
+
Object.defineProperty(exports, key, {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function get() {
|
|
73
|
+
return _adaptorUtils[key];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
62
77
|
//# sourceMappingURL=index.js.map
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/utils/path.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ApiModel, IMethod, IType } from '@looker/sdk-codegen';
|
|
2
|
+
import type { Location as HLocation } from 'history';
|
|
2
3
|
export declare const buildMethodPath: (specKey: string, tag: string, methodName: string) => string;
|
|
3
4
|
export declare const buildTypePath: (specKey: string, tag: string, typeName: string) => string;
|
|
4
5
|
export declare const diffPath = "diff";
|
|
5
6
|
export declare const oAuthPath = "oauth";
|
|
7
|
+
export declare const isMethod: (item: IMethod | IType) => boolean;
|
|
6
8
|
export declare const buildPath: (api: ApiModel, item: IMethod | IType, specKey: string) => string;
|
|
9
|
+
export declare const getSpecKey: (location: HLocation | Location) => string | null;
|
package/lib/utils/path.js
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.buildPath = exports.oAuthPath = exports.diffPath = exports.buildTypePath = exports.buildMethodPath = void 0;
|
|
6
|
+
exports.getSpecKey = exports.buildPath = exports.isMethod = exports.oAuthPath = exports.diffPath = exports.buildTypePath = exports.buildMethodPath = void 0;
|
|
7
7
|
|
|
8
8
|
var _sdkCodegen = require("@looker/sdk-codegen");
|
|
9
9
|
|
|
10
|
+
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
|
+
|
|
12
|
+
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
|
+
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
+
|
|
10
16
|
var buildMethodPath = (specKey, tag, methodName) => "/".concat(specKey, "/methods/").concat(tag, "/").concat(methodName);
|
|
11
17
|
|
|
12
18
|
exports.buildMethodPath = buildMethodPath;
|
|
@@ -29,6 +35,10 @@ var getMethodTag = (api, methodName) => {
|
|
|
29
35
|
})[0];
|
|
30
36
|
};
|
|
31
37
|
|
|
38
|
+
var isMethod = item => 'params' in item;
|
|
39
|
+
|
|
40
|
+
exports.isMethod = isMethod;
|
|
41
|
+
|
|
32
42
|
var getTypeTag = (api, type) => {
|
|
33
43
|
var method = (0, _sdkCodegen.firstMethodRef)(api, type);
|
|
34
44
|
return getMethodTag(api, method.name);
|
|
@@ -37,7 +47,7 @@ var getTypeTag = (api, type) => {
|
|
|
37
47
|
var buildPath = (api, item, specKey) => {
|
|
38
48
|
var path;
|
|
39
49
|
|
|
40
|
-
if (item
|
|
50
|
+
if (isMethod(item)) {
|
|
41
51
|
var tag = getMethodTag(api, item.name);
|
|
42
52
|
path = buildMethodPath(specKey, tag, item.name);
|
|
43
53
|
} else {
|
|
@@ -50,4 +60,24 @@ var buildPath = (api, item, specKey) => {
|
|
|
50
60
|
};
|
|
51
61
|
|
|
52
62
|
exports.buildPath = buildPath;
|
|
63
|
+
|
|
64
|
+
var getSpecKey = location => {
|
|
65
|
+
var _match, _match$groups;
|
|
66
|
+
|
|
67
|
+
var pathname = location.pathname;
|
|
68
|
+
var match;
|
|
69
|
+
|
|
70
|
+
if (pathname.startsWith("/".concat(diffPath))) {
|
|
71
|
+
var pattern = new RegExp("(?:/".concat(diffPath, ")/(?<specKey>\\w+.\\w+)"));
|
|
72
|
+
match = pathname.match(pattern);
|
|
73
|
+
} else {
|
|
74
|
+
match = pathname.match(_wrapRegExp(/\/([0-9A-Z_a-z]+\.[0-9A-Z_a-z]+).*/, {
|
|
75
|
+
specKey: 1
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return ((_match = match) === null || _match === void 0 ? void 0 : (_match$groups = _match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.specKey) || null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
exports.getSpecKey = getSpecKey;
|
|
53
83
|
//# sourceMappingURL=path.js.map
|
package/lib/utils/path.js.map
CHANGED
|
@@ -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","getTypeTag","type","method","name","buildPath","
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@looker/api-explorer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.29",
|
|
4
4
|
"description": "Looker API Explorer",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@looker/components-test-utils": "^1.5.5",
|
|
36
|
-
"@looker/sdk-codegen-scripts": "^21.
|
|
37
|
-
"@looker/sdk-node": "^
|
|
36
|
+
"@looker/sdk-codegen-scripts": "^21.3.0",
|
|
37
|
+
"@looker/sdk-node": "^22.2.0",
|
|
38
38
|
"@styled-icons/styled-icon": "^10.6.3",
|
|
39
39
|
"@testing-library/jest-dom": "^5.11.6",
|
|
40
40
|
"@testing-library/react": "^11.2.2",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"webpack-merge": "^5.7.3"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@looker/code-editor": "^0.1.
|
|
70
|
+
"@looker/code-editor": "^0.1.19",
|
|
71
71
|
"@looker/components": "^2.8.1",
|
|
72
72
|
"@looker/components-date": "^2.4.1",
|
|
73
73
|
"@looker/design-tokens": "^2.7.1",
|
|
74
|
-
"@looker/extension-utils": "^0.1.
|
|
74
|
+
"@looker/extension-utils": "^0.1.6",
|
|
75
75
|
"@looker/icons": "^1.5.3",
|
|
76
76
|
"@looker/redux": "0.0.0",
|
|
77
|
-
"@looker/run-it": "^0.9.
|
|
78
|
-
"@looker/sdk": "^
|
|
79
|
-
"@looker/sdk-codegen": "^21.
|
|
80
|
-
"@looker/sdk-rtl": "^21.3.
|
|
77
|
+
"@looker/run-it": "^0.9.29",
|
|
78
|
+
"@looker/sdk": "^22.2.0",
|
|
79
|
+
"@looker/sdk-codegen": "^21.5.0",
|
|
80
|
+
"@looker/sdk-rtl": "^21.3.2",
|
|
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": "
|
|
99
|
+
"gitHead": "8db44f3017f7303ad84f678a9e4999c216dfcfd9"
|
|
100
100
|
}
|
package/src/ApiExplorer.tsx
CHANGED
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import type { FC } from 'react'
|
|
28
|
-
import React, {
|
|
29
|
-
import { useLocation } from 'react-router'
|
|
28
|
+
import React, { useState, useEffect, useCallback } from 'react'
|
|
30
29
|
import styled, { createGlobalStyle } from 'styled-components'
|
|
31
30
|
import {
|
|
32
31
|
Aside,
|
|
@@ -38,27 +37,25 @@ import {
|
|
|
38
37
|
Page,
|
|
39
38
|
Space,
|
|
40
39
|
} from '@looker/components'
|
|
41
|
-
import type { SpecList } from '@looker/sdk-codegen'
|
|
42
|
-
import type { RunItSetter } from '@looker/run-it'
|
|
43
|
-
import { funFetch, fallbackFetch, OAuthScene } from '@looker/run-it'
|
|
44
40
|
import { FirstPage } from '@styled-icons/material/FirstPage'
|
|
45
41
|
import { LastPage } from '@styled-icons/material/LastPage'
|
|
46
|
-
|
|
47
|
-
import type { IEnvironmentAdaptor } from '@looker/extension-utils'
|
|
48
42
|
import {
|
|
49
43
|
registerEnvAdaptor,
|
|
50
44
|
unregisterEnvAdaptor,
|
|
51
45
|
} from '@looker/extension-utils'
|
|
52
|
-
import {
|
|
46
|
+
import { useSelector } from 'react-redux'
|
|
47
|
+
import { useLocation } from 'react-router-dom'
|
|
48
|
+
|
|
49
|
+
import type { IApixAdaptor } from './utils'
|
|
53
50
|
import {
|
|
54
51
|
Header,
|
|
55
52
|
SideNav,
|
|
56
53
|
ErrorBoundary,
|
|
57
|
-
Loader,
|
|
58
54
|
SelectorContainer,
|
|
59
55
|
HEADER_TOGGLE_LABEL,
|
|
56
|
+
Loader,
|
|
57
|
+
Banner,
|
|
60
58
|
} from './components'
|
|
61
|
-
import { specReducer, initDefaultSpecState, updateSpecApi } from './reducers'
|
|
62
59
|
import { AppRouter } from './routes'
|
|
63
60
|
import { apixFilesHost } from './utils/lodeUtils'
|
|
64
61
|
import {
|
|
@@ -66,12 +63,15 @@ import {
|
|
|
66
63
|
useSettingStoreState,
|
|
67
64
|
useLodeActions,
|
|
68
65
|
useLodesStoreState,
|
|
66
|
+
useSpecActions,
|
|
67
|
+
useSpecStoreState,
|
|
68
|
+
selectSpecs,
|
|
69
|
+
selectCurrentSpec,
|
|
69
70
|
} from './state'
|
|
71
|
+
import { getSpecKey, diffPath } from './utils'
|
|
70
72
|
|
|
71
73
|
export interface ApiExplorerProps {
|
|
72
|
-
|
|
73
|
-
adaptor: IEnvironmentAdaptor
|
|
74
|
-
setVersionsUrl: RunItSetter
|
|
74
|
+
adaptor: IApixAdaptor
|
|
75
75
|
examplesLodeUrl?: string
|
|
76
76
|
declarationsLodeUrl?: string
|
|
77
77
|
headless?: boolean
|
|
@@ -80,25 +80,21 @@ export interface ApiExplorerProps {
|
|
|
80
80
|
const BodyOverride = createGlobalStyle` html { height: 100%; overflow: hidden; } `
|
|
81
81
|
|
|
82
82
|
export const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
83
|
-
specs,
|
|
84
83
|
adaptor,
|
|
85
|
-
setVersionsUrl,
|
|
86
84
|
examplesLodeUrl = 'https://raw.githubusercontent.com/looker-open-source/sdk-codegen/main/examplesIndex.json',
|
|
87
85
|
declarationsLodeUrl = `${apixFilesHost}/declarationsIndex.json`,
|
|
88
86
|
headless = false,
|
|
89
87
|
}) => {
|
|
90
|
-
|
|
88
|
+
useSettingStoreState()
|
|
91
89
|
useLodesStoreState()
|
|
90
|
+
const { working, description } = useSpecStoreState()
|
|
91
|
+
const specs = useSelector(selectSpecs)
|
|
92
|
+
const spec = useSelector(selectCurrentSpec)
|
|
92
93
|
const { initLodesAction } = useLodeActions()
|
|
93
94
|
const { initSettingsAction } = useSettingActions()
|
|
94
|
-
const
|
|
95
|
-
const oauthReturn = location.pathname === `/${oAuthPath}`
|
|
96
|
-
const [specState, specDispatch] = useReducer(
|
|
97
|
-
specReducer,
|
|
98
|
-
initDefaultSpecState(specs, location)
|
|
99
|
-
)
|
|
100
|
-
const { spec } = specState
|
|
95
|
+
const { initSpecsAction, setCurrentSpecAction } = useSpecActions()
|
|
101
96
|
|
|
97
|
+
const location = useLocation()
|
|
102
98
|
const [hasNavigation, setHasNavigation] = useState(true)
|
|
103
99
|
const toggleNavigation = (target?: boolean) =>
|
|
104
100
|
setHasNavigation(target || !hasNavigation)
|
|
@@ -109,14 +105,24 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
109
105
|
}
|
|
110
106
|
}, [])
|
|
111
107
|
|
|
108
|
+
registerEnvAdaptor(adaptor)
|
|
109
|
+
|
|
112
110
|
useEffect(() => {
|
|
113
|
-
registerEnvAdaptor(adaptor)
|
|
114
111
|
initSettingsAction()
|
|
115
112
|
initLodesAction({ examplesLodeUrl, declarationsLodeUrl })
|
|
116
113
|
|
|
114
|
+
const specKey = getSpecKey(location)
|
|
115
|
+
initSpecsAction({ specKey })
|
|
117
116
|
return () => unregisterEnvAdaptor()
|
|
118
117
|
}, [])
|
|
119
118
|
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const maybeSpec = location.pathname?.split('/')[1]
|
|
121
|
+
if (spec && maybeSpec && maybeSpec !== diffPath && maybeSpec !== spec.key) {
|
|
122
|
+
setCurrentSpecAction({ currentSpecKey: maybeSpec })
|
|
123
|
+
}
|
|
124
|
+
}, [location.pathname, spec])
|
|
125
|
+
|
|
120
126
|
useEffect(() => {
|
|
121
127
|
if (headless) {
|
|
122
128
|
window.addEventListener('message', hasNavigationToggle)
|
|
@@ -128,46 +134,27 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
128
134
|
}
|
|
129
135
|
}, [headless, hasNavigationToggle])
|
|
130
136
|
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
const loadSpec = async () => {
|
|
133
|
-
if (!spec.api) {
|
|
134
|
-
try {
|
|
135
|
-
const newSpec = { ...spec }
|
|
136
|
-
const api = await fallbackFetch(newSpec, funFetch)
|
|
137
|
-
if (api) {
|
|
138
|
-
spec.api = api
|
|
139
|
-
specDispatch(updateSpecApi(spec.key, api))
|
|
140
|
-
}
|
|
141
|
-
} catch (error) {
|
|
142
|
-
console.error(error)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (!oauthReturn) {
|
|
147
|
-
loadSpec()
|
|
148
|
-
}
|
|
149
|
-
}, [spec, location])
|
|
150
|
-
|
|
151
137
|
const themeOverrides = adaptor.themeOverrides()
|
|
152
138
|
|
|
139
|
+
let neededSpec = location.pathname?.split('/')[1]
|
|
140
|
+
if (!neededSpec || neededSpec === diffPath) {
|
|
141
|
+
neededSpec = spec?.key
|
|
142
|
+
}
|
|
143
|
+
|
|
153
144
|
return (
|
|
154
145
|
<>
|
|
155
146
|
<ComponentsProvider
|
|
156
147
|
loadGoogleFonts={themeOverrides.loadGoogleFonts}
|
|
157
148
|
themeCustomizations={themeOverrides.themeCustomizations}
|
|
158
149
|
>
|
|
159
|
-
{!
|
|
160
|
-
<Loader message=
|
|
150
|
+
{working || !neededSpec || neededSpec !== spec.key ? (
|
|
151
|
+
<Loader message={description} themeOverrides={themeOverrides} />
|
|
161
152
|
) : (
|
|
162
153
|
<ErrorBoundary logError={adaptor.logError.bind(adaptor)}>
|
|
154
|
+
<Banner adaptor={adaptor} specs={specs} />
|
|
163
155
|
<Page style={{ overflow: 'hidden' }}>
|
|
164
156
|
{!headless && (
|
|
165
|
-
<Header
|
|
166
|
-
specs={specs}
|
|
167
|
-
spec={spec}
|
|
168
|
-
specDispatch={specDispatch}
|
|
169
|
-
toggleNavigation={toggleNavigation}
|
|
170
|
-
/>
|
|
157
|
+
<Header spec={spec} toggleNavigation={toggleNavigation} />
|
|
171
158
|
)}
|
|
172
159
|
<Layout hasAside height="100%">
|
|
173
160
|
<AsideBorder
|
|
@@ -207,36 +194,22 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({
|
|
|
207
194
|
<>
|
|
208
195
|
<Divider mb="u3" appearance="light" />
|
|
209
196
|
<SelectorContainer
|
|
197
|
+
spec={spec}
|
|
210
198
|
ml="large"
|
|
211
199
|
mr="large"
|
|
212
|
-
specs={specs}
|
|
213
|
-
spec={spec}
|
|
214
|
-
specDispatch={specDispatch}
|
|
215
200
|
/>
|
|
216
201
|
</>
|
|
217
202
|
)}
|
|
218
203
|
</>
|
|
219
204
|
)}
|
|
220
|
-
{hasNavigation &&
|
|
221
|
-
<SideNav
|
|
222
|
-
headless={headless}
|
|
223
|
-
specs={specs}
|
|
224
|
-
spec={spec}
|
|
225
|
-
specDispatch={specDispatch}
|
|
226
|
-
/>
|
|
227
|
-
)}
|
|
205
|
+
{hasNavigation && <SideNav headless={headless} spec={spec} />}
|
|
228
206
|
</AsideBorder>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
toggleNavigation={toggleNavigation}
|
|
236
|
-
adaptor={adaptor}
|
|
237
|
-
setVersionsUrl={setVersionsUrl}
|
|
238
|
-
/>
|
|
239
|
-
)}
|
|
207
|
+
<AppRouter
|
|
208
|
+
specKey={spec.key}
|
|
209
|
+
api={spec.api!}
|
|
210
|
+
specs={specs}
|
|
211
|
+
toggleNavigation={toggleNavigation}
|
|
212
|
+
/>
|
|
240
213
|
</Layout>
|
|
241
214
|
</Page>
|
|
242
215
|
</ErrorBoundary>
|