@looker/sdk-rtl 21.4.0 → 21.6.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.
- package/CHANGELOG.md +14 -0
- package/lib/CSRFSession.js +3 -17
- package/lib/CSRFSession.js.map +1 -1
- package/lib/apiMethods.js +6 -47
- package/lib/apiMethods.js.map +1 -1
- package/lib/apiSettings.js +4 -24
- package/lib/apiSettings.js.map +1 -1
- package/lib/authSession.js +3 -18
- package/lib/authSession.js.map +1 -1
- package/lib/authToken.js +3 -18
- package/lib/authToken.js.map +1 -1
- package/lib/baseTransport.js +3 -12
- package/lib/baseTransport.js.map +1 -1
- package/lib/browser.js +0 -34
- package/lib/browser.js.map +1 -1
- package/lib/browserServices.js +3 -11
- package/lib/browserServices.js.map +1 -1
- package/lib/browserSession.js +6 -21
- package/lib/browserSession.js.map +1 -1
- package/lib/browserTransport.js +10 -64
- package/lib/browserTransport.js.map +1 -1
- package/lib/constants.js +1 -11
- package/lib/constants.js.map +1 -1
- package/lib/cryptoHash.js +1 -1
- package/lib/cryptoHash.js.map +1 -1
- package/lib/delimArray.js +3 -8
- package/lib/delimArray.js.map +1 -1
- package/lib/errorDoc.js +9 -50
- package/lib/errorDoc.js.map +1 -1
- package/lib/esm/CSRFSession.js +14 -17
- package/lib/esm/CSRFSession.js.map +1 -1
- package/lib/esm/apiMethods.js +18 -46
- package/lib/esm/apiMethods.js.map +1 -1
- package/lib/esm/apiSettings.js +32 -28
- package/lib/esm/apiSettings.js.map +1 -1
- package/lib/esm/authSession.js +14 -19
- package/lib/esm/authSession.js.map +1 -1
- package/lib/esm/authToken.js +11 -17
- package/lib/esm/authToken.js.map +1 -1
- package/lib/esm/baseTransport.js +14 -13
- package/lib/esm/baseTransport.js.map +1 -1
- package/lib/esm/browser.js +192 -17
- package/lib/esm/browser.js.map +1 -1
- package/lib/esm/browserServices.js +15 -12
- package/lib/esm/browserServices.js.map +1 -1
- package/lib/esm/browserSession.js +21 -23
- package/lib/esm/browserSession.js.map +1 -1
- package/lib/esm/browserTransport.js +29 -69
- package/lib/esm/browserTransport.js.map +1 -1
- package/lib/esm/constants.js +22 -10
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/cryptoHash.js.map +1 -1
- package/lib/esm/delimArray.js +10 -6
- package/lib/esm/delimArray.js.map +1 -1
- package/lib/esm/errorDoc.js +24 -52
- package/lib/esm/errorDoc.js.map +1 -1
- package/lib/esm/extensionSession.js +11 -16
- package/lib/esm/extensionSession.js.map +1 -1
- package/lib/esm/extensionTransport.js +13 -19
- package/lib/esm/extensionTransport.js.map +1 -1
- package/lib/esm/index.js +236 -21
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/lookerSDKError.js +13 -12
- package/lib/esm/lookerSDKError.js.map +1 -1
- package/lib/esm/oauthSession.js +23 -66
- package/lib/esm/oauthSession.js.map +1 -1
- package/lib/esm/paging.js +24 -71
- package/lib/esm/paging.js.map +1 -1
- package/lib/esm/platformServices.js.map +1 -1
- package/lib/esm/proxySession.js +13 -13
- package/lib/esm/proxySession.js.map +1 -1
- package/lib/esm/testUtils/index.js +17 -0
- package/lib/esm/testUtils/index.js.map +1 -0
- package/lib/esm/testUtils/testUtils.js +46 -0
- package/lib/esm/testUtils/testUtils.js.map +1 -0
- package/lib/esm/transport.js +57 -62
- package/lib/esm/transport.js.map +1 -1
- package/lib/extensionSession.js +3 -17
- package/lib/extensionSession.js.map +1 -1
- package/lib/extensionTransport.js +5 -20
- package/lib/extensionTransport.js.map +1 -1
- package/lib/index.js +0 -42
- package/lib/index.js.map +1 -1
- package/lib/lookerSDKError.js +5 -13
- package/lib/lookerSDKError.js.map +1 -1
- package/lib/oauthSession.js +8 -63
- package/lib/oauthSession.js.map +1 -1
- package/lib/paging.js +5 -70
- package/lib/paging.js.map +1 -1
- package/lib/platformServices.js +1 -1
- package/lib/platformServices.js.map +1 -1
- package/lib/proxySession.js +0 -12
- package/lib/proxySession.js.map +1 -1
- package/lib/testUtils/index.js +0 -2
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/testUtils.js +1 -16
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/transport.d.ts +2 -0
- package/lib/transport.js +8 -50
- package/lib/transport.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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.6.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.5.0...sdk-rtl-v21.6.0) (2023-02-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
|
|
14
|
+
|
|
15
|
+
## [21.5.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.4.0...sdk-rtl-v21.5.0) (2022-12-09)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add request time tracking ([#1223](https://www.github.com/looker-open-source/sdk-codegen/issues/1223)) ([2aefe06](https://www.github.com/looker-open-source/sdk-codegen/commit/2aefe064d668e02f3af95202e4667036cba01979))
|
|
21
|
+
|
|
8
22
|
## [21.4.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-rtl-v21.3.4...sdk-rtl-v21.4.0) (2022-09-21)
|
|
9
23
|
|
|
10
24
|
|
package/lib/CSRFSession.js
CHANGED
|
@@ -4,59 +4,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CSRFSession = void 0;
|
|
7
|
-
|
|
8
7
|
var _browserTransport = require("./browserTransport");
|
|
9
|
-
|
|
10
8
|
var _authSession = require("./authSession");
|
|
11
|
-
|
|
12
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
-
|
|
14
10
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
14
|
class CSRFSession extends _authSession.AuthSession {
|
|
19
15
|
constructor(settings, transport) {
|
|
20
16
|
super(settings, transport || new _browserTransport.BrowserTransport(settings));
|
|
21
17
|
this.settings = settings;
|
|
22
|
-
|
|
23
18
|
_defineProperty(this, "_activeToken", '');
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
get activeToken() {
|
|
27
21
|
if (!this._activeToken) {
|
|
28
22
|
var meta = document.head.querySelector('[name=csrf-token]');
|
|
29
23
|
this._activeToken = meta ? meta.content : '';
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
return this._activeToken;
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
getToken() {
|
|
36
28
|
var _this = this;
|
|
37
|
-
|
|
38
29
|
return _asyncToGenerator(function* () {
|
|
39
30
|
return _this.activeToken;
|
|
40
31
|
})();
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
isAuthenticated() {
|
|
44
34
|
var token = this.activeToken;
|
|
45
35
|
if (!token) return false;
|
|
46
36
|
return true;
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
authenticate(props) {
|
|
50
39
|
var _this2 = this;
|
|
51
|
-
|
|
52
40
|
return _asyncToGenerator(function* () {
|
|
53
41
|
var token = _this2.activeToken;
|
|
54
42
|
if (token) props.headers['X-CSRF-TOKEN'] = token;
|
|
55
43
|
return props;
|
|
56
44
|
})();
|
|
57
45
|
}
|
|
58
|
-
|
|
59
46
|
}
|
|
60
|
-
|
|
61
47
|
exports.CSRFSession = CSRFSession;
|
|
62
48
|
//# sourceMappingURL=CSRFSession.js.map
|
package/lib/CSRFSession.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"CSRFSession.js","names":["CSRFSession","AuthSession","constructor","settings","transport","BrowserTransport","activeToken","_activeToken","meta","document","head","querySelector","content","getToken","isAuthenticated","token","authenticate","props","headers"],"sources":["../src/CSRFSession.ts"],"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"],"mappings":";;;;;;AA4BA;AACA;AAA2C;AAAA;AAAA;AAAA;AAAA;AAUpC,MAAMA,WAAW,SAASC,wBAAW,CAAC;EAE3CC,WAAW,CAAQC,QAAsB,EAAEC,SAAsB,EAAE;IACjE,KAAK,CAACD,QAAQ,EAAEC,SAAS,IAAI,IAAIC,kCAAgB,CAACF,QAAQ,CAAC,CAAC;IAAA,KAD3CA,QAAsB,GAAtBA,QAAsB;IAAA,sCAD1B,EAAE;EAGjB;EAEA,IAAIG,WAAW,GAAG;IAChB,IAAI,CAAC,IAAI,CAACC,YAAY,EAAE;MACtB,IAAMC,IAAI,GAAGC,QAAQ,CAACC,IAAI,CAACC,aAAa,CACtC,mBAAmB,CACD;MACpB,IAAI,CAACJ,YAAY,GAAGC,IAAI,GAAGA,IAAI,CAACI,OAAO,GAAG,EAAE;IAC9C;IACA,OAAO,IAAI,CAACL,YAAY;EAC1B;EAEMM,QAAQ,GAAG;IAAA;IAAA;MACf,OAAO,KAAI,CAACP,WAAW;IAAA;EACzB;EAMAQ,eAAe,GAAG;IAChB,IAAMC,KAAK,GAAG,IAAI,CAACT,WAAW;IAC9B,IAAI,CAACS,KAAK,EAAE,OAAO,KAAK;IACxB,OAAO,IAAI;EACb;EAOMC,YAAY,CAACC,KAAoB,EAAE;IAAA;IAAA;MACvC,IAAMF,KAAK,GAAG,MAAI,CAACT,WAAW;MAC9B,IAAIS,KAAK,EAAEE,KAAK,CAACC,OAAO,CAAC,cAAc,CAAC,GAAGH,KAAK;MAChD,OAAOE,KAAK;IAAA;EACd;AACF;AAAC"}
|
package/lib/apiMethods.js
CHANGED
|
@@ -3,164 +3,123 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.functionalSdk = exports.APIMethods = void 0;
|
|
8
7
|
var _transport = require("./transport");
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
13
|
-
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
-
|
|
16
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
15
|
var functionalSdk = (authSession, apiVersion, sdkVersion) => {
|
|
21
16
|
var sdk = new APIMethods(authSession, sdkVersion);
|
|
22
17
|
sdk.apiVersion = apiVersion;
|
|
23
18
|
sdk.apiPath = authSession.settings.base_url === '' ? '' : authSession.settings.base_url + '/api/' + apiVersion;
|
|
24
19
|
return sdk;
|
|
25
20
|
};
|
|
26
|
-
|
|
27
21
|
exports.functionalSdk = functionalSdk;
|
|
28
|
-
|
|
29
22
|
class APIMethods {
|
|
30
23
|
constructor(authSession, sdkVersion) {
|
|
31
24
|
this.authSession = authSession;
|
|
32
25
|
this.sdkVersion = sdkVersion;
|
|
33
|
-
|
|
34
26
|
_defineProperty(this, "_apiPath", '');
|
|
35
|
-
|
|
36
27
|
_defineProperty(this, "_apiVersion", '');
|
|
37
|
-
|
|
38
28
|
if (!('agentTag' in authSession.settings && authSession.settings.agentTag)) {
|
|
39
29
|
authSession.settings.agentTag = "".concat(_transport.agentPrefix, " ").concat(sdkVersion);
|
|
40
30
|
}
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
get apiPath() {
|
|
44
33
|
return this._apiPath;
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
set apiPath(value) {
|
|
48
36
|
if (this._apiPath) {
|
|
49
37
|
throw new Error("API Path is set to \"".concat(this._apiPath, "\" and cannot be reassigned"));
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
this._apiPath = value;
|
|
53
40
|
}
|
|
54
|
-
|
|
55
41
|
get apiVersion() {
|
|
56
42
|
return this._apiVersion;
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
set apiVersion(value) {
|
|
60
45
|
if (this._apiVersion) {
|
|
61
46
|
throw new Error("API Version is set to \"".concat(this._apiVersion, "\" and cannot be reassigned"));
|
|
62
47
|
}
|
|
63
|
-
|
|
64
48
|
this._apiVersion = value;
|
|
65
49
|
}
|
|
66
|
-
|
|
67
50
|
static create(type, authSession) {
|
|
68
51
|
return new type(authSession);
|
|
69
52
|
}
|
|
70
|
-
|
|
71
53
|
ok(promise) {
|
|
72
54
|
return _asyncToGenerator(function* () {
|
|
73
55
|
return (0, _transport.sdkOk)(promise);
|
|
74
56
|
})();
|
|
75
57
|
}
|
|
76
|
-
|
|
77
58
|
makePath(path, options, authenticator) {
|
|
78
59
|
if (path.match(/^(http:\/\/|https:\/\/)/gi)) return path;
|
|
79
60
|
var base = authenticator ? this.apiPath : options.base_url;
|
|
80
61
|
return "".concat(base).concat(path);
|
|
81
62
|
}
|
|
82
|
-
|
|
83
63
|
authRequest(method, path, queryParams, body, options) {
|
|
84
64
|
var _this = this;
|
|
85
|
-
|
|
86
65
|
return _asyncToGenerator(function* () {
|
|
87
66
|
options = _objectSpread(_objectSpread({}, _this.authSession.settings), options);
|
|
88
|
-
|
|
89
67
|
var authenticator = init => {
|
|
90
68
|
return _this.authSession.authenticate(init);
|
|
91
69
|
};
|
|
92
|
-
|
|
93
70
|
path = _this.makePath(path, options, authenticator);
|
|
94
71
|
return _this.authSession.transport.request(method, path, queryParams, body, authenticator, options);
|
|
95
72
|
})();
|
|
96
73
|
}
|
|
97
|
-
|
|
98
74
|
authStream(callback, method, path, queryParams, body, options) {
|
|
99
75
|
var _this2 = this;
|
|
100
|
-
|
|
101
76
|
return _asyncToGenerator(function* () {
|
|
102
77
|
options = _objectSpread(_objectSpread({}, _this2.authSession.settings), options);
|
|
103
|
-
|
|
104
78
|
var authenticator = init => {
|
|
105
79
|
return _this2.authSession.authenticate(init);
|
|
106
80
|
};
|
|
107
|
-
|
|
108
81
|
path = _this2.makePath(path, options, authenticator);
|
|
109
82
|
return _this2.authSession.transport.stream(callback, method, path, queryParams, body, init => {
|
|
110
83
|
return _this2.authSession.authenticate(init);
|
|
111
84
|
}, options);
|
|
112
85
|
})();
|
|
113
86
|
}
|
|
114
|
-
|
|
115
87
|
get(path, queryParams, body, options) {
|
|
116
88
|
var _this3 = this;
|
|
117
|
-
|
|
118
89
|
return _asyncToGenerator(function* () {
|
|
119
90
|
return _this3.authRequest('GET', path, queryParams, body, options);
|
|
120
91
|
})();
|
|
121
92
|
}
|
|
122
|
-
|
|
123
93
|
head(path, queryParams, body, options) {
|
|
124
94
|
var _this4 = this;
|
|
125
|
-
|
|
126
95
|
return _asyncToGenerator(function* () {
|
|
127
96
|
return _this4.authRequest('HEAD', path, queryParams, body, options);
|
|
128
97
|
})();
|
|
129
98
|
}
|
|
130
|
-
|
|
131
99
|
delete(path, queryParams, body, options) {
|
|
132
100
|
var _this5 = this;
|
|
133
|
-
|
|
134
101
|
return _asyncToGenerator(function* () {
|
|
135
102
|
return _this5.authRequest('DELETE', path, queryParams, body, options);
|
|
136
103
|
})();
|
|
137
104
|
}
|
|
138
|
-
|
|
139
105
|
post(path, queryParams, body, options) {
|
|
140
106
|
var _this6 = this;
|
|
141
|
-
|
|
142
107
|
return _asyncToGenerator(function* () {
|
|
143
108
|
return _this6.authRequest('POST', path, queryParams, body, options);
|
|
144
109
|
})();
|
|
145
110
|
}
|
|
146
|
-
|
|
147
111
|
put(path, queryParams, body, options) {
|
|
148
112
|
var _this7 = this;
|
|
149
|
-
|
|
150
113
|
return _asyncToGenerator(function* () {
|
|
151
114
|
return _this7.authRequest('PUT', path, queryParams, body, options);
|
|
152
115
|
})();
|
|
153
116
|
}
|
|
154
|
-
|
|
155
117
|
patch(path, queryParams, body, options) {
|
|
156
118
|
var _this8 = this;
|
|
157
|
-
|
|
158
119
|
return _asyncToGenerator(function* () {
|
|
159
120
|
return _this8.authRequest('PATCH', path, queryParams, body, options);
|
|
160
121
|
})();
|
|
161
122
|
}
|
|
162
|
-
|
|
163
123
|
}
|
|
164
|
-
|
|
165
124
|
exports.APIMethods = APIMethods;
|
|
166
125
|
//# sourceMappingURL=apiMethods.js.map
|
package/lib/apiMethods.js.map
CHANGED
|
@@ -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":";;;;;;;AAkCA;;;;;;;;;;;;AASO,IAAMA,aAAa,GAAG,CAC3BC,WAD2B,EAE3BC,UAF2B,EAG3BC,UAH2B,KAIxB;AACH,MAAMC,GAAG,GAAG,IAAIC,UAAJ,CAAeJ,WAAf,EAA4BE,UAA5B,CAAZ;AACAC,EAAAA,GAAG,CAACF,UAAJ,GAAiBA,UAAjB;AACAE,EAAAA,GAAG,CAACE,OAAJ,GACEL,WAAW,CAACM,QAAZ,CAAqBC,QAArB,KAAkC,EAAlC,GACI,EADJ,GAEIP,WAAW,CAACM,QAAZ,CAAqBC,QAArB,GAAgC,OAAhC,GAA0CN,UAHhD;AAIA,SAAOE,GAAP;AACD,CAZM;;;;AAkJA,MAAMC,UAAN,CAAwC;AAS7CI,EAAAA,WAAW,CAAQR,WAAR,EAA0CE,UAA1C,EAA8D;AAAA,SAAtDF,WAAsD,GAAtDA,WAAsD;AAAA,SAApBE,UAAoB,GAApBA,UAAoB;;AAAA,sCARtD,EAQsD;;AAAA,yCAPnD,EAOmD;;AACvE,QACE,EAAE,cAAcF,WAAW,CAACM,QAA1B,IAAsCN,WAAW,CAACM,QAAZ,CAAqBG,QAA7D,CADF,EAEE;AAEAT,MAAAA,WAAW,CAACM,QAAZ,CAAqBG,QAArB,aAAmCC,sBAAnC,cAAkDR,UAAlD;AACD;AACF;;AAEU,MAAPG,OAAO,GAAG;AACZ,WAAO,KAAKM,QAAZ;AACD;;AAEU,MAAPN,OAAO,CAACO,KAAD,EAAgB;AACzB,QAAI,KAAKD,QAAT,EAAmB;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AEVO,WAFU,EAGVC,IAHU,EAIVP,OAJU,EAK8B;AAAA;;AAAA;AACxC,aAAO,MAAI,CAACI,WAAL,CACL,QADK,EAELL,IAFK,EAGLO,WAHK,EAILC,IAJK,EAKLP,OALK,CAAP;AADwC;AAQzC;;AAGKkB,EAAAA,IAAI,CACRnB,IADQ,EAERO,WAFQ,EAGRC,IAHQ,EAIRP,OAJQ,EAKgC;AAAA;;AAAA;AACxC,aAAO,MAAI,CAACI,WAAL,CACL,MADK,EAELL,IAFK,EAGLO,WAHK,EAILC,IAJK,EAKLP,OALK,CAAP;AADwC;AAQzC;;AAGKmB,EAAAA,GAAG,CACPpB,IADO,EAEPO,WAFO,EAGPC,IAHO,EAIPP,OAJO,EAKiC;AAAA;;AAAA;AACxC,aAAO,MAAI,CAACI,WAAL,CACL,KADK,EAELL,IAFK,EAGLO,WAHK,EAILC,IAJK,EAKLP,OALK,CAAP;AADwC;AAQzC;;AAGKoB,EAAAA,KAAK,CACTrB,IADS,EAETO,WAFS,EAGTC,IAHS,EAITP,OAJS,EAK+B;AAAA;;AAAA;AACxC,aAAO,MAAI,CAACI,WAAL,CACL,OADK,EAELL,IAFK,EAGLO,WAHK,EAILC,IAJK,EAKLP,OALK,CAAP;AADwC;AAQzC;;AAzR4C","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
|
+
{"version":3,"file":"apiMethods.js","names":["functionalSdk","authSession","apiVersion","sdkVersion","sdk","APIMethods","apiPath","settings","base_url","constructor","agentTag","agentPrefix","_apiPath","value","Error","_apiVersion","create","type","ok","promise","sdkOk","makePath","path","options","authenticator","match","base","authRequest","method","queryParams","body","init","authenticate","transport","request","authStream","callback","stream","get","head","delete","post","put","patch"],"sources":["../src/apiMethods.ts"],"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"],"mappings":";;;;;;AAkCA;AAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzC,IAAMA,aAAa,GAAG,CAC3BC,WAAyB,EACzBC,UAAkB,EAClBC,UAAkB,KACf;EACH,IAAMC,GAAG,GAAG,IAAIC,UAAU,CAACJ,WAAW,EAAEE,UAAU,CAAC;EACnDC,GAAG,CAACF,UAAU,GAAGA,UAAU;EAC3BE,GAAG,CAACE,OAAO,GACTL,WAAW,CAACM,QAAQ,CAACC,QAAQ,KAAK,EAAE,GAChC,EAAE,GACFP,WAAW,CAACM,QAAQ,CAACC,QAAQ,GAAG,OAAO,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ED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.strBadConfiguration = exports.configValue = exports.ValueSettings = exports.DefaultSettings = exports.ApiSettings = exports.ApiConfigMap = void 0;
|
|
8
7
|
var _transport = require("./transport");
|
|
9
|
-
|
|
10
8
|
var _constants = require("./constants");
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
12
|
var ApiConfigMap = envPrefix => {
|
|
15
13
|
if (!envPrefix) return {};
|
|
16
14
|
return {
|
|
@@ -21,27 +19,21 @@ var ApiConfigMap = envPrefix => {
|
|
|
21
19
|
verify_ssl: "".concat(envPrefix, "_VERIFY_SSL")
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
exports.ApiConfigMap = ApiConfigMap;
|
|
26
23
|
var strBadConfiguration = "".concat(_transport.agentPrefix, " configuration error:\nMissing required configuration values like base_url\n");
|
|
27
24
|
exports.strBadConfiguration = strBadConfiguration;
|
|
28
|
-
|
|
29
25
|
var DefaultSettings = () => ({
|
|
30
26
|
agentTag: _transport.agentPrefix,
|
|
31
27
|
base_url: '',
|
|
32
28
|
timeout: _transport.defaultTimeout,
|
|
33
29
|
verify_ssl: true
|
|
34
30
|
});
|
|
35
|
-
|
|
36
31
|
exports.DefaultSettings = DefaultSettings;
|
|
37
|
-
|
|
38
32
|
var configValue = (values, name, envKey) => {
|
|
39
33
|
var val = values[envKey[name]] || values[name];
|
|
40
34
|
return typeof val === 'string' ? (0, _constants.unquote)(val) : val;
|
|
41
35
|
};
|
|
42
|
-
|
|
43
36
|
exports.configValue = configValue;
|
|
44
|
-
|
|
45
37
|
var ValueSettings = (values, envPrefix) => {
|
|
46
38
|
var settings = DefaultSettings();
|
|
47
39
|
var envKey = ApiConfigMap(envPrefix);
|
|
@@ -52,40 +44,28 @@ var ValueSettings = (values, envPrefix) => {
|
|
|
52
44
|
settings.timeout = timeout ? parseInt(timeout, 10) : _transport.defaultTimeout;
|
|
53
45
|
return settings;
|
|
54
46
|
};
|
|
55
|
-
|
|
56
47
|
exports.ValueSettings = ValueSettings;
|
|
57
|
-
|
|
58
48
|
class ApiSettings {
|
|
59
49
|
constructor(settings) {
|
|
60
50
|
var _settings$verify_ssl, _settings$timeout;
|
|
61
|
-
|
|
62
51
|
_defineProperty(this, "base_url", '');
|
|
63
|
-
|
|
64
52
|
_defineProperty(this, "verify_ssl", true);
|
|
65
|
-
|
|
66
53
|
_defineProperty(this, "timeout", _transport.defaultTimeout);
|
|
67
|
-
|
|
68
54
|
_defineProperty(this, "agentTag", _transport.agentPrefix);
|
|
69
|
-
|
|
70
55
|
this.base_url = 'base_url' in settings ? (0, _constants.unquote)(settings.base_url) : this.base_url;
|
|
71
56
|
this.verify_ssl = 'verify_ssl' in settings ? (0, _constants.isTrue)((0, _constants.unquote)((_settings$verify_ssl = settings.verify_ssl) === null || _settings$verify_ssl === void 0 ? void 0 : _settings$verify_ssl.toString())) : this.verify_ssl;
|
|
72
57
|
this.timeout = 'timeout' in settings ? parseInt((0, _constants.unquote)((_settings$timeout = settings.timeout) === null || _settings$timeout === void 0 ? void 0 : _settings$timeout.toString()), 10) : this.timeout;
|
|
73
58
|
if ('agentTag' in settings && settings.agentTag) this.agentTag = settings.agentTag;
|
|
74
|
-
|
|
75
59
|
if (!this.isConfigured()) {
|
|
76
60
|
throw new Error(strBadConfiguration);
|
|
77
61
|
}
|
|
78
62
|
}
|
|
79
|
-
|
|
80
63
|
isConfigured() {
|
|
81
64
|
return !!this.base_url;
|
|
82
65
|
}
|
|
83
|
-
|
|
84
66
|
readConfig(_section) {
|
|
85
67
|
return {};
|
|
86
68
|
}
|
|
87
|
-
|
|
88
69
|
}
|
|
89
|
-
|
|
90
70
|
exports.ApiSettings = ApiSettings;
|
|
91
71
|
//# sourceMappingURL=apiSettings.js.map
|
package/lib/apiSettings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"apiSettings.js","names":["ApiConfigMap","envPrefix","base_url","client_id","client_secret","timeout","verify_ssl","strBadConfiguration","agentPrefix","DefaultSettings","agentTag","defaultTimeout","configValue","values","name","envKey","val","unquote","ValueSettings","settings","boolDefault","parseInt","ApiSettings","constructor","isTrue","toString","isConfigured","Error","readConfig","_section"],"sources":["../src/apiSettings.ts"],"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"],"mappings":";;;;;;AA2BA;AACA;AAA0D;AAAA;AAAA;AAYnD,IAAMA,YAAY,GAAIC,SAAiB,IAAqB;EACjE,IAAI,CAACA,SAAS,EAAE,OAAO,CAAC,CAAC;EACz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exports.AuthSession = void 0;
|
|
7
|
-
|
|
8
7
|
var _transport = require("./transport");
|
|
9
|
-
|
|
10
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
-
|
|
12
9
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
13
|
class AuthSession {
|
|
17
14
|
constructor(settings, transport) {
|
|
18
15
|
_defineProperty(this, "settings", void 0);
|
|
19
|
-
|
|
20
16
|
_defineProperty(this, "sudoId", '');
|
|
21
|
-
|
|
22
17
|
_defineProperty(this, "transport", void 0);
|
|
23
|
-
|
|
24
18
|
this.settings = settings;
|
|
25
19
|
this.transport = transport;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
login(_sudoId) {
|
|
29
22
|
return Promise.reject(AuthSession.TBD);
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
logout() {
|
|
33
25
|
return Promise.resolve(false);
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
isSudo() {
|
|
37
28
|
return this.sudoId !== '' && this.isAuthenticated();
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
reset() {
|
|
41
31
|
this.sudoId = '';
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
ok(promise) {
|
|
45
34
|
return _asyncToGenerator(function* () {
|
|
46
35
|
var result = yield promise;
|
|
47
|
-
|
|
48
36
|
if (result.ok) {
|
|
49
37
|
return result.value;
|
|
50
38
|
} else {
|
|
@@ -58,10 +46,7 @@ class AuthSession {
|
|
|
58
46
|
}
|
|
59
47
|
})();
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
exports.AuthSession = AuthSession;
|
|
65
|
-
|
|
66
51
|
_defineProperty(AuthSession, "TBD", 'Method not implemented in AuthSession');
|
|
67
52
|
//# sourceMappingURL=authSession.js.map
|
package/lib/authSession.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"authSession.js","names":["AuthSession","constructor","settings","transport","login","_sudoId","Promise","reject","TBD","logout","resolve","isSudo","sudoId","isAuthenticated","reset","ok","promise","result","value","Buffer","sdkError","message","toString"],"sources":["../src/authSession.ts"],"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'\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 | null\n /**\n * Documentation link (read-only)\n */\n documentation_url: string | null\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"],"mappings":";;;;;;AA2BA;AAAsC;AAAA;AAAA;AAAA;AAAA;AA4G/B,MAAeA,WAAW,CAAyB;EAM9CC,WAAW,CAACC,QAAsB,EAAEC,SAAqB,EAAE;IAAA;IAAA,gCAH5D,EAAE;IAAA;IAIT,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;EAC5B;EA0BAC,KAAK,CAACC,OAAyB,EAAgB;IAC7C,OAAOC,OAAO,CAACC,MAAM,CAACP,WAAW,CAACQ,GAAG,CAAC;EACxC;EAOAC,MAAM,GAAqB;IACzB,OAAOH,OAAO,CAACI,OAAO,CAAC,KAAK,CAAC;EAC/B;EAKAC,MAAM,GAAY;IAChB,OAAO,IAAI,CAACC,MAAM,KAAK,EAAE,IAAI,IAAI,CAACC,eAAe,EAAE;EACrD;EAKAC,KAAK,GAAS;IACZ,IAAI,CAACF,MAAM,GAAG,EAAE;EAClB;EAEgBG,EAAE,CAChBC,OAA+C,EAC/C;IAAA;MACA,IAAMC,MAAM,SAASD,OAAO;MAC5B,IAAIC,MAAM,CAACF,EAAE,EAAE;QACb,OAAOE,MAAM,CAACC,KAAK;MACrB,CAAC,MAAM;QACL,IAAID,MAAM,YAAYE,MAAM,EAAE;UAC5B,MAAM,IAAAC,mBAAQ,EAAC;YAAEC,OAAO,EAAEJ,MAAM,CAACK,QAAQ,CAAC,MAAM;UAAE,CAAC,CAAC;QACtD,CAAC,MAAM;UACL,MAAM,IAAAF,mBAAQ,EAACH,MAAM,CAAC;QACxB;MACF;IAAC;EACH;AACF;AAAC;AAAA,gBA5EqBjB,WAAW,SAClB,uCAAuC"}
|