@looker/sdk-node 24.14.0 → 24.16.2
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 +44 -0
- package/README.md +17 -21
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/nodeSession.apitest.js +78 -0
- package/lib/esm/nodeSession.apitest.js.map +1 -0
- package/lib/esm/nodeSession.js +6 -1
- package/lib/esm/nodeSession.js.map +1 -1
- package/lib/esm/nodeSettings.js.map +1 -1
- package/lib/esm/nodeTransport.apitest.js +127 -0
- package/lib/esm/nodeTransport.apitest.js.map +1 -0
- package/lib/esm/nodeTransport.js +129 -161
- package/lib/esm/nodeTransport.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/nodeSession.apitest.d.ts +1 -0
- package/lib/nodeSession.apitest.js +82 -0
- package/lib/nodeSession.apitest.js.map +1 -0
- package/lib/nodeSession.js +6 -1
- package/lib/nodeSession.js.map +1 -1
- package/lib/nodeSettings.js.map +1 -1
- package/lib/nodeTransport.apitest.d.ts +1 -0
- package/lib/nodeTransport.apitest.js +129 -0
- package/lib/nodeTransport.apitest.js.map +1 -0
- package/lib/nodeTransport.d.ts +7 -11
- package/lib/nodeTransport.js +135 -164
- package/lib/nodeTransport.js.map +1 -1
- package/package.json +11 -13
- package/lib/esm/testUtils/index.js +0 -2
- package/lib/esm/testUtils/index.js.map +0 -1
- package/lib/esm/testUtils/testUtils.js +0 -43
- package/lib/esm/testUtils/testUtils.js.map +0 -1
- package/lib/testUtils/index.js +0 -17
- package/lib/testUtils/index.js.map +0 -1
- package/lib/testUtils/testUtils.js +0 -53
- package/lib/testUtils/testUtils.js.map +0 -1
package/lib/nodeTransport.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.NodeTransport = exports.NodeCryptoHash = void 0;
|
|
6
|
+
exports.createWritableStream = exports.NodeTransport = exports.NodeCryptoHash = void 0;
|
|
7
7
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var _readableStream = require("readable-stream");
|
|
11
|
-
var _errors = require("request-promise-native/errors");
|
|
8
|
+
var _buffer = require("buffer");
|
|
9
|
+
var process = _interopRequireWildcard(require("process"));
|
|
12
10
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
11
|
+
var _web = require("node:stream/web");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
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; }
|
|
15
16
|
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; }
|
|
@@ -20,8 +21,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
20
21
|
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); }); }; }
|
|
21
22
|
var utf8 = 'utf8';
|
|
22
23
|
var asString = value => {
|
|
23
|
-
if (value instanceof Buffer) {
|
|
24
|
-
return Buffer.from(value).toString(utf8);
|
|
24
|
+
if (value instanceof _buffer.Buffer) {
|
|
25
|
+
return _buffer.Buffer.from(value).toString(utf8);
|
|
25
26
|
}
|
|
26
27
|
if (value instanceof Object) {
|
|
27
28
|
return JSON.stringify(value);
|
|
@@ -46,68 +47,102 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
46
47
|
super(options);
|
|
47
48
|
this.options = options;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
retry(request) {
|
|
50
51
|
var _this = this;
|
|
51
52
|
return _asyncToGenerator(function* () {
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
var _request$options, _newOpts$maxTries;
|
|
54
|
+
var {
|
|
55
|
+
method,
|
|
56
|
+
path,
|
|
57
|
+
queryParams,
|
|
58
|
+
body,
|
|
59
|
+
authenticator
|
|
60
|
+
} = request;
|
|
61
|
+
var newOpts = (0, _sdkRtl.mergeOptions)(_this.options, (_request$options = request.options) !== null && _request$options !== void 0 ? _request$options : {});
|
|
62
|
+
var requestPath = _this.makeUrl(path, newOpts, queryParams);
|
|
63
|
+
var waiter = newOpts.waitHandler || _sdkRtl.retryWait;
|
|
64
|
+
var props = yield _this.initRequest(method, requestPath, body, authenticator, newOpts);
|
|
65
|
+
var response = (0, _sdkRtl.initResponse)(method, requestPath);
|
|
66
|
+
var maxTries = (_newOpts$maxTries = newOpts.maxTries) !== null && _newOpts$maxTries !== void 0 ? _newOpts$maxTries : 1;
|
|
67
|
+
var attempt = 1;
|
|
68
|
+
var _loop = function* _loop() {
|
|
69
|
+
var req = fetch(props.url, props);
|
|
70
|
+
var requestStarted = Date.now();
|
|
71
|
+
try {
|
|
72
|
+
var res = yield req;
|
|
73
|
+
var responseCompleted = Date.now();
|
|
74
|
+
var started = _sdkRtl.BrowserTransport.markStart(_sdkRtl.BrowserTransport.markName(requestPath));
|
|
75
|
+
var contentType = String(res.headers.get('content-type'));
|
|
76
|
+
var mode = (0, _sdkRtl.responseMode)(contentType);
|
|
77
|
+
var responseBody = mode === _sdkRtl.ResponseMode.binary ? res.blob() : res.text();
|
|
78
|
+
if (!('fromRequest' in newOpts)) {
|
|
79
|
+
_sdkRtl.BrowserTransport.markEnd(requestPath, started);
|
|
80
|
+
}
|
|
81
|
+
var headers = {};
|
|
82
|
+
res.headers.forEach((value, key) => headers[key] = value);
|
|
83
|
+
response = {
|
|
84
|
+
method,
|
|
85
|
+
url: requestPath,
|
|
86
|
+
body: responseBody,
|
|
87
|
+
contentType,
|
|
88
|
+
statusCode: res.status,
|
|
89
|
+
statusMessage: res.statusText,
|
|
90
|
+
startMark: started,
|
|
91
|
+
headers,
|
|
92
|
+
requestStarted,
|
|
93
|
+
responseCompleted,
|
|
94
|
+
ok: true
|
|
95
|
+
};
|
|
96
|
+
response.ok = _this.ok(response);
|
|
97
|
+
if ((0, _sdkRtl.canRetry)(response.statusCode) && attempt < maxTries) {
|
|
98
|
+
var result = yield (0, _sdkRtl.pauseForRetry)(request, response, attempt, waiter);
|
|
99
|
+
if (result.response === 'cancel') {
|
|
100
|
+
if (result.reason) {
|
|
101
|
+
response.statusMessage = result.reason;
|
|
102
|
+
}
|
|
103
|
+
return "break";
|
|
104
|
+
} else if (result.response === 'error') {
|
|
105
|
+
if (result.reason) {
|
|
106
|
+
response.statusMessage = result.reason;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
v: (0, _sdkRtl.retryError)(response)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
return "break";
|
|
90
114
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
115
|
+
attempt++;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
response.ok = false;
|
|
118
|
+
response.body = e;
|
|
119
|
+
response.statusCode = e.statusCode;
|
|
120
|
+
response.statusMessage = e.message;
|
|
121
|
+
return {
|
|
122
|
+
v: response
|
|
123
|
+
};
|
|
96
124
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
ok: false,
|
|
103
|
-
statusCode,
|
|
104
|
-
statusMessage,
|
|
105
|
-
headers: {},
|
|
106
|
-
requestStarted,
|
|
107
|
-
responseCompleted
|
|
108
|
-
};
|
|
125
|
+
};
|
|
126
|
+
while (attempt <= maxTries) {
|
|
127
|
+
var _ret = yield* _loop();
|
|
128
|
+
if (_ret === "break") break;
|
|
129
|
+
if (typeof _ret === "object") return _ret.v;
|
|
109
130
|
}
|
|
110
|
-
return
|
|
131
|
+
return response;
|
|
132
|
+
})();
|
|
133
|
+
}
|
|
134
|
+
rawRequest(method, path, queryParams, body, authenticator, options) {
|
|
135
|
+
var _this2 = this;
|
|
136
|
+
return _asyncToGenerator(function* () {
|
|
137
|
+
var response = yield _this2.retry({
|
|
138
|
+
method,
|
|
139
|
+
path,
|
|
140
|
+
queryParams,
|
|
141
|
+
body,
|
|
142
|
+
authenticator,
|
|
143
|
+
options
|
|
144
|
+
});
|
|
145
|
+
return _this2.observer ? _this2.observer(response) : response;
|
|
111
146
|
})();
|
|
112
147
|
}
|
|
113
148
|
parseResponse(res) {
|
|
@@ -116,7 +151,7 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
116
151
|
var response;
|
|
117
152
|
var error;
|
|
118
153
|
if (!res.ok) {
|
|
119
|
-
error = res.body;
|
|
154
|
+
error = yield res.body;
|
|
120
155
|
if (typeof error === 'string') {
|
|
121
156
|
try {
|
|
122
157
|
error = JSON.parse(error);
|
|
@@ -136,8 +171,8 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
136
171
|
if (mode === _sdkRtl.ResponseMode.string) {
|
|
137
172
|
if (res.contentType.match(/^application\/.*\bjson\b/g)) {
|
|
138
173
|
try {
|
|
139
|
-
if (result instanceof Buffer) {
|
|
140
|
-
result = Buffer.from(result).toString(
|
|
174
|
+
if (result instanceof _buffer.Buffer) {
|
|
175
|
+
result = _buffer.Buffer.from(result).toString();
|
|
141
176
|
}
|
|
142
177
|
if (!(result instanceof Object)) {
|
|
143
178
|
result = JSON.parse(result.toString());
|
|
@@ -150,8 +185,13 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
150
185
|
}
|
|
151
186
|
} else {
|
|
152
187
|
try {
|
|
153
|
-
var
|
|
154
|
-
|
|
188
|
+
var body = yield result;
|
|
189
|
+
if (typeof body === 'string') {
|
|
190
|
+
result = body;
|
|
191
|
+
} else {
|
|
192
|
+
var bytes = yield body.arrayBuffer();
|
|
193
|
+
result = _buffer.Buffer.from(bytes !== null && bytes !== void 0 ? bytes : '').toString('binary');
|
|
194
|
+
}
|
|
155
195
|
} catch (err) {
|
|
156
196
|
error = err;
|
|
157
197
|
}
|
|
@@ -171,11 +211,11 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
171
211
|
})();
|
|
172
212
|
}
|
|
173
213
|
request(method, path, queryParams, body, authenticator, options) {
|
|
174
|
-
var
|
|
214
|
+
var _this3 = this;
|
|
175
215
|
return _asyncToGenerator(function* () {
|
|
176
216
|
try {
|
|
177
|
-
var res = yield
|
|
178
|
-
return yield
|
|
217
|
+
var res = yield _this3.rawRequest(method, path, queryParams, body, authenticator, options);
|
|
218
|
+
return yield _this3.parseResponse(res);
|
|
179
219
|
} catch (e) {
|
|
180
220
|
var error = {
|
|
181
221
|
message: typeof e.message === 'string' ? e.message : "The SDK call was not successful. The error was '".concat(e, "'."),
|
|
@@ -188,107 +228,38 @@ class NodeTransport extends _sdkRtl.BaseTransport {
|
|
|
188
228
|
}
|
|
189
229
|
})();
|
|
190
230
|
}
|
|
191
|
-
requestor(props) {
|
|
192
|
-
var _props$method;
|
|
193
|
-
var method = (_props$method = props.method) === null || _props$method === void 0 ? void 0 : _props$method.toString().toUpperCase();
|
|
194
|
-
switch (method) {
|
|
195
|
-
case 'GET':
|
|
196
|
-
return _request.default.get(props);
|
|
197
|
-
case 'PUT':
|
|
198
|
-
return _request.default.put(props);
|
|
199
|
-
case 'POST':
|
|
200
|
-
return _request.default.post(props);
|
|
201
|
-
case 'PATCH':
|
|
202
|
-
return _request.default.patch(props);
|
|
203
|
-
case 'DELETE':
|
|
204
|
-
return _request.default.put(props);
|
|
205
|
-
case 'HEAD':
|
|
206
|
-
return _request.default.head(props);
|
|
207
|
-
default:
|
|
208
|
-
return _request.default.get(props);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
231
|
stream(callback, method, path, queryParams, body, authenticator, options) {
|
|
212
|
-
var
|
|
232
|
+
var _this4 = this;
|
|
213
233
|
return _asyncToGenerator(function* () {
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
var init = yield _this3.initRequest(method, path, queryParams, body, authenticator, options);
|
|
217
|
-
var streamPromise = new Promise((resolve, reject) => {
|
|
218
|
-
(0, _sdkRtl.trace)("[stream] beginning stream via download url", init);
|
|
219
|
-
var hasResolved = false;
|
|
220
|
-
var req = _this3.requestor(init);
|
|
221
|
-
req.on('error', err => {
|
|
222
|
-
if (hasResolved && err.code === 'ECONNRESET') {
|
|
223
|
-
(0, _sdkRtl.trace)('ignoring ECONNRESET that occurred after streaming finished', init);
|
|
224
|
-
} else {
|
|
225
|
-
(0, _sdkRtl.trace)('streaming error', err);
|
|
226
|
-
reject(err);
|
|
227
|
-
}
|
|
228
|
-
}).on('finish', () => {
|
|
229
|
-
(0, _sdkRtl.trace)("[stream] streaming via download url finished", init);
|
|
230
|
-
}).on('socket', socket => {
|
|
231
|
-
(0, _sdkRtl.trace)("[stream] setting keepalive on socket", init);
|
|
232
|
-
socket.setKeepAlive(true);
|
|
233
|
-
}).on('abort', () => {
|
|
234
|
-
(0, _sdkRtl.trace)("[stream] streaming via download url aborted", init);
|
|
235
|
-
}).on('response', () => {
|
|
236
|
-
(0, _sdkRtl.trace)("[stream] got response from download url", init);
|
|
237
|
-
}).on('close', () => {
|
|
238
|
-
(0, _sdkRtl.trace)("[stream] request stream closed", init);
|
|
239
|
-
}).pipe(stream).on('error', err => {
|
|
240
|
-
(0, _sdkRtl.trace)("[stream] PassThrough stream error", err);
|
|
241
|
-
reject(err);
|
|
242
|
-
}).on('finish', () => {
|
|
243
|
-
(0, _sdkRtl.trace)("[stream] PassThrough stream finished", init);
|
|
244
|
-
resolve();
|
|
245
|
-
hasResolved = true;
|
|
246
|
-
}).on('close', () => {
|
|
247
|
-
(0, _sdkRtl.trace)("[stream] PassThrough stream closed", init);
|
|
248
|
-
});
|
|
234
|
+
var newOpts = _objectSpread(_objectSpread({}, _this4.options), {}, {
|
|
235
|
+
options
|
|
249
236
|
});
|
|
250
|
-
var
|
|
251
|
-
|
|
237
|
+
var requestPath = _this4.makeUrl(path, newOpts, queryParams);
|
|
238
|
+
var init = yield _this4.initRequest(method, requestPath, body, authenticator, newOpts);
|
|
239
|
+
var response = yield fetch(requestPath, init);
|
|
240
|
+
return yield callback(response);
|
|
252
241
|
})();
|
|
253
242
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
timeout(options) {
|
|
259
|
-
if (!options) options = this.options;
|
|
260
|
-
if ('timeout' in options && options.timeout) return options.timeout;
|
|
261
|
-
return _sdkRtl.defaultTimeout;
|
|
262
|
-
}
|
|
263
|
-
initRequest(method, path, queryParams, body, authenticator, options) {
|
|
264
|
-
var _this4 = this;
|
|
243
|
+
initRequest(method, path, body, authenticator, options) {
|
|
244
|
+
var _superprop_getInitRequest = () => super.initRequest,
|
|
245
|
+
_this5 = this;
|
|
265
246
|
return _asyncToGenerator(function* () {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
247
|
+
var props = yield _superprop_getInitRequest().call(_this5, method, path, body, authenticator, options);
|
|
248
|
+
props.credentials = undefined;
|
|
249
|
+
if (!(0, _sdkRtl.verifySsl)(options)) {
|
|
250
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
269
251
|
}
|
|
270
|
-
|
|
271
|
-
[_sdkRtl.LookerAppId]: options.agentTag
|
|
272
|
-
}, options.headers);
|
|
273
|
-
var requestPath = _this4.makeUrl(path, options, queryParams);
|
|
274
|
-
var init = {
|
|
275
|
-
body: body || undefined,
|
|
276
|
-
encoding: null,
|
|
277
|
-
headers: headers,
|
|
278
|
-
json: body && typeof body !== 'string',
|
|
279
|
-
method,
|
|
280
|
-
rejectUnauthorized: _this4.verifySsl(options),
|
|
281
|
-
resolveWithFullResponse: true,
|
|
282
|
-
timeout: _this4.timeout(options) * 1000,
|
|
283
|
-
url: requestPath
|
|
284
|
-
};
|
|
285
|
-
if ('encoding' in options) init.encoding = options.encoding;
|
|
286
|
-
if (authenticator) {
|
|
287
|
-
init = yield authenticator(init);
|
|
288
|
-
}
|
|
289
|
-
return init;
|
|
252
|
+
return props;
|
|
290
253
|
})();
|
|
291
254
|
}
|
|
292
255
|
}
|
|
293
256
|
exports.NodeTransport = NodeTransport;
|
|
257
|
+
var createWritableStream = writer => {
|
|
258
|
+
return new _web.WritableStream({
|
|
259
|
+
write: chunk => {
|
|
260
|
+
writer.write(chunk);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
exports.createWritableStream = createWritableStream;
|
|
294
265
|
//# sourceMappingURL=nodeTransport.js.map
|
package/lib/nodeTransport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTransport.js","names":["_crypto","_interopRequireDefault","require","_request","_requestPromiseNative","_readableStream","_errors","_sdkRtl","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","utf8","asString","Buffer","from","toString","JSON","stringify","NodeCryptoHash","secureRandom","byteCount","nodeCrypto","randomBytes","sha256Hash","message","hash","createHash","update","safeBase64","Uint8Array","digest","exports","NodeTransport","BaseTransport","constructor","options","rawRequest","method","path","queryParams","body","authenticator","_this","init","initRequest","req","rp","promise","rawResponse","requestStarted","Date","now","responseCompleted","res","resTyped","url","contentType","headers","ok","statusCode","statusMessage","concat","StatusCodeError","observer","parseResponse","mode","responseMode","response","parse","_unused","result","ResponseMode","string","match","_result","request","_this2","type","requestor","props","_props$method","toUpperCase","rq","get","put","post","patch","head","stream","callback","_this3","PassThrough","returnPromise","streamPromise","trace","hasResolved","on","code","socket","setKeepAlive","pipe","results","all","verifySsl","verify_ssl","timeout","defaultTimeout","_this4","agentTag","agentPrefix","LookerAppId","requestPath","makeUrl","encoding","json","rejectUnauthorized","resolveWithFullResponse"],"sources":["../src/nodeTransport.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 nodeCrypto from 'crypto';\nimport type { Request } from 'request';\nimport rq from 'request';\n\nimport rp from 'request-promise-native';\nimport type { Readable } from 'readable-stream';\nimport { PassThrough } from 'readable-stream';\nimport { StatusCodeError } from 'request-promise-native/errors';\nimport {\n BaseTransport,\n LookerAppId,\n ResponseMode,\n agentPrefix,\n defaultTimeout,\n responseMode,\n safeBase64,\n trace,\n} from '@looker/sdk-rtl';\nimport type {\n Authenticator,\n HttpMethod,\n ICryptoHash,\n IRawResponse,\n IRequestHeaders,\n ISDKError,\n ITransportSettings,\n SDKResponse,\n Values,\n} from '@looker/sdk-rtl';\n\nconst utf8 = 'utf8';\n\nconst asString = (value: any): string => {\n if (value instanceof Buffer) {\n return Buffer.from(value).toString(utf8);\n }\n if (value instanceof Object) {\n return JSON.stringify(value);\n }\n return value.toString();\n};\n\nexport class NodeCryptoHash implements ICryptoHash {\n secureRandom(byteCount: number): string {\n // TODO update this to Node 18\n return nodeCrypto.randomBytes(byteCount).toString('hex');\n }\n\n async sha256Hash(message: string): Promise<string> {\n const hash = nodeCrypto.createHash('sha256');\n hash.update(message);\n return safeBase64(new Uint8Array(hash.digest()));\n }\n}\n\nexport type RequestOptions = rq.RequiredUriUrl &\n rp.RequestPromiseOptions &\n rq.OptionsWithUrl;\n\nexport class NodeTransport extends BaseTransport {\n constructor(protected readonly options: ITransportSettings) {\n super(options);\n }\n\n async rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse> {\n const init: RequestOptions = await this.initRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n const req = rp(init).promise();\n let rawResponse: IRawResponse;\n\n const requestStarted = Date.now();\n let responseCompleted;\n try {\n const res = await req;\n responseCompleted = Date.now();\n const resTyped = res as rq.Response;\n rawResponse = {\n method,\n url: resTyped.url || init.url.toString() || '',\n body: await resTyped.body,\n contentType: String(resTyped.headers['content-type']),\n ok: true,\n statusCode: resTyped.statusCode,\n statusMessage: resTyped.statusMessage,\n headers: res.headers,\n requestStarted,\n responseCompleted,\n };\n // Update OK with response statusCode check\n rawResponse.ok = this.ok(rawResponse);\n } catch (e: any) {\n let statusMessage = `${method} ${path}`;\n let statusCode = 404;\n let contentType = 'text';\n let body;\n responseCompleted = Date.now();\n if (e instanceof StatusCodeError) {\n statusCode = e.statusCode;\n if (e.error instanceof Buffer) {\n body = asString(e.error);\n statusMessage += `: ${statusCode}`;\n } else if (e.error instanceof Object) {\n // Capture error object as body\n body = e.error;\n statusMessage += `: ${e.message}`;\n // Clarify the error message\n body.message = statusMessage;\n contentType = 'application/json';\n }\n } else if (e.error instanceof Buffer) {\n body = asString(e.error);\n } else {\n body = JSON.stringify(e);\n contentType = 'application/json';\n }\n rawResponse = {\n method,\n url: init.url.toString(),\n body,\n contentType,\n ok: false,\n statusCode,\n statusMessage,\n headers: {},\n requestStarted,\n responseCompleted,\n };\n }\n return this.observer ? this.observer(rawResponse) : rawResponse;\n }\n\n async parseResponse<TSuccess, TError>(res: IRawResponse) {\n const mode = responseMode(res.contentType);\n let response: SDKResponse<TSuccess, TError>;\n let error;\n if (!res.ok) {\n // Raw request had an error. Make sure it's a string before parsing the result\n error = res.body;\n if (typeof error === 'string') {\n try {\n error = JSON.parse(error);\n } catch {\n error = { message: `Request failed: ${error}` };\n }\n }\n response = { ok: false, error };\n return response;\n }\n let result = await res.body;\n if (mode === ResponseMode.string) {\n if (res.contentType.match(/^application\\/.*\\bjson\\b/g)) {\n try {\n if (result instanceof Buffer) {\n result = Buffer.from(result).toString(utf8);\n }\n if (!(result instanceof Object)) {\n result = JSON.parse(result.toString());\n }\n } catch (err) {\n error = err;\n }\n } else if (!error) {\n // Convert to string otherwise\n result = asString(result);\n }\n } else {\n try {\n result = Buffer.from(result ?? '').toString('binary');\n } catch (err) {\n error = err;\n }\n }\n if (!error) {\n response = { ok: true, value: result };\n } else {\n response = { ok: false, error: error as TError };\n }\n return response;\n }\n\n async 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 try {\n const res = await this.rawRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n return await this.parseResponse<TSuccess, TError>(res);\n } catch (e: any) {\n const error: ISDKError = {\n message:\n typeof e.message === 'string'\n ? e.message\n : `The SDK call was not successful. The error was '${e}'.`,\n type: 'sdk_error',\n };\n return { error, ok: false };\n }\n }\n\n /**\n * Http method dispatcher from general-purpose request properties\n * @param props\n * @returns {request.Request}\n */\n protected requestor(props: RequestOptions): Request {\n const method = props.method?.toString().toUpperCase() as HttpMethod;\n switch (method) {\n case 'GET':\n return rq.get(props);\n case 'PUT':\n return rq.put(props);\n case 'POST':\n return rq.post(props);\n case 'PATCH':\n return rq.patch(props);\n case 'DELETE':\n return rq.put(props);\n case 'HEAD':\n return rq.head(props);\n default:\n return rq.get(props);\n }\n }\n\n async stream<TSuccess>(\n callback: (readable: Readable) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n const stream = new PassThrough();\n const returnPromise = callback(stream);\n const init = await this.initRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n\n const streamPromise = new Promise<void>((resolve, reject) => {\n trace(`[stream] beginning stream via download url`, init);\n let hasResolved = false;\n const req = this.requestor(init);\n\n req\n .on('error', (err) => {\n if (hasResolved && (err as any).code === 'ECONNRESET') {\n trace(\n 'ignoring ECONNRESET that occurred after streaming finished',\n init\n );\n } else {\n trace('streaming error', err);\n reject(err);\n }\n })\n .on('finish', () => {\n trace(`[stream] streaming via download url finished`, init);\n })\n .on('socket', (socket) => {\n trace(`[stream] setting keepalive on socket`, init);\n socket.setKeepAlive(true);\n })\n .on('abort', () => {\n trace(`[stream] streaming via download url aborted`, init);\n })\n .on('response', () => {\n trace(`[stream] got response from download url`, init);\n })\n .on('close', () => {\n trace(`[stream] request stream closed`, init);\n })\n .pipe(stream)\n .on('error', (err) => {\n trace(`[stream] PassThrough stream error`, err);\n reject(err);\n })\n .on('finish', () => {\n trace(`[stream] PassThrough stream finished`, init);\n resolve();\n hasResolved = true;\n })\n .on('close', () => {\n trace(`[stream] PassThrough stream closed`, init);\n });\n });\n\n const results = await Promise.all([returnPromise, streamPromise]);\n return results[0];\n }\n\n /**\n * should the request verify SSL?\n * @param {Partial<ITransportSettings>} options Defaults to the instance options values\n * @returns {boolean} true if the request should require full SSL verification\n */\n verifySsl(options?: Partial<ITransportSettings>) {\n if (!options) options = this.options;\n return 'verify_ssl' in options ? options.verify_ssl : true;\n }\n\n /**\n * Request timeout in seconds\n * @param {Partial<ITransportSettings>} options Defaults to the instance options values\n * @returns {number | undefined}\n */\n timeout(options?: Partial<ITransportSettings>): number {\n if (!options) options = this.options;\n if ('timeout' in options && options.timeout) return options.timeout;\n return defaultTimeout;\n }\n\n private async initRequest(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ) {\n options = options ? { ...this.options, ...options } : this.options;\n if (!options.agentTag) {\n options.agentTag = agentPrefix;\n }\n const headers: IRequestHeaders = {\n [LookerAppId]: options.agentTag,\n ...options.headers,\n };\n\n const requestPath = this.makeUrl(path, options, queryParams);\n let init: RequestOptions = {\n body: body || undefined,\n encoding: null,\n headers: headers,\n json: body && typeof body !== 'string',\n // null = requests are returned as binary so `Content-Type` dictates response format\n method,\n\n rejectUnauthorized: this.verifySsl(options),\n\n // If body is a string, pass as is\n resolveWithFullResponse: true,\n\n timeout: this.timeout(options) * 1000,\n url: requestPath,\n };\n if ('encoding' in options) init.encoding = options.encoding;\n\n if (authenticator) {\n // Automatic authentication process for the request\n init = await authenticator(init);\n }\n return init;\n }\n\n // /**\n // * A streaming helper for the \"json\" data format. It handles automatically parsing\n // * the JSON in a streaming fashion. You just need to implement a function that will\n // * be called for each row.\n // *\n // * ```ts\n // * await request.streamJson((row) => {\n // * // This will be called for each row of data\n // * })\n // * ```\n // *\n // * @returns A promise that will be resolved when streaming is complete.\n // * @param onRow A function that will be called for each streamed row, with the row as the first argument.\n // */\n // async streamJson(onRow: (row: { [fieldName: string]: any }) => void) {\n // return new Promise<void>((resolve, reject) => {\n // let rows = 0\n // this.stream(async (readable) => {\n // oboe(readable)\n // .node(\"![*]\", this.safeOboe(readable, reject, (row) => {\n // rows++\n // onRow(row)\n // }))\n // .done(() => {\n // winston.info(`[streamJson] oboe reports done`, {...this.logInfo, rows})\n // })\n // }).then(() => {\n // winston.info(`[streamJson] complete`, {...this.logInfo, rows})\n // resolve()\n // }).catch((error) => {\n // // This error should not be logged as it could come from an action\n // // which might decide to include user information in the error message\n // winston.info(`[streamJson] reported an error`, {...this.logInfo, rows})\n // reject(error)\n // })\n // })\n // }\n //\n // /**\n // * A streaming helper for the \"json_detail\" data format. It handles automatically parsing\n // * the JSON in a streaming fashion. You can implement an `onFields` callback to get\n // * the field metadata, and an `onRow` callback for each row of data.\n // *\n // * ```ts\n // * await request.streamJsonDetail({\n // * onFields: (fields) => {\n // * // This will be called when fields are available\n // * },\n // * onRow: (row) => {\n // * // This will be called for each row of data\n // * },\n // * })\n // * ```\n // *\n // * @returns A promise that will be resolved when streaming is complete.\n // * @param callbacks An object consisting of several callbacks that will be called\n // * when various parts of the data are parsed.\n // */\n // async streamJsonDetail(callbacks: {\n // onRow: (row: JsonDetailRow) => void,\n // onFields?: (fields: Fieldset) => void,\n // onRanAt?: (iso8601string: string) => void,\n // }) {\n // return new Promise<void>((resolve, reject) => {\n // let rows = 0\n // this.stream(async (readable) => {\n // oboe(readable)\n // .node(\"data.*\", this.safeOboe(readable, reject, (row) => {\n // rows++\n // callbacks.onRow(row)\n // }))\n // .node(\"!.fields\", this.safeOboe(readable, reject, (fields) => {\n // if (callbacks.onFields) {\n // callbacks.onFields(fields)\n // }\n // }))\n // .node(\"!.ran_at\", this.safeOboe(readable, reject, (ranAt) => {\n // if (callbacks.onRanAt) {\n // callbacks.onRanAt(ranAt)\n // }\n // }))\n // .done(() => {\n // winston.info(`[streamJsonDetail] oboe reports done`, {...this.logInfo, rows})\n // })\n // }).then(() => {\n // winston.info(`[streamJsonDetail] complete`, {...this.logInfo, rows})\n // resolve()\n // }).catch((error) => {\n // // This error should not be logged as it could come from an action\n // // which might decide to include user information in the error message\n // winston.info(`[streamJsonDetail] reported an error`, {...this.logInfo, rows})\n // reject(error)\n // })\n // })\n // }\n}\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;A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,EAAEI,WAAW,CAAC;MAC5D,IAAII,IAAoB,GAAG;QACzBH,IAAI,EAAEA,IAAI,IAAI9B,SAAS;QACvBuG,QAAQ,EAAE,IAAI;QACdxD,OAAO,EAAEA,OAAO;QAChByD,IAAI,EAAE1E,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ;QAEtCH,MAAM;QAEN8E,kBAAkB,EAAER,MAAI,CAACJ,SAAS,CAACpE,OAAO,CAAC;QAG3CiF,uBAAuB,EAAE,IAAI;QAE7BX,OAAO,EAAEE,MAAI,CAACF,OAAO,CAACtE,OAAO,CAAC,GAAG,IAAI;QACrCoB,GAAG,EAAEwD;MACP,CAAC;MACD,IAAI,UAAU,IAAI5E,OAAO,EAAEQ,IAAI,CAACsE,QAAQ,GAAG9E,OAAO,CAAC8E,QAAQ;MAE3D,IAAIxE,aAAa,EAAE;QAEjBE,IAAI,SAASF,aAAa,CAACE,IAAI,CAAC;MAClC;MACA,OAAOA,IAAI;IAAC;EACd;AAiGF;AAACZ,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"nodeTransport.js","names":["_crypto","_interopRequireDefault","require","_buffer","process","_interopRequireWildcard","_sdkRtl","_web","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","obj","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","key","value","_toPropertyKey","configurable","writable","_toPrimitive","String","Symbol","toPrimitive","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","undefined","utf8","asString","Buffer","from","toString","JSON","stringify","NodeCryptoHash","secureRandom","byteCount","nodeCrypto","randomBytes","sha256Hash","message","hash","createHash","update","safeBase64","Uint8Array","digest","exports","NodeTransport","BaseTransport","constructor","options","retry","request","_this","_request$options","_newOpts$maxTries","method","path","queryParams","body","authenticator","newOpts","mergeOptions","requestPath","makeUrl","waiter","waitHandler","retryWait","props","initRequest","response","initResponse","maxTries","attempt","_loop","req","fetch","url","requestStarted","Date","now","res","responseCompleted","started","BrowserTransport","markStart","markName","contentType","headers","mode","responseMode","responseBody","ResponseMode","binary","blob","text","markEnd","statusCode","status","statusMessage","statusText","startMark","ok","canRetry","result","pauseForRetry","reason","v","retryError","_ret","rawRequest","_this2","observer","parseResponse","parse","_unused","concat","string","match","bytes","arrayBuffer","_this3","type","stream","callback","_this4","init","_superprop_getInitRequest","_this5","credentials","verifySsl","env","NODE_TLS_REJECT_UNAUTHORIZED","createWritableStream","writer","WritableStream","write","chunk"],"sources":["../src/nodeTransport.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 nodeCrypto from 'crypto';\nimport type * as fs from 'fs';\n\nimport { Buffer } from 'buffer';\nimport * as process from 'process';\n\nimport type {\n Authenticator,\n HttpMethod,\n ICryptoHash,\n IRawRequest,\n IRawResponse,\n IRequestHeaders,\n ISDKError,\n ITransportSettings,\n SDKResponse,\n Values,\n} from '@looker/sdk-rtl';\nimport {\n BaseTransport,\n BrowserTransport,\n ResponseMode,\n canRetry,\n initResponse,\n pauseForRetry,\n responseMode,\n retryError,\n retryWait,\n safeBase64,\n mergeOptions,\n verifySsl,\n} from '@looker/sdk-rtl';\nimport { WritableStream } from 'node:stream/web';\n\nconst utf8 = 'utf8';\n\nconst asString = (value: any): string => {\n if (value instanceof Buffer) {\n return Buffer.from(value).toString(utf8);\n }\n if (value instanceof Object) {\n return JSON.stringify(value);\n }\n return value.toString();\n};\n\nexport class NodeCryptoHash implements ICryptoHash {\n secureRandom(byteCount: number): string {\n return nodeCrypto.randomBytes(byteCount).toString('hex');\n }\n\n async sha256Hash(message: string): Promise<string> {\n const hash = nodeCrypto.createHash('sha256');\n hash.update(message);\n return safeBase64(new Uint8Array(hash.digest()));\n }\n}\n\nexport class NodeTransport extends BaseTransport {\n constructor(protected readonly options: ITransportSettings) {\n super(options);\n }\n\n /**\n * Standard retry where requests will be retried based on configured\n * transport settings. If retry is not enabled, no requests will be retried\n *\n * This default retry pattern implements the \"full\" jitter algorithm\n * documented in https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/\n *\n * @param request options for HTTP request\n */\n async retry(request: IRawRequest): Promise<IRawResponse> {\n const { method, path, queryParams, body, authenticator } = request;\n const newOpts = mergeOptions(this.options, request.options ?? {});\n const requestPath = this.makeUrl(path, newOpts, queryParams);\n const waiter = newOpts.waitHandler || retryWait;\n const props = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n newOpts\n );\n let response = initResponse(method, requestPath);\n // TODO assign to MaxTries constant when retry is opt-out instead of opt-in\n const maxTries = newOpts.maxTries ?? 1; // MaxTries\n let attempt = 1;\n while (attempt <= maxTries) {\n const req = fetch(\n props.url,\n props as RequestInit // Weird package issues with unresolved imports for RequestInit for node-fetch :(\n );\n\n const requestStarted = Date.now();\n try {\n const res = await req;\n const responseCompleted = Date.now();\n\n // Start tracking the time it takes to convert the response\n const started = BrowserTransport.markStart(\n BrowserTransport.markName(requestPath)\n );\n const contentType = String(res.headers.get('content-type'));\n const mode = responseMode(contentType);\n const responseBody =\n mode === ResponseMode.binary ? res.blob() : res.text();\n if (!('fromRequest' in newOpts)) {\n // Request will markEnd, so don't mark the end here\n BrowserTransport.markEnd(requestPath, started);\n }\n const headers: IRequestHeaders = {};\n res.headers.forEach((value, key) => (headers[key] = value));\n response = {\n method,\n url: requestPath,\n body: responseBody,\n contentType,\n statusCode: res.status,\n statusMessage: res.statusText,\n startMark: started,\n headers,\n requestStarted,\n responseCompleted,\n ok: true,\n };\n response.ok = this.ok(response);\n if (canRetry(response.statusCode) && attempt < maxTries) {\n const result = await pauseForRetry(\n request,\n response,\n attempt,\n waiter\n );\n if (result.response === 'cancel') {\n if (result.reason) {\n response.statusMessage = result.reason;\n }\n break;\n } else if (result.response === 'error') {\n if (result.reason) {\n response.statusMessage = result.reason;\n }\n return retryError(response);\n }\n } else {\n break;\n }\n attempt++;\n } catch (e: any) {\n response.ok = false;\n response.body = e;\n response.statusCode = e.statusCode;\n response.statusMessage = e.message;\n return response;\n }\n }\n return response;\n }\n\n async rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse> {\n const response = await this.retry({\n method,\n path,\n queryParams,\n body,\n authenticator,\n options,\n });\n return this.observer ? this.observer(response) : response;\n }\n\n async parseResponse<TSuccess, TError>(res: IRawResponse) {\n const mode = responseMode(res.contentType);\n let response: SDKResponse<TSuccess, TError>;\n let error;\n if (!res.ok) {\n // Raw request had an error. Make sure it's a string before parsing the result\n error = await res.body;\n if (typeof error === 'string') {\n try {\n error = JSON.parse(error);\n } catch {\n error = { message: `Request failed: ${error}` };\n }\n }\n response = { ok: false, error };\n return response;\n }\n let result = await res.body;\n if (mode === ResponseMode.string) {\n if (res.contentType.match(/^application\\/.*\\bjson\\b/g)) {\n try {\n if (result instanceof Buffer) {\n result = Buffer.from(result).toString(); // (utf8);\n }\n if (!(result instanceof Object)) {\n result = JSON.parse(result.toString());\n }\n } catch (err: any) {\n error = err;\n }\n } else if (!error) {\n // Convert to string otherwise\n result = asString(result);\n }\n } else {\n try {\n const body = await result;\n if (typeof body === 'string') {\n result = body;\n } else {\n // must be a blob?\n const bytes = await body.arrayBuffer();\n result = Buffer.from(bytes ?? '').toString('binary');\n }\n } catch (err: any) {\n error = err;\n }\n }\n if (!error) {\n response = { ok: true, value: result };\n } else {\n response = { ok: false, error: error as TError };\n }\n return response;\n }\n\n async 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 try {\n const res = await this.rawRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n return await this.parseResponse<TSuccess, TError>(res);\n } catch (e: any) {\n const error: ISDKError = {\n message:\n typeof e.message === 'string'\n ? e.message\n : `The SDK call was not successful. The error was '${e}'.`,\n type: 'sdk_error',\n };\n return { error, ok: false };\n }\n }\n\n async stream<TSuccess>(\n callback: (response: Response) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n const newOpts = { ...this.options, options };\n const requestPath = this.makeUrl(path, newOpts, queryParams);\n const init = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n newOpts\n );\n\n const response: Response = await fetch(requestPath, init as RequestInit);\n return await callback(response);\n }\n\n protected override async initRequest(\n method: HttpMethod,\n path: string,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ) {\n const props = await super.initRequest(\n method,\n path,\n body,\n authenticator,\n options\n );\n // don't default to same-origin for NodeJS\n props.credentials = undefined;\n\n if (!verifySsl(options)) {\n process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';\n }\n\n return props;\n }\n}\n\n/**\n * Turn a NodeJS WriteStream into a WritableStream for compatibility with browser standards\n * @param writer usually created by fs.createWriteStream()\n */\nexport const createWritableStream = (\n writer: ReturnType<typeof fs.createWriteStream>\n) => {\n return new WritableStream({\n write: (chunk: any) => {\n writer.write(chunk);\n },\n });\n};\n"],"mappings":";;;;;;AA0BA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,uBAAA,CAAAH,OAAA;AAcA,IAAAI,OAAA,GAAAJ,OAAA;AAcA,IAAAK,IAAA,GAAAL,OAAA;AAAiD,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CA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EAClBxE,MAAM,EACNC,IAAI,EACJE,IAAI,EACJC,aAAa,EACbV,OACF,CAAC;MAEDkB,KAAK,CAAC6D,WAAW,GAAGxG,SAAS;MAE7B,IAAI,CAAC,IAAAyG,iBAAS,EAAChF,OAAO,CAAC,EAAE;QACvB9F,OAAO,CAAC+K,GAAG,CAACC,4BAA4B,GAAG,GAAG;MAChD;MAEA,OAAOhE,KAAK;IAAC;EACf;AACF;AAACtB,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAMM,IAAMsF,oBAAoB,GAC/BC,MAA+C,IAC5C;EACH,OAAO,IAAIC,mBAAc,CAAC;IACxBC,KAAK,EAAGC,KAAU,IAAK;MACrBH,MAAM,CAACE,KAAK,CAACC,KAAK,CAAC;IACrB;EACF,CAAC,CAAC;AACJ,CAAC;AAAC3F,OAAA,CAAAuF,oBAAA,GAAAA,oBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@looker/sdk-node",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.16.2",
|
|
4
4
|
"description": "Looker SDK Runtime for Node Library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -31,24 +31,22 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/looker-open-source/sdk-codegen/tree/main/packages/sdk-node",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/ini": "
|
|
35
|
-
"@types/node": "
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
34
|
+
"@types/ini": "4.1.1",
|
|
35
|
+
"@types/node": "22.5.4",
|
|
36
|
+
"dotenv": "^8.2.0",
|
|
37
|
+
"expect": "29.7.0",
|
|
38
|
+
"tsx": "4.19.0",
|
|
39
|
+
"whatwg-fetch": "3.6.20"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@looker/sdk": "24.
|
|
42
|
-
"@looker/sdk-rtl": "21.6.
|
|
43
|
-
"ini": "
|
|
44
|
-
"readable-stream": "^3.4.0",
|
|
45
|
-
"request": "^2.88.0",
|
|
46
|
-
"request-promise-native": "^1.0.8"
|
|
42
|
+
"@looker/sdk": "24.16.2",
|
|
43
|
+
"@looker/sdk-rtl": "21.6.3",
|
|
44
|
+
"ini": "5.0.0"
|
|
47
45
|
},
|
|
48
46
|
"keywords": [
|
|
49
47
|
"Looker",
|
|
50
48
|
"SDK",
|
|
51
49
|
"RTL"
|
|
52
50
|
],
|
|
53
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "e7e30025690483553a16231c9218cd6f7e65a59b"
|
|
54
52
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/testUtils/index.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\nexport * from './testUtils';\n"],"mappings":"AA0BA,cAAc,aAAa"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { config } from 'dotenv';
|
|
4
|
-
import { readIniConfig } from '../nodeSettings';
|
|
5
|
-
var utf8 = 'utf-8';
|
|
6
|
-
var homeToRoost = '../../../../';
|
|
7
|
-
export var getRootPath = () => path.join(__dirname, homeToRoost);
|
|
8
|
-
export var rootFile = function rootFile() {
|
|
9
|
-
var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
10
|
-
return path.join(getRootPath(), fileName);
|
|
11
|
-
};
|
|
12
|
-
export var TestConfig = function TestConfig() {
|
|
13
|
-
var rootPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
14
|
-
config();
|
|
15
|
-
var testFile = 'data.yml.json';
|
|
16
|
-
var envPrefix = 'LOOKERSDK';
|
|
17
|
-
var sectionName = 'Looker';
|
|
18
|
-
rootPath = rootPath || getRootPath();
|
|
19
|
-
var localIni = process.env.LOOKERSDK_INI || rootFile('looker.ini');
|
|
20
|
-
var testPath = rootFile('test/');
|
|
21
|
-
var dataFile = "".concat(testPath).concat(testFile);
|
|
22
|
-
var testData = JSON.parse(fs.readFileSync(dataFile, utf8));
|
|
23
|
-
var testIni = "".concat(rootPath).concat(testData.iniFile);
|
|
24
|
-
var section = readIniConfig(localIni, envPrefix, sectionName);
|
|
25
|
-
var baseUrl = section.base_url;
|
|
26
|
-
var timeout = parseInt(section.timeout, 10);
|
|
27
|
-
var testSection = readIniConfig(localIni, envPrefix, sectionName);
|
|
28
|
-
if (!fs.existsSync(localIni)) localIni = '';
|
|
29
|
-
if (!fs.existsSync(testIni)) testIni = '';
|
|
30
|
-
return {
|
|
31
|
-
baseUrl,
|
|
32
|
-
dataFile,
|
|
33
|
-
localIni,
|
|
34
|
-
rootPath,
|
|
35
|
-
section,
|
|
36
|
-
testData,
|
|
37
|
-
testIni,
|
|
38
|
-
testPath,
|
|
39
|
-
testSection,
|
|
40
|
-
timeout
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=testUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","names":["fs","path","config","readIniConfig","utf8","homeToRoost","getRootPath","join","__dirname","rootFile","fileName","arguments","length","undefined","TestConfig","rootPath","testFile","envPrefix","sectionName","localIni","process","env","LOOKERSDK_INI","testPath","dataFile","concat","testData","JSON","parse","readFileSync","testIni","iniFile","section","baseUrl","base_url","timeout","parseInt","testSection","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';\nimport { readIniConfig } from '../nodeSettings';\n\ninterface IKeyAny {\n [key: string]: any;\n}\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 baseUrl: string;\n timeout: number;\n testData: any;\n testIni: string;\n section: IKeyAny;\n testSection: IKeyAny;\n}\n\nconst homeToRoost = '../../../../';\n\nexport const getRootPath = () => path.join(__dirname, homeToRoost);\nexport const rootFile = (fileName = '') => path.join(getRootPath(), fileName);\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 const envPrefix = 'LOOKERSDK';\n const sectionName = 'Looker';\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 const section = readIniConfig(localIni, envPrefix, sectionName);\n const baseUrl = section.base_url;\n const timeout = parseInt(section.timeout, 10);\n const testSection = readIniConfig(localIni, envPrefix, sectionName);\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 baseUrl,\n dataFile,\n localIni,\n rootPath,\n section,\n testData,\n testIni,\n testPath,\n testSection,\n timeout,\n };\n};\n"],"mappings":"AA0BA,OAAO,KAAKA,EAAE,MAAM,IAAI;AACxB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAASC,aAAa,QAAQ,iBAAiB;AAM/C,IAAMC,IAAI,GAAG,OAAO;AAkBpB,IAAMC,WAAW,GAAG,cAAc;AAElC,OAAO,IAAMC,WAAW,GAAGA,CAAA,KAAML,IAAI,CAACM,IAAI,CAACC,SAAS,EAAE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C,IAAME,WAAW,GAAGlC,aAAa,CAACgB,QAAQ,EAAEF,SAAS,EAAEC,WAAW,CAAC;EAGnE,IAAI,CAAClB,EAAE,CAACsC,UAAU,CAACnB,QAAQ,CAAC,EAAEA,QAAQ,GAAG,EAAE;EAC3C,IAAI,CAACnB,EAAE,CAACsC,UAAU,CAACR,OAAO,CAAC,EAAEA,OAAO,GAAG,EAAE;EAEzC,OAAO;IACLG,OAAO;IACPT,QAAQ;IACRL,QAAQ;IACRJ,QAAQ;IACRiB,OAAO;IACPN,QAAQ;IACRI,OAAO;IACPP,QAAQ;IACRc,WAAW;IACXF;EACF,CAAC;AACH,CAAC"}
|
package/lib/testUtils/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _testUtils = require("./testUtils");
|
|
7
|
-
Object.keys(_testUtils).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _testUtils[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _testUtils[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|