@looker/sdk-rtl 21.3.4 → 21.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,161 @@
1
+ var _templateObject;
2
+
3
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); _groups.set(_this, groups || _groups.get(re)); return _setPrototypeOf(_this, BabelRegExp.prototype); } _inherits(BabelRegExp, RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; if (typeof args[args.length - 1] !== "object") { args = [].slice.call(args); args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
4
+
5
+ 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
+
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+
9
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+
11
+ 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); } }
12
+
13
+ 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); }); }; }
14
+
15
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
16
+
17
+ import { sdkOk } from './transport';
18
+ export var ErrorCodesUrl = 'https://marketplace-api.looker.com/errorcodes/';
19
+ export var ErrorDocNotFound = '### No documentation found for ';
20
+ var ErrorDocPatternExpression = String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["(?<redirector>(https://docs.looker.com/r)?/err/)(?<apiVersion>.*)/(?<statusCode>d{3})(?<apiPath>.*)"], ["(?<redirector>(https:\\/\\/docs\\.looker\\.com\\/r)?\\/err\\/)(?<apiVersion>.*)\\/(?<statusCode>\\d{3})(?<apiPath>.*)"])));
21
+ export var ErrorDocRx = RegExp(ErrorDocPatternExpression, 'i');
22
+
23
+ var sdkUrlGet = function () {
24
+ var _ref = _asyncToGenerator(function* (sdk, url) {
25
+ return yield sdkOk(sdk.authSession.transport.request('GET', url));
26
+ });
27
+
28
+ return function sdkUrlGet(_x, _x2) {
29
+ return _ref.apply(this, arguments);
30
+ };
31
+ }();
32
+
33
+ export class ErrorDoc {
34
+ constructor(sdk) {
35
+ var getter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : sdkUrlGet;
36
+ var cdnUrl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ErrorCodesUrl;
37
+ this.sdk = sdk;
38
+ this.getter = getter;
39
+ this.cdnUrl = cdnUrl;
40
+
41
+ _defineProperty(this, "_index", undefined);
42
+ }
43
+
44
+ load() {
45
+ var _this = this;
46
+
47
+ return _asyncToGenerator(function* () {
48
+ if (!_this._index) {
49
+ try {
50
+ var result = yield _this.getter(_this.sdk, _this.indexUrl);
51
+
52
+ if (typeof result === 'string') {
53
+ result = JSON.parse(result);
54
+ }
55
+
56
+ _this._index = result;
57
+ } catch (e) {
58
+ return Promise.resolve({});
59
+ }
60
+ }
61
+
62
+ return _this._index;
63
+ })();
64
+ }
65
+
66
+ get indexUrl() {
67
+ return this.contentUrl('index.json');
68
+ }
69
+
70
+ get index() {
71
+ if (!this._index) {
72
+ this.load().catch(reason => console.error(reason));
73
+ }
74
+
75
+ return this._index;
76
+ }
77
+
78
+ specPath(path) {
79
+ var result = path.replace(/:\w+/g, found => "{".concat(found.substr(1), "}"));
80
+ return result;
81
+ }
82
+
83
+ errorKey(docUrl) {
84
+ var bits = this.parse(docUrl);
85
+ if (!bits.redirector) return '';
86
+ return this.specPath("".concat(bits.statusCode).concat(bits.apiPath));
87
+ }
88
+
89
+ notFound(key) {
90
+ return "".concat(ErrorDocNotFound).concat(key);
91
+ }
92
+
93
+ getContent(url) {
94
+ var _this2 = this;
95
+
96
+ return _asyncToGenerator(function* () {
97
+ try {
98
+ return yield _this2.getter(_this2.sdk, url);
99
+ } catch (e) {
100
+ return Promise.resolve(_this2.notFound(e.message));
101
+ }
102
+ })();
103
+ }
104
+
105
+ content(docUrl) {
106
+ var _this3 = this;
107
+
108
+ return _asyncToGenerator(function* () {
109
+ var key = _this3.errorKey(docUrl);
110
+
111
+ if (!key) {
112
+ return Promise.resolve(_this3.notFound('bad error code link'));
113
+ }
114
+
115
+ yield _this3.load();
116
+ var item = _this3.index ? _this3.index[key] : undefined;
117
+
118
+ if (!item) {
119
+ var code = key.split('/')[0];
120
+ item = _this3.index ? _this3.index[code] : undefined;
121
+
122
+ if (!item) {
123
+ return Promise.resolve(_this3.notFound(key));
124
+ }
125
+ }
126
+
127
+ var url = _this3.contentUrl(item.url);
128
+
129
+ return yield _this3.getContent(url);
130
+ })();
131
+ }
132
+
133
+ contentUrl(urlPath) {
134
+ return "".concat(this.cdnUrl).concat(urlPath);
135
+ }
136
+
137
+ methodName(errorMdUrl) {
138
+ var _match$groups;
139
+
140
+ var ErrorMdRx = _wrapRegExp(/([0-9A-Z_a-z]+)_[0-9]{3}\.md/i, {
141
+ name: 1
142
+ });
143
+
144
+ var match = errorMdUrl.match(ErrorMdRx);
145
+ return (match === null || match === void 0 ? void 0 : (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.name) || '';
146
+ }
147
+
148
+ parse(docUrl) {
149
+ var _match$groups2, _match$groups3, _match$groups4, _match$groups5;
150
+
151
+ var match = docUrl.match(ErrorDocRx);
152
+ return {
153
+ redirector: (match === null || match === void 0 ? void 0 : (_match$groups2 = match.groups) === null || _match$groups2 === void 0 ? void 0 : _match$groups2.redirector) || '',
154
+ apiVersion: (match === null || match === void 0 ? void 0 : (_match$groups3 = match.groups) === null || _match$groups3 === void 0 ? void 0 : _match$groups3.apiVersion) || '',
155
+ statusCode: (match === null || match === void 0 ? void 0 : (_match$groups4 = match.groups) === null || _match$groups4 === void 0 ? void 0 : _match$groups4.statusCode) || '',
156
+ apiPath: (match === null || match === void 0 ? void 0 : (_match$groups5 = match.groups) === null || _match$groups5 === void 0 ? void 0 : _match$groups5.apiPath) || ''
157
+ };
158
+ }
159
+
160
+ }
161
+ //# sourceMappingURL=errorDoc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/errorDoc.ts"],"names":["sdkOk","ErrorCodesUrl","ErrorDocNotFound","ErrorDocPatternExpression","String","raw","ErrorDocRx","RegExp","sdkUrlGet","sdk","url","authSession","transport","request","ErrorDoc","constructor","getter","cdnUrl","undefined","load","_index","result","indexUrl","JSON","parse","e","Promise","resolve","contentUrl","index","catch","reason","console","error","specPath","path","replace","found","substr","errorKey","docUrl","bits","redirector","statusCode","apiPath","notFound","key","getContent","message","content","item","code","split","urlPath","methodName","errorMdUrl","ErrorMdRx","match","groups","name","apiVersion"],"mappings":";;;;;;;;;;;;;;;;AA2BA,SAASA,KAAT,QAAsB,aAAtB;AAQA,OAAO,IAAMC,aAAa,GAAG,gDAAtB;AAMP,OAAO,IAAMC,gBAAgB,GAAG,iCAAzB;AAGP,IAAMC,yBAAyB,GAAGC,MAAM,CAACC,GAAV,mSAA/B;AACA,OAAO,IAAMC,UAAU,GAAGC,MAAM,CAACJ,yBAAD,EAA4B,GAA5B,CAAzB;;AAmFP,IAAMK,SAAS;AAAA,+BAAG,WAAOC,GAAP,EAAyBC,GAAzB,EAAyC;AACzD,iBAAaV,KAAK,CAChBS,GAAG,CAACE,WAAJ,CAAgBC,SAAhB,CAA0BC,OAA1B,CAAiD,KAAjD,EAAwDH,GAAxD,CADgB,CAAlB;AAGD,GAJc;;AAAA,kBAATF,SAAS;AAAA;AAAA;AAAA,GAAf;;AAMA,OAAO,MAAMM,QAAN,CAAoC;AAEzCC,EAAAA,WAAW,CACFN,GADE,EAIT;AAAA,QAFOO,MAEP,uEAFgCR,SAEhC;AAAA,QADgBS,MAChB,uEADiChB,aACjC;AAAA,SAHOQ,GAGP,GAHOA,GAGP;AAAA,SAFOO,MAEP,GAFOA,MAEP;AAAA,SADgBC,MAChB,GADgBA,MAChB;;AAAA,oCALgCC,SAKhC;AAAE;;AAESC,EAAAA,IAAI,GAA4B;AAAA;;AAAA;AAC3C,UAAI,CAAC,KAAI,CAACC,MAAV,EAAkB;AAChB,YAAI;AACF,cAAIC,MAAM,SAAS,KAAI,CAACL,MAAL,CAAY,KAAI,CAACP,GAAjB,EAAsB,KAAI,CAACa,QAA3B,CAAnB;;AACA,cAAI,OAAOD,MAAP,KAAkB,QAAtB,EAAgC;AAC9BA,YAAAA,MAAM,GAAGE,IAAI,CAACC,KAAL,CAAWH,MAAX,CAAT;AACD;;AACD,UAAA,KAAI,CAACD,MAAL,G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P,gEAAeC,IAAf,KAAuB,EAA9B;AACD;;AAEDnC,EAAAA,KAAK,CAACgB,MAAD,EAAgC;AAAA;;AACnC,QAAMiB,KAAK,GAAGjB,MAAM,CAACiB,KAAP,CAAanD,UAAb,CAAd;AACA,WAAO;AACLoC,MAAAA,UAAU,EAAE,CAAAe,KAAK,SAAL,IAAAA,KAAK,WAAL,8BAAAA,KAAK,CAAEC,MAAP,kEAAehB,UAAf,KAA6B,EADpC;AAELkB,MAAAA,UAAU,EAAE,CAAAH,KAAK,SAAL,IAAAA,KAAK,WAAL,8BAAAA,KAAK,CAAEC,MAAP,kEAAeE,UAAf,KAA6B,EAFpC;AAGLjB,MAAAA,UAAU,EAAE,CAAAc,KAAK,SAAL,IAAAA,KAAK,WAAL,8BAAAA,KAAK,CAAEC,MAAP,kEAAef,UAAf,KAA6B,EAHpC;AAILC,MAAAA,OAAO,EAAE,CAAAa,KAAK,SAAL,IAAAA,KAAK,WAAL,8BAAAA,KAAK,CAAEC,MAAP,kEAAed,OAAf,KAA0B;AAJ9B,KAAP;AAMD;;AA9FwC","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 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 { IAPIMethods } from './apiMethods'\nimport { sdkOk } from './transport'\n\nexport interface IErrorDocItem {\n /** relative path of mark down document */\n url: string\n}\n\n/** Location of the public CDN for Looker API Error codes */\nexport const ErrorCodesUrl = 'https://marketplace-api.looker.com/errorcodes/'\n\n/** Structure of the error code document index */\nexport type ErrorCodeIndex = Record<string, IErrorDocItem>\n\n/** Default \"not found\" content for error documents that don't (yet) exist */\nexport const ErrorDocNotFound = '### No documentation found for '\n\n/** API error document_url link pattern */\nconst ErrorDocPatternExpression = String.raw`(?<redirector>(https:\\/\\/docs\\.looker\\.com\\/r)?\\/err\\/)(?<apiVersion>.*)\\/(?<statusCode>\\d{3})(?<apiPath>.*)`\nexport const ErrorDocRx = RegExp(ErrorDocPatternExpression, 'i')\n\nexport interface IErrorDocLink {\n /** base redirector url */\n redirector: string\n /** api version of the error link */\n apiVersion: string\n /** HTTP status code */\n statusCode: string\n /** REST API Path */\n apiPath: string\n}\n\nexport interface IErrorDoc {\n /** Index of all know error codes. Call load() to populate it */\n index?: ErrorCodeIndex\n\n /** Url of API error document index */\n indexUrl: string\n\n /**\n * Extract error url into its parts\n * @param docUrl value of documentation_url from error payload\n */\n parse(docUrl: string): IErrorDocLink\n\n /**\n * full url to resolve error document\n * @param urlPath resolved index item (used by content())\n */\n contentUrl(urlPath: string): string\n\n /**\n * fetch content from the URL, returning a \"not found\" response if it fails\n * @param url to fetch\n */\n getContent(url: string): Promise<string>\n\n /**\n * Returns the markdown of the error document\n *\n * Some kind of content is always returned from this method. The content is\n * one of:\n * - the specific document for the method and error code\n * - a generic document for the error code\n * - a \"not found\" mark down if the specific and generic are not defined\n *\n * @param docUrl value of documentation_url from error payload\n */\n content(docUrl: string): Promise<string>\n\n /**\n * Ensure API request path matches the OpenAPI path pattern\n *\n * @example\n * `/entity/:id/part/:part` should be `/entity/{id}/part/{part}`\n *\n * @param path to convert to a spec path\n */\n specPath(path: string): string\n\n /**\n * get the lookup key for the documentation_url\n * @param docUrl value of documentation_url from error payload\n */\n errorKey(docUrl: string): string\n\n /** Fetch and parse the error codes documentation index from the CDN */\n load(): Promise<ErrorCodeIndex>\n\n /**\n * get the name of the method from the error doc url\n * @param errorMdUrl url for the error document\n */\n methodName(errorMdUrl: string): string\n}\n\nexport type SDKGetCallback = (sdk: IAPIMethods, url: string) => Promise<string>\n/**\n * Default fetcher using the SDK\n * @param url to get\n * @private\n */\nconst sdkUrlGet = async (sdk: IAPIMethods, url: string) => {\n return await sdkOk(\n sdk.authSession.transport.request<string, Error>('GET', url)\n )\n}\n\nexport class ErrorDoc implements IErrorDoc {\n private _index?: ErrorCodeIndex = undefined\n constructor(\n public sdk: IAPIMethods,\n public getter: SDKGetCallback = sdkUrlGet,\n public readonly cdnUrl: string = ErrorCodesUrl\n ) {}\n\n public async load(): Promise<ErrorCodeIndex> {\n if (!this._index) {\n try {\n let result = await this.getter(this.sdk, this.indexUrl)\n if (typeof result === 'string') {\n result = JSON.parse(result)\n }\n this._index = result as unknown as ErrorCodeIndex\n } catch (e: any) {\n return Promise.resolve({})\n }\n }\n return this._index\n }\n\n public get indexUrl() {\n return this.contentUrl('index.json')\n }\n\n public get index() {\n if (!this._index) {\n this.load().catch((reason) => console.error(reason))\n }\n return this._index\n }\n\n specPath(path: string): string {\n const result = path.replace(/:\\w+/g, (found) => `{${found.substr(1)}}`)\n return result\n }\n\n errorKey(docUrl: string): string {\n const bits = this.parse(docUrl)\n if (!bits.redirector) return ''\n return this.specPath(`${bits.statusCode}${bits.apiPath}`)\n }\n\n private notFound(key: string): string {\n return `${ErrorDocNotFound}${key}`\n }\n\n async getContent(url: string): Promise<string> {\n try {\n return await this.getter(this.sdk, url)\n } catch (e: any) {\n return Promise.resolve(this.notFound(e.message))\n }\n }\n\n async content(docUrl: string): Promise<string> {\n const key = this.errorKey(docUrl)\n if (!key) {\n return Promise.resolve(this.notFound('bad error code link'))\n }\n await this.load()\n let item = this.index ? this.index[key] : undefined\n if (!item) {\n // fallback to generic error document\n const code = key.split('/')[0]\n item = this.index ? this.index[code] : undefined\n if (!item) {\n return Promise.resolve(this.notFound(key))\n }\n }\n const url = this.contentUrl(item.url)\n return await this.getContent(url)\n }\n\n contentUrl(urlPath: string): string {\n return `${this.cdnUrl}${urlPath}`\n }\n\n methodName(errorMdUrl: string): string {\n const ErrorMdRx = /(?<name>\\w+)_\\d{3}\\.md/i\n const match = errorMdUrl.match(ErrorMdRx)\n return match?.groups?.name || ''\n }\n\n parse(docUrl: string): IErrorDocLink {\n const match = docUrl.match(ErrorDocRx)\n return {\n redirector: match?.groups?.redirector || '',\n apiVersion: match?.groups?.apiVersion || '',\n statusCode: match?.groups?.statusCode || '',\n apiPath: match?.groups?.apiPath || '',\n }\n }\n}\n"],"file":"errorDoc.js"}
package/lib/esm/index.js CHANGED
@@ -10,8 +10,10 @@ export * from './constants';
10
10
  export * from './cryptoHash';
11
11
  export * from './CSRFSession';
12
12
  export * from './delimArray';
13
+ export * from './errorDoc';
13
14
  export * from './extensionSession';
14
15
  export * from './extensionTransport';
16
+ export * from './lookerSDKError';
15
17
  export * from './oauthSession';
16
18
  export * from './paging';
17
19
  export * from './platformServices';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AA0BA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,aAAd;AACA,cAAc,iBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,oBAAd;AACA,cAAc,sBAAd;AACA,cAAc,gBAAd;AACA,cAAc,UAAd;AACA,cAAc,oBAAd;AACA,cAAc,gBAAd;AACA,cAAc,aAAd","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 './apiMethods'\nexport * from './apiSettings'\nexport * from './authSession'\nexport * from './authToken'\nexport * from './baseTransport'\nexport * from './browserSession'\nexport * from './browserServices'\nexport * from './browserTransport'\nexport * from './constants'\nexport * from './cryptoHash'\nexport * from './CSRFSession'\nexport * from './delimArray'\nexport * from './extensionSession'\nexport * from './extensionTransport'\nexport * from './oauthSession'\nexport * from './paging'\nexport * from './platformServices'\nexport * from './proxySession'\nexport * from './transport'\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AA0BA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,aAAd;AACA,cAAc,iBAAd;AACA,cAAc,kBAAd;AACA,cAAc,mBAAd;AACA,cAAc,oBAAd;AACA,cAAc,aAAd;AACA,cAAc,cAAd;AACA,cAAc,eAAd;AACA,cAAc,cAAd;AACA,cAAc,YAAd;AACA,cAAc,oBAAd;AACA,cAAc,sBAAd;AACA,cAAc,kBAAd;AACA,cAAc,gBAAd;AACA,cAAc,UAAd;AACA,cAAc,oBAAd;AACA,cAAc,gBAAd;AACA,cAAc,aAAd","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 './apiMethods'\nexport * from './apiSettings'\nexport * from './authSession'\nexport * from './authToken'\nexport * from './baseTransport'\nexport * from './browserSession'\nexport * from './browserServices'\nexport * from './browserTransport'\nexport * from './constants'\nexport * from './cryptoHash'\nexport * from './CSRFSession'\nexport * from './delimArray'\nexport * from './errorDoc'\nexport * from './extensionSession'\nexport * from './extensionTransport'\nexport * from './lookerSDKError'\nexport * from './oauthSession'\nexport * from './paging'\nexport * from './platformServices'\nexport * from './proxySession'\nexport * from './transport'\n"],"file":"index.js"}
@@ -0,0 +1,52 @@
1
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
2
+
3
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
+
5
+ export var LookerSDKError = (() => {
6
+ 'use strict';
7
+
8
+ var LookerSDKErrorConstructor = function LookerSDKError() {
9
+ var _errors, _documentation_url;
10
+
11
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
12
+ _ref[_key] = arguments[_key];
13
+ }
14
+
15
+ var [message, _ref2 = {}, ...rest] = _ref;
16
+
17
+ var {
18
+ errors,
19
+ documentation_url
20
+ } = _ref2,
21
+ errorOptions = _objectWithoutProperties(_ref2, ["errors", "documentation_url"]);
22
+
23
+ (_errors = errors) !== null && _errors !== void 0 ? _errors : errors = [];
24
+ (_documentation_url = documentation_url) !== null && _documentation_url !== void 0 ? _documentation_url : documentation_url = '';
25
+ var error = this ? new Error(message, errorOptions, ...rest) : Error(message, errorOptions, ...rest);
26
+ Object.setPrototypeOf(error, this ? Object.getPrototypeOf(this) : LookerSDKError.prototype);
27
+ Object.defineProperty(error, 'message', {
28
+ enumerable: true
29
+ });
30
+ error.errors = errors;
31
+ error.documentation_url = documentation_url;
32
+ return error;
33
+ };
34
+
35
+ Object.defineProperty(LookerSDKErrorConstructor, 'prototype', {
36
+ value: Object.create(Error.prototype, {
37
+ constructor: {
38
+ value: LookerSDKErrorConstructor,
39
+ writable: true,
40
+ configurable: true
41
+ },
42
+ name: {
43
+ value: 'LookerSDKError',
44
+ writable: true,
45
+ configurable: true
46
+ }
47
+ }),
48
+ writable: false
49
+ });
50
+ return LookerSDKErrorConstructor;
51
+ })();
52
+ //# sourceMappingURL=lookerSDKError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lookerSDKError.ts"],"names":["LookerSDKError","LookerSDKErrorConstructor","message","rest","errors","documentation_url","errorOptions","error","Error","Object","setPrototypeOf","getPrototypeOf","prototype","defineProperty","enumerable","value","create","constructor","writable","configurable","name"],"mappings":";;;;AAiFA,OAAO,IAAMA,cAA0C,GACtC,CAAC,MAAM;AACpB;;AACA,MAAMC,yBAAyB,GAAG,SAASD,cAAT,GAkBhC;AAAA;;AAAA;AAAA;AAAA;;AAAA,QAhBG,CACDE,OADC,EAED,QAII,EANH,EAOD,GAAGC,IAPF,CAgBH;;AAAA,QAdE;AACEC,MAAAA,MADF;AAEEC,MAAAA;AAFF,KAcF;AAAA,QAXOC,YAWP;;AAEA,eAAAF,MAAM,UAAN,mCAAAA,MAAM,GAAK,EAAX;AACA,0BAAAC,iBAAiB,UAAjB,yDAAAA,iBAAiB,GAAK,EAAtB;AAKA,QAAME,KAAK,GAAG,OACV,IAAIC,KAAJ,CACEN,OADF,EAKEI,YALF,EAME,GAAGH,IANL,CADU,GASVK,KAAK,CACHN,OADG,EAGHI,YAHG,EAIH,GAAGH,IAJA,CATT;AAoBAM,IAAAA,MAAM,CAACC,cAAP,CACEH,KADF,EAEE,OAAOE,MAAM,CAACE,cAAP,CAAsB,IAAtB,CAAP,GAAqCX,cAAc,CAACY,SAFtD;AASAH,IAAAA,MAAM,CAACI,cAAP,CAAsBN,KAAtB,EAA6B,SAA7B,EAAwC;AAAEO,MAAAA,UAAU,EAAE;AAAd,KAAxC;AACEP,IAAAA,KAAD,CAA0BH,MAA1B,GAAmCA,MAAnC;AACCG,IAAAA,KAAD,CAA0BF,iBAA1B,GAA8CA,iBAA9C;AAED,WAAOE,KAAP;AACD,GA5DD;;AAuEAE,EAAAA,MAAM,CAACI,cAAP,CACEZ,yBADF,EAEE,WAFF,EAOE;AACEc,IAAAA,KAAK,EAAEN,MAAM,CAACO,MAAP,CAAcR,KAAK,CAACI,SAApB,EAA+B;AACpCK,MAAAA,WAAW,EAAE;AACXF,QAAAA,KAAK,EAAEd,yBADI;AAEXiB,QAAAA,QAAQ,EAAE,IAFC;AAGXC,QAAAA,YAAY,EAAE;AAHH,OADuB;AAMpCC,MAAAA,IAAI,EAAE;AACJL,QAAAA,KAAK,EAAE,gBADH;AAEJG,QAAAA,QAAQ,EAAE,IAFN;AAGJC,QAAAA,YAAY,EAAE;AAHV;AAN8B,KAA/B,CADT;AAiBED,IAAAA,QAAQ,EAAE;AAjBZ,GAPF;AA4BA,SAAOjB,yBAAP;AACD,CAtGc,GADV","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2022 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\n/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-redeclare */\n\n// Defensive type-level programming to guard against additional\n// parameters being added to Error, as happened in lib.es2022.error.d.ts\n// (which introduced the errorOptions argument)\ntype AugmentErrorOptions<\n ErrorParameters extends unknown[],\n AdditionalErrorOptions\n> = ErrorParameters extends [(infer Message)?]\n ? [Message?, AdditionalErrorOptions?]\n : ErrorParameters extends [(infer Message)?, (infer ErrorOptions)?]\n ? [Message?, (ErrorOptions & AdditionalErrorOptions)?]\n : ErrorParameters extends [\n (infer Message)?,\n (infer ErrorOptions)?,\n ...infer Rest\n ]\n ? [Message?, (ErrorOptions & AdditionalErrorOptions)?, ...Rest]\n : never\n\ninterface IErrorDetail {\n field?: string\n code?: string\n message?: string\n documentation_url: string\n}\n\n// This specifies SDK custom error options\ninterface ILookerSDKErrorOptions {\n errors?: IErrorDetail[]\n documentation_url?: string | null\n}\n\ninterface ILookerSDKErrorConstructor {\n new (\n ...args: AugmentErrorOptions<\n ConstructorParameters<ErrorConstructor>,\n ILookerSDKErrorOptions\n >\n ): LookerSDKError\n (\n ...args: AugmentErrorOptions<\n Parameters<ErrorConstructor>,\n ILookerSDKErrorOptions\n >\n ): LookerSDKError\n}\n\n// The subclass and function expression's name should match, so that stack traces look clean.\n// We bind it to a local identifier for clarity, and to perform a type assertion.\nexport interface LookerSDKError extends Error {\n errors?: IErrorDetail[]\n documentation_url?: string | null\n}\n\nexport const LookerSDKError: ILookerSDKErrorConstructor =\n /* #__PURE__*/ (() => {\n 'use strict'\n const LookerSDKErrorConstructor = function LookerSDKError(\n this: LookerSDKError | undefined,\n ...[\n message,\n {\n errors,\n documentation_url,\n ...errorOptions\n } = {} as ILookerSDKErrorOptions,\n ...rest\n ]: AugmentErrorOptions<\n ConstructorParameters<ErrorConstructor>,\n ILookerSDKErrorOptions\n > &\n AugmentErrorOptions<\n Parameters<ErrorConstructor>,\n ILookerSDKErrorOptions\n >\n ) {\n // handle null in addition to undefined\n errors ??= []\n documentation_url ??= ''\n\n // The `super()` call. At present, Error() and new Error() are\n // indistinguishable, but use whatever we were invoked with in case\n // that ever changes.\n const error = this\n ? new Error(\n message,\n // we have to suppress a type error here if TypeScript\n // doesn't know es2022's two-argument Error constructor\n // @ts-ignore-error\n errorOptions,\n ...rest\n )\n : Error(\n message,\n // @ts-ignore-error\n errorOptions,\n ...rest\n )\n\n // Object.setPrototypeOf() is necessary when extending built-ins,\n // since Error.call(this, message, errorOptions, ...rest) doesn't\n // set up the prototype chain the way it would with a user-defined\n // class.\n Object.setPrototypeOf(\n error,\n this ? Object.getPrototypeOf(this) : LookerSDKError.prototype\n )\n\n // Normally the 'message' property of JavaScript Error objects is non-enumerable\n // set it to be enumerable for consistency with our non-error responses,\n // which are implemented as plain JavaScript objects where all\n // properties are enumerable.\n Object.defineProperty(error, 'message', { enumerable: true })\n ;(error as LookerSDKError).errors = errors\n ;(error as LookerSDKError).documentation_url = documentation_url\n\n return error\n } as ILookerSDKErrorConstructor\n\n // LookerSDKError.prototype, LookerSDKError.prototype.constructor, and\n // LookerSDKError.prototoype.name all have to be non-enumerable to match\n // the built-in RangeError, TypeError, etc., so we use\n // Object.defineProperty to set them instead of `=` assignment.\n\n // Default values for property descriptor objects:\n // writable: false\n // enumerable: false\n // configurable: false\n Object.defineProperty(\n LookerSDKErrorConstructor,\n 'prototype',\n // It's a weird wart that the built-in Error constructor\n // prototypes have writable and configurable constructor and name\n // fields. We follow that behavior to be consistent, not because\n // it makes sense.\n {\n value: Object.create(Error.prototype, {\n constructor: {\n value: LookerSDKErrorConstructor,\n writable: true,\n configurable: true,\n },\n name: {\n value: 'LookerSDKError',\n writable: true,\n configurable: true,\n },\n }),\n // SomeConstructorFunction.prototype starts off writable with\n // `function`-type constructors, in contrast to `class SomeClass`.\n // Set this to be non-writable to match `class`es and the built-in\n // Error constructors.\n writable: false,\n }\n )\n\n return LookerSDKErrorConstructor\n })()\n"],"file":"lookerSDKError.js"}
@@ -4,6 +4,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4
4
 
