@looker/sdk-rtl 21.6.1 → 21.6.3
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 +48 -62
- package/README.md +101 -1
- package/lib/CSRFSession.js +2 -2
- package/lib/CSRFSession.js.map +1 -1
- package/lib/apiMethods.d.ts +2 -19
- package/lib/apiMethods.js +4 -4
- package/lib/apiMethods.js.map +1 -1
- package/lib/apiSettings.d.ts +1 -1
- package/lib/apiSettings.js +3 -4
- package/lib/apiSettings.js.map +1 -1
- package/lib/authSession.js +2 -2
- package/lib/authSession.js.map +1 -1
- package/lib/authToken.js +2 -2
- package/lib/authToken.js.map +1 -1
- package/lib/baseTransport.d.ts +4 -3
- package/lib/baseTransport.js +51 -2
- package/lib/baseTransport.js.map +1 -1
- package/lib/browser.js.map +1 -1
- package/lib/browserServices.js +2 -2
- package/lib/browserServices.js.map +1 -1
- package/lib/browserSession.d.ts +1 -1
- package/lib/browserSession.js +4 -4
- package/lib/browserSession.js.map +1 -1
- package/lib/browserTransport.d.ts +3 -4
- package/lib/browserTransport.js +98 -80
- package/lib/browserTransport.js.map +1 -1
- package/lib/constants.d.ts +4 -4
- package/lib/constants.js +5 -10
- package/lib/constants.js.map +1 -1
- package/lib/cryptoHash.js.map +1 -1
- package/lib/delimArray.d.ts +1 -1
- package/lib/delimArray.js +2 -2
- package/lib/delimArray.js.map +1 -1
- package/lib/errorDoc.d.ts +3 -3
- package/lib/errorDoc.js +7 -10
- package/lib/errorDoc.js.map +1 -1
- package/lib/esm/CSRFSession.js +6 -13
- package/lib/esm/CSRFSession.js.map +1 -1
- package/lib/esm/apiMethods.js +9 -17
- package/lib/esm/apiMethods.js.map +1 -1
- package/lib/esm/apiSettings.js +20 -32
- package/lib/esm/apiSettings.js.map +1 -1
- package/lib/esm/authSession.js +6 -13
- package/lib/esm/authSession.js.map +1 -1
- package/lib/esm/authToken.js +3 -10
- package/lib/esm/authToken.js.map +1 -1
- package/lib/esm/baseTransport.js +55 -13
- package/lib/esm/baseTransport.js.map +1 -1
- package/lib/esm/browser.js +17 -192
- package/lib/esm/browser.js.map +1 -1
- package/lib/esm/browserServices.js +8 -15
- package/lib/esm/browserServices.js.map +1 -1
- package/lib/esm/browserSession.js +12 -19
- package/lib/esm/browserSession.js.map +1 -1
- package/lib/esm/browserTransport.js +104 -94
- package/lib/esm/browserTransport.js.map +1 -1
- package/lib/esm/constants.js +8 -22
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/cryptoHash.js.map +1 -1
- package/lib/esm/delimArray.js +3 -10
- package/lib/esm/delimArray.js.map +1 -1
- package/lib/esm/errorDoc.js +10 -20
- package/lib/esm/errorDoc.js.map +1 -1
- package/lib/esm/extensionSession.js +3 -10
- package/lib/esm/extensionSession.js.map +1 -1
- package/lib/esm/extensionTransport.js +8 -12
- package/lib/esm/extensionTransport.js.map +1 -1
- package/lib/esm/index.js +22 -236
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/lookerSDKError.js +9 -19
- package/lib/esm/lookerSDKError.js.map +1 -1
- package/lib/esm/oauthSession.js +15 -22
- package/lib/esm/oauthSession.js.map +1 -1
- package/lib/esm/paging.js +11 -23
- package/lib/esm/paging.js.map +1 -1
- package/lib/esm/platformServices.js.map +1 -1
- package/lib/esm/proxySession.js +6 -13
- package/lib/esm/proxySession.js.map +1 -1
- package/lib/esm/sleep.js +14 -0
- package/lib/esm/sleep.js.map +1 -0
- package/lib/esm/testUtils/index.js +1 -16
- package/lib/esm/testUtils/index.js.map +1 -1
- package/lib/esm/testUtils/testUtils.js +20 -26
- package/lib/esm/testUtils/testUtils.js.map +1 -1
- package/lib/esm/transport.js +122 -57
- package/lib/esm/transport.js.map +1 -1
- package/lib/extensionSession.d.ts +1 -1
- package/lib/extensionSession.js +2 -2
- package/lib/extensionSession.js.map +1 -1
- package/lib/extensionTransport.d.ts +3 -3
- package/lib/extensionTransport.js +7 -4
- package/lib/extensionTransport.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -1
- package/lib/lookerSDKError.d.ts +1 -1
- package/lib/lookerSDKError.js +9 -13
- package/lib/lookerSDKError.js.map +1 -1
- package/lib/oauthSession.d.ts +6 -4
- package/lib/oauthSession.js +7 -7
- package/lib/oauthSession.js.map +1 -1
- package/lib/paging.d.ts +5 -6
- package/lib/paging.js +4 -6
- package/lib/paging.js.map +1 -1
- package/lib/platformServices.js.map +1 -1
- package/lib/proxySession.d.ts +1 -1
- package/lib/proxySession.js.map +1 -1
- package/lib/sleep.d.ts +1 -0
- package/lib/sleep.js +20 -0
- package/lib/sleep.js.map +1 -0
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/testUtils.js +16 -11
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/transport.d.ts +64 -17
- package/lib/transport.js +113 -20
- package/lib/transport.js.map +1 -1
- package/package.json +5 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","names":["fs","
|
|
1
|
+
{"version":3,"file":"testUtils.js","names":["fs","path","yaml","findRootSync","config","utf8","rootPath","getRootPath","__dirname","rootDir","rootFile","fileName","arguments","length","undefined","join","readFile","readFileSync","TestConfig","testFile","localIni","process","env","LOOKERSDK_INI","testPath","concat","dataFile","testData","existsSync","load","testIni","iniFile"],"sources":["../../../src/testUtils/testUtils.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 * as fs from 'fs';\nimport path from 'path';\nimport * as yaml from 'js-yaml';\nimport { findRootSync } from '@manypkg/find-root';\nimport { config } from 'dotenv';\n\nconst utf8 = 'utf-8';\n\n/**\n * Properties used for various typescript-based tests\n */\nexport interface ITestConfig {\n rootPath: string;\n testPath: string;\n dataFile: string;\n localIni: string;\n testData: any;\n testIni: string;\n}\n\nlet rootPath = '';\n/** fully resolved root dir of the repository */\nexport const getRootPath = (): string => {\n if (!rootPath) {\n rootPath = findRootSync(__dirname).rootDir;\n }\n return rootPath;\n};\n\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName);\nexport const readFile = (fileName: string) => fs.readFileSync(fileName, utf8);\n\n/**\n * Reads configuration information, returning various test values\n * @param {string} rootPath\n * @returns {{testConfig: {[p: string]: any}; localIni: string; baseUrl: any; testData: any; apiVersion: any; testIni: string; configContents: string; rootPath: string; testSection: any; timeout: number}}\n * @constructor\n */\nexport const TestConfig = (rootPath = ''): ITestConfig => {\n config();\n const testFile = 'data.yml';\n rootPath = rootPath || getRootPath();\n let localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini');\n const testPath = `${rootPath}/packages/sdk-codegen-utils/data/`;\n const dataFile = `${testPath}${testFile}`;\n const testData: any = fs.existsSync(dataFile)\n ? yaml.load(fs.readFileSync(dataFile, utf8))\n : {};\n let testIni = `${rootPath}${testData.iniFile}`;\n\n // If .ini files don't exist, don't try to read them downstream and expect environment variables to be set\n if (!fs.existsSync(localIni)) localIni = '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,MAAAC,MAAA,CAAMnB,QAAQ,sCAAmC;EAC/D,IAAMoB,QAAQ,MAAAD,MAAA,CAAMD,QAAQ,EAAAC,MAAA,CAAGN,QAAQ,CAAE;EACzC,IAAMQ,QAAa,GAAG3B,EAAE,CAAC4B,UAAU,CAACF,QAAQ,CAAC,GACzCxB,IAAI,CAAC2B,IAAI,CAAC7B,EAAE,CAACiB,YAAY,CAACS,QAAQ,EAAErB,IAAI,CAAC,CAAC,GAC1C,CAAC,CAAC;EACN,IAAIyB,OAAO,MAAAL,MAAA,CAAMnB,QAAQ,EAAAmB,MAAA,CAAGE,QAAQ,CAACI,OAAO,CAAE;EAG9C,IAAI,CAAC/B,EAAE,CAAC4B,UAAU,CAACR,QAAQ,CAAC,EAAEA,QAAQ,GAAG,EAAE;EAC3C,IAAI,CAACpB,EAAE,CAAC4B,UAAU,CAACE,OAAO,CAAC,EAAEA,OAAO,GAAG,EAAE;EAEzC,OAAO;IACLJ,QAAQ;IACRN,QAAQ;IACRd,QAAQ;IACRqB,QAAQ;IACRG,OAAO;IACPN;EACF,CAAC;AACH,CAAC"}
|
package/lib/esm/transport.js
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.StatusCode = exports.ResponseMode = exports.LookerAppId = void 0;
|
|
7
|
-
exports.addQueryParams = addQueryParams;
|
|
8
|
-
exports.defaultTimeout = exports.contentPatternString = exports.contentPatternBinary = exports.charsetUtf8Pattern = exports.agentPrefix = void 0;
|
|
9
|
-
exports.encodeParam = encodeParam;
|
|
10
|
-
exports.encodeParams = encodeParams;
|
|
11
|
-
exports.isErrorLike = isErrorLike;
|
|
12
|
-
exports.isUtf8 = isUtf8;
|
|
13
|
-
exports.responseMode = responseMode;
|
|
14
|
-
exports.safeBase64 = safeBase64;
|
|
15
|
-
exports.sdkError = sdkError;
|
|
16
|
-
exports.sdkOk = sdkOk;
|
|
17
|
-
exports.trace = trace;
|
|
18
|
-
var _constants = require("./constants");
|
|
19
|
-
var _delimArray = require("./delimArray");
|
|
20
|
-
var _lookerSDKError = require("./lookerSDKError");
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
6
|
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); } }
|
|
22
7
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
import { matchCharsetUtf8, matchModeBinary, matchModeString } from './constants';
|
|
9
|
+
import { DelimArray } from './delimArray';
|
|
10
|
+
import { LookerSDKError } from './lookerSDKError';
|
|
11
|
+
import { sleep } from './sleep';
|
|
12
|
+
export var agentPrefix = 'TS-SDK';
|
|
13
|
+
export var LookerAppId = 'x-looker-appid';
|
|
14
|
+
export var MaxTries = 3;
|
|
27
15
|
var tracing = false;
|
|
28
|
-
function trace(message, info) {
|
|
16
|
+
export function trace(message, info) {
|
|
29
17
|
if (tracing) {
|
|
30
18
|
console.debug(message);
|
|
31
19
|
if (info) {
|
|
@@ -35,22 +23,20 @@ function trace(message, info) {
|
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
|
-
|
|
26
|
+
export function canRetry(statusCode) {
|
|
27
|
+
return statusCode === StatusCode.Accepted || statusCode === StatusCode.TooManyRequests || statusCode === StatusCode.ServiceUnavailable;
|
|
28
|
+
}
|
|
29
|
+
export var ResponseMode = function (ResponseMode) {
|
|
39
30
|
ResponseMode[ResponseMode["binary"] = 0] = "binary";
|
|
40
31
|
ResponseMode[ResponseMode["string"] = 1] = "string";
|
|
41
32
|
ResponseMode[ResponseMode["unknown"] = 2] = "unknown";
|
|
42
33
|
return ResponseMode;
|
|
43
34
|
}({});
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
var charsetUtf8Pattern = new RegExp(_constants.matchCharsetUtf8, 'i');
|
|
50
|
-
exports.charsetUtf8Pattern = charsetUtf8Pattern;
|
|
51
|
-
var defaultTimeout = 120;
|
|
52
|
-
exports.defaultTimeout = defaultTimeout;
|
|
53
|
-
var StatusCode = function (StatusCode) {
|
|
35
|
+
export var contentPatternString = new RegExp(matchModeString, 'i');
|
|
36
|
+
export var contentPatternBinary = new RegExp(matchModeBinary, 'i');
|
|
37
|
+
export var charsetUtf8Pattern = new RegExp(matchCharsetUtf8, 'i');
|
|
38
|
+
export var defaultTimeout = 120;
|
|
39
|
+
export var StatusCode = function (StatusCode) {
|
|
54
40
|
StatusCode[StatusCode["OK"] = 200] = "OK";
|
|
55
41
|
StatusCode[StatusCode["Created"] = 201] = "Created";
|
|
56
42
|
StatusCode[StatusCode["Accepted"] = 202] = "Accepted";
|
|
@@ -112,8 +98,7 @@ var StatusCode = function (StatusCode) {
|
|
|
112
98
|
StatusCode[StatusCode["NetworkAuthRequired"] = 511] = "NetworkAuthRequired";
|
|
113
99
|
return StatusCode;
|
|
114
100
|
}({});
|
|
115
|
-
|
|
116
|
-
function responseMode(contentType) {
|
|
101
|
+
export function responseMode(contentType) {
|
|
117
102
|
if (contentType.match(contentPatternString)) {
|
|
118
103
|
return ResponseMode.string;
|
|
119
104
|
}
|
|
@@ -122,13 +107,13 @@ function responseMode(contentType) {
|
|
|
122
107
|
}
|
|
123
108
|
return ResponseMode.unknown;
|
|
124
109
|
}
|
|
125
|
-
function isUtf8(contentType) {
|
|
110
|
+
export function isUtf8(contentType) {
|
|
126
111
|
return contentType.match(/;.*\bcharset\b=\butf-8\b/i);
|
|
127
112
|
}
|
|
128
|
-
function encodeParam(value) {
|
|
113
|
+
export function encodeParam(value) {
|
|
129
114
|
if (value instanceof Date) {
|
|
130
115
|
value = value.toISOString();
|
|
131
|
-
} else if (value instanceof
|
|
116
|
+
} else if (value instanceof DelimArray) {
|
|
132
117
|
value = value.toString();
|
|
133
118
|
}
|
|
134
119
|
var encoded = typeof value === 'object' ? JSON.stringify(value) : value.toString();
|
|
@@ -146,12 +131,12 @@ function encodeParam(value) {
|
|
|
146
131
|
}
|
|
147
132
|
return encoded;
|
|
148
133
|
}
|
|
149
|
-
function encodeParams(values) {
|
|
134
|
+
export function encodeParams(values) {
|
|
150
135
|
if (!values) return '';
|
|
151
136
|
var keys = Object.keys(values);
|
|
152
137
|
return keys.filter(k => values[k] !== undefined).map(k => k + '=' + encodeParam(values[k])).join('&');
|
|
153
138
|
}
|
|
154
|
-
function addQueryParams(path, obj) {
|
|
139
|
+
export function addQueryParams(path, obj) {
|
|
155
140
|
if (!obj) {
|
|
156
141
|
return path;
|
|
157
142
|
}
|
|
@@ -177,38 +162,39 @@ function bufferString(val) {
|
|
|
177
162
|
}
|
|
178
163
|
return result;
|
|
179
164
|
}
|
|
180
|
-
function sdkError(response) {
|
|
165
|
+
export function sdkError(response) {
|
|
181
166
|
if (typeof response === 'string') {
|
|
182
|
-
return new
|
|
167
|
+
return new LookerSDKError(response);
|
|
183
168
|
}
|
|
184
169
|
if ('error' in response) {
|
|
185
170
|
var _error = response.error;
|
|
186
171
|
if (typeof _error === 'string') {
|
|
187
|
-
return new
|
|
172
|
+
return new LookerSDKError(_error);
|
|
188
173
|
}
|
|
189
174
|
if ('error' in _error) {
|
|
190
175
|
var _result = bufferString(_error.error);
|
|
191
|
-
return new
|
|
176
|
+
return new LookerSDKError(_result);
|
|
192
177
|
}
|
|
193
178
|
if ('message' in _error) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
179
|
+
var _error$errors, _error$documentation_;
|
|
180
|
+
return new LookerSDKError(response.error.message.toString(), {
|
|
181
|
+
errors: (_error$errors = _error === null || _error === void 0 ? void 0 : _error.errors) !== null && _error$errors !== void 0 ? _error$errors : [],
|
|
182
|
+
documentation_url: (_error$documentation_ = _error === null || _error === void 0 ? void 0 : _error.documentation_url) !== null && _error$documentation_ !== void 0 ? _error$documentation_ : ''
|
|
197
183
|
});
|
|
198
184
|
}
|
|
199
185
|
if ('statusMessage' in _error) {
|
|
200
|
-
return new
|
|
186
|
+
return new LookerSDKError(_error.statusMessage);
|
|
201
187
|
}
|
|
202
188
|
var result = bufferString(_error);
|
|
203
|
-
return new
|
|
189
|
+
return new LookerSDKError(result);
|
|
204
190
|
}
|
|
205
191
|
if ('message' in response) {
|
|
206
|
-
return new
|
|
192
|
+
return new LookerSDKError(response.message);
|
|
207
193
|
}
|
|
208
194
|
var error = JSON.stringify(response);
|
|
209
|
-
return new
|
|
195
|
+
return new LookerSDKError("Unknown error with SDK method ".concat(error));
|
|
210
196
|
}
|
|
211
|
-
function sdkOk(_x) {
|
|
197
|
+
export function sdkOk(_x) {
|
|
212
198
|
return _sdkOk.apply(this, arguments);
|
|
213
199
|
}
|
|
214
200
|
function _sdkOk() {
|
|
@@ -222,15 +208,94 @@ function _sdkOk() {
|
|
|
222
208
|
});
|
|
223
209
|
return _sdkOk.apply(this, arguments);
|
|
224
210
|
}
|
|
225
|
-
function safeBase64(u8) {
|
|
211
|
+
export function safeBase64(u8) {
|
|
226
212
|
var rawBase64 = btoa(String.fromCharCode(...u8));
|
|
227
213
|
return rawBase64.replace(/\+/g, '-').replace(/\//g, '_');
|
|
228
214
|
}
|
|
229
|
-
function isErrorLike(error) {
|
|
215
|
+
export function isErrorLike(error) {
|
|
230
216
|
if (typeof error !== 'object') return false;
|
|
231
217
|
if (!error) return false;
|
|
232
218
|
if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false;
|
|
233
219
|
if (typeof error.message !== 'string') return false;
|
|
234
220
|
return true;
|
|
235
221
|
}
|
|
222
|
+
export function jittery(attempt) {
|
|
223
|
+
var baseDelayMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
224
|
+
var maxDelayMs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000;
|
|
225
|
+
var jitterFactor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
|
|
226
|
+
var exponentialDelay = baseDelayMs * Math.pow(2, attempt);
|
|
227
|
+
exponentialDelay = Math.min(exponentialDelay, maxDelayMs);
|
|
228
|
+
var jitter = Math.random() * jitterFactor * exponentialDelay;
|
|
229
|
+
var delayWithJitter = exponentialDelay + jitter;
|
|
230
|
+
return delayWithJitter;
|
|
231
|
+
}
|
|
232
|
+
export function retryWait(_x2) {
|
|
233
|
+
return _retryWait.apply(this, arguments);
|
|
234
|
+
}
|
|
235
|
+
function _retryWait() {
|
|
236
|
+
_retryWait = _asyncToGenerator(function* (wait) {
|
|
237
|
+
yield sleep(wait.waitMS);
|
|
238
|
+
return {
|
|
239
|
+
response: 'retry',
|
|
240
|
+
reason: "waited ".concat(wait.waitMS, " ms")
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
return _retryWait.apply(this, arguments);
|
|
244
|
+
}
|
|
245
|
+
export function pauseForRetry(_x3, _x4, _x5) {
|
|
246
|
+
return _pauseForRetry.apply(this, arguments);
|
|
247
|
+
}
|
|
248
|
+
function _pauseForRetry() {
|
|
249
|
+
_pauseForRetry = _asyncToGenerator(function* (rawRequest, rawResponse, attempt) {
|
|
250
|
+
var waiter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : retryWait;
|
|
251
|
+
var retryAfter = rawResponse.headers['Retry-After'];
|
|
252
|
+
var after = (retryAfter ? Number(retryAfter) : 1.0) * 1000;
|
|
253
|
+
var jitter = jittery(attempt, after);
|
|
254
|
+
var response = yield waiter({
|
|
255
|
+
request: rawRequest,
|
|
256
|
+
response: rawResponse,
|
|
257
|
+
attempt,
|
|
258
|
+
waitMS: jitter
|
|
259
|
+
});
|
|
260
|
+
return response;
|
|
261
|
+
});
|
|
262
|
+
return _pauseForRetry.apply(this, arguments);
|
|
263
|
+
}
|
|
264
|
+
export var mergeOptions = (base, custom) => {
|
|
265
|
+
var _base$headers$custom$;
|
|
266
|
+
var headers = (_base$headers$custom$ = _objectSpread(_objectSpread({}, base.headers), custom.headers)) !== null && _base$headers$custom$ !== void 0 ? _base$headers$custom$ : {};
|
|
267
|
+
var result = _objectSpread(_objectSpread(_objectSpread({}, base), custom), {
|
|
268
|
+
headers
|
|
269
|
+
});
|
|
270
|
+
return result;
|
|
271
|
+
};
|
|
272
|
+
export function initResponse(method, requestPath) {
|
|
273
|
+
return {
|
|
274
|
+
method,
|
|
275
|
+
url: requestPath,
|
|
276
|
+
body: 'no reply at all',
|
|
277
|
+
contentType: 'text/plain',
|
|
278
|
+
ok: false,
|
|
279
|
+
statusCode: 404,
|
|
280
|
+
statusMessage: 'Not found',
|
|
281
|
+
headers: {},
|
|
282
|
+
requestStarted: 0,
|
|
283
|
+
responseCompleted: 0
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
export function retryError(response) {
|
|
287
|
+
response.statusCode = StatusCode.RequestTimeout;
|
|
288
|
+
response.ok = false;
|
|
289
|
+
if (!response.statusMessage) {
|
|
290
|
+
response.statusMessage = 'Retry waiting exited with an error condition';
|
|
291
|
+
}
|
|
292
|
+
return response;
|
|
293
|
+
}
|
|
294
|
+
export function verifySsl(options) {
|
|
295
|
+
return options && 'verify_ssl' in options ? options.verify_ssl : true;
|
|
296
|
+
}
|
|
297
|
+
export function sdkTimeout(options) {
|
|
298
|
+
if (options && 'timeout' in options && options.timeout && options.timeout > 0) return options.timeout;
|
|
299
|
+
return defaultTimeout;
|
|
300
|
+
}
|
|
236
301
|
//# sourceMappingURL=transport.js.map
|
package/lib/esm/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","names":["_constants","require","_delimArray","_lookerSDKError","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","agentPrefix","exports","LookerAppId","tracing","trace","message","console","debug","ResponseMode","contentPatternString","RegExp","matchModeString","contentPatternBinary","matchModeBinary","charsetUtf8Pattern","matchCharsetUtf8","defaultTimeout","StatusCode","responseMode","contentType","match","string","binary","unknown","isUtf8","encodeParam","Date","toISOString","DelimArray","toString","encoded","JSON","stringify","decoded","decodeURIComponent","encodeURIComponent","e","URIError","encodeParams","values","keys","Object","filter","k","map","join","addQueryParams","path","obj","qp","concat","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","sdkError","response","LookerSDKError","errors","documentation_url","statusMessage","sdkOk","_x","_sdkOk","promise","ok","safeBase64","u8","rawBase64","btoa","String","fromCharCode","replace","isErrorLike","prototype","hasOwnProperty","call"],"sources":["../../src/transport.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 { Agent } from 'https'\nimport type { Headers } from 'request'\nimport type { Readable } from 'readable-stream'\nimport { matchCharsetUtf8, matchModeBinary, matchModeString } from './constants'\nimport { DelimArray } from './delimArray'\nimport { LookerSDKError } from './lookerSDKError'\n\nexport const agentPrefix = 'TS-SDK'\nexport const LookerAppId = 'x-looker-appid'\n\n/** Set to `true` to follow streaming process */\nconst tracing = false\n\n/**\n * trivial tracing function that should be replaced with a log plugin\n * @param message description for trace\n * @param info any additional information to produce for output\n */\nexport function trace(message: string, info?: any) {\n if (tracing) {\n // eslint-disable-next-line no-console\n console.debug(message)\n if (info) {\n // eslint-disable-next-line no-console\n console.debug({ info })\n }\n }\n}\n\n/** ResponseMode for an HTTP request */\nexport enum ResponseMode {\n 'binary', // this is a binary response\n 'string', // this is a \"string\" response\n 'unknown', // unrecognized response type\n}\n\n/**\n * MIME patterns for string content types\n * @type {RegExp}\n */\nexport const contentPatternString = new RegExp(matchModeString, 'i')\n\n/**\n * MIME patterns for \"binary\" content types\n * @type {RegExp}\n */\nexport const contentPatternBinary = new RegExp(matchModeBinary, 'i')\n\n/**\n * MIME pattern for UTF8 charset attribute\n * @type {RegExp}\n */\nexport const charsetUtf8Pattern = new RegExp(matchCharsetUtf8, 'i')\n\n/**\n * Default request timeout\n * @type {number} default request timeout is 120 seconds, or two minutes\n */\nexport const defaultTimeout = 120\n\n/** Recognized HTTP methods */\nexport type HttpMethod =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'TRACE'\n | 'HEAD'\n\n/**\n * HTTP status codes\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for reference\n * TODO is there a platform-agnostic list of these that can be used instead of this static declaration?\n */\nexport enum StatusCode {\n OK = 200,\n Created,\n Accepted,\n NonAuthoritative,\n NoContent,\n ResetContent,\n PartialContent,\n MultiStatus,\n MultiStatusDav,\n IMUsed = 226,\n MultipleChoice = 300,\n MovedPermanently,\n Found,\n SeeOther,\n NotModified,\n UseProxy,\n UnusedRedirect,\n TemporaryRedirect,\n PermanentRedirect,\n BadRequest = 400,\n Unauthorized,\n PaymentRequired,\n Forbidden,\n NotFound,\n MethodNotAllowed,\n NotAcceptable,\n ProxyAuthRequired,\n RequestTimeout,\n Conflict,\n Gone,\n LengthRequired,\n PreconditionFailed,\n PayloadTooLarge,\n UriTooLong,\n UnsupportedMediaType,\n RequestedRangeNotSatisfiable,\n ExpectationFailed,\n ImATeapot,\n MisdirectedRequest = 421,\n UnprocessableEntity,\n Locked,\n FailedDependency,\n TooEarly,\n UpgradeRequired,\n PreconditionRequired = 428,\n TooManyRequests,\n RequestHeaderFieldsTooLarge = 431,\n UnavailableForLegalReasons = 451,\n InternalServerError = 500,\n NotImplemented,\n BadGateway,\n ServiceUnavailable,\n GatewayTimeout,\n HttpVersionNotSupported,\n VariantAlsoNegotiates,\n InsufficientStorage,\n LoopDetected,\n NotExtended = 510,\n NetworkAuthRequired,\n}\n\n/** Untyped basic HTTP response type for \"raw\" HTTP requests */\nexport interface IRawResponse {\n /** Http method of the request */\n method: HttpMethod\n /** ok is `true` if the response is successful, `false` otherwise */\n ok: boolean\n /** HTTP request url */\n url: string\n /** HTTP response code */\n statusCode: number\n /** HTTP response status message text */\n statusMessage: string\n /** MIME type of the response from the HTTP response header */\n contentType: string\n /** The body of the HTTP response, without any additional processing */\n body: any\n /** Optional performance tracking starting mark name */\n startMark?: string\n /** Response headers */\n headers: IRequestHeaders\n /** Request start time */\n requestStarted: number\n /** Completion time for request */\n responseCompleted: number\n}\n\n/** IRawResponse observer function type */\nexport type RawObserver = (raw: IRawResponse) => IRawResponse\n\n/** Transport plug-in interface */\nexport interface ITransport {\n /** Observer lambda to process raw responses */\n observer: RawObserver | undefined\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * Note: This method returns the result of the HTTP request without any error handling\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 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 * HTTP request function for atomic, fully downloaded responses\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 request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * Processes the raw response, converting it into an SDKResponse\n * @param raw response result\n */\n parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * HTTP request function for a streamable response\n * @param callback that receives the stream response and pipes it somewhere\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 `T` upon success\n * @throws `ISDKErrorResponse` on failure\n */\n stream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n}\n\n/** A successful SDK call. */\nexport interface ISDKSuccessResponse<T> {\n /** Whether the SDK call was successful. */\n ok: true\n /** The object returned by the SDK call. */\n value: T\n}\n\n/** An errant SDK call. */\nexport interface ISDKErrorResponse<T> {\n /** Whether the SDK call was successful. */\n ok: false\n /** The error object returned by the SDK call. */\n error: T\n}\n\n/** An error representing an issue in the SDK, like a network or parsing error. */\nexport interface ISDKError {\n type: 'sdk_error'\n message: string\n}\n\nexport type SDKResponse<TSuccess, TError> =\n | ISDKSuccessResponse<TSuccess>\n | ISDKErrorResponse<TError | ISDKError>\n\n/** Generic collection */\nexport interface IRequestHeaders {\n [key: string]: string\n}\n\n/**\n * Generic http request property collection\n * TODO: Trim this down to what is required\n */\nexport interface IRequestProps {\n [key: string]: any\n /** full url for request, including any query params */\n url: string\n\n /** body of request. optional */\n body?: any\n /** headers for request. optional */\n headers: IRequestHeaders\n /** Http method for request. required. */\n method: HttpMethod\n /** Redirect processing for request. optional */\n redirect?: any\n /** Credentials to use */\n credentials?: 'include' | 'omit' | 'same-origin' | undefined\n\n /** http.Agent instance, allows custom proxy, certificate etc. */\n agent?: Agent\n /** support gzip/deflate content encoding. false to disable */\n compress?: boolean\n /** maximum redirect count. 0 to not follow redirect */\n follow?: number\n /** maximum response body size in bytes */\n size?: number\n /** req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) */\n timeout?: number\n}\n\n/** General purpose authentication callback */\nexport type Authenticator = (props: any) => any\n\n/** Interface for API transport values */\nexport interface ITransportSettings {\n [key: string]: any\n /** base URL of API REST web service */\n base_url: string\n /** standard headers to provide in all transport requests */\n headers?: Headers\n /** whether to verify ssl certs or not. Defaults to true */\n verify_ssl: boolean\n /** request timeout in seconds. Default to 30 */\n timeout: number\n /** encoding override */\n encoding?: string | null\n /** agent tag to use for the SDK requests */\n agentTag: string\n}\n\n/**\n * Is the content type binary or \"string\"?\n * @param {string} contentType\n * @returns {ResponseMode.binary | ResponseMode.string}\n */\nexport function responseMode(contentType: string) {\n if (contentType.match(contentPatternString)) {\n return ResponseMode.string\n }\n if (contentType.match(contentPatternBinary)) {\n return ResponseMode.binary\n }\n return ResponseMode.unknown\n}\n\n/**\n * Does this content type have a UTF-8 charset?\n * @param contentType\n * @returns match if it exists\n */\nexport function isUtf8(contentType: string) {\n return contentType.match(/;.*\\bcharset\\b=\\butf-8\\b/i)\n}\n\n/** Used for name/value pair collections like for QueryParams */\nexport type Values = { [key: string]: any } | null | undefined\n\n/**\n * Encode parameter if not already encoded\n *\n * Note: this includes recognition of Date, DelimArray, and default objects for special handling\n *\n * @param value value of parameter\n * @returns URI encoded value\n */\nexport function encodeParam(value: any) {\n if (value instanceof Date) {\n value = value.toISOString()\n } else if (value instanceof DelimArray) {\n value = value.toString()\n }\n // check for object type to prevent \"[object Object]\" as the value.toString()\n let encoded =\n typeof value === 'object' ? JSON.stringify(value) : value.toString()\n\n // decodeURIComponent throws URIError if there is a % character\n // without it being part of an encoded\n try {\n const decoded = decodeURIComponent(value)\n if (value === decoded) {\n encoded = encodeURIComponent(value)\n }\n } catch (e) {\n if (e instanceof URIError) {\n encoded = encodeURIComponent(value)\n } else {\n throw e\n }\n }\n return encoded\n}\n\n/**\n * Converts `Values` to query string parameter format\n * @param values Name/value collection to encode\n * @returns {string} query string parameter formatted values. Both `false` and `null` are included. Only `undefined` are omitted.\n */\nexport function encodeParams(values?: Values) {\n if (!values) return ''\n\n const keys = Object.keys(values)\n return keys\n .filter((k) => values[k] !== undefined) // `null` and `false` will both be passed\n .map((k) => k + '=' + encodeParam(values[k]))\n .join('&')\n}\n\n/**\n * constructs the path argument including any optional query parameters\n * @param path the base path of the request\n * @param obj optional collection of query parameters to encode and append to the path\n */\nexport function addQueryParams(path: string, obj?: Values) {\n if (!obj) {\n return path\n }\n const qp = encodeParams(obj)\n return `${path}${qp ? '?' + qp : ''}`\n}\n\nconst utf8 = 'utf-8'\n\n/**\n * Convert this value to a string representation however we can do it\n * @param val\n */\nfunction bufferString(val: any) {\n let result = 'Unknown error'\n try {\n const decoder = new TextDecoder(utf8)\n result = decoder.decode(val)\n } catch (e: any) {\n // Supremely ugly hack. If we get here, we must be in Node (or IE 11, but who cares about that?)\n // Node requires an import from `util` for TextDecoder to be found BUT it \"just has\" Buffer unless WebPack messes us up\n try {\n if (val instanceof Buffer) {\n result = Buffer.from(val).toString(utf8)\n } else {\n result = JSON.stringify(val)\n }\n } catch (err: any) {\n // The fallback logic here will at least give us some information about the error being thrown\n result = JSON.stringify(val)\n }\n }\n return result\n}\n\n/**\n * SDK error handler\n * @param response any kind of error\n * @returns a new `Error` object with the failure message\n */\nexport function sdkError(response: any) {\n if (typeof response === 'string') {\n return new LookerSDKError(response)\n }\n if ('error' in response) {\n const error = response.error\n if (typeof error === 'string') {\n return new LookerSDKError(error)\n }\n // Try to get most specific error first\n if ('error' in error) {\n const result = bufferString(error.error)\n return new LookerSDKError(result)\n }\n if ('message' in error) {\n return new LookerSDKError(response.error.message.toString(), {\n errors: error.errors,\n documentation_url: error.documentation_url,\n })\n }\n if ('statusMessage' in error) {\n return new LookerSDKError(error.statusMessage)\n }\n const result = bufferString(error)\n return new LookerSDKError(result)\n }\n if ('message' in response) {\n return new LookerSDKError(response.message)\n }\n const error = JSON.stringify(response)\n return new LookerSDKError(`Unknown error with SDK method ${error}`)\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 sdkOk(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\nexport async function sdkOk<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 throw sdkError(result)\n }\n}\n\n/**\n * Converts a byte array to a \"URL safe\" base64 string\n * @param u8 byte array to convert\n */\nexport function safeBase64(u8: Uint8Array) {\n const rawBase64 = btoa(String.fromCharCode(...u8))\n return rawBase64.replace(/\\+/g, '-').replace(/\\//g, '_')\n}\n\n/**\n * Type predicate. Asserts that a given object is error-like.\n * @param error a value of unknown type\n * @return boolean true if the error has a `message` key of type string.\n */\nexport function isErrorLike<T extends unknown>(\n error: T\n): error is T & { message: string } {\n if (typeof error !== 'object') return false\n if (!error) return false\n if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false\n if (typeof (error as unknown as { message: unknown }).message !== 'string')\n return false\n return true\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAAiD,SAAAG,mBAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,GAAA,EAAAC,GAAA,cAAAC,IAAA,GAAAP,GAAA,CAAAK,GAAA,EAAAC,GAAA,OAAAE,K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,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAC1D;AAOO,SAASC,WAAWA,CACzB1F,KAAQ,EAC0B;EAClC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,KAAK;EAC3C,IAAI,CAACA,KAAK,EAAE,OAAO,KAAK;EACxB,IAAI,CAACqD,MAAM,CAACsC,SAAS,CAACC,cAAc,CAACC,IAAI,CAAC7F,KAAK,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK;EACzE,IAAI,OAAQA,KAAK,CAAqCiB,OAAO,KAAK,QAAQ,EACxE,OAAO,KAAK;EACd,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"transport.js","names":["matchCharsetUtf8","matchModeBinary","matchModeString","DelimArray","LookerSDKError","sleep","agentPrefix","LookerAppId","MaxTries","tracing","trace","message","info","console","debug","canRetry","statusCode","StatusCode","Accepted","TooManyRequests","ServiceUnavailable","ResponseMode","contentPatternString","RegExp","contentPatternBinary","charsetUtf8Pattern","defaultTimeout","responseMode","contentType","match","string","binary","unknown","isUtf8","encodeParam","value","Date","toISOString","toString","encoded","JSON","stringify","decoded","decodeURIComponent","encodeURIComponent","e","URIError","encodeParams","values","keys","Object","filter","k","undefined","map","join","addQueryParams","path","obj","qp","concat","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","err","sdkError","response","error","_error$errors","_error$documentation_","errors","documentation_url","statusMessage","sdkOk","_x","_sdkOk","apply","arguments","_asyncToGenerator","promise","ok","safeBase64","u8","rawBase64","btoa","String","fromCharCode","replace","isErrorLike","prototype","hasOwnProperty","call","jittery","attempt","baseDelayMs","length","maxDelayMs","jitterFactor","exponentialDelay","Math","pow","min","jitter","random","delayWithJitter","retryWait","_x2","_retryWait","wait","waitMS","reason","pauseForRetry","_x3","_x4","_x5","_pauseForRetry","rawRequest","rawResponse","waiter","retryAfter","headers","after","Number","request","mergeOptions","base","custom","_base$headers$custom$","_objectSpread","initResponse","method","requestPath","url","body","requestStarted","responseCompleted","retryError","RequestTimeout","verifySsl","options","verify_ssl","sdkTimeout","timeout"],"sources":["../../src/transport.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 { Agent } from 'https';\nimport {\n matchCharsetUtf8,\n matchModeBinary,\n matchModeString,\n} from './constants';\nimport { DelimArray } from './delimArray';\nimport { LookerSDKError } from './lookerSDKError';\nimport type { IAuthSession } from './authSession';\nimport { sleep } from './sleep';\n\nexport const agentPrefix = 'TS-SDK';\nexport const LookerAppId = 'x-looker-appid';\n\n/** default maximum number of retries to attempt */\nexport const MaxTries = 3;\n\n/** Set to `true` to turn on tracing wherever it may be referenced in the sdk */\nconst tracing = false;\n\n/**\n * trivial tracing function that should be replaced with a log plugin\n * @param message description for trace\n * @param info any additional information to produce for output\n */\nexport function trace(message: string, info?: any) {\n if (tracing) {\n // eslint-disable-next-line no-console\n console.debug(message);\n if (info) {\n // eslint-disable-next-line no-console\n console.debug({ info });\n }\n }\n}\n\n/**\n * is this status code retryable?\n *\n * @returns true if statusCode is 202, 429, or 503\n * @param statusCode HTTP status code\n *\n */\nexport function canRetry(statusCode: number) {\n return (\n statusCode === StatusCode.Accepted ||\n statusCode === StatusCode.TooManyRequests ||\n statusCode === StatusCode.ServiceUnavailable\n );\n}\n\n/** ResponseMode for an HTTP request */\nexport enum ResponseMode {\n 'binary', // this is a binary response\n 'string', // this is a \"string\" response\n 'unknown', // unrecognized response type\n}\n\n/**\n * MIME patterns for string content types\n * @type {RegExp}\n */\nexport const contentPatternString = new RegExp(matchModeString, 'i');\n\n/**\n * MIME patterns for \"binary\" content types\n * @type {RegExp}\n */\nexport const contentPatternBinary = new RegExp(matchModeBinary, 'i');\n\n/**\n * MIME pattern for UTF8 charset attribute\n * @type {RegExp}\n */\nexport const charsetUtf8Pattern = new RegExp(matchCharsetUtf8, 'i');\n\n/**\n * Default request timeout\n * @type {number} default request timeout is 120 seconds, or two minutes\n */\nexport const defaultTimeout = 120;\n\n/** Recognized HTTP methods */\nexport type HttpMethod =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'TRACE'\n | 'HEAD';\n\n/**\n * HTTP status codes\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for reference\n * TODO is there a platform-agnostic list of these that can be used instead of this static declaration?\n */\nexport enum StatusCode {\n OK = 200,\n Created,\n Accepted,\n NonAuthoritative,\n NoContent,\n ResetContent,\n PartialContent,\n MultiStatus,\n MultiStatusDav,\n IMUsed = 226,\n MultipleChoice = 300,\n MovedPermanently,\n Found,\n SeeOther,\n NotModified,\n UseProxy,\n UnusedRedirect,\n TemporaryRedirect,\n PermanentRedirect,\n BadRequest = 400,\n Unauthorized,\n PaymentRequired,\n Forbidden,\n NotFound,\n MethodNotAllowed,\n NotAcceptable,\n ProxyAuthRequired,\n RequestTimeout,\n Conflict,\n Gone,\n LengthRequired,\n PreconditionFailed,\n PayloadTooLarge,\n UriTooLong,\n UnsupportedMediaType,\n RequestedRangeNotSatisfiable,\n ExpectationFailed,\n ImATeapot,\n MisdirectedRequest = 421,\n UnprocessableEntity,\n Locked,\n FailedDependency,\n TooEarly,\n UpgradeRequired,\n PreconditionRequired = 428,\n TooManyRequests,\n RequestHeaderFieldsTooLarge = 431,\n UnavailableForLegalReasons = 451,\n InternalServerError = 500,\n NotImplemented,\n BadGateway,\n ServiceUnavailable,\n GatewayTimeout,\n HttpVersionNotSupported,\n VariantAlsoNegotiates,\n InsufficientStorage,\n LoopDetected,\n NotExtended = 510,\n NetworkAuthRequired,\n}\n\n/** Property bag for submitting an HTTP request */\nexport interface IRawRequest {\n /** HTTP request method */\n method: HttpMethod;\n /** HTTP Request path */\n path: string;\n /** optional query parameters collection */\n queryParams?: Values;\n /** optional request body */\n body?: any;\n /** optional API authenticator callback */\n authenticator?: Authenticator;\n /** optional transport settings overrides */\n options?: Partial<ITransportSettings>;\n}\n\n/** Untyped basic HTTP response type for \"raw\" HTTP requests */\nexport interface IRawResponse {\n /** Http method of the request */\n method: HttpMethod;\n /** ok is `true` if the response is successful, `false` otherwise */\n ok: boolean;\n /** HTTP request url */\n url: string;\n /** HTTP response code */\n statusCode: number;\n /** HTTP response status message text */\n statusMessage: string;\n /** MIME type of the response from the HTTP response header */\n contentType: string;\n /** The body of the HTTP response, without any additional processing */\n body: any;\n /** Optional performance tracking starting mark name */\n startMark?: string;\n /** Response headers */\n headers: IRequestHeaders;\n /** Request start time */\n requestStarted: number;\n /** Completion time for request */\n responseCompleted: number;\n}\n\n/** IRawResponse observer function type */\nexport type RawObserver = (raw: IRawResponse) => IRawResponse;\n\n/** A successful SDK call. */\nexport interface ISDKSuccessResponse<T> {\n /** Whether the SDK call was successful. */\n ok: true;\n /** The object returned by the SDK call. */\n value: T;\n}\n\n/** An errant SDK call. */\nexport interface ISDKErrorResponse<T> {\n /** Whether the SDK call was successful. */\n ok: false;\n /** The error object returned by the SDK call. */\n error: T;\n}\n\n/** An error representing an issue in the SDK, like a network or parsing error. */\nexport interface ISDKError {\n type: 'sdk_error';\n message: string;\n}\n\nexport type SDKResponse<TSuccess, TError> =\n | ISDKSuccessResponse<TSuccess>\n | ISDKErrorResponse<TError | ISDKError>;\n\n/** Keyed string hash */\nexport interface IRequestHeaders {\n [key: string]: string;\n}\n\n/**\n * Generic http request property collection\n * TODO: Trim this down to what is required\n */\nexport interface IRequestProps {\n [key: string]: any;\n /** full url for request, including any query params */\n url: string;\n\n /** body of request. optional */\n body?: any;\n /** headers for request. optional */\n headers: IRequestHeaders;\n /** Http method for request. required. */\n method: HttpMethod;\n /** Redirect processing for request. optional */\n redirect?: any;\n /** Credentials to use */\n credentials?: 'include' | 'omit' | 'same-origin' | undefined;\n\n /** http.Agent instance, allows custom proxy, certificate etc. */\n agent?: Agent;\n /** support gzip/deflate content encoding. false to disable */\n compress?: boolean;\n /** maximum redirect count. 0 to not follow redirect */\n follow?: number;\n /** maximum response body size in bytes */\n size?: number;\n /** req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) */\n timeout?: number;\n}\n\n/** General purpose authentication callback */\nexport type Authenticator = (props: any) => any;\n\n/** Alpha: Properties for an async Waitable retry handler */\nexport interface IWait {\n /** HTTP request that responded with a retry code */\n request: IRawRequest;\n /** HTTP response that is a retry */\n response: IRawResponse;\n /** Attempt number for the retry */\n attempt: number;\n /** Time in milliseconds to wait before retrying */\n waitMS: number;\n}\n\n/** Alpha: Response from a Waitable function */\nexport interface IWaitResponse {\n /** cancel, retry, or error are the allowed responses for the retryable waiter */\n response: 'cancel' | 'retry' | 'error';\n /** Optional reason for the response */\n reason?: string;\n}\n\n/** Alpha: Waitable function override for retrying an HTTP request */\nexport type Waitable = (waiting: IWait) => Promise<IWaitResponse>;\n\n/** Interface for API transport values */\nexport interface ITransportSettings {\n [key: string]: any;\n /** base URL of API REST web service */\n base_url: string;\n /** standard headers to provide in all transport requests */\n headers?: IRequestHeaders;\n /** whether to verify ssl certs or not. Defaults to true */\n verify_ssl: boolean;\n /** request timeout in seconds. Default to 30 */\n timeout: number;\n /** encoding override */\n encoding?: string | null;\n /** agent tag to use for the SDK requests */\n agentTag: string;\n /** maximum number of times for a retry response */\n maxTries?: number;\n /** override for awaiting retry requests */\n waitHandler?: Waitable;\n /** abort controller signal customization */\n signal?: AbortSignal;\n}\n\n/** Transport plug-in interface */\nexport interface ITransport {\n /** Observer lambda to process raw responses */\n observer: RawObserver | undefined;\n\n /**\n * default retryable HTTP request. If maxTries > 1 in the `options`\n * properties for the SDK, this is where HTTP requests will be retried.\n */\n retry(request: IRawRequest): Promise<IRawResponse>;\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * Note: This method returns the result of the HTTP request without any error handling\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 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 * HTTP request function for atomic, fully downloaded responses\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 request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>;\n\n /**\n * Processes the raw response, converting it into an SDKResponse\n * @param raw response result\n */\n parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>;\n\n /**\n * HTTP request function for a streamable response\n * @param callback that receives the stream response and pipes it somewhere\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 `T` upon success\n * @throws `ISDKErrorResponse` on failure\n */\n stream<T>(\n callback: (response: Response) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>;\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 method type of HTTP method\n * @param path API endpoint path\n * @param queryParams Optional query params collection for request\n * @param body Optional body for request\n * @param 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 callback\n * @param method HTTP method\n * @param path HTTP request path\n * @param queryParams query string parameters\n * @param body of the request\n * @param options Optional overrides like timeout and verify_ssl\n * @returns {Promise<T>}\n */\n authStream<T>(\n callback: (response: Response) => 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\n/**\n * Is the content type binary or \"string\"?\n * @param contentType MIME content type description\n * @returns {ResponseMode.binary | ResponseMode.string}\n */\nexport function responseMode(contentType: string) {\n if (contentType.match(contentPatternString)) {\n return ResponseMode.string;\n }\n if (contentType.match(contentPatternBinary)) {\n return ResponseMode.binary;\n }\n return ResponseMode.unknown;\n}\n\n/**\n * Does this content type have a UTF-8 charset?\n * @param contentType\n * @returns match if it exists\n */\nexport function isUtf8(contentType: string) {\n return contentType.match(/;.*\\bcharset\\b=\\butf-8\\b/i);\n}\n\n/** Used for name/value pair collections like for QueryParams */\nexport type Values = { [key: string]: any } | null | undefined;\n\n/**\n * Encode parameter if not already encoded\n *\n * Note: this includes recognition of Date, DelimArray, and default objects for special handling\n *\n * @param value value of parameter\n * @returns URI encoded value\n */\nexport function encodeParam(value: any) {\n if (value instanceof Date) {\n value = value.toISOString();\n } else if (value instanceof DelimArray) {\n value = value.toString();\n }\n // check for object type to prevent \"[object Object]\" as the value.toString()\n let encoded =\n typeof value === 'object' ? JSON.stringify(value) : value.toString();\n\n // decodeURIComponent throws URIError if there is a % character\n // without it being part of an encoded\n try {\n const decoded = decodeURIComponent(value);\n if (value === decoded) {\n encoded = encodeURIComponent(value);\n }\n } catch (e) {\n if (e instanceof URIError) {\n encoded = encodeURIComponent(value);\n } else {\n throw e;\n }\n }\n return encoded;\n}\n\n/**\n * Converts `Values` to query string parameter format\n * @param values Name/value collection to encode\n * @returns {string} query string parameter formatted values. Both `false` and `null` are included. Only `undefined` are omitted.\n */\nexport function encodeParams(values?: Values) {\n if (!values) return '';\n\n const keys = Object.keys(values);\n return keys\n .filter(k => values[k] !== undefined) // `null` and `false` will both be passed\n .map(k => k + '=' + encodeParam(values[k]))\n .join('&');\n}\n\n/**\n * constructs the path argument including any optional query parameters\n * @param path the base path of the request\n * @param obj optional collection of query parameters to encode and append to the path\n */\nexport function addQueryParams(path: string, obj?: Values) {\n if (!obj) {\n return path;\n }\n const qp = encodeParams(obj);\n return `${path}${qp ? '?' + qp : ''}`;\n}\n\nconst utf8 = 'utf-8';\n\n/**\n * Convert this value to a string representation however we can do it\n * @param val\n */\nfunction bufferString(val: any) {\n let result = 'Unknown error';\n try {\n const decoder = new TextDecoder(utf8);\n result = decoder.decode(val);\n } catch (e: any) {\n // Supremely ugly hack. If we get here, we must be in Node (or IE 11, but who cares about that?)\n // Node requires an import from `util` for TextDecoder to be found BUT it \"just has\" Buffer unless WebPack messes us up\n try {\n if (val instanceof Buffer) {\n result = Buffer.from(val).toString(utf8);\n } else {\n result = JSON.stringify(val);\n }\n } catch (err: any) {\n // The fallback logic here will at least give us some information about the error being thrown\n result = JSON.stringify(val);\n }\n }\n return result;\n}\n\n/**\n * SDK error handler\n * @param response any kind of error\n * @returns a new `Error` object with the failure message\n */\nexport function sdkError(response: any) {\n if (typeof response === 'string') {\n return new LookerSDKError(response);\n }\n if ('error' in response) {\n const error = response.error;\n if (typeof error === 'string') {\n return new LookerSDKError(error);\n }\n // Try to get most specific error first\n if ('error' in error) {\n const result = bufferString(error.error);\n return new LookerSDKError(result);\n }\n if ('message' in error) {\n return new LookerSDKError(response.error.message.toString(), {\n errors: error?.errors ?? [],\n documentation_url: error?.documentation_url ?? '',\n });\n }\n if ('statusMessage' in error) {\n return new LookerSDKError(error.statusMessage);\n }\n const result = bufferString(error);\n return new LookerSDKError(result);\n }\n if ('message' in response) {\n return new LookerSDKError(response.message);\n }\n const error = JSON.stringify(response);\n return new LookerSDKError(`Unknown error with SDK method ${error}`);\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 sdkOk(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\nexport async function sdkOk<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 throw sdkError(result);\n }\n}\n\n/**\n * Converts a byte array to a \"URL safe\" base64 string\n * @param u8 byte array to convert\n */\nexport function safeBase64(u8: Uint8Array) {\n const rawBase64 = btoa(String.fromCharCode(...u8));\n return rawBase64.replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Type predicate. Asserts that a given object is error-like.\n * @param error a value of unknown type\n * @return boolean true if the error has a `message` key of type string.\n */\nexport function isErrorLike<T>(error: T): error is T & { message: string } {\n if (typeof error !== 'object') return false;\n if (!error) return false;\n if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false;\n if (typeof (error as unknown as { message: unknown }).message !== 'string')\n return false;\n return true;\n}\n\n/**\n * Calculate complete delay for exponential backoff/retry with jitter\n * @param attempt count of attempts\n * @param baseDelayMs minimum delay, based on `Retry-After` header\n * @param maxDelayMs maximum delay to allow\n * @param jitterFactor multiplication factor for jitter value\n */\nexport function jittery(\n attempt: number,\n baseDelayMs = 1000,\n maxDelayMs = 10000,\n jitterFactor = 0.5\n): number {\n // Exponential Backoff: Double the delay with each retry\n let exponentialDelay = baseDelayMs * Math.pow(2, attempt);\n\n // Cap the delay to prevent excessive wait times\n exponentialDelay = Math.min(exponentialDelay, maxDelayMs);\n\n // Apply Jitter: Introduce randomness to avoid retry collisions\n const jitter = Math.random() * jitterFactor * exponentialDelay;\n const delayWithJitter = exponentialDelay + jitter;\n\n return delayWithJitter;\n}\n\n/**\n * Default retry waiting function. Called after jitter period is calculated\n * @param wait parameters for request/response/attempt and wait time\n */\nexport async function retryWait(wait: IWait): Promise<IWaitResponse> {\n await sleep(wait.waitMS);\n return { response: 'retry', reason: `waited ${wait.waitMS} ms` };\n}\n\n/**\n * Calculate the jitter time and call the waiter\n * @param rawRequest request that had a retry. `options.maxTries` is available here.\n * @param rawResponse retry response\n * @param attempt count of attempts made.\n * @param waiter function to perform waiting process\n */\nexport async function pauseForRetry(\n rawRequest: IRawRequest,\n rawResponse: IRawResponse,\n attempt: number,\n waiter: Waitable = retryWait\n) {\n // calculate minimum delay in MS\n const retryAfter = rawResponse.headers['Retry-After'];\n const after = (retryAfter ? Number(retryAfter) : 1.0) * 1000;\n // randomize the retry\n const jitter = jittery(attempt, after);\n const response = await waiter({\n request: rawRequest,\n response: rawResponse,\n attempt,\n waitMS: jitter,\n });\n return response;\n}\n\n/**\n * Merge base settings with custom settings, ensuring no header overrides are lost\n * @param base settings\n * @param custom settings\n */\nexport const mergeOptions = (\n base: Partial<ITransportSettings>,\n custom: Partial<ITransportSettings>\n): Partial<ITransportSettings> => {\n const headers = { ...base.headers, ...custom.headers } ?? {};\n const result = { ...base, ...custom, ...{ headers } };\n return result;\n};\n\n/**\n * Create a default \"no reply\" response object for retry loops\n * @param method Http method for initialization\n * @param requestPath Http path for request to initialize\n */\nexport function initResponse(\n method: HttpMethod,\n requestPath: string\n): IRawResponse {\n return {\n method,\n url: requestPath,\n body: 'no reply at all',\n contentType: 'text/plain',\n ok: false,\n statusCode: 404,\n statusMessage: 'Not found',\n headers: {},\n requestStarted: 0,\n responseCompleted: 0,\n };\n}\n\n/**\n * Modify and return response object indicating retry waiting had an error\n * @param response to modify\n */\nexport function retryError(response: IRawResponse): IRawResponse {\n // retry wait function decided on 'error' so throw an error equivalent\n response.statusCode = StatusCode.RequestTimeout;\n response.ok = false;\n if (!response.statusMessage) {\n response.statusMessage = 'Retry waiting exited with an error condition';\n }\n return response;\n}\n\n/**\n * should the request verify SSL?\n * @param options Defaults to the instance options values\n * @returns true (the default) if the request should require full SSL verification\n */\nexport function verifySsl(options?: Partial<ITransportSettings>) {\n return options && 'verify_ssl' in options ? options.verify_ssl : true;\n}\n\n/**\n * Get the HTTP request timeout, in seconds\n *\n * The configured timeout value must be > 0 to be used\n *\n * @param options Defaults to `defaultTimeout`\n */\nexport function sdkTimeout(options?: Partial<ITransportSettings>): number {\n if (options && 'timeout' in options && options.timeout && options.timeout > 0)\n return options.timeout;\n return defaultTimeout;\n}\n"],"mappings":";;;;;;;AA2BA,SACEA,gBAAgB,EAChBC,eAAe,EACfC,eAAe,QACV,aAAa;AACpB,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,SAASC,KAAK,QAAQ,SAAS;AAE/B,OAAO,IAAMC,WAAW,GAAG,QAAQ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AAC;IACjBC,iBAAiB,EAAE;EACrB,CAAC;AACH;AAMA,OAAO,SAASC,UAAUA,CAACtE,QAAsB,EAAgB;EAE/DA,QAAQ,CAACxD,UAAU,GAAGC,UAAU,CAAC8H,cAAc;EAC/CvE,QAAQ,CAACc,EAAE,GAAG,KAAK;EACnB,IAAI,CAACd,QAAQ,CAACM,aAAa,EAAE;IAC3BN,QAAQ,CAACM,aAAa,GAAG,8CAA8C;EACzE;EACA,OAAON,QAAQ;AACjB;AAOA,OAAO,SAASwE,SAASA,CAACC,OAAqC,EAAE;EAC/D,OAAOA,OAAO,IAAI,YAAY,IAAIA,OAAO,GAAGA,OAAO,CAACC,UAAU,GAAG,IAAI;AACvE;AASA,OAAO,SAASC,UAAUA,CAACF,OAAqC,EAAU;EACxE,IAAIA,OAAO,IAAI,SAAS,IAAIA,OAAO,IAAIA,OAAO,CAACG,OAAO,IAAIH,OAAO,CAACG,OAAO,GAAG,CAAC,EAC3E,OAAOH,OAAO,CAACG,OAAO;EACxB,OAAO1H,cAAc;AACvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IApiSettings } from './apiSettings';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IRequestProps, ITransport } from './transport';
|
|
3
3
|
import type { IAuthSession } from './authSession';
|
|
4
4
|
export declare class ExtensionSession implements IAuthSession {
|
|
5
5
|
settings: IApiSettings;
|
package/lib/extensionSession.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.ExtensionSession = void 0;
|
|
|
7
7
|
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); } }
|
|
8
8
|
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); }); }; }
|
|
9
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(
|
|
11
|
-
function _toPrimitive(
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
12
|
class ExtensionSession {
|
|
13
13
|
constructor(settings, transport) {
|
|
14
14
|
this.settings = settings;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionSession.js","names":["ExtensionSession","constructor","settings","transport","_defineProperty","isAuthenticated","authenticate","init","_asyncToGenerator","Promise","reject","Error","concat","getToken","isSudo","login","sudoId","logout","reset","exports"],"sources":["../src/extensionSession.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'
|
|
1
|
+
{"version":3,"file":"extensionSession.js","names":["ExtensionSession","constructor","settings","transport","_defineProperty","isAuthenticated","authenticate","init","_asyncToGenerator","Promise","reject","Error","concat","getToken","isSudo","login","sudoId","logout","reset","exports"],"sources":["../src/extensionSession.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 type { IAuthSession } from './authSession';\n\nexport class ExtensionSession implements IAuthSession {\n sudoId = '';\n transport: ITransport;\n\n constructor(public settings: IApiSettings, transport: ITransport) {\n this.settings = settings;\n this.transport = transport;\n }\n\n isAuthenticated() {\n // Assume if the extension exists then it is authenticated\n return true;\n }\n\n async authenticate(init: IRequestProps) {\n return Promise.reject(\n Error(\n `Authenticate ${\n init ? 'request property overrides' : ''\n } not supported from ExtensionSession`\n )\n );\n }\n\n async getToken(): Promise<any> {\n return Promise.reject(\n Error('Access to token is not allowed from ExtensionSession')\n );\n }\n\n isSudo(): boolean {\n throw new Error('isSudo is not allowed from ExtensionSession');\n }\n\n async login(sudoId?: string | number): Promise<any> {\n return Promise.reject(\n Error(\n `Login ${sudoId ? 'for sudo' : ''} not supported from ExtensionSession`\n )\n );\n }\n\n async logout(): Promise<boolean> {\n return Promise.reject(Error('Logout not supported from ExtensionSession'));\n }\n\n reset(): void {\n // noop\n }\n}\n"],"mappings":";;;;;;;;;;;AA8BO,MAAMA,gBAAgB,CAAyB;EAIpDC,WAAWA,CAAQC,QAAsB,EAAEC,SAAqB,EAAE;IAAA,KAA/CD,QAAsB,GAAtBA,QAAsB;IAAAE,eAAA,iBAHhC,EAAE;IAAAA,eAAA;IAIT,IAAI,CAACF,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;EAC5B;EAEAE,eAAeA,CAAA,EAAG;IAEhB,OAAO,IAAI;EACb;EAEMC,YAAYA,CAACC,IAAmB,EAAE;IAAA,OAAAC,iBAAA;MACtC,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,iBAAAC,MAAA,CAEDL,IAAI,GAAG,4BAA4B,GAAG,EAAE,yCAE5C,CACF,CAAC;IAAC;EACJ;EAEMM,QAAQA,CAAA,EAAiB;IAAA,OAAAL,iBAAA;MAC7B,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,CAAC,sDAAsD,CAC9D,CAAC;IAAC;EACJ;EAEAG,MAAMA,CAAA,EAAY;IAChB,MAAM,IAAIH,KAAK,CAAC,6CAA6C,CAAC;EAChE;EAEMI,KAAKA,CAACC,MAAwB,EAAgB;IAAA,OAAAR,iBAAA;MAClD,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,UAAAC,MAAA,CACMI,MAAM,GAAG,UAAU,GAAG,EAAE,yCACnC,CACF,CAAC;IAAC;EACJ;EAEMC,MAAMA,CAAA,EAAqB;IAAA,OAAAT,iBAAA;MAC/B,OAAOC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAAC;EAC7E;EAEAO,KAAKA,CAAA,EAAS,CAEd;AACF;AAACC,OAAA,CAAAnB,gBAAA,GAAAA,gBAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Authenticator, Values, SDKResponse, ITransport, ITransportSettings, HttpMethod, IRawResponse, RawObserver } from './transport';
|
|
1
|
+
import type { Authenticator, HttpMethod, IRawRequest, IRawResponse, ITransport, ITransportSettings, RawObserver, SDKResponse, Values } from './transport';
|
|
3
2
|
export interface IHostConnection {
|
|
4
3
|
rawRequest(httpMethod: string, path: string, body?: any, params?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<IRawResponse>;
|
|
5
4
|
request(httpMethod: string, path: string, body?: any, params?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<any>;
|
|
6
|
-
stream<T>(callback: (readable:
|
|
5
|
+
stream<T>(callback: (readable: any) => Promise<T>, method: HttpMethod, path: string, queryParams?: Values, body?: any, authenticator?: Authenticator, options?: Partial<ITransportSettings>): Promise<T>;
|
|
7
6
|
}
|
|
8
7
|
export declare class ExtensionTransport implements ITransport {
|
|
9
8
|
private readonly options;
|
|
@@ -14,4 +13,5 @@ export declare class ExtensionTransport implements ITransport {
|
|
|
14
13
|
request<TSuccess, TError>(method: HttpMethod, path: string, queryParams?: any, body?: any, authenticator?: any, options?: Partial<ITransportSettings>): Promise<SDKResponse<TSuccess, TError>>;
|
|
15
14
|
stream<TSuccess>(callback: (readable: any) => Promise<TSuccess>, method: HttpMethod, path: string, queryParams?: any, body?: any, authenticator?: any, options?: Partial<ITransportSettings>): Promise<TSuccess>;
|
|
16
15
|
parseResponse<TSuccess, TError>(_raw: IRawResponse): Promise<SDKResponse<TSuccess, TError>>;
|
|
16
|
+
retry(_request: IRawRequest): Promise<IRawResponse>;
|
|
17
17
|
}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExtensionTransport = void 0;
|
|
7
|
-
function ownKeys(
|
|
8
|
-
function _objectSpread(
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
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); } }
|
|
10
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); }); }; }
|
|
11
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(
|
|
13
|
-
function _toPrimitive(
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
14
|
class ExtensionTransport {
|
|
15
15
|
constructor(options, hostConnection) {
|
|
16
16
|
this.options = options;
|
|
@@ -46,6 +46,9 @@ class ExtensionTransport {
|
|
|
46
46
|
};
|
|
47
47
|
return Promise.resolve(result);
|
|
48
48
|
}
|
|
49
|
+
retry(_request) {
|
|
50
|
+
return Promise.reject(new Error('TODO: retry not implemented yet'));
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
exports.ExtensionTransport = ExtensionTransport;
|
|
51
54
|
//# sourceMappingURL=extensionTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionTransport.js","names":["ExtensionTransport","constructor","options","hostConnection","_defineProperty","rawRequest","method","path","queryParams","body","authenticator","_this","_asyncToGenerator","response","observer","request","_this2","stream","callback","_this3","_objectSpread","parseResponse","_raw","result","ok","error","Error","Promise","resolve","exports"],"sources":["../src/extensionTransport.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 {
|
|
1
|
+
{"version":3,"file":"extensionTransport.js","names":["ExtensionTransport","constructor","options","hostConnection","_defineProperty","rawRequest","method","path","queryParams","body","authenticator","_this","_asyncToGenerator","response","observer","request","_this2","stream","callback","_this3","_objectSpread","parseResponse","_raw","result","ok","error","Error","Promise","resolve","retry","_request","reject","exports"],"sources":["../src/extensionTransport.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 {\n Authenticator,\n HttpMethod,\n IRawRequest,\n IRawResponse,\n ITransport,\n ITransportSettings,\n RawObserver,\n SDKResponse,\n Values,\n} from './transport';\n\nexport interface IHostConnection {\n rawRequest(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>;\n\n request(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<any>;\n\n stream<T>(\n callback: (readable: any) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>;\n}\n\nexport class ExtensionTransport implements ITransport {\n constructor(\n private readonly options: ITransportSettings,\n private hostConnection: IHostConnection\n ) {\n this.options = options;\n this.hostConnection = hostConnection;\n }\n\n observer: RawObserver | undefined;\n\n async rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse> {\n const response = await this.hostConnection.rawRequest(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n return this.observer ? this.observer(response) : response;\n }\n\n async request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.hostConnection.request(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n }\n\n async stream<TSuccess>(\n callback: (readable: any) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n options = options ? { ...this.options, ...options } : this.options;\n return this.hostConnection.stream(\n callback,\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n }\n\n parseResponse<TSuccess, TError>(\n _raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>> {\n const result: SDKResponse<TSuccess, TError> = {\n ok: false,\n error: new Error('Should not be called!') as unknown as TError,\n };\n return Promise.resolve(result);\n }\n\n retry(_request: IRawRequest): Promise<IRawResponse> {\n // TODO implement this\n return Promise.reject(new Error('TODO: retry not implemented yet'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAoEO,MAAMA,kBAAkB,CAAuB;EACpDC,WAAWA,CACQC,OAA2B,EACpCC,cAA+B,EACvC;IAAA,KAFiBD,OAA2B,GAA3BA,OAA2B;IAAA,KACpCC,cAA+B,GAA/BA,cAA+B;IAAAC,eAAA;IAEvC,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAGA,cAAc;EACtC;EAIME,UAAUA,CACdC,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EACd;IAAA,IAAAS,KAAA;IAAA,OAAAC,iBAAA;MACvB,IAAMC,QAAQ,SAASF,KAAI,CAACR,cAAc,CAACE,UAAU,CACnDC,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbR,OACF,CAAC;MACD,OAAOS,KAAI,CAACG,QAAQ,GAAGH,KAAI,CAACG,QAAQ,CAACD,QAAQ,CAAC,GAAGA,QAAQ;IAAC;EAC5D;EAEME,OAAOA,CACXT,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EACG;IAAA,IAAAc,MAAA;IAAA,OAAAJ,iBAAA;MACxC,OAAOI,MAAI,CAACb,cAAc,CAACY,OAAO,CAChCT,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbR,OACF,CAAC;IAAC;EACJ;EAEMe,MAAMA,CACVC,QAA8C,EAC9CZ,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EAClB;IAAA,IAAAiB,MAAA;IAAA,OA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