@looker/sdk-node 22.20.1 → 23.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [23.2.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-node-v23.0.0...sdk-node-v23.2.0) (2023-03-01)
9
+
10
+
11
+ ### Miscellaneous Chores
12
+
13
+ * **sdk-node:** Synchronize undefined versions
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @looker/sdk bumped from ^23.0.0 to ^23.2.0
21
+
22
+ ## [23.0.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-node-v22.20.1...sdk-node-v23.0.0) (2023-02-22)
23
+
24
+
25
+ ### Features
26
+
27
+ * keep all body parameters toggle in API Explorer requests ([#1245](https://github.com/looker-open-source/sdk-codegen/issues/1245)) ([043ed3f](https://github.com/looker-open-source/sdk-codegen/commit/043ed3ff12cba4f821604b5b668d7301ed4aa6d1))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @looker/sdk bumped from ^22.20.1 to ^23.0.0
35
+ * @looker/sdk-rtl bumped from ^21.5.0 to ^21.6.0
36
+
8
37
  ### [22.20.1](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-node-v22.20.0...sdk-node-v22.20.1) (2022-12-09)
9
38
 
10
39
 
@@ -433,4 +462,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
433
462
 
434
463
  ## [21.0.4]
435
464
 
436
- - introduces `@looker/node-sdk` for using the Looker TypeScript SDK with Node
465
+ - introduces `@looker/node-sdk` for using the Looker TypeScript SDK with Node
package/lib/esm/index.js CHANGED
@@ -1,6 +1,61 @@
1
- export * from './nodeServices';
2
- export * from './nodeSession';
3
- export * from './nodeSettings';
4
- export * from './nodeTransport';
5
- export * from './nodeSdk';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _nodeServices = require("./nodeServices");
7
+ Object.keys(_nodeServices).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _nodeServices[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _nodeServices[key];
14
+ }
15
+ });
16
+ });
17
+ var _nodeSession = require("./nodeSession");
18
+ Object.keys(_nodeSession).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _nodeSession[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _nodeSession[key];
25
+ }
26
+ });
27
+ });
28
+ var _nodeSettings = require("./nodeSettings");
29
+ Object.keys(_nodeSettings).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _nodeSettings[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _nodeSettings[key];
36
+ }
37
+ });
38
+ });
39
+ var _nodeTransport = require("./nodeTransport");
40
+ Object.keys(_nodeTransport).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _nodeTransport[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _nodeTransport[key];
47
+ }
48
+ });
49
+ });
50
+ var _nodeSdk = require("./nodeSdk");
51
+ Object.keys(_nodeSdk).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _nodeSdk[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _nodeSdk[key];
58
+ }
59
+ });
60
+ });
6
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":"AA2BA,cAAc,gBAAd;AACA,cAAc,eAAd;AACA,cAAc,gBAAd;AACA,cAAc,iBAAd;AACA,cAAc,WAAd","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\n// Version 21.0.4\nexport * from './nodeServices'\nexport * from './nodeSession'\nexport * from './nodeSettings'\nexport * from './nodeTransport'\nexport * from './nodeSdk'\n"],"file":"index.js"}
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\n// Version 21.0.4\nexport * from './nodeServices'\nexport * from './nodeSession'\nexport * from './nodeSettings'\nexport * from './nodeTransport'\nexport * from './nodeSdk'\n"],"mappings":";;;;;AA2BA;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,21 +1,25 @@
1
- import { Looker31SDK, Looker40SDK, environmentPrefix } from '@looker/sdk';
2
- import { NodeSettingsIniFile, NodeSession, NodeTransport } from '.';
3
- export class LookerNodeSDK {
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LookerNodeSDK = void 0;
7
+ var _sdk = require("@looker/sdk");
8
+ var _ = require(".");
9
+ class LookerNodeSDK {
4
10
  static init31(settings, transport, session) {
5
- settings = settings || new NodeSettingsIniFile(environmentPrefix);
6
- transport = transport || new NodeTransport(settings);
7
- session = session || new NodeSession(settings, transport);
8
- return new Looker31SDK(session);
11
+ settings = settings || new _.NodeSettingsIniFile(_sdk.environmentPrefix);
12
+ transport = transport || new _.NodeTransport(settings);
13
+ session = session || new _.NodeSession(settings, transport);
14
+ return new _sdk.Looker31SDK(session);
9
15
  }
10
-
11
16
  static init40(settings, transport, session) {
12
17
  var _session;
13
-
14
- settings = settings || new NodeSettingsIniFile(environmentPrefix);
15
- transport = transport || new NodeTransport(settings);
16
- session = (_session = session) !== null && _session !== void 0 ? _session : new NodeSession(settings, transport);
17
- return new Looker40SDK(session);
18
+ settings = settings || new _.NodeSettingsIniFile(_sdk.environmentPrefix);
19
+ transport = transport || new _.NodeTransport(settings);
20
+ session = (_session = session) !== null && _session !== void 0 ? _session : new _.NodeSession(settings, transport);
21
+ return new _sdk.Looker40SDK(session);
18
22
  }
19
-
20
23
  }
24
+ exports.LookerNodeSDK = LookerNodeSDK;
21
25
  //# sourceMappingURL=nodeSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/nodeSdk.ts"],"names":["Looker31SDK","Looker40SDK","environmentPrefix","NodeSettingsIniFile","NodeSession","NodeTransport","LookerNodeSDK","init31","settings","transport","session","init40"],"mappings":"AA2BA,SAASA,WAAT,EAAsBC,WAAtB,EAAmCC,iBAAnC,QAA4D,aAA5D;AACA,SAASC,mBAAT,EAA8BC,WAA9B,EAA2CC,aAA3C,QAAgE,GAAhE;AAQA,OAAO,MAAMC,aAAN,CAAoB;AAUZ,SAANC,MAAM,CACXC,QADW,EAEXC,SAFW,EAGXC,OAHW,EAIX;AACAF,IAAAA,QAAQ,GAAGA,QAAQ,IAAI,IAAIL,mBAAJ,CAAwBD,iBAAxB,CAAvB;AACAO,IAAAA,SAAS,GAAGA,SAAS,IAAI,IAAIJ,aAAJ,CAAkBG,QAAlB,CAAzB;AACAE,IAAAA,OAAO,GAAGA,OAAO,IAAI,IAAIN,WAAJ,CAAgBI,QAAhB,EAA0BC,SAA1B,CAArB;AACA,WAAO,IAAIT,WAAJ,CAAgBU,OAAhB,CAAP;AACD;;AAWY,SAANC,MAAM,CACXH,QADW,EAEXC,SAFW,EAGXC,OAHW,EAIX;AAAA;;AACAF,IAAAA,QAAQ,GAAGA,QAAQ,IAAI,IAAIL,mBAAJ,CAAwBD,iBAAxB,CAAvB;AACAO,IAAAA,SAAS,GAAGA,SAAS,IAAI,IAAIJ,aAAJ,CAAkBG,QAAlB,CAAzB;AACAE,IAAAA,OAAO,eAAGA,OAAH,+CAAc,IAAIN,WAAJ,CAAgBI,QAAhB,EAA0BC,SAA1B,CAArB;AACA,WAAO,IAAIR,WAAJ,CAAgBS,OAAhB,CAAP;AACD;;AAvCwB","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 { ITransport, IApiSettings, IAuthSession } from '@looker/sdk-rtl'\nimport { Looker31SDK, Looker40SDK, environmentPrefix } from '@looker/sdk'\nimport { NodeSettingsIniFile, NodeSession, NodeTransport } from '.'\n\n/**\n * @class LookerNodeSDK\n *\n * Simple factory for the Node version of the Looker SDK. Provides default connectivity for SDK methods\n *\n */\nexport class LookerNodeSDK {\n /**\n * Creates a [[Looker31SDK]] object.\n *\n * @param settings Defaults to the settings from LookerIni\n *\n * @param transport Defaults to a `NodeTransport` object\n *\n * @param session Defaults to `NodeSession` which logs in the user\n */\n static init31(\n settings?: IApiSettings,\n transport?: ITransport,\n session?: IAuthSession\n ) {\n settings = settings || new NodeSettingsIniFile(environmentPrefix)\n transport = transport || new NodeTransport(settings)\n session = session || new NodeSession(settings, transport)\n return new Looker31SDK(session)\n }\n\n /**\n * Creates a [[Looker40SDK]] object.\n *\n * @param settings Defaults to the settings from LookerIni\n *\n * @param transport Defaults to a `NodeTransport` object\n *\n * @param session Defaults to `NodeSession` which logs in the user\n */\n static init40(\n settings?: IApiSettings,\n transport?: ITransport,\n session?: IAuthSession\n ) {\n settings = settings || new NodeSettingsIniFile(environmentPrefix)\n transport = transport || new NodeTransport(settings)\n session = session ?? new NodeSession(settings, transport)\n return new Looker40SDK(session)\n }\n}\n"],"file":"nodeSdk.js"}
1
+ {"version":3,"file":"nodeSdk.js","names":["LookerNodeSDK","init31","settings","transport","session","NodeSettingsIniFile","environmentPrefix","NodeTransport","NodeSession","Looker31SDK","init40","Looker40SDK"],"sources":["../../src/nodeSdk.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 { ITransport, IApiSettings, IAuthSession } from '@looker/sdk-rtl'\nimport { Looker31SDK, Looker40SDK, environmentPrefix } from '@looker/sdk'\nimport { NodeSettingsIniFile, NodeSession, NodeTransport } from '.'\n\n/**\n * @class LookerNodeSDK\n *\n * Simple factory for the Node version of the Looker SDK. Provides default connectivity for SDK methods\n *\n */\nexport class LookerNodeSDK {\n /**\n * Creates a [[Looker31SDK]] object.\n *\n * @param settings Defaults to the settings from LookerIni\n *\n * @param transport Defaults to a `NodeTransport` object\n *\n * @param session Defaults to `NodeSession` which logs in the user\n */\n static init31(\n settings?: IApiSettings,\n transport?: ITransport,\n session?: IAuthSession\n ) {\n settings = settings || new NodeSettingsIniFile(environmentPrefix)\n transport = transport || new NodeTransport(settings)\n session = session || new NodeSession(settings, transport)\n return new Looker31SDK(session)\n }\n\n /**\n * Creates a [[Looker40SDK]] object.\n *\n * @param settings Defaults to the settings from LookerIni\n *\n * @param transport Defaults to a `NodeTransport` object\n *\n * @param session Defaults to `NodeSession` which logs in the user\n */\n static init40(\n settings?: IApiSettings,\n transport?: ITransport,\n session?: IAuthSession\n ) {\n settings = settings || new NodeSettingsIniFile(environmentPrefix)\n transport = transport || new NodeTransport(settings)\n session = session ?? new NodeSession(settings, transport)\n return new Looker40SDK(session)\n }\n}\n"],"mappings":";;;;;;AA2BA;AACA;AAQO,MAAMA,aAAa,CAAC;EAUzB,OAAOC,MAAM,CACXC,QAAuB,EACvBC,SAAsB,EACtBC,OAAsB,EACtB;IACAF,QAAQ,GAAGA,QAAQ,IAAI,IAAIG,qBAAmB,CAACC,sBAAiB,CAAC;IACjEH,SAAS,GAAGA,SAAS,IAAI,IAAII,eAAa,CAACL,QAAQ,CAAC;IACpDE,OAAO,GAAGA,OAAO,IAAI,IAAII,aAAW,CAACN,QAAQ,EAAEC,SAAS,CAAC;IACzD,OAAO,IAAIM,gBAAW,CAACL,OAAO,CAAC;EACjC;EAWA,OAAOM,MAAM,CACXR,QAAuB,EACvBC,SAAsB,EACtBC,OAAsB,EACtB;IAAA;IACAF,QAAQ,GAAGA,QAAQ,IAAI,IAAIG,qBAAmB,CAACC,sBAAiB,CAAC;IACjEH,SAAS,GAAGA,SAAS,IAAI,IAAII,eAAa,CAACL,QAAQ,CAAC;IACpDE,OAAO,eAAGA,OAAO,+CAAI,IAAII,aAAW,CAACN,QAAQ,EAAEC,SAAS,CAAC;IACzD,OAAO,IAAIQ,gBAAW,CAACP,OAAO,CAAC;EACjC;AACF;AAAC"}
@@ -1,25 +1,28 @@
1
- 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; }
1
+ "use strict";
2
2
 