5
5
  import { matchCharsetUtf8, matchModeBinary, matchModeString } from './constants';
6
6
  import { DelimArray } from './delimArray';
7
+ import { LookerSDKError } from './lookerSDKError';
7
8
  export var agentPrefix = 'TS-SDK';
8
9
  export var LookerAppId = 'x-looker-appid';
9
10
  var tracing = false;
@@ -171,40 +172,43 @@ function bufferString(val) {
171
172
 
172
173
  export function sdkError(response) {
173
174
  if (typeof response === 'string') {
174
- return new Error(response);
175
+ return new LookerSDKError(response);
175
176
  }
176
177
 
177
178
  if ('error' in response) {
178
179
  var _error = response.error;
179
180
 
180
181
  if (typeof _error === 'string') {
181
- return new Error(_error);
182
+ return new LookerSDKError(_error);
182
183
  }
183
184
 
184
185
  if ('error' in _error) {
185
186
  var _result = bufferString(_error.error);
186
187
 
187
- return new Error(_result);
188
+ return new LookerSDKError(_result);
188
189
  }
189
190
 
190
191
  if ('message' in _error) {
191
- return new Error(response.error.message.toString());
192
+ return new LookerSDKError(response.error.message.toString(), {
193
+ errors: _error.errors,
194
+ documentation_url: _error.documentation_url
195
+ });
192
196
  }
193
197
 
194
198
  if ('statusMessage' in _error) {
195
- return new Error(_error.statusMessage);
199
+ return new LookerSDKError(_error.statusMessage);
196
200
  }
197
201
 
198
202
  var result = bufferString(_error);
199
- return new Error(result);
203
+ return new LookerSDKError(result);
200
204
  }
201
205
 
202
206
  if ('message' in response) {
203
- return new Error(response.message);
207
+ return new LookerSDKError(response.message);
204
208
  }
205
209
 
206
210
  var error = JSON.stringify(response);
207
- return new Error("Unknown error with SDK method ".concat(error));
211
+ return new LookerSDKError("Unknown error with SDK method ".concat(error));
208
212
  }
209
213
  export function sdkOk(_x) {
210
214
  return _sdkOk.apply(this, arguments);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/transport.ts"],"names":["matchCharsetUtf8","matchModeBinary","matchModeString","DelimArray","agentPrefix","LookerAppId","tracing","trace","message","info","console","debug","ResponseMode","contentPatternString","RegExp","contentPatternBinary","charsetUtf8Pattern","defaultTimeout","StatusCode","responseMode","contentType","match","string","binary","unknown","isUtf8","encodeParam","value","Date","toISOString","toString","encoded","JSON","stringify","decoded","decodeURIComponent","encodeURIComponent","e","URIError","encodeParams","values","keys","Object","filter","k","undefined","map","join","addQueryParams","path","obj","qp","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","err","sdkError","response","Error","error","statusMessage","sdkOk","promise","ok","safeBase64","u8","rawBase64","btoa","String","fromCharCode","replace","isErrorLike","prototype","hasOwnProperty","call"],"mappings":";;;;AA6BA,SAASA,gBAAT,EAA2BC,eAA3B,EAA4CC,eAA5C,QAAmE,aAAnE;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA,OAAO,IAAMC,WAAW,GAAG,QAApB;AACP,OAAO,IAAMC,WAAW,GAAG,gBAApB;AAGP,IAAMC,OAAO,GAAG,KAAhB;AAOA,OAAO,SAASC,KAAT,CAAeC,OAAf,EAAgCC,IAAhC,EAA4C;AACjD,MAAIH,OAAJ,EAAa;AAEXI,IAAAA,OAAO,CAACC,KAAR,CAAcH,OAAd;;AACA,QAAIC,IAAJ,EAAU;AAERC,MAAAA,OAAO,CAACC,KAAR,CAAc;AAAEF,QAAAA;AAAF,OAAd;AACD;AACF;AACF;AAGD,WAAYG,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;AAAAA,EAAAA,Y,CAAAA,Y;GAAAA,Y,KAAAA,Y;;AAUZ,OAAO,IAAMC,oBAAoB,GAAG,IAAIC,MAAJ,CAAWZ,eAAX,EAA4B,GAA5B,CAA7B;AAMP,OAAO,IAAMa,oBAAoB,GAAG,IAAID,MAAJ,CAAWb,eAAX,EAA4B,GAA5B,CAA7B;AAMP,OAAO,IAAMe,kBAAkB,GAAG,IAAIF,MAAJ,CAAWd,gBAAX,EAA6B,GAA7B,CAA3B;AAMP,OAAO,IAAMiB,cAAc,GAAG,GAAvB;AAiBP,WAAYC,UAAZ;;WAAYA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,EAAAA,U,CAAAA,U;AAAAA,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B;AAAA;AAAA;;;6BAAO,WACLC,OADK,EAEL;AACA,QAAMb,MAAM,SAASa,OAArB;;AACA,QAAIb,MAAM,CAACc,EAAX,EAAe;AACb,aAAOd,MAAM,CAAC5B,KAAd;AACD,KAFD,MAEO;AACL,YAAMmC,QAAQ,CAACP,MAAD,CAAd;AACD;AACF,G;;;;AAMD,OAAO,SAASe,UAAT,CAAoBC,EAApB,EAAoC;AACzC,MAAMC,SAAS,GAAGC,IAAI,CAACC,MAAM,CAACC,YAAP,CAAoB,GAAGJ,EAAvB,CAAD,CAAtB;AACA,SAAOC,SAAS,CAACI,OAAV,CAAkB,KAAlB,EAAyB,GAAzB,EAA8BA,OAA9B,CAAsC,KAAtC,EAA6C,GAA7C,CAAP;AACD;AAOD,OAAO,SAASC,WAAT,CACLZ,KADK,EAE6B;AAClC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B,OAAO,KAAP;AAC/B,MAAI,CAACA,KAAL,EAAY,OAAO,KAAP;AACZ,MAAI,CAACvB,MAAM,CAACoC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCf,KAArC,EAA4C,SAA5C,CAAL,EAA6D,OAAO,KAAP;AAC7D,MAAI,OAAQA,KAAD,CAAgCzD,OAAvC,KAAmD,QAAvD,EAAiE,OAAO,KAAP;AACjE,SAAO,IAAP;AACD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Agent } from 'https'\nimport type { Headers } from 'request'\nimport type { Readable } from 'readable-stream'\nimport { matchCharsetUtf8, matchModeBinary, matchModeString } from './constants'\nimport { DelimArray } from './delimArray'\n\nexport const agentPrefix = 'TS-SDK'\nexport const LookerAppId = 'x-looker-appid'\n\n/** Set to `true` to follow streaming process */\nconst tracing = false\n\n/**\n * trivial tracing function that should be replaced with a log plugin\n * @param message description for trace\n * @param info any additional information to produce for output\n */\nexport function trace(message: string, info?: any) {\n if (tracing) {\n // eslint-disable-next-line no-console\n console.debug(message)\n if (info) {\n // eslint-disable-next-line no-console\n console.debug({ info })\n }\n }\n}\n\n/** ResponseMode for an HTTP request */\nexport enum ResponseMode {\n 'binary', // this is a binary response\n 'string', // this is a \"string\" response\n 'unknown', // unrecognized response type\n}\n\n/**\n * MIME patterns for string content types\n * @type {RegExp}\n */\nexport const contentPatternString = new RegExp(matchModeString, 'i')\n\n/**\n * MIME patterns for \"binary\" content types\n * @type {RegExp}\n */\nexport const contentPatternBinary = new RegExp(matchModeBinary, 'i')\n\n/**\n * MIME pattern for UTF8 charset attribute\n * @type {RegExp}\n */\nexport const charsetUtf8Pattern = new RegExp(matchCharsetUtf8, 'i')\n\n/**\n * Default request timeout\n * @type {number} default request timeout is 120 seconds, or two minutes\n */\nexport const defaultTimeout = 120\n\n/** Recognized HTTP methods */\nexport type HttpMethod =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'TRACE'\n | 'HEAD'\n\n/**\n * HTTP status codes\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for reference\n * TODO is there a platform-agnostic list of these that can be used instead of this static declaration?\n */\nexport enum StatusCode {\n OK = 200,\n Created,\n Accepted,\n NonAuthoritative,\n NoContent,\n ResetContent,\n PartialContent,\n MultiStatus,\n MultiStatusDav,\n IMUsed = 226,\n MultipleChoice = 300,\n MovedPermanently,\n Found,\n SeeOther,\n NotModified,\n UseProxy,\n UnusedRedirect,\n TemporaryRedirect,\n PermanentRedirect,\n BadRequest = 400,\n Unauthorized,\n PaymentRequired,\n Forbidden,\n NotFound,\n MethodNotAllowed,\n NotAcceptable,\n ProxyAuthRequired,\n RequestTimeout,\n Conflict,\n Gone,\n LengthRequired,\n PreconditionFailed,\n PayloadTooLarge,\n UriTooLong,\n UnsupportedMediaType,\n RequestedRangeNotSatisfiable,\n ExpectationFailed,\n ImATeapot,\n MisdirectedRequest = 421,\n UnprocessableEntity,\n Locked,\n FailedDependency,\n TooEarly,\n UpgradeRequired,\n PreconditionRequired = 428,\n TooManyRequests,\n RequestHeaderFieldsTooLarge = 431,\n UnavailableForLegalReasons = 451,\n InternalServerError = 500,\n NotImplemented,\n BadGateway,\n ServiceUnavailable,\n GatewayTimeout,\n HttpVersionNotSupported,\n VariantAlsoNegotiates,\n InsufficientStorage,\n LoopDetected,\n NotExtended = 510,\n NetworkAuthRequired,\n}\n\n/** Untyped basic HTTP response type for \"raw\" HTTP requests */\nexport interface IRawResponse {\n /** Http method of the request */\n method: HttpMethod\n /** ok is `true` if the response is successful, `false` otherwise */\n ok: boolean\n /** HTTP request url */\n url: string\n /** HTTP response code */\n statusCode: number\n /** HTTP response status message text */\n statusMessage: string\n /** MIME type of the response from the HTTP response header */\n contentType: string\n /** The body of the HTTP response, without any additional processing */\n body: any\n /** Optional performance tracking starting mark name */\n startMark?: string\n /** Response headers */\n headers: IRequestHeaders\n}\n\n/** IRawResponse observer function type */\nexport type RawObserver = (raw: IRawResponse) => IRawResponse\n\n/** Transport plug-in interface */\nexport interface ITransport {\n /** Observer lambda to process raw responses */\n observer: RawObserver | undefined\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * Note: This method returns the result of the HTTP request without any error handling\n *\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>\n\n /**\n * HTTP request function for atomic, fully downloaded responses\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * Processes the raw response, converting it into an SDKResponse\n * @param raw response result\n */\n parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * HTTP request function for a streamable response\n * @param callback that receives the stream response and pipes it somewhere\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns `T` upon success\n * @throws `ISDKErrorResponse` on failure\n */\n stream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n}\n\n/** A successful SDK call. */\nexport interface ISDKSuccessResponse<T> {\n /** Whether the SDK call was successful. */\n ok: true\n /** The object returned by the SDK call. */\n value: T\n}\n\n/** An errant SDK call. */\nexport interface ISDKErrorResponse<T> {\n /** Whether the SDK call was successful. */\n ok: false\n /** The error object returned by the SDK call. */\n error: T\n}\n\n/** An error representing an issue in the SDK, like a network or parsing error. */\nexport interface ISDKError {\n type: 'sdk_error'\n message: string\n}\n\nexport type SDKResponse<TSuccess, TError> =\n | ISDKSuccessResponse<TSuccess>\n | ISDKErrorResponse<TError | ISDKError>\n\n/** Generic collection */\nexport interface IRequestHeaders {\n [key: string]: string\n}\n\n/**\n * Generic http request property collection\n * TODO: Trim this down to what is required\n */\nexport interface IRequestProps {\n [key: string]: any\n /** full url for request, including any query params */\n url: string\n\n /** body of request. optional */\n body?: any\n /** headers for request. optional */\n headers: IRequestHeaders\n /** Http method for request. required. */\n method: HttpMethod\n /** Redirect processing for request. optional */\n redirect?: any\n /** Credentials to use */\n credentials?: 'include' | 'omit' | 'same-origin' | undefined\n\n /** http.Agent instance, allows custom proxy, certificate etc. */\n agent?: Agent\n /** support gzip/deflate content encoding. false to disable */\n compress?: boolean\n /** maximum redirect count. 0 to not follow redirect */\n follow?: number\n /** maximum response body size in bytes */\n size?: number\n /** req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) */\n timeout?: number\n}\n\n/** General purpose authentication callback */\nexport type Authenticator = (props: any) => any\n\n/** Interface for API transport values */\nexport interface ITransportSettings {\n [key: string]: any\n /** base URL of API REST web service */\n base_url: string\n /** standard headers to provide in all transport requests */\n headers?: Headers\n /** whether to verify ssl certs or not. Defaults to true */\n verify_ssl: boolean\n /** request timeout in seconds. Default to 30 */\n timeout: number\n /** encoding override */\n encoding?: string | null\n /** agent tag to use for the SDK requests */\n agentTag: string\n}\n\n/**\n * Is the content type binary or \"string\"?\n * @param {string} contentType\n * @returns {ResponseMode.binary | ResponseMode.string}\n */\nexport function responseMode(contentType: string) {\n if (contentType.match(contentPatternString)) {\n return ResponseMode.string\n }\n if (contentType.match(contentPatternBinary)) {\n return ResponseMode.binary\n }\n return ResponseMode.unknown\n}\n\n/**\n * Does this content type have a UTF-8 charset?\n * @param contentType\n * @returns match if it exists\n */\nexport function isUtf8(contentType: string) {\n return contentType.match(/;.*\\bcharset\\b=\\butf-8\\b/i)\n}\n\n/** Used for name/value pair collections like for QueryParams */\nexport type Values = { [key: string]: any } | null | undefined\n\n/**\n * Encode parameter if not already encoded\n *\n * Note: this includes recognition of Date, DelimArray, and default objects for special handling\n *\n * @param value value of parameter\n * @returns URI encoded value\n */\nexport function encodeParam(value: any) {\n if (value instanceof Date) {\n value = value.toISOString()\n } else if (value instanceof DelimArray) {\n value = value.toString()\n }\n // check for object type to prevent \"[object Object]\" as the value.toString()\n let encoded =\n typeof value === 'object' ? JSON.stringify(value) : value.toString()\n\n // decodeURIComponent throws URIError if there is a % character\n // without it being part of an encoded\n try {\n const decoded = decodeURIComponent(value)\n if (value === decoded) {\n encoded = encodeURIComponent(value)\n }\n } catch (e) {\n if (e instanceof URIError) {\n encoded = encodeURIComponent(value)\n } else {\n throw e\n }\n }\n return encoded\n}\n\n/**\n * Converts `Values` to query string parameter format\n * @param values Name/value collection to encode\n * @returns {string} query string parameter formatted values. Both `false` and `null` are included. Only `undefined` are omitted.\n */\nexport function encodeParams(values?: Values) {\n if (!values) return ''\n\n const keys = Object.keys(values)\n return keys\n .filter((k) => values[k] !== undefined) // `null` and `false` will both be passed\n .map((k) => k + '=' + encodeParam(values[k]))\n .join('&')\n}\n\n/**\n * constructs the path argument including any optional query parameters\n * @param path the base path of the request\n * @param obj optional collection of query parameters to encode and append to the path\n */\nexport function addQueryParams(path: string, obj?: Values) {\n if (!obj) {\n return path\n }\n const qp = encodeParams(obj)\n return `${path}${qp ? '?' + qp : ''}`\n}\n\nconst utf8 = 'utf-8'\n\n/**\n * Convert this value to a string representation however we can do it\n * @param val\n */\nfunction bufferString(val: any) {\n let result = 'Unknown error'\n try {\n const decoder = new TextDecoder(utf8)\n result = decoder.decode(val)\n } catch (e: any) {\n // Supremely ugly hack. If we get here, we must be in Node (or IE 11, but who cares about that?)\n // Node requires an import from `util` for TextDecoder to be found BUT it \"just has\" Buffer unless WebPack messes us up\n try {\n if (val instanceof Buffer) {\n result = Buffer.from(val).toString(utf8)\n } else {\n result = JSON.stringify(val)\n }\n } catch (err: any) {\n // The fallback logic here will at least give us some information about the error being thrown\n result = JSON.stringify(val)\n }\n }\n return result\n}\n\n/**\n * SDK error handler\n * @param response any kind of error\n * @returns a new `Error` object with the failure message\n */\nexport function sdkError(response: any) {\n if (typeof response === 'string') {\n return new Error(response)\n }\n if ('error' in response) {\n const error = response.error\n if (typeof error === 'string') {\n return new Error(error)\n }\n // Try to get most specific error first\n if ('error' in error) {\n const result = bufferString(error.error)\n return new Error(result)\n }\n if ('message' in error) {\n return new Error(response.error.message.toString())\n }\n if ('statusMessage' in error) {\n return new Error(error.statusMessage)\n }\n const result = bufferString(error)\n return new Error(result)\n }\n if ('message' in response) {\n return new Error(response.message)\n }\n const error = JSON.stringify(response)\n return new Error(`Unknown error with SDK method ${error}`)\n}\n\n/** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdkOk(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\nexport async function sdkOk<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n) {\n const result = await promise\n if (result.ok) {\n return result.value\n } else {\n throw sdkError(result)\n }\n}\n\n/**\n * Converts a byte array to a \"URL safe\" base64 string\n * @param u8 byte array to convert\n */\nexport function safeBase64(u8: Uint8Array) {\n const rawBase64 = btoa(String.fromCharCode(...u8))\n return rawBase64.replace(/\\+/g, '-').replace(/\\//g, '_')\n}\n\n/**\n * Type predicate. Asserts that a given object is error-like.\n * @param error a value of unknown type\n * @return boolean true if the error has a `message` key of type string.\n */\nexport function isErrorLike<T extends unknown>(\n error: T\n): error is T & { message: string } {\n if (typeof error !== 'object') return false\n if (!error) return false\n if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false\n if (typeof (error as { message: unknown }).message !== 'string') return false\n return true\n}\n"],"file":"transport.js"}
1
+ {"version":3,"sources":["../../src/transport.ts"],"names":["matchCharsetUtf8","matchModeBinary","matchModeString","DelimArray","LookerSDKError","agentPrefix","LookerAppId","tracing","trace","message","info","console","debug","ResponseMode","contentPatternString","RegExp","contentPatternBinary","charsetUtf8Pattern","defaultTimeout","StatusCode","responseMode","contentType","match","string","binary","unknown","isUtf8","encodeParam","value","Date","toISOString","toString","encoded","JSON","stringify","decoded","decodeURIComponent","encodeURIComponent","e","URIError","encodeParams","values","keys","Object","filter","k","undefined","map","join","addQueryParams","path","obj","qp","utf8","bufferString","val","result","decoder","TextDecoder","decode","Buffer","from","err","sdkError","response","error","errors","documentation_url","statusMessage","sdkOk","promise","ok","safeBase64","u8","rawBase64","btoa","String","fromCharCode","replace","isErrorLike","prototype","hasOwnProperty","call"],"mappings":";;;;AA6BA,SAASA,gBAAT,EAA2BC,eAA3B,EAA4CC,eAA5C,QAAmE,aAAnE;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA,OAAO,IAAMC,WAAW,GAAG,QAApB;AACP,OAAO,IAAMC,WAAW,GAAG,gBAApB;AAGP,IAAMC,OAAO,GAAG,KAAhB;AAOA,OAAO,SAASC,KAAT,CAAeC,OAAf,EAAgCC,IAAhC,EAA4C;AACjD,MAAIH,OAAJ,EAAa;AAEXI,IAAAA,OAAO,CAACC,KAAR,CAAcH,OAAd;;AACA,QAAIC,IAAJ,EAAU;AAERC,MAAAA,OAAO,CAACC,KAA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C,CAAP;AACD;AAOD,OAAO,SAASC,WAAT,CACLd,KADK,EAE6B;AAClC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B,OAAO,KAAP;AAC/B,MAAI,CAACA,KAAL,EAAY,OAAO,KAAP;AACZ,MAAI,CAACtB,MAAM,CAACqC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCjB,KAArC,EAA4C,SAA5C,CAAL,EAA6D,OAAO,KAAP;AAC7D,MAAI,OAAQA,KAAD,CAAgCxD,OAAvC,KAAmD,QAAvD,EAAiE,OAAO,KAAP;AACjE,SAAO,IAAP;AACD","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Agent } from 'https'\nimport type { Headers } from 'request'\nimport type { Readable } from 'readable-stream'\nimport { matchCharsetUtf8, matchModeBinary, matchModeString } from './constants'\nimport { DelimArray } from './delimArray'\nimport { LookerSDKError } from './lookerSDKError'\n\nexport const agentPrefix = 'TS-SDK'\nexport const LookerAppId = 'x-looker-appid'\n\n/** Set to `true` to follow streaming process */\nconst tracing = false\n\n/**\n * trivial tracing function that should be replaced with a log plugin\n * @param message description for trace\n * @param info any additional information to produce for output\n */\nexport function trace(message: string, info?: any) {\n if (tracing) {\n // eslint-disable-next-line no-console\n console.debug(message)\n if (info) {\n // eslint-disable-next-line no-console\n console.debug({ info })\n }\n }\n}\n\n/** ResponseMode for an HTTP request */\nexport enum ResponseMode {\n 'binary', // this is a binary response\n 'string', // this is a \"string\" response\n 'unknown', // unrecognized response type\n}\n\n/**\n * MIME patterns for string content types\n * @type {RegExp}\n */\nexport const contentPatternString = new RegExp(matchModeString, 'i')\n\n/**\n * MIME patterns for \"binary\" content types\n * @type {RegExp}\n */\nexport const contentPatternBinary = new RegExp(matchModeBinary, 'i')\n\n/**\n * MIME pattern for UTF8 charset attribute\n * @type {RegExp}\n */\nexport const charsetUtf8Pattern = new RegExp(matchCharsetUtf8, 'i')\n\n/**\n * Default request timeout\n * @type {number} default request timeout is 120 seconds, or two minutes\n */\nexport const defaultTimeout = 120\n\n/** Recognized HTTP methods */\nexport type HttpMethod =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'TRACE'\n | 'HEAD'\n\n/**\n * HTTP status codes\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for reference\n * TODO is there a platform-agnostic list of these that can be used instead of this static declaration?\n */\nexport enum StatusCode {\n OK = 200,\n Created,\n Accepted,\n NonAuthoritative,\n NoContent,\n ResetContent,\n PartialContent,\n MultiStatus,\n MultiStatusDav,\n IMUsed = 226,\n MultipleChoice = 300,\n MovedPermanently,\n Found,\n SeeOther,\n NotModified,\n UseProxy,\n UnusedRedirect,\n TemporaryRedirect,\n PermanentRedirect,\n BadRequest = 400,\n Unauthorized,\n PaymentRequired,\n Forbidden,\n NotFound,\n MethodNotAllowed,\n NotAcceptable,\n ProxyAuthRequired,\n RequestTimeout,\n Conflict,\n Gone,\n LengthRequired,\n PreconditionFailed,\n PayloadTooLarge,\n UriTooLong,\n UnsupportedMediaType,\n RequestedRangeNotSatisfiable,\n ExpectationFailed,\n ImATeapot,\n MisdirectedRequest = 421,\n UnprocessableEntity,\n Locked,\n FailedDependency,\n TooEarly,\n UpgradeRequired,\n PreconditionRequired = 428,\n TooManyRequests,\n RequestHeaderFieldsTooLarge = 431,\n UnavailableForLegalReasons = 451,\n InternalServerError = 500,\n NotImplemented,\n BadGateway,\n ServiceUnavailable,\n GatewayTimeout,\n HttpVersionNotSupported,\n VariantAlsoNegotiates,\n InsufficientStorage,\n LoopDetected,\n NotExtended = 510,\n NetworkAuthRequired,\n}\n\n/** Untyped basic HTTP response type for \"raw\" HTTP requests */\nexport interface IRawResponse {\n /** Http method of the request */\n method: HttpMethod\n /** ok is `true` if the response is successful, `false` otherwise */\n ok: boolean\n /** HTTP request url */\n url: string\n /** HTTP response code */\n statusCode: number\n /** HTTP response status message text */\n statusMessage: string\n /** MIME type of the response from the HTTP response header */\n contentType: string\n /** The body of the HTTP response, without any additional processing */\n body: any\n /** Optional performance tracking starting mark name */\n startMark?: string\n /** Response headers */\n headers: IRequestHeaders\n}\n\n/** IRawResponse observer function type */\nexport type RawObserver = (raw: IRawResponse) => IRawResponse\n\n/** Transport plug-in interface */\nexport interface ITransport {\n /** Observer lambda to process raw responses */\n observer: RawObserver | undefined\n\n /**\n * HTTP request function for atomic, fully downloaded raw HTTP responses\n *\n * Note: This method returns the result of the HTTP request without any error handling\n *\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>\n\n /**\n * HTTP request function for atomic, fully downloaded responses\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns typed response of `TSuccess`, or `TError` result\n */\n request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * Processes the raw response, converting it into an SDKResponse\n * @param raw response result\n */\n parseResponse<TSuccess, TError>(\n raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>>\n\n /**\n * HTTP request function for a streamable response\n * @param callback that receives the stream response and pipes it somewhere\n * @param method of HTTP request\n * @param path request path, either relative or fully specified\n * @param queryParams name/value pairs to pass as part of the URL\n * @param body data for the body of the request\n * @param authenticator authenticator callback, typically from `IAuthSession` implementation\n * @param options overrides of default transport settings\n * @returns `T` upon success\n * @throws `ISDKErrorResponse` on failure\n */\n stream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n}\n\n/** A successful SDK call. */\nexport interface ISDKSuccessResponse<T> {\n /** Whether the SDK call was successful. */\n ok: true\n /** The object returned by the SDK call. */\n value: T\n}\n\n/** An errant SDK call. */\nexport interface ISDKErrorResponse<T> {\n /** Whether the SDK call was successful. */\n ok: false\n /** The error object returned by the SDK call. */\n error: T\n}\n\n/** An error representing an issue in the SDK, like a network or parsing error. */\nexport interface ISDKError {\n type: 'sdk_error'\n message: string\n}\n\nexport type SDKResponse<TSuccess, TError> =\n | ISDKSuccessResponse<TSuccess>\n | ISDKErrorResponse<TError | ISDKError>\n\n/** Generic collection */\nexport interface IRequestHeaders {\n [key: string]: string\n}\n\n/**\n * Generic http request property collection\n * TODO: Trim this down to what is required\n */\nexport interface IRequestProps {\n [key: string]: any\n /** full url for request, including any query params */\n url: string\n\n /** body of request. optional */\n body?: any\n /** headers for request. optional */\n headers: IRequestHeaders\n /** Http method for request. required. */\n method: HttpMethod\n /** Redirect processing for request. optional */\n redirect?: any\n /** Credentials to use */\n credentials?: 'include' | 'omit' | 'same-origin' | undefined\n\n /** http.Agent instance, allows custom proxy, certificate etc. */\n agent?: Agent\n /** support gzip/deflate content encoding. false to disable */\n compress?: boolean\n /** maximum redirect count. 0 to not follow redirect */\n follow?: number\n /** maximum response body size in bytes */\n size?: number\n /** req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) */\n timeout?: number\n}\n\n/** General purpose authentication callback */\nexport type Authenticator = (props: any) => any\n\n/** Interface for API transport values */\nexport interface ITransportSettings {\n [key: string]: any\n /** base URL of API REST web service */\n base_url: string\n /** standard headers to provide in all transport requests */\n headers?: Headers\n /** whether to verify ssl certs or not. Defaults to true */\n verify_ssl: boolean\n /** request timeout in seconds. Default to 30 */\n timeout: number\n /** encoding override */\n encoding?: string | null\n /** agent tag to use for the SDK requests */\n agentTag: string\n}\n\n/**\n * Is the content type binary or \"string\"?\n * @param {string} contentType\n * @returns {ResponseMode.binary | ResponseMode.string}\n */\nexport function responseMode(contentType: string) {\n if (contentType.match(contentPatternString)) {\n return ResponseMode.string\n }\n if (contentType.match(contentPatternBinary)) {\n return ResponseMode.binary\n }\n return ResponseMode.unknown\n}\n\n/**\n * Does this content type have a UTF-8 charset?\n * @param contentType\n * @returns match if it exists\n */\nexport function isUtf8(contentType: string) {\n return contentType.match(/;.*\\bcharset\\b=\\butf-8\\b/i)\n}\n\n/** Used for name/value pair collections like for QueryParams */\nexport type Values = { [key: string]: any } | null | undefined\n\n/**\n * Encode parameter if not already encoded\n *\n * Note: this includes recognition of Date, DelimArray, and default objects for special handling\n *\n * @param value value of parameter\n * @returns URI encoded value\n */\nexport function encodeParam(value: any) {\n if (value instanceof Date) {\n value = value.toISOString()\n } else if (value instanceof DelimArray) {\n value = value.toString()\n }\n // check for object type to prevent \"[object Object]\" as the value.toString()\n let encoded =\n typeof value === 'object' ? JSON.stringify(value) : value.toString()\n\n // decodeURIComponent throws URIError if there is a % character\n // without it being part of an encoded\n try {\n const decoded = decodeURIComponent(value)\n if (value === decoded) {\n encoded = encodeURIComponent(value)\n }\n } catch (e) {\n if (e instanceof URIError) {\n encoded = encodeURIComponent(value)\n } else {\n throw e\n }\n }\n return encoded\n}\n\n/**\n * Converts `Values` to query string parameter format\n * @param values Name/value collection to encode\n * @returns {string} query string parameter formatted values. Both `false` and `null` are included. Only `undefined` are omitted.\n */\nexport function encodeParams(values?: Values) {\n if (!values) return ''\n\n const keys = Object.keys(values)\n return keys\n .filter((k) => values[k] !== undefined) // `null` and `false` will both be passed\n .map((k) => k + '=' + encodeParam(values[k]))\n .join('&')\n}\n\n/**\n * constructs the path argument including any optional query parameters\n * @param path the base path of the request\n * @param obj optional collection of query parameters to encode and append to the path\n */\nexport function addQueryParams(path: string, obj?: Values) {\n if (!obj) {\n return path\n }\n const qp = encodeParams(obj)\n return `${path}${qp ? '?' + qp : ''}`\n}\n\nconst utf8 = 'utf-8'\n\n/**\n * Convert this value to a string representation however we can do it\n * @param val\n */\nfunction bufferString(val: any) {\n let result = 'Unknown error'\n try {\n const decoder = new TextDecoder(utf8)\n result = decoder.decode(val)\n } catch (e: any) {\n // Supremely ugly hack. If we get here, we must be in Node (or IE 11, but who cares about that?)\n // Node requires an import from `util` for TextDecoder to be found BUT it \"just has\" Buffer unless WebPack messes us up\n try {\n if (val instanceof Buffer) {\n result = Buffer.from(val).toString(utf8)\n } else {\n result = JSON.stringify(val)\n }\n } catch (err: any) {\n // The fallback logic here will at least give us some information about the error being thrown\n result = JSON.stringify(val)\n }\n }\n return result\n}\n\n/**\n * SDK error handler\n * @param response any kind of error\n * @returns a new `Error` object with the failure message\n */\nexport function sdkError(response: any) {\n if (typeof response === 'string') {\n return new LookerSDKError(response)\n }\n if ('error' in response) {\n const error = response.error\n if (typeof error === 'string') {\n return new LookerSDKError(error)\n }\n // Try to get most specific error first\n if ('error' in error) {\n const result = bufferString(error.error)\n return new LookerSDKError(result)\n }\n if ('message' in error) {\n return new LookerSDKError(response.error.message.toString(), {\n errors: error.errors,\n documentation_url: error.documentation_url,\n })\n }\n if ('statusMessage' in error) {\n return new LookerSDKError(error.statusMessage)\n }\n const result = bufferString(error)\n return new LookerSDKError(result)\n }\n if ('message' in response) {\n return new LookerSDKError(response.message)\n }\n const error = JSON.stringify(response)\n return new LookerSDKError(`Unknown error with SDK method ${error}`)\n}\n\n/** A helper method for simplifying error handling of SDK responses.\n *\n * Pass in a promise returned by any SDK method, and it will return a promise\n * that rejects if the `SDKResponse` is not `ok`. This will swallow the type\n * information in the error case, but allows you to route all the error cases\n * into a single promise rejection.\n *\n * The promise will have an `Error` rejection reason with a string `message`.\n * If the server error contains a `message` field, it will be provided, otherwise a\n * generic message will occur.\n *\n * ```ts\n * const sdk = LookerSDK({...})\n * let look\n * try {\n * look = await sdkOk(sdk.create_look({...}))\n * // do something with look\n * }\n * catch(e) {\n * // handle error case\n * }\n * ```\n */\nexport async function sdkOk<TSuccess, TError>(\n promise: Promise<SDKResponse<TSuccess, TError>>\n) {\n const result = await promise\n if (result.ok) {\n return result.value\n } else {\n throw sdkError(result)\n }\n}\n\n/**\n * Converts a byte array to a \"URL safe\" base64 string\n * @param u8 byte array to convert\n */\nexport function safeBase64(u8: Uint8Array) {\n const rawBase64 = btoa(String.fromCharCode(...u8))\n return rawBase64.replace(/\\+/g, '-').replace(/\\//g, '_')\n}\n\n/**\n * Type predicate. Asserts that a given object is error-like.\n * @param error a value of unknown type\n * @return boolean true if the error has a `message` key of type string.\n */\nexport function isErrorLike<T extends unknown>(\n error: T\n): error is T & { message: string } {\n if (typeof error !== 'object') return false\n if (!error) return false\n if (!Object.prototype.hasOwnProperty.call(error, 'message')) return false\n if (typeof (error as { message: unknown }).message !== 'string') return false\n return true\n}\n"],"file":"transport.js"}
package/lib/index.d.ts CHANGED
@@ -10,8 +10,10 @@ export * from './constants';
10
10
  export * from './cryptoHash';
11
11
  export * from './CSRFSession';
12
12
  export * from './delimArray';
13
+ export * from './errorDoc';
13
14
  export * from './extensionSession';
14
15
  export * from './extensionTransport';
16
+ export * from './lookerSDKError';
15
17
  export * from './oauthSession';
16
18
  export * from './paging';
17
19
  export * from './platformServices';
package/lib/index.js CHANGED
@@ -160,6 +160,19 @@ Object.keys(_delimArray).forEach(function (key) {
160
160
  });
161
161
  });
