@withwiz/toolkit 0.6.1 → 0.6.2

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 (124) hide show
  1. package/dist/auth/config.d.ts +0 -3
  2. package/dist/auth/config.js +1 -1
  3. package/dist/auth/core/jwt/cookie.js +2 -2
  4. package/dist/auth/core/jwt/index.js +2 -2
  5. package/dist/auth/handlers/index.js +21 -21
  6. package/dist/auth/handlers/login.handler.js +3 -3
  7. package/dist/auth/handlers/logout.handler.js +3 -3
  8. package/dist/auth/handlers/me.handler.js +2 -2
  9. package/dist/auth/handlers/oauth-callback.handler.js +3 -3
  10. package/dist/auth/handlers/refresh.handler.js +3 -3
  11. package/dist/auth/index.js +2 -2
  12. package/dist/auth/services/index.js +10 -10
  13. package/dist/auth/services/login.service.js +2 -2
  14. package/dist/auth/services/oauth-callback.service.js +2 -2
  15. package/dist/auth/services/token-refresh.service.js +2 -2
  16. package/dist/cache/cache-config.js +4 -4
  17. package/dist/cache/cache-env.js +3 -3
  18. package/dist/cache/cache-factory.js +12 -12
  19. package/dist/cache/cache-invalidation.js +13 -13
  20. package/dist/cache/cache-redis.js +6 -6
  21. package/dist/cache/cache-wrapper.js +13 -13
  22. package/dist/cache/cache.js +14 -14
  23. package/dist/cache/config.d.ts +0 -14
  24. package/dist/cache/config.js +1 -1
  25. package/dist/cache/hybrid-cache-manager.js +8 -8
  26. package/dist/cache/index.js +14 -14
  27. package/dist/cache/inmemory-cache-manager.js +3 -3
  28. package/dist/cache/noop-cache-manager.js +5 -5
  29. package/dist/cache/redis-cache-manager.js +7 -7
  30. package/dist/{chunk-3ECJUXLM.js → chunk-2KG2G35D.js} +3 -3
  31. package/dist/{chunk-3AJHXCDG.js → chunk-34IDAA7V.js} +2 -2
  32. package/dist/{chunk-77BJRPMN.js → chunk-3LVCK2NQ.js} +4 -4
  33. package/dist/{chunk-W2GBKW2T.js → chunk-545Q34YU.js} +2 -2
  34. package/dist/{chunk-2VMTIYLX.js → chunk-7DMKTJHU.js} +2 -2
  35. package/dist/{chunk-O35V6RIF.js → chunk-7UQZH2OH.js} +3 -3
  36. package/dist/{chunk-7KZRPDQD.js → chunk-A6FKWYO2.js} +2 -2
  37. package/dist/{chunk-EXJQKCTN.js → chunk-A7TN46LC.js} +4 -4
  38. package/dist/{chunk-S7OQWKUJ.js → chunk-B6Q7UNCU.js} +1 -1
  39. package/dist/{chunk-AYZJN32D.js → chunk-CDLCZB6F.js} +10 -15
  40. package/dist/{chunk-SR3SQL72.js → chunk-CVFVL5FL.js} +2 -2
  41. package/dist/{chunk-Q6KXN7HL.js → chunk-ENETIGKL.js} +2 -2
  42. package/dist/{chunk-WNEXLSDB.js → chunk-ERO4PGNO.js} +1 -1
  43. package/dist/{chunk-BEV7PQM3.js → chunk-F3NGZYL2.js} +1 -1
  44. package/dist/chunk-FDFPNSKY.js +14 -0
  45. package/dist/{chunk-G5OMETUS.js → chunk-FDRQUDFH.js} +1 -1
  46. package/dist/{chunk-MGQV723O.js → chunk-L74XPPH4.js} +1 -1
  47. package/dist/{chunk-SSS6XSEG.js → chunk-LG6GH4V7.js} +1 -1
  48. package/dist/{chunk-HHCDMWEF.js → chunk-LGAV5UU2.js} +1 -1
  49. package/dist/{chunk-3CBGGMIY.js → chunk-LHIVUV7Q.js} +10 -15
  50. package/dist/{chunk-OHBAELPZ.js → chunk-LMQSV5UK.js} +15 -21
  51. package/dist/{chunk-A2XAOU55.js → chunk-LNPZZ23G.js} +13 -19
  52. package/dist/{chunk-X6MGVFT3.js → chunk-LRRQ54YJ.js} +1 -1
  53. package/dist/chunk-MGBNIDTP.js +100 -0
  54. package/dist/{chunk-PYVYYO4X.js → chunk-MULM3Q5S.js} +5 -5
  55. package/dist/{chunk-TEXVRHPF.js → chunk-NOAU2JG7.js} +1 -1
  56. package/dist/{chunk-WJSMXUZB.js → chunk-NQUYNPSD.js} +1 -1
  57. package/dist/{chunk-CKK55QFQ.js → chunk-NW3JIRFK.js} +1 -1
  58. package/dist/{chunk-FI46LV42.js → chunk-O5E36ZIJ.js} +1 -1
  59. package/dist/{chunk-DBHISLC6.js → chunk-OFSPZUQD.js} +2 -2
  60. package/dist/{chunk-WRWWB2NU.js → chunk-PT4FA7U4.js} +2 -2
  61. package/dist/{chunk-VCOA6LMN.js → chunk-QOKDGW3F.js} +1 -1
  62. package/dist/{chunk-OCI7QCLM.js → chunk-QXIQB6OF.js} +2 -2
  63. package/dist/{chunk-L5WLPC2T.js → chunk-QXPMO2CO.js} +1 -1
  64. package/dist/{chunk-LFKPXF5E.js → chunk-RXVX2DCW.js} +2 -2
  65. package/dist/{chunk-PAF5OGDU.js → chunk-SI2Z26KP.js} +7 -7
  66. package/dist/{chunk-4BGAE7NU.js → chunk-TLBY3DUK.js} +1 -1
  67. package/dist/{chunk-IHUQRVPV.js → chunk-UQM35MAO.js} +2 -2
  68. package/dist/{chunk-G2Q4TI3Q.js → chunk-V3ZIR4UL.js} +1 -1
  69. package/dist/{chunk-GFWGLWTS.js → chunk-WJWCTCWZ.js} +10 -15
  70. package/dist/{chunk-CMU52MEQ.js → chunk-WLXAEHKK.js} +2 -2
  71. package/dist/{chunk-SFPMFVSD.js → chunk-WPW4HXW4.js} +9 -15
  72. package/dist/{chunk-ON7HZ3PW.js → chunk-WSXOKK6N.js} +1 -1
  73. package/dist/{chunk-MDTID4D2.js → chunk-XY3ZVORI.js} +1 -1
  74. package/dist/{chunk-KF3O2DAV.js → chunk-YTXCKIWE.js} +1 -1
  75. package/dist/{chunk-7JKZBEVB.js → chunk-YX3XMDDI.js} +8 -8
  76. package/dist/{chunk-CW3INZMV.js → chunk-ZG2XGO44.js} +1 -1
  77. package/dist/config/common.d.ts +0 -3
  78. package/dist/config/common.js +1 -1
  79. package/dist/config/registry.d.ts +5 -13
  80. package/dist/config/registry.js +1 -1
  81. package/dist/constants/index.js +14 -14
  82. package/dist/error/error-handler.js +3 -3
  83. package/dist/error/index.js +3 -3
  84. package/dist/geolocation/batch-processor.js +3 -3
  85. package/dist/geolocation/config.d.ts +0 -3
  86. package/dist/geolocation/config.js +1 -1
  87. package/dist/geolocation/index.js +7 -7
  88. package/dist/geolocation/providers/index.js +4 -4
  89. package/dist/geolocation/providers/ipgeolocation-provider.js +2 -2
  90. package/dist/geolocation/providers/maxmind-provider.js +2 -2
  91. package/dist/initialize.d.ts +2 -1
  92. package/dist/initialize.js +18 -17
  93. package/dist/logger/config.d.ts +0 -3
  94. package/dist/logger/config.js +1 -1
  95. package/dist/logger/logger.js +2 -2
  96. package/dist/middleware/auth.js +5 -5
  97. package/dist/middleware/cors-config.d.ts +0 -3
  98. package/dist/middleware/cors-config.js +1 -1
  99. package/dist/middleware/cors.js +4 -4
  100. package/dist/middleware/error-handler.js +4 -4
  101. package/dist/middleware/index.js +14 -14
  102. package/dist/middleware/middleware-chain.js +3 -3
  103. package/dist/middleware/rate-limit.js +3 -3
  104. package/dist/middleware/response-logger.js +3 -3
  105. package/dist/middleware/security.js +3 -3
  106. package/dist/middleware/wrappers.js +14 -14
  107. package/dist/storage/config.d.ts +0 -3
  108. package/dist/storage/config.js +1 -1
  109. package/dist/storage/r2-storage.js +1 -1
  110. package/dist/system/cpu.js +4 -4
  111. package/dist/system/disk.js +4 -4
  112. package/dist/system/environment.js +8 -8
  113. package/dist/system/health-check.js +5 -5
  114. package/dist/system/index.js +13 -13
  115. package/dist/system/memory.js +4 -4
  116. package/dist/system/network.js +4 -4
  117. package/dist/system/utils.js +3 -3
  118. package/dist/utils/cors.js +3 -3
  119. package/dist/utils/csv-export.js +3 -3
  120. package/dist/utils/error-processor.js +3 -3
  121. package/dist/utils/index.js +15 -15
  122. package/package.json +1 -1
  123. package/dist/chunk-GTPUVHSV.js +0 -30
  124. package/dist/chunk-UCIUAZQT.js +0 -106
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  InMemoryCacheManager
3
- } from "../chunk-CW3INZMV.js";
4
- import "../chunk-TEXVRHPF.js";
3
+ } from "../chunk-ZG2XGO44.js";
4
+ import "../chunk-NOAU2JG7.js";
5
5
  import "../chunk-SS56XFLI.js";
