@looker/sdk-rtl 21.0.17 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/CSRFSession.d.ts +2 -2
  3. package/lib/CSRFSession.js.map +1 -1
  4. package/lib/apiMethods.d.ts +3 -3
  5. package/lib/apiMethods.js.map +1 -1
  6. package/lib/apiSettings.d.ts +1 -1
  7. package/lib/apiSettings.js.map +1 -1
  8. package/lib/authSession.d.ts +3 -3
  9. package/lib/authSession.js.map +1 -1
  10. package/lib/authToken.d.ts +1 -1
  11. package/lib/authToken.js.map +1 -1
  12. package/lib/baseTransport.d.ts +1 -1
  13. package/lib/baseTransport.js.map +1 -1
  14. package/lib/browserServices.d.ts +4 -4
  15. package/lib/browserServices.js.map +1 -1
  16. package/lib/browserSession.d.ts +2 -2
  17. package/lib/browserSession.js.map +1 -1
  18. package/lib/browserTransport.d.ts +4 -4
  19. package/lib/browserTransport.js +25 -7
  20. package/lib/browserTransport.js.map +1 -1
  21. package/lib/esm/CSRFSession.js.map +1 -1
  22. package/lib/esm/apiMethods.js.map +1 -1
  23. package/lib/esm/apiSettings.js.map +1 -1
  24. package/lib/esm/authSession.js.map +1 -1
  25. package/lib/esm/authToken.js.map +1 -1
  26. package/lib/esm/baseTransport.js.map +1 -1
  27. package/lib/esm/browserServices.js.map +1 -1
  28. package/lib/esm/browserSession.js.map +1 -1
  29. package/lib/esm/browserTransport.js +26 -7
  30. package/lib/esm/browserTransport.js.map +1 -1
  31. package/lib/esm/extensionSession.js.map +1 -1
  32. package/lib/esm/extensionTransport.js.map +1 -1
  33. package/lib/esm/oauthSession.js +2 -1
  34. package/lib/esm/oauthSession.js.map +1 -1
  35. package/lib/esm/paging.js +4 -0
  36. package/lib/esm/paging.js.map +1 -1
  37. package/lib/esm/proxySession.js.map +1 -1
  38. package/lib/esm/transport.js +22 -13
  39. package/lib/esm/transport.js.map +1 -1
  40. package/lib/extensionSession.d.ts +3 -3
  41. package/lib/extensionSession.js.map +1 -1
  42. package/lib/extensionTransport.d.ts +2 -2
  43. package/lib/extensionTransport.js.map +1 -1
  44. package/lib/oauthSession.d.ts +4 -4
  45. package/lib/oauthSession.js +2 -1
  46. package/lib/oauthSession.js.map +1 -1
  47. package/lib/paging.d.ts +2 -2
  48. package/lib/paging.js +4 -0
  49. package/lib/paging.js.map +1 -1
  50. package/lib/platformServices.d.ts +3 -3
  51. package/lib/proxySession.d.ts +2 -2
  52. package/lib/proxySession.js.map +1 -1
  53. package/lib/transport.d.ts +6 -3
  54. package/lib/transport.js +23 -13
  55. package/lib/transport.js.map +1 -1
  56. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [21.1.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.20...sdk-rtl-v21.1.0) (2021-10-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * closest path match for API Explorer ([#811](https://www.github.com/looker-open-source/sdk-codegen/issues/811)) ([45fd26f](https://www.github.com/looker-open-source/sdk-codegen/commit/45fd26fb0f325fa90edfec72f835ed3a79b9afeb))
14
+
15
+ ### [21.0.20](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.19...sdk-rtl-v21.0.20) (2021-09-01)
16
+
17
+
18
+ ### Features
19
+
20
+ * http response explorer for RunIt ([#800](https://www.github.com/looker-open-source/sdk-codegen/issues/800)) ([3f273ea](https://www.github.com/looker-open-source/sdk-codegen/commit/3f273ea7f849dafece8f4f5f60558021ecd41705))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * placate TypeScript 4.4 ([#809](https://www.github.com/looker-open-source/sdk-codegen/issues/809)) ([6509c17](https://www.github.com/looker-open-source/sdk-codegen/commit/6509c17da655be1fb7d51d0275b9e198aa6ae929))
26
+
27
+ ### [21.0.19](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.18...sdk-rtl-v21.0.19) (2021-07-30)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * support response observer chaining ([025618c](https://www.github.com/looker-open-source/sdk-codegen/commit/025618c806efc1664b4f573248ad5a64d6cee3e3))
33
+
34
+ ### [21.0.18](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.17...sdk-rtl-v21.0.18) (2021-07-09)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * browserTransport.ts retains ok: false now ([#745](https://www.github.com/looker-open-source/sdk-codegen/issues/745)) ([451481c](https://www.github.com/looker-open-source/sdk-codegen/commit/451481c62cdc986c860c582e4a77e3e887c6a732))
40
+
8
41
  ### [21.0.17](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.0.16...sdk-rtl-v21.0.17) (2021-07-08)
9
42
 
10
43
 
@@ -1,5 +1,5 @@
1
- import { IApiSettings } from './apiSettings';
2
- import { IRequestProps, ITransport } from './transport';
1
+ import type { IApiSettings } from './apiSettings';
2
+ import type { IRequestProps, ITransport } from './transport';
3
3
  import { AuthSession } from './authSession';
4
4
  export declare class CSRFSession extends AuthSession {
5
5
  settings: IApiSettings;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/CSRFSession.ts"],"names":["CSRFSession","AuthSession","constructor","settings","transport","BrowserTransport","activeToken","_activeToken","meta","document","head","querySelector","content","getToken","isAuthenticated","token","authenticate","props","headers"],"mappings":";;;;;;;AA4BA;;AACA;;;;;;;;AAUO,MAAMA,WAAN,SAA0BC,wBAA1B,CAAsC;AAE3CC,EAAAA,WAAW,CAAQC,QAAR,EAAgCC,SAAhC,EAAwD;AACjE,UAAMD,QAAN,EAAgBC,SAAS,IAAI,IAAIC,kCAAJ,CAAqBF,QAArB,CAA7B;AADiE,SAAhDA,QAAgD,GAAhDA,QAAgD;;AAAA,0CADpD,EACoD;AAElE;;AAEc,MAAXG,WAAW,GAAG;AAChB,QAAI,CAAC,KAAKC,YAAV,EAAwB;AACtB,UAAMC,IAAI,GAAGC,QAAQ,CAACC,IAAT,CAAcC,aAAd,CACX,mBADW,CAAb;AAGA,WAAKJ,YAAL,GAAoBC,IAAI,GAAGA,IAAI,CAACI,OAAR,GAAkB,EAA1C;AACD;;AACD,WAAO,KAAKL,YAAZ;AACD;;AAEKM,EAAAA,QAAQ,GAAG;AAAA;;AAAA;AACf,aAAO,KAAI,CAACP,WAAZ;AADe;AAEhB;;AAMDQ,EAAAA,eAAe,GAAG;AAChB,QAAMC,KAAK,GAAG,KAAKT,WAAnB;AACA,QAAI,CAACS,KAAL,EAAY,OAAO,KAAP;AACZ,WAAO,IAAP;AACD;;AAOKC,EAAAA,YAAY,CAACC,KAAD,EAAuB;AAAA;;AAAA;AACvC,UAAMF,KAAK,GAAG,MAAI,CAACT,WAAnB;AACA,UAAIS,KAAJ,EAAWE,KAAK,CAACC,OAAN,CAAc,cAAd,IAAgCH,KAAhC;AACX,aAAOE,KAAP;AAHuC;AAIxC;;AAvC0C","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 { IApiSettings } from './apiSettings'\nimport { IRequestProps, ITransport } from './transport'\nimport { BrowserTransport } from './browserTransport'\nimport { AuthSession } from './authSession'\n\n/**\n * CSRFSession is only for use within the Looker UI or a script that\n * executes in the Looker UI. Not for use by third party web apps. Looker UI web\n * service endpoints require that requests must contain a CSRF token to block third\n * party request forgeries. The actual login state is conveyed via encrypted browser\n * cookies exclusive to the looker domain, which the browser implicitly includes on\n * all web requests to looker UI web service.\n */\nexport class CSRFSession extends AuthSession {\n _activeToken = ''\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new BrowserTransport(settings))\n }\n\n get activeToken() {\n if (!this._activeToken) {\n const meta = document.head.querySelector(\n '[name=csrf-token]'\n ) as HTMLMetaElement\n this._activeToken = meta ? meta.content : ''\n }\n return this._activeToken\n }\n\n async getToken() {\n return this.activeToken\n }\n\n /**\n * Returns true if the same origin browser session has a CRSF token established\n * that can be used for API authentication\n */\n isAuthenticated() {\n const token = this.activeToken\n if (!token) return false\n return true\n }\n\n /**\n * Authenticates a request with the CSRF token if it is active\n *\n * @param props Request properties to decorate\n */\n async authenticate(props: IRequestProps) {\n const token = this.activeToken\n if (token) props.headers['X-CSRF-TOKEN'] = token\n return props\n }\n}\n"],"file":"CSRFSession.js"}
1
+ {"version":3,"sources":["../src/CSRFSession.ts"],"names":["CSRFSession","AuthSession","constructor","settings","transport","BrowserTransport","activeToken","_activeToken","meta","document","head","querySelector","content","getToken","isAuthenticated","token","authenticate","props","headers"],"mappings":";;;;;;;AA4BA;;AACA;;;;;;;;AAUO,MAAMA,WAAN,SAA0BC,wBAA1B,CAAsC;AAE3CC,EAAAA,WAAW,CAAQC,QAAR,EAAgCC,SAAhC,EAAwD;AACjE,UAAMD,QAAN,EAAgBC,SAAS,IAAI,IAAIC,kCAAJ,CAAqBF,QAArB,CAA7B;AADiE,SAAhDA,QAAgD,GAAhDA,QAAgD;;AAAA,0CADpD,EACoD;AAElE;;AAEc,MAAXG,WAAW,GAAG;AAChB,QAAI,CAAC,KAAKC,YAAV,EAAwB;AACtB,UAAMC,IAAI,GAAGC,QAAQ,CAACC,IAAT,CAAcC,aAAd,CACX,mBADW,CAAb;AAGA,WAAKJ,YAAL,GAAoBC,IAAI,GAAGA,IAAI,CAACI,OAAR,GAAkB,EAA1C;AACD;;AACD,WAAO,KAAKL,YAAZ;AACD;;AAEKM,EAAAA,QAAQ,GAAG;AAAA;;AAAA;AACf,aAAO,KAAI,CAACP,WAAZ;AADe;AAEhB;;AAMDQ,EAAAA,eAAe,GAAG;AAChB,QAAMC,KAAK,GAAG,KAAKT,WAAnB;AACA,QAAI,CAACS,KAAL,EAAY,OAAO,KAAP;AACZ,WAAO,IAAP;AACD;;AAOKC,EAAAA,YAAY,CAACC,KAAD,EAAuB;AAAA;;AAAA;AACvC,UAAMF,KAAK,GAAG,MAAI,CAACT,WAAnB;AACA,UAAIS,KAAJ,EAAWE,KAAK,CAACC,OAAN,CAAc,cAAd,IAAgCH,KAAhC;AACX,aAAOE,KAAP;AAHuC;AAIxC;;AAvC0C","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 './apiSettings'\nimport type { IRequestProps, ITransport } from './transport'\nimport { BrowserTransport } from './browserTransport'\nimport { AuthSession } from './authSession'\n\n/**\n * CSRFSession is only for use within the Looker UI or a script that\n * executes in the Looker UI. Not for use by third party web apps. Looker UI web\n * service endpoints require that requests must contain a CSRF token to block third\n * party request forgeries. The actual login state is conveyed via encrypted browser\n * cookies exclusive to the looker domain, which the browser implicitly includes on\n * all web requests to looker UI web service.\n */\nexport class CSRFSession extends AuthSession {\n _activeToken = ''\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new BrowserTransport(settings))\n }\n\n get activeToken() {\n if (!this._activeToken) {\n const meta = document.head.querySelector(\n '[name=csrf-token]'\n ) as HTMLMetaElement\n this._activeToken = meta ? meta.content : ''\n }\n return this._activeToken\n }\n\n async getToken() {\n return this.activeToken\n }\n\n /**\n * Returns true if the same origin browser session has a CRSF token established\n * that can be used for API authentication\n */\n isAuthenticated() {\n const token = this.activeToken\n if (!token) return false\n return true\n }\n\n /**\n * Authenticates a request with the CSRF token if it is active\n *\n * @param props Request properties to decorate\n */\n async authenticate(props: IRequestProps) {\n const token = this.activeToken\n if (token) props.headers['X-CSRF-TOKEN'] = token\n return props\n }\n}\n"],"file":"CSRFSession.js"}
@@ -1,6 +1,6 @@
1
- import { Readable } from 'readable-stream';
2
- import { Authenticator, HttpMethod, ITransportSettings, SDKResponse, Values } from './transport';
3
- import { IAuthSession } from './authSession';
1
+ import type { Readable } from 'readable-stream';
2
+ import type { Authenticator, HttpMethod, ITransportSettings, SDKResponse, Values } from './transport';
3
+ import type { IAuthSession } from './authSession';
4
4
  export declare const functionalSdk: (authSession: IAuthSession, apiVersion: string, sdkVersion: string) => APIMethods;
5
5
  export interface IAPIMethods {
6
6
  authSession: IAuthSession;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apiMethods.ts"],"names":["functionalSdk","authSession","apiVersion","sdkVersion","sdk","APIMethods","apiPath","settings","base_url","constructor","agentTag","agentPrefix","_apiPath","value","Error","_apiVersion","create","type","ok","promise","makePath","path","options","authenticator","match","base","authRequest","method","queryParams","body","init","authenticate","transport","request","authStream","callback","stream","get","head","delete","post","put","patch"],"mappings":"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","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { Readable } from 'readable-stream'\nimport {\n agentPrefix,\n Authenticator,\n HttpMethod,\n ITransportSettings,\n sdkOk,\n SDKResponse,\n Values,\n} from './transport'\nimport { IAuthSession } from './authSession'\n\n/**\n * Creates an \"sdk\" to be used with the TypeScript SDK's funcs.ts file\n * @param authSession authentication session\n * @param apiVersion version of API to use (e.g. \"3.1\" or \"4.0\")\n * @param sdkVersion Looker release version (e.g. \"21.4\")\n */\nexport const functionalSdk = (\n authSession: IAuthSession,\n apiVersion: string,\n sdkVersion: string\n) => {\n const sdk = new APIMethods(authSession, sdkVersion)\n sdk.apiVersion = apiVersion\n sdk.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + apiVersion\n return sdk\n}\n\nexport interface IAPIMethods {\n authSession: IAuthSession\n sdkVersion: string\n apiPath: string\n apiVersion: string\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n ok<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n ): Promise<TSuccess>\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ): string\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n\n /** Make a GET request */\n get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a HEAD request */\n head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a DELETE request */\n delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a POST request */\n post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PUT request */\n put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PATCH request */\n patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n}\n\nexport class APIMethods implements IAPIMethods {\n private _apiPath = ''\n private _apiVersion = ''\n\n /**\n * Initialize the APIMethods wrapper\n * @param authSession authentication management session\n * @param sdkVersion version of the SDK for agent tagging\n */\n constructor(public authSession: IAuthSession, public sdkVersion: string) {\n if (\n !('agentTag' in authSession.settings && authSession.settings.agentTag)\n ) {\n // Initialize agentTag if it's not already explicitly set\n authSession.settings.agentTag = `${agentPrefix} ${sdkVersion}`\n }\n }\n\n get apiPath() {\n return this._apiPath\n }\n\n set apiPath(value: string) {\n if (this._apiPath) {\n throw new Error(\n `API Path is set to \"${this._apiPath}\" and cannot be reassigned`\n )\n }\n this._apiPath = value\n }\n\n get apiVersion() {\n return this._apiVersion\n }\n\n set apiVersion(value: string) {\n // API version can only be set once for the instance\n if (this._apiVersion) {\n throw new Error(\n `API Version is set to \"${this._apiVersion}\" and cannot be reassigned`\n )\n }\n this._apiVersion = value\n }\n\n /** A helper method for constructing with a type as a param\n *\n * Example:\n * APIMethods.create(Looker40SDK, authSession)\n *\n * @param type\n * @param authSession\n */\n static create<T extends APIMethods>(\n type: new (authSession: IAuthSession) => T,\n authSession: IAuthSession\n ): T {\n // eslint-disable-next-line new-cap\n return new type(authSession)\n }\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n async ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>) {\n return sdkOk<TSuccess, TError>(promise)\n }\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ) {\n if (path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) return path\n // is this an API-versioned call?\n const base = authenticator ? this.apiPath : options.base_url\n return `${base}${path}` // path was relative\n }\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n async authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.request<TSuccess, TError>(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n )\n }\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n async authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.stream<T>(\n callback,\n method,\n path,\n queryParams,\n body,\n (init: any) => {\n return this.authSession.authenticate(init)\n },\n options\n )\n }\n\n // // dynamically evaluate a template string\n // macro(template: string, vars: any) {\n // // replace {foo} from spec path with ${foo} for template string\n // template = template.replace(/{/gi, '${')\n // return new Function('return `+ template +`;').call(vars)\n // }\n //\n // pathify(path: string, pathParams?: any) {\n // if (!pathParams) return path\n // if (path.indexOf('{') < 0) return path\n // return this.macro(path, pathParams)\n // }\n\n /** Make a GET request */\n async get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'GET',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a HEAD request */\n async head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'HEAD',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a DELETE request */\n async delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'DELETE',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a POST request */\n async post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'POST',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PUT request */\n async put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PUT',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PATCH request */\n async patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PATCH',\n path,\n queryParams,\n body,\n options\n )\n }\n}\n"],"file":"apiMethods.js"}
1
+ {"version":3,"sources":["../src/apiMethods.ts"],"names":["functionalSdk","authSession","apiVersion","sdkVersion","sdk","APIMethods","apiPath","settings","base_url","constructor","agentTag","agentPrefix","_apiPath","value","Error","_apiVersion","create","type","ok","promise","makePath","path","options","authenticator","match","base","authRequest","method","queryParams","body","init","authenticate","transport","request","authStream","callback","stream","get","head","delete","post","put","patch"],"mappings":"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","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Readable } from 'readable-stream'\nimport type {\n Authenticator,\n HttpMethod,\n ITransportSettings,\n SDKResponse,\n Values,\n} from './transport'\nimport { agentPrefix, sdkOk } from './transport'\nimport type { IAuthSession } from './authSession'\n\n/**\n * Creates an \"sdk\" to be used with the TypeScript SDK's funcs.ts file\n * @param authSession authentication session\n * @param apiVersion version of API to use (e.g. \"3.1\" or \"4.0\")\n * @param sdkVersion Looker release version (e.g. \"21.4\")\n */\nexport const functionalSdk = (\n authSession: IAuthSession,\n apiVersion: string,\n sdkVersion: string\n) => {\n const sdk = new APIMethods(authSession, sdkVersion)\n sdk.apiVersion = apiVersion\n sdk.apiPath =\n authSession.settings.base_url === ''\n ? ''\n : authSession.settings.base_url + '/api/' + apiVersion\n return sdk\n}\n\nexport interface IAPIMethods {\n authSession: IAuthSession\n sdkVersion: string\n apiPath: string\n apiVersion: string\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n ok<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n ): Promise<TSuccess>\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ): string\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n\n /** Make a GET request */\n get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a HEAD request */\n head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a DELETE request */\n delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a POST request */\n post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PUT request */\n put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /** Make a PATCH request */\n patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n}\n\nexport class APIMethods implements IAPIMethods {\n private _apiPath = ''\n private _apiVersion = ''\n\n /**\n * Initialize the APIMethods wrapper\n * @param authSession authentication management session\n * @param sdkVersion version of the SDK for agent tagging\n */\n constructor(public authSession: IAuthSession, public sdkVersion: string) {\n if (\n !('agentTag' in authSession.settings && authSession.settings.agentTag)\n ) {\n // Initialize agentTag if it's not already explicitly set\n authSession.settings.agentTag = `${agentPrefix} ${sdkVersion}`\n }\n }\n\n get apiPath() {\n return this._apiPath\n }\n\n set apiPath(value: string) {\n if (this._apiPath) {\n throw new Error(\n `API Path is set to \"${this._apiPath}\" and cannot be reassigned`\n )\n }\n this._apiPath = value\n }\n\n get apiVersion() {\n return this._apiVersion\n }\n\n set apiVersion(value: string) {\n // API version can only be set once for the instance\n if (this._apiVersion) {\n throw new Error(\n `API Version is set to \"${this._apiVersion}\" and cannot be reassigned`\n )\n }\n this._apiVersion = value\n }\n\n /** A helper method for constructing with a type as a param\n *\n * Example:\n * APIMethods.create(Looker40SDK, authSession)\n *\n * @param type\n * @param authSession\n */\n static create<T extends APIMethods>(\n type: new (authSession: IAuthSession) => T,\n authSession: IAuthSession\n ): T {\n // eslint-disable-next-line new-cap\n return new type(authSession)\n }\n\n /** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdk.ok(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\n async ok<TSuccess, TError>(promise: Promise<SDKResponse<TSuccess, TError>>) {\n return sdkOk<TSuccess, TError>(promise)\n }\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param authenticator optional callback\n * @returns the fully specified request path including any query string parameters\n */\n makePath(\n path: string,\n options: Partial<ITransportSettings>,\n authenticator?: Authenticator\n ) {\n if (path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) return path\n // is this an API-versioned call?\n const base = authenticator ? this.apiPath : options.base_url\n return `${base}${path}` // path was relative\n }\n\n /**\n *\n * A helper method to add authentication to an API request for deserialization\n *\n * @param {HttpMethod} method type of HTTP method\n * @param {string} path API endpoint path\n * @param {any} queryParams Optional query params collection for request\n * @param {any} body Optional body for request\n * @param {Partial<ITransportSettings>} options Optional overrides like timeout and verify_ssl\n */\n async authRequest<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.request<TSuccess, TError>(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n )\n }\n\n /**\n * A helper method to add authentication to an API request for streaming\n * @param {(readable: Readable) => Promise<T>} callback\n * @param {HttpMethod} method\n * @param {string} path\n * @param queryParams\n * @param body\n * @param {Partial<ITransportSettings>} options\n * @returns {Promise<T>}\n */\n async authStream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<T> {\n options = { ...this.authSession.settings, ...options }\n const authenticator = (init: any) => {\n return this.authSession.authenticate(init)\n }\n path = this.makePath(path, options, authenticator)\n return this.authSession.transport.stream<T>(\n callback,\n method,\n path,\n queryParams,\n body,\n (init: any) => {\n return this.authSession.authenticate(init)\n },\n options\n )\n }\n\n // // dynamically evaluate a template string\n // macro(template: string, vars: any) {\n // // replace {foo} from spec path with ${foo} for template string\n // template = template.replace(/{/gi, '${')\n // return new Function('return `+ template +`;').call(vars)\n // }\n //\n // pathify(path: string, pathParams?: any) {\n // if (!pathParams) return path\n // if (path.indexOf('{') < 0) return path\n // return this.macro(path, pathParams)\n // }\n\n /** Make a GET request */\n async get<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'GET',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a HEAD request */\n async head<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'HEAD',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a DELETE request */\n async delete<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'DELETE',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a POST request */\n async post<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'POST',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PUT request */\n async put<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PUT',\n path,\n queryParams,\n body,\n options\n )\n }\n\n /** Make a PATCH request */\n async patch<TSuccess, TError>(\n path: string,\n queryParams?: Values,\n body?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.authRequest<TSuccess, TError>(\n 'PATCH',\n path,\n queryParams,\n body,\n options\n )\n }\n}\n"],"file":"apiMethods.js"}
@@ -1,4 +1,4 @@
1
- import { ITransportSettings } from './transport';
1
+ import type { ITransportSettings } from './transport';
2
2
  export interface IValueSettings {
3
3
  [name: string]: string;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apiSettings.ts"],"names":["ApiConfigMap","envPrefix","base_url","client_id","client_secret","timeout","verify_ssl","strBadConfiguration","agentPrefix","DefaultSettings","agentTag","defaultTimeout","configValue","values","name","envKey","val","ValueSettings","settings","parseInt","ApiSettings","constructor","toString","isConfigured","Error","readConfig","_section"],"mappings":";;;;;;;AA0BA;;AACA;;;;AAYO,IAAMA,YAAY,GAAIC,SAAD,IAAuC;AACjE,MAAI,CAACA,SAAL,EAAgB,OAAO,EAAP;AAChB,SAAO;AACLC,IAAAA,QAAQ,YAAKD,SAAL,cADH;AAELE,IAAAA,SAAS,YAAKF,SAAL,eAFJ;AAGLG,IAAAA,aAAa,YAAKH,SAAL,mBAHR;AAILI,IAAAA,OAAO,YAAKJ,SAAL,aAJF;AAKLK,IAAAA,UAAU,YAAKL,SAAL;AALL,GAAP;AAOD,CATM;;;AAWA,IAAMM,mBAAmB,aAAMC,sBAAN,iFAAzB;;;AA8BA,IAAMC,eAAe,GAAG,OAC5B;AACCC,EAAAA,QAAQ,EAAEF,sBADX;AAECN,EAAAA,QAAQ,EAAE,EAFX;AAGCG,EAAAA,OAAO,EAAEM,yBAHV;AAICL,EAAAA,UAAU,EAAE;AAJb,CAD4B,CAAxB;;;;AAeA,IAAMM,WAAW,GAAG,CACzBC,MADyB,EAEzBC,IAFyB,EAGzBC,MAHyB,KAItB;AACH,MAAMC,GAAG,GAAGH,MAAM,CAACE,MAAM,CAACD,IAAD,CAAP,CAAN,IAAwBD,MAAM,CAACC,IAAD,CAA1C;AACA,SAAO,OAAOE,GAAP,KAAe,QAAf,GAA0B,wBAAQA,GAAR,CAA1B,GAAyCA,GAAhD;AACD,CAPM;;;;AAoBA,IAAMC,aAAa,GAAG,CAC3BJ,MAD2B,EAE3BZ,SAF2B,KAGV;AACjB,MAAMiB,QAAQ,GAAGT,eAAe,EAAhC;AACA,MAAMM,MAAM,GAAGf,YAAY,CAACC,SAAD,CAA3B;AACAiB,EAAAA,QAAQ,CAAChB,QAAT,GACEU,WAAW,CAACC,MAAD,EAAS,UAAT,EAAqBE,MAArB,CAAX,IAA2CG,QAAQ,CAAChB,QADtD;AAEAgB,EAAAA,QAAQ,CAACZ,UAAT,GAAsB,4BACpBM,WAAW,CAACC,MAAD,EAAS,YAAT,EAAuBE,MAAvB,CADS,EAEpB,IAFoB,CAAtB;AAIAG,EAAAA,QAAQ,CAACR,QAAT;AACA,MAAML,OAAO,GAAGO,WAAW,CAACC,MAAD,EAAS,SAAT,EAAoBE,MAApB,CAA3B;AACAG,EAAAA,QAAQ,CAACb,OAAT,GAAmBA,OAAO,GAAGc,QAAQ,CAACd,OAAD,EAAU,EAAV,CAAX,GAA2BM,yBAArD;AACA,SAAOO,QAAP;AACD,CAhBM;;;;AAuBA,MAAME,WAAN,CAA0C;AAM/CC,EAAAA,WAAW,CAACH,QAAD,EAAkC;AAAA;;AAAA,sCALlC,EAKkC;;AAAA,wCAJhC,IAIgC;;AAAA,qCAH3BP,yBAG2B;;AAAA,sCAFlCH,sBAEkC;;AAE3C,SAAKN,QAAL,GACE,cAAcgB,QAAd,GAAyB,wBAAQA,QAAQ,CAAChB,QAAjB,CAAzB,GAAsD,KAAKA,QAD7D;AAEA,SAAKI,UAAL,GACE,gBAAgBY,QAAhB,GACI,uBAAO,gDAAQA,QAAQ,CAACZ,UAAjB,yDAAQ,qBAAqBgB,QAArB,EAAR,CAAP,CADJ,GAEI,KAAKhB,UAHX;AAIA,SAAKD,OAAL,GACE,aAAaa,QAAb,GACIC,QAAQ,CAAC,6CAAQD,QAAQ,CAACb,OAAjB,sDAAQ,kBAAkBiB,QAAlB,EAAR,CAAD,EAAwC,EAAxC,CADZ,GAEI,KAAKjB,OAHX;AAIA,QAAI,cAAca,QAAd,IAA0BA,QAAQ,CAACR,QAAvC,EACE,KAAKA,QAAL,GAAgBQ,QAAQ,CAACR,QAAzB;;AACF,QAAI,CAAC,KAAKa,YAAL,EAAL,EAA0B;AACxB,YAAM,IAAIC,KAAJ,CAAUjB,mBAAV,CAAN;AACD;AACF;;AAEDgB,EAAAA,YAAY,GAAG;AACb,WAAO,CAAC,CAAC,KAAKrB,QAAd;AACD;;AAODuB,EAAAA,UAAU,CAACC,QAAD,EAAiC;AACzC,WAAO,EAAP;AACD;;AApC8C","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 { agentPrefix, defaultTimeout, ITransportSettings } from './transport'\nimport { boolDefault, isTrue, unquote } from './constants'\n\n/** Used for reading configuration name/value pairs */\nexport interface IValueSettings {\n [name: string]: string\n}\n\n/**\n * Gets list of environment variable names for config values\n * @param envPrefix Environment naming prefix to use. Pass an empty string to return no variable keys\n * @constructor\n */\nexport const ApiConfigMap = (envPrefix: string): IValueSettings => {\n if (!envPrefix) return {} as IValueSettings\n return {\n base_url: `${envPrefix}_BASE_URL`,\n client_id: `${envPrefix}_CLIENT_ID`,\n client_secret: `${envPrefix}_CLIENT_SECRET`,\n timeout: `${envPrefix}_TIMEOUT`,\n verify_ssl: `${envPrefix}_VERIFY_SSL`,\n }\n}\n\nexport const strBadConfiguration = `${agentPrefix} configuration error:\nMissing required configuration values like base_url\n`\n\nexport interface IApiSection {\n [key: string]: string\n}\n\nexport interface IApiSettings extends ITransportSettings {\n /**\n * Reading API settings on demand from some configuration source\n */\n readConfig(section?: string): IApiSection\n\n /**\n * Checks to see if minimal configuration values are assigned.\n *\n * If this function returns `false`, the Api configuration class will typically throw a run-time\n * error so the implementer knows required configuration values are missing\n *\n * @returns true or false\n */\n isConfigured(): boolean\n}\n\n/**\n * default the runtime configuration settings\n * @constructor\n *\n */\nexport const DefaultSettings = () =>\n ({\n agentTag: agentPrefix,\n base_url: '',\n timeout: defaultTimeout,\n verify_ssl: true,\n } as IApiSettings)\n\n/**\n * Return environment variable name value first, otherwise config name value\n * @param {IValueSettings} values\n * @param {string} name of config variable\n * @param envKey key collection of environment variables\n * @returns {string} environment value\n */\nexport const configValue = (\n values: IValueSettings,\n name: string,\n envKey: IValueSettings\n) => {\n const val = values[envKey[name]] || values[name]\n return typeof val === 'string' ? unquote(val) : val\n}\n\n/**\n * Read any key/value collection for environment variable names and return as IApiSettings\n * @constructor\n *\n * The keys for the values are:\n * - <environmentPrefix>_BASE_URL or `base_url`\n * - <environmentPrefix>_CLIENT_ID or `client_id`\n * - <environmentPrefix>_CLIENT_SECRET or `client_secret`\n * - <environmentPrefix>_VERIFY_SSL or `verify_ssl`\n * - <environmentPrefix>_TIMEOUT or `timeout`\n */\nexport const ValueSettings = (\n values: IValueSettings,\n envPrefix: string\n): IApiSettings => {\n const settings = DefaultSettings()\n const envKey = ApiConfigMap(envPrefix)\n settings.base_url =\n configValue(values, 'base_url', envKey) || settings.base_url\n settings.verify_ssl = boolDefault(\n configValue(values, 'verify_ssl', envKey),\n true\n )\n settings.agentTag = `TS-SDK`\n const timeout = configValue(values, 'timeout', envKey)\n settings.timeout = timeout ? parseInt(timeout, 10) : defaultTimeout\n return settings\n}\n\n/**\n * @class ApiSettings\n *\n * .ini Configuration initializer\n */\nexport class ApiSettings implements IApiSettings {\n base_url = ''\n verify_ssl = true\n timeout: number = defaultTimeout\n agentTag = agentPrefix\n\n constructor(settings: Partial<IApiSettings>) {\n // coerce types to declared types since some paths could have non-conforming settings values\n this.base_url =\n 'base_url' in settings ? unquote(settings.base_url) : this.base_url\n this.verify_ssl =\n 'verify_ssl' in settings\n ? isTrue(unquote(settings.verify_ssl?.toString()))\n : this.verify_ssl\n this.timeout =\n 'timeout' in settings\n ? parseInt(unquote(settings.timeout?.toString()), 10)\n : this.timeout\n if ('agentTag' in settings && settings.agentTag)\n this.agentTag = settings.agentTag\n if (!this.isConfigured()) {\n throw new Error(strBadConfiguration)\n }\n }\n\n isConfigured() {\n return !!this.base_url\n }\n\n /**\n * Default dynamic configuration reader\n * @param _section key/name of configuration section to read\n * @returns an empty `IAPISection`\n */\n readConfig(_section?: string): IApiSection {\n return {}\n }\n}\n"],"file":"apiSettings.js"}
1
+ {"version":3,"sources":["../src/apiSettings.ts"],"names":["ApiConfigMap","envPrefix","base_url","client_id","client_secret","timeout","verify_ssl","strBadConfiguration","agentPrefix","DefaultSettings","agentTag","defaultTimeout","configValue","values","name","envKey","val","ValueSettings","settings","parseInt","ApiSettings","constructor","toString","isConfigured","Error","readConfig","_section"],"mappings":"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","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { ITransportSettings } from './transport'\nimport { agentPrefix, defaultTimeout } from './transport'\nimport { boolDefault, isTrue, unquote } from './constants'\n\n/** Used for reading configuration name/value pairs */\nexport interface IValueSettings {\n [name: string]: string\n}\n\n/**\n * Gets list of environment variable names for config values\n * @param envPrefix Environment naming prefix to use. Pass an empty string to return no variable keys\n * @constructor\n */\nexport const ApiConfigMap = (envPrefix: string): IValueSettings => {\n if (!envPrefix) return {} as IValueSettings\n return {\n base_url: `${envPrefix}_BASE_URL`,\n client_id: `${envPrefix}_CLIENT_ID`,\n client_secret: `${envPrefix}_CLIENT_SECRET`,\n timeout: `${envPrefix}_TIMEOUT`,\n verify_ssl: `${envPrefix}_VERIFY_SSL`,\n }\n}\n\nexport const strBadConfiguration = `${agentPrefix} configuration error:\nMissing required configuration values like base_url\n`\n\nexport interface IApiSection {\n [key: string]: string\n}\n\nexport interface IApiSettings extends ITransportSettings {\n /**\n * Reading API settings on demand from some configuration source\n */\n readConfig(section?: string): IApiSection\n\n /**\n * Checks to see if minimal configuration values are assigned.\n *\n * If this function returns `false`, the Api configuration class will typically throw a run-time\n * error so the implementer knows required configuration values are missing\n *\n * @returns true or false\n */\n isConfigured(): boolean\n}\n\n/**\n * default the runtime configuration settings\n * @constructor\n *\n */\nexport const DefaultSettings = () =>\n ({\n agentTag: agentPrefix,\n base_url: '',\n timeout: defaultTimeout,\n verify_ssl: true,\n } as IApiSettings)\n\n/**\n * Return environment variable name value first, otherwise config name value\n * @param {IValueSettings} values\n * @param {string} name of config variable\n * @param envKey key collection of environment variables\n * @returns {string} environment value\n */\nexport const configValue = (\n values: IValueSettings,\n name: string,\n envKey: IValueSettings\n) => {\n const val = values[envKey[name]] || values[name]\n return typeof val === 'string' ? unquote(val) : val\n}\n\n/**\n * Read any key/value collection for environment variable names and return as IApiSettings\n * @constructor\n *\n * The keys for the values are:\n * - <environmentPrefix>_BASE_URL or `base_url`\n * - <environmentPrefix>_CLIENT_ID or `client_id`\n * - <environmentPrefix>_CLIENT_SECRET or `client_secret`\n * - <environmentPrefix>_VERIFY_SSL or `verify_ssl`\n * - <environmentPrefix>_TIMEOUT or `timeout`\n */\nexport const ValueSettings = (\n values: IValueSettings,\n envPrefix: string\n): IApiSettings => {\n const settings = DefaultSettings()\n const envKey = ApiConfigMap(envPrefix)\n settings.base_url =\n configValue(values, 'base_url', envKey) || settings.base_url\n settings.verify_ssl = boolDefault(\n configValue(values, 'verify_ssl', envKey),\n true\n )\n settings.agentTag = `TS-SDK`\n const timeout = configValue(values, 'timeout', envKey)\n settings.timeout = timeout ? parseInt(timeout, 10) : defaultTimeout\n return settings\n}\n\n/**\n * @class ApiSettings\n *\n * .ini Configuration initializer\n */\nexport class ApiSettings implements IApiSettings {\n base_url = ''\n verify_ssl = true\n timeout: number = defaultTimeout\n agentTag = agentPrefix\n\n constructor(settings: Partial<IApiSettings>) {\n // coerce types to declared types since some paths could have non-conforming settings values\n this.base_url =\n 'base_url' in settings ? unquote(settings.base_url) : this.base_url\n this.verify_ssl =\n 'verify_ssl' in settings\n ? isTrue(unquote(settings.verify_ssl?.toString()))\n : this.verify_ssl\n this.timeout =\n 'timeout' in settings\n ? parseInt(unquote(settings.timeout?.toString()), 10)\n : this.timeout\n if ('agentTag' in settings && settings.agentTag)\n this.agentTag = settings.agentTag\n if (!this.isConfigured()) {\n throw new Error(strBadConfiguration)\n }\n }\n\n isConfigured() {\n return !!this.base_url\n }\n\n /**\n * Default dynamic configuration reader\n * @param _section key/name of configuration section to read\n * @returns an empty `IAPISection`\n */\n readConfig(_section?: string): IApiSection {\n return {}\n }\n}\n"],"file":"apiSettings.js"}
@@ -1,6 +1,6 @@
1
- import { IRequestProps, ITransport, SDKResponse } from './transport';
2
- import { IApiSettings } from './apiSettings';
3
- import { Url } from './constants';
1
+ import type { IRequestProps, ITransport, SDKResponse } from './transport';
2
+ import type { IApiSettings } from './apiSettings';
3
+ import type { Url } from './constants';
4
4
  export interface IAccessToken {
5
5
  access_token?: string;
6
6
  token_type?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/authSession.ts"],"names":["AuthSession","constructor","settings","transport","login","_sudoId","Promise","reject","TBD","logout","resolve","isSudo","sudoId","isAuthenticated","reset","ok","promise","result","value","Buffer","message","toString"],"mappings":";;;;;;;AA0BA;;;;;;;;AA6GO,MAAeA,WAAf,CAAmD;AAM9CC,EAAAA,WAAW,CAACC,QAAD,EAAyBC,SAAzB,EAAgD;AAAA;;AAAA,oCAH5D,EAG4D;;AAAA;;AACnE,SAAKD,QAAL,GAAgBA,QAAhB;AACA,SAAKC,SAAL,GAAiBA,SAAjB;AACD;;AA0BDC,EAAAA,KAAK,CAACC,OAAD,EAA0C;AAC7C,WAAOC,OAAO,CAACC,MAAR,CAAeP,WAAW,CAACQ,GAA3B,CAAP;AACD;;AAODC,EAAAA,MAAM,GAAqB;AACzB,WAAOH,OAAO,CAACI,OAAR,CAAgB,KAAhB,CAAP;AACD;;AAKDC,EAAAA,MAAM,GAAY;AAChB,WAAO,KAAKC,MAAL,KAAgB,EAAhB,IAAsB,KAAKC,eAAL,EAA7B;AACD;;AAKDC,EAAAA,KAAK,GAAS;AACZ,SAAKF,MAAL,GAAc,EAAd;AACD;;AAEeG,EAAAA,EAAE,CAChBC,OADgB,EAEhB;AAAA;AACA,UAAMC,MAAM,SAASD,OAArB;;AACA,UAAIC,MAAM,CAACF,EAAX,EAAe;AACb,eAAOE,MAAM,CAACC,KAAd;AACD,OAFD,MAEO;AACL,YAAID,MAAM,YAAYE,MAAtB,EAA8B;AAC5B,gBAAM,yBAAS;AAAEC,YAAAA,OAAO,EAAEH,MAAM,CAACI,QAAP,CAAgB,MAAhB;AAAX,WAAT,CAAN;AACD,SAFD,MAEO;AACL,gBAAM,yBAASJ,MAAT,CAAN;AACD;AACF;AAVD;AAWD;;AA3EuD;;;;gBAApCjB,W,SACP,uC","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 { IRequestProps, ITransport, sdkError, SDKResponse } from './transport'\nimport { IApiSettings } from './apiSettings'\nimport { Url } from './constants'\n\n/**\n * Same as the Looker API access token object\n * Re-declared here to be independent of model generation\n */\nexport interface IAccessToken {\n /**\n * Access Token used for API calls (read-only)\n */\n access_token?: string\n /**\n * Type of Token (read-only)\n */\n token_type?: string\n /**\n * Number of seconds before the token expires (read-only)\n */\n expires_in?: number\n /**\n * Refresh token which can be used to obtain a new access token (read-only)\n */\n refresh_token?: string\n}\n\n/**\n * Same as the Looker API error object\n * Re-declared here to be independent of model generation\n */\nexport interface IError {\n /**\n * Error details (read-only)\n */\n message: string\n /**\n * Documentation link (read-only)\n */\n documentation_url: Url\n}\n\n/**\n * Basic authorization session interface for most API authentication scenarios\n */\nexport interface IAuthSession {\n settings: IApiSettings\n transport: ITransport\n /**\n * ID of sudo user\n */\n sudoId: string\n\n /**\n * is the current session authenticated?\n */\n isAuthenticated(): boolean\n\n /**\n * Decorate the request with authentication information\n * @param props Properties of request to use or update in callback\n * @returns the request properties with authentication information added\n */\n authenticate(props: IRequestProps): Promise<IRequestProps>\n\n /**\n * Log out the current user\n *\n * - if the current user is a sudo user, the API user becomes the active user\n * - if the current user is the API user, the API session is logged out\n * - any subsequent SDK method calls will automatically log the API user back in for this scenario\n * @returns {Promise<boolean>} `true` if a logout happened, `false` otherwise\n */\n logout(): Promise<boolean>\n\n /**\n * Typically returns an `IAccessToken` but could be any data used for auth.\n *\n * This method is not used in all session patterns, so it's not abstract in the base AuthSession\n *\n * @returns {Promise<any>} authentication information\n */\n getToken(): Promise<any>\n\n /**\n *\n * @returns `true` if the auth session is in sudo mode\n */\n isSudo(): boolean\n\n /**\n * Login to the auth session, optionally as a sudo user\n * @param {string | number} sudoId\n * @returns {Promise<any>} authentication data\n */\n login(sudoId?: string | number): Promise<any>\n\n /**\n * Clears all authentication tracking. Does **not** log the API user out in default implementations.\n */\n reset(): void\n}\n\n/**\n * Base implementation of automatically authenticated sessions for calling API endpoints\n *\n * All \"auth session\" components can descend from this class\n *\n */\nexport abstract class AuthSession implements IAuthSession {\n static TBD = 'Method not implemented in AuthSession'\n settings: IApiSettings\n sudoId = ''\n transport: ITransport\n\n protected constructor(settings: IApiSettings, transport: ITransport) {\n this.settings = settings\n this.transport = transport\n }\n\n /**\n * Decorate request properties with the required authentication information\n *\n * Properties could be additional headers, cookies, or some other request property\n *\n * @param props Request properties to use and/or modify in authentication method\n */\n abstract authenticate(props: IRequestProps): Promise<IRequestProps>\n\n /**\n * Does the session have active authentication information?\n */\n abstract isAuthenticated(): boolean\n\n /**\n * Override this method to implement a authentication retrieval from the server\n */\n abstract getToken(): Promise<any>\n\n /**\n * Override this method to implement API session login\n *\n * @param sudoId ID of sudo user. A missing sudoId means the API credentials are used to login\n */\n login(_sudoId?: string | number): Promise<any> {\n return Promise.reject(AuthSession.TBD)\n }\n\n /**\n * Override this method to implement logout\n *\n * The base implementation just returns a false promise.\n */\n logout(): Promise<boolean> {\n return Promise.resolve(false)\n }\n\n /**\n * Is a sudo user active for this session?\n */\n isSudo(): boolean {\n return this.sudoId !== '' && this.isAuthenticated()\n }\n\n /**\n * Resets all authentication status, but standard implementations do NOT log out an API session\n */\n reset(): void {\n this.sudoId = ''\n }\n\n protected async ok<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n ) {\n const result = await promise\n if (result.ok) {\n return result.value\n } else {\n if (result instanceof Buffer) {\n throw sdkError({ message: result.toString('utf8') })\n } else {\n throw sdkError(result)\n }\n }\n }\n}\n"],"file":"authSession.js"}
1
+ {"version":3,"sources":["../src/authSession.ts"],"names":["AuthSession","constructor","settings","transport","login","_sudoId","Promise","reject","TBD","logout","resolve","isSudo","sudoId","isAuthenticated","reset","ok","promise","result","value","Buffer","message","toString"],"mappings":";;;;;;;AA2BA;;;;;;;;AA6GO,MAAeA,WAAf,CAAmD;AAM9CC,EAAAA,WAAW,CAACC,QAAD,EAAyBC,SAAzB,EAAgD;AAAA;;AAAA,oCAH5D,EAG4D;;AAAA;;AACnE,SAAKD,QAAL,GAAgBA,QAAhB;AACA,SAAKC,SAAL,GAAiBA,SAAjB;AACD;;AA0BDC,EAAAA,KAAK,CAACC,OAAD,EAA0C;AAC7C,WAAOC,OAAO,CAACC,MAAR,CAAeP,WAAW,CAACQ,GAA3B,CAAP;AACD;;AAODC,EAAAA,MAAM,GAAqB;AACzB,WAAOH,OAAO,CAACI,OAAR,CAAgB,KAAhB,CAAP;AACD;;AAKDC,EAAAA,MAAM,GAAY;AAChB,WAAO,KAAKC,MAAL,KAAgB,EAAhB,IAAsB,KAAKC,eAAL,EAA7B;AACD;;AAKDC,EAAAA,KAAK,GAAS;AACZ,SAAKF,MAAL,GAAc,EAAd;AACD;;AAEeG,EAAAA,EAAE,CAChBC,OADgB,EAEhB;AAAA;AACA,UAAMC,MAAM,SAASD,OAArB;;AACA,UAAIC,MAAM,CAACF,EAAX,EAAe;AACb,eAAOE,MAAM,CAACC,KAAd;AACD,OAFD,MAEO;AACL,YAAID,MAAM,YAAYE,MAAtB,EAA8B;AAC5B,gBAAM,yBAAS;AAAEC,YAAAA,OAAO,EAAEH,MAAM,CAACI,QAAP,CAAgB,MAAhB;AAAX,WAAT,CAAN;AACD,SAFD,MAEO;AACL,gBAAM,yBAASJ,MAAT,CAAN;AACD;AACF;AAVD;AAWD;;AA3EuD;;;;gBAApCjB,W,SACP,uC","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 { IRequestProps, ITransport, SDKResponse } from './transport'\nimport { sdkError } from './transport'\nimport type { IApiSettings } from './apiSettings'\nimport type { Url } from './constants'\n\n/**\n * Same as the Looker API access token object\n * Re-declared here to be independent of model generation\n */\nexport interface IAccessToken {\n /**\n * Access Token used for API calls (read-only)\n */\n access_token?: string\n /**\n * Type of Token (read-only)\n */\n token_type?: string\n /**\n * Number of seconds before the token expires (read-only)\n */\n expires_in?: number\n /**\n * Refresh token which can be used to obtain a new access token (read-only)\n */\n refresh_token?: string\n}\n\n/**\n * Same as the Looker API error object\n * Re-declared here to be independent of model generation\n */\nexport interface IError {\n /**\n * Error details (read-only)\n */\n message: string\n /**\n * Documentation link (read-only)\n */\n documentation_url: Url\n}\n\n/**\n * Basic authorization session interface for most API authentication scenarios\n */\nexport interface IAuthSession {\n settings: IApiSettings\n transport: ITransport\n /**\n * ID of sudo user\n */\n sudoId: string\n\n /**\n * is the current session authenticated?\n */\n isAuthenticated(): boolean\n\n /**\n * Decorate the request with authentication information\n * @param props Properties of request to use or update in callback\n * @returns the request properties with authentication information added\n */\n authenticate(props: IRequestProps): Promise<IRequestProps>\n\n /**\n * Log out the current user\n *\n * - if the current user is a sudo user, the API user becomes the active user\n * - if the current user is the API user, the API session is logged out\n * - any subsequent SDK method calls will automatically log the API user back in for this scenario\n * @returns {Promise<boolean>} `true` if a logout happened, `false` otherwise\n */\n logout(): Promise<boolean>\n\n /**\n * Typically returns an `IAccessToken` but could be any data used for auth.\n *\n * This method is not used in all session patterns, so it's not abstract in the base AuthSession\n *\n * @returns {Promise<any>} authentication information\n */\n getToken(): Promise<any>\n\n /**\n *\n * @returns `true` if the auth session is in sudo mode\n */\n isSudo(): boolean\n\n /**\n * Login to the auth session, optionally as a sudo user\n * @param {string | number} sudoId\n * @returns {Promise<any>} authentication data\n */\n login(sudoId?: string | number): Promise<any>\n\n /**\n * Clears all authentication tracking. Does **not** log the API user out in default implementations.\n */\n reset(): void\n}\n\n/**\n * Base implementation of automatically authenticated sessions for calling API endpoints\n *\n * All \"auth session\" components can descend from this class\n *\n */\nexport abstract class AuthSession implements IAuthSession {\n static TBD = 'Method not implemented in AuthSession'\n settings: IApiSettings\n sudoId = ''\n transport: ITransport\n\n protected constructor(settings: IApiSettings, transport: ITransport) {\n this.settings = settings\n this.transport = transport\n }\n\n /**\n * Decorate request properties with the required authentication information\n *\n * Properties could be additional headers, cookies, or some other request property\n *\n * @param props Request properties to use and/or modify in authentication method\n */\n abstract authenticate(props: IRequestProps): Promise<IRequestProps>\n\n /**\n * Does the session have active authentication information?\n */\n abstract isAuthenticated(): boolean\n\n /**\n * Override this method to implement a authentication retrieval from the server\n */\n abstract getToken(): Promise<any>\n\n /**\n * Override this method to implement API session login\n *\n * @param sudoId ID of sudo user. A missing sudoId means the API credentials are used to login\n */\n login(_sudoId?: string | number): Promise<any> {\n return Promise.reject(AuthSession.TBD)\n }\n\n /**\n * Override this method to implement logout\n *\n * The base implementation just returns a false promise.\n */\n logout(): Promise<boolean> {\n return Promise.resolve(false)\n }\n\n /**\n * Is a sudo user active for this session?\n */\n isSudo(): boolean {\n return this.sudoId !== '' && this.isAuthenticated()\n }\n\n /**\n * Resets all authentication status, but standard implementations do NOT log out an API session\n */\n reset(): void {\n this.sudoId = ''\n }\n\n protected async ok<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n ) {\n const result = await promise\n if (result.ok) {\n return result.value\n } else {\n if (result instanceof Buffer) {\n throw sdkError({ message: result.toString('utf8') })\n } else {\n throw sdkError(result)\n }\n }\n }\n}\n"],"file":"authSession.js"}
@@ -1,4 +1,4 @@
1
- import { IAccessToken } from './authSession';
1
+ import type { IAccessToken } from './authSession';
2
2
  export declare class AuthToken implements IAccessToken {
3
3
  lagTime: number;
4
4
  access_token: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/authToken.ts"],"names":["AuthToken","constructor","token","Date","setToken","isActive","access_token","expiresAt","now","token_type","expires_in","refresh_token","exp","setSeconds","getSeconds","lagTime","reset"],"mappings":";;;;;;;;;AA4BO,MAAMA,SAAN,CAAwC;AAS7CC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA,qCAPxB,EAOwB;;AAAA,0CANnB,EAMmB;;AAAA,wCALrB,EAKqB;;AAAA;;AAAA,wCAHrB,CAGqB;;AAAA,uCAFtB,IAAIC,IAAJ,EAEsB;;AAChC,QAAI,CAACD,KAAL,EAAYA,KAAK,GAAG,EAAR;AACZ,SAAKE,QAAL,CAAcF,KAAd;AACD;;AAGDG,EAAAA,QAAQ,GAAG;AACT,QAAI,CAAC,KAAKC,YAAV,EAAwB,OAAO,KAAP;AACxB,QAAI,CAAC,KAAKC,SAAV,EAAqB,OAAO,KAAP;AACrB,QAAMC,GAAG,GAAG,IAAIL,IAAJ,EAAZ;AACA,WAAO,KAAKI,SAAL,GAAiBC,GAAxB;AACD;;AAGDJ,EAAAA,QAAQ,CAACF,KAAD,EAAsB;AAC5B,SAAKI,YAAL,GAAoBJ,KAAK,CAACI,YAAN,IAAsB,EAA1C;AACA,SAAKG,UAAL,GAAkBP,KAAK,CAACO,UAAN,IAAoB,EAAtC;AACA,SAAKC,UAAL,GAAkBR,KAAK,CAACQ,UAAN,IAAoB,CAAtC;;AAGA,QAAIR,KAAK,CAACS,aAAV,EAAyB;AACvB,WAAKA,aAAL,GAAqBT,KAAK,CAACS,aAA3B;AACD;;AACD,QAAMC,GAAG,GAAG,IAAIT,IAAJ,EAAZ;;AACA,QAAI,KAAKG,YAAL,IAAqB,KAAKI,UAA9B,EAA0C;AACxCE,MAAAA,GAAG,CAACC,UAAJ,CAAeD,GAAG,CAACE,UAAJ,KAAmB,KAAKJ,UAAxB,GAAqC,KAAKK,OAAzD;AACD,KAFD,MAEO;AACLH,MAAAA,GAAG,CAACC,UAAJ,CAAeD,GAAG,CAACE,UAAJ,KAAmB,KAAKC,OAAvC;AACD;;AACD,SAAKR,SAAL,GAAiBK,GAAjB;AACA,WAAO,IAAP;AACD;;AAEDI,EAAAA,KAAK,GAAG;AACN,SAAKV,YAAL,GAAoB,EAApB;AACA,SAAKI,UAAL,GAAkB,CAAlB;AACD;;AA7C4C","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 { IAccessToken } from './authSession'\n\nexport class AuthToken implements IAccessToken {\n /** set the server response lag time to 10 seconds */\n lagTime = 10\n access_token = ''\n token_type = ''\n refresh_token?: string\n expires_in = 0\n expiresAt = new Date()\n\n constructor(token?: IAccessToken) {\n if (!token) token = {} as IAccessToken\n this.setToken(token)\n }\n\n // true if the authentication token is set and has not timed out\n isActive() {\n if (!this.access_token) return false\n if (!this.expiresAt) return false\n const now = new Date()\n return this.expiresAt > now\n }\n\n // Assign the token and set its expiration\n setToken(token: IAccessToken) {\n this.access_token = token.access_token || ''\n this.token_type = token.token_type || ''\n this.expires_in = token.expires_in || 0\n // nil refresh_token in new token means keep using the old refresh_token\n // capture non-nil new refresh_token\n if (token.refresh_token) {\n this.refresh_token = token.refresh_token\n }\n const exp = new Date()\n if (this.access_token && this.expires_in) {\n exp.setSeconds(exp.getSeconds() + this.expires_in - this.lagTime)\n } else {\n exp.setSeconds(exp.getSeconds() - this.lagTime) // set to expire 'lagTime' ago\n }\n this.expiresAt = exp\n return this\n }\n\n reset() {\n this.access_token = ''\n this.expires_in = 0\n }\n}\n"],"file":"authToken.js"}
1
+ {"version":3,"sources":["../src/authToken.ts"],"names":["AuthToken","constructor","token","Date","setToken","isActive","access_token","expiresAt","now","token_type","expires_in","refresh_token","exp","setSeconds","getSeconds","lagTime","reset"],"mappings":";;;;;;;;;AA4BO,MAAMA,SAAN,CAAwC;AAS7CC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA,qCAPxB,EAOwB;;AAAA,0CANnB,EAMmB;;AAAA,wCALrB,EAKqB;;AAAA;;AAAA,wCAHrB,CAGqB;;AAAA,uCAFtB,IAAIC,IAAJ,EAEsB;;AAChC,QAAI,CAACD,KAAL,EAAYA,KAAK,GAAG,EAAR;AACZ,SAAKE,QAAL,CAAcF,KAAd;AACD;;AAGDG,EAAAA,QAAQ,GAAG;AACT,QAAI,CAAC,KAAKC,YAAV,EAAwB,OAAO,KAAP;AACxB,QAAI,CAAC,KAAKC,SAAV,EAAqB,OAAO,KAAP;AACrB,QAAMC,GAAG,GAAG,IAAIL,IAAJ,EAAZ;AACA,WAAO,KAAKI,SAAL,GAAiBC,GAAxB;AACD;;AAGDJ,EAAAA,QAAQ,CAACF,KAAD,EAAsB;AAC5B,SAAKI,YAAL,GAAoBJ,KAAK,CAACI,YAAN,IAAsB,EAA1C;AACA,SAAKG,UAAL,GAAkBP,KAAK,CAACO,UAAN,IAAoB,EAAtC;AACA,SAAKC,UAAL,GAAkBR,KAAK,CAACQ,UAAN,IAAoB,CAAtC;;AAGA,QAAIR,KAAK,CAACS,aAAV,EAAyB;AACvB,WAAKA,aAAL,GAAqBT,KAAK,CAACS,aAA3B;AACD;;AACD,QAAMC,GAAG,GAAG,IAAIT,IAAJ,EAAZ;;AACA,QAAI,KAAKG,YAAL,IAAqB,KAAKI,UAA9B,EAA0C;AACxCE,MAAAA,GAAG,CAACC,UAAJ,CAAeD,GAAG,CAACE,UAAJ,KAAmB,KAAKJ,UAAxB,GAAqC,KAAKK,OAAzD;AACD,KAFD,MAEO;AACLH,MAAAA,GAAG,CAACC,UAAJ,CAAeD,GAAG,CAACE,UAAJ,KAAmB,KAAKC,OAAvC;AACD;;AACD,SAAKR,SAAL,GAAiBK,GAAjB;AACA,WAAO,IAAP;AACD;;AAEDI,EAAAA,KAAK,GAAG;AACN,SAAKV,YAAL,GAAoB,EAApB;AACA,SAAKI,UAAL,GAAkB,CAAlB;AACD;;AA7C4C","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 { IAccessToken } from './authSession'\n\nexport class AuthToken implements IAccessToken {\n /** set the server response lag time to 10 seconds */\n lagTime = 10\n access_token = ''\n token_type = ''\n refresh_token?: string\n expires_in = 0\n expiresAt = new Date()\n\n constructor(token?: IAccessToken) {\n if (!token) token = {} as IAccessToken\n this.setToken(token)\n }\n\n // true if the authentication token is set and has not timed out\n isActive() {\n if (!this.access_token) return false\n if (!this.expiresAt) return false\n const now = new Date()\n return this.expiresAt > now\n }\n\n // Assign the token and set its expiration\n setToken(token: IAccessToken) {\n this.access_token = token.access_token || ''\n this.token_type = token.token_type || ''\n this.expires_in = token.expires_in || 0\n // nil refresh_token in new token means keep using the old refresh_token\n // capture non-nil new refresh_token\n if (token.refresh_token) {\n this.refresh_token = token.refresh_token\n }\n const exp = new Date()\n if (this.access_token && this.expires_in) {\n exp.setSeconds(exp.getSeconds() + this.expires_in - this.lagTime)\n } else {\n exp.setSeconds(exp.getSeconds() - this.lagTime) // set to expire 'lagTime' ago\n }\n this.expiresAt = exp\n return this\n }\n\n reset() {\n this.access_token = ''\n this.expires_in = 0\n }\n}\n"],"file":"authToken.js"}
@@ -1,4 +1,4 @@
1
- import { Readable } from 'readable-stream';
1
+ import type { Readable } from 'readable-stream';
2
2
  import type { Authenticator, HttpMethod, IRawResponse, ITransport, ITransportSettings, SDKResponse, Values, RawObserver } from './transport';
3
3
  export declare abstract class BaseTransport implements ITransport {
4
4
  protected readonly options: ITransportSettings;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/baseTransport.ts"],"names":["BaseTransport","constructor","options","undefined","ok","res","statusCode","StatusCode","OK","IMUsed","makeUrl","path","queryParams","base","base_url","match"],"mappings":";;;;;;;AA2BA;;;;AAYO,MAAeA,aAAf,CAAmD;AAC9CC,EAAAA,WAAW,CAAoBC,OAApB,EAAiD;AAAA,SAA7BA,OAA6B,GAA7BA,OAA6B;;AAAA,sCAIlCC,SAJkC;;AACpE,SAAKD,OAAL,GAAeA,OAAf;AACD;;AAQDE,EAAAA,EAAE,CAACC,GAAD,EAA6B;AAC7B,WACEA,GAAG,CAACC,UAAJ,IAAkBC,sBAAWC,EAA7B,IAAmCH,GAAG,CAACC,UAAJ,IAAkBC,sBAAWE,MADlE;AAGD;;AAwEDC,EAAAA,OAAO,CACLC,IADK,EAELT,OAFK,EAGLU,WAHK,EAIL;AAEA,QAAMC,IAAI,GAAGX,OAAO,CAACY,QAArB;;AACA,QAAI,CAACH,IAAI,CAACI,KAAL,CAAW,2BAAX,CAAL,EAA8C;AAC5CJ,MAAAA,IAAI,aAAME,IAAN,SAAaF,IAAb,CAAJ;AACD;;AACDA,IAAAA,IAAI,GAAG,+BAAeA,IAAf,EAAqBC,WAArB,CAAP;AACA,WAAOD,IAAP;AACD;;AAnGuD","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 { Readable } from 'readable-stream'\nimport { addQueryParams, StatusCode } from './transport'\nimport type {\n Authenticator,\n HttpMethod,\n IRawResponse,\n ITransport,\n ITransportSettings,\n SDKResponse,\n Values,\n RawObserver,\n} from './transport'\n\nexport abstract class BaseTransport implements ITransport {\n protected constructor(protected readonly options: ITransportSettings) {\n this.options = options\n }\n\n observer: RawObserver | undefined = undefined\n\n abstract parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>\n\n ok(res: IRawResponse): boolean {\n return (\n res.statusCode >= StatusCode.OK && res.statusCode <= StatusCode.IMUsed\n )\n }\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * NOTE: This method has no error handling. It simply returns the results of the HTTP request.\n *\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n abstract rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>\n\n /**\n * Request a streaming response\n * @param {HttpMethod} method\n * @param {string} path Request path\n * @param queryParams query parameters for the request\n * @param body http body to include with request\n * @param {Authenticator} authenticator callback to add authentication information to the request\n * @param {Partial<ITransportSettings>} options transport option overrides\n * @returns {Promise<TSuccess>} the streaming response\n */\n abstract request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * Request a streaming response\n * @param {(readable: _Readable.Readable) => Promise<TSuccess>} callback A function will be called with a Node.js or\n * Browser `Readable` object. The readable object represents the streaming data.\n * @param {HttpMethod} method\n * @param {string} path Request path\n * @param queryParams query parameters for the request\n * @param body http body to include with request\n * @param {Authenticator} authenticator callback to add authentication information to the request\n * @param {Partial<ITransportSettings>} options transport option overrides\n * @returns {Promise<TSuccess>} the streaming response\n */\n abstract stream<TSuccess>(\n callback: (readable: Readable) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess>\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param queryParams Collection of query Params\n * @returns the fully specified request path including any query string parameters\n */\n makeUrl(\n path: string,\n options: Partial<ITransportSettings>,\n queryParams?: Values\n ) {\n // is this an API-versioned call?\n const base = options.base_url\n if (!path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) {\n path = `${base}${path}` // path was relative\n }\n path = addQueryParams(path, queryParams)\n return path\n }\n}\n"],"file":"baseTransport.js"}
1
+ {"version":3,"sources":["../src/baseTransport.ts"],"names":["BaseTransport","constructor","options","undefined","ok","res","statusCode","StatusCode","OK","IMUsed","makeUrl","path","queryParams","base","base_url","match"],"mappings":";;;;;;;AA2BA;;;;AAYO,MAAeA,aAAf,CAAmD;AAC9CC,EAAAA,WAAW,CAAoBC,OAApB,EAAiD;AAAA,SAA7BA,OAA6B,GAA7BA,OAA6B;;AAAA,sCAIlCC,SAJkC;;AACpE,SAAKD,OAAL,GAAeA,OAAf;AACD;;AAQDE,EAAAA,EAAE,CAACC,GAAD,EAA6B;AAC7B,WACEA,GAAG,CAACC,UAAJ,IAAkBC,sBAAWC,EAA7B,IAAmCH,GAAG,CAACC,UAAJ,IAAkBC,sBAAWE,MADlE;AAGD;;AAwEDC,EAAAA,OAAO,CACLC,IADK,EAELT,OAFK,EAGLU,WAHK,EAIL;AAEA,QAAMC,IAAI,GAAGX,OAAO,CAACY,QAArB;;AACA,QAAI,CAACH,IAAI,CAACI,KAAL,CAAW,2BAAX,CAAL,EAA8C;AAC5CJ,MAAAA,IAAI,aAAME,IAAN,SAAaF,IAAb,CAAJ;AACD;;AACDA,IAAAA,IAAI,GAAG,+BAAeA,IAAf,EAAqBC,WAArB,CAAP;AACA,WAAOD,IAAP;AACD;;AAnGuD","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 { Readable } from 'readable-stream'\nimport { addQueryParams, StatusCode } from './transport'\nimport type {\n Authenticator,\n HttpMethod,\n IRawResponse,\n ITransport,\n ITransportSettings,\n SDKResponse,\n Values,\n RawObserver,\n} from './transport'\n\nexport abstract class BaseTransport implements ITransport {\n protected constructor(protected readonly options: ITransportSettings) {\n this.options = options\n }\n\n observer: RawObserver | undefined = undefined\n\n abstract parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>\n\n ok(res: IRawResponse): boolean {\n return (\n res.statusCode >= StatusCode.OK && res.statusCode <= StatusCode.IMUsed\n )\n }\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * NOTE: This method has no error handling. It simply returns the results of the HTTP request.\n *\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n abstract rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>\n\n /**\n * Request a streaming response\n * @param {HttpMethod} method\n * @param {string} path Request path\n * @param queryParams query parameters for the request\n * @param body http body to include with request\n * @param {Authenticator} authenticator callback to add authentication information to the request\n * @param {Partial<ITransportSettings>} options transport option overrides\n * @returns {Promise<TSuccess>} the streaming response\n */\n abstract request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * Request a streaming response\n * @param {(readable: _Readable.Readable) => Promise<TSuccess>} callback A function will be called with a Node.js or\n * Browser `Readable` object. The readable object represents the streaming data.\n * @param {HttpMethod} method\n * @param {string} path Request path\n * @param queryParams query parameters for the request\n * @param body http body to include with request\n * @param {Authenticator} authenticator callback to add authentication information to the request\n * @param {Partial<ITransportSettings>} options transport option overrides\n * @returns {Promise<TSuccess>} the streaming response\n */\n abstract stream<TSuccess>(\n callback: (readable: Readable) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess>\n\n /**\n * Determine whether the url should be an API path, relative from base_url, or is already fully specified override\n * @param path Request path\n * @param options Transport settings\n * @param queryParams Collection of query Params\n * @returns the fully specified request path including any query string parameters\n */\n makeUrl(\n path: string,\n options: Partial<ITransportSettings>,\n queryParams?: Values\n ) {\n // is this an API-versioned call?\n const base = options.base_url\n if (!path.match(/^(http:\\/\\/|https:\\/\\/)/gi)) {\n path = `${base}${path}` // path was relative\n }\n path = addQueryParams(path, queryParams)\n return path\n }\n}\n"],"file":"baseTransport.js"}
@@ -1,7 +1,7 @@
1
- import { ICryptoHash } from './cryptoHash';
2
- import { IApiSettings } from './apiSettings';
3
- import { ITransport } from './transport';
4
- import { IPlatformServices } from './platformServices';
1
+ import type { ICryptoHash } from './cryptoHash';
2
+ import type { IApiSettings } from './apiSettings';
3
+ import type { ITransport } from './transport';
4
+ import type { IPlatformServices } from './platformServices';
5
5
  export declare class BrowserServices implements IPlatformServices {
6
6
  crypto: ICryptoHash;
7
7
  settings: IApiSettings;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/browserServices.ts"],"names":["BrowserServices","constructor","services","settings","message","transport","BrowserTransport","crypto","BrowserCryptoHash"],"mappings":";;;;;;;AA4BA;;AACA;;;;AAGO,MAAMA,eAAN,CAAmD;AAKxDC,EAAAA,WAAW,CAACC,QAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAChD,QAAI,CAACA,QAAQ,CAACC,QAAd,EAAwB;AACtB,YAAM,yBAAS;AAAEC,QAAAA,OAAO,EAAE;AAAX,OAAT,CAAN;AACD;;AACD,SAAKD,QAAL,GAAgBD,QAAQ,CAACC,QAAzB;AACA,SAAKE,SAAL,GAAiBH,QAAQ,CAACG,SAAT,IAAsB,IAAIC,kCAAJ,CAAqB,KAAKH,QAA1B,CAAvC;AACA,SAAKI,MAAL,GAAcL,QAAQ,CAACK,MAAT,IAAmB,IAAIC,mCAAJ,EAAjC;AACD;;AAZuD","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 { ICryptoHash } from './cryptoHash'\nimport { IApiSettings } from './apiSettings'\nimport { ITransport, sdkError } from './transport'\nimport { BrowserCryptoHash, BrowserTransport } from './browserTransport'\nimport { IPlatformServices } from './platformServices'\n\nexport class BrowserServices implements IPlatformServices {\n crypto: ICryptoHash\n settings: IApiSettings\n transport: ITransport\n\n constructor(services: Partial<IPlatformServices>) {\n if (!services.settings) {\n throw sdkError({ message: 'Missing required IApiSettings' })\n }\n this.settings = services.settings\n this.transport = services.transport || new BrowserTransport(this.settings)\n this.crypto = services.crypto || new BrowserCryptoHash()\n }\n}\n"],"file":"browserServices.js"}
1
+ {"version":3,"sources":["../src/browserServices.ts"],"names":["BrowserServices","constructor","services","settings","message","transport","BrowserTransport","crypto","BrowserCryptoHash"],"mappings":";;;;;;;AA6BA;;AACA;;;;AAGO,MAAMA,eAAN,CAAmD;AAKxDC,EAAAA,WAAW,CAACC,QAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAChD,QAAI,CAACA,QAAQ,CAACC,QAAd,EAAwB;AACtB,YAAM,yBAAS;AAAEC,QAAAA,OAAO,EAAE;AAAX,OAAT,CAAN;AACD;;AACD,SAAKD,QAAL,GAAgBD,QAAQ,CAACC,QAAzB;AACA,SAAKE,SAAL,GAAiBH,QAAQ,CAACG,SAAT,IAAsB,IAAIC,kCAAJ,CAAqB,KAAKH,QAA1B,CAAvC;AACA,SAAKI,MAAL,GAAcL,QAAQ,CAACK,MAAT,IAAmB,IAAIC,mCAAJ,EAAjC;AACD;;AAZuD","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 { ICryptoHash } from './cryptoHash'\nimport type { IApiSettings } from './apiSettings'\nimport type { ITransport } from './transport'\nimport { sdkError } from './transport'\nimport { BrowserCryptoHash, BrowserTransport } from './browserTransport'\nimport type { IPlatformServices } from './platformServices'\n\nexport class BrowserServices implements IPlatformServices {\n crypto: ICryptoHash\n settings: IApiSettings\n transport: ITransport\n\n constructor(services: Partial<IPlatformServices>) {\n if (!services.settings) {\n throw sdkError({ message: 'Missing required IApiSettings' })\n }\n this.settings = services.settings\n this.transport = services.transport || new BrowserTransport(this.settings)\n this.crypto = services.crypto || new BrowserCryptoHash()\n }\n}\n"],"file":"browserServices.js"}
@@ -1,6 +1,6 @@
1
- import { ITransport, IRequestProps } from './transport';
1
+ import type { ITransport, IRequestProps } from './transport';
2
2
  import { OAuthSession } from './oauthSession';
3
- import { IApiSettings } from './apiSettings';
3
+ import type { IApiSettings } from './apiSettings';
4
4
  export declare class BrowserSession extends OAuthSession {
5
5
  settings: IApiSettings;
6
6
  constructor(settings: IApiSettings, transport?: ITransport);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/browserSession.ts"],"names":["BrowserSession","OAuthSession","constructor","settings","transport","BrowserServices","BrowserTransport","authenticate","props","isAuthenticated","mode","credentials","headers","Authorization","activeToken","access_token","LookerAppId","agentTag"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAkBO,MAAMA,cAAN,SAA6BC,0BAA7B,CAA0C;AAC/CC,EAAAA,WAAW,CAAQC,QAAR,EAAgCC,SAAhC,EAAwD;AACjE,UACE,IAAIC,gCAAJ,CAAoB;AAClBF,MAAAA,QADkB;AAElBC,MAAAA,SAAS,EAAEA,SAAS,IAAI,IAAIE,kCAAJ,CAAqBH,QAArB;AAFN,KAApB,CADF;AADiE,SAAhDA,QAAgD,GAAhDA,QAAgD;AAOlE;;AAUKI,EAAAA,YAAY,CAACC,KAAD,EAAuB;AAAA;AAAA;;AAAA;AACvCA,MAAAA,KAAK,SAAS,yCAAmBA,KAAnB,CAAd;;AACA,UAAI,KAAI,CAACC,eAAL,EAAJ,EAA4B;AAK1BD,QAAAA,KAAK,CAACE,IAAN,GAAa,MAAb;AAKA,eAAOF,KAAK,CAACG,WAAb;AAEA,YAAMC,OAAO,GAAG;AAEdC,UAAAA,aAAa,mBAAY,KAAI,CAACC,WAAL,CAAiBC,YAA7B,CAFC;AAId,WAACC,sBAAD,GAAe,KAAI,CAACb,QAAL,CAAcc;AAJf,SAAhB;;AAUA,YAAIT,KAAK,CAACI,OAAV,EAAmB;AACjBJ,UAAAA,KAAK,CAACI,OAAN,mCAAqBJ,KAAK,CAACI,OAA3B,GAAuCA,OAAvC;AACD,SAFD,MAEO;AACLJ,UAAAA,KAAK,CAACI,OAAN,GAAgBA,OAAhB;AACD;AACF;;AAED,aAAOJ,KAAP;AA/BuC;AAgCxC;;AAlD8C","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 { ITransport, IRequestProps, LookerAppId } from './transport'\nimport { BrowserTransport } from './browserTransport'\nimport { OAuthSession } from './oauthSession'\nimport { BrowserServices } from './browserServices'\nimport { IApiSettings } from './apiSettings'\n\n/**\n * An AuthSession class intended for use with CORS requests\n *\n * This session uses `authenticate()` to establish a token via the overridden `getToken()` before\n * decorating the requests with the authentication information to call the API endpoint.\n *\n * The Looker API `login` endpoint is not available via CORS calls, so `getToken()` needs to be\n * implemented in the descendant of this class that's instantiated for the browser run-time. This\n * can be a brokered \"get token\" operation from a proxy server, or some other method of getting\n * the token.\n *\n * Or, you can call activeToken.setToken to assign an auth token after construction. This disables\n * auto token management.\n *\n */\nexport class BrowserSession extends OAuthSession {\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(\n new BrowserServices({\n settings,\n transport: transport || new BrowserTransport(settings),\n })\n )\n }\n\n /**\n * This implementation calls the inheritor-implemented `getToken()` method to retrieve the authentication token for\n * the Looker API server because the `/login` endpoint is not available via CORS for the Looker API.\n *\n * @param props the properties of the request\n * @returns the same request properties with \"authentication\" data added\n *\n */\n async authenticate(props: IRequestProps) {\n props = await super.authenticate(props)\n if (this.isAuthenticated()) {\n /**\n * Session is authenticated\n * set CORS mode\n */\n props.mode = 'cors'\n\n /**\n * remove any credentials attribute that may have been set\n */\n delete props.credentials\n\n const headers = {\n /** Provide the authentication information */\n Authorization: `Bearer ${this.activeToken.access_token}`,\n /** Identify the SDK */\n [LookerAppId]: this.settings.agentTag,\n }\n /**\n * replace the headers argument with required values\n * Note: using new Headers() to construct the headers breaks CORS for the Looker API. Don't know why yet\n */\n if (props.headers) {\n props.headers = { ...props.headers, ...headers }\n } else {\n props.headers = headers\n }\n }\n\n return props\n }\n}\n"],"file":"browserSession.js"}
1
+ {"version":3,"sources":["../src/browserSession.ts"],"names":["BrowserSession","OAuthSession","constructor","settings","transport","BrowserServices","BrowserTransport","authenticate","props","isAuthenticated","mode","credentials","headers","Authorization","activeToken","access_token","LookerAppId","agentTag"],"mappings":";;;;;;;AA2BA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAkBO,MAAMA,cAAN,SAA6BC,0BAA7B,CAA0C;AAC/CC,EAAAA,WAAW,CAAQC,QAAR,EAAgCC,SAAhC,EAAwD;AACjE,UACE,IAAIC,gCAAJ,CAAoB;AAClBF,MAAAA,QADkB;AAElBC,MAAAA,SAAS,EAAEA,SAAS,IAAI,IAAIE,kCAAJ,CAAqBH,QAArB;AAFN,KAApB,CADF;AADiE,SAAhDA,QAAgD,GAAhDA,QAAgD;AAOlE;;AAUKI,EAAAA,YAAY,CAACC,KAAD,EAAuB;AAAA;AAAA;;AAAA;AACvCA,MAAAA,KAAK,SAAS,yCAAmBA,KAAnB,CAAd;;AACA,UAAI,KAAI,CAACC,eAAL,EAAJ,EAA4B;AAK1BD,QAAAA,KAAK,CAACE,IAAN,GAAa,MAAb;AAKA,eAAOF,KAAK,CAACG,WAAb;AAEA,YAAMC,OAAO,GAAG;AAEdC,UAAAA,aAAa,mBAAY,KAAI,CAACC,WAAL,CAAiBC,YAA7B,CAFC;AAId,WAACC,sBAAD,GAAe,KAAI,CAACb,QAAL,CAAcc;AAJf,SAAhB;;AAUA,YAAIT,KAAK,CAACI,OAAV,EAAmB;AACjBJ,UAAAA,KAAK,CAACI,OAAN,mCAAqBJ,KAAK,CAACI,OAA3B,GAAuCA,OAAvC;AACD,SAFD,MAEO;AACLJ,UAAAA,KAAK,CAACI,OAAN,GAAgBA,OAAhB;AACD;AACF;;AAED,aAAOJ,KAAP;AA/BuC;AAgCxC;;AAlD8C","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 { ITransport, IRequestProps } from './transport'\nimport { LookerAppId } from './transport'\nimport { BrowserTransport } from './browserTransport'\nimport { OAuthSession } from './oauthSession'\nimport { BrowserServices } from './browserServices'\nimport type { IApiSettings } from './apiSettings'\n\n/**\n * An AuthSession class intended for use with CORS requests\n *\n * This session uses `authenticate()` to establish a token via the overridden `getToken()` before\n * decorating the requests with the authentication information to call the API endpoint.\n *\n * The Looker API `login` endpoint is not available via CORS calls, so `getToken()` needs to be\n * implemented in the descendant of this class that's instantiated for the browser run-time. This\n * can be a brokered \"get token\" operation from a proxy server, or some other method of getting\n * the token.\n *\n * Or, you can call activeToken.setToken to assign an auth token after construction. This disables\n * auto token management.\n *\n */\nexport class BrowserSession extends OAuthSession {\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(\n new BrowserServices({\n settings,\n transport: transport || new BrowserTransport(settings),\n })\n )\n }\n\n /**\n * This implementation calls the inheritor-implemented `getToken()` method to retrieve the authentication token for\n * the Looker API server because the `/login` endpoint is not available via CORS for the Looker API.\n *\n * @param props the properties of the request\n * @returns the same request properties with \"authentication\" data added\n *\n */\n async authenticate(props: IRequestProps) {\n props = await super.authenticate(props)\n if (this.isAuthenticated()) {\n /**\n * Session is authenticated\n * set CORS mode\n */\n props.mode = 'cors'\n\n /**\n * remove any credentials attribute that may have been set\n */\n delete props.credentials\n\n const headers = {\n /** Provide the authentication information */\n Authorization: `Bearer ${this.activeToken.access_token}`,\n /** Identify the SDK */\n [LookerAppId]: this.settings.agentTag,\n }\n /**\n * replace the headers argument with required values\n * Note: using new Headers() to construct the headers breaks CORS for the Looker API. Don't know why yet\n */\n if (props.headers) {\n props.headers = { ...props.headers, ...headers }\n } else {\n props.headers = headers\n }\n }\n\n return props\n }\n}\n"],"file":"browserSession.js"}
@@ -1,7 +1,7 @@
1
- import { Readable } from 'readable-stream';
2
- import { SDKResponse, ITransportSettings, HttpMethod, Authenticator, Values, IRawResponse } from './transport';
1
+ import type { Readable } from 'readable-stream';
2
+ import type { SDKResponse, ITransportSettings, HttpMethod, Authenticator, Values, IRawResponse } from './transport';
3
3
  import { BaseTransport } from './baseTransport';
4
- import { ICryptoHash } from './cryptoHash';
4
+ import type { ICryptoHash } from './cryptoHash';
5
5
  export declare class BrowserCryptoHash implements ICryptoHash {
6
6
  arrayToHex(array: Uint8Array): string;
7
7
  fromBase64(str: string): number[];
@@ -25,5 +25,5 @@ export declare class BrowserTransport extends BaseTransport {
25
25
  parseResponse<TSuccess, TError>(res: IRawResponse): Promise<SDKResponse<TSuccess, TError>>;
26
26
  request<TSuccess, TError>(method: HttpMethod, path: string, queryParams?: any, body?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
27
27
  private initRequest;
28
- stream<TSuccess>(callback: (readable: Readable) => Promise<TSuccess>, method: HttpMethod, path: string, queryParams?: any, body?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<TSuccess>;
28
+ stream<TSuccess>(_callback: (readable: Readable) => Promise<TSuccess>, method: HttpMethod, path: string, queryParams?: any, body?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<TSuccess>;
29
29
  }
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BrowserTransport = exports.BrowserCryptoHash = void 0;
7
7
 
8
- var _readableStream = require("readable-stream");
9
-
10
8
  var _transport = require("./transport");
11
9
 
12
10
  var _baseTransport = require("./baseTransport");
@@ -147,6 +145,27 @@ class BrowserTransport extends _baseTransport.BaseTransport {
147
145
  parseResponse(res) {
148
146
  return _asyncToGenerator(function* () {
149
147
  var perfMark = res.startMark || '';
148
+
149
+ if (!res.ok) {
150
+ var _error = res.body;
151
+
152
+ if (typeof _error === 'string') {
153
+ try {
154
+ _error = JSON.parse(_error);
155
+ } catch (_unused) {
156
+ _error = {
157
+ message: "Request failed: ".concat(_error)
158
+ };
159
+ }
160
+ }
161
+
162
+ var response = {
163
+ ok: false,
164
+ error: _error
165
+ };
166
+ return response;
167
+ }
168
+
150
169
  var value;
151
170
  var error;
152
171
 
@@ -176,7 +195,7 @@ class BrowserTransport extends _baseTransport.BaseTransport {
176
195
  if (error) {
177
196
  result = {
178
197
  ok: false,
179
- error
198
+ error: error
180
199
  };
181
200
  } else {
182
201
  result = {
@@ -204,6 +223,7 @@ class BrowserTransport extends _baseTransport.BaseTransport {
204
223
  var result = yield _this2.parseResponse(res);
205
224
  return result;
206
225
  } catch (e) {
226
+ if (!(0, _transport.isErrorLike)(e)) throw e;
207
227
  var error = {
208
228
  message: typeof e.message === 'string' ? e.message : "The SDK call was not successful. The error was '".concat(e, "'."),
209
229
  type: 'sdk_error'
@@ -260,19 +280,17 @@ class BrowserTransport extends _baseTransport.BaseTransport {
260
280
  })();
261
281
  }
262
282
 
263
- stream(callback, method, path, queryParams, body, authenticator, options) {
283
+ stream(_callback, method, path, queryParams, body, authenticator, options) {
264
284
  var _this4 = this;
265
285
 
266
286
  return _asyncToGenerator(function* () {
267
287
  options = options ? _objectSpread(_objectSpread({}, _this4.options), options) : _this4.options;
268
- var stream = new _readableStream.PassThrough();
269
- var returnPromise = callback(stream);
270
288
 
271
289
  var requestPath = _this4.makeUrl(path, options, queryParams);
272
290
 
273
291
  var props = yield _this4.initRequest(method, requestPath, body, authenticator, options);
274
292
  (0, _transport.trace)("[stream] attempting to stream via download url", props);
275
- return Promise.reject(Error("Streaming for".concat(returnPromise ? 'callback' : '', " ").concat(props.method, " ").concat(props.requestPath, " is not implemented")));
293
+ return Promise.reject(Error("Streaming for callback ".concat(props.method, " ").concat(props.requestPath, " is not implemented")));
276
294
  })();
277
295
  }
278
296