@looker/sdk-rtl 21.6.0 → 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 +53 -60
  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 +4 -4
  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 +126 -61
  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 +117 -24
  116. package/lib/transport.js.map +1 -1
  117. package/package.json +5 -13
@@ -1 +1 @@
1
- {"version":3,"file":"errorDoc.js","names":["ErrorCodesUrl","ErrorDocNotFound","ErrorDocPatternExpression","String","raw","ErrorDocRx","RegExp","sdkUrlGet","sdk","url","sdkOk","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"],"sources":["../../src/errorDoc.ts"],"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|https:\\/\\/cloud\\.google\\.com\\/looker\\/docs\\/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"],"mappings":";;;;;;AA2BA;AAAmC;AAAA;AAAA;AAAA;AA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eAAehB,UAAU,KAAI,EAAE;MAC3CkB,UAAU,EAAE,CAAAH,KAAK,aAALA,KAAK,yCAALA,KAAK,CAAEC,MAAM,mDAAb,eAAeE,UAAU,KAAI,EAAE;MAC3CjB,UAAU,EAAE,CAAAc,KAAK,aAALA,KAAK,yCAALA,KAAK,CAAEC,MAAM,mDAAb,eAAef,UAAU,KAAI,EAAE;MAC3CC,OAAO,EAAE,CAAAa,KAAK,aAALA,KAAK,yCAALA,KAAK,CAAEC,MAAM,mDAAb,eAAed,OAAO,KAAI;IACrC,CAAC;EACH;AACF;AAAC"}
1
+ {"version":3,"file":"errorDoc.js","names":["sdkOk","ErrorCodesUrl","ErrorDocNotFound","ErrorDocPatternExpression","String","raw","_templateObject","_taggedTemplateLiteral","ErrorDocRx","RegExp","sdkUrlGet","_ref","_asyncToGenerator","sdk","url","authSession","transport","request","_x","_x2","apply","arguments","ErrorDoc","constructor","getter","length","undefined","cdnUrl","_defineProperty","load","_this","_index","result","indexUrl","JSON","parse","e","Promise","resolve","contentUrl","index","catch","reason","console","error","specPath","path","replace","found","concat","substring","errorKey","docUrl","bits","redirector","statusCode","apiPath","notFound","key","getContent","_this2","message","content","_this3","item","code","split","urlPath","methodName","errorMdUrl","_match$groups","ErrorMdRx","_wrapRegExp","name","match","groups","_match$groups2","_match$groups3","_match$groups4","_match$groups5","apiVersion"],"sources":["../../src/errorDoc.ts"],"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 './transport';\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://static-a.cdn.looker.app/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|https:\\/\\/cloud\\.google\\.com\\/looker\\/docs\\/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.substring(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"],"mappings":";;;;;;;;;;AA2BA,SAASA,KAAK,QAAQ,aAAa;AAQnC,OAAO,IAAMC,aAAa,GAAG,6CAA6C;AAM1E,OAAO,IAAMC,gBAAgB,GAAG,iCAAiC;AAGjE,IAAMC,yBAAyB,GAAGC,MAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,GAAAC,sBAAA,kUAA4J;AACxM,OAAO,IAAMC,UAAU,GAAGC,MAAM,CAACN,yBAAyB,EAAE,GAAG,CAAC;AAmFhE,IAAMO,SAAS;EAAA,IAAAC,IAAA,GAAAC,iBAAA,CAAG,WAAOC,GAAgB,EAAEC,GAAW,EAAK;IACzD,a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EAClC;EAEAtC,KAAKA,CAACiB,MAAc,EAAiB;IAAA,IAAAwB,cAAA,EAAAC,cAAA,EAAAC,cAAA,EAAAC,cAAA;IACnC,IAAML,KAAK,GAAGtB,MAAM,CAACsB,KAAK,CAAClE,UAAU,CAAC;IACtC,OAAO;MACL8C,UAAU,EAAE,CAAAoB,KAAK,aAALA,KAAK,wBAAAE,cAAA,GAALF,KAAK,CAAEC,MAAM,cAAAC,cAAA,uBAAbA,cAAA,CAAetB,UAAU,KAAI,EAAE;MAC3C0B,UAAU,EAAE,CAAAN,KAAK,aAALA,KAAK,wBAAAG,cAAA,GAALH,KAAK,CAAEC,MAAM,cAAAE,cAAA,uBAAbA,cAAA,CAAeG,UAAU,KAAI,EAAE;MAC3CzB,UAAU,EAAE,CAAAmB,KAAK,aAALA,KAAK,wBAAAI,cAAA,GAALJ,KAAK,CAAEC,MAAM,cAAAG,cAAA,uBAAbA,cAAA,CAAevB,UAAU,KAAI,EAAE;MAC3CC,OAAO,EAAE,CAAAkB,KAAK,aAALA,KAAK,wBAAAK,cAAA,GAALL,KAAK,CAAEC,MAAM,cAAAI,cAAA,uBAAbA,cAAA,CAAevB,OAAO,KAAI;IACrC,CAAC;EACH;AACF"}
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ExtensionSession = void 0;
7
1
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
8
2
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
9
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
- class ExtensionSession {
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ export class ExtensionSession {
13
7
  constructor(settings, transport) {
14
8
  this.settings = settings;
15
9
  _defineProperty(this, "sudoId", '');
@@ -45,5 +39,4 @@ class ExtensionSession {
45
39
  }
46
40
  reset() {}
47
41
  }
48
- exports.ExtensionSession = ExtensionSession;
49
42
  //# sourceMappingURL=extensionSession.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensionSession.js","names":["ExtensionSession","constructor","settings","transport","isAuthenticated","authenticate","init","Promise","reject","Error","getToken","isSudo","login","sudoId","logout","reset"],"sources":["../../src/extensionSession.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IApiSettings } from './apiSettings'\nimport type { ITransport, IRequestProps } from './transport'\nimport type { IAuthSession } from './authSession'\n\nexport class ExtensionSession implements IAuthSession {\n sudoId = ''\n transport: ITransport\n\n constructor(public settings: IApiSettings, transport: ITransport) {\n this.settings = settings\n this.transport = transport\n }\n\n isAuthenticated() {\n // Assume if the extension exists then it is authenticated\n return true\n }\n\n async authenticate(init: IRequestProps) {\n return Promise.reject(\n Error(\n `Authenticate ${\n init ? 'request property overrides' : ''\n } not supported from ExtensionSession`\n )\n )\n }\n\n async getToken(): Promise<any> {\n return Promise.reject(\n Error('Access to token is not allowed from ExtensionSession')\n )\n }\n\n isSudo(): boolean {\n throw new Error('isSudo is not allowed from ExtensionSession')\n }\n\n async login(sudoId?: string | number): Promise<any> {\n return Promise.reject(\n Error(\n `Login ${sudoId ? 'for sudo' : ''} not supported from ExtensionSession`\n )\n )\n }\n\n async logout(): Promise<boolean> {\n return Promise.reject(Error('Logout not supported from ExtensionSession'))\n }\n\n reset(): void {\n // noop\n }\n}\n"],"mappings":";;;;;;;;;;;AA8BO,MAAMA,gBAAgB,CAAyB;EAIpDC,WAAW,CAAQC,QAAsB,EAAEC,SAAqB,EAAE;IAAA,KAA/CD,QAAsB,GAAtBA,QAAsB;IAAA,gCAHhC,EAAE;IAAA;IAIT,IAAI,CAACA,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;EAC5B;EAEAC,eAAe,GAAG;IAEhB,OAAO,IAAI;EACb;EAEMC,YAAY,CAACC,IAAmB,EAAE;IAAA;MACtC,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,wBAEDH,IAAI,GAAG,4BAA4B,GAAG,EAAE,0CAE3C,CACF;IAAA;EACH;EAEMI,QAAQ,GAAiB;IAAA;MAC7B,OAAOH,OAAO,CAACC,MAAM,CACnBC,KAAK,CAAC,sDAAsD,CAAC,CAC9D;IAAA;EACH;EAEAE,MAAM,GAAY;IAChB,MAAM,IAAIF,KAAK,CAAC,6CAA6C,CAAC;EAChE;EAEMG,KAAK,CAACC,MAAwB,EAAgB;IAAA;MAClD,OAAON,OAAO,CAACC,MAAM,CACnBC,KAAK,iBACMI,MAAM,GAAG,UAAU,GAAG,EAAE,0CAClC,CACF;IAAA;EACH;EAEMC,MAAM,GAAqB;IAAA;MAC/B,OAAOP,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAAA;EAC5E;EAEAM,KAAK,GAAS,CAEd;AACF;AAAC"}
1
+ {"version":3,"file":"extensionSession.js","names":["ExtensionSession","constructor","settings","transport","_defineProperty","isAuthenticated","authenticate","init","_asyncToGenerator","Promise","reject","Error","concat","getToken","isSudo","login","sudoId","logout","reset"],"sources":["../../src/extensionSession.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IApiSettings } from './apiSettings';\nimport type { IRequestProps, ITransport } from './transport';\nimport type { IAuthSession } from './authSession';\n\nexport class ExtensionSession implements IAuthSession {\n sudoId = '';\n transport: ITransport;\n\n constructor(public settings: IApiSettings, transport: ITransport) {\n this.settings = settings;\n this.transport = transport;\n }\n\n isAuthenticated() {\n // Assume if the extension exists then it is authenticated\n return true;\n }\n\n async authenticate(init: IRequestProps) {\n return Promise.reject(\n Error(\n `Authenticate ${\n init ? 'request property overrides' : ''\n } not supported from ExtensionSession`\n )\n );\n }\n\n async getToken(): Promise<any> {\n return Promise.reject(\n Error('Access to token is not allowed from ExtensionSession')\n );\n }\n\n isSudo(): boolean {\n throw new Error('isSudo is not allowed from ExtensionSession');\n }\n\n async login(sudoId?: string | number): Promise<any> {\n return Promise.reject(\n Error(\n `Login ${sudoId ? 'for sudo' : ''} not supported from ExtensionSession`\n )\n );\n }\n\n async logout(): Promise<boolean> {\n return Promise.reject(Error('Logout not supported from ExtensionSession'));\n }\n\n reset(): void {\n // noop\n }\n}\n"],"mappings":";;;;;AA8BA,OAAO,MAAMA,gBAAgB,CAAyB;EAIpDC,WAAWA,CAAQC,QAAsB,EAAEC,SAAqB,EAAE;IAAA,KAA/CD,QAAsB,GAAtBA,QAAsB;IAAAE,eAAA,iBAHhC,EAAE;IAAAA,eAAA;IAIT,IAAI,CAACF,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,SAAS,GAAGA,SAAS;EAC5B;EAEAE,eAAeA,CAAA,EAAG;IAEhB,OAAO,IAAI;EACb;EAEMC,YAAYA,CAACC,IAAmB,EAAE;IAAA,OAAAC,iBAAA;MACtC,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,iBAAAC,MAAA,CAEDL,IAAI,GAAG,4BAA4B,GAAG,EAAE,yCAE5C,CACF,CAAC;IAAC;EACJ;EAEMM,QAAQA,CAAA,EAAiB;IAAA,OAAAL,iBAAA;MAC7B,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,CAAC,sDAAsD,CAC9D,CAAC;IAAC;EACJ;EAEAG,MAAMA,CAAA,EAAY;IAChB,MAAM,IAAIH,KAAK,CAAC,6CAA6C,CAAC;EAChE;EAEMI,KAAKA,CAACC,MAAwB,EAAgB;IAAA,OAAAR,iBAAA;MAClD,OAAOC,OAAO,CAACC,MAAM,CACnBC,KAAK,UAAAC,MAAA,CACMI,MAAM,GAAG,UAAU,GAAG,EAAE,yCACnC,CACF,CAAC;IAAC;EACJ;EAEMC,MAAMA,CAAA,EAAqB;IAAA,OAAAT,iBAAA;MAC/B,OAAOC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAAC;EAC7E;EAEAO,KAAKA,CAAA,EAAS,CAEd;AACF"}
@@ -1,17 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ExtensionTransport = void 0;
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
5
  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); }
