@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.js","names":["utf8","homeToRoost","getRootPath","path","join","__dirname","rootFile","fileName","readFile","fs","readFileSync","TestConfig","rootPath","config","testFile","localIni","process","env","LOOKERSDK_INI","testPath","dataFile","testData","JSON","parse","testIni","iniFile","existsSync"],"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 { 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\nconst homeToRoost = '../../../../'\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost)\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.json'\n rootPath = rootPath || getRootPath()\n let localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini')\n const testPath = rootFile('test/')\n const dataFile = `${testPath}${testFile}`\n const testData = JSON.parse(fs.readFileSync(dataFile, utf8))\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 = ''\n if (!fs.existsSync(testIni)) testIni = ''\n\n return {\n dataFile,\n localIni,\n rootPath,\n testData,\n testIni,\n testPath,\n }\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAA+B;AAAA;AAAA;AAE/B,IAAMA,IAAI,GAAG,OAAO;AAcpB,IAAMC,WAAW,GAAG,cAAc;AAE3B,IAAMC,WAAW,GAAG,MAAMC,aAAI,CAACC,IAAI,CAACC,SAAS,EAAEJ,WAAW,CAAC;AAAA;AAC3D,IAAMK,QAAQ,GAAG,SAAXA,QAAQ;EAAA,IAAIC,QAAQ,uEAAG,EAAE;EAAA,OAAKJ,aAAI,CAACC,IAAI,CAACF,WAAW,EAAE,EAAEK,QAAQ,CAAC;AAAA;AAAA;AACtE,IAAMC,QAAQ,GAAID,QAAgB,IAAKE,EAAE,CAACC,YAAY,CAACH,QAAQ,EAAEP,IAAI,CAAC;AAAA;AAQtE,IAAMW,UAAU,GAAG,SAAbA,UAAU,GAAmC;EAAA,IAA/BC,QAAQ,uEAAG,EAAE;EACtC,IAAAC,cAAM,GAAE;EACR,IAAMC,QAAQ,GAAG,eAAe;EAChCF,QAAQ,GAAGA,QAAQ,IAAIV,WAAW,EAAE;EACpC,IAAIa,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,aAAa,IAAIZ,QAAQ,CAAC,YAAY,CAAC;EAClE,IAAMa,QAAQ,GAAGb,QAAQ,CAAC,OAAO,CAAC;EAClC,IAAMc,QAAQ,aAAMD,QAAQ,SAAGL,QAAQ,CAAE;EACzC,IAAMO,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACd,EAAE,CAACC,YAAY,CAACU,QAAQ,EAAEpB,IAAI,CAAC,CAAC;EAC5D,IAAIwB,OAAO,aAAMZ,QAAQ,SAAGS,QAAQ,CAACI,OAAO,CAAE;EAG9C,IAAI,CAAChB,EAAE,CAACiB,UAAU,CAACX,QAAQ,CAAC,EAAEA,QAAQ,GAAG,EAAE;EAC3C,IAAI,CAACN,EAAE,CAACiB,UAAU,CAACF,OAAO,CAAC,EAAEA,OAAO,GAAG,EAAE;EAEzC,OAAO;IACLJ,QAAQ;IACRL,QAAQ;IACRH,QAAQ;IACRS,QAAQ;IACRG,OAAO;IACPL;EACF,CAAC;AACH,CAAC;AAAA"}
|
package/lib/esm/transport.js
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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
21
|
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); } }
|
|
2
|
-
|
|
3
22
|
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); }); }; }
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export var agentPrefix = 'TS-SDK';
|
|
9
|
-
export var LookerAppId = 'x-looker-appid';
|
|
23
|
+
var agentPrefix = 'TS-SDK';
|
|
24
|
+
exports.agentPrefix = agentPrefix;
|
|
25
|
+
var LookerAppId = 'x-looker-appid';
|
|
26
|
+
exports.LookerAppId = LookerAppId;
|
|
10
27
|
var tracing = false;
|
|
11
|
-
|
|
28
|
+
function trace(message, info) {
|
|
12
29
|
if (tracing) {
|
|
13
30
|
console.debug(message);
|
|
14
|
-
|
|
15
31
|
if (info) {
|
|
16
32
|
console.debug({
|
|
17
33
|
info
|
|
@@ -19,20 +35,23 @@ export function trace(message, info) {
|
|
|
19
35
|
}
|
|
20
36
|
}
|
|
21
37
|
}
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
var ResponseMode;
|
|
39
|
+
exports.ResponseMode = ResponseMode;
|
|
24
40
|
(function (ResponseMode) {
|
|
25
41
|
ResponseMode[ResponseMode["binary"] = 0] = "binary";
|
|
26
42
|
ResponseMode[ResponseMode["string"] = 1] = "string";
|
|
27
43
|
ResponseMode[ResponseMode["unknown"] = 2] = "unknown";
|
|
28
|
-
})(ResponseMode || (ResponseMode = {}));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
})(ResponseMode || (exports.ResponseMode = ResponseMode = {}));
|
|
45
|
+
var contentPatternString = new RegExp(_constants.matchModeString, 'i');
|
|
46
|
+
exports.contentPatternString = contentPatternString;
|
|
47
|
+
var contentPatternBinary = new RegExp(_constants.matchModeBinary, 'i');
|
|
48
|
+
exports.contentPatternBinary = contentPatternBinary;
|
|
49
|
+
var charsetUtf8Pattern = new RegExp(_constants.matchCharsetUtf8, 'i');
|
|
50
|
+
exports.charsetUtf8Pattern = charsetUtf8Pattern;
|
|
51
|
+
var defaultTimeout = 120;
|
|
52
|
+
exports.defaultTimeout = defaultTimeout;
|
|
53
|
+
var StatusCode;
|
|
54
|
+
exports.StatusCode = StatusCode;
|
|
36
55
|
(function (StatusCode) {
|
|
37
56
|
StatusCode[StatusCode["OK"] = 200] = "OK";
|
|
38
57
|
StatusCode[StatusCode["Created"] = 201] = "Created";
|
|
@@ -93,34 +112,28 @@ export var StatusCode;
|
|
|
93
112
|
StatusCode[StatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
94
113
|
StatusCode[StatusCode["NotExtended"] = 510] = "NotExtended";
|
|
95
114
|
StatusCode[StatusCode["NetworkAuthRequired"] = 511] = "NetworkAuthRequired";
|
|
96
|
-
})(StatusCode || (StatusCode = {}));
|
|
97
|
-
|
|
98
|
-
export function responseMode(contentType) {
|
|
115
|
+
})(StatusCode || (exports.StatusCode = StatusCode = {}));
|
|
116
|
+
function responseMode(contentType) {
|
|
99
117
|
if (contentType.match(contentPatternString)) {
|
|
100
118
|
return ResponseMode.string;
|
|
101
119
|
}
|
|
102
|
-
|
|
103
120
|
if (contentType.match(contentPatternBinary)) {
|
|
104
121
|
return ResponseMode.binary;
|
|
105
122
|
}
|
|
106
|
-
|
|
107
123
|
return ResponseMode.unknown;
|
|
108
124
|
}
|
|
109
|
-
|
|
125
|
+
function isUtf8(contentType) {
|
|
110
126
|
return contentType.match(/;.*\bcharset\b=\butf-8\b/i);
|
|
111
127
|
}
|
|
112
|
-
|
|
128
|
+
function encodeParam(value) {
|
|
113
129
|
if (value instanceof Date) {
|
|
114
130
|
value = value.toISOString();
|
|
115
|
-
} else if (value instanceof DelimArray) {
|
|
131
|
+
} else if (value instanceof _delimArray.DelimArray) {
|
|
116
132
|
value = value.toString();
|
|
117
133
|
}
|
|
118
|
-
|
|
119
134
|
var encoded = typeof value === 'object' ? JSON.stringify(value) : value.toString();
|
|
120
|
-
|
|
121
135
|
try {
|
|
122
136
|
var decoded = decodeURIComponent(value);
|
|
123
|
-
|
|
124
137
|
if (value === decoded) {
|
|
125
138
|
encoded = encodeURIComponent(value);
|
|
126
139
|
}
|
|
@@ -131,27 +144,23 @@ export function encodeParam(value) {
|
|
|
131
144
|
throw e;
|
|
132
145
|
}
|
|
133
146
|
}
|
|
134
|
-
|
|
135
147
|
return encoded;
|
|
136
148
|
}
|
|
137
|
-
|
|
149
|
+
function encodeParams(values) {
|
|
138
150
|
if (!values) return '';
|
|
139
151
|
var keys = Object.keys(values);
|
|
140
152
|
return keys.filter(k => values[k] !== undefined).map(k => k + '=' + encodeParam(values[k])).join('&');
|
|
141
153
|
}
|
|
142
|
-
|
|
154
|
+
function addQueryParams(path, obj) {
|
|
143
155
|
if (!obj) {
|
|
144
156
|
return path;
|
|
145
157
|
}
|
|
146
|
-
|
|
147
158
|
var qp = encodeParams(obj);
|
|
148
159
|
return "".concat(path).concat(qp ? '?' + qp : '');
|
|
149
160
|
}
|
|
150
161
|
var utf8 = 'utf-8';
|
|
151
|
-
|
|
152
162
|
function bufferString(val) {
|
|
153
163
|
var result = 'Unknown error';
|
|
154
|
-
|
|
155
164
|
try {
|
|
156
165
|
var decoder = new TextDecoder(utf8);
|
|
157
166
|
result = decoder.decode(val);
|
|
@@ -166,58 +175,45 @@ function bufferString(val) {
|
|
|
166
175
|
result = JSON.stringify(val);
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
|
-
|
|
170
178
|
return result;
|
|
171
179
|
}
|
|
172
|
-
|
|
173
|
-
export function sdkError(response) {
|
|
180
|
+
function sdkError(response) {
|
|
174
181
|
if (typeof response === 'string') {
|
|
175
|
-
return new LookerSDKError(response);
|
|
182
|
+
return new _lookerSDKError.LookerSDKError(response);
|
|
176
183
|
}
|
|
177
|
-
|
|
178
184
|
if ('error' in response) {
|
|
179
185
|
var _error = response.error;
|
|
180
|
-
|
|
181
186
|
if (typeof _error === 'string') {
|
|
182
|
-
return new LookerSDKError(_error);
|
|
187
|
+
return new _lookerSDKError.LookerSDKError(_error);
|
|
183
188
|
}
|
|
184
|
-
|
|
185
189
|
if ('error' in _error) {
|
|
186
190
|
var _result = bufferString(_error.error);
|
|
187
|
-
|
|
188
|
-
return new LookerSDKError(_result);
|
|
191
|
+
return new _lookerSDKError.LookerSDKError(_result);
|
|
189
192
|
}
|
|
190
|
-
|
|
191
193
|
if ('message' in _error) {
|
|
192
|
-
return new LookerSDKError(response.error.message.toString(), {
|
|
194
|
+
return new _lookerSDKError.LookerSDKError(response.error.message.toString(), {
|
|
193
195
|
errors: _error.errors,
|
|
194
196
|
documentation_url: _error.documentation_url
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
|
-
|
|
198
199
|
if ('statusMessage' in _error) {
|
|
199
|
-
return new LookerSDKError(_error.statusMessage);
|
|
200
|
+
return new _lookerSDKError.LookerSDKError(_error.statusMessage);
|
|
200
201
|
}
|
|
201
|
-
|
|
202
202
|
var result = bufferString(_error);
|
|
203
|
-
return new LookerSDKError(result);
|
|
203
|
+
return new _lookerSDKError.LookerSDKError(result);
|
|
204
204
|
}
|
|
205
|
-
|
|
206
205
|
if ('message' in response) {
|
|
207
|
-
return new LookerSDKError(response.message);
|
|
206
|
+
return new _lookerSDKError.LookerSDKError(response.message);
|
|
208
207
|
}
|
|
209
|
-
|
|
210
208
|
var error = JSON.stringify(response);
|
|
211
|
-
return new LookerSDKError("Unknown error with SDK method ".concat(error));
|
|
209
|
+
return new _lookerSDKError.LookerSDKError("Unknown error with SDK method ".concat(error));
|
|
212
210
|
}
|
|
213
|
-
|
|
211
|
+
function sdkOk(_x) {
|
|
214
212
|
return _sdkOk.apply(this, arguments);
|
|
215
213
|
}
|
|
216
|
-
|
|
217
214
|
function _sdkOk() {
|
|
218
215
|
_sdkOk = _asyncToGenerator(function* (promise) {
|
|
219
216
|
var result = yield promise;
|
|
220
|
-
|
|
221
217
|
if (result.ok) {
|
|
222
218
|
return result.value;
|
|
223
219
|
} else {
|
|
@@ -226,12 +222,11 @@ function _sdkOk() {
|
|
|
226
222
|
});
|
|
227
223
|
return _sdkOk.apply(this, arguments);
|
|
228
224
|
}
|
|
229
|
-
|
|
230
|
-
export function safeBase64(u8) {
|
|
225
|
+
function safeBase64(u8) {
|
|
231
226
|
var rawBase64 = btoa(String.fromCharCode(...u8));
|
|
232
227
|
return rawBase64.replace(/\+/g, '-').replace(/\//g, '_');
|
|
233
228
|
}
|
|
234
|
-
|
|
229
|
+
function isErrorLike(error) {
|
|
235
230
|
if (typeof error !== 'object') return false;
|
|
236
231
|
if (!error) return false;
|
|
237
232
|
if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false;
|
package/lib/esm/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transport.ts"],"names":["matchCharsetUtf8","matchModeBinary","matchModeString","DelimArray","LookerSDKError","agentPrefix","LookerAppId","tracing","trace","message","info","console","debug","ResponseMode","contentPatternString","RegExp","contentPatternBinary","charsetUtf8Pattern","defaultTimeout","StatusCode","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","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","err","sdkError","response","error","errors","documentation_url","statusMessage","sdkOk","promise","ok","safeBase64","u8","rawBase64","btoa","String","fromCharCode","replace","isErrorLike","prototype","hasOwnProperty","call"],"mappings":";;;;AA6BA,SAASA,gBAAT,EAA2BC,eAA3B,EAA4CC,eAA5C,QAAmE,aAAnE;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA,OAAO,IAAMC,WAAW,GAAG,QAApB;AACP,OAAO,IAAMC,WAAW,GAAG,gBAApB;AAGP,IAAMC,OAAO,GAAG,KAAhB;AAOA,OAAO,SAASC,KAAT,CAAeC,OAAf,EAAgCC,IAAhC,EAA4C;AACjD,MAAIH,OAAJ,EAAa;AAEXI,IAAAA,OAAO,CAACC,KAAR,CAAcH,OAAd;;AACA,QAAIC,IAAJ,EAAU;AAERC,MAAAA,OAAO,CAACC,KAAR,CAAc;AAAEF,QAAAA;AAAF,OAAd;AACD;AACF;AACF;AAGD,WAAYG,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;GAAAA,Y,KAAAA,Y;;AAUZ,OAAO,IAAMC,oBAAoB,GAAG,IAAIC,MAAJ,CAAWb,eAAX,EAA4B,GAA5B,CAA7B;AAMP,OAAO,IAAMc,oBAAoB,GAAG,IAAID,MAAJ,CAAWd,eAAX,EAA4B,GAA5B,CAA7B;AAMP,OAAO,IAAMgB,kBAAkB,GAAG,IAAIF,MAAJ,CAAWf,gBAAX,EAA6B,GAA7B,CAA3B;AAMP,OAAO,IAAMkB,cAAc,GAAG,GAAvB;AAiBP,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EA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O,IAAI5D,cAAJ,CAAmB4D,QAAQ,CAACvD,OAA5B,CAAP;AACD;;AACD,MAAMwD,KAAK,GAAGhC,IAAI,CAACC,SAAL,CAAe8B,QAAf,CAAd;AACA,SAAO,IAAI5D,cAAJ,yCAAoD6D,KAApD,EAAP;AACD;AAyBD,gBAAsBI,KAAtB;AAAA;AAAA;;;6BAAO,WACLC,OADK,EAEL;AACA,QAAMd,MAAM,SAASc,OAArB;;AACA,QAAId,MAAM,CAACe,EAAX,EAAe;AACb,aAAOf,MAAM,CAAC5B,KAAd;AACD,KAFD,MAEO;AACL,YAAMmC,QAAQ,CAACP,MAAD,CAAd;AACD;AACF,G;;;;AAMD,OAAO,SAASgB,UAAT,CAAoBC,EAApB,EAAoC;AACzC,MAAMC,SAAS,GAAGC,IAAI,CAACC,MAAM,CAACC,YAAP,CAAoB,GAAGJ,EAAvB,CAAD,CAAtB;AACA,SAAOC,SAAS,CAACI,OAAV,CAAkB,KAAlB,EAAyB,GAAzB,EAA8BA,OAA9B,CAAsC,KAAtC,EAA6C,GAA7C,CAAP;AACD;AAOD,OAAO,SAASC,WAAT,CACLd,KADK,EAE6B;AAClC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B,OAAO,KAAP;AAC/B,MAAI,CAACA,KAAL,EAAY,OAAO,KAAP;AACZ,MAAI,CAACtB,MAAM,CAACqC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCjB,KAArC,EAA4C,SAA5C,CAAL,EAA6D,OAAO,KAAP;AAC7D,MAAI,OAAQA,KAAD,CAAgCxD,OAAvC,KAAmD,QAAvD,EAAiE,OAAO,KAAP;AACjE,SAAO,IAAP;AACD","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}\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 { message: unknown }).message !== 'string') return false\n return true\n}\n"],"file":"transport.js"}
|
|
1
|
+
{"version":3,"file":"transport.js","names":["agentPrefix","LookerAppId","tracing","trace","message","info","console","debug","ResponseMode","contentPatternString","RegExp","matchModeString","contentPatternBinary","matchModeBinary","charsetUtf8Pattern","matchCharsetUtf8","defaultTimeout","StatusCode","responseMode","contentType","match","string","binary","unknown","isUtf8","encodeParam","value","Date","toISOString","DelimArray","toString","encoded","JSON","stringify","decoded","decodeURIComponent","encodeURIComponent","e","URIError","encodeParams","values","keys","Object","filter","k","undefined","map","join","addQueryParams","path","obj","qp","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","err","sdkError","response","LookerSDKError","error","errors","documentation_url","statusMessage","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;AACA;AACA;AAAiD;AAAA;AAE1C,IAAMA,WAAW,GAAG,QAAQ;AAAA;AAC5B,IAAMC,WAAW,GAAG,gBAAgB;AAAA;AAG3C,IAAMC,OAAO,GAAG,KAAK;AAOd,SAASC,KAAK,CAACC,OAAe,EAAEC,IAAU,EAAE;EACjD,IAAIH,OAAO,EAAE;IAEXI,OAAO,CAACC,KAAK,CAACH,OAAO,CAAC;IACtB,IAAIC,IAAI,EAAE;MAERC,OAAO,CAACC,KAAK,CAAC;QAAEF;MAAK,CAAC,CAAC;IACzB;EACF;AACF;AAAC,IAGWG,YAAY;AAAA;AAAA,WAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAA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AAK;EACzE,IAAI,OAAQA,KAAK,CAAqC7D,OAAO,KAAK,QAAQ,EACxE,OAAO,KAAK;EACd,OAAO,IAAI;AACb"}
|
package/lib/extensionSession.js
CHANGED
|
@@ -4,60 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExtensionSession = void 0;
|
|
7
|
-
|
|
8
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); } }
|
|
9
|
-
|
|
10
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); }); }; }
|
|
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
|
class ExtensionSession {
|
|
15
13
|
constructor(settings, transport) {
|
|
16
14
|
this.settings = settings;
|
|
17
|
-
|
|
18
15
|
_defineProperty(this, "sudoId", '');
|
|
19
|
-
|
|
20
16
|
_defineProperty(this, "transport", void 0);
|
|
21
|
-
|
|
22
17
|
this.settings = settings;
|
|
23
18
|
this.transport = transport;
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
isAuthenticated() {
|
|
27
21
|
return true;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
authenticate(init) {
|
|
31
24
|
return _asyncToGenerator(function* () {
|
|
32
25
|
return Promise.reject(Error("Authenticate ".concat(init ? 'request property overrides' : '', " not supported from ExtensionSession")));
|
|
33
26
|
})();
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
getToken() {
|
|
37
29
|
return _asyncToGenerator(function* () {
|
|
38
30
|
return Promise.reject(Error('Access to token is not allowed from ExtensionSession'));
|
|
39
31
|
})();
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
isSudo() {
|
|
43
34
|
throw new Error('isSudo is not allowed from ExtensionSession');
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
login(sudoId) {
|
|
47
37
|
return _asyncToGenerator(function* () {
|
|
48
38
|
return Promise.reject(Error("Login ".concat(sudoId ? 'for sudo' : '', " not supported from ExtensionSession")));
|
|
49
39
|
})();
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
logout() {
|
|
53
42
|
return _asyncToGenerator(function* () {
|
|
54
43
|
return Promise.reject(Error('Logout not supported from ExtensionSession'));
|
|
55
44
|
})();
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
reset() {}
|
|
59
|
-
|
|
60
47
|
}
|
|
61
|
-
|
|
62
48
|
exports.ExtensionSession = ExtensionSession;
|
|
63
49
|
//# sourceMappingURL=extensionSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"extensionSession.js","names":["ExtensionSession","constructor","settings","transport","isAuthenticated","authenticate","init","Promise","reject","Error","getToken","isSudo","login","sudoId","logout","reset"],"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 { ITransport, IRequestProps } 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,WAAW,CAAQC,QAAsB,EAAEC,SAAqB,EAAE;IAAA,KAA/CD,QAAsB,GAAtBA,QAAsB;IAAA,gCAHhC,EAAE;IAAA;IAIT,IAAI,CAACA,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;EAC5B;EAEAC,eAAe,GAAG;IAEhB,OAAO,IAAI;EACb;EAEMC,YAAY,CAACC,IAAmB,EAAE;IAAA;MACtC,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,wBAEDH,IAAI,GAAG,4BAA4B,GAAG,EAAE,0CAE3C,CACF;IAAA;EACH;EAEMI,QAAQ,GAAiB;IAAA;MAC7B,OAAOH,OAAO,CAACC,MAAM,CACnBC,KAAK,CAAC,sDAAsD,CAAC,CAC9D;IAAA;EACH;EAEAE,MAAM,GAAY;IAChB,MAAM,IAAIF,KAAK,CAAC,6CAA6C,CAAC;EAChE;EAEMG,KAAK,CAACC,MAAwB,EAAgB;IAAA;MAClD,OAAON,OAAO,CAACC,MAAM,CACnBC,KAAK,iBACMI,MAAM,GAAG,UAAU,GAAG,EAAE,0CAClC,CACF;IAAA;EACH;EAEMC,MAAM,GAAqB;IAAA;MAC/B,OAAOP,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAAA;EAC5E;EAEAM,KAAK,GAAS,CAEd;AACF;AAAC"}
|
|
@@ -4,54 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ExtensionTransport = void 0;
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
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; }
|
|
11
|
-
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
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 ExtensionTransport {
|
|
19
15
|
constructor(options, hostConnection) {
|
|
20
16
|
this.options = options;
|
|
21
17
|
this.hostConnection = hostConnection;
|
|
22
|
-
|
|
23
18
|
_defineProperty(this, "observer", void 0);
|
|
24
|
-
|
|
25
19
|
this.options = options;
|
|
26
20
|
this.hostConnection = hostConnection;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
rawRequest(method, path, queryParams, body, authenticator, options) {
|
|
30
23
|
var _this = this;
|
|
31
|
-
|
|
32
24
|
return _asyncToGenerator(function* () {
|
|
33
25
|
var response = yield _this.hostConnection.rawRequest(method, path, body, queryParams, authenticator, options);
|
|
34
26
|
return _this.observer ? _this.observer(response) : response;
|
|
35
27
|
})();
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
request(method, path, queryParams, body, authenticator, options) {
|
|
39
30
|
var _this2 = this;
|
|
40
|
-
|
|
41
31
|
return _asyncToGenerator(function* () {
|
|
42
32
|
return _this2.hostConnection.request(method, path, body, queryParams, authenticator, options);
|
|
43
33
|
})();
|
|
44
34
|
}
|
|
45
|
-
|
|
46
35
|
stream(callback, method, path, queryParams, body, authenticator, options) {
|
|
47
36
|
var _this3 = this;
|
|
48
|
-
|
|
49
37
|
return _asyncToGenerator(function* () {
|
|
50
38
|
options = options ? _objectSpread(_objectSpread({}, _this3.options), options) : _this3.options;
|
|
51
39
|
return _this3.hostConnection.stream(callback, method, path, body, queryParams, authenticator, options);
|
|
52
40
|
})();
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
parseResponse(_raw) {
|
|
56
43
|
var result = {
|
|
57
44
|
ok: false,
|
|
@@ -59,8 +46,6 @@ class ExtensionTransport {
|
|
|
59
46
|
};
|
|
60
47
|
return Promise.resolve(result);
|
|
61
48
|
}
|
|
62
|
-
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
exports.ExtensionTransport = ExtensionTransport;
|
|
66
51
|
//# sourceMappingURL=extensionTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"extensionTransport.js","names":["ExtensionTransport","constructor","options","hostConnection","rawRequest","method","path","queryParams","body","authenticator","response","observer","request","stream","callback","parseResponse","_raw","result","ok","error","Error","Promise","resolve"],"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 { Readable } from 'readable-stream'\nimport type {\n Authenticator,\n Values,\n SDKResponse,\n ITransport,\n ITransportSettings,\n HttpMethod,\n IRawResponse,\n RawObserver,\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: 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\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"],"mappings":";;;;;;;;;;;;;AAoEO,MAAMA,kBAAkB,CAAuB;EACpDC,WAAW,CACQC,OAA2B,EACpCC,cAA+B,EACvC;IAAA,KAFiBD,OAA2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