@looker/api-explorer 0.9.81 → 0.9.83

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 CHANGED
@@ -401,6 +401,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
401
401
  * @looker/sdk-codegen-scripts bumped from 21.5.37 to 21.5.38
402
402
  * @looker/sdk-node bumped from 25.20.0 to 26.0.0
403
403
 
404
+ ### Dependencies
405
+
406
+ * The following workspace dependencies were updated
407
+ * dependencies
408
+ * @looker/code-editor bumped from 0.1.48 to 0.1.49
409
+ * @looker/extension-utils bumped from 0.1.58 to 0.1.59
410
+ * @looker/run-it bumped from 0.9.81 to 0.9.82
411
+ * @looker/sdk bumped from 26.0.0 to 26.2.0
412
+ * @looker/sdk-codegen bumped from 21.10.3 to 21.10.4
413
+ * devDependencies
414
+ * @looker/sdk-codegen-scripts bumped from 21.5.38 to 21.5.39
415
+ * @looker/sdk-node bumped from 26.0.0 to 26.2.0
416
+
417
+ ## [0.9.83](https://github.com/looker-open-source/sdk-codegen/compare/api-explorer-v0.9.82...api-explorer-v0.9.83) (2026-03-11)
418
+
419
+
420
+ ### Features
421
+
422
+ * **api-explorer-test:** allow some api-explorer e2e tests to run remotely - phase 1 ([#1641](https://github.com/looker-open-source/sdk-codegen/issues/1641)) ([25a5335](https://github.com/looker-open-source/sdk-codegen/commit/25a53355a3abf2066aa06a7a3a20f35be0e61028)), closes [#1640](https://github.com/looker-open-source/sdk-codegen/issues/1640)
423
+ * **api-explorer:** render and format form-urlencoded queries as body parameters ([#1648](https://github.com/looker-open-source/sdk-codegen/issues/1648)) ([46eb5c9](https://github.com/looker-open-source/sdk-codegen/commit/46eb5c968098417fe3cfb6cce3adf8bffd21d663))
424
+
425
+
426
+ ### Dependencies
427
+
428
+ * The following workspace dependencies were updated
429
+ * dependencies
430
+ * @looker/code-editor bumped from 0.1.49 to 0.1.50
431
+ * @looker/extension-utils bumped from 0.1.59 to 0.1.60
432
+ * @looker/run-it bumped from 0.9.82 to 0.9.83
433
+ * @looker/sdk bumped from 26.2.0 to 26.4.0
434
+ * @looker/sdk-codegen bumped from 21.10.4 to 21.11.0
435
+ * devDependencies
436
+ * @looker/sdk-codegen-scripts bumped from 21.5.39 to 21.5.40
437
+ * @looker/sdk-node bumped from 26.2.0 to 26.4.0
438
+
404
439
  ## [0.9.74](https://github.com/looker-open-source/sdk-codegen/compare/api-explorer-v0.9.73...api-explorer-v0.9.74) (2025-03-11)
405
440
 
406
441
 
package/README.md CHANGED
@@ -31,3 +31,29 @@ To see the other scripts supported by the package, do
31
31
  ```sh
32
32
  yarn workspace @looker/api-explorer run
33
33
  ```
34
+
35
+ ## Running E2E Tests
36
+
37
+ The API Explorer includes end-to-end tests using Puppeteer.
38
+
39
+ ### Run Local Tests
40
+
41
+ This command will automatically start the development server (`yarn develop`) and run the tests against it.
42
+
43
+ ```sh
44
+ yarn workspace @looker/api-explorer run test:e2e
45
+ ```
46
+
47
+ ### E2E Testing
48
+
49
+ To run the E2E tests against a remote Looker instance, you must provide your API client credentials.
50
+
51
+ #### Run Remote E2E Tests
52
+ This runs the local development server (with your code changes) but proxies API requests to the remote Looker instance.
53
+
54
+ ```bash
55
+ API_PROXY_TARGET=https://<your-looker-instance> \
56
+ LOOKER_CLIENT_ID=<your-client-id> \
57
+ LOOKER_CLIENT_SECRET=<your-client-secret> \
58
+ yarn workspace @looker/api-explorer run test:e2e
59
+ ```
@@ -23,7 +23,14 @@
23
23
  SOFTWARE.
24
24
 
25
25
  */
26
- import { goToPage, v40Url as v40, v40Url } from './helpers';
26
+ import {
27
+ goToPage,
28
+ v40Url as v40,
29
+ v40Url,
30
+ injectToken,
31
+ ensureSdkSelected,
32
+ mockExternalResources,
33
+ } from './helpers';
27
34
 
28
35
  jest.setTimeout(120000);
29
36
 
@@ -31,6 +38,9 @@ describe('MethodScene', () => {
31
38
  beforeEach(async () => {
32
39
  await jestPuppeteer.resetBrowser();
33
40
  await page.setDefaultNavigationTimeout(120000);
41
+ await injectToken();
42
+ await mockExternalResources();
43
+ await ensureSdkSelected('Python');
34
44
  });
35
45
 
36
46
  afterEach(async () => {
package/e2e/e2e.spec.ts CHANGED
@@ -25,7 +25,14 @@
25
25
  */
26
26
  import '@testing-library/jest-dom';
27
27
 
28
- import { goToPage, pageReload, v40Url as v40 } from './helpers';
28
+ import {
29
+ injectToken,
30
+ pageReload,
31
+ goToPage,
32
+ ensureSdkSelected,
33
+ mockExternalResources,
34
+ v40Url as v40,
35
+ } from './helpers';
29
36
 
30
37
  // https://github.com/smooth-code/jest-puppeteer/tree/master/packages/expect-puppeteer
31
38
  // https://github.com/puppeteer/puppeteer/blob/main/docs/api.md
@@ -36,6 +43,10 @@ describe('API Explorer', () => {
36
43
  beforeEach(async () => {
37
44
  await jestPuppeteer.resetBrowser();
38
45
  await page.setDefaultNavigationTimeout(120000);
46
+ // Inject token if remote
47
+ await injectToken();
48
+ await mockExternalResources();
49
+ await ensureSdkSelected('Python');
39
50
  });
40
51
 
41
52
  afterEach(async () => {
@@ -58,6 +69,7 @@ describe('API Explorer', () => {
58
69
  page.waitForNavigation(),
59
70
  expect(page).toClick('h3', { text: 'Get All Dashboards' }),
60
71
  ]);
72
+
61
73
  await expect(page.url()).toEqual(
62
74
  `${v40}/methods/Dashboard/all_dashboards?sdk=py`
63
75
  );
package/e2e/helpers.ts CHANGED
@@ -31,6 +31,83 @@ export const BASE_URL = 'https://localhost:8080';
31
31
  export const v31Url = `${BASE_URL}/3.1`;
32
32
  export const v40Url = `${BASE_URL}/4.0`;
33
33
 
34
+ export const mockExternalResources = async (): Promise<void> => {
35
+ await page.setRequestInterception(true);
36
+ page.on('request', request => {
37
+ if (request.url().includes('examplesIndex.json')) {
38
+ request.respond({
39
+ status: 200,
40
+ contentType: 'application/json',
41
+ body: JSON.stringify({
42
+ commitHash: 'hash',
43
+ remoteOrigin: 'https://github.com/looker-open-source/sdk-codegen',
44
+ summaries: {
45
+ 'examples/python/all_dashboards.py': {
46
+ sourceFile: 'examples/python/all_dashboards.py',
47
+ summary: 'Get All Dashboards',
48
+ },
49
+ 'examples/python/me.py': {
50
+ sourceFile: 'examples/python/me.py',
51
+ summary: 'Get Current User',
52
+ },
53
+ },
54
+ nuggets: {
55
+ all_dashboards: {
56
+ operationId: 'all_dashboards',
57
+ calls: {
58
+ '.py': [
59
+ {
60
+ sourceFile: 'examples/python/all_dashboards.py',
61
+ line: 10,
62
+ },
63
+ ],
64
+ },
65
+ },
66
+ me: {
67
+ operationId: 'me',
68
+ calls: {
69
+ '.py': [
70
+ {
71
+ sourceFile: 'examples/python/me.py',
72
+ line: 5,
73
+ },
74
+ ],
75
+ },
76
+ },
77
+ content_metadata: {
78
+ operationId: 'content_metadata',
79
+ calls: {
80
+ '.py': [
81
+ {
82
+ sourceFile: 'examples/python/content_metadata.py',
83
+ line: 5,
84
+ },
85
+ ],
86
+ },
87
+ },
88
+ },
89
+ }),
90
+ headers: {
91
+ 'Access-Control-Allow-Origin': '*',
92
+ },
93
+ });
94
+ } else if (request.url().includes('/err/')) {
95
+ const urlParts = request.url().split('/');
96
+ const errorCode = urlParts.find(part => /^\d{3}$/.test(part)) || '400';
97
+ request.respond({
98
+ status: 200,
99
+ contentType: 'text/markdown',
100
+ body: `## API Response ${errorCode} for `,
101
+ headers: {
102
+ 'Access-Control-Allow-Origin': '*',
103
+ },
104
+ });
105
+ } else {
106
+ request.continue();
107
+ }
108
+ });
109
+ };
110
+
34
111
  /**
35
112
  * Reloads the page, waiting for for the DomContentLoaded event before resolving
36
113
  */
@@ -52,8 +129,123 @@ export const goToPage = async (url: string): Promise<void> => {
52
129
  /**
53
130
  * Gets the key of the selected spec
54
131
  */
132
+ export const injectToken = async (): Promise<void> => {
133
+ const clientId = process.env.LOOKER_CLIENT_ID;
134
+ const clientSecret = process.env.LOOKER_CLIENT_SECRET;
135
+
136
+ if (!clientId || !clientSecret) {
137
+ // eslint-disable-next-line no-console
138
+ console.warn(
139
+ 'LOOKER_CLIENT_ID or LOOKER_CLIENT_SECRET not set. Skipping token injection.'
140
+ );
141
+ return;
142
+ }
143
+
144
+ // Go to the base URL (or login page) to ensure we are on the correct origin
145
+ await goToPage(BASE_URL);
146
+
147
+ try {
148
+ await page.evaluate(
149
+ (clientId, clientSecret, baseUrl) => {
150
+ return fetch(`${baseUrl}/api/4.0/login`, {
151
+ method: 'POST',
152
+ body: new URLSearchParams({
153
+ client_id: clientId,
154
+ client_secret: clientSecret,
155
+ }),
156
+ })
157
+ .then(response => {
158
+ if (!response.ok) {
159
+ return response.text().then(text => {
160
+ throw new Error(
161
+ `Token fetch failed: ${response.status} ${response.statusText} - ${text}`
162
+ );
163
+ });
164
+ }
165
+ return response.json();
166
+ })
167
+ .then(token => {
168
+ sessionStorage.setItem('LOOKER_TEST_TOKEN', JSON.stringify(token));
169
+ return token;
170
+ });
171
+ },
172
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
173
+ process.env.LOOKER_CLIENT_ID!,
174
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
175
+ process.env.LOOKER_CLIENT_SECRET!,
176
+ BASE_URL
177
+ );
178
+
179
+ const token = await page.evaluate(() => {
180
+ return JSON.parse(sessionStorage.getItem('LOOKER_TEST_TOKEN') || 'null');
181
+ });
182
+
183
+ if (token) {
184
+ await page.setExtraHTTPHeaders({
185
+ Authorization: `Bearer ${token.access_token}`,
186
+ });
187
+ } else {
188
+ throw new Error('Token injection failed: Session storage empty');
189
+ }
190
+
191
+ // Reload to pick up the token and headers
192
+ await page.reload({ waitUntil: ['domcontentloaded', 'networkidle0'] });
193
+
194
+ // Wait for app to load
195
+ try {
196
+ await page.waitForSelector('input[aria-label="sdk language selector"]', {
197
+ timeout: 30000,
198
+ });
199
+ } catch (e) {
200
+ const title = await page.title();
201
+ const url = await page.url();
202
+ // eslint-disable-next-line no-console
203
+ console.warn(`App not found.\nURL: ${url}\nTitle: ${title}`);
204
+ }
205
+ } catch (error) {
206
+ // eslint-disable-next-line no-console
207
+ console.error('Failed to inject token:', error);
208
+ }
209
+ };
210
+
55
211
  export const getSpecKey = async (): Promise<string> => {
56
212
  const specSelectorHandle = await page.$('input[aria-label="spec selector"]');
57
213
  const specKey = await page.evaluate(e => e.value, specSelectorHandle);
58
214
  return specKey;
59
215
  };
216
+
217
+ export const ensureSdkSelected = async (language: string): Promise<void> => {
218
+ const selector = `input[aria-label="sdk language selector"][value="${language}"]`;
219
+ const isSelected = await page.$(selector);
220
+ if (!isSelected) {
221
+ const input = await page.$('input[aria-label="sdk language selector"]');
222
+ if (input) {
223
+ await input.click();
224
+ try {
225
+ const option = await page.waitForXPath(
226
+ `//li[contains(., "${language}")]`,
227
+ { timeout: 5000 }
228
+ );
229
+ if (option) {
230
+ await option.click();
231
+ }
232
+ } catch (e) {
233
+ // eslint-disable-next-line no-console
234
+ console.error(`Failed to find SDK option for ${language}`, e);
235
+ }
236
+ // Wait for selection to apply
237
+ await page.waitForFunction(
238
+ (selector: string, lang: string) => {
239
+ const input = document.querySelector(selector) as HTMLInputElement;
240
+ return input?.value === lang;
241
+ },
242
+ {},
243
+ 'input[aria-label="sdk language selector"]',
244
+ language
245
+ );
246
+ } else {
247
+ // eslint-disable-next-line no-console
248
+ console.error('SDK selector input not found');
249
+ }
250
+ }
251
+ };
@@ -29,7 +29,8 @@ module.exports = {
29
29
  ...base,
30
30
  rootDir: '../..',
31
31
  preset: 'jest-puppeteer',
32
- setupFilesAfterEnv: ['expect-puppeteer'],
32
+ testEnvironment: 'jest-environment-puppeteer',
33
+ setupFilesAfterEnv: [...base.setupFilesAfterEnv, 'expect-puppeteer'],
33
34
  launch: {
34
35
  // `headless:false` and `slowMo:250` can be useful for "test-watch" usage
35
36
  headless: true,
@@ -25,20 +25,29 @@ var StandaloneApiExplorer = _ref => {
25
25
  var location = (0, _reactRouter.useLocation)();
26
26
  var oauthReturn = location.pathname === "/".concat(_utils.oAuthPath);
27
27
  var sdk = browserAdaptor.sdk;
28
- var canLogin = sdk.authSession.settings.authIsConfigured() && !sdk.authSession.isAuthenticated() && !oauthReturn;
28
+ var [hasToken, setHasToken] = (0, _react.useState)(sdk.authSession.isAuthenticated());
29
+ var canLogin = sdk.authSession.settings.authIsConfigured() && !sdk.authSession.isAuthenticated() && !oauthReturn && !hasToken;
29
30
  (0, _react.useEffect)(() => {
30
- var login = function () {
31
- var _ref2 = _asyncToGenerator(function* () {
32
- return yield browserAdaptor.login();
33
- });
34
- return function login() {
35
- return _ref2.apply(this, arguments);
36
- };
37
- }();
38
- if (canLogin) {
39
- login();
31
+ var token = sessionStorage.getItem('LOOKER_TEST_TOKEN');
32
+ if (token) {
33
+ var session = sdk.authSession;
34
+ var tokenObj = JSON.parse(token);
35
+ session.activeToken.setToken(tokenObj);
36
+ setHasToken(true);
37
+ } else {
38
+ var login = function () {
39
+ var _ref2 = _asyncToGenerator(function* () {
40
+ return yield browserAdaptor.login();
41
+ });
42
+ return function login() {
43
+ return _ref2.apply(this, arguments);
44
+ };
45
+ }();
46
+ if (canLogin) {
47
+ login();
48
+ }
40
49
  }
41
- }, []);
50
+ }, [browserAdaptor, canLogin, sdk.authSession]);
42
51
  var {
43
52
  looker_url
44
53
  } = sdk.authSession.settings.getStoredConfig();
@@ -1 +1 @@
1
- {"version":3,"file":"StandaloneApiExplorer.js","names":["_react","_interopRequireWildcard","require","_runIt","_extensionUtils","_reactRedux","_reactRouter","_ApiExplorer","_state","_utils","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","StandaloneApiExplorer","_ref","headless","browserAdaptor","useState","ApixAdaptor","initRunItSdk","window","origin","location","useLocation","oauthReturn","pathname","concat","oAuthPath","sdk","canLogin","authSession","settings","authIsConfigured","isAuthenticated","useEffect","login","_ref2","looker_url","getStoredConfig","createElement","Provider","store","RunItProvider","basePath","Loader","themeOverrides","message","Fragment","OAuthScene","adaptor","ApiExplorer","exports"],"sources":["../src/StandaloneApiExplorer.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React, { useEffect, useState } from 'react';\nimport { RunItProvider, initRunItSdk } from '@looker/run-it';\nimport type { OAuthConfigProvider } from '@looker/extension-utils';\nimport { OAuthScene } from '@looker/extension-utils';\nimport { Provider } from 'react-redux';\nimport { useLocation } from 'react-router';\n\nimport { ApiExplorer } from './ApiExplorer';\nimport { store } from './state';\nimport { ApixAdaptor, oAuthPath } from './utils';\nimport { Loader } from './components';\n\nexport interface StandaloneApiExplorerProps {\n headless?: boolean;\n versionsUrl: string;\n}\n\nexport const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({\n headless = false,\n}) => {\n const [browserAdaptor] = useState(\n new ApixAdaptor(initRunItSdk(), window.origin)\n );\n const location = useLocation();\n const oauthReturn = location.pathname === `/${oAuthPath}`;\n const sdk = browserAdaptor.sdk;\n const canLogin =\n (sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&\n !sdk.authSession.isAuthenticated() &&\n !oauthReturn;\n\n useEffect(() => {\n const login = async () => await browserAdaptor.login();\n if (canLogin) {\n login();\n }\n }, []);\n\n const { looker_url } = (\n sdk.authSession.settings as OAuthConfigProvider\n ).getStoredConfig();\n\n return (\n <Provider store={store}>\n <RunItProvider basePath=\"/api/4.0\">\n {canLogin ? (\n <Loader\n themeOverrides={browserAdaptor.themeOverrides()}\n message={`Configuration found. Logging into ${looker_url}`}\n />\n ) : (\n <>\n {oauthReturn ? (\n <OAuthScene adaptor={browserAdaptor} />\n ) : (\n <ApiExplorer adaptor={browserAdaptor} headless={headless} />\n )}\n </>\n )}\n </RunItProvider>\n </Provider>\n );\n};\n"],"mappings":";;;;;;AA2BA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAAsC,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,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E,CAAC;EAEN,IAAM;IAAEE;EAAW,CAAC,GAClBT,GAAG,CAACE,WAAW,CAACC,QAAQ,CACxBO,eAAe,CAAC,CAAC;EAEnB,OACE/E,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAAC3E,WAAA,CAAA4E,QAAQ;IAACC,KAAK,EAAEA;EAAM,GACrBlF,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAAC7E,MAAA,CAAAgF,aAAa;IAACC,QAAQ,EAAC;EAAU,GAC/Bd,QAAQ,GACPtE,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAACtE,WAAA,CAAA2E,MAAM;IACLC,cAAc,EAAE7B,cAAc,CAAC6B,cAAc,CAAC,CAAE;IAChDC,OAAO,uCAAApB,MAAA,CAAuCW,UAAU;EAAG,CAC5D,CAAC,GAEF9E,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAAAhF,MAAA,CAAAiB,OAAA,CAAAuE,QAAA,QACGvB,WAAW,GACVjE,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAAC5E,eAAA,CAAAqF,UAAU;IAACC,OAAO,EAAEjC;EAAe,CAAE,CAAC,GAEvCzD,MAAA,CAAAiB,OAAA,CAAA+D,aAAA,CAACzE,YAAA,CAAAoF,WAAW;IAACD,OAAO,EAAEjC,cAAe;IAACD,QAAQ,EAAEA;EAAS,CAAE,CAE7D,CAES,CACP,CAAC;AAEf,CAAC;AAACoC,OAAA,CAAAtC,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"file":"StandaloneApiExplorer.js","names":["_react","_interopRequireWildcard","require","_runIt","_extensionUtils","_reactRedux","_reactRouter","_ApiExplorer","_state","_utils","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","StandaloneApiExplorer","_ref","headless","browserAdaptor","useState","ApixAdaptor","initRunItSdk","window","origin","location","useLocation","oauthReturn","pathname","concat","oAuthPath","sdk","hasToken","setHasToken","authSession","isAuthenticated","canLogin","settings","authIsConfigured","useEffect","token","sessionStorage","getItem","session","tokenObj","JSON","parse","activeToken","setToken","login","_ref2","looker_url","getStoredConfig","createElement","Provider","store","RunItProvider","basePath","Loader","themeOverrides","message","Fragment","OAuthScene","adaptor","ApiExplorer","exports"],"sources":["../src/StandaloneApiExplorer.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React, { useEffect, useState } from 'react';\nimport { RunItProvider, initRunItSdk } from '@looker/run-it';\nimport type { OAuthConfigProvider } from '@looker/extension-utils';\nimport { OAuthScene } from '@looker/extension-utils';\nimport { Provider } from 'react-redux';\nimport { useLocation } from 'react-router';\n\nimport { ApiExplorer } from './ApiExplorer';\nimport { store } from './state';\nimport { ApixAdaptor, oAuthPath } from './utils';\nimport { Loader } from './components';\n\nexport interface StandaloneApiExplorerProps {\n headless?: boolean;\n versionsUrl: string;\n}\n\nexport const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({\n headless = false,\n}) => {\n const [browserAdaptor] = useState(\n new ApixAdaptor(initRunItSdk(), window.origin)\n );\n const location = useLocation();\n const oauthReturn = location.pathname === `/${oAuthPath}`;\n const sdk = browserAdaptor.sdk;\n const [hasToken, setHasToken] = useState(sdk.authSession.isAuthenticated());\n\n const canLogin =\n (sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&\n !sdk.authSession.isAuthenticated() &&\n !oauthReturn &&\n !hasToken;\n\n useEffect(() => {\n const token = sessionStorage.getItem('LOOKER_TEST_TOKEN');\n if (token) {\n const session = sdk.authSession as any;\n const tokenObj = JSON.parse(token);\n session.activeToken.setToken(tokenObj);\n setHasToken(true);\n } else {\n const login = async () => await browserAdaptor.login();\n if (canLogin) {\n login();\n }\n }\n }, [browserAdaptor, canLogin, sdk.authSession]);\n\n const { looker_url } = (\n sdk.authSession.settings as OAuthConfigProvider\n ).getStoredConfig();\n\n return (\n <Provider store={store}>\n <RunItProvider basePath=\"/api/4.0\">\n {canLogin ? (\n <Loader\n themeOverrides={browserAdaptor.themeOverrides()}\n message={`Configuration found. Logging into ${looker_url}`}\n />\n ) : (\n <>\n {oauthReturn ? (\n <OAuthScene adaptor={browserAdaptor} />\n ) : (\n <ApiExplorer adaptor={browserAdaptor} headless={headless} />\n )}\n </>\n )}\n </RunItProvider>\n </Provider>\n );\n};\n"],"mappings":";;;;;;AA2BA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,G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,GAC/BrB,QAAQ,GACP1E,MAAA,CAAAiB,OAAA,CAAA0E,aAAA,CAACjF,WAAA,CAAAsF,MAAM;IACLC,cAAc,EAAExC,cAAc,CAACwC,cAAc,CAAC,CAAE;IAChDC,OAAO,uCAAA/B,MAAA,CAAuCsB,UAAU;EAAG,CAC5D,CAAC,GAEFzF,MAAA,CAAAiB,OAAA,CAAA0E,aAAA,CAAA3F,MAAA,CAAAiB,OAAA,CAAAkF,QAAA,QACGlC,WAAW,GACVjE,MAAA,CAAAiB,OAAA,CAAA0E,aAAA,CAACvF,eAAA,CAAAgG,UAAU;IAACC,OAAO,EAAE5C;EAAe,CAAE,CAAC,GAEvCzD,MAAA,CAAAiB,OAAA,CAAA0E,aAAA,CAACpF,YAAA,CAAA+F,WAAW;IAACD,OAAO,EAAE5C,cAAe;IAACD,QAAQ,EAAEA;EAAS,CAAE,CAE7D,CAES,CACP,CAAC;AAEf,CAAC;AAAC+C,OAAA,CAAAjD,qBAAA,GAAAA,qBAAA"}
@@ -17,20 +17,29 @@ export var StandaloneApiExplorer = _ref => {
17
17
  var location = useLocation();
18
18
  var oauthReturn = location.pathname === "/".concat(oAuthPath);
19
19
  var sdk = browserAdaptor.sdk;
20
- var canLogin = sdk.authSession.settings.authIsConfigured() && !sdk.authSession.isAuthenticated() && !oauthReturn;
20
+ var [hasToken, setHasToken] = useState(sdk.authSession.isAuthenticated());
21
+ var canLogin = sdk.authSession.settings.authIsConfigured() && !sdk.authSession.isAuthenticated() && !oauthReturn && !hasToken;
21
22
  useEffect(() => {
22
- var login = function () {
23
- var _ref2 = _asyncToGenerator(function* () {
24
- return yield browserAdaptor.login();
25
- });
26
- return function login() {
27
- return _ref2.apply(this, arguments);
28
- };
29
- }();
30
- if (canLogin) {
31
- login();
23
+ var token = sessionStorage.getItem('LOOKER_TEST_TOKEN');
24
+ if (token) {
25
+ var session = sdk.authSession;
26
+ var tokenObj = JSON.parse(token);
27
+ session.activeToken.setToken(tokenObj);
28
+ setHasToken(true);
29
+ } else {
30
+ var login = function () {
31
+ var _ref2 = _asyncToGenerator(function* () {
32
+ return yield browserAdaptor.login();
33
+ });
34
+ return function login() {
35
+ return _ref2.apply(this, arguments);
36
+ };
37
+ }();
38
+ if (canLogin) {
39
+ login();
40
+ }
32
41
  }
33
- }, []);
42
+ }, [browserAdaptor, canLogin, sdk.authSession]);
34
43
  var {
35
44
  looker_url
36
45
  } = sdk.authSession.settings.getStoredConfig();
@@ -1 +1 @@
1
- {"version":3,"file":"StandaloneApiExplorer.js","names":["React","useEffect","useState","RunItProvider","initRunItSdk","OAuthScene","Provider","useLocation","ApiExplorer","store","ApixAdaptor","oAuthPath","Loader","StandaloneApiExplorer","_ref","headless","browserAdaptor","window","origin","location","oauthReturn","pathname","concat","sdk","canLogin","authSession","settings","authIsConfigured","isAuthenticated","login","_ref2","_asyncToGenerator","apply","arguments","looker_url","getStoredConfig","createElement","basePath","themeOverrides","message","Fragment","adaptor"],"sources":["../../src/StandaloneApiExplorer.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React, { useEffect, useState } from 'react';\nimport { RunItProvider, initRunItSdk } from '@looker/run-it';\nimport type { OAuthConfigProvider } from '@looker/extension-utils';\nimport { OAuthScene } from '@looker/extension-utils';\nimport { Provider } from 'react-redux';\nimport { useLocation } from 'react-router';\n\nimport { ApiExplorer } from './ApiExplorer';\nimport { store } from './state';\nimport { ApixAdaptor, oAuthPath } from './utils';\nimport { Loader } from './components';\n\nexport interface StandaloneApiExplorerProps {\n headless?: boolean;\n versionsUrl: string;\n}\n\nexport const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({\n headless = false,\n}) => {\n const [browserAdaptor] = useState(\n new ApixAdaptor(initRunItSdk(), window.origin)\n );\n const location = useLocation();\n const oauthReturn = location.pathname === `/${oAuthPath}`;\n const sdk = browserAdaptor.sdk;\n const canLogin =\n (sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&\n !sdk.authSession.isAuthenticated() &&\n !oauthReturn;\n\n useEffect(() => {\n const login = async () => await browserAdaptor.login();\n if (canLogin) {\n login();\n }\n }, []);\n\n const { looker_url } = (\n sdk.authSession.settings as OAuthConfigProvider\n ).getStoredConfig();\n\n return (\n <Provider store={store}>\n <RunItProvider basePath=\"/api/4.0\">\n {canLogin ? (\n <Loader\n themeOverrides={browserAdaptor.themeOverrides()}\n message={`Configuration found. Logging into ${looker_url}`}\n />\n ) : (\n <>\n {oauthReturn ? (\n <OAuthScene adaptor={browserAdaptor} />\n ) : (\n <ApiExplorer adaptor={browserAdaptor} headless={headless} />\n )}\n </>\n )}\n </RunItProvider>\n </Provider>\n );\n};\n"],"mappings":";;AA2BA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,EAAEC,YAAY,QAAQ,gBAAgB;AAE5D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,QAAQ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;EAAM,GACrBT,KAAA,CAAAoC,aAAA,CAACjC,aAAa;IAACkC,QAAQ,EAAC;EAAU,GAC/Bb,QAAQ,GACPxB,KAAA,CAAAoC,aAAA,CAACxB,MAAM;IACL0B,cAAc,EAAEtB,cAAc,CAACsB,cAAc,CAAC,CAAE;IAChDC,OAAO,uCAAAjB,MAAA,CAAuCY,UAAU;EAAG,CAC5D,CAAC,GAEFlC,KAAA,CAAAoC,aAAA,CAAApC,KAAA,CAAAwC,QAAA,QACGpB,WAAW,GACVpB,KAAA,CAAAoC,aAAA,CAAC/B,UAAU;IAACoC,OAAO,EAAEzB;EAAe,CAAE,CAAC,GAEvChB,KAAA,CAAAoC,aAAA,CAAC5B,WAAW;IAACiC,OAAO,EAAEzB,cAAe;IAACD,QAAQ,EAAEA;EAAS,CAAE,CAE7D,CAES,CACP,CAAC;AAEf,CAAC"}
1
+ {"version":3,"file":"StandaloneApiExplorer.js","names":["React","useEffect","useState","RunItProvider","initRunItSdk","OAuthScene","Provider","useLocation","ApiExplorer","store","ApixAdaptor","oAuthPath","Loader","StandaloneApiExplorer","_ref","headless","browserAdaptor","window","origin","location","oauthReturn","pathname","concat","sdk","hasToken","setHasToken","authSession","isAuthenticated","canLogin","settings","authIsConfigured","token","sessionStorage","getItem","session","tokenObj","JSON","parse","activeToken","setToken","login","_ref2","_asyncToGenerator","apply","arguments","looker_url","getStoredConfig","createElement","basePath","themeOverrides","message","Fragment","adaptor"],"sources":["../../src/StandaloneApiExplorer.tsx"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { FC } from 'react';\nimport React, { useEffect, useState } from 'react';\nimport { RunItProvider, initRunItSdk } from '@looker/run-it';\nimport type { OAuthConfigProvider } from '@looker/extension-utils';\nimport { OAuthScene } from '@looker/extension-utils';\nimport { Provider } from 'react-redux';\nimport { useLocation } from 'react-router';\n\nimport { ApiExplorer } from './ApiExplorer';\nimport { store } from './state';\nimport { ApixAdaptor, oAuthPath } from './utils';\nimport { Loader } from './components';\n\nexport interface StandaloneApiExplorerProps {\n headless?: boolean;\n versionsUrl: string;\n}\n\nexport const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({\n headless = false,\n}) => {\n const [browserAdaptor] = useState(\n new ApixAdaptor(initRunItSdk(), window.origin)\n );\n const location = useLocation();\n const oauthReturn = location.pathname === `/${oAuthPath}`;\n const sdk = browserAdaptor.sdk;\n const [hasToken, setHasToken] = useState(sdk.authSession.isAuthenticated());\n\n const canLogin =\n (sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&\n !sdk.authSession.isAuthenticated() &&\n !oauthReturn &&\n !hasToken;\n\n useEffect(() => {\n const token = sessionStorage.getItem('LOOKER_TEST_TOKEN');\n if (token) {\n const session = sdk.authSession as any;\n const tokenObj = JSON.parse(token);\n session.activeToken.setToken(tokenObj);\n setHasToken(true);\n } else {\n const login = async () => await browserAdaptor.login();\n if (canLogin) {\n login();\n }\n }\n }, [browserAdaptor, canLogin, sdk.authSession]);\n\n const { looker_url } = (\n sdk.authSession.settings as OAuthConfigProvider\n ).getStoredConfig();\n\n return (\n <Provider store={store}>\n <RunItProvider basePath=\"/api/4.0\">\n {canLogin ? (\n <Loader\n themeOverrides={browserAdaptor.themeOverrides()}\n message={`Configuration found. Logging into ${looker_url}`}\n />\n ) : (\n <>\n {oauthReturn ? (\n <OAuthScene adaptor={browserAdaptor} />\n ) : (\n <ApiExplorer adaptor={browserAdaptor} headless={headless} />\n )}\n </>\n )}\n </RunItProvider>\n </Provider>\n );\n};\n"],"mappings":";;AA2BA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,aAAa,EAAEC,YAAY,QAAQ,gBAAgB;AAE5D,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,WAAW,QAAQ,cAAc;AAE1C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,KAAK,QAAQ,SAAS;AAC/B,SAASC,WAAW,EAAEC,SAAS,QAAQ,SAAS;AAChD,SAASC,MAAM,QAAQ,cAAc;AAOrC,OAAO,IAAMC,qBAAqD,GAAGC,IAAA,IAE/D;EAAA,IAFgE;IACpEC,QAAQ,GAAG;EACb,CAAC,GAAAD,IAAA;EACC,IAAM,CAACE,cAAc,CAAC,GAAGd,QAAQ,CAC/B,IAAIQ,WAAW,CAACN,YAAY,CAAC,CAAC,EAAEa,MAAM,CAACC,MAAM,CAC/C,CAAC;EACD,IAAMC,QAAQ,GAAGZ,WAAW,CAAC,CAAC;EAC9B,IAAMa,WAAW,GAAGD,QAAQ,CAACE,QAAQ,SAAAC,MAAA,CAASX,SAAS,CAAE;EACzD,IAAMY,GAAG,GAAGP,cAAc,CAACO,GAAG;EAC9B,IAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGvB,QAAQ,CAACqB,GAAG,CAACG,WAAW,CAACC,eAAe,CAAC,CAAC,CAAC;EA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5B,MAAA,CAAuCuB,UAAU;EAAG,CAC5D,CAAC,GAEF7C,KAAA,CAAA+C,aAAA,CAAA/C,KAAA,CAAAmD,QAAA,QACG/B,WAAW,GACVpB,KAAA,CAAA+C,aAAA,CAAC1C,UAAU;IAAC+C,OAAO,EAAEpC;EAAe,CAAE,CAAC,GAEvChB,KAAA,CAAA+C,aAAA,CAACvC,WAAW;IAAC4C,OAAO,EAAEpC,cAAe;IAACD,QAAQ,EAAEA;EAAS,CAAE,CAE7D,CAES,CACP,CAAC;AAEf,CAAC"}
@@ -6,13 +6,18 @@ export var DocRequestBody = _ref => {
6
6
  method,
7
7
  api
8
8
  } = _ref;
9
- var bodies = method.bodyParams;
9
+ var bodies = method.isFormUrlEncoded ? method.queryParams : method.bodyParams;
10
10
  if (bodies.length === 0) return React.createElement(React.Fragment, null);
11
- var header = bodies.length > 1 ? 'Request bodies' : 'Request body';
11
+ var header = method.isFormUrlEncoded ? 'Form parameters' : bodies.length > 1 ? 'Request bodies' : 'Request body';
12
12
  return React.createElement(CollapserCard, {
13
13
  id: "bodies",
14
14
  heading: header
15
- }, React.createElement(React.Fragment, null, bodies.map(body => React.createElement(ExploreType, {
15
+ }, React.createElement(React.Fragment, null, method.isFormUrlEncoded ? React.createElement("div", {
16
+ style: {
17
+ paddingBottom: '0.5rem',
18
+ color: '#666'
19
+ }
20
+ }, "application/x-www-form-urlencoded") : null, bodies.map(body => React.createElement(ExploreType, {
16
21
  api: api,
17
22
  type: body.type,
18
23
  open: false,
@@ -1 +1 @@
1
- {"version":3,"file":"DocRequestBody.js","names":["React","CollapserCard","ExploreType","DocRequestBody","_ref","method","api","bodies","bodyParams","length","createElement","Fragment","header","id","heading","map","body","type","open","key","concat","name"],"sources":["../../../../../src/scenes/MethodScene/components/DocRequestBody.tsx"],"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 type { ApiModel, IMethod } from '@looker/sdk-codegen';\nimport { CollapserCard } from '@looker/run-it';\nimport { ExploreType } from '../../../components';\n\ninterface DocRequestBodyProps {\n method: IMethod;\n api: ApiModel;\n}\n\n/**\n * If a method has request body parameters, display them\n * @param method to document\n */\nexport const DocRequestBody: FC<DocRequestBodyProps> = ({ method, api }) => {\n const bodies = method.bodyParams;\n if (bodies.length === 0) return <></>;\n const header = bodies.length > 1 ? 'Request bodies' : 'Request body';\n\n return (\n <CollapserCard id=\"bodies\" heading={header}>\n <>\n {bodies.map(body => (\n <ExploreType\n api={api}\n type={body.type}\n open={false}\n key={`body.${body.name}`}\n />\n ))}\n </>\n </CollapserCard>\n );\n};\n"],"mappings":"AA0BA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,WAAW,QAAQ,qBAAqB;AAWjD,OAAO,IAAMC,cAAuC,GAAGC,IAAA,IAAqB;EAAA,IAApB;IAAEC,MAAM;IAAEC;EAAI,CAAC,GAAAF,IAAA;EACrE,IAAMG,MAAM,GAAGF,MAAM,CAACG,UAAU;EAChC,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOT,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,MAAI,CAAC;EACrC,IAAMC,MAAM,GAAGL,MAAM,CAACE,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,cAAc;EAEpE,OACET,KAAA,CAAAU,aAAA,CAACT,aAAa;IAACY,EAAE,EAAC,QAAQ;IAACC,OAAO,EAAEF;EAAO,GACzCZ,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,QACGJ,MAAM,CAACQ,GAAG,CAACC,IAAI,IACdhB,KAAA,CAAAU,aAAA,CAACR,WAAW;IACVI,GAAG,EAAEA,GAAI;IACTW,IAAI,EAAED,IAAI,CAACC,IAAK;IAChBC,IAAI,EAAE,KAAM;IACZC,GAAG,UAAAC,MAAA,CAAUJ,IAAI,CAACK,IAAI;EAAG,CAC1B,CACF,CACD,CACW,CAAC;AAEpB,CAAC"}
1
+ {"version":3,"file":"DocRequestBody.js","names":["React","CollapserCard","ExploreType","DocRequestBody","_ref","method","api","bodies","isFormUrlEncoded","queryParams","bodyParams","length","createElement","Fragment","header","id","heading","style","paddingBottom","color","map","body","type","open","key","concat","name"],"sources":["../../../../../src/scenes/MethodScene/components/DocRequestBody.tsx"],"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 type { ApiModel, IMethod } from '@looker/sdk-codegen';\nimport { CollapserCard } from '@looker/run-it';\nimport { ExploreType } from '../../../components';\n\ninterface DocRequestBodyProps {\n method: IMethod;\n api: ApiModel;\n}\n\n/**\n * If a method has request body parameters, display them\n * @param method to document\n */\nexport const DocRequestBody: FC<DocRequestBodyProps> = ({ method, api }) => {\n const bodies = method.isFormUrlEncoded\n ? method.queryParams\n : method.bodyParams;\n if (bodies.length === 0) return <></>;\n const header = method.isFormUrlEncoded\n ? 'Form parameters'\n : bodies.length > 1\n ? 'Request bodies'\n : 'Request body';\n\n return (\n <CollapserCard id=\"bodies\" heading={header}>\n <>\n {method.isFormUrlEncoded ? (\n <div style={{ paddingBottom: '0.5rem', color: '#666' }}>\n application/x-www-form-urlencoded\n </div>\n ) : null}\n {bodies.map(body => (\n <ExploreType\n api={api}\n type={body.type}\n open={false}\n key={`body.${body.name}`}\n />\n ))}\n </>\n </CollapserCard>\n );\n};\n"],"mappings":"AA0BA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,WAAW,QAAQ,qBAAqB;AAWjD,OAAO,IAAMC,cAAuC,GAAGC,IAAA,IAAqB;EAAA,IAApB;IAAEC,MAAM;IAAEC;EAAI,CAAC,GAAAF,IAAA;EACrE,IAAMG,MAAM,GAAGF,MAAM,CAACG,gBAAgB,GAClCH,MAAM,CAACI,WAAW,GAClBJ,MAAM,CAACK,UAAU;EACrB,IAAIH,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE,OAAOX,KAAA,CAAAY,aAAA,CAAAZ,KAAA,CAAAa,QAAA,MAAI,CAAC;EACrC,IAAMC,MAAM,GAAGT,MAAM,CAACG,gBAAgB,GAClC,iBAAiB,GACjBD,MAAM,CAACI,MAAM,GAAG,CAAC,GACjB,gBAAgB,GAChB,cAAc;EAElB,OACEX,KAAA,CAAAY,aAAA,CAACX,aAAa;IAACc,EAAE,EAAC,QAAQ;IAACC,OAAO,EAAEF;EAAO,GACzCd,KAAA,CAAAY,aAAA,CAAAZ,KAAA,CAAAa,QAAA,QACGR,MAAM,CAACG,gBAAgB,GACtBR,KAAA,CAAAY,aAAA;IAAKK,KAAK,EAAE;MAAEC,aAAa,EAAE,QAAQ;MAAEC,KAAK,EAAE;IAAO;EAAE,GAAC,mCAEnD,CAAC,GACJ,IAAI,EACPZ,MAAM,CAACa,GAAG,CAACC,IAAI,IACdrB,KAAA,CAAAY,aAAA,CAACV,WAAW;IACVI,GAAG,EAAEA,GAAI;IACTgB,IAAI,EAAED,IAAI,CAACC,IAAK;IAChBC,IAAI,EAAE,KAAM;IACZC,GAAG,UAAAC,MAAA,CAAUJ,IAAI,CAACK,IAAI;EAAG,CAC1B,CACF,CACD,CACW,CAAC;AAEpB,CAAC"}
@@ -13,13 +13,18 @@ var DocRequestBody = _ref => {
13
13
  method,
14
14
  api
15
15
  } = _ref;
16
- var bodies = method.bodyParams;
16
+ var bodies = method.isFormUrlEncoded ? method.queryParams : method.bodyParams;
17
17
  if (bodies.length === 0) return _react.default.createElement(_react.default.Fragment, null);
18
- var header = bodies.length > 1 ? 'Request bodies' : 'Request body';
18
+ var header = method.isFormUrlEncoded ? 'Form parameters' : bodies.length > 1 ? 'Request bodies' : 'Request body';
19
19
  return _react.default.createElement(_runIt.CollapserCard, {
20
20
  id: "bodies",
21
21
  heading: header
22
- }, _react.default.createElement(_react.default.Fragment, null, bodies.map(body => _react.default.createElement(_components.ExploreType, {
22
+ }, _react.default.createElement(_react.default.Fragment, null, method.isFormUrlEncoded ? _react.default.createElement("div", {
23
+ style: {
24
+ paddingBottom: '0.5rem',
25
+ color: '#666'
26
+ }
27
+ }, "application/x-www-form-urlencoded") : null, bodies.map(body => _react.default.createElement(_components.ExploreType, {
23
28
  api: api,
24
29
  type: body.type,
25
30
  open: false,
@@ -1 +1 @@
1
- {"version":3,"file":"DocRequestBody.js","names":["_react","_interopRequireDefault","require","_runIt","_components","obj","__esModule","default","DocRequestBody","_ref","method","api","bodies","bodyParams","length","createElement","Fragment","header","CollapserCard","id","heading","map","body","ExploreType","type","open","key","concat","name","exports"],"sources":["../../../../src/scenes/MethodScene/components/DocRequestBody.tsx"],"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 type { ApiModel, IMethod } from '@looker/sdk-codegen';\nimport { CollapserCard } from '@looker/run-it';\nimport { ExploreType } from '../../../components';\n\ninterface DocRequestBodyProps {\n method: IMethod;\n api: ApiModel;\n}\n\n/**\n * If a method has request body parameters, display them\n * @param method to document\n */\nexport const DocRequestBody: FC<DocRequestBodyProps> = ({ method, api }) => {\n const bodies = method.bodyParams;\n if (bodies.length === 0) return <></>;\n const header = bodies.length > 1 ? 'Request bodies' : 'Request body';\n\n return (\n <CollapserCard id=\"bodies\" heading={header}>\n <>\n {bodies.map(body => (\n <ExploreType\n api={api}\n type={body.type}\n open={false}\n key={`body.${body.name}`}\n />\n ))}\n </>\n </CollapserCard>\n );\n};\n"],"mappings":";;;;;;AA0BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAAkD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAW3C,IAAMG,cAAuC,GAAGC,IAAA,IAAqB;EAAA,IAApB;IAAEC,MAAM;IAAEC;EAAI,CAAC,GAAAF,IAAA;EACrE,IAAMG,MAAM,GAAGF,MAAM,CAACG,UAAU;EAChC,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOd,MAAA,CAAAO,OAAA,CAAAQ,aAAA,CAAAf,MAAA,CAAAO,OAAA,CAAAS,QAAA,MAAI,CAAC;EACrC,IAAMC,MAAM,GAAGL,MAAM,CAACE,MAAM,GAAG,CAAC,GAAG,gBAAgB,GAAG,cAAc;EAEpE,OACEd,MAAA,CAAAO,OAAA,CAAAQ,aAAA,CAACZ,MAAA,CAAAe,aAAa;IAACC,EAAE,EAAC,QAAQ;IAACC,OAAO,EAAEH;EAAO,GACzCjB,MAAA,CAAAO,OAAA,CAAAQ,aAAA,CAAAf,MAAA,CAAAO,OAAA,CAAAS,QAAA,QACGJ,MAAM,CAACS,GAAG,CAACC,IAAI,IACdtB,MAAA,CAAAO,OAAA,CAAAQ,aAAA,CAACX,WAAA,CAAAmB,WAAW;IACVZ,GAAG,EAAEA,GAAI;IACTa,IAAI,EAAEF,IAAI,CAACE,IAAK;IAChBC,IAAI,EAAE,KAAM;IACZC,GAAG,UAAAC,MAAA,CAAUL,IAAI,CAACM,IAAI;EAAG,CAC1B,CACF,CACD,CACW,CAAC;AAEpB,CAAC;AAACC,OAAA,CAAArB,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"file":"DocRequestBody.js","names":["_react","_interopRequireDefault","require","_runIt","_components","obj","__esModule","default","DocRequestBody","_ref","method","api","bodies","isFormUrlEncoded","queryParams","bodyParams","length","createElement","Fragment","header","CollapserCard","id","heading","style","paddingBottom","color","map","body","ExploreType","type","open","key","concat","name","exports"],"sources":["../../../../src/scenes/MethodScene/components/DocRequestBody.tsx"],"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 type { ApiModel, IMethod } from '@looker/sdk-codegen';\nimport { CollapserCard } from '@looker/run-it';\nimport { ExploreType } from '../../../components';\n\ninterface DocRequestBodyProps {\n method: IMethod;\n api: ApiModel;\n}\n\n/**\n * If a method has request body parameters, display them\n * @param method to document\n */\nexport const DocRequestBody: FC<DocRequestBodyProps> = ({ method, api }) => {\n const bodies = method.isFormUrlEncoded\n ? method.queryParams\n : method.bodyParams;\n if (bodies.length === 0) return <></>;\n const header = method.isFormUrlEncoded\n ? 'Form parameters'\n : bodies.length > 1\n ? 'Request bodies'\n : 'Request body';\n\n return (\n <CollapserCard id=\"bodies\" heading={header}>\n <>\n {method.isFormUrlEncoded ? (\n <div style={{ paddingBottom: '0.5rem', color: '#666' }}>\n application/x-www-form-urlencoded\n </div>\n ) : null}\n {bodies.map(body => (\n <ExploreType\n api={api}\n type={body.type}\n open={false}\n key={`body.${body.name}`}\n />\n ))}\n </>\n </CollapserCard>\n );\n};\n"],"mappings":";;;;;;AA0BA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAAkD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAW3C,IAAMG,cAAuC,GAAGC,IAAA,IAAqB;EAAA,IAApB;IAAEC,MAAM;IAAEC;EAAI,CAAC,GAAAF,IAAA;EACrE,IAAMG,MAAM,GAAGF,MAAM,CAACG,gBAAgB,GAClCH,MAAM,CAACI,WAAW,GAClBJ,MAAM,CAACK,UAAU;EACrB,IAAIH,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE,OAAOhB,MAAA,CAAAO,OAAA,CAAAU,aAAA,CAAAjB,MAAA,CAAAO,OAAA,CAAAW,QAAA,MAAI,CAAC;EACrC,IAAMC,MAAM,GAAGT,MAAM,CAACG,gBAAgB,GAClC,iBAAiB,GACjBD,MAAM,CAACI,MAAM,GAAG,CAAC,GACjB,gBAAgB,GAChB,cAAc;EAElB,OACEhB,MAAA,CAAAO,OAAA,CAAAU,aAAA,CAACd,MAAA,CAAAiB,aAAa;IAACC,EAAE,EAAC,QAAQ;IAACC,OAAO,EAAEH;EAAO,GACzCnB,MAAA,CAAAO,OAAA,CAAAU,aAAA,CAAAjB,MAAA,CAAAO,OAAA,CAAAW,QAAA,QACGR,MAAM,CAACG,gBAAgB,GACtBb,MAAA,CAAAO,OAAA,CAAAU,aAAA;IAAKM,KAAK,EAAE;MAAEC,aAAa,EAAE,QAAQ;MAAEC,KAAK,EAAE;IAAO;EAAE,GAAC,mCAEnD,CAAC,GACJ,IAAI,EACPb,MAAM,CAACc,GAAG,CAACC,IAAI,IACd3B,MAAA,CAAAO,OAAA,CAAAU,aAAA,CAACb,WAAA,CAAAwB,WAAW;IACVjB,GAAG,EAAEA,GAAI;IACTkB,IAAI,EAAEF,IAAI,CAACE,IAAK;IAChBC,IAAI,EAAE,KAAM;IACZC,GAAG,UAAAC,MAAA,CAAUL,IAAI,CAACM,IAAI;EAAG,CAC1B,CACF,CACD,CACW,CAAC;AAEpB,CAAC;AAACC,OAAA,CAAA1B,cAAA,GAAAA,cAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looker/api-explorer",
3
- "version": "0.9.81",
3
+ "version": "0.9.83",
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.27",
36
- "@looker/sdk-codegen-scripts": "21.5.38",
37
- "@looker/sdk-node": "26.0.0",
36
+ "@looker/sdk-codegen-scripts": "21.5.40",
37
+ "@looker/sdk-node": "26.4.0",
38
38
  "@styled-icons/styled-icon": "^10.6.3",
39
39
  "@testing-library/jest-dom": "5.16.5",
40
40
  "@testing-library/react": "12.1.5",
@@ -70,15 +70,15 @@
70
70
  "webpack-merge": "^5.7.3"
71
71
  },
72
72
  "dependencies": {
73
- "@looker/code-editor": "0.1.48",
73
+ "@looker/code-editor": "0.1.50",
74
74
  "@looker/components": "^5.0.3",
75
75
  "@looker/design-tokens": "^3.1.3",
76
- "@looker/extension-utils": "0.1.58",
76
+ "@looker/extension-utils": "0.1.60",
77
77
  "@looker/icons": "^1.5.21",
78
78
  "@looker/redux": "^0.0.1",
79
- "@looker/run-it": "0.9.81",
80
- "@looker/sdk": "26.0.0",
81
- "@looker/sdk-codegen": "21.10.3",
79
+ "@looker/run-it": "0.9.83",
80
+ "@looker/sdk": "26.4.0",
81
+ "@looker/sdk-codegen": "21.11.0",
82
82
  "@looker/sdk-rtl": "21.6.4",
83
83
  "@reduxjs/toolkit": "^1.9.3",
84
84
  "@styled-icons/material": "^10.47.0",
@@ -97,5 +97,5 @@
97
97
  "styled-components": "^5.3.1",
98
98
  "typed-redux-saga": "^1.5.0"
99
99
  },
100
- "gitHead": "bda3dc08ee839151fbaaf455c7f7b1c80cb57fba"
100
+ "gitHead": "4ad57362107ab0ed2c865876921136b8b7d77db4"
101
101
  }
@@ -51,17 +51,28 @@ export const StandaloneApiExplorer: FC<StandaloneApiExplorerProps> = ({
51
51
  const location = useLocation();
52
52
  const oauthReturn = location.pathname === `/${oAuthPath}`;
53
53
  const sdk = browserAdaptor.sdk;
54
+ const [hasToken, setHasToken] = useState(sdk.authSession.isAuthenticated());
55
+
54
56
  const canLogin =
55
57
  (sdk.authSession.settings as OAuthConfigProvider).authIsConfigured() &&
56
58
  !sdk.authSession.isAuthenticated() &&
57
- !oauthReturn;
59
+ !oauthReturn &&
60
+ !hasToken;
58
61
 
59
62
  useEffect(() => {
60
- const login = async () => await browserAdaptor.login();
61
- if (canLogin) {
62
- login();
63
+ const token = sessionStorage.getItem('LOOKER_TEST_TOKEN');
64
+ if (token) {
65
+ const session = sdk.authSession as any;
66
+ const tokenObj = JSON.parse(token);
67
+ session.activeToken.setToken(tokenObj);
68
+ setHasToken(true);
69
+ } else {
70
+ const login = async () => await browserAdaptor.login();
71
+ if (canLogin) {
72
+ login();
73
+ }
63
74
  }
64
- }, []);
75
+ }, [browserAdaptor, canLogin, sdk.authSession]);
65
76
 
66
77
  const { looker_url } = (
67
78
  sdk.authSession.settings as OAuthConfigProvider
@@ -39,13 +39,24 @@ interface DocRequestBodyProps {
39
39
  * @param method to document
40
40
  */
41
41
  export const DocRequestBody: FC<DocRequestBodyProps> = ({ method, api }) => {
42
- const bodies = method.bodyParams;
42
+ const bodies = method.isFormUrlEncoded
43
+ ? method.queryParams
44
+ : method.bodyParams;
43
45
  if (bodies.length === 0) return <></>;
44
- const header = bodies.length > 1 ? 'Request bodies' : 'Request body';
46
+ const header = method.isFormUrlEncoded
47
+ ? 'Form parameters'
48
+ : bodies.length > 1
49
+ ? 'Request bodies'
50
+ : 'Request body';
45
51
 
46
52
  return (
47
53
  <CollapserCard id="bodies" heading={header}>
48
54
  <>
55
+ {method.isFormUrlEncoded ? (
56
+ <div style={{ paddingBottom: '0.5rem', color: '#666' }}>
57
+ application/x-www-form-urlencoded
58
+ </div>
59
+ ) : null}
49
60
  {bodies.map(body => (
50
61
  <ExploreType
51
62
  api={api}
@@ -49,5 +49,30 @@ module.exports = merge(base, browser, {
49
49
  'Access-Control-Allow-Methods': '*',
50
50
  'Access-Control-Allow-Headers': '*',
51
51
  },
52
+ proxy: (() => {
53
+ const proxyTarget =
54
+ process.env.API_PROXY_TARGET ||
55
+ process.env.LOOKER_API_EXPLORER_URL ||
56
+ 'http://localhost:19999';
57
+ return {
58
+ '/api': {
59
+ target: proxyTarget,
60
+ changeOrigin: true,
61
+ secure: false,
62
+ onProxyReq: proxyReq => {
63
+ proxyReq.removeHeader('Origin');
64
+ proxyReq.removeHeader('Referer');
65
+ },
66
+ },
67
+ '/login': {
68
+ target: proxyTarget,
69
+ changeOrigin: true,
70
+ secure: false,
71
+ onProxyReq: proxyReq => {
72
+ proxyReq.removeHeader('Origin');
73
+ },
74
+ },
75
+ };
76
+ })(),
52
77
  },
53
78
  });