@nsshunt/stsconfig 1.25.156 → 1.25.157

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.
@@ -1,5 +1,23 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateWrapper = (obj, member, setter, getter) => ({
9
+ set _(value) {
10
+ __privateSet(obj, member, value, setter);
11
+ },
12
+ get _() {
13
+ return __privateGet(obj, member, getter);
14
+ }
15
+ });
16
+ var _options, _httpAgent, _httpsAgent, _agentResetInterval, _requestCount, _SetupResetInterval, _GetAgentOptions;
1
17
  import * as fs from "node:fs";
2
18
  import * as dotenv from "dotenv";
19
+ import http from "node:http";
20
+ import https from "node:https";
3
21
  function getDefaultExportFromCjs(x) {
4
22
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
5
23
  }
@@ -1648,9 +1666,106 @@ const envOptionsHandler = {
1648
1666
  }
1649
1667
  };
1650
1668
  const goptions = new Proxy(envOptions, envOptionsHandler);
1669
+ class AgentManager {
1670
+ constructor(agentManagerOptions) {
1671
+ __privateAdd(this, _options);
1672
+ __privateAdd(this, _httpAgent, null);
1673
+ __privateAdd(this, _httpsAgent, null);
1674
+ __privateAdd(this, _agentResetInterval, null);
1675
+ __privateAdd(this, _requestCount, 0);
1676
+ __privateAdd(this, _SetupResetInterval, () => {
1677
+ __privateSet(this, _agentResetInterval, setTimeout(() => {
1678
+ this.ResetAgent();
1679
+ __privateGet(this, _SetupResetInterval).call(this);
1680
+ }, __privateGet(this, _options).agentResetInterval).unref());
1681
+ });
1682
+ __privateAdd(this, _GetAgentOptions, (https2) => {
1683
+ let options;
1684
+ if (__privateGet(this, _options).agentOptions) {
1685
+ options = {
1686
+ keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
1687
+ maxSockets: __privateGet(this, _options).agentOptions.maxSockets,
1688
+ maxTotalSockets: __privateGet(this, _options).agentOptions.maxTotalSockets,
1689
+ maxFreeSockets: __privateGet(this, _options).agentOptions.maxFreeSockets,
1690
+ timeout: __privateGet(this, _options).agentOptions.timeout
1691
+ //@@ config
1692
+ };
1693
+ if (https2 === true) {
1694
+ options.rejectUnauthorized = __privateGet(this, _options).agentOptions.rejectUnauthorized;
1695
+ }
1696
+ } else {
1697
+ options = {
1698
+ keepAlive: process.env.NODE_ENV === "test" ? false : goptions.keepAlive,
1699
+ maxSockets: goptions.maxSockets,
1700
+ maxTotalSockets: goptions.maxTotalSockets,
1701
+ maxFreeSockets: goptions.maxFreeSockets,
1702
+ timeout: 3e4
1703
+ //@@ config
1704
+ };
1705
+ if (https2 === true) {
1706
+ options.rejectUnauthorized = goptions.isProduction;
1707
+ }
1708
+ }
1709
+ return options;
1710
+ });
1711
+ __privateSet(this, _options, agentManagerOptions);
1712
+ if (__privateGet(this, _options).agentResetInterval) {
1713
+ __privateGet(this, _SetupResetInterval).call(this);
1714
+ }
1715
+ }
1716
+ IncRequestCount() {
1717
+ __privateWrapper(this, _requestCount)._++;
1718
+ if (__privateGet(this, _options).agentResetCount) {
1719
+ if (__privateGet(this, _requestCount) % __privateGet(this, _options).agentResetCount === 0) {
1720
+ this.ResetAgent();
1721
+ }
1722
+ }
1723
+ }
1724
+ GetAgent(protocol) {
1725
+ if (protocol.toLowerCase().startsWith("https:")) {
1726
+ if (__privateGet(this, _httpsAgent) === null) {
1727
+ __privateSet(this, _httpsAgent, new https.Agent(__privateGet(this, _GetAgentOptions).call(this, true)));
1728
+ }
1729
+ return __privateGet(this, _httpsAgent);
1730
+ } else if (protocol.toLowerCase().startsWith("http:")) {
1731
+ if (__privateGet(this, _httpAgent) === null) {
1732
+ __privateSet(this, _httpAgent, new http.Agent(__privateGet(this, _GetAgentOptions).call(this, false)));
1733
+ }
1734
+ return __privateGet(this, _httpAgent);
1735
+ } else {
1736
+ return null;
1737
+ }
1738
+ }
1739
+ ResetAgent() {
1740
+ __privateSet(this, _httpAgent, null);
1741
+ __privateSet(this, _httpsAgent, null);
1742
+ }
1743
+ Terminate() {
1744
+ if (__privateGet(this, _agentResetInterval)) {
1745
+ clearTimeout(__privateGet(this, _agentResetInterval));
1746
+ __privateSet(this, _agentResetInterval, null);
1747
+ }
1748
+ if (__privateGet(this, _httpAgent)) {
1749
+ __privateGet(this, _httpAgent).destroy();
1750
+ __privateSet(this, _httpAgent, null);
1751
+ }
1752
+ if (__privateGet(this, _httpsAgent)) {
1753
+ __privateGet(this, _httpsAgent).destroy();
1754
+ __privateSet(this, _httpsAgent, null);
1755
+ }
1756
+ }
1757
+ }
1758
+ _options = new WeakMap();
1759
+ _httpAgent = new WeakMap();
1760
+ _httpsAgent = new WeakMap();
1761
+ _agentResetInterval = new WeakMap();
1762
+ _requestCount = new WeakMap();
1763
+ _SetupResetInterval = new WeakMap();
1764
+ _GetAgentOptions = new WeakMap();
1651
1765
  export {
1652
1766
  $ResetOptions,
1653
1767
  $ResetOptionsEx,
1768
+ AgentManager,
1654
1769
  goptions
1655
1770
  };
1656
1771
  //# sourceMappingURL=stsconfig.mjs.map