162
162
 
163
+ var _errorDoc = require("./errorDoc");
164
+
165
+ Object.keys(_errorDoc).forEach(function (key) {
166
+ if (key === "default" || key === "__esModule") return;
167
+ if (key in exports && exports[key] === _errorDoc[key]) return;
168
+ Object.defineProperty(exports, key, {
169
+ enumerable: true,
170
+ get: function get() {
171
+ return _errorDoc[key];
172
+ }
173
+ });
174
+ });
175
+
163
176
  var _extensionSession = require("./extensionSession");
164
177
 
165
178
  Object.keys(_extensionSession).forEach(function (key) {
@@ -186,6 +199,19 @@ Object.keys(_extensionTransport).forEach(function (key) {
186
199
  });
187
200
  });
188
201
 
202
+ var _lookerSDKError = require("./lookerSDKError");
203
+
204
+ Object.keys(_lookerSDKError).forEach(function (key) {
205
+ if (key === "default" || key === "__esModule") return;
206
+ if (key in exports && exports[key] === _lookerSDKError[key]) return;
207
+ Object.defineProperty(exports, key, {
208
+ enumerable: true,
209
+ get: function get() {
210
+ return _lookerSDKError[key];
211
+ }
212
+ });
213
+ });
214
+
189
215
  var _oauthSession = require("./oauthSession");
