@looker/sdk-rtl 21.6.1 → 21.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +48 -62
  2. package/README.md +101 -1
  3. package/lib/CSRFSession.js +2 -2
  4. package/lib/CSRFSession.js.map +1 -1
  5. package/lib/apiMethods.d.ts +2 -19
  6. package/lib/apiMethods.js +4 -4
  7. package/lib/apiMethods.js.map +1 -1
  8. package/lib/apiSettings.d.ts +1 -1
  9. package/lib/apiSettings.js +3 -4
  10. package/lib/apiSettings.js.map +1 -1
  11. package/lib/authSession.js +2 -2
  12. package/lib/authSession.js.map +1 -1
  13. package/lib/authToken.js +2 -2
  14. package/lib/authToken.js.map +1 -1
  15. package/lib/baseTransport.d.ts +4 -3
  16. package/lib/baseTransport.js +51 -2
  17. package/lib/baseTransport.js.map +1 -1
  18. package/lib/browser.js.map +1 -1
  19. package/lib/browserServices.js +2 -2
  20. package/lib/browserServices.js.map +1 -1
  21. package/lib/browserSession.d.ts +1 -1
  22. package/lib/browserSession.js +4 -4
  23. package/lib/browserSession.js.map +1 -1
  24. package/lib/browserTransport.d.ts +3 -4
  25. package/lib/browserTransport.js +98 -80
  26. package/lib/browserTransport.js.map +1 -1
  27. package/lib/constants.d.ts +4 -4
  28. package/lib/constants.js +5 -10
  29. package/lib/constants.js.map +1 -1
  30. package/lib/cryptoHash.js.map +1 -1
  31. package/lib/delimArray.d.ts +1 -1
  32. package/lib/delimArray.js +2 -2
  33. package/lib/delimArray.js.map +1 -1
  34. package/lib/errorDoc.d.ts +3 -3
  35. package/lib/errorDoc.js +7 -10
  36. package/lib/errorDoc.js.map +1 -1
  37. package/lib/esm/CSRFSession.js +6 -13
  38. package/lib/esm/CSRFSession.js.map +1 -1
  39. package/lib/esm/apiMethods.js +9 -17
  40. package/lib/esm/apiMethods.js.map +1 -1
  41. package/lib/esm/apiSettings.js +20 -32
  42. package/lib/esm/apiSettings.js.map +1 -1
  43. package/lib/esm/authSession.js +6 -13
  44. package/lib/esm/authSession.js.map +1 -1
  45. package/lib/esm/authToken.js +3 -10
  46. package/lib/esm/authToken.js.map +1 -1
  47. package/lib/esm/baseTransport.js +55 -13
  48. package/lib/esm/baseTransport.js.map +1 -1
  49. package/lib/esm/browser.js +17 -192
  50. package/lib/esm/browser.js.map +1 -1
  51. package/lib/esm/browserServices.js +8 -15
  52. package/lib/esm/browserServices.js.map +1 -1
  53. package/lib/esm/browserSession.js +12 -19
  54. package/lib/esm/browserSession.js.map +1 -1
  55. package/lib/esm/browserTransport.js +104 -94
  56. package/lib/esm/browserTransport.js.map +1 -1
  57. package/lib/esm/constants.js +8 -22
  58. package/lib/esm/constants.js.map +1 -1
  59. package/lib/esm/cryptoHash.js.map +1 -1
  60. package/lib/esm/delimArray.js +3 -10
  61. package/lib/esm/delimArray.js.map +1 -1
  62. package/lib/esm/errorDoc.js +10 -20
  63. package/lib/esm/errorDoc.js.map +1 -1
  64. package/lib/esm/extensionSession.js +3 -10
  65. package/lib/esm/extensionSession.js.map +1 -1
  66. package/lib/esm/extensionTransport.js +8 -12
  67. package/lib/esm/extensionTransport.js.map +1 -1
  68. package/lib/esm/index.js +22 -236
  69. package/lib/esm/index.js.map +1 -1
  70. package/lib/esm/lookerSDKError.js +9 -19
  71. package/lib/esm/lookerSDKError.js.map +1 -1
  72. package/lib/esm/oauthSession.js +15 -22
  73. package/lib/esm/oauthSession.js.map +1 -1
  74. package/lib/esm/paging.js +11 -23
  75. package/lib/esm/paging.js.map +1 -1
  76. package/lib/esm/platformServices.js.map +1 -1
  77. package/lib/esm/proxySession.js +6 -13
  78. package/lib/esm/proxySession.js.map +1 -1
  79. package/lib/esm/sleep.js +14 -0
  80. package/lib/esm/sleep.js.map +1 -0
  81. package/lib/esm/testUtils/index.js +1 -16
  82. package/lib/esm/testUtils/index.js.map +1 -1
  83. package/lib/esm/testUtils/testUtils.js +20 -26
  84. package/lib/esm/testUtils/testUtils.js.map +1 -1
  85. package/lib/esm/transport.js +122 -57
  86. package/lib/esm/transport.js.map +1 -1
  87. package/lib/extensionSession.d.ts +1 -1
  88. package/lib/extensionSession.js +2 -2
  89. package/lib/extensionSession.js.map +1 -1
  90. package/lib/extensionTransport.d.ts +3 -3
  91. package/lib/extensionTransport.js +7 -4
  92. package/lib/extensionTransport.js.map +1 -1
  93. package/lib/index.d.ts +1 -0
  94. package/lib/index.js +11 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/lookerSDKError.d.ts +1 -1
  97. package/lib/lookerSDKError.js +9 -13
  98. package/lib/lookerSDKError.js.map +1 -1
  99. package/lib/oauthSession.d.ts +6 -4
  100. package/lib/oauthSession.js +7 -7
  101. package/lib/oauthSession.js.map +1 -1
  102. package/lib/paging.d.ts +5 -6
  103. package/lib/paging.js +4 -6
  104. package/lib/paging.js.map +1 -1
  105. package/lib/platformServices.js.map +1 -1
  106. package/lib/proxySession.d.ts +1 -1
  107. package/lib/proxySession.js.map +1 -1
  108. package/lib/sleep.d.ts +1 -0
  109. package/lib/sleep.js +20 -0
  110. package/lib/sleep.js.map +1 -0
  111. package/lib/testUtils/index.js.map +1 -1
  112. package/lib/testUtils/testUtils.js +16 -11
  113. package/lib/testUtils/testUtils.js.map +1 -1
  114. package/lib/transport.d.ts +64 -17
  115. package/lib/transport.js +113 -20
  116. package/lib/transport.js.map +1 -1
  117. package/package.json +5 -13
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.BrowserTransport = exports.BrowserCryptoHash = void 0;
7
7
  var _transport = require("./transport");
8
8
  var _baseTransport = require("./baseTransport");
9
- 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; }
10
- 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; }
9
+ 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; }
10
+ 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; }
11
11
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
- function _toPropertyKey(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); }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
14
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
15
  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); }); }; }
16
16
  class BrowserCryptoHash {
@@ -81,40 +81,92 @@ class BrowserTransport extends _baseTransport.BaseTransport {
81
81
  }
82
82
  return '';
83
83
  }