3
- import { sdkError } from '@looker/sdk-rtl';
4
- import { NodeCryptoHash, NodeTransport } from './nodeTransport';
5
- export class NodeServices {
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeServices = void 0;
7
+ var _sdkRtl = require("@looker/sdk-rtl");
8
+ var _nodeTransport = require("./nodeTransport");
9
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
+ class NodeServices {
6
13
  constructor(services) {
7
14
  _defineProperty(this, "crypto", void 0);
8
-
9
15
  _defineProperty(this, "settings", void 0);
10
-
11
16
  _defineProperty(this, "transport", void 0);
12
-
13
17
  if (!services.settings) {
14
- throw sdkError({
18
+ throw (0, _sdkRtl.sdkError)({
15
19
  message: 'Missing required IApiSettings'
16
20
  });
17
21
  }
18
-
19
22
  this.settings = services.settings;
20
- this.transport = services.transport || new NodeTransport(this.settings);
21
- this.crypto = services.crypto || new NodeCryptoHash();
23
+ this.transport = services.transport || new _nodeTransport.NodeTransport(this.settings);
24
+ this.crypto = services.crypto || new _nodeTransport.NodeCryptoHash();
22
25
  }
23
-
24
26
  }
27
+ exports.NodeServices = NodeServices;
25
28
  //# sourceMappingURL=nodeServices.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/nodeServices.ts"],"names":["sdkError","NodeCryptoHash","NodeTransport","NodeServices","constructor","services","settings","message","transport","crypto"],"mappings":";;AAgCA,SAASA,QAAT,QAAyB,iBAAzB;AACA,SAASC,cAAT,EAAyBC,aAAzB,QAA8C,iBAA9C;AAEA,OAAO,MAAMC,YAAN,CAAgD;AAOrDC,EAAAA,WAAW,CAACC,QAAD,EAAuC;AAAA;;AAAA;;AAAA;;AAChD,QAAI,CAACA,QAAQ,CAACC,QAAd,EAAwB;AACtB,YAAMN,QAAQ,CAAC;AAAEO,QAAAA,OAAO,EAAE;AAAX,OAAD,CAAd;AACD;;AACD,SAAKD,QAAL,GAAgBD,QAAQ,CAACC,QAAzB;AACA,SAAKE,SAAL,GAAiBH,QAAQ,CAACG,SAAT,IAAsB,IAAIN,aAAJ,CAAkB,KAAKI,QAAvB,CAAvC;AACA,SAAKG,MAAL,GAAcJ,QAAQ,CAACI,MAAT,IAAmB,IAAIR,cAAJ,EAAjC;AACD;;AAdoD","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 ICryptoHash,\n IApiSettings,\n ITransport,\n IPlatformServices,\n} from '@looker/sdk-rtl'\nimport { sdkError } from '@looker/sdk-rtl'\nimport { NodeCryptoHash, NodeTransport } from './nodeTransport'\n\nexport class NodeServices implements IPlatformServices {\n /** Cryptography service interface */\n crypto: ICryptoHash\n /** SDK configuration interface */\n settings: IApiSettings\n transport: ITransport\n\n constructor(services: Partial<IPlatformServices>) {\n if (!services.settings) {\n throw sdkError({ message: 'Missing required IApiSettings' })\n }\n this.settings = services.settings\n this.transport = services.transport || new NodeTransport(this.settings)\n this.crypto = services.crypto || new NodeCryptoHash()\n }\n}\n"],"file":"nodeServices.js"}
1
+ {"version":3,"file":"nodeServices.js","names":["NodeServices","constructor","services","settings","sdkError","message","transport","NodeTransport","crypto","NodeCryptoHash"],"sources":["../../src/nodeServices.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 ICryptoHash,\n IApiSettings,\n ITransport,\n IPlatformServices,\n} from '@looker/sdk-rtl'\nimport { sdkError } from '@looker/sdk-rtl'\nimport { NodeCryptoHash, NodeTransport } from './nodeTransport'\n\nexport class NodeServices implements IPlatformServices {\n /** Cryptography service interface */\n crypto: ICryptoHash\n /** SDK configuration interface */\n settings: IApiSettings\n transport: ITransport\n\n constructor(services: Partial<IPlatformServices>) {\n if (!services.settings) {\n throw sdkError({ message: 'Missing required IApiSettings' })\n }\n this.settings = services.settings\n this.transport = services.transport || new NodeTransport(this.settings)\n this.crypto = services.crypto || new NodeCryptoHash()\n }\n}\n"],"mappings":";;;;;;AAgCA;AACA;AAA+D;AAAA;AAAA;AAExD,MAAMA,YAAY,CAA8B;EAOrDC,WAAW,CAACC,QAAoC,EAAE;IAAA;IAAA;IAAA;IAChD,IAAI,CAACA,QAAQ,CAACC,QAAQ,EAAE;MACtB,MAAM,IAAAC,gBAAQ,EAAC;QAAEC,OAAO,EAAE;MAAgC,CAAC,CAAC;IAC9D;IACA,IAAI,CAACF,QAAQ,GAAGD,QAAQ,CAACC,QAAQ;IACjC,IAAI,CAACG,SAAS,GAAGJ,QAAQ,CAACI,SAAS,IAAI,IAAIC,4BAAa,CAAC,IAAI,CAACJ,QAAQ,CAAC;IACvE,IAAI,CAACK,MAAM,GAAGN,QAAQ,CAACM,MAAM,IAAI,IAAIC,6BAAc,EAAE;EACvD;AACF;AAAC"}
@@ -1,80 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeSession = void 0;
7
+ var _sdkRtl = require("@looker/sdk-rtl");
8
+ var _nodeTransport = require("./nodeTransport");
1
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
-
3
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
-
5
- 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; }
6
-
7
- import { sdkError, encodeParams, AuthToken, AuthSession } from '@looker/sdk-rtl';
8
- import { NodeTransport } from './nodeTransport';
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
14
  var strPost = 'POST';
10
15
  var strDelete = 'DELETE';
11
- export class NodeSession extends AuthSession {
16
+ class NodeSession extends _sdkRtl.AuthSession {
12
17
  constructor(settings, transport) {
13
- super(settings, transport || new NodeTransport(settings));
18
+ super(settings, transport || new _nodeTransport.NodeTransport(settings));
14
19
  this.settings = settings;
15
-
16
20
  _defineProperty(this, "apiPath", '/api/4.0');
17
-
18
- _defineProperty(this, "_authToken", new AuthToken());
19
-
20
- _defineProperty(this, "_sudoToken", new AuthToken());
21
+ _defineProperty(this, "_authToken", new _sdkRtl.AuthToken());
22
+ _defineProperty(this, "_sudoToken", new _sdkRtl.AuthToken());
21
23
  }
22
-
23
24
  get activeToken() {
24
25
  if (this._sudoToken.access_token) {
25
26
  return this._sudoToken;
26
27
  }
27
-
28
28
  return this._authToken;
29
29
  }
30
-
31
30
  isAuthenticated() {
32
31
  var token = this.activeToken;
33
32
  if (!(token && token.access_token)) return false;
34
33
  return token.isActive();
35
34
  }
36
-
37
35
  authenticate(props) {
38
36
  var _this = this;
39
-
40
37
  return _asyncToGenerator(function* () {
41
38
  var token = yield _this.getToken();
42
-
43
39
  if (token && token.access_token) {
44
40
  props.headers.Authorization = "Bearer ".concat(token.access_token);
45
41
  }
46
-
47
42
  return props;
48
43
  })();
49
44
  }
50
-
51
45
  isSudo() {
52
46
  return !!this.sudoId && this._sudoToken.isActive();
53
47
  }
54
-
55
48
  getToken() {
56
49
  var _this2 = this;
57
-
58
50
  return _asyncToGenerator(function* () {
59
51
  if (!_this2.isAuthenticated()) {
60
52
  yield _this2.login();
61
53
  }
62
-
63
54
  return _this2.activeToken;
64
55
  })();
65
56
  }
66
-
67
57
  reset() {
68
58
  this.sudoId = '';
69
-
70
59
  this._authToken.reset();
71
-
72
60
  this._sudoToken.reset();
73
61
  }
74
-
75
62
  login(sudoId) {
76
63
  var _this3 = this;
77
-
78
64
  return _asyncToGenerator(function* () {
79
65
  if (sudoId || sudoId !== _this3.sudoId || !_this3.isAuthenticated()) {
80
66
  if (sudoId) {
@@ -83,125 +69,91 @@ export class NodeSession extends AuthSession {
83
69
  yield _this3._login();
84
70
  }
85
71
  }
86
-
87
72
  return _this3.activeToken;
88
73
  })();
89
74
  }
90
-
91
75
  logout() {
92
76
  var _this4 = this;
93
-
94
77
  return _asyncToGenerator(function* () {
95
78
  var result = false;
96
-
97
79
  if (_this4.isAuthenticated()) {
98
80
  result = yield _this4._logout();
99
81
  }
100
-
101
82
  return result;
102
83
  })();
103
84
  }
104
-
105
85
  sudoLogout() {
106
86
  var _this5 = this;
107
-
108
87
  return _asyncToGenerator(function* () {
109
88
  var result = false;
110
-
111
89
  if (_this5.isSudo()) {
112
90
  result = yield _this5.logout();
113
-
114
91
  _this5._sudoToken.reset();
115
92
  }
116
-
117
93
  return result;
118
94
  })();
119
95
  }
120
-
121
96
  _login(newId) {
122
97
  var _this6 = this;
123
-
124
98
  return _asyncToGenerator(function* () {
125
99
  yield _this6.sudoLogout();
126
-
127
100
  if (newId !== _this6.sudoId) {
128
101
  _this6.sudoId = newId || '';
129
102
  }
130
-
131
103
  if (!_this6._authToken.isActive()) {
132
104
  _this6.reset();
133
-
134
105
  var section = _this6.settings.readConfig();
135
-
136
106
  var clientId = section.client_id;
137
107
  var clientSecret = section.client_secret;
138
-
139
108
  if (!clientId || !clientSecret) {
140
- throw sdkError({
109
+ throw (0, _sdkRtl.sdkError)({
141
110
  message: 'API credentials client_id and/or client_secret are not set'
142
111
  });
143
112
  }
144
-
145
- var body = encodeParams({
113
+ var body = (0, _sdkRtl.encodeParams)({
146
114
  client_id: clientId,
147
115
  client_secret: clientSecret
148
116
  });
149
117
  var token = yield _this6.ok(_this6.transport.request(strPost, "".concat(_this6.apiPath, "/login"), undefined, body));
150
-
151
118
  _this6._authToken.setToken(token);
152
119
  }
153
-
154
120
  if (_this6.sudoId) {
155
121
  var _token = _this6.activeToken;
156
-
157
122
  var promise = _this6.transport.request(strPost, encodeURI("".concat(_this6.apiPath, "/login/").concat(newId)), null, null, init => {
158
123
  if (_token.access_token) {
159
124
  init.headers.Authorization = "Bearer ".concat(_token.access_token);
160
125
  }
161
-
162
126
  return init;
163
127
  }, _this6.settings);
164
-
165
128
  var accessToken = yield _this6.ok(promise);
166
-
167
129
  _this6._sudoToken.setToken(accessToken);
168
130
  }
169
-
170
131
  return _this6.activeToken;
171
132
  })();
172
133
  }
173
-
174
134
  _logout() {
175
135
  var _this7 = this;
176
-
177
136
  return _asyncToGenerator(function* () {
178
137
  var token = _this7.activeToken;
179
-
180
138
  var promise = _this7.transport.request(strDelete, "".concat(_this7.apiPath, "/logout"), null, null, init => {
181
139
  if (token.access_token) {
182
140
  init.headers.Authorization = "Bearer ".concat(token.access_token);
183
141
  }
184
-
185
142
  return init;
186
143
  }, _this7.settings);
187
-
188
144
  yield _this7.ok(promise);
189
-
190
145
  if (_this7.sudoId) {
191
146
  _this7.sudoId = '';
192
-
193
147
  _this7._sudoToken.reset();
194
-
195
148
  if (!_this7._authToken.isActive()) {
196
149
  yield _this7.login();
197
150
  }
198
151
  } else {
199
152
  _this7.reset();
200
153
  }
201
-
202
154
  return true;
203
155
  })();
204
156
  }
205
-
206
157
  }
158
+ exports.NodeSession = NodeSession;
207
159
  //# sourceMappingURL=nodeSession.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/nodeSession.ts"],"names":["sdkError","encodeParams","AuthToken","AuthSession","NodeTransport","strPost","strDelete","NodeSession","constructor","settings","transport","activeToken","_sudoToken","access_token","_authToken","isAuthenticated","token","isActive","authenticate","props","getToken","headers","Authorization","isSudo","sudoId","login","reset","_login","toString","logout","result","_logout","sudoLogout","newId","section","readConfig","clientId","client_id","clientSecret","client_secret","message","body","ok","request","apiPath","undefined","setToken","promise","enc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AACD;;AACD,iBAAOoC,IAAP;AACD,SAXa,EAYd,MAAI,CAACxC,QAZS,CAAhB;;AAeA,YAAMyC,WAAW,SAAS,MAAI,CAACR,EAAL,CAAQK,OAAR,CAA1B;;AAEA,QAAA,MAAI,CAACnC,UAAL,CAAgBkC,QAAhB,CAAyBI,WAAzB;AACD;;AAED,aAAO,MAAI,CAACvC,WAAZ;AA3DmC;AA4DpC;;AAEaoB,EAAAA,OAAO,GAAG;AAAA;;AAAA;AACtB,UAAMf,KAAK,GAAG,MAAI,CAACL,WAAnB;;AACA,UAAMoC,OAAO,GAAG,MAAI,CAACrC,SAAL,CAAeiC,OAAf,CACdrC,SADc,YAEX,MAAI,CAACsC,OAFM,cAGd,IAHc,EAId,IAJc,EAMbK,IAAD,IAAyB;AACvB,YAAIjC,KAAK,CAACH,YAAV,EAAwB;AACtBoC,UAAAA,IAAI,CAAC5B,OAAL,CAAaC,aAAb,oBAAuCN,KAAK,CAACH,YAA7C;AACD;;AACD,eAAOoC,IAAP;AACD,OAXa,EAYd,MAAI,CAACxC,QAZS,CAAhB;;AAeA,YAAM,MAAI,CAACiC,EAAL,CAAQK,OAAR,CAAN;;AAGA,UAAI,MAAI,CAACvB,MAAT,EAAiB;AAEf,QAAA,MAAI,CAACA,MAAL,GAAc,EAAd;;AACA,QAAA,MAAI,CAACZ,UAAL,CAAgBc,KAAhB;;AACA,YAAI,CAAC,MAAI,CAACZ,UAAL,CAAgBG,QAAhB,EAAL,EAAiC;AAC/B,gBAAM,MAAI,CAACQ,KAAL,EAAN;AACD;AACF,OAPD,MAOO;AAEL,QAAA,MAAI,CAACC,KAAL;AACD;;AACD,aAAO,IAAP;AA/BsB;AAgCvB;;AAtM0C","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 IRequestProps,\n ITransport,\n HttpMethod,\n IApiSettings,\n IAccessToken,\n IError,\n} from '@looker/sdk-rtl'\nimport { sdkError, encodeParams, AuthToken, AuthSession } from '@looker/sdk-rtl'\nimport { NodeTransport } from './nodeTransport'\n\nconst strPost: HttpMethod = 'POST'\nconst strDelete: HttpMethod = 'DELETE'\n\nexport class NodeSession extends AuthSession {\n private readonly apiPath: string = '/api/4.0'\n _authToken: AuthToken = new AuthToken()\n _sudoToken: AuthToken = new AuthToken()\n\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new NodeTransport(settings))\n }\n\n /**\n * Abstraction of AuthToken retrieval to support sudo mode\n */\n get activeToken() {\n if (this._sudoToken.access_token) {\n return this._sudoToken\n }\n return this._authToken\n }\n\n /**\n * Is there an active authentication token?\n */\n isAuthenticated() {\n // TODO I think this can be simplified\n const token = this.activeToken\n if (!(token && token.access_token)) return false\n return token.isActive()\n }\n\n /**\n * Add authentication data to the pending API request\n * @param props initialized API request properties\n *\n * @returns the updated request properties\n */\n async authenticate(props: IRequestProps) {\n const token = await this.getToken()\n if (token && token.access_token) {\n props.headers.Authorization = `Bearer ${token.access_token}`\n }\n return props\n }\n\n isSudo() {\n return !!this.sudoId && this._sudoToken.isActive()\n }\n\n /**\n * retrieve the current authentication token. If there is no active token, performs default\n * login to retrieve the token\n */\n async getToken() {\n if (!this.isAuthenticated()) {\n await this.login()\n }\n return this.activeToken\n }\n\n /**\n * Reset the authentication session\n */\n reset() {\n this.sudoId = ''\n this._authToken.reset()\n this._sudoToken.reset()\n }\n\n /**\n * Activate the authentication token for the API3 or sudo user\n * @param sudoId {string | number}: optional. If provided, impersonates the user specified\n *\n */\n async login(sudoId?: string | number) {\n if (sudoId || sudoId !== this.sudoId || !this.isAuthenticated()) {\n if (sudoId) {\n await this._login(sudoId.toString())\n } else {\n await this._login()\n }\n }\n return this.activeToken\n }\n\n /**\n * Logout the active user. If the active user is sudo, the session reverts to the API3 user\n */\n async logout() {\n let result = false\n if (this.isAuthenticated()) {\n result = await this._logout()\n }\n return result\n }\n\n private async sudoLogout() {\n let result = false\n if (this.isSudo()) {\n result = await this.logout() // Logout the current sudo\n this._sudoToken.reset()\n }\n return result\n }\n\n // internal login method that manages default auth token and sudo workflow\n private async _login(newId?: string) {\n // for linty freshness, always logout sudo if set\n await this.sudoLogout()\n\n if (newId !== this.sudoId) {\n // Assign new requested sudo id\n this.sudoId = newId || ''\n }\n\n if (!this._authToken.isActive()) {\n this.reset()\n // only retain client API3 credentials for the lifetime of the login request\n const section = this.settings.readConfig()\n const clientId = section.client_id\n const clientSecret = section.client_secret\n if (!clientId || !clientSecret) {\n throw sdkError({\n message: 'API credentials client_id and/or client_secret are not set',\n })\n }\n const body = encodeParams({\n client_id: clientId,\n client_secret: clientSecret,\n })\n // authenticate client\n const token = await this.ok(\n this.transport.request<IAccessToken, IError>(\n strPost,\n `${this.apiPath}/login`,\n undefined,\n body\n )\n )\n this._authToken.setToken(token)\n }\n\n if (this.sudoId) {\n // Use the API user auth to sudo\n const token = this.activeToken\n const promise = this.transport.request<IAccessToken, IError>(\n strPost,\n encodeURI(`${this.apiPath}/login/${newId}`),\n null,\n null,\n // ensure the auth token is included in the sudo request\n (init: IRequestProps) => {\n if (token.access_token) {\n init.headers.Authorization = `Bearer ${token.access_token}`\n }\n return init\n },\n this.settings // TODO this may not be needed here\n )\n\n const accessToken = await this.ok(promise)\n\n this._sudoToken.setToken(accessToken)\n }\n\n return this.activeToken\n }\n\n private async _logout() {\n const token = this.activeToken\n const promise = this.transport.request<string, IError>(\n strDelete,\n `${this.apiPath}/logout`,\n null,\n null,\n // ensure the auth token is included in the logout promise\n (init: IRequestProps) => {\n if (token.access_token) {\n init.headers.Authorization = `Bearer ${token.access_token}`\n }\n return init\n },\n this.settings\n )\n\n await this.ok(promise)\n\n // If no error was thrown, logout was successful\n if (this.sudoId) {\n // User was logged out, so set auth back to default\n this.sudoId = ''\n this._sudoToken.reset()\n if (!this._authToken.isActive()) {\n await this.login()\n }\n } else {\n // completely logged out\n this.reset()\n }\n return true\n }\n}\n"],"file":"nodeSession.js"}
1
+ {"version":3,"file":"nodeSession.js","names":["strPost","strDelete","NodeSession","AuthSession","constructor","settings","transport","NodeTransport","AuthToken","activeToken","_sudoToken","access_token","_authToken","isAuthenticated","token","isActive","authenticate","props","getToken","headers","Authorization","isSudo","sudoId","login","reset","_login","toString","logout","result","_logout","sudoLogout","newId","section","readConfig","clientId","client_id","clientSecret","client_secret","sdkError","message","body","encodeParams","ok","request","apiPath","undefined","setToken","promise","encodeURI","init","accessToken"],"sources":["../../src/nodeSession.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 IRequestProps,\n ITransport,\n HttpMethod,\n IApiSettings,\n IAccessToken,\n IError,\n} from '@looker/sdk-rtl'\nimport { sdkError, encodeParams, AuthToken, AuthSession } from '@looker/sdk-rtl'\nimport { NodeTransport } from './nodeTransport'\n\nconst strPost: HttpMethod = 'POST'\nconst strDelete: HttpMethod = 'DELETE'\n\nexport class NodeSession extends AuthSession {\n private readonly apiPath: string = '/api/4.0'\n _authToken: AuthToken = new AuthToken()\n _sudoToken: AuthToken = new AuthToken()\n\n constructor(public settings: IApiSettings, transport?: ITransport) {\n super(settings, transport || new NodeTransport(settings))\n }\n\n /**\n * Abstraction of AuthToken retrieval to support sudo mode\n */\n get activeToken() {\n if (this._sudoToken.access_token) {\n return this._sudoToken\n }\n return this._authToken\n }\n\n /**\n * Is there an active authentication token?\n */\n isAuthenticated() {\n // TODO I think this can be simplified\n const token = this.activeToken\n if (!(token && token.access_token)) return false\n return token.isActive()\n }\n\n /**\n * Add authentication data to the pending API request\n * @param props initialized API request properties\n *\n * @returns the updated request properties\n */\n async authenticate(props: IRequestProps) {\n const token = await this.getToken()\n if (token && token.access_token) {\n props.headers.Authorization = `Bearer ${token.access_token}`\n }\n return props\n }\n\n isSudo() {\n return !!this.sudoId && this._sudoToken.isActive()\n }\n\n /**\n * retrieve the current authentication token. If there is no active token, performs default\n * login to retrieve the token\n */\n async getToken() {\n if (!this.isAuthenticated()) {\n await this.login()\n }\n return this.activeToken\n }\n\n /**\n * Reset the authentication session\n */\n reset() {\n this.sudoId = ''\n this._authToken.reset()\n this._sudoToken.reset()\n }\n\n /**\n * Activate the authentication token for the API3 or sudo user\n * @param sudoId {string | number}: optional. If provided, impersonates the user specified\n *\n */\n async login(sudoId?: string | number) {\n if (sudoId || sudoId !== this.sudoId || !this.isAuthenticated()) {\n if (sudoId) {\n await this._login(sudoId.toString())\n } else {\n await this._login()\n }\n }\n return this.activeToken\n }\n\n /**\n * Logout the active user. If the active user is sudo, the session reverts to the API3 user\n */\n async logout() {\n let result = false\n if (this.isAuthenticated()) {\n result = await this._logout()\n }\n return result\n }\n\n private async sudoLogout() {\n let result = false\n if (this.isSudo()) {\n result = await this.logout() // Logout the current sudo\n this._sudoToken.reset()\n }\n return result\n }\n\n // internal login method that manages default auth token and sudo workflow\n private async _login(newId?: string) {\n // for linty freshness, always logout sudo if set\n await this.sudoLogout()\n\n if (newId !== this.sudoId) {\n // Assign new requested sudo id\n this.sudoId = newId || ''\n }\n\n if (!this._authToken.isActive()) {\n this.reset()\n // only retain client API3 credentials for the lifetime of the login request\n const section = this.settings.readConfig()\n const clientId = section.client_id\n const clientSecret = section.client_secret\n if (!clientId || !clientSecret) {\n throw sdkError({\n message: 'API credentials client_id and/or client_secret are not set',\n })\n }\n const body = encodeParams({\n client_id: clientId,\n client_secret: clientSecret,\n })\n // authenticate client\n const token = await this.ok(\n this.transport.request<IAccessToken, IError>(\n strPost,\n `${this.apiPath}/login`,\n undefined,\n body\n )\n )\n this._authToken.setToken(token)\n }\n\n if (this.sudoId) {\n // Use the API user auth to sudo\n const token = this.activeToken\n const promise = this.transport.request<IAccessToken, IError>(\n strPost,\n encodeURI(`${this.apiPath}/login/${newId}`),\n null,\n null,\n // ensure the auth token is included in the sudo request\n (init: IRequestProps) => {\n if (token.access_token) {\n init.headers.Authorization = `Bearer ${token.access_token}`\n }\n return init\n },\n this.settings // TODO this may not be needed here\n )\n\n const accessToken = await this.ok(promise)\n\n this._sudoToken.setToken(accessToken)\n }\n\n return this.activeToken\n }\n\n private async _logout() {\n const token = this.activeToken\n const promise = this.transport.request<string, IError>(\n strDelete,\n `${this.apiPath}/logout`,\n null,\n null,\n // ensure the auth token is included in the logout promise\n (init: IRequestProps) => {\n if (token.access_token) {\n init.headers.Authorization = `Bearer ${token.access_token}`\n }\n return init\n },\n this.settings\n )\n\n await this.ok(promise)\n\n // If no error was thrown, logout was successful\n if (this.sudoId) {\n // User was logged out, so set auth back to default\n this.sudoId = ''\n this._sudoToken.reset()\n if (!this._authToken.isActive()) {\n await this.login()\n }\n } else {\n // completely logged out\n this.reset()\n }\n return true\n }\n}\n"],"mappings":";;;;;;AAkCA;AACA;AAA+C;AAAA;AAAA;AAAA;AAAA;AAE/C,IAAMA,OAAmB,GAAG,MAAM;AAClC,IAAMC,SAAqB,GAAG,QAAQ;AAE/B,MAAMC,WAAW,SAASC,mBAAW,CAAC;EAK3CC,WAAW,CAAQC,QAAsB,EAAEC,SAAsB,EAAE;IACjE,KAAK,CAACD,QAAQ,EAAEC,SAAS,IAAI,IAAIC,4BAAa,CAACF,QAAQ,CAAC,CAAC;IAAA,KADxCA,QAAsB,GAAtBA,QAAsB;IAAA,iCAJN,UAAU;IAAA,oCACrB,IAAIG,iBAAS,EAAE;IAAA,oCACf,IAAIA,iBAAS,EAAE;EAIvC;EAKA,IAAIC,WAAW,GAAG;IAChB,IAAI,IAAI,CAACC,UAAU,CAACC,YAAY,EAAE;MAChC,OAAO,IAAI,CAACD,UAAU;IACxB;IACA,OAAO,IAAI,CAACE,UAAU;EACxB;EAKAC,eAAe,GAAG;IAEhB,IAAMC,KAAK,GAAG,IAAI,CAACL,WAAW;IAC9B,IAAI,EAAEK,KAAK,IAAIA,KAAK,CAACH,YAAY,CAAC,EAAE,OAAO,KAAK;IAChD,OAAOG,KAAK,CAACC,QAAQ,EAAE;EACzB;EAQMC,YAAY,CAACC,KAAoB,EAAE;IAAA;IAAA;MACvC,IAAMH,KAAK,SAAS,KAAI,CAACI,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