14
- class ExtensionTransport {
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
7
+ 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); }
8
+ export class ExtensionTransport {
15
9
  constructor(options, hostConnection) {
16
10
  this.options = options;
17
11
  this.hostConnection = hostConnection;
@@ -46,6 +40,8 @@ class ExtensionTransport {
46
40
  };
47
41
  return Promise.resolve(result);
48
42
  }
43
+ retry(_request) {
44
+ return Promise.reject(new Error('TODO: retry not implemented yet'));
45
+ }
49
46
  }
50
- exports.ExtensionTransport = ExtensionTransport;
51
47
  //# sourceMappingURL=extensionTransport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensionTransport.js","names":["ExtensionTransport","constructor","options","hostConnection","rawRequest","method","path","queryParams","body","authenticator","response","observer","request","stream","callback","parseResponse","_raw","result","ok","error","Error","Promise","resolve"],"sources":["../../src/extensionTransport.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { Readable } from 'readable-stream'\nimport type {\n Authenticator,\n Values,\n SDKResponse,\n ITransport,\n ITransportSettings,\n HttpMethod,\n IRawResponse,\n RawObserver,\n} from './transport'\n\nexport interface IHostConnection {\n rawRequest(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>\n\n request(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<any>\n\n stream<T>(\n callback: (readable: Readable) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>\n}\n\nexport class ExtensionTransport implements ITransport {\n constructor(\n private readonly options: ITransportSettings,\n private hostConnection: IHostConnection\n ) {\n this.options = options\n this.hostConnection = hostConnection\n }\n\n observer: RawObserver | undefined\n\n async rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse> {\n const response = await this.hostConnection.rawRequest(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n )\n return this.observer ? this.observer(response) : response\n }\n\n async request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.hostConnection.request(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n )\n }\n\n async stream<TSuccess>(\n callback: (readable: any) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n options = options ? { ...this.options, ...options } : this.options\n return this.hostConnection.stream(\n callback,\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n )\n }\n\n parseResponse<TSuccess, TError>(\n _raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>> {\n const result: SDKResponse<TSuccess, TError> = {\n ok: false,\n error: new Error('Should not be called!') as unknown as TError,\n }\n return Promise.resolve(result)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAoEO,MAAMA,kBAAkB,CAAuB;EACpDC,WAAW,CACQC,OAA2B,EACpCC,cAA+B,EACvC;IAAA,KAFiBD,OAA2B,GAA3BA,OAA2B;IAAA,KACpCC,cAA+B,GAA/BA,cAA+B;IAAA;IAEvC,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAGA,cAAc;EACtC;EAIMC,UAAU,CACdC,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBP,OAAqC,EACd;IAAA;IAAA;MACvB,IAAMQ,QAAQ,SAAS,KAAI,CAACP,cAAc,CAACC,UAAU,CACnDC,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbP,OAAO,CACR;MACD,OAAO,KAAI,CAACS,QAAQ,GAAG,KAAI,CAACA,QAAQ,CAACD,QAAQ,CAAC,GAAGA,QAAQ;IAAA;EAC3D;EAEME,OAAO,CACXP,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBP,OAAqC,EACG;IAAA;IAAA;MACxC,OAAO,MAAI,CAACC,cAAc,CAACS,OAAO,CAChCP,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbP,OAAO,CACR;IAAA;EACH;EAEMW,MAAM,CACVC,QAA8C,EAC9CT,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBP,OAAqC,EAClB;IAAA;IAAA;MACnBA,OAAO,GAAGA,OAAO,mCAAQ,MAAI,CAACA,OAAO,GAAKA,OAAO,IAAK,MAAI,CAACA,OAAO;MAClE,OAAO,MAAI,CAACC,cAAc,CAACU,MAAM,CAC/BC,QAAQ,EACRT,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbP,OAAO,CACR;IAAA;EACH;EAEAa,aAAa,CACXC,IAAkB,EACsB;IACxC,IAAMC,MAAqC,GAAG;MAC5CC,EAAE,EAAE,KAAK;MACTC,KAAK,EAAE,IAAIC,KAAK,CAAC,uBAAuB;IAC1C,CAAC;IACD,OAAOC,OAAO,CAACC,OAAO,CAACL,MAAM,CAAC;EAChC;AACF;AAAC"}