84
- rawRequest(method, path, queryParams, body, authenticator, options) {
84
+ retry(request) {
85
85
  var _this = this;
86
86
  return _asyncToGenerator(function* () {
87
- options = _objectSpread(_objectSpread({}, _this.options), options);
88
- var requestPath = _this.makeUrl(path, options, queryParams);
89
- var props = yield _this.initRequest(method, requestPath, body, authenticator, options);
90
- var req = fetch(props.url, props);
91
- var requestStarted = Date.now();
92
- var res = yield req;
93
- var responseCompleted = Date.now();
94
- var started = BrowserTransport.markStart(BrowserTransport.markName(requestPath));
95
- var contentType = String(res.headers.get('content-type'));
96
- var mode = (0, _transport.responseMode)(contentType);
97
- var responseBody = mode === _transport.ResponseMode.binary ? yield res.blob() : yield res.text();
98
- if (!('fromRequest' in options)) {
99
- BrowserTransport.markEnd(requestPath, started);
100
- }
101
- var headers = {};
102
- res.headers.forEach((value, key) => headers[key] = value);
103
- var response = {
87
+ var _request$options, _newOpts$maxTries;
88
+ var {
104
89
  method,
105
- url: requestPath,
106
- body: responseBody,
107
- contentType,
108
- ok: true,
109
- statusCode: res.status,
110
- statusMessage: res.statusText,
111
- startMark: started,
112
- headers,
113
- requestStarted,
114
- responseCompleted
90
+ path,
91
+ queryParams,
92
+ body,
93
+ authenticator
94
+ } = request;
95
+ var newOpts = (0, _transport.mergeOptions)(_this.options, (_request$options = request.options) !== null && _request$options !== void 0 ? _request$options : {});
96
+ var requestPath = _this.makeUrl(path, newOpts, queryParams);
97
+ var props = yield _this.initRequest(method, requestPath, body, authenticator, newOpts);
98
+ var waiter = newOpts.waitHandler || _transport.retryWait;
99
+ var response = (0, _transport.initResponse)(method, requestPath);
100
+ var maxRetries = (_newOpts$maxTries = newOpts === null || newOpts === void 0 ? void 0 : newOpts.maxTries) !== null && _newOpts$maxTries !== void 0 ? _newOpts$maxTries : 1;
101
+ var attempt = 1;
102
+ var _loop = function* _loop() {
103
+ var req = fetch(props.url, props);
104
+ var requestStarted = Date.now();
105
+ var res = yield req;
106
+ var responseCompleted = Date.now();
107
+ var started = BrowserTransport.markStart(BrowserTransport.markName(requestPath));
108
+ var contentType = String(res.headers.get('content-type'));
109
+ var mode = (0, _transport.responseMode)(contentType);
110
+ var responseBody = mode === _transport.ResponseMode.binary ? yield res.blob() : yield res.text();
111
+ if (!('fromRequest' in newOpts)) {
112
+ BrowserTransport.markEnd(requestPath, started);
113
+ }
114
+ var headers = {};
115
+ res.headers.forEach((value, key) => headers[key] = value);
116
+ response = {
117
+ method,
118
+ url: requestPath,
119
+ body: responseBody,
120
+ contentType,
121
+ statusCode: res.status,
122
+ statusMessage: res.statusText,
123
+ startMark: started,
124
+ headers,
125
+ requestStarted,
126
+ responseCompleted,
127
+ ok: true
128
+ };
129
+ response.ok = _this.ok(response);
130
+ if ((0, _transport.canRetry)(response.statusCode) && attempt < maxRetries) {
131
+ var result = yield (0, _transport.pauseForRetry)(request, response, attempt, waiter);
132
+ if (result.response === 'cancel') {
133
+ if (result.reason) {
134
+ response.statusMessage = result.reason;
135
+ }
136
+ return "break";
137
+ } else if (result.response === 'error') {
138
+ if (result.reason) {
139
+ response.statusMessage = result.reason;
140
+ }
141
+ return {
142
+ v: (0, _transport.retryError)(response)
143
+ };
144
+ }
145
+ } else {
146
+ return "break";
147
+ }
148
+ attempt++;
115
149
  };
116
- response.ok = _this.ok(response);
117
- return _this.observer ? _this.observer(response) : response;
150
+ while (attempt <= maxRetries) {
151
+ var _ret = yield* _loop();
152
+ if (_ret === "break") break;
153
+ if (typeof _ret === "object") return _ret.v;
154
+ }
155
+ return response;
156
+ })();
157
+ }
158
+ rawRequest(method, path, queryParams, body, authenticator, options) {
159
+ var _this2 = this;
160
+ return _asyncToGenerator(function* () {
161
+ var response = yield _this2.retry({
162
+ method,
163
+ path,
164
+ queryParams,
165
+ body,
166
+ authenticator,
167
+ options
168
+ });
169
+ return _this2.observer ? _this2.observer(response) : response;
118
170
  })();
119
171
  }
120
172
  parseResponse(res) {
@@ -175,16 +227,16 @@ class BrowserTransport extends _baseTransport.BaseTransport {
175
227
  })();
176
228
  }
177
229
  request(method, path, queryParams, body, authenticator, options) {
178
- var _this2 = this;
230
+ var _this3 = this;
179
231
  return _asyncToGenerator(function* () {
180
232
  try {
181
233
  if (BrowserTransport.trackPerformance) {
182
- options = _objectSpread(_objectSpread({}, options), {
234
+ options = _objectSpread(_objectSpread({}, options), {}, {
183
235
  fromRequest: true
184
236
  });
185
237
  }
186
- var res = yield _this2.rawRequest(method, path, queryParams, body, authenticator, options);
187
- var result = yield _this2.parseResponse(res);
238
+ var res = yield _this3.rawRequest(method, path, queryParams, body, authenticator, options);
239
+ var result = yield _this3.parseResponse(res);
188
240
  return result;
189
241
  } catch (e) {
190
242
  if (!(0, _transport.isErrorLike)(e)) throw e;
@@ -199,50 +251,16 @@ class BrowserTransport extends _baseTransport.BaseTransport {
199
251
  }
200
252
  })();
201
253
  }
202
- initRequest(method, path, body, authenticator, options) {
203
- var _this3 = this;
204
- return _asyncToGenerator(function* () {
205
- var _options;
206
- var agentTag = ((_options = options) === null || _options === void 0 ? void 0 : _options.agentTag) || _transport.agentPrefix;
207
- options = options ? _objectSpread(_objectSpread({}, _this3.options), options) : _this3.options;
208
- var headers = {
209
- [_transport.LookerAppId]: agentTag
210
- };
211
- if (options && options.headers) {
212
- Object.entries(options.headers).forEach(_ref => {
213
- var [key, val] = _ref;
214
- headers[key] = val;
215
- });
216
- }
217
- if (!body) {
218
- body = undefined;
219
- } else {
220
- if (typeof body !== 'string') {
221
- body = JSON.stringify(body);
222
- headers['Content-Type'] = 'application/json';
223
- }
224
- }
225
- var props = {
226
- body,
227
- credentials: 'same-origin',
228
- headers,
229
- method,
230
- url: path
231
- };
232
- if (authenticator) {
233
- props = yield authenticator(props);
234
- }
235
- return props;
236
- })();
237
- }
238
- stream(_callback, method, path, queryParams, body, authenticator, options) {
254
+ stream(callback, method, path, queryParams, body, authenticator, options) {
239
255
  var _this4 = this;
240
256
  return _asyncToGenerator(function* () {
241
- options = options ? _objectSpread(_objectSpread({}, _this4.options), options) : _this4.options;
242
- var requestPath = _this4.makeUrl(path, options, queryParams);
243
- var props = yield _this4.initRequest(method, requestPath, body, authenticator, options);
244
- (0, _transport.trace)("[stream] attempting to stream via download url", props);
245
- return Promise.reject(Error("Streaming for callback ".concat(props.method, " ").concat(props.requestPath, " is not implemented")));
257
+ var newOpts = _objectSpread(_objectSpread({}, _this4.options), {}, {
258
+ options
259
+ });
260
+ var requestPath = _this4.makeUrl(path, newOpts, queryParams);
261
+ var init = yield _this4.initRequest(method, requestPath, body, authenticator, newOpts);
262
+ var response = yield fetch(requestPath, init);
263
+ return yield callback(response);
246
264
  })();
247
265
  }
248
266
  }
@@ -1 +1 @@
1
- {"version":3,"file":"browserTransport.js","names":["_transport","require","_baseTransport","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","asyncGeneratorStep","gen","resolve","reject","_next","_throw","info","error","done","Promise","then","_asyncToGenerator","fn","self","args","err","BrowserCryptoHash","arrayToHex","array","Array","from","map","b","toString","padStart","join","fromBase64","str","atob","split","c","charCodeAt","secureRandom","byteCount","bytes","Uint8Array","window","crypto","getRandomValues","sha256Hash","message","msgUint8","TextEncoder","encode","hashBuffer","subtle","digest","safeBase64","exports","BrowserTransport","BaseTransport","constructor","options","supportsPerformance","performance","mark","measure","trackPerformance","_trackPerf","name","tag","concat","markName","url","entries","getEntriesByName","last","startTime","markStart","startMark","markEnd","startName","measureName","end","endMark","clearMarks","rawRequest","method","path","queryParams","body","authenticator","_this","requestPath","makeUrl","props","initRequest","req","fetch","requestStarted","Date","now","responseCompleted","started","contentType","headers","get","mode","responseMode","responseBody","ResponseMode","binary","blob","text","response","ok","statusCode","status","statusMessage","statusText","observer","parseResponse","perfMark","JSON","parse","_unused","match","startsWith","result","request","_this2","fromRequest","e","isErrorLike","type","_this3","_options","agentTag","agentPrefix","LookerAppId","_ref","val","stringify","credentials","stream","_callback","_this4","trace","Error"],"sources":["../src/browserTransport.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 ISDKError,\n SDKResponse,\n ITransportSettings,\n HttpMethod,\n Authenticator,\n IRequestProps,\n IRequestHeaders,\n Values,\n IRawResponse,\n} from './transport'\nimport {\n trace,\n LookerAppId,\n agentPrefix,\n responseMode,\n ResponseMode,\n safeBase64,\n isErrorLike,\n} from './transport'\nimport { BaseTransport } from './baseTransport'\nimport type { ICryptoHash } from './cryptoHash'\n\nexport class BrowserCryptoHash implements ICryptoHash {\n arrayToHex(array: Uint8Array): string {\n return Array.from(array)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n }\n\n fromBase64(str: string) {\n return atob(str)\n .split('')\n .map(function (c) {\n return c.charCodeAt(0)\n })\n }\n\n secureRandom(byteCount: number): string {\n const bytes = new Uint8Array(byteCount)\n window.crypto.getRandomValues(bytes)\n return this.arrayToHex(bytes)\n }\n\n async sha256Hash(message: string): Promise<string> {\n const msgUint8 = new TextEncoder().encode(message)\n const hashBuffer = await window.crypto.subtle.digest('SHA-256', msgUint8)\n return safeBase64(new Uint8Array(hashBuffer))\n }\n}\n\nexport class BrowserTransport extends BaseTransport {\n constructor(protected readonly options: ITransportSettings) {\n super(options)\n }\n\n /** Does this browser have the necessary performance APIs? */\n static supportsPerformance() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!(performance && performance.mark && performance.measure)\n }\n\n private static _trackPerf = false\n\n public static get trackPerformance() {\n return this._trackPerf\n }\n\n public static set trackPerformance(value: boolean) {\n this._trackPerf = value && BrowserTransport.supportsPerformance()\n }\n\n static startMark = 'A'\n static endMark = 'B'\n\n /**\n * Create a performance mark\n * @param name to use as prefix of mark. Use `markName()` to determine the name\n * @param tag tag to use to distinguish mark\n * @returns the name of the mark used, or '' if not marked\n */\n static mark(name: string, tag: string) {\n if (this.trackPerformance) {\n const mark = `${name}-${tag}`\n performance.mark(mark)\n return mark\n }\n return ''\n }\n\n /**\n * Create a unique name for the performance metric of the url based on its start time\n * @param url metric to find\n *\n * Uses the last entry of the matching metric to create the name for the tracker so\n * post processing can use it to merge into the main resource tracker\n *\n */\n static markName(url: string) {\n if (!this.trackPerformance) return ''\n\n const entries = performance.getEntriesByName(url, 'resource')\n if (entries.length > 0) {\n const last = entries[entries.length - 1]\n return `${url}-${last.startTime}`\n }\n return url\n }\n\n /**\n * Mark the start of a performance measure\n * @param name to use as prefix of mark. Use `markName()` to determine the name\n */\n static markStart(name: string) {\n return BrowserTransport.mark(name, BrowserTransport.startMark)\n }\n\n /**\n * Mark the end of a performance measure\n * @param url to find starting mark which doesn't have a resource entry yet\n * @param startName name of the start mark\n *\n * Creates the start/end performance measure\n *\n * @returns the name of the performance measure\n */\n static markEnd(url: string, startName: string) {\n if (this.trackPerformance) {\n // Find the resource entry and use it to create the measure name\n const measureName = this.markName(url)\n const end = BrowserTransport.mark(measureName, BrowserTransport.endMark)\n performance.measure(measureName, startName, end)\n // Marks have been processed into a measure, so remove them\n performance.clearMarks(startName)\n performance.clearMarks(end)\n return measureName\n }\n return ''\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 options = { ...this.options, ...options }\n const requestPath = this.makeUrl(path, options, queryParams)\n const props = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n options\n )\n const req = fetch(\n props.url,\n props // Weird package issues with unresolved imports for RequestInit :(\n )\n\n const requestStarted = Date.now()\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 ? await res.blob() : await res.text()\n if (!('fromRequest' in options)) {\n // Request will markEnd, so don't mark the end here\n BrowserTransport.markEnd(requestPath, started)\n }\n const headers = {}\n res.headers.forEach((value, key) => (headers[key] = value))\n const response: IRawResponse = {\n method,\n url: requestPath,\n body: responseBody,\n contentType,\n ok: true,\n statusCode: res.status,\n statusMessage: res.statusText,\n startMark: started,\n headers,\n requestStarted,\n responseCompleted,\n }\n // Update OK with response statusCode check\n response.ok = this.ok(response)\n return this.observer ? this.observer(response) : response\n }\n\n /**\n * Process the response based on content type\n * @param res response to process\n */\n async parseResponse<TSuccess, TError>(\n res: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>> {\n const perfMark = res.startMark || ''\n if (!res.ok) {\n // Raw request had an error. Make sure it's a string before parsing the result\n let 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 const response: SDKResponse<TSuccess, TError> = { ok: false, error }\n return response\n }\n\n let value\n let error\n if (res.contentType.match(/application\\/json/g)) {\n try {\n value = JSON.parse(await res.body)\n BrowserTransport.markEnd(res.url, perfMark)\n } catch (err) {\n error = err\n BrowserTransport.markEnd(res.url, perfMark)\n }\n } else if (\n res.contentType === 'text' ||\n res.contentType.startsWith('text/')\n ) {\n value = res.body.toString()\n BrowserTransport.markEnd(res.url, perfMark)\n } else {\n try {\n BrowserTransport.markEnd(res.url, perfMark)\n value = res.body\n } catch (err) {\n BrowserTransport.markEnd(res.url, perfMark)\n error = err\n }\n }\n let result: SDKResponse<TSuccess, TError>\n if (error) {\n result = { ok: false, error: error as TError }\n } else {\n result = { ok: true, value }\n }\n return result\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 if (BrowserTransport.trackPerformance) {\n options = { ...options, ...{ fromRequest: true } }\n }\n const res = await this.rawRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n )\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const result: SDKResponse<TSuccess, TError> = await this.parseResponse(\n res\n )\n return result\n } catch (e: unknown) {\n if (!isErrorLike(e)) throw e\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 private async initRequest(\n method: HttpMethod,\n path: string,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ) {\n const agentTag = options?.agentTag || agentPrefix\n options = options ? { ...this.options, ...options } : this.options\n const headers: IRequestHeaders = { [LookerAppId]: agentTag }\n if (options && options.headers) {\n Object.entries(options.headers).forEach(([key, val]) => {\n headers[key] = val\n })\n }\n\n // Make sure an empty body is undefined\n if (!body) {\n body = undefined\n } else {\n if (typeof body !== 'string') {\n body = JSON.stringify(body)\n headers['Content-Type'] = 'application/json'\n }\n }\n let props: IRequestProps = {\n body,\n credentials: 'same-origin',\n headers,\n method,\n url: path,\n }\n\n if (authenticator) {\n // Add authentication information to the request\n props = await authenticator(props)\n }\n\n return props\n }\n\n // TODO finish this method\n async stream<TSuccess>(\n _callback: (readable: Readable) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n options = options ? { ...this.options, ...options } : this.options\n // const stream = new PassThrough()\n // const returnPromise = callback(stream)\n const requestPath = this.makeUrl(path, options, queryParams)\n const props = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n options\n )\n trace(`[stream] attempting to stream via download url`, props)\n\n return Promise.reject<TSuccess>(\n // Silly error message to prevent linter from complaining about unused variables\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Error(\n `Streaming for callback ${props.method} ${props.requestPath} is not implemented`\n )\n )\n\n /*\n TODO complete this for the browser implementation\n const streamPromise = new Promise<void>((resolve, reject) => {\n trace(`[stream] beginning stream via download url`, props)\n reject(Error('Not implemented yet!'))\n // let hasResolved = false\n // const req = this.requestor(props)\n //\n // req\n // .on(\"error\", (err) => {\n // if (hasResolved && (err as any).code === \"ECONNRESET\") {\n // trace('ignoring ECONNRESET that occurred after streaming finished', props)\n // } else {\n // trace('streaming error', err)\n // reject(err)\n // }\n // })\n // .on(\"finish\", () => {\n // trace(`[stream] streaming via download url finished`, props)\n // })\n // .on(\"socket\", (socket) => {\n // trace(`[stream] setting keepalive on socket`, props)\n // socket.setKeepAlive(true)\n // })\n // .on(\"abort\", () => {\n // trace(`[stream] streaming via download url aborted`, props)\n // })\n // .on(\"response\", () => {\n // trace(`[stream] got response from download url`, props)\n // })\n // .on(\"close\", () => {\n // trace(`[stream] request stream closed`, props)\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`, props)\n // resolve()\n // hasResolved = true\n // })\n // .on(\"close\", () => {\n // trace(`[stream] PassThrough stream closed`, props)\n // })\n })\n\n const results = await Promise.all([returnPromise, streamPromise])\n return results[0]\n */\n }\n}\n"],"mappings":";;;;;;AAsCA,IAAAA,UAAA,GAAAC,OAAA;AASA,IAAAC,cAAA,GAAAD,OAAA;AAA+C,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SA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K,CAAC;MAE9D,OAAO5E,OAAO,CAACN,MAAM,CAInBuI,KAAK,2BAAA7E,MAAA,CACuBwB,KAAK,CAACR,MAAM,OAAAhB,MAAA,CAAIwB,KAAK,CAACF,WAAW,yBAC5D,CACF;IAAA;EAqDH;AACF;AAACnC,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAAAvE,eAAA,CA/WYuE,gBAAgB,gBAYC,KAAK;AAAAvE,eAAA,CAZtBuE,gBAAgB,eAsBR,GAAG;AAAAvE,eAAA,CAtBXuE,gBAAgB,aAuBV,GAAG"}
1
+ {"version":3,"file":"browserTransport.js","names":["_transport","require","_baseTransport","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","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","BrowserCryptoHash","arrayToHex","array","Array","from","map","b","toString","padStart","join","fromBase64","str","atob","split","c","charCodeAt","secureRandom","byteCount","bytes","Uint8Array","window","crypto","getRandomValues","sha256Hash","message","msgUint8","TextEncoder","encode","hashBuffer","subtle","digest","safeBase64","exports","BrowserTransport","BaseTransport","constructor","options","supportsPerformance","performance","mark","measure","trackPerformance","_trackPerf","name","tag","concat","markName","url","entries","getEntriesByName","last","startTime","markStart","startMark","markEnd","startName","measureName","end","endMark","clearMarks","retry","request","_this","_request$options","_newOpts$maxTries","method","path","queryParams","body","authenticator","newOpts","mergeOptions","requestPath","makeUrl","props","initRequest","waiter","waitHandler","retryWait","response","initResponse","maxRetries","maxTries","attempt","_loop","req","fetch","requestStarted","Date","now","res","responseCompleted","started","contentType","headers","get","mode","responseMode","responseBody","ResponseMode","binary","blob","text","statusCode","status","statusMessage","statusText","ok","canRetry","result","pauseForRetry","reason","v","retryError","_ret","rawRequest","_this2","observer","parseResponse","perfMark","JSON","parse","_unused","match","startsWith","_this3","fromRequest","isErrorLike","type","stream","callback","_this4","init"],"sources":["../src/browserTransport.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type {\n Authenticator,\n HttpMethod,\n IRawRequest,\n IRawResponse,\n ISDKError,\n ITransportSettings,\n SDKResponse,\n Values,\n} from './transport';\nimport {\n ResponseMode,\n canRetry,\n initResponse,\n isErrorLike,\n pauseForRetry,\n responseMode,\n retryError,\n retryWait,\n safeBase64,\n mergeOptions,\n} from './transport';\nimport { BaseTransport } from './baseTransport';\nimport type { ICryptoHash } from './cryptoHash';\n\nexport class BrowserCryptoHash implements ICryptoHash {\n arrayToHex(array: Uint8Array): string {\n return Array.from(array)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n }\n\n fromBase64(str: string) {\n return atob(str)\n .split('')\n .map(function (c) {\n return c.charCodeAt(0);\n });\n }\n\n secureRandom(byteCount: number): string {\n const bytes = new Uint8Array(byteCount);\n window.crypto.getRandomValues(bytes);\n return this.arrayToHex(bytes);\n }\n\n async sha256Hash(message: string): Promise<string> {\n const msgUint8 = new TextEncoder().encode(message);\n const hashBuffer = await window.crypto.subtle.digest('SHA-256', msgUint8);\n return safeBase64(new Uint8Array(hashBuffer));\n }\n}\n\nexport class BrowserTransport extends BaseTransport {\n constructor(protected readonly options: ITransportSettings) {\n super(options);\n }\n\n /** Does this browser have the necessary performance APIs? */\n static supportsPerformance() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!(performance && performance.mark && performance.measure);\n }\n\n private static _trackPerf = false;\n\n public static get trackPerformance() {\n return this._trackPerf;\n }\n\n public static set trackPerformance(value: boolean) {\n this._trackPerf = value && BrowserTransport.supportsPerformance();\n }\n\n static startMark = 'A';\n static endMark = 'B';\n\n /**\n * Create a performance mark\n * @param name to use as prefix of mark. Use `markName()` to determine the name\n * @param tag tag to use to distinguish mark\n * @returns the name of the mark used, or '' if not marked\n */\n static mark(name: string, tag: string) {\n if (this.trackPerformance) {\n const mark = `${name}-${tag}`;\n performance.mark(mark);\n return mark;\n }\n return '';\n }\n\n /**\n * Create a unique name for the performance metric of the url based on its start time\n * @param url metric to find\n *\n * Uses the last entry of the matching metric to create the name for the tracker so\n * post processing can use it to merge into the main resource tracker\n *\n */\n static markName(url: string) {\n if (!this.trackPerformance) return '';\n\n const entries = performance.getEntriesByName(url, 'resource');\n if (entries.length > 0) {\n const last = entries[entries.length - 1];\n return `${url}-${last.startTime}`;\n }\n return url;\n }\n\n /**\n * Mark the start of a performance measure\n * @param name to use as prefix of mark. Use `markName()` to determine the name\n */\n static markStart(name: string) {\n return BrowserTransport.mark(name, BrowserTransport.startMark);\n }\n\n /**\n * Mark the end of a performance measure\n * @param url to find starting mark which doesn't have a resource entry yet\n * @param startName name of the start mark\n *\n * Creates the start/end performance measure\n *\n * @returns the name of the performance measure\n */\n static markEnd(url: string, startName: string) {\n if (this.trackPerformance) {\n // Find the resource entry and use it to create the measure name\n const measureName = this.markName(url);\n const end = BrowserTransport.mark(measureName, BrowserTransport.endMark);\n performance.measure(measureName, startName, end);\n // Marks have been processed into a measure, so remove them\n performance.clearMarks(startName);\n performance.clearMarks(end);\n return measureName;\n }\n return '';\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 props = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n newOpts\n );\n const waiter = newOpts.waitHandler || retryWait;\n let response = initResponse(method, requestPath);\n // TODO assign to MaxTries when retry is opt-out instead of opt-in\n const maxRetries = newOpts?.maxTries ?? 1; // MaxTries\n let attempt = 1;\n while (attempt <= maxRetries) {\n const req = fetch(props.url, props as RequestInit);\n\n const requestStarted = Date.now();\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 ? await res.blob() : await 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: { [key: string]: any } = {};\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 < maxRetries) {\n const result = await pauseForRetry(request, response, attempt, waiter);\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 }\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 /**\n * Process the response based on content type\n * @param res response to process\n */\n async parseResponse<TSuccess, TError>(\n res: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>> {\n const perfMark = res.startMark || '';\n if (!res.ok) {\n // Raw request had an error. Make sure it's a string before parsing the result\n let 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 const response: SDKResponse<TSuccess, TError> = { ok: false, error };\n return response;\n }\n\n let value;\n let error;\n if (res.contentType.match(/application\\/json/g)) {\n try {\n value = JSON.parse(await res.body);\n BrowserTransport.markEnd(res.url, perfMark);\n } catch (err) {\n error = err;\n BrowserTransport.markEnd(res.url, perfMark);\n }\n } else if (\n res.contentType === 'text' ||\n res.contentType.startsWith('text/')\n ) {\n value = res.body.toString();\n BrowserTransport.markEnd(res.url, perfMark);\n } else {\n try {\n BrowserTransport.markEnd(res.url, perfMark);\n value = res.body;\n } catch (err) {\n BrowserTransport.markEnd(res.url, perfMark);\n error = err;\n }\n }\n let result: SDKResponse<TSuccess, TError>;\n if (error) {\n result = { ok: false, error: error as TError };\n } else {\n result = { ok: true, value };\n }\n return result;\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 if (BrowserTransport.trackPerformance) {\n options = { ...options, fromRequest: true } as any;\n }\n const res = await this.rawRequest(\n method,\n path,\n queryParams,\n body,\n authenticator,\n options\n );\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const result: SDKResponse<TSuccess, TError> = await this.parseResponse(\n res\n );\n return result;\n } catch (e: unknown) {\n if (!isErrorLike(e)) throw e;\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 // TODO push this method down to base transport\n const newOpts = { ...this.options, options };\n const requestPath = this.makeUrl(path, newOpts, queryParams);\n // TODO add signal: AbortSignal support\n const init = await this.initRequest(\n method,\n requestPath,\n body,\n authenticator,\n newOpts\n );\n\n const response = await fetch(requestPath, init as RequestInit);\n return await callback(response);\n }\n}\n"],"mappings":";;;;;;AAoCA,IAAAA,UAAA,GAAAC,OAAA;AAYA,IAAAC,cAAA,GAAAD,OAAA;AAAgD,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA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WAAoB,EACpBC,IAAU,EACVC,aAA6B,EAC7BjC,OAAqC,EAClB;IAAA,IAAA+F,MAAA;IAAA,OAAAzI,iBAAA;MAEnB,IAAM4E,OAAO,GAAA9G,aAAA,CAAAA,aAAA,KAAQ2K,MAAI,CAAC/F,OAAO;QAAEA;MAAO,EAAE;MAC5C,IAAMoC,WAAW,GAAG2D,MAAI,CAAC1D,OAAO,CAACP,IAAI,EAAEI,OAAO,EAAEH,WAAW,CAAC;MAE5D,IAAMiE,IAAI,SAASD,MAAI,CAACxD,WAAW,CACjCV,MAAM,EACNO,WAAW,EACXJ,IAAI,EACJC,aAAa,EACbC,OACF,CAAC;MAED,IAAMS,QAAQ,SAASO,KAAK,CAACd,WAAW,EAAE4D,IAAmB,CAAC;MAC9D,aAAaF,QAAQ,CAACnD,QAAQ,CAAC;IAAC;EAClC;AACF;AAAC/C,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAAArE,eAAA,CApTYqE,gBAAgB,gBAYC,KAAK;AAAArE,eAAA,CAZtBqE,gBAAgB,eAsBR,GAAG;AAAArE,eAAA,CAtBXqE,gBAAgB,aAuBV,GAAG"}
@@ -1,13 +1,13 @@
1
1
  export declare const matchCharset = ";.*\bcharset\b=";
2
- export declare const matchCharsetUtf8: string;
3
- export declare const matchModeString: string;
2
+ export declare const matchCharsetUtf8 = ";.*\bcharset\b=.*\\butf-8\\b";
3
+ export declare const matchModeString = "(^application\\/.*(\\bjson\\b|\\bxml\\b|\\bsql\\b|\\bgraphql\\b|\\bjavascript\\b|\\bx-www-form-urlencoded\\b)|^text\\/|.*\\+xml\\b|;.*\bcharset\b=)";
4
4
  export declare const matchModeBinary = "^image\\/|^audio\\/|^video\\/|^font\\/|^application\\/|^multipart\\/";
5
5
  export declare const isTrue: (value: string) => boolean;
6
6
  export declare const isFalse: (value: string) => boolean;
7
7
  export declare const boolDefault: (value: string, defaultBool?: boolean) => boolean;
8
8
  export declare const unquote: (value: string | undefined | null) => string;
9
- export declare type Url = string;
9
+ export type Url = string;
10
10
  export interface IDictionary<T> {
11
11
  [key: string]: T;
12
12
  }
13
- export declare type Password = string;
13
+ export type Password = string;
package/lib/constants.js CHANGED
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unquote = exports.matchModeString = exports.matchModeBinary = exports.matchCharsetUtf8 = exports.matchCharset = exports.isTrue = exports.isFalse = exports.boolDefault = void 0;
7
- var matchCharset = ';.*charset=';
8
- exports.matchCharset = matchCharset;
9
- var matchCharsetUtf8 = "".concat(matchCharset, ".*\\butf-8\\b");
10
- exports.matchCharsetUtf8 = matchCharsetUtf8;
11
- var matchModeString = "(^application\\/.*(\\bjson\\b|\\bxml\\b|\\bsql\\b|\\bgraphql\\b|\\bjavascript\\b|\\bx-www-form-urlencoded\\b)|^text\\/|.*\\+xml\\b|".concat(matchCharset, ")");
12
- exports.matchModeString = matchModeString;
13
- var matchModeBinary = '^image\\/|^audio\\/|^video\\/|^font\\/|^application\\/|^multipart\\/';
14
- exports.matchModeBinary = matchModeBinary;
7
+ var matchCharset = exports.matchCharset = ';.*charset=';
8
+ var matchCharsetUtf8 = exports.matchCharsetUtf8 = "".concat(matchCharset, ".*\\butf-8\\b");
9
+ var matchModeString = exports.matchModeString = "(^application\\/.*(\\bjson\\b|\\bxml\\b|\\bsql\\b|\\bgraphql\\b|\\bjavascript\\b|\\bx-www-form-urlencoded\\b)|^text\\/|.*\\+xml\\b|".concat(matchCharset, ")");
10
+ var matchModeBinary = exports.matchModeBinary = '^image\\/|^audio\\/|^video\\/|^font\\/|^application\\/|^multipart\\/';
15
11
  var isTrue = value => /^(true|t|yes|y|1)$/i.test(value);
16
12
  exports.isTrue = isTrue;
17
13
  var isFalse = value => /^(false|f|no|n|0)$/i.test(value);
18
14
  exports.isFalse = isFalse;
19
- var boolDefault = function boolDefault(value) {
15
+ var boolDefault = exports.boolDefault = function boolDefault(value) {
20
16
  var defaultBool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21
17
  if (isTrue(value)) return true;
22
18
  if (isFalse(value)) return false;
23
19
  return defaultBool;
24
20
  };
25
- exports.boolDefault = boolDefault;
26
21
  var unquote = value => {
27
22
  if (!value) return '';
28
23
  if (/^['"`]/.test(value)) {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["matchCharset","exports","matchCharsetUtf8","concat","matchModeString","matchModeBinary","isTrue","value","test","isFalse","boolDefault","defaultBool","arguments","length","undefined","unquote","quote","substring","endsWith"],"sources":["../src/constants.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 const matchCharset = ';.*\bcharset\b='\n\n/**\n * Does this content type say it's utf-8?\n * @type {string} Regular expression for matching charset=utf-8 in Content-Type\n */\nexport const matchCharsetUtf8 = `${matchCharset}.*\\\\butf-8\\\\b`\n\n/**\n * Matching rules for string/text types. String matches must be checked *before* binary matches\n * @type {string} Regular expression for matching Content-Type headers\n */\nexport const matchModeString = `(^application\\\\/.*(\\\\bjson\\\\b|\\\\bxml\\\\b|\\\\bsql\\\\b|\\\\bgraphql\\\\b|\\\\bjavascript\\\\b|\\\\bx-www-form-urlencoded\\\\b)|^text\\\\/|.*\\\\+xml\\\\b|${matchCharset})`\n\n/**\n * Matching rules for all binary or unknown types. Binary matches must be checked *after* string matches\n * @type {string} Regular expression for matching Content-Type headers\n */\nexport const matchModeBinary =\n '^image\\\\/|^audio\\\\/|^video\\\\/|^font\\\\/|^application\\\\/|^multipart\\\\/'\n\n/**\n * Does this string mean \"true\"\n * @param {string} value\n * @returns {boolean} true if matching a `true` value, false otherwise\n */\nexport const isTrue = (value: string) => /^(true|t|yes|y|1)$/i.test(value)\n\n/**\n * Does this string mean \"false\"\n * @param {string} value\n * @returns {boolean} true if matching a `false` value, false otherwise\n */\nexport const isFalse = (value: string) => /^(false|f|no|n|0)$/i.test(value)\n\n/**\n * Return true, false, or default boolean value for string representation of boolean\n * @param {string} value\n * @param {boolean} defaultBool is the value to return if the string doesn't match. defaults to false.\n * @returns {boolean} true or false\n */\nexport const boolDefault = (value: string, defaultBool = false) => {\n if (isTrue(value)) return true\n if (isFalse(value)) return false\n return defaultBool\n}\n\n/**\n * strip surrounding quotes from a string if it is uniformly quoted\n * @param {string | null} value to unquote\n * @returns {string | null} unquoted string if it begins and ends with the same character out of `\\` \" '`\n */\nexport const unquote = (value: string | undefined | null): string => {\n if (!value) return ''\n if (/^['\"`]/.test(value)) {\n const quote = value.substring(0, 1)\n // Strip surrounding quotes?\n if (value.endsWith(quote)) return value.substring(1, value.length - 1)\n }\n return value\n}\n\n/**\n * Documented type alias because URL assignment construction is not compatible with API parameters\n */\nexport type Url = string\n\n/** Documented type to clarify SDK hash types */\nexport interface IDictionary<T> {\n [key: string]: T\n}\n\n/**\n * Documented type alias for password spec\n */\nexport type Password = string\n"],"mappings":";;;;;;AA0BO,IAAMA,YAAY,GAAG,eAAe;AAAAC,OAAA,CAAAD,YAAA,GAAAA,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,CAAC;AAAAN,OAAA,CAAAc,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"file":"constants.js","names":["matchCharset","exports","matchCharsetUtf8","concat","matchModeString","matchModeBinary","isTrue","value","test","isFalse","boolDefault","defaultBool","arguments","length","undefined","unquote","quote","substring","endsWith"],"sources":["../src/constants.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 const matchCharset = ';.*\bcharset\b=';\n\n/**\n * Does this content type say it's utf-8?\n * @type {string} Regular expression for matching charset=utf-8 in Content-Type\n */\nexport const matchCharsetUtf8 = `${matchCharset}.*\\\\butf-8\\\\b`;\n\n/**\n * Matching rules for string/text types. String matches must be checked *before* binary matches\n * @type {string} Regular expression for matching Content-Type headers\n */\nexport const matchModeString = `(^application\\\\/.*(\\\\bjson\\\\b|\\\\bxml\\\\b|\\\\bsql\\\\b|\\\\bgraphql\\\\b|\\\\bjavascript\\\\b|\\\\bx-www-form-urlencoded\\\\b)|^text\\\\/|.*\\\\+xml\\\\b|${matchCharset})`;\n\n/**\n * Matching rules for all binary or unknown types. Binary matches must be checked *after* string matches\n * @type {string} Regular expression for matching Content-Type headers\n */\nexport const matchModeBinary =\n '^image\\\\/|^audio\\\\/|^video\\\\/|^font\\\\/|^application\\\\/|^multipart\\\\/';\n\n/**\n * Does this string mean \"true\"\n * @param {string} value\n * @returns {boolean} true if matching a `true` value, false otherwise\n */\nexport const isTrue = (value: string) => /^(true|t|yes|y|1)$/i.test(value);\n\n/**\n * Does this string mean \"false\"\n * @param {string} value\n * @returns {boolean} true if matching a `false` value, false otherwise\n */\nexport const isFalse = (value: string) => /^(false|f|no|n|0)$/i.test(value);\n\n/**\n * Return true, false, or default boolean value for string representation of boolean\n * @param {string} value\n * @param {boolean} defaultBool is the value to return if the string doesn't match. defaults to false.\n * @returns {boolean} true or false\n */\nexport const boolDefault = (value: string, defaultBool = false) => {\n if (isTrue(value)) return true;\n if (isFalse(value)) return false;\n return defaultBool;\n};\n\n/**\n * strip surrounding quotes from a string if it is uniformly quoted\n * @param {string | null} value to unquote\n * @returns {string | null} unquoted string if it begins and ends with the same character out of `\\` \" '`\n */\nexport const unquote = (value: string | undefined | null): string => {\n if (!value) return '';\n if (/^['\"`]/.test(value)) {\n const quote = value.substring(0, 1);\n // Strip surrounding quotes?\n if (value.endsWith(quote)) return value.substring(1, value.length - 1);\n }\n return value;\n};\n\n/**\n * Documented type alias because URL assignment construction is not compatible with API parameters\n */\nexport type Url = string;\n\n/** Documented type to clarify SDK hash types */\nexport interface IDictionary<T> {\n [key: string]: T;\n}\n\n/**\n * Documented type alias for password spec\n */\nexport type Password = string;\n"],"mappings":";;;;;;AA0BO,IAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,eAAe;AAMpC,IAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,MAAAC,MAAA,CAAMH,YAAY,kBAAe;AAMvD,IAAMI,eAAe,GAAAH,OAAA,CAAAG,eAAA,yIAAAD,MAAA,CAAyIH,YAAY,MAAG;AAM7K,IAAMK,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAC1B,sEAAsE;AAOjE,IAAMC,MAAM,GAAIC,KAAa,IAAK,qBAAqB,CAACC,IAAI,CAACD,KAAK,CAAC;AAACN,OAAA,CAAAK,MAAA,GAAAA,MAAA;AAOpE,IAAMG,OAAO,GAAIF,KAAa,IAAK,qBAAqB,CAACC,IAAI,CAACD,KAAK,CAAC;AAACN,OAAA,CAAAQ,OAAA,GAAAA,OAAA;AAQrE,IAAMC,WAAW,GAAAT,OAAA,CAAAS,WAAA,GAAG,SAAdA,WAAWA,CAAIH,KAAa,EAA0B;EAAA,IAAxBI,WAAW,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAC5D,IAAIN,MAAM,CAACC,KAAK,CAAC,EAAE,OAAO,IAAI;EAC9B,IAAIE,OAAO,CAACF,KAAK,CAAC,EAAE,OAAO,KAAK;EAChC,OAAOI,WAAW;AACpB,CAAC;AAOM,IAAMI,OAAO,GAAIR,KAAgC,IAAa;EACnE,IAAI,CAACA,KAAK,EAAE,OAAO,EAAE;EACrB,IAAI,QAAQ,CAACC,IAAI,CAACD,KAAK,CAAC,EAAE;IACxB,IAAMS,KAAK,GAAGT,KAAK,CAACU,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAEnC,IAAIV,KAAK,CAACW,QAAQ,CAACF,KAAK,CAAC,EAAE,OAAOT,KAAK,CAACU,SAAS,CAAC,CAAC,EAAEV,KAAK,CAACM,MAAM,GAAG,CAAC,CAAC;EACxE;EACA,OAAON,KAAK;AACd,CAAC;AAACN,OAAA,CAAAc,OAAA,GAAAA,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"cryptoHash.js","names":[],"sources":["../src/cryptoHash.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 interface ICryptoHash {\n secureRandom(byte_count: number): string\n sha256Hash(message: string): Promise<string>\n}\n"],"mappings":""}
1
+ {"version":3,"file":"cryptoHash.js","names":[],"sources":["../src/cryptoHash.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 interface ICryptoHash {\n secureRandom(byte_count: number): string;\n sha256Hash(message: string): Promise<string>;\n}\n"],"mappings":""}
@@ -2,7 +2,7 @@ export declare class DelimArray<T> extends Array<T> {
2
2
  separator: string;
3
3
  prefix: string;
4
4
  suffix: string;
5
- constructor(items?: Array<T>, separator?: string, prefix?: string, suffix?: string);
5
+ constructor(items?: T[], separator?: string, prefix?: string, suffix?: string);
6
6
  static create<T>(): DelimArray<T>;
7
7
  toString: () => string;
8
8
  }
package/lib/delimArray.js CHANGED
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.DelimArray = void 0;
7
7
  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; }
8
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
9
- 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); }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  class DelimArray extends Array {
11
11
  constructor(items) {
12
12
  var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
@@ -1 +1 @@
1
- {"version":3,"file":"delimArray.js","names":["DelimArray","Array","constructor","items","separator","arguments","length","undefined","prefix","suffix","_defineProperty","concat","join","push","create","Object","prototype","exports"],"sources":["../src/delimArray.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 class DelimArray<T> extends Array<T> {\n constructor(\n items?: Array<T>,\n public separator: string = ',',\n public prefix: string = '',\n public suffix: string = ''\n ) {\n super()\n this.push(...(items || []))\n }\n\n static create<T>(): DelimArray<T> {\n return Object.create(DelimArray.prototype)\n }\n\n /**\n * Override of Array<T> toString so custom separators can be used\n * @returns {string} Delimited version of array\n */\n public toString = (): string => {\n return `${this.prefix}${this.join(this.separator)}${this.suffix}`\n }\n}\n"],"mappings":";;;;;;;;;AA0BO,MAAMA,UAAU,SAAYC,KAAK,CAAI;EAC1CC,WAAWA,CACTC,KAAgB,EAIhB;IAAA,IAHOC,SAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IACvBG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACnBI,MAAc,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAE1B,KAAK,EAAE;IAAA,KAJAD,SAAiB,GAAjBA,SAAiB;IAAA,KACjBI,MAAc,GAAdA,MAAc;IAAA,KACdC,MAAc,GAAdA,MAAc;IAAAC,eAAA,mBAcL,MAAc;MAC9B,UAAAC,MAAA,CAAU,IAAI,CAACH,MAAM,EAAAG,MAAA,CAAG,IAAI,CAACC,IAAI,CAAC,IAAI,CAACR,SAAS,CAAC,EAAAO,MAAA,CAAG,IAAI,CAACF,MAAM;IACjE,CAAC;IAbC,IAAI,CAACI,IAAI,CAAC,IAAIV,KAAK,IAAI,EAAE,CAAC,CAAC;EAC7B;EAEA,OAAOW,MAAMA,CAAA,EAAqB;IAChC,OAAOC,MAAM,CAACD,MAAM,CAACd,UAAU,CAACgB,SAAS,CAAC;EAC5C;AASF;AAACC,OAAA,CAAAjB,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"file":"delimArray.js","names":["DelimArray","Array","constructor","items","separator","arguments","length","undefined","prefix","suffix","_defineProperty","concat","join","push","create","Object","prototype","exports"],"sources":["../src/delimArray.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 class DelimArray<T> extends Array<T> {\n constructor(\n items?: T[],\n public separator: string = ',',\n public prefix: string = '',\n public suffix: string = ''\n ) {\n super();\n this.push(...(items || []));\n }\n\n static create<T>(): DelimArray<T> {\n return Object.create(DelimArray.prototype);\n }\n\n /**\n * Override of Array<T> toString so custom separators can be used\n * @returns {string} Delimited version of array\n */\n public toString = (): string => {\n return `${this.prefix}${this.join(this.separator)}${this.suffix}`;\n };\n}\n"],"mappings":";;;;;;;;;AA0BO,MAAMA,UAAU,SAAYC,KAAK,CAAI;EAC1CC,WAAWA,CACTC,KAAW,EAIX;IAAA,IAHOC,SAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;IAAA,IACvBG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACnBI,MAAc,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAE1B,KAAK,CAAC,CAAC;IAAC,KAJDD,SAAiB,GAAjBA,SAAiB;IAAA,KACjBI,MAAc,GAAdA,MAAc;IAAA,KACdC,MAAc,GAAdA,MAAc;IAAAC,eAAA,mBAcL,MAAc;MAC9B,UAAAC,MAAA,CAAU,IAAI,CAACH,MAAM,EAAAG,MAAA,CAAG,IAAI,CAACC,IAAI,CAAC,IAAI,CAACR,SAAS,CAAC,EAAAO,MAAA,CAAG,IAAI,CAACF,MAAM;IACjE,CAAC;IAbC,IAAI,CAACI,IAAI,CAAC,IAAIV,KAAK,IAAI,EAAE,CAAC,CAAC;EAC7B;EAEA,OAAOW,MAAMA,CAAA,EAAqB;IAChC,OAAOC,MAAM,CAACD,MAAM,CAACd,UAAU,CAACgB,SAAS,CAAC;EAC5C;AASF;AAACC,OAAA,CAAAjB,UAAA,GAAAA,UAAA"}
package/lib/errorDoc.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { IAPIMethods } from './apiMethods';
1
+ import type { IAPIMethods } from './transport';
2
2
  export interface IErrorDocItem {
3
3
  url: string;
4
4
  }
5
5
  export declare const ErrorCodesUrl = "https://static-a.cdn.looker.app/errorcodes/";
6
- export declare type ErrorCodeIndex = Record<string, IErrorDocItem>;
6
+ export type ErrorCodeIndex = Record<string, IErrorDocItem>;
7
7
  export declare const ErrorDocNotFound = "### No documentation found for ";
8
8
  export declare const ErrorDocRx: RegExp;
9
9
  export interface IErrorDocLink {
@@ -24,7 +24,7 @@ export interface IErrorDoc {
24
24
  load(): Promise<ErrorCodeIndex>;
25
25
  methodName(errorMdUrl: string): string;
26
26
  }
27
- export declare type SDKGetCallback = (sdk: IAPIMethods, url: string) => Promise<string>;
27
+ export type SDKGetCallback = (sdk: IAPIMethods, url: string) => Promise<string>;
28
28
  export declare class ErrorDoc implements IErrorDoc {
29
29
  sdk: IAPIMethods;
30
30
  getter: SDKGetCallback;
package/lib/errorDoc.js CHANGED
@@ -6,22 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ErrorDocRx = exports.ErrorDocNotFound = exports.ErrorDoc = exports.ErrorCodesUrl = void 0;
7
7
  var _transport = require("./transport");
8
8
  var _templateObject;
9
- function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
9
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = new RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
10
10
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
11
11
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
12
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
15
  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); } }
16
16
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
17
17
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
- var ErrorCodesUrl = 'https://static-a.cdn.looker.app/errorcodes/';
19
- exports.ErrorCodesUrl = ErrorCodesUrl;
20
- var ErrorDocNotFound = '### No documentation found for ';
21
- exports.ErrorDocNotFound = ErrorDocNotFound;
18
+ var ErrorCodesUrl = exports.ErrorCodesUrl = 'https://static-a.cdn.looker.app/errorcodes/';
19
+ var ErrorDocNotFound = exports.ErrorDocNotFound = '### No documentation found for ';
22
20
  var ErrorDocPatternExpression = String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["(?<redirector>(https://docs.looker.com/r|https://cloud.google.com/looker/docs/r)?/err/)(?<apiVersion>.*)/(?<statusCode>d{3})(?<apiPath>.*)"], ["(?<redirector>(https:\\/\\/docs\\.looker\\.com\\/r|https:\\/\\/cloud\\.google\\.com\\/looker\\/docs\\/r)?\\/err\\/)(?<apiVersion>.*)\\/(?<statusCode>\\d{3})(?<apiPath>.*)"])));
23
- var ErrorDocRx = RegExp(ErrorDocPatternExpression, 'i');
24
- exports.ErrorDocRx = ErrorDocRx;
21
+ var ErrorDocRx = exports.ErrorDocRx = RegExp(ErrorDocPatternExpression, 'i');
25
22
  var sdkUrlGet = function () {
26
23
  var _ref = _asyncToGenerator(function* (sdk, url) {
27
24
  return yield (0, _transport.sdkOk)(sdk.authSession.transport.request('GET', url));
@@ -66,7 +63,7 @@ class ErrorDoc {
66
63
  return this._index;
67
64
  }
68
65
  specPath(path) {
69
- var result = path.replace(/:\w+/g, found => "{".concat(found.substr(1), "}"));
66
+ var result = path.replace(/:\w+/g, found => "{".concat(found.substring(1), "}"));
70
67
  return result;
71
68
  }
72
69
  errorKey(docUrl) {