@looker/run-it 0.9.22 → 0.9.26
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +73 -0
- package/lib/RunIt.d.ts +2 -0
- package/lib/RunIt.js +20 -27
- package/lib/RunIt.js.map +1 -1
- package/lib/RunItProvider.d.ts +0 -4
- package/lib/RunItProvider.js +2 -7
- package/lib/RunItProvider.js.map +1 -1
- package/lib/components/ConfigForm/ConfigForm.d.ts +0 -4
- package/lib/components/ConfigForm/ConfigForm.js +12 -11
- package/lib/components/ConfigForm/ConfigForm.js.map +1 -1
- package/lib/components/ConfigForm/configUtils.js +6 -4
- package/lib/components/ConfigForm/configUtils.js.map +1 -1
- package/lib/components/DocSdkCalls/DocMultiCall.d.ts +5 -2
- package/lib/components/DocSdkCalls/DocMultiCall.js +7 -19
- package/lib/components/DocSdkCalls/DocMultiCall.js.map +1 -1
- package/lib/components/DocSdkCalls/DocSdkCalls.js +26 -9
- package/lib/components/DocSdkCalls/DocSdkCalls.js.map +1 -1
- package/lib/components/LoginForm/LoginForm.d.ts +2 -8
- package/lib/components/LoginForm/LoginForm.js +5 -6
- package/lib/components/LoginForm/LoginForm.js.map +1 -1
- package/lib/components/PerfTracker/PerfTracker.d.ts +0 -2
- package/lib/components/PerfTracker/PerfTracker.js +7 -8
- package/lib/components/PerfTracker/PerfTracker.js.map +1 -1
- package/lib/components/RequestForm/RequestForm.d.ts +0 -4
- package/lib/components/RequestForm/RequestForm.js +0 -7
- package/lib/components/RequestForm/RequestForm.js.map +1 -1
- package/lib/components/RequestForm/formUtils.d.ts +1 -1
- package/lib/components/RequestForm/formUtils.js +25 -10
- package/lib/components/RequestForm/formUtils.js.map +1 -1
- package/lib/components/common/index.d.ts +0 -1
- package/lib/components/common/index.js +0 -18
- package/lib/components/common/index.js.map +1 -1
- package/lib/esm/RunIt.js +20 -28
- package/lib/esm/RunIt.js.map +1 -1
- package/lib/esm/RunItProvider.js +2 -7
- package/lib/esm/RunItProvider.js.map +1 -1
- package/lib/esm/components/ConfigForm/ConfigForm.js +12 -12
- package/lib/esm/components/ConfigForm/ConfigForm.js.map +1 -1
- package/lib/esm/components/ConfigForm/configUtils.js +6 -4
- package/lib/esm/components/ConfigForm/configUtils.js.map +1 -1
- package/lib/esm/components/DocSdkCalls/DocMultiCall.js +8 -19
- package/lib/esm/components/DocSdkCalls/DocMultiCall.js.map +1 -1
- package/lib/esm/components/DocSdkCalls/DocSdkCalls.js +25 -10
- package/lib/esm/components/DocSdkCalls/DocSdkCalls.js.map +1 -1
- package/lib/esm/components/LoginForm/LoginForm.js +5 -6
- package/lib/esm/components/LoginForm/LoginForm.js.map +1 -1
- package/lib/esm/components/PerfTracker/PerfTracker.js +7 -8
- package/lib/esm/components/PerfTracker/PerfTracker.js.map +1 -1
- package/lib/esm/components/RequestForm/RequestForm.js +0 -7
- package/lib/esm/components/RequestForm/RequestForm.js.map +1 -1
- package/lib/esm/components/RequestForm/formUtils.js +25 -10
- package/lib/esm/components/RequestForm/formUtils.js.map +1 -1
- package/lib/esm/components/common/index.js +0 -1
- package/lib/esm/components/common/index.js.map +1 -1
- package/lib/esm/scenes/OAuthScene/OAuthScene.js +3 -6
- package/lib/esm/scenes/OAuthScene/OAuthScene.js.map +1 -1
- package/lib/esm/utils/RunItSDK.js +12 -77
- package/lib/esm/utils/RunItSDK.js.map +1 -1
- package/lib/esm/utils/requestUtils.js +21 -14
- package/lib/esm/utils/requestUtils.js.map +1 -1
- package/lib/scenes/OAuthScene/OAuthScene.js +2 -5
- package/lib/scenes/OAuthScene/OAuthScene.js.map +1 -1
- package/lib/test-data/responses.js +9 -0
- package/lib/test-data/responses.js.map +1 -1
- package/lib/utils/RunItSDK.d.ts +3 -16
- package/lib/utils/RunItSDK.js +15 -87
- package/lib/utils/RunItSDK.js.map +1 -1
- package/lib/utils/requestUtils.d.ts +2 -3
- package/lib/utils/requestUtils.js +22 -15
- package/lib/utils/requestUtils.js.map +1 -1
- package/package.json +9 -8
- package/lib/components/DocSdkCalls/DocSingleCall.d.ts +0 -3
- package/lib/components/DocSdkCalls/DocSingleCall.js +0 -32
- package/lib/components/DocSdkCalls/DocSingleCall.js.map +0 -1
- package/lib/components/common/StandaloneConfigurator.d.ts +0 -7
- package/lib/components/common/StandaloneConfigurator.js +0 -61
- package/lib/components/common/StandaloneConfigurator.js.map +0 -1
- package/lib/esm/components/DocSdkCalls/DocSingleCall.js +0 -18
- package/lib/esm/components/DocSdkCalls/DocSingleCall.js.map +0 -1
- package/lib/esm/components/common/StandaloneConfigurator.js +0 -51
- package/lib/esm/components/common/StandaloneConfigurator.js.map +0 -1
package/lib/utils/RunItSDK.js
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.StoreConstants = exports.initRunItSdk = void 0;
|
7
|
+
|
8
|
+
var _sdkRtl = require("@looker/sdk-rtl");
|
7
9
|
|
8
10
|
var _sdk = require("@looker/sdk");
|
9
11
|
|
10
|
-
var
|
12
|
+
var _extensionUtils = require("@looker/extension-utils");
|
11
13
|
|
12
14
|
var _components = require("../components");
|
13
15
|
|
@@ -17,70 +19,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
17
19
|
|
18
20
|
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; }
|
19
21
|
|
20
|
-
var
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
class RunItSettings extends _sdkRtl.ApiSettings {
|
26
|
-
constructor(settings, configurator) {
|
27
|
-
super(settings);
|
28
|
-
|
29
|
-
_defineProperty(this, "configurator", void 0);
|
30
|
-
|
31
|
-
this.configurator = configurator;
|
32
|
-
}
|
33
|
-
|
34
|
-
getStoredConfig() {
|
35
|
-
var storage = this.configurator.getStorage(_components.RunItConfigKey);
|
36
|
-
var config = {
|
37
|
-
base_url: '',
|
38
|
-
looker_url: ''
|
39
|
-
};
|
40
|
-
|
41
|
-
if (storage.value) {
|
42
|
-
config = JSON.parse(storage.value);
|
43
|
-
}
|
44
|
-
|
45
|
-
return config;
|
46
|
-
}
|
47
|
-
|
48
|
-
authIsConfigured() {
|
49
|
-
var config = this.getStoredConfig();
|
50
|
-
return config.base_url !== '' && config.looker_url !== '';
|
51
|
-
}
|
52
|
-
|
53
|
-
readConfig(_section) {
|
54
|
-
var config = this.getStoredConfig();
|
22
|
+
var initRunItSdk = () => {
|
23
|
+
var settings = _objectSpread(_objectSpread({}, (0, _sdkRtl.DefaultSettings)()), {}, {
|
24
|
+
base_url: 'https://self-signed.looker.com:19999',
|
25
|
+
agentTag: 'RunIt 0.8'
|
26
|
+
});
|
55
27
|
|
56
|
-
|
57
|
-
var url = new URL(this.base_url);
|
58
|
-
var authServer = "".concat(url.protocol, "//").concat(url.hostname);
|
59
|
-
config = {
|
60
|
-
base_url: this.base_url,
|
61
|
-
looker_url: "".concat(authServer, ":9999")
|
62
|
-
};
|
63
|
-
}
|
64
|
-
|
65
|
-
var {
|
66
|
-
base_url,
|
67
|
-
looker_url
|
68
|
-
} = config;
|
69
|
-
this.base_url = base_url;
|
70
|
-
return _objectSpread(_objectSpread({}, super.readConfig(_section)), {
|
71
|
-
base_url,
|
72
|
-
looker_url,
|
73
|
-
client_id: 'looker.api-explorer',
|
74
|
-
redirect_uri: "".concat(window.location.origin, "/oauth")
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
exports.RunItSettings = RunItSettings;
|
81
|
-
|
82
|
-
var perfSDK = (settings, configurator) => {
|
83
|
-
var options = new RunItSettings(settings, configurator);
|
28
|
+
var options = new _extensionUtils.OAuthConfigProvider(settings, _components.RunItConfigKey);
|
84
29
|
var transport = new _sdkRtl.BrowserTransport(options);
|
85
30
|
var session = new _sdkRtl.BrowserSession(options, transport);
|
86
31
|
var sdk = (0, _sdk.functionalSdk40)(session);
|
@@ -88,28 +33,11 @@ var perfSDK = (settings, configurator) => {
|
|
88
33
|
return sdk;
|
89
34
|
};
|
90
35
|
|
91
|
-
var runItSDK;
|
92
|
-
exports.runItSDK = runItSDK;
|
93
|
-
|
94
|
-
var initRunItSdk = configurator => {
|
95
|
-
if (!runItSDK) {
|
96
|
-
exports.runItSDK = runItSDK = perfSDK(settings, configurator);
|
97
|
-
}
|
98
|
-
|
99
|
-
return runItSDK;
|
100
|
-
};
|
101
|
-
|
102
36
|
exports.initRunItSdk = initRunItSdk;
|
37
|
+
var StoreConstants;
|
38
|
+
exports.StoreConstants = StoreConstants;
|
103
39
|
|
104
|
-
|
105
|
-
|
106
|
-
exports.
|
107
|
-
|
108
|
-
var sdkNeedsAuth = sdk => {
|
109
|
-
if (!sdk) return false;
|
110
|
-
var configIsNeeded = sdkNeedsConfig(sdk);
|
111
|
-
return configIsNeeded && !sdk.authSession.isAuthenticated();
|
112
|
-
};
|
113
|
-
|
114
|
-
exports.sdkNeedsAuth = sdkNeedsAuth;
|
40
|
+
(function (StoreConstants) {
|
41
|
+
StoreConstants["LOCALSTORAGE_SETTINGS_KEY"] = "settings";
|
42
|
+
})(StoreConstants || (exports.StoreConstants = StoreConstants = {}));
|
115
43
|
//# sourceMappingURL=RunItSDK.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/RunItSDK.ts"],"names":["settings","base_url","agentTag","
|
1
|
+
{"version":3,"sources":["../../src/utils/RunItSDK.ts"],"names":["initRunItSdk","settings","base_url","agentTag","options","OAuthConfigProvider","RunItConfigKey","transport","BrowserTransport","session","BrowserSession","sdk","trackPerformance","StoreConstants"],"mappings":";;;;;;;AA2BA;;AAKA;;AACA;;AAEA;;;;;;;;AAEO,IAAMA,YAAY,GAAG,MAAM;AAChC,MAAMC,QAAQ,mCACT,8BADS;AAEZC,IAAAA,QAAQ,EAAE,sCAFE;AAGZC,IAAAA,QAAQ,EAAE;AAHE,IAAd;;AAMA,MAAMC,OAAO,GAAG,IAAIC,mCAAJ,CAAwBJ,QAAxB,EAAkCK,0BAAlC,CAAhB;AACA,MAAMC,SAAS,GAAG,IAAIC,wBAAJ,CAAqBJ,OAArB,CAAlB;AACA,MAAMK,OAAO,GAAG,IAAIC,sBAAJ,CAAmBN,OAAnB,EAA4BG,SAA5B,CAAhB;AACA,MAAMI,GAAG,GAAG,0BAAgBF,OAAhB,CAAZ;AACAD,2BAAiBI,gBAAjB,GAAoC,IAApC;AACA,SAAOD,GAAP;AACD,CAbM;;;IAeKE,c;;;WAAAA,c;AAAAA,EAAAA,c;GAAAA,c,8BAAAA,c","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 { IApiSettings } from '@looker/sdk-rtl'\nimport {\n BrowserSession,\n BrowserTransport,\n DefaultSettings,\n} from '@looker/sdk-rtl'\nimport { functionalSdk40 } from '@looker/sdk'\nimport { OAuthConfigProvider } from '@looker/extension-utils'\n\nimport { RunItConfigKey } from '../components'\n\nexport const initRunItSdk = () => {\n const settings = {\n ...DefaultSettings(),\n base_url: 'https://self-signed.looker.com:19999',\n agentTag: 'RunIt 0.8',\n } as IApiSettings\n\n const options = new OAuthConfigProvider(settings, RunItConfigKey)\n const transport = new BrowserTransport(options)\n const session = new BrowserSession(options, transport)\n const sdk = functionalSdk40(session)\n BrowserTransport.trackPerformance = true\n return sdk\n}\n\nexport enum StoreConstants {\n LOCALSTORAGE_SETTINGS_KEY = 'settings',\n}\n"],"file":"RunItSDK.js"}
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import type { IAPIMethods, IRawResponse } from '@looker/sdk-rtl';
|
2
2
|
import type { IApiModel, IMethod } from '@looker/sdk-codegen';
|
3
3
|
import type { RunItHttpMethod, RunItInput, RunItValues } from '../RunIt';
|
4
|
-
import type { RunItConfigurator } from '../components';
|
5
4
|
export declare type RunItSetter = (value: any) => any;
|
6
5
|
export declare const runItNoSet: RunItSetter;
|
7
6
|
export declare const pathify: (path: string, pathParams?: RunItValues | undefined) => string;
|
8
7
|
export declare const prepareInputs: (inputs: RunItInput[], requestContent: RunItValues) => RunItValues;
|
9
|
-
export declare const formValues: (
|
10
|
-
export declare const initRequestContent: (
|
8
|
+
export declare const formValues: () => Promise<any>;
|
9
|
+
export declare const initRequestContent: (inputs: RunItInput[], requestContent?: {}) => {};
|
11
10
|
export declare const createRequestParams: (inputs: RunItInput[], requestContent: RunItValues) => any[];
|
12
11
|
export declare const runRequest: (sdk: IAPIMethods, basePath: string, httpMethod: RunItHttpMethod, endpoint: string, pathParams: RunItValues, queryParams: RunItValues, body: any) => Promise<IRawResponse>;
|
13
12
|
export declare const createInputs: (spec: IApiModel, method: IMethod) => RunItInput[];
|
@@ -11,9 +11,9 @@ var _lodash = require("lodash");
|
|
11
11
|
|
12
12
|
var _sdkCodegen = require("@looker/sdk-codegen");
|
13
13
|
|
14
|
-
var
|
14
|
+
var _extensionUtils = require("@looker/extension-utils");
|
15
15
|
|
16
|
-
var
|
16
|
+
var _components = require("../components");
|
17
17
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
19
|
|
@@ -68,18 +68,25 @@ var prepareInputs = (inputs, requestContent) => {
|
|
68
68
|
|
69
69
|
exports.prepareInputs = prepareInputs;
|
70
70
|
|
71
|
-
var formValues =
|
72
|
-
var
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
var formValues = function () {
|
72
|
+
var _ref = _asyncToGenerator(function* () {
|
73
|
+
var adaptor = (0, _extensionUtils.getEnvAdaptor)();
|
74
|
+
var formValue = yield adaptor.localStorageGetItem(_components.RunItFormKey);
|
75
|
+
var result = formValue ? JSON.parse(formValue) : {};
|
76
|
+
adaptor.localStorageRemoveItem(_components.RunItFormKey);
|
77
|
+
return result;
|
78
|
+
});
|
79
|
+
|
80
|
+
return function formValues() {
|
81
|
+
return _ref.apply(this, arguments);
|
82
|
+
};
|
83
|
+
}();
|
77
84
|
|
78
85
|
exports.formValues = formValues;
|
79
86
|
|
80
|
-
var initRequestContent = function initRequestContent(
|
81
|
-
var requestContent = arguments.length >
|
82
|
-
var content =
|
87
|
+
var initRequestContent = function initRequestContent(inputs) {
|
88
|
+
var requestContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
89
|
+
var content = {};
|
83
90
|
|
84
91
|
if ((0, _lodash.isEmpty)(content)) {
|
85
92
|
content = prepareInputs(inputs, requestContent);
|
@@ -124,18 +131,18 @@ var createRequestParams = (inputs, requestContent) => {
|
|
124
131
|
exports.createRequestParams = createRequestParams;
|
125
132
|
|
126
133
|
var runRequest = function () {
|
127
|
-
var
|
134
|
+
var _ref2 = _asyncToGenerator(function* (sdk, basePath, httpMethod, endpoint, pathParams, queryParams, body) {
|
128
135
|
if (!sdk.authSession.isAuthenticated()) {
|
129
|
-
yield sdk.ok(
|
136
|
+
yield sdk.ok(sdk.authSession.login());
|
130
137
|
}
|
131
138
|
|
132
139
|
var url = "".concat(basePath).concat(pathify(endpoint, pathParams));
|
133
|
-
var raw = yield sdk.authSession.transport.rawRequest(httpMethod, url, queryParams, body, props =>
|
140
|
+
var raw = yield sdk.authSession.transport.rawRequest(httpMethod, url, queryParams, body, props => sdk.authSession.authenticate(props));
|
134
141
|
return raw;
|
135
142
|
});
|
136
143
|
|
137
144
|
return function runRequest(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
138
|
-
return
|
145
|
+
return _ref2.apply(this, arguments);
|
139
146
|
};
|
140
147
|
}();
|
141
148
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/requestUtils.ts"],"names":["runItNoSet","value","macro","path","vars","replace","_","b","pathify","pathParams","result","includes","prepareInputs","inputs","requestContent","input","name","location","parsed","JSON","parse","type","e","formValues","configurator","storage","getStorage","RunItFormKey","removeStorage","initRequestContent","content","createRequestParams","queryParams","prepped","trimmed","body","Error","runRequest","sdk","basePath","httpMethod","endpoint","authSession","isAuthenticated","ok","runItSDK","login","url","raw","transport","rawRequest","props","authenticate","getTypeDefault","createSampleBody","spec","getSampleValue","IntrinsicType","DelimArrayType","elementType","EnumType","ArrayType","customType","recurse","types","HashType","sampleBody","prop","writeable","sampleValue","undefined","editType","createInputs","method","allParams","map","param","required","description"],"mappings":";;;;;;;AA2BA;;AACA;;AAEA;;AAWA;;AACA;;;;;;;;AASO,IAAMA,UAAuB,GAAIC,KAAD,IAAgBA,KAAhD;;;;AAQP,IAAMC,KAAK,GAAG,CAACC,IAAD,EAAeC,IAAf,KACZD,IAAI,CAACE,OAAL,CAAa,UAAb,EAAyB,CAACC,CAAD,EAAIC,CAAJ,KAAUH,IAAI,CAACG,CAAD,CAAvC,CADF;;AASO,IAAMC,OAAO,GAAG,CAACL,IAAD,EAAeM,UAAf,KAAoD;AACzE,MAAIC,MAAM,GAAGP,IAAb;;AACA,MAAIM,UAAU,IAAIN,IAAI,CAACQ,QAAL,CAAc,GAAd,CAAlB,EAAsC;AACpCD,IAAAA,MAAM,GAAGR,KAAK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AkBkB,MAAlB,KAC1BA,MAAM,CAACC,SAAP,CAAiBC,GAAjB,CAAsBC,KAAD,KAAY;AAC/B5D,EAAAA,IAAI,EAAE4D,KAAK,CAAC5D,IADmB;AAE/BC,EAAAA,QAAQ,EAAE2D,KAAK,CAAC3D,QAFe;AAG/BI,EAAAA,IAAI,EAAEkD,QAAQ,CAAChB,IAAD,EAAOqB,KAAK,CAACvD,IAAb,CAHiB;AAI/BwD,EAAAA,QAAQ,EAAED,KAAK,CAACC,QAJe;AAK/BC,EAAAA,WAAW,EAAEF,KAAK,CAACE;AALY,CAAZ,CAArB,CADK","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 { IAPIMethods, IRawResponse } from '@looker/sdk-rtl'\nimport cloneDeep from 'lodash/cloneDeep'\nimport { isEmpty } from 'lodash'\nimport type { IApiModel, IMethod, IType } from '@looker/sdk-codegen'\nimport {\n ArrayType,\n DelimArrayType,\n EnumType,\n HashType,\n IntrinsicType,\n trimInputs,\n} from '@looker/sdk-codegen'\n\nimport type { RunItHttpMethod, RunItInput, RunItValues } from '../RunIt'\nimport type { RunItConfigurator } from '../components'\nimport { RunItFormKey } from '../components'\nimport { runItSDK } from './RunItSDK'\n\n/** Hook to set a URL somewhere else in APIX */\nexport type RunItSetter = (value: any) => any\n\n/**\n * A \"no-op\" function\n * @param value passed through\n */\nexport const runItNoSet: RunItSetter = (value: any) => value\n\n/**\n * Replaces {foo} with vars[foo] in provided path\n * @param path with templatized param names\n * @param vars Collection of path params\n * @returns Path with param names replaced with values\n */\nconst macro = (path: string, vars: RunItValues) =>\n path.replace(/{(\\w+)}/g, (_, b) => vars[b])\n\n/**\n * Construct a full request path including path params\n * @param path A request path with path params in curly braces e.g. /queries/{query_id}/run/{result_format}\n * @param pathParams Collection of path params\n * @returns a full request path\n */\nexport const pathify = (path: string, pathParams?: RunItValues): string => {\n let result = path\n if (pathParams && path.includes('{')) {\n result = macro(path, pathParams)\n }\n return result\n}\n\n/**\n * Prepares the inputs for use with the SDK and other RunIt components\n * @param inputs An array describing RunIt form inputs\n * @param requestContent Current request parameters\n */\nexport const prepareInputs = (\n inputs: RunItInput[],\n requestContent: RunItValues\n) => {\n const result = cloneDeep(requestContent)\n for (const input of inputs) {\n const name = input.name\n if (input.location === 'body') {\n try {\n let parsed\n if (name in requestContent) {\n const value = requestContent[name]\n /** The value is not a string when the user has not interacted with this param and prepareInputs has been\n * called (e.g. if user navigates to the Code tab).\n */\n parsed = typeof value === 'string' ? JSON.parse(value) : value\n } else {\n /** This scenario occurs when RunIt is about to be mounted for a new method */\n parsed = input.type\n }\n result[name] = parsed\n } catch (e) {\n /** Treat as x-www-form-urlencoded */\n result[name] = requestContent[name]\n }\n }\n }\n return result\n}\n\n/**\n * Load and clear any saved form values from the session\n * @param configurator storage service\n */\nexport const formValues = (configurator: RunItConfigurator) => {\n const storage = configurator.getStorage(RunItFormKey)\n const result = storage.value ? JSON.parse(storage.value) : {}\n configurator.removeStorage(RunItFormKey)\n return result\n}\n\n/**\n * Initializes the request content object from local storage or input definitions, in that order\n * @param configurator storage service\n * @param inputs\n * @param requestContent the current request content\n */\nexport const initRequestContent = (\n configurator: RunItConfigurator,\n inputs: RunItInput[],\n requestContent = {}\n) => {\n let content = formValues(configurator)\n if (isEmpty(content)) {\n content = prepareInputs(inputs, requestContent)\n }\n return content\n}\n\n/**\n * Takes all form input values and categorizes them based on their request location\n * @param inputs RunIt form inputs\n * @param requestContent Form input values\n * @returns path, query and body param objects\n */\nexport const createRequestParams = (\n inputs: RunItInput[],\n requestContent: RunItValues\n) => {\n const pathParams = {}\n const queryParams = {}\n const prepped = prepareInputs(inputs, requestContent)\n const trimmed = trimInputs(prepped)\n let body\n for (const input of inputs) {\n const name = input.name\n switch (input.location) {\n case 'path':\n pathParams[name] = trimmed[name]\n break\n case 'query':\n queryParams[name] = trimmed[name]\n break\n case 'body':\n body = trimmed[name]\n break\n default:\n throw new Error(`Invalid input location: '${input.location}'`)\n }\n }\n return [pathParams, queryParams, body]\n}\n\n/**\n * Makes an http request using the SDK browser transport rawRequest method\n * @param sdk functional SDK that supports rawRequest via its transport\n * @param basePath base path for the URL. For standalone this includes the specKey. Empty for extension.\n * @param httpMethod Request operation\n * @param endpoint Request path with path params in curly braces e.g. /queries/{query_id}/run/{result_format}\n * @param pathParams Collection of path params\n * @param queryParams Collection of query params\n * @param body Collection of body params\n */\nexport const runRequest = async (\n sdk: IAPIMethods,\n basePath: string,\n httpMethod: RunItHttpMethod,\n endpoint: string,\n pathParams: RunItValues,\n queryParams: RunItValues,\n body: any\n): Promise<IRawResponse> => {\n if (!sdk.authSession.isAuthenticated()) {\n await sdk.ok(runItSDK.authSession.login())\n }\n const url = `${basePath}${pathify(endpoint, pathParams)}`\n const raw = await sdk.authSession.transport.rawRequest(\n httpMethod,\n url,\n queryParams,\n body,\n (props) => runItSDK.authSession.authenticate(props)\n )\n return raw\n}\n\n/**\n * Return a default value for a given type name\n * @param type A type name\n */\nconst getTypeDefault = (type: string) => {\n // TODO: use potential equivalent from sdk-codegen, confirm formats\n switch (type) {\n case 'boolean':\n return false\n case 'int64':\n case 'integer':\n return 0\n case 'float':\n case 'double':\n return 0.0\n case 'hostname':\n case 'ipv4':\n case 'ipv6':\n case 'uuid':\n case 'uri':\n case 'string':\n case 'email':\n return ''\n case 'string[]':\n return []\n case 'object':\n return {}\n case 'datetime':\n return ''\n default:\n return ''\n }\n}\n\n/**\n * Given a type object reduce it to its writeable intrinsic and/or custom type properties and their default values\n * @param spec Api spec\n * @param type A type object\n */\nconst createSampleBody = (spec: IApiModel, type: IType) => {\n /* eslint-disable @typescript-eslint/no-use-before-define */\n const getSampleValue = (type: IType) => {\n if (type instanceof IntrinsicType) return getTypeDefault(type.name)\n if (type instanceof DelimArrayType)\n return getTypeDefault(type.elementType.name)\n if (type instanceof EnumType) return ''\n if (type instanceof ArrayType)\n return type.customType\n ? [recurse(spec.types[type.customType])]\n : getTypeDefault(type.name)\n if (type instanceof HashType)\n return type.customType ? recurse(spec.types[type.customType]) : {}\n\n return recurse(type)\n }\n /* eslint-enable @typescript-eslint/no-use-before-define */\n\n const recurse = (type: IType) => {\n const sampleBody: RunItValues = {}\n for (const prop of type.writeable) {\n const sampleValue = getSampleValue(prop.type)\n if (sampleValue !== undefined) {\n sampleBody[prop.name] = sampleValue\n }\n }\n return sampleBody\n }\n return recurse(type)\n}\n\n/**\n * Convert model type to an editable type\n * @param spec API model for building input editor\n * @param type to convert\n */\nconst editType = (spec: IApiModel, type: IType) => {\n if (type instanceof IntrinsicType) return type.name\n // TODO create a DelimArray editing component as part of the complex type editor\n if (type instanceof DelimArrayType) return 'string'\n return createSampleBody(spec, type)\n}\n\n/**\n * Given an SDK method create and return an array of inputs for the run-it form\n * @param spec Api spec\n * @param method A method object\n */\nexport const createInputs = (spec: IApiModel, method: IMethod): RunItInput[] =>\n method.allParams.map((param) => ({\n name: param.name,\n location: param.location,\n type: editType(spec, param.type),\n required: param.required,\n description: param.description,\n }))\n"],"file":"requestUtils.js"}
|
1
|
+
{"version":3,"sources":["../../src/utils/requestUtils.ts"],"names":["runItNoSet","value","macro","path","vars","replace","_","b","pathify","pathParams","result","includes","prepareInputs","inputs","requestContent","input","name","location","parsed","JSON","parse","type","e","formValues","adaptor","formValue","localStorageGetItem","RunItFormKey","localStorageRemoveItem","initRequestContent","content","createRequestParams","queryParams","prepped","trimmed","body","Error","runRequest","sdk","basePath","httpMethod","endpoint","authSession","isAuthenticated","ok","login","url","raw","transport","rawRequest","props","authenticate","getTypeDefault","createSampleBody","spec","getSampleValue","IntrinsicType","DelimArrayType","elementType","EnumType","ArrayType","customType","recurse","types","HashType","sampleBody","prop","writeable","sampleValue","undefined","editType","createInputs","method","allParams","map","param","required","description"],"mappings":";;;;;;;AA2BA;;AACA;;AAEA;;AAQA;;AAGA;;;;;;;;AASO,IAAMA,UAAuB,GAAIC,KAAD,IAAgBA,KAAhD;;;;AAQP,IAAMC,KAAK,GAAG,CAACC,IAAD,EAAeC,IAAf,KACZD,IAAI,CAACE,OAAL,CAAa,UAAb,EAAyB,CAACC,CAAD,EAAIC,CAAJ,KAAUH,IAAI,CAACG,CAAD,CAAvC,CADF;;AASO,IAAMC,OAAO,GAAG,CAACL,IAAD,EAAeM,UAAf,KAAoD;AACzE,MAAIC,MAAM,GAAGP,IAAb;;AACA,MAAIM,UAAU,IAAIN,IAAI,CAACQ,QAAL,CAAc,GAAd,CAAlB,EAAsC;AACpCD,IAAAA,MAAM,GAAGR,KAAK,CAACC,IAAD,EAAOM,UAAP,CAAd;AACD;;AACD,SAAOC,MAAP;AACD,CANM;;;;AAaA,IAAME,aAAa,GAAG,CAC3BC,MAD2B,EAE3BC,cAF2B,KAGxB;AACH,MAAMJ,MAAM,GAAG,wBAAUI,cAAV,CAAf;;AACA,OAAK,IAAMC,KAAX,IAAoBF,MAApB,EAA4B;AAC1B,QAAMG,IAAI,GAAGD,KAAK,CAACC,IAAnB;;AACA,QAAID,KAAK,CAACE,QA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,EAAAA,QAAQ,EAAED,KAAK,CAACC,QAJe;AAK/BC,EAAAA,WAAW,EAAEF,KAAK,CAACE;AALY,CAAZ,CAArB,CADK","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 { IAPIMethods, IRawResponse } from '@looker/sdk-rtl'\nimport cloneDeep from 'lodash/cloneDeep'\nimport { isEmpty } from 'lodash'\nimport type { IApiModel, IMethod, IType } from '@looker/sdk-codegen'\nimport {\n ArrayType,\n DelimArrayType,\n EnumType,\n HashType,\n IntrinsicType,\n trimInputs,\n} from '@looker/sdk-codegen'\nimport { getEnvAdaptor } from '@looker/extension-utils'\n\nimport type { RunItHttpMethod, RunItInput, RunItValues } from '../RunIt'\nimport { RunItFormKey } from '../components'\n\n/** Hook to set a URL somewhere else in APIX */\nexport type RunItSetter = (value: any) => any\n\n/**\n * A \"no-op\" function\n * @param value passed through\n */\nexport const runItNoSet: RunItSetter = (value: any) => value\n\n/**\n * Replaces {foo} with vars[foo] in provided path\n * @param path with templatized param names\n * @param vars Collection of path params\n * @returns Path with param names replaced with values\n */\nconst macro = (path: string, vars: RunItValues) =>\n path.replace(/{(\\w+)}/g, (_, b) => vars[b])\n\n/**\n * Construct a full request path including path params\n * @param path A request path with path params in curly braces e.g. /queries/{query_id}/run/{result_format}\n * @param pathParams Collection of path params\n * @returns a full request path\n */\nexport const pathify = (path: string, pathParams?: RunItValues): string => {\n let result = path\n if (pathParams && path.includes('{')) {\n result = macro(path, pathParams)\n }\n return result\n}\n\n/**\n * Prepares the inputs for use with the SDK and other RunIt components\n * @param inputs An array describing RunIt form inputs\n * @param requestContent Current request parameters\n */\nexport const prepareInputs = (\n inputs: RunItInput[],\n requestContent: RunItValues\n) => {\n const result = cloneDeep(requestContent)\n for (const input of inputs) {\n const name = input.name\n if (input.location === 'body') {\n try {\n let parsed\n if (name in requestContent) {\n const value = requestContent[name]\n /** The value is not a string when the user has not interacted with this param and prepareInputs has been\n * called (e.g. if user navigates to the Code tab).\n */\n parsed = typeof value === 'string' ? JSON.parse(value) : value\n } else {\n /** This scenario occurs when RunIt is about to be mounted for a new method */\n parsed = input.type\n }\n result[name] = parsed\n } catch (e) {\n /** Treat as x-www-form-urlencoded */\n result[name] = requestContent[name]\n }\n }\n }\n return result\n}\n\n/**\n * Load and clear any saved form values from the session\n * @param configurator storage service\n */\nexport const formValues = async () => {\n const adaptor = getEnvAdaptor()\n const formValue = await adaptor.localStorageGetItem(RunItFormKey)\n const result = formValue ? JSON.parse(formValue) : {}\n adaptor.localStorageRemoveItem(RunItFormKey)\n return result\n}\n\n/**\n * Initializes the request content object from local storage or input definitions, in that order\n * @param configurator storage service\n * @param inputs\n * @param requestContent the current request content\n */\nexport const initRequestContent = (\n inputs: RunItInput[],\n requestContent = {}\n) => {\n // TODO: Temporarily disabling request form state persistence until RunIt is using redux\n // let content = await formValues()\n let content = {}\n if (isEmpty(content)) {\n content = prepareInputs(inputs, requestContent)\n }\n return content\n}\n\n/**\n * Takes all form input values and categorizes them based on their request location\n * @param inputs RunIt form inputs\n * @param requestContent Form input values\n * @returns path, query and body param objects\n */\nexport const createRequestParams = (\n inputs: RunItInput[],\n requestContent: RunItValues\n) => {\n const pathParams = {}\n const queryParams = {}\n const prepped = prepareInputs(inputs, requestContent)\n const trimmed = trimInputs(prepped)\n let body\n for (const input of inputs) {\n const name = input.name\n switch (input.location) {\n case 'path':\n pathParams[name] = trimmed[name]\n break\n case 'query':\n queryParams[name] = trimmed[name]\n break\n case 'body':\n body = trimmed[name]\n break\n default:\n throw new Error(`Invalid input location: '${input.location}'`)\n }\n }\n return [pathParams, queryParams, body]\n}\n\n/**\n * Makes an http request using the SDK browser transport rawRequest method\n * @param sdk functional SDK that supports rawRequest via its transport\n * @param basePath base path for the URL. For standalone this includes the specKey. Empty for extension.\n * @param httpMethod Request operation\n * @param endpoint Request path with path params in curly braces e.g. /queries/{query_id}/run/{result_format}\n * @param pathParams Collection of path params\n * @param queryParams Collection of query params\n * @param body Collection of body params\n */\nexport const runRequest = async (\n sdk: IAPIMethods,\n basePath: string,\n httpMethod: RunItHttpMethod,\n endpoint: string,\n pathParams: RunItValues,\n queryParams: RunItValues,\n body: any\n): Promise<IRawResponse> => {\n if (!sdk.authSession.isAuthenticated()) {\n await sdk.ok(sdk.authSession.login())\n }\n const url = `${basePath}${pathify(endpoint, pathParams)}`\n const raw = await sdk.authSession.transport.rawRequest(\n httpMethod,\n url,\n queryParams,\n body,\n (props) => sdk.authSession.authenticate(props)\n )\n return raw\n}\n\n/**\n * Return a default value for a given type name\n * @param type A type name\n */\nconst getTypeDefault = (type: string) => {\n // TODO: use potential equivalent from sdk-codegen, confirm formats\n switch (type) {\n case 'boolean':\n return false\n case 'int64':\n case 'integer':\n return 0\n case 'float':\n case 'double':\n return 0.0\n case 'hostname':\n case 'ipv4':\n case 'ipv6':\n case 'uuid':\n case 'uri':\n case 'string':\n case 'email':\n return ''\n case 'string[]':\n return []\n case 'object':\n return {}\n case 'datetime':\n return ''\n default:\n return ''\n }\n}\n\n/**\n * Given a type object reduce it to its writeable intrinsic and/or custom type properties and their default values\n * @param spec Api spec\n * @param type A type object\n */\nconst createSampleBody = (spec: IApiModel, type: IType) => {\n /* eslint-disable @typescript-eslint/no-use-before-define */\n const getSampleValue = (type: IType) => {\n if (type instanceof IntrinsicType) return getTypeDefault(type.name)\n if (type instanceof DelimArrayType)\n return getTypeDefault(type.elementType.name)\n if (type instanceof EnumType) return ''\n if (type instanceof ArrayType)\n return type.customType\n ? [recurse(spec.types[type.customType])]\n : getTypeDefault(type.name)\n if (type instanceof HashType)\n return type.customType ? recurse(spec.types[type.customType]) : {}\n\n return recurse(type)\n }\n /* eslint-enable @typescript-eslint/no-use-before-define */\n\n const recurse = (type: IType) => {\n const sampleBody: RunItValues = {}\n for (const prop of type.writeable) {\n const sampleValue = getSampleValue(prop.type)\n if (sampleValue !== undefined) {\n sampleBody[prop.name] = sampleValue\n }\n }\n return sampleBody\n }\n return recurse(type)\n}\n\n/**\n * Convert model type to an editable type\n * @param spec API model for building input editor\n * @param type to convert\n */\nconst editType = (spec: IApiModel, type: IType) => {\n if (type instanceof IntrinsicType) return type.name\n // TODO create a DelimArray editing component as part of the complex type editor\n if (type instanceof DelimArrayType) return 'string'\n return createSampleBody(spec, type)\n}\n\n/**\n * Given an SDK method create and return an array of inputs for the run-it form\n * @param spec Api spec\n * @param method A method object\n */\nexport const createInputs = (spec: IApiModel, method: IMethod): RunItInput[] =>\n method.allParams.map((param) => ({\n name: param.name,\n location: param.location,\n type: editType(spec, param.type),\n required: param.required,\n description: param.description,\n }))\n"],"file":"requestUtils.js"}
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@looker/run-it",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.26",
|
4
4
|
"description": "A dynamic REST request input form and response visualizer",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"module": "lib/esm/index.js",
|
7
|
-
"sideEffects":
|
7
|
+
"sideEffects": false,
|
8
8
|
"typings": "lib/index.d.ts",
|
9
9
|
"files": [
|
10
10
|
"lib"
|
@@ -18,7 +18,7 @@
|
|
18
18
|
"repository": {
|
19
19
|
"type": "git",
|
20
20
|
"url": "git+https://github.com/looker-open-source/sdk-codegen.git",
|
21
|
-
"directory": "packages/
|
21
|
+
"directory": "packages/run-it"
|
22
22
|
},
|
23
23
|
"homepage": "https://github.com/looker-open-source/sdk-codegen/tree/main/packages/run-it",
|
24
24
|
"bugs": {
|
@@ -51,15 +51,16 @@
|
|
51
51
|
"webpack-dev-server": "^3.11.2"
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@looker/code-editor": "^0.1.
|
54
|
+
"@looker/code-editor": "^0.1.17",
|
55
55
|
"@looker/components": "^2.8.1",
|
56
56
|
"@looker/components-date": "^2.4.1",
|
57
57
|
"@looker/design-tokens": "^2.7.1",
|
58
|
+
"@looker/extension-utils": "^0.1.3",
|
58
59
|
"@looker/icons": "^1.5.3",
|
59
|
-
"@looker/sdk": "^21.
|
60
|
-
"@looker/sdk-codegen": "^21.
|
60
|
+
"@looker/sdk": "^21.20.0",
|
61
|
+
"@looker/sdk-codegen": "^21.3.1",
|
61
62
|
"@looker/sdk-codegen-utils": "^21.0.11",
|
62
|
-
"@looker/sdk-rtl": "^21.
|
63
|
+
"@looker/sdk-rtl": "^21.3.1",
|
63
64
|
"@styled-icons/material": "^10.28.0",
|
64
65
|
"@styled-icons/material-outlined": "^10.28.0",
|
65
66
|
"@styled-icons/material-rounded": "^10.28.0",
|
@@ -72,5 +73,5 @@
|
|
72
73
|
"react-is": "^16.13.1",
|
73
74
|
"styled-components": "^5.2.1"
|
74
75
|
},
|
75
|
-
"gitHead": "
|
76
|
+
"gitHead": "933163198d7e1ab482c8c5aedc43c35eb9923d86"
|
76
77
|
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.DocSingleCall = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _sdkCodegen = require("@looker/sdk-codegen");
|
11
|
-
|
12
|
-
var _codeEditor = require("@looker/code-editor");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
var DocSingleCall = _ref => {
|
17
|
-
var {
|
18
|
-
api,
|
19
|
-
method,
|
20
|
-
inputs,
|
21
|
-
sdkLanguage
|
22
|
-
} = _ref;
|
23
|
-
var generator = (0, _sdkCodegen.getCodeGenerator)(sdkLanguage, api);
|
24
|
-
var code = generator.makeTheCall(method, inputs);
|
25
|
-
return _react.default.createElement(_codeEditor.CodeCopy, {
|
26
|
-
code: code,
|
27
|
-
language: sdkLanguage
|
28
|
-
});
|
29
|
-
};
|
30
|
-
|
31
|
-
exports.DocSingleCall = DocSingleCall;
|
32
|
-
//# sourceMappingURL=DocSingleCall.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DocSdkCalls/DocSingleCall.tsx"],"names":["DocSingleCall","api","method","inputs","sdkLanguage","generator","code","makeTheCall"],"mappings":";;;;;;;AA0BA;;AACA;;AAEA;;;;AAMO,IAAMA,aAAmC,GAAG,QAK7C;AAAA,MAL8C;AAClDC,IAAAA,GADkD;AAElDC,IAAAA,MAFkD;AAGlDC,IAAAA,MAHkD;AAIlDC,IAAAA;AAJkD,GAK9C;AACJ,MAAMC,SAAS,GAAG,kCAAiBD,WAAjB,EAA8BH,GAA9B,CAAlB;AACA,MAAMK,IAAI,GAAGD,SAAS,CAAEE,WAAX,CAAuBL,MAAvB,EAA+BC,MAA/B,CAAb;AAEA,SAAO,6BAAC,oBAAD;AAAU,IAAA,IAAI,EAAEG,IAAhB;AAAsB,IAAA,QAAQ,EAAEF;AAAhC,IAAP;AACD,CAVM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { FC } from 'react'\nimport React from 'react'\nimport { getCodeGenerator } from '@looker/sdk-codegen'\n\nimport { CodeCopy } from '@looker/code-editor'\nimport type { DocSdkCallsProps } from './DocSdkCalls'\n\n/**\n * Generates the SDK call syntax for a given language\n */\nexport const DocSingleCall: FC<DocSdkCallsProps> = ({\n api,\n method,\n inputs,\n sdkLanguage,\n}) => {\n const generator = getCodeGenerator(sdkLanguage, api)\n const code = generator!.makeTheCall(method, inputs)\n\n return <CodeCopy code={code} language={sdkLanguage} />\n}\n"],"file":"DocSingleCall.js"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { IStorageValue, RunItConfigurator, StorageLocation } from '..';
|
2
|
-
export declare class StandaloneConfigurator implements RunItConfigurator {
|
3
|
-
getStorage(key: string, defaultValue?: string): IStorageValue;
|
4
|
-
setStorage(key: string, value: string, location?: StorageLocation): string;
|
5
|
-
removeStorage(key: string): void;
|
6
|
-
}
|
7
|
-
export declare const defaultConfigurator: StandaloneConfigurator;
|
@@ -1,61 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.defaultConfigurator = exports.StandaloneConfigurator = void 0;
|
7
|
-
|
8
|
-
class StandaloneConfigurator {
|
9
|
-
getStorage(key) {
|
10
|
-
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
11
|
-
var value = sessionStorage.getItem(key);
|
12
|
-
|
13
|
-
if (value) {
|
14
|
-
return {
|
15
|
-
location: 'session',
|
16
|
-
value
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
value = localStorage.getItem(key);
|
21
|
-
|
22
|
-
if (value) {
|
23
|
-
return {
|
24
|
-
location: 'local',
|
25
|
-
value
|
26
|
-
};
|
27
|
-
}
|
28
|
-
|
29
|
-
return {
|
30
|
-
location: 'session',
|
31
|
-
value: defaultValue
|
32
|
-
};
|
33
|
-
}
|
34
|
-
|
35
|
-
setStorage(key, value) {
|
36
|
-
var location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'session';
|
37
|
-
|
38
|
-
switch (location.toLocaleLowerCase()) {
|
39
|
-
case 'local':
|
40
|
-
localStorage.setItem(key, value);
|
41
|
-
break;
|
42
|
-
|
43
|
-
case 'session':
|
44
|
-
sessionStorage.setItem(key, value);
|
45
|
-
break;
|
46
|
-
}
|
47
|
-
|
48
|
-
return value;
|
49
|
-
}
|
50
|
-
|
51
|
-
removeStorage(key) {
|
52
|
-
localStorage.removeItem(key);
|
53
|
-
sessionStorage.removeItem(key);
|
54
|
-
}
|
55
|
-
|
56
|
-
}
|
57
|
-
|
58
|
-
exports.StandaloneConfigurator = StandaloneConfigurator;
|
59
|
-
var defaultConfigurator = new StandaloneConfigurator();
|
60
|
-
exports.defaultConfigurator = defaultConfigurator;
|
61
|
-
//# sourceMappingURL=StandaloneConfigurator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/common/StandaloneConfigurator.ts"],"names":["StandaloneConfigurator","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","setStorage","toLocaleLowerCase","setItem","removeStorage","removeItem","defaultConfigurator"],"mappings":";;;;;;;AA2BO,MAAMA,sBAAN,CAA0D;AAC/DC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AACxD,QAAIC,KAAK,GAAGC,cAAc,CAACC,OAAf,CAAuBJ,GAAvB,CAAZ;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,SADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACDA,IAAAA,KAAK,GAAGI,YAAY,CAACF,OAAb,CAAqBJ,GAArB,CAAR;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,OADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACD,WAAO;AACLG,MAAAA,QAAQ,EAAE,SADL;AAELH,MAAAA,KAAK,EAAED;AAFF,KAAP;AAID;;AAEDM,EAAAA,UAAU,CACRP,GADQ,EAERE,KAFQ,EAIA;AAAA,QADRG,QACQ,uEADoB,SACpB;;AACR,YAAQA,QAAQ,CAACG,iBAAT,EAAR;AACE,WAAK,OAAL;AACEF,QAAAA,YAAY,CAACG,OAAb,CAAqBT,GAArB,EAA0BE,KAA1B;AACA;;AACF,WAAK,SAAL;AACEC,QAAAA,cAAc,CAACM,OAAf,CAAuBT,GAAvB,EAA4BE,KAA5B;AACA;AANJ;;AAQA,WAAOA,KAAP;AACD;;AAEDQ,EAAAA,aAAa,CAACV,GAAD,EAAc;AACzBM,IAAAA,YAAY,CAACK,UAAb,CAAwBX,GAAxB;AACAG,IAAAA,cAAc,CAACQ,UAAf,CAA0BX,GAA1B;AACD;;AAzC8D;;;AA4C1D,IAAMY,mBAAmB,GAAG,IAAId,sBAAJ,EAA5B","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 { IStorageValue, RunItConfigurator, StorageLocation } from '..'\n\nexport class StandaloneConfigurator implements RunItConfigurator {\n getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n setStorage(\n key: string,\n value: string,\n location: StorageLocation = 'session'\n ): string {\n switch (location.toLocaleLowerCase()) {\n case 'local':\n localStorage.setItem(key, value)\n break\n case 'session':\n sessionStorage.setItem(key, value)\n break\n }\n return value\n }\n\n removeStorage(key: string) {\n localStorage.removeItem(key)\n sessionStorage.removeItem(key)\n }\n}\n\nexport const defaultConfigurator = new StandaloneConfigurator()\n"],"file":"StandaloneConfigurator.js"}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { getCodeGenerator } from '@looker/sdk-codegen';
|
3
|
-
import { CodeCopy } from '@looker/code-editor';
|
4
|
-
export var DocSingleCall = _ref => {
|
5
|
-
var {
|
6
|
-
api,
|
7
|
-
method,
|
8
|
-
inputs,
|
9
|
-
sdkLanguage
|
10
|
-
} = _ref;
|
11
|
-
var generator = getCodeGenerator(sdkLanguage, api);
|
12
|
-
var code = generator.makeTheCall(method, inputs);
|
13
|
-
return React.createElement(CodeCopy, {
|
14
|
-
code: code,
|
15
|
-
language: sdkLanguage
|
16
|
-
});
|
17
|
-
};
|
18
|
-
//# sourceMappingURL=DocSingleCall.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/DocSdkCalls/DocSingleCall.tsx"],"names":["React","getCodeGenerator","CodeCopy","DocSingleCall","api","method","inputs","sdkLanguage","generator","code","makeTheCall"],"mappings":"AA0BA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AAEA,SAASC,QAAT,QAAyB,qBAAzB;AAMA,OAAO,IAAMC,aAAmC,GAAG,QAK7C;AAAA,MAL8C;AAClDC,IAAAA,GADkD;AAElDC,IAAAA,MAFkD;AAGlDC,IAAAA,MAHkD;AAIlDC,IAAAA;AAJkD,GAK9C;AACJ,MAAMC,SAAS,GAAGP,gBAAgB,CAACM,WAAD,EAAcH,GAAd,CAAlC;AACA,MAAMK,IAAI,GAAGD,SAAS,CAAEE,WAAX,CAAuBL,MAAvB,EAA+BC,MAA/B,CAAb;AAEA,SAAO,oBAAC,QAAD;AAAU,IAAA,IAAI,EAAEG,IAAhB;AAAsB,IAAA,QAAQ,EAAEF;AAAhC,IAAP;AACD,CAVM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\nimport type { FC } from 'react'\nimport React from 'react'\nimport { getCodeGenerator } from '@looker/sdk-codegen'\n\nimport { CodeCopy } from '@looker/code-editor'\nimport type { DocSdkCallsProps } from './DocSdkCalls'\n\n/**\n * Generates the SDK call syntax for a given language\n */\nexport const DocSingleCall: FC<DocSdkCallsProps> = ({\n api,\n method,\n inputs,\n sdkLanguage,\n}) => {\n const generator = getCodeGenerator(sdkLanguage, api)\n const code = generator!.makeTheCall(method, inputs)\n\n return <CodeCopy code={code} language={sdkLanguage} />\n}\n"],"file":"DocSingleCall.js"}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
export class StandaloneConfigurator {
|
2
|
-
getStorage(key) {
|
3
|
-
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
4
|
-
var value = sessionStorage.getItem(key);
|
5
|
-
|
6
|
-
if (value) {
|
7
|
-
return {
|
8
|
-
location: 'session',
|
9
|
-
value
|
10
|
-
};
|
11
|
-
}
|
12
|
-
|
13
|
-
value = localStorage.getItem(key);
|
14
|
-
|
15
|
-
if (value) {
|
16
|
-
return {
|
17
|
-
location: 'local',
|
18
|
-
value
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
return {
|
23
|
-
location: 'session',
|
24
|
-
value: defaultValue
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
setStorage(key, value) {
|
29
|
-
var location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'session';
|
30
|
-
|
31
|
-
switch (location.toLocaleLowerCase()) {
|
32
|
-
case 'local':
|
33
|
-
localStorage.setItem(key, value);
|
34
|
-
break;
|
35
|
-
|
36
|
-
case 'session':
|
37
|
-
sessionStorage.setItem(key, value);
|
38
|
-
break;
|
39
|
-
}
|
40
|
-
|
41
|
-
return value;
|
42
|
-
}
|
43
|
-
|
44
|
-
removeStorage(key) {
|
45
|
-
localStorage.removeItem(key);
|
46
|
-
sessionStorage.removeItem(key);
|
47
|
-
}
|
48
|
-
|
49
|
-
}
|
50
|
-
export var defaultConfigurator = new StandaloneConfigurator();
|
51
|
-
//# sourceMappingURL=StandaloneConfigurator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/common/StandaloneConfigurator.ts"],"names":["StandaloneConfigurator","getStorage","key","defaultValue","value","sessionStorage","getItem","location","localStorage","setStorage","toLocaleLowerCase","setItem","removeStorage","removeItem","defaultConfigurator"],"mappings":"AA2BA,OAAO,MAAMA,sBAAN,CAA0D;AAC/DC,EAAAA,UAAU,CAACC,GAAD,EAAgD;AAAA,QAAlCC,YAAkC,uEAAnB,EAAmB;AACxD,QAAIC,KAAK,GAAGC,cAAc,CAACC,OAAf,CAAuBJ,GAAvB,CAAZ;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,SADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACDA,IAAAA,KAAK,GAAGI,YAAY,CAACF,OAAb,CAAqBJ,GAArB,CAAR;;AACA,QAAIE,KAAJ,EAAW;AACT,aAAO;AACLG,QAAAA,QAAQ,EAAE,OADL;AAELH,QAAAA;AAFK,OAAP;AAID;;AACD,WAAO;AACLG,MAAAA,QAAQ,EAAE,SADL;AAELH,MAAAA,KAAK,EAAED;AAFF,KAAP;AAID;;AAEDM,EAAAA,UAAU,CACRP,GADQ,EAERE,KAFQ,EAIA;AAAA,QADRG,QACQ,uEADoB,SACpB;;AACR,YAAQA,QAAQ,CAACG,iBAAT,EAAR;AACE,WAAK,OAAL;AACEF,QAAAA,YAAY,CAACG,OAAb,CAAqBT,GAArB,EAA0BE,KAA1B;AACA;;AACF,WAAK,SAAL;AACEC,QAAAA,cAAc,CAACM,OAAf,CAAuBT,GAAvB,EAA4BE,KAA5B;AACA;AANJ;;AAQA,WAAOA,KAAP;AACD;;AAEDQ,EAAAA,aAAa,CAACV,GAAD,EAAc;AACzBM,IAAAA,YAAY,CAACK,UAAb,CAAwBX,GAAxB;AACAG,IAAAA,cAAc,CAACQ,UAAf,CAA0BX,GAA1B;AACD;;AAzC8D;AA4CjE,OAAO,IAAMY,mBAAmB,GAAG,IAAId,sBAAJ,EAA5B","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 { IStorageValue, RunItConfigurator, StorageLocation } from '..'\n\nexport class StandaloneConfigurator implements RunItConfigurator {\n getStorage(key: string, defaultValue = ''): IStorageValue {\n let value = sessionStorage.getItem(key)\n if (value) {\n return {\n location: 'session',\n value,\n }\n }\n value = localStorage.getItem(key)\n if (value) {\n return {\n location: 'local',\n value,\n }\n }\n return {\n location: 'session',\n value: defaultValue,\n }\n }\n\n setStorage(\n key: string,\n value: string,\n location: StorageLocation = 'session'\n ): string {\n switch (location.toLocaleLowerCase()) {\n case 'local':\n localStorage.setItem(key, value)\n break\n case 'session':\n sessionStorage.setItem(key, value)\n break\n }\n return value\n }\n\n removeStorage(key: string) {\n localStorage.removeItem(key)\n sessionStorage.removeItem(key)\n }\n}\n\nexport const defaultConfigurator = new StandaloneConfigurator()\n"],"file":"StandaloneConfigurator.js"}
|