1
+ {"version":3,"file":"extensionTransport.js","names":["ExtensionTransport","constructor","options","hostConnection","_defineProperty","rawRequest","method","path","queryParams","body","authenticator","_this","_asyncToGenerator","response","observer","request","_this2","stream","callback","_this3","_objectSpread","parseResponse","_raw","result","ok","error","Error","Promise","resolve","retry","_request","reject"],"sources":["../../src/extensionTransport.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type {\n Authenticator,\n HttpMethod,\n IRawRequest,\n IRawResponse,\n ITransport,\n ITransportSettings,\n RawObserver,\n SDKResponse,\n Values,\n} from './transport';\n\nexport interface IHostConnection {\n rawRequest(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse>;\n\n request(\n httpMethod: string,\n path: string,\n body?: any,\n params?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<any>;\n\n stream<T>(\n callback: (readable: any) => Promise<T>,\n method: HttpMethod,\n path: string,\n queryParams?: Values,\n body?: any,\n authenticator?: Authenticator,\n options?: Partial<ITransportSettings>\n ): Promise<T>;\n}\n\nexport class ExtensionTransport implements ITransport {\n constructor(\n private readonly options: ITransportSettings,\n private hostConnection: IHostConnection\n ) {\n this.options = options;\n this.hostConnection = hostConnection;\n }\n\n observer: RawObserver | undefined;\n\n async rawRequest(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<IRawResponse> {\n const response = await this.hostConnection.rawRequest(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n return this.observer ? this.observer(response) : response;\n }\n\n async request<TSuccess, TError>(\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<SDKResponse<TSuccess, TError>> {\n return this.hostConnection.request(\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n }\n\n async stream<TSuccess>(\n callback: (readable: any) => Promise<TSuccess>,\n method: HttpMethod,\n path: string,\n queryParams?: any,\n body?: any,\n authenticator?: any,\n options?: Partial<ITransportSettings>\n ): Promise<TSuccess> {\n options = options ? { ...this.options, ...options } : this.options;\n return this.hostConnection.stream(\n callback,\n method,\n path,\n body,\n queryParams,\n authenticator,\n options\n );\n }\n\n parseResponse<TSuccess, TError>(\n _raw: IRawResponse\n ): Promise<SDKResponse<TSuccess, TError>> {\n const result: SDKResponse<TSuccess, TError> = {\n ok: false,\n error: new Error('Should not be called!') as unknown as TError,\n };\n return Promise.resolve(result);\n }\n\n retry(_request: IRawRequest): Promise<IRawResponse> {\n // TODO implement this\n return Promise.reject(new Error('TODO: retry not implemented yet'));\n }\n}\n"],"mappings":";;;;;;;AAoEA,OAAO,MAAMA,kBAAkB,CAAuB;EACpDC,WAAWA,CACQC,OAA2B,EACpCC,cAA+B,EACvC;IAAA,KAFiBD,OAA2B,GAA3BA,OAA2B;IAAA,KACpCC,cAA+B,GAA/BA,cAA+B;IAAAC,eAAA;IAEvC,IAAI,CAACF,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,cAAc,GAAGA,cAAc;EACtC;EAIME,UAAUA,CACdC,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EACd;IAAA,IAAAS,KAAA;IAAA,OAAAC,iBAAA;MACvB,IAAMC,QAAQ,SAASF,KAAI,CAACR,cAAc,CAACE,UAAU,CACnDC,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbR,OACF,CAAC;MACD,OAAOS,KAAI,CAACG,QAAQ,GAAGH,KAAI,CAACG,QAAQ,CAACD,QAAQ,CAAC,GAAGA,QAAQ;IAAC;EAC5D;EAEME,OAAOA,CACXT,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EACG;IAAA,IAAAc,MAAA;IAAA,OAAAJ,iBAAA;MACxC,OAAOI,MAAI,CAACb,cAAc,CAACY,OAAO,CAChCT,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbR,OACF,CAAC;IAAC;EACJ;EAEMe,MAAMA,CACVC,QAA8C,EAC9CZ,MAAkB,EAClBC,IAAY,EACZC,WAAiB,EACjBC,IAAU,EACVC,aAAmB,EACnBR,OAAqC,EAClB;IAAA,IAAAiB,MAAA;IAAA,OAAAP,iBAAA;MACnBV,OAAO,GAAGA,OAAO,GAAAkB,aAAA,CAAAA,aAAA,KAAQD,MAAI,CAACjB,OAAO,GAAKA,OAAO,IAAKiB,MAAI,CAACjB,OAAO;MAClE,OAAOiB,MAAI,CAAChB,cAAc,CAACc,MAAM,CAC/BC,QAAQ,EACRZ,MAAM,EACNC,IAAI,EACJE,IAAI,EACJD,WAAW,EACXE,aAAa,EACbR,OACF,CAAC;IAAC;EACJ;EAEAmB,aAAaA,CACXC,IAAkB,EACsB;IACxC,IAAMC,MAAqC,GAAG;MAC5CC,EAAE,EAAE,KAAK;MACTC,KAAK,EAAE,IAAIC,KAAK,CAAC,uBAAuB;IAC1C,CAAC;IACD,OAAOC,OAAO,CAACC,OAAO,CAACL,MAAM,CAAC;EAChC;EAEAM,KAAKA,CAACC,QAAqB,EAAyB;IAElD,OAAOH,OAAO,CAACI,MAAM,CAAC,IAAIL,KAAK,CAAC,iCAAiC,CAAC,CAAC;EACrE;AACF"}
package/lib/esm/index.js CHANGED
@@ -1,237 +1,23 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _apiMethods = require("./apiMethods");
7
- Object.keys(_apiMethods).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _apiMethods[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function get() {
13
- return _apiMethods[key];
14
- }
15
- });
16
- });
17
- var _apiSettings = require("./apiSettings");
18
- Object.keys(_apiSettings).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _apiSettings[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function get() {
24
- return _apiSettings[key];
25
- }
26
- });
27
- });
28
- var _authSession = require("./authSession");
29
- Object.keys(_authSession).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _authSession[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function get() {
35
- return _authSession[key];
36
- }
37
- });
38
- });
39
- var _authToken = require("./authToken");
40
- Object.keys(_authToken).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _authToken[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function get() {
46
- return _authToken[key];
47
- }
48
- });
49
- });
50
- var _baseTransport = require("./baseTransport");
51
- Object.keys(_baseTransport).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _baseTransport[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function get() {
57
- return _baseTransport[key];
58
- }
59
- });
60
- });
61
- var _browserSession = require("./browserSession");
62
- Object.keys(_browserSession).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _browserSession[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function get() {
68
- return _browserSession[key];
69
- }
70
- });
71
- });
72
- var _browserServices = require("./browserServices");
73
- Object.keys(_browserServices).forEach(function (key) {
74
- if (key === "default" || key === "__esModule") return;
75
- if (key in exports && exports[key] === _browserServices[key]) return;
76
- Object.defineProperty(exports, key, {
77
- enumerable: true,
78
- get: function get() {
79
- return _browserServices[key];
80
- }
81
- });
82
- });
83
- var _browserTransport = require("./browserTransport");
84
- Object.keys(_browserTransport).forEach(function (key) {
85
- if (key === "default" || key === "__esModule") return;
86
- if (key in exports && exports[key] === _browserTransport[key]) return;
87
- Object.defineProperty(exports, key, {
88
- enumerable: true,
89
- get: function get() {
90
- return _browserTransport[key];
91
- }
92
- });
93
- });
94
- var _constants = require("./constants");
95
- Object.keys(_constants).forEach(function (key) {
96
- if (key === "default" || key === "__esModule") return;
97
- if (key in exports && exports[key] === _constants[key]) return;
98
- Object.defineProperty(exports, key, {
99
- enumerable: true,
100
- get: function get() {
101
- return _constants[key];
102
- }
103
- });
104
- });
105
- var _cryptoHash = require("./cryptoHash");
106
- Object.keys(_cryptoHash).forEach(function (key) {
107
- if (key === "default" || key === "__esModule") return;
108
- if (key in exports && exports[key] === _cryptoHash[key]) return;
109
- Object.defineProperty(exports, key, {
110
- enumerable: true,
111
- get: function get() {
112
- return _cryptoHash[key];
113
- }
114
- });
115
- });
116
- var _CSRFSession = require("./CSRFSession");
117
- Object.keys(_CSRFSession).forEach(function (key) {
118
- if (key === "default" || key === "__esModule") return;
119
- if (key in exports && exports[key] === _CSRFSession[key]) return;
120
- Object.defineProperty(exports, key, {
121
- enumerable: true,
122
- get: function get() {
123
- return _CSRFSession[key];
124
- }
125
- });
126
- });
127
- var _delimArray = require("./delimArray");
128
- Object.keys(_delimArray).forEach(function (key) {
129
- if (key === "default" || key === "__esModule") return;
130
- if (key in exports && exports[key] === _delimArray[key]) return;
131
- Object.defineProperty(exports, key, {
132
- enumerable: true,
133
- get: function get() {
134
- return _delimArray[key];
135
- }
136
- });
137
- });
138
- var _errorDoc = require("./errorDoc");
139
- Object.keys(_errorDoc).forEach(function (key) {
140
- if (key === "default" || key === "__esModule") return;
141
- if (key in exports && exports[key] === _errorDoc[key]) return;
142
- Object.defineProperty(exports, key, {
143
- enumerable: true,
144
- get: function get() {
145
- return _errorDoc[key];
146
- }
147
- });
148
- });
149
- var _extensionSession = require("./extensionSession");
150
- Object.keys(_extensionSession).forEach(function (key) {
151
- if (key === "default" || key === "__esModule") return;
152
- if (key in exports && exports[key] === _extensionSession[key]) return;
153
- Object.defineProperty(exports, key, {
154
- enumerable: true,
155
- get: function get() {
156
- return _extensionSession[key];
157
- }
158
- });
159
- });
160
- var _extensionTransport = require("./extensionTransport");
161
- Object.keys(_extensionTransport).forEach(function (key) {
162
- if (key === "default" || key === "__esModule") return;
163
- if (key in exports && exports[key] === _extensionTransport[key]) return;
164
- Object.defineProperty(exports, key, {
165
- enumerable: true,
166
- get: function get() {
167
- return _extensionTransport[key];
168
- }
169
- });
170
- });
171
- var _lookerSDKError = require("./lookerSDKError");
172
- Object.keys(_lookerSDKError).forEach(function (key) {
173
- if (key === "default" || key === "__esModule") return;
174
- if (key in exports && exports[key] === _lookerSDKError[key]) return;
175
- Object.defineProperty(exports, key, {
176
- enumerable: true,
177
- get: function get() {
178
- return _lookerSDKError[key];
179
- }
180
- });
181
- });
182
- var _oauthSession = require("./oauthSession");
183
- Object.keys(_oauthSession).forEach(function (key) {
184
- if (key === "default" || key === "__esModule") return;
185
- if (key in exports && exports[key] === _oauthSession[key]) return;
186
- Object.defineProperty(exports, key, {
187
- enumerable: true,
188
- get: function get() {
189
- return _oauthSession[key];
190
- }
191
- });
192
- });
193
- var _paging = require("./paging");
194
- Object.keys(_paging).forEach(function (key) {
195
- if (key === "default" || key === "__esModule") return;
196
- if (key in exports && exports[key] === _paging[key]) return;
197
- Object.defineProperty(exports, key, {
198
- enumerable: true,
199
- get: function get() {
200
- return _paging[key];
201
- }
202
- });
203
- });
204
- var _platformServices = require("./platformServices");
205
- Object.keys(_platformServices).forEach(function (key) {
206
- if (key === "default" || key === "__esModule") return;
207
- if (key in exports && exports[key] === _platformServices[key]) return;
208
- Object.defineProperty(exports, key, {
209
- enumerable: true,
210
- get: function get() {
211
- return _platformServices[key];
212
- }
213
- });
214
- });
215
- var _proxySession = require("./proxySession");
216
- Object.keys(_proxySession).forEach(function (key) {
217
- if (key === "default" || key === "__esModule") return;
218
- if (key in exports && exports[key] === _proxySession[key]) return;
219
- Object.defineProperty(exports, key, {
220
- enumerable: true,
221
- get: function get() {
222
- return _proxySession[key];
223
- }
224
- });
225
- });
226
- var _transport = require("./transport");
227
- Object.keys(_transport).forEach(function (key) {
228
- if (key === "default" || key === "__esModule") return;
229
- if (key in exports && exports[key] === _transport[key]) return;
230
- Object.defineProperty(exports, key, {
231
- enumerable: true,
232
- get: function get() {
233
- return _transport[key];
234
- }
235
- });
236
- });
1
+ export * from './apiMethods';
2
+ export * from './apiSettings';
3
+ export * from './authSession';
4
+ export * from './authToken';
5
+ export * from './baseTransport';
6
+ export * from './browserSession';
7
+ export * from './browserServices';
8
+ export * from './browserTransport';
9
+ export * from './constants';
10
+ export * from './cryptoHash';
11
+ export * from './CSRFSession';
12
+ export * from './delimArray';
13
+ export * from './errorDoc';
14
+ export * from './extensionSession';
15
+ export * from './extensionTransport';
16
+ export * from './lookerSDKError';
17
+ export * from './oauthSession';
18
+ export * from './paging';
19
+ export * from './platformServices';
20
+ export * from './proxySession';
21
+ export * from './sleep';
22
+ export * from './transport';
237
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './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"],"mappings":";;;;;AA0BA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nexport * from './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 './sleep';\nexport * from './transport';\n"],"mappings":"AA0BA,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,oBAAoB;AAClC,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,aAAa"}
@@ -1,35 +1,26 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.LookerSDKError = void 0;
7
1
  var _excluded = ["errors", "documentation_url"];