6
- import "../chunk-OHBAELPZ.js";
6
+ import "../chunk-LMQSV5UK.js";
7
7
  import "../chunk-K25ICPU4.js";
8
8
  import "../chunk-2QH66EVQ.js";
9
9
  import "../chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  NoopCacheManager
3
- } from "../chunk-Q6KXN7HL.js";
4
- import "../chunk-BEV7PQM3.js";
5
- import "../chunk-DBHISLC6.js";
6
- import "../chunk-SFPMFVSD.js";
7
- import "../chunk-UCIUAZQT.js";
3
+ } from "../chunk-ENETIGKL.js";
4
+ import "../chunk-F3NGZYL2.js";
5
+ import "../chunk-OFSPZUQD.js";
6
+ import "../chunk-WPW4HXW4.js";
7
+ import "../chunk-MGBNIDTP.js";
8
8
  import "../chunk-K25ICPU4.js";
9
9
  import "../chunk-2QH66EVQ.js";
10
10
  import "../chunk-57W32BFZ.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  RedisCacheManager
3
- } from "../chunk-O35V6RIF.js";
4
- import "../chunk-IHUQRVPV.js";
5
- import "../chunk-TEXVRHPF.js";
6
- import "../chunk-OHBAELPZ.js";
7
- import "../chunk-DBHISLC6.js";
8
- import "../chunk-SFPMFVSD.js";
9
- import "../chunk-UCIUAZQT.js";
3
+ } from "../chunk-7UQZH2OH.js";
4
+ import "../chunk-UQM35MAO.js";
5
+ import "../chunk-NOAU2JG7.js";
6
+ import "../chunk-LMQSV5UK.js";
7
+ import "../chunk-OFSPZUQD.js";
8
+ import "../chunk-WPW4HXW4.js";
9
+ import "../chunk-MGBNIDTP.js";
10
10
  import "../chunk-K25ICPU4.js";