190
216
 
191
217
  Object.keys(_oauthSession).forEach(function (key) {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA0BA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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 './apiMethods'\nexport * from './apiSettings'\nexport * from './authSession'\nexport * from './authToken'\nexport * from './baseTransport'\nexport * from './browserSession'\nexport * from './browserServices'\nexport * from './browserTransport'\nexport * from './constants'\nexport * from './cryptoHash'\nexport * from './CSRFSession'\nexport * from './delimArray'\nexport * from './extensionSession'\nexport * from './extensionTransport'\nexport * from './oauthSession'\nexport * from './paging'\nexport * from './platformServices'\nexport * from './proxySession'\nexport * from './transport'\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AA0BA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","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 './apiMethods'\nexport * from './apiSettings'\nexport * from './authSession'\nexport * from './authToken'\nexport * from './baseTransport'\nexport * from './browserSession'\nexport * from './browserServices'\nexport * from './browserTransport'\nexport * from './constants'\nexport * from './cryptoHash'\nexport * from './CSRFSession'\nexport * from './delimArray'\nexport * from './errorDoc'\nexport * from './extensionSession'\nexport * from './extensionTransport'\nexport * from './lookerSDKError'\nexport * from './oauthSession'\nexport * from './paging'\nexport * from './platformServices'\nexport * from './proxySession'\nexport * from './transport'\n"],"file":"index.js"}
@@ -0,0 +1,25 @@
1
+ declare type AugmentErrorOptions<ErrorParameters extends unknown[], AdditionalErrorOptions> = ErrorParameters extends [(infer Message)?] ? [Message?, AdditionalErrorOptions?] : ErrorParameters extends [(infer Message)?, (infer ErrorOptions)?] ? [Message?, (ErrorOptions & AdditionalErrorOptions)?] : ErrorParameters extends [
2
+ (infer Message)?,
3
+ (infer ErrorOptions)?,
4
+ ...infer Rest
5
+ ] ? [Message?, (ErrorOptions & AdditionalErrorOptions)?, ...Rest] : never;
6
+ interface IErrorDetail {
7
+ field?: string;
8
+ code?: string;
9
+ message?: string;
10
+ documentation_url: string;
11
+ }
12
+ interface ILookerSDKErrorOptions {
13
+ errors?: IErrorDetail[];
14
+ documentation_url?: string | null;
15
+ }
16
+ interface ILookerSDKErrorConstructor {
17
+ new (...args: AugmentErrorOptions<ConstructorParameters<ErrorConstructor>, ILookerSDKErrorOptions>): LookerSDKError;
18
+ (...args: AugmentErrorOptions<Parameters<ErrorConstructor>, ILookerSDKErrorOptions>): LookerSDKError;
19
+ }
20
+ export interface LookerSDKError extends Error {
21
+ errors?: IErrorDetail[];
22
+ documentation_url?: string | null;
23
+ }
24
+ export declare const LookerSDKError: ILookerSDKErrorConstructor;
25
+ export {};
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LookerSDKError = void 0;
7
+
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
+
12
+ var LookerSDKError = (() => {
13
+ 'use strict';
14
+
15
+ var LookerSDKErrorConstructor = function LookerSDKError() {
16
+ var _errors, _documentation_url;
17
+
18
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ _ref[_key] = arguments[_key];
20
+ }
21
+
22
+ var [message, _ref2 = {}, ...rest] = _ref;
23
+
24
+ var {
25
+ errors,
26
+ documentation_url
27
+ } = _ref2,
28
+ errorOptions = _objectWithoutProperties(_ref2, ["errors", "documentation_url"]);
29
+
30
+ (_errors = errors) !== null && _errors !== void 0 ? _errors : errors = [];
31
+ (_documentation_url = documentation_url) !== null && _documentation_url !== void 0 ? _documentation_url : documentation_url = '';
32
+ var error = this ? new Error(message, errorOptions, ...rest) : Error(message, errorOptions, ...rest);
33
+ Object.setPrototypeOf(error, this ? Object.getPrototypeOf(this) : LookerSDKError.prototype);
34
+ Object.defineProperty(error, 'message', {
35
+ enumerable: true
36
+ });
37
+ error.errors = errors;
38
+ error.documentation_url = documentation_url;
39
+ return error;
40
+ };
41
+
42
+ Object.defineProperty(LookerSDKErrorConstructor, 'prototype', {
43
+ value: Object.create(Error.prototype, {
44
+ constructor: {
45
+ value: LookerSDKErrorConstructor,
46
+ writable: true,
47
+ configurable: true
48
+ },
49
+ name: {
50
+ value: 'LookerSDKError',
51
+ writable: true,
52
+ configurable: true
53
+ }
54
+ }),
55
+ writable: false
56
+ });
57
+ return LookerSDKErrorConstructor;
58
+ })();
59
+
60
+ exports.LookerSDKError = LookerSDKError;
61
+ //# sourceMappingURL=lookerSDKError.js.map