8
2
  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
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; }
10
- var LookerSDKError = (() => {
4
+ export var LookerSDKError = (() => {
11
5
  'use strict';
12
6
 
13
7
  var LookerSDKErrorConstructor = function LookerSDKError() {
14
- var _errors, _documentation_url;
15
- for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
16
- _ref[_key] = arguments[_key];
8
+ for (var _len = arguments.length, errorArguments = new Array(_len), _key = 0; _key < _len; _key++) {
9
+ errorArguments[_key] = arguments[_key];
17
10
  }
18
- var [message, _ref2 = {}, ...rest] = _ref;
11
+ var [message, _ref = {}, ...rest] = errorArguments;
19
12
  var {
20
13
  errors,
21
14
  documentation_url
22
- } = _ref2,
23
- errorOptions = _objectWithoutProperties(_ref2, _excluded);
24
- (_errors = errors) !== null && _errors !== void 0 ? _errors : errors = [];
25
- (_documentation_url = documentation_url) !== null && _documentation_url !== void 0 ? _documentation_url : documentation_url = '';
26
- var error = this ? new Error(message, errorOptions, ...rest) : Error(message, errorOptions, ...rest);
15
+ } = _ref,
16
+ errorOptions = _objectWithoutProperties(_ref, _excluded);
17
+ var error = new Error(message, errorOptions, ...rest);
27
18
  Object.setPrototypeOf(error, this ? Object.getPrototypeOf(this) : LookerSDKError.prototype);
28
19
  Object.defineProperty(error, 'message', {
29
20
  enumerable: true
30
21
  });
31
- error.errors = errors;
32
- error.documentation_url = documentation_url;
22
+ error.errors = errors !== null && errors !== void 0 ? errors : [];
23
+ error.documentation_url = documentation_url !== null && documentation_url !== void 0 ? documentation_url : '';
33
24
  return error;
34
25
  };
35
26
  Object.defineProperty(LookerSDKErrorConstructor, 'prototype', {
@@ -49,5 +40,4 @@ var LookerSDKError = (() => {
49
40
  });
50
41
  return LookerSDKErrorConstructor;
51
42
  })();
52
- exports.LookerSDKError = LookerSDKError;
53
43
  //# sourceMappingURL=lookerSDKError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lookerSDKError.js","names":["LookerSDKError","LookerSDKErrorConstructor","message","rest","errors","documentation_url","errorOptions","error","Error","Object","setPrototypeOf","getPrototypeOf","prototype","defineProperty","enumerable","value","create","constructor","writable","configurable","name"],"sources":["../../src/lookerSDKError.ts"],"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"],"mappings":";;;;;;;;;AAiFO,IAAMA,cAA0C,GACtC,CAAC,MAAM;EACpB,YAAY;;EACZ,IAAMC,yBAAyB,GAAG,SAASD,cAAc,GAkBvD;IAAA;IAAA;MAAA;IAAA;IAAA,IAhBG,CACDE,OAAO,EACP,QAII,CAAC,CAA2B,EAChC,GAAGC,IAAI,CACR;IAAA,IANC;QACEC,MAAM;QACNC;MAEF,CAAC;MADIC,YAAY;IAanB,WAAAF,MAAM,6CAANA,MAAM,GAAK,EAAE;IACb,sBAAAC,iBAAiB,mEAAjBA,iBAAiB,GAAK,EAAE;IAKxB,IAAME,KAAK,GAAG,IAAI,GACd,IAAIC,KAAK,CACPN,OAAO,EAIPI,YAAY,EACZ,GAAGH,IAAI,CACR,GACDK,KAAK,CACHN,OAAO,EAEPI,YAAY,EACZ,GAAGH,IAAI,CACR;IAMLM,MAAM,CAACC,cAAc,CACnBH,KAAK,EACL,IAAI,GAAGE,MAAM,CAACE,cAAc,CAAC,IAAI,CAAC,GAAGX,cAAc,CAACY,SAAS,CAC9D;IAMDH,MAAM,CAACI,cAAc,CAACN,KAAK,EAAE,SAAS,EAAE;MAAEO,UAAU,EAAE;IAAK,CAAC,CAAC;IAC3DP,KAAK,CAAoBH,MAAM,GAAGA,MAAM;IACxCG,KAAK,CAAoBF,iBAAiB,GAAGA,iBAAiB;IAEhE,OAAOE,KAAK;EACd,CAA+B;EAW/BE,MAAM,CAACI,cAAc,CACnBZ,yBAAyB,EACzB,WAAW,EAKX;IACEc,KAAK,EAAEN,MAAM,CAACO,MAAM,CAACR,KAAK,CAACI,SAAS,EAAE;MACpCK,WAAW,EAAE;QACXF,KAAK,EAAEd,yBAAyB;QAChCiB,QAAQ,EAAE,IAAI;QACdC,YAAY,EAAE;MAChB,CAAC;MACDC,IAAI,EAAE;QACJL,KAAK,EAAE,gBAAgB;QACvBG,QAAQ,EAAE,IAAI;QACdC,YAAY,EAAE;MAChB;IACF,CAAC,CAAC;IAKFD,QAAQ,EAAE;EACZ,CAAC,CACF;EAED,OAAOjB,yBAAyB;AAClC,CAAC,GAAG;AAAA"}
1
+ {"version":3,"file":"lookerSDKError.js","names":["LookerSDKError","LookerSDKErrorConstructor","_len","arguments","length","errorArguments","Array","_key","message","_ref","rest","errors","documentation_url","errorOptions","_objectWithoutProperties","_excluded","error","Error","Object","setPrototypeOf","getPrototypeOf","prototype","defineProperty","enumerable","value","create","constructor","writable","configurable","name"],"sources":["../../src/lookerSDKError.ts"],"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 ...errorArguments\n ) {\n const [\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 > = errorArguments;\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 // TODO resolve this parsing complaint\n // @ts-ignore-error\n const error = new 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\n // handle null in addition to undefined\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"],"mappings":";;;AAiFA,OAAO,IAAMA,cAA0C,GACrC,CAAC,MAAM;EACrB,YAAY;;EACZ,IAAMC,yBAAyB,GAAG,SAASD,cAAcA,CAAA,EAGvD;IAAA,SAAAE,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADGC,cAAc,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAdF,cAAc,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAEjB,IAAM,CACJC,OAAO,EACPC,IAAA,GAII,CAAC,CAA2B,EAChC,GAAGC,IAAI,CAQN,GAAGL,cAAc;IAAC,IAbnB;QACEM,MAAM;QACNC;MAEF,CAAC,GAAAH,IAAA;MADII,YAAY,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;IA2BnB,IAAMC,KAAK,GAAG,IAAIC,KAAK,CACrBT,OAAO,EAEPK,YAAY,EACZ,GAAGH,IACL,CAAC;IAMDQ,MAAM,CAACC,cAAc,CACnBH,KAAK,EACL,IAAI,GAAGE,MAAM,CAACE,cAAc,CAAC,IAAI,CAAC,GAAGpB,cAAc,CAACqB,SACtD,CAAC;IAMDH,MAAM,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