11
11
  import "../chunk-2QH66EVQ.js";
12
12
  import "../chunk-57W32BFZ.js";
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-YUBXS7YI.js";
5
5
  import {
6
6
  getPlatform
7
- } from "./chunk-X6MGVFT3.js";
7
+ } from "./chunk-LRRQ54YJ.js";
8
8
  import {
9
9
  logger
10
- } from "./chunk-TEXVRHPF.js";
10
+ } from "./chunk-NOAU2JG7.js";
11
11
  import {
12
12
  getResolvedCacheConfig
13
- } from "./chunk-UCIUAZQT.js";
13
+ } from "./chunk-MGBNIDTP.js";
14
14
 
15
15
  // src/system/health-check.ts
16
16
  async function checkServiceHealth(prismaClient) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-X6MGVFT3.js";
4
+ } from "./chunk-LRRQ54YJ.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-TEXVRHPF.js";
7
+ } from "./chunk-NOAU2JG7.js";
8
8
 
9
9
  // src/system/memory.ts
10
10
  import os from "os";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  getCacheManager,
3
3
  getEffectiveCacheBackend
4
- } from "./chunk-7JKZBEVB.js";
4
+ } from "./chunk-YX3XMDDI.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-TEXVRHPF.js";
7
+ } from "./chunk-NOAU2JG7.js";
8
8
  import {
9
9
  getCacheConfig,
10
10
  getCacheTTL
11
- } from "./chunk-BEV7PQM3.js";
11
+ } from "./chunk-F3NGZYL2.js";
12
12
  import {
13
13
  isCacheEnabled
14
- } from "./chunk-DBHISLC6.js";
14
+ } from "./chunk-OFSPZUQD.js";
15
15
 
16
16
  // src/cache/cache-wrapper.ts
17
17
  function getCacheBackendLabel() {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-X6MGVFT3.js";
4
+ } from "./chunk-LRRQ54YJ.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-TEXVRHPF.js";
7
+ } from "./chunk-NOAU2JG7.js";
8
8
 
9
9
  // src/system/disk.ts
10
10
  async function getDiskInfo() {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCorsConfig
3
- } from "./chunk-GFWGLWTS.js";
3
+ } from "./chunk-WJWCTCWZ.js";
4
4
  import {
5
5
  getCommonConfig
6
- } from "./chunk-SFPMFVSD.js";
6
+ } from "./chunk-WPW4HXW4.js";
7
7
  import {
8
8
  __spreadValues
9
9
  } from "./chunk-ORMEWXMH.js";
@@ -3,14 +3,14 @@ import {
3
3
  isRedisGloballyDisabled,
4
4
  notifyRedisError,
5
5
  resetRedisGlobalState
6
- } from "./chunk-IHUQRVPV.js";
6
+ } from "./chunk-UQM35MAO.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-TEXVRHPF.js";
9
+ } from "./chunk-NOAU2JG7.js";
10
10
  import {
11
11
  getENV,
12
12
  isCacheEnabled
13
- } from "./chunk-DBHISLC6.js";
13
+ } from "./chunk-OFSPZUQD.js";
14
14
  import {
15
15
  __spreadValues
16
16
  } from "./chunk-ORMEWXMH.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCorsConfig
3
- } from "./chunk-GFWGLWTS.js";
3
+ } from "./chunk-WJWCTCWZ.js";
4
4
  import {
5
5
  logger
6
- } from "./chunk-TEXVRHPF.js";
6
+ } from "./chunk-NOAU2JG7.js";
7
7
 
8
8
  // src/middleware/cors.ts
9
9
  import { NextResponse } from "next/server";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  isRedisGloballyDisabled,
3
3
  notifyRedisError
4
- } from "./chunk-IHUQRVPV.js";
4
+ } from "./chunk-UQM35MAO.js";
5
5
  import {
6
6
  InMemoryCacheManager
7
- } from "./chunk-CW3INZMV.js";
7
+ } from "./chunk-ZG2XGO44.js";
8
8
  import {
9
9
  logger
10
- } from "./chunk-TEXVRHPF.js";
10
+ } from "./chunk-NOAU2JG7.js";
11
11
  import {
12
12
  getCacheFallbackConfig
13
- } from "./chunk-DBHISLC6.js";
13
+ } from "./chunk-OFSPZUQD.js";
14
14
  import {
15
15
  __spreadValues
16
16
  } from "./chunk-ORMEWXMH.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-HZLJYEOO.js";
7
7
  import {
8
8
  setTokenCookies
9
- } from "./chunk-G2Q4TI3Q.js";
9
+ } from "./chunk-V3ZIR4UL.js";
10
10
  import {
11
11
  AuthError
12
12
  } from "./chunk-AIH3F7JV.js";
@@ -6,36 +6,31 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/storage/config.ts
9
- var GLOBAL_KEY = "__withwiz_storage_config";
10
- function getConfig() {
11
- var _a;
12
- return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
13
- }
14
- function setConfig(config) {
15
- globalThis[GLOBAL_KEY] = config;
16
- }
17
9
  function initializeStorage(config) {
18
- if (getConfig()) return;
10
+ var _a;
11
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
12
+ if (globalThis.__withwiz_config.storage) return;
19
13
  if (!config.accountId) throw new ConfigurationError("Storage", "accountId is required");
20
14
  if (!config.accessKeyId) throw new ConfigurationError("Storage", "accessKeyId is required");
21
15
  if (!config.secretAccessKey) throw new ConfigurationError("Storage", "secretAccessKey is required");
22
16
  if (!config.bucketName) throw new ConfigurationError("Storage", "bucketName is required");
23
17
  if (config.publicUrl === void 0) configWarn("Storage", "publicUrl not provided");
24
- setConfig({
18
+ globalThis.__withwiz_config.storage = {
25
19
  accountId: config.accountId,
26
20
  accessKeyId: config.accessKeyId,
27
21
  secretAccessKey: config.secretAccessKey,
28
22
  bucketName: config.bucketName,
29
23
  publicUrl: config.publicUrl
30
- });
24
+ };
31
25
  }
32
26
  function getStorageConfig() {
33
- const config = getConfig();
34
- if (!config) throw new ConfigurationError("Storage", "Not initialized. Call initializeStorage() first.");
35
- return config;
27
+ var _a;
28
+ const storage = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.storage;
29
+ if (!storage) throw new ConfigurationError("Storage", "Not initialized. Call initializeStorage() first.");
30
+ return storage;
36
31
  }
37
32
  function resetStorage() {
38
- globalThis[GLOBAL_KEY] = void 0;
33
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.storage;
39
34
  }
40
35
 
41
36
  export {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-X6MGVFT3.js";
4
+ } from "./chunk-LRRQ54YJ.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-TEXVRHPF.js";
7
+ } from "./chunk-NOAU2JG7.js";
8
8
 
9
9
  // src/system/cpu.ts
10
10
  import os from "os";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCacheConfig
3
- } from "./chunk-BEV7PQM3.js";
3
+ } from "./chunk-F3NGZYL2.js";
4
4
  import {
5
5
  getENV
6
- } from "./chunk-DBHISLC6.js";
6
+ } from "./chunk-OFSPZUQD.js";
7
7
 
8
8
  // src/cache/noop-cache-manager.ts
9
9
  var NoopCacheManager = class {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearTokenCookies
3
- } from "./chunk-G2Q4TI3Q.js";
3
+ } from "./chunk-V3ZIR4UL.js";
4
4
 
5
5
  // src/auth/handlers/logout.handler.ts
6
6
  import { NextResponse } from "next/server";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getENV,
3
3
  isCacheEnabled
4
- } from "./chunk-DBHISLC6.js";
4
+ } from "./chunk-OFSPZUQD.js";
5
5
 
6
6
  // src/cache/cache-config.ts
7
7
  var getCacheConfig = {
@@ -0,0 +1,14 @@
1
+ // src/config/registry.ts
2
+ var _a;
3
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
4
+ var config = globalThis.__withwiz_config;
5
+ function resetConfig() {
6
+ for (const key of Object.keys(globalThis.__withwiz_config)) {
7
+ delete globalThis.__withwiz_config[key];
8
+ }
9
+ }
10
+
11
+ export {
12
+ config,
13
+ resetConfig
14
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-AHDPGRXS.js";
4
4
  import {
5
5
  getGeolocationConfig
6
- } from "./chunk-3CBGGMIY.js";
6
+ } from "./chunk-LHIVUV7Q.js";
7
7
 
8
8
  // src/geolocation/providers/maxmind-provider.ts
9
9
  var MaxMindProvider = class extends BaseGeoIPProvider {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-3GAY2T2A.js";
4
4
  import {
5
5
  setTokenCookies
6
- } from "./chunk-G2Q4TI3Q.js";
6
+ } from "./chunk-V3ZIR4UL.js";
7
7
  import {
8
8
  AuthError
9
9
  } from "./chunk-AIH3F7JV.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-TEXVRHPF.js";
3
+ } from "./chunk-NOAU2JG7.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AHDPGRXS.js";
5
5
  import {
6
6
  getGeolocationConfig
7
- } from "./chunk-3CBGGMIY.js";
7
+ } from "./chunk-LHIVUV7Q.js";
8
8
 
9
9
  // src/geolocation/providers/ipgeolocation-provider.ts
10
10
  var IPGeolocationProvider = class extends BaseGeoIPProvider {
@@ -6,30 +6,25 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/geolocation/config.ts
9
- var GLOBAL_KEY = "__withwiz_geolocation_config";
10
- function getConfig() {
11
- var _a;
12
- return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
13
- }
14
- function setConfig(config) {
15
- globalThis[GLOBAL_KEY] = config;
16
- }
17
9
  function initializeGeolocation(config) {
18
- if (getConfig()) return;
10
+ var _a;
11
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
12
+ if (globalThis.__withwiz_config.geolocation) return;
19
13
  if (!config.ipgeolocationApiKey) configWarn("Geolocation", "ipgeolocationApiKey not provided, IPGeolocation provider will be unavailable");
20
14
  if (!config.maxmindLicenseKey) configWarn("Geolocation", "maxmindLicenseKey not provided, MaxMind provider will be unavailable");
21
- setConfig({
15
+ globalThis.__withwiz_config.geolocation = {
22
16
  ipgeolocationApiKey: config.ipgeolocationApiKey,
23
17
  maxmindLicenseKey: config.maxmindLicenseKey
24
- });
18
+ };
25
19
  }
26
20
  function getGeolocationConfig() {
27
- const config = getConfig();
28
- if (!config) throw new ConfigurationError("Geolocation", "Not initialized. Call initializeGeolocation() first.");
29
- return config;
21
+ var _a;
22
+ const geo = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.geolocation;
23
+ if (!geo) throw new ConfigurationError("Geolocation", "Not initialized. Call initializeGeolocation() first.");
24
+ return geo;
30
25
  }
31
26
  function resetGeolocation() {
32
- globalThis[GLOBAL_KEY] = void 0;
27
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.geolocation;
33
28
  }
34
29
 
35
30
  export {
@@ -6,37 +6,31 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/logger/config.ts
9
- var GLOBAL_KEY = "__withwiz_logger_config";
10
- function getConfig() {
11
- var _a;
12
- return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
13
- }
14
- function setConfig(config) {
15
- globalThis[GLOBAL_KEY] = config;
16
- }
17
9
  function initializeLogger(config) {
18
- var _a, _b, _c, _d, _e;
19
- if (getConfig()) return;
10
+ var _a, _b, _c, _d, _e, _f;
11
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
12
+ if (globalThis.__withwiz_config.logger) return;
20
13
  if (config.level === void 0) configWarn("Logger", "level not provided, using default: info");
21
14
  if (config.dir === void 0) configWarn("Logger", "dir not provided, using default: ./logs");
22
15
  if (config.file === void 0) configWarn("Logger", "file not provided, using default: app.log");
23
16
  if (config.fileEnabled === void 0) configWarn("Logger", "fileEnabled not provided, using default: true");
24
17
  if (config.consoleEnabled === void 0) configWarn("Logger", "consoleEnabled not provided, using default: true");
25
- setConfig({
26
- level: (_a = config.level) != null ? _a : "info",
27
- dir: (_b = config.dir) != null ? _b : "./logs",
28
- file: (_c = config.file) != null ? _c : "app.log",
29
- fileEnabled: (_d = config.fileEnabled) != null ? _d : true,
30
- consoleEnabled: (_e = config.consoleEnabled) != null ? _e : true
31
- });
18
+ globalThis.__withwiz_config.logger = {
19
+ level: (_b = config.level) != null ? _b : "info",
20
+ dir: (_c = config.dir) != null ? _c : "./logs",
21
+ file: (_d = config.file) != null ? _d : "app.log",
22
+ fileEnabled: (_e = config.fileEnabled) != null ? _e : true,
23
+ consoleEnabled: (_f = config.consoleEnabled) != null ? _f : true
24
+ };
32
25
  }
33
26
  function getLoggerConfig() {
34
- const config = getConfig();
35
- if (!config) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
36
- return config;
27
+ var _a;
28
+ const logger = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.logger;
29
+ if (!logger) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
30
+ return logger;
37
31
  }
38
32
  function resetLogger() {
39
- globalThis[GLOBAL_KEY] = void 0;
33
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.logger;
40
34
  }
41
35
 
42
36
  export {
@@ -6,17 +6,10 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/auth/config.ts
9
- var GLOBAL_KEY = "__withwiz_auth_config";
10
- function getConfig() {
11
- var _a;
12
- return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
13
- }
14
- function setConfig(config) {
15
- globalThis[GLOBAL_KEY] = config;
16
- }
17
9
  function initializeAuth(config) {
18
- var _a, _b, _c;
19
- if (getConfig()) return;
10
+ var _a, _b, _c, _d;
11
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
12
+ if (globalThis.__withwiz_config.auth) return;
20
13
  if (!config.jwtSecret) {
21
14
  throw new ConfigurationError("Auth", "jwtSecret is required");
22
15
  }
@@ -26,22 +19,23 @@ function initializeAuth(config) {
26
19
  if (!config.refreshTokenExpiry) {
27
20
  configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
28
21
  }
29
- setConfig({
22
+ globalThis.__withwiz_config.auth = {
30
23
  jwtSecret: config.jwtSecret,
31
- accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
32
- refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d",
33
- cookieSecure: (_c = config.cookieSecure) != null ? _c : false
34
- });
24
+ accessTokenExpiry: (_b = config.accessTokenExpiry) != null ? _b : "7d",
25
+ refreshTokenExpiry: (_c = config.refreshTokenExpiry) != null ? _c : "30d",
26
+ cookieSecure: (_d = config.cookieSecure) != null ? _d : false
27
+ };
35
28
  }
36
29
  function getAuthConfig() {
37
- const config = getConfig();
38
- if (!config) {
30
+ var _a;
31
+ const auth = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.auth;
32
+ if (!auth) {
39
33
  throw new ConfigurationError("Auth", "Not initialized. Call initializeAuth() first.");
40
34
  }
41
- return config;
35
+ return auth;
42
36
  }
43
37
  function resetAuth() {
44
- globalThis[GLOBAL_KEY] = void 0;
38
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.auth;
45
39
  }
46
40
 
47
41
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-TEXVRHPF.js";
3
+ } from "./chunk-NOAU2JG7.js";
4
4
 
5
5
  // src/system/utils.ts
6
6
  import { exec } from "child_process";
@@ -0,0 +1,100 @@
1
+ import {
2
+ ConfigurationError
3
+ } from "./chunk-2QH66EVQ.js";
4
+ import {
5
+ CACHE_DURATION_DEFAULTS,
6
+ CACHE_FALLBACK_DEFAULTS,
7
+ CACHE_HEALTH_DEFAULTS,
8
+ CACHE_TTL_DEFAULTS,
9
+ INMEMORY_CACHE_DEFAULTS
10
+ } from "./chunk-57W32BFZ.js";
11
+ import {
12
+ __spreadValues
13
+ } from "./chunk-ORMEWXMH.js";
14
+
15
+ // src/cache/config.ts
16
+ function initializeCache(input) {
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __;
18
+ (_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
19
+ if (globalThis.__withwiz_config.cache) return;
20
+ if (input.redis !== void 0) {
21
+ if (!input.redis.url) {
22
+ throw new ConfigurationError("cache", "redis.url is required");
23
+ }
24
+ if (!input.redis.token) {
25
+ throw new ConfigurationError("cache", "redis.token is required");
26
+ }
27
+ }
28
+ const defaultCategories = {};
29
+ for (const [key, duration] of Object.entries(CACHE_DURATION_DEFAULTS)) {
30
+ defaultCategories[key] = { enabled: true, duration };
31
+ }
32
+ const mergedCategories = __spreadValues({}, defaultCategories);
33
+ if (input.categories) {
34
+ for (const [key, value] of Object.entries(input.categories)) {
35
+ if (value !== void 0) {
36
+ mergedCategories[key] = {
37
+ enabled: (_b = value.enabled) != null ? _b : true,
38
+ duration: (_e = (_d = value.duration) != null ? _d : (_c = defaultCategories[key]) == null ? void 0 : _c.duration) != null ? _e : CACHE_TTL_DEFAULTS.DEFAULT
39
+ };
40
+ }
41
+ }
42
+ }
43
+ globalThis.__withwiz_config.cache = {
44
+ enabled: (_f = input.enabled) != null ? _f : true,
45
+ redis: input.redis ? {
46
+ url: input.redis.url,
47
+ token: input.redis.token,
48
+ enabled: (_g = input.redis.enabled) != null ? _g : true
49
+ } : void 0,
50
+ inmemory: {
51
+ enabled: (_i = (_h = input.inmemory) == null ? void 0 : _h.enabled) != null ? _i : true,
52
+ maxSize: (_k = (_j = input.inmemory) == null ? void 0 : _j.maxSize) != null ? _k : INMEMORY_CACHE_DEFAULTS.MAX_SIZE,
53
+ maxMb: (_m = (_l = input.inmemory) == null ? void 0 : _l.maxMb) != null ? _m : INMEMORY_CACHE_DEFAULTS.MAX_MB,
54
+ eviction: (_o = (_n = input.inmemory) == null ? void 0 : _n.eviction) != null ? _o : INMEMORY_CACHE_DEFAULTS.EVICTION,
55
+ cleanupInterval: (_q = (_p = input.inmemory) == null ? void 0 : _p.cleanupInterval) != null ? _q : INMEMORY_CACHE_DEFAULTS.CLEANUP_INTERVAL
56
+ },
57
+ ttl: {
58
+ DEFAULT: (_s = (_r = input.ttl) == null ? void 0 : _r.DEFAULT) != null ? _s : CACHE_TTL_DEFAULTS.DEFAULT,
59
+ SHORT: (_u = (_t = input.ttl) == null ? void 0 : _t.SHORT) != null ? _u : CACHE_TTL_DEFAULTS.SHORT,
60
+ LONG: (_w = (_v = input.ttl) == null ? void 0 : _v.LONG) != null ? _w : CACHE_TTL_DEFAULTS.LONG,
61
+ GEOIP: (_y = (_x = input.ttl) == null ? void 0 : _x.GEOIP) != null ? _y : CACHE_TTL_DEFAULTS.GEOIP,
62
+ SETTINGS: (_A = (_z = input.ttl) == null ? void 0 : _z.SETTINGS) != null ? _A : CACHE_TTL_DEFAULTS.SETTINGS,
63
+ ANALYTICS: (_C = (_B = input.ttl) == null ? void 0 : _B.ANALYTICS) != null ? _C : CACHE_TTL_DEFAULTS.ANALYTICS,
64
+ USER: (_E = (_D = input.ttl) == null ? void 0 : _D.USER) != null ? _E : CACHE_TTL_DEFAULTS.USER
65
+ },
66
+ categories: mergedCategories,
67
+ fallback: {
68
+ redisErrorThresholdGlobal: (_G = (_F = input.fallback) == null ? void 0 : _F.redisErrorThresholdGlobal) != null ? _G : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_GLOBAL,
69
+ redisErrorThresholdLocal: (_I = (_H = input.fallback) == null ? void 0 : _H.redisErrorThresholdLocal) != null ? _I : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_LOCAL,
70
+ redisReconnectInterval: (_K = (_J = input.fallback) == null ? void 0 : _J.redisReconnectInterval) != null ? _K : CACHE_FALLBACK_DEFAULTS.REDIS_RECONNECT_INTERVAL,
71
+ fallbackOnRedisError: (_M = (_L = input.fallback) == null ? void 0 : _L.fallbackOnRedisError) != null ? _M : CACHE_FALLBACK_DEFAULTS.FALLBACK_ON_REDIS_ERROR,
72
+ writeToMemory: (_O = (_N = input.fallback) == null ? void 0 : _N.writeToMemory) != null ? _O : CACHE_FALLBACK_DEFAULTS.WRITE_TO_MEMORY
73
+ },
74
+ health: {
75
+ errorRateThreshold: (_Q = (_P = input.health) == null ? void 0 : _P.errorRateThreshold) != null ? _Q : CACHE_HEALTH_DEFAULTS.ERROR_RATE_THRESHOLD,
76
+ hitRateThreshold: (_S = (_R = input.health) == null ? void 0 : _R.hitRateThreshold) != null ? _S : CACHE_HEALTH_DEFAULTS.HIT_RATE_THRESHOLD,
77
+ reportHitRateThreshold: (_U = (_T = input.health) == null ? void 0 : _T.reportHitRateThreshold) != null ? _U : CACHE_HEALTH_DEFAULTS.REPORT_HIT_RATE_THRESHOLD,
78
+ reportResponseTimeThreshold: (_W = (_V = input.health) == null ? void 0 : _V.reportResponseTimeThreshold) != null ? _W : CACHE_HEALTH_DEFAULTS.REPORT_RESPONSE_TIME_THRESHOLD,
79
+ reportInvalidationThreshold: (_Y = (_X = input.health) == null ? void 0 : _X.reportInvalidationThreshold) != null ? _Y : CACHE_HEALTH_DEFAULTS.REPORT_INVALIDATION_THRESHOLD,
80
+ reportMinRequests: (__ = (_Z = input.health) == null ? void 0 : _Z.reportMinRequests) != null ? __ : CACHE_HEALTH_DEFAULTS.REPORT_MIN_REQUESTS
81
+ }
82
+ };
83
+ }
84
+ function getResolvedCacheConfig() {
85
+ var _a;
86
+ const cache = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.cache;
87
+ if (!cache) {
88
+ throw new ConfigurationError("cache", "Cache config not initialized. Call initializeCache() first.");
89
+ }
90
+ return cache;
91
+ }
92
+ function resetCache() {
93
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.cache;
94
+ }
95
+
96
+ export {
97
+ initializeCache,
98
+ getResolvedCacheConfig,
99
+ resetCache
100
+ };
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  getPlatform
3
- } from "./chunk-X6MGVFT3.js";
3
+ } from "./chunk-LRRQ54YJ.js";
4
4
  import {
5
5
  getGeolocationConfig
6
- } from "./chunk-3CBGGMIY.js";
6
+ } from "./chunk-LHIVUV7Q.js";
7
7
  import {
8
8
  getAuthConfig
9
- } from "./chunk-A2XAOU55.js";
9
+ } from "./chunk-LNPZZ23G.js";
10
10
  import {
11
11
  getCommonConfig
12
- } from "./chunk-SFPMFVSD.js";
12
+ } from "./chunk-WPW4HXW4.js";
13
13
  import {
14
14
  getResolvedCacheConfig
15
- } from "./chunk-UCIUAZQT.js";
15
+ } from "./chunk-MGBNIDTP.js";
16
16
 
17
17
  // src/system/environment.ts
18
18
  import os from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLoggerConfig
3
- } from "./chunk-OHBAELPZ.js";
3
+ } from "./chunk-LMQSV5UK.js";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SNTLJ646.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-TEXVRHPF.js";
9
+ } from "./chunk-NOAU2JG7.js";
10
10
 
11
11
  // src/middleware/rate-limit.ts
12
12
  var GLOBAL_KEY = "__withwiz_rateLimitAdapter__";