@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withwiz/toolkit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Shared utility library for withwiz projects",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,30 +0,0 @@
1
- // src/config/registry.ts
2
- var MODULE_KEYS = {
3
- common: "__withwiz_common_config",
4
- auth: "__withwiz_auth_config",
5
- logger: "__withwiz_logger_config",
6
- cache: "__withwiz_cache_config",
7
- storage: "__withwiz_storage_config",
8
- geolocation: "__withwiz_geolocation_config",
9
- cors: "__withwiz_cors_config"
10
- };
11
- var config = new Proxy({}, {
12
- get(_target, prop) {
13
- const globalKey = MODULE_KEYS[prop];
14
- if (!globalKey) return void 0;
15
- return globalThis[globalKey];
16
- },
17
- set() {
18
- throw new TypeError("config is read-only");
19
- }
20
- });
21
- function resetConfig() {
22
- for (const globalKey of Object.values(MODULE_KEYS)) {
23
- globalThis[globalKey] = void 0;
24
- }
25
- }
26
-
27
- export {
28
- config,
29
- resetConfig
30
- };
@@ -1,106 +0,0 @@
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
- var GLOBAL_KEY = "__withwiz_cache_config";
17
- function getConfig() {
18
- var _a;
19
- return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
20
- }
21
- function setConfig(config) {
22
- globalThis[GLOBAL_KEY] = config;
23
- }
24
- function initializeCache(input) {
25
- 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;
26
- if (getConfig()) return;
27
- if (input.redis !== void 0) {
28
- if (!input.redis.url) {
29
- throw new ConfigurationError("cache", "redis.url is required");
30
- }
31
- if (!input.redis.token) {
32
- throw new ConfigurationError("cache", "redis.token is required");
33
- }
34
- }
35
- const defaultCategories = {};
36
- for (const [key, duration] of Object.entries(CACHE_DURATION_DEFAULTS)) {
37
- defaultCategories[key] = { enabled: true, duration };
38
- }
39
- const mergedCategories = __spreadValues({}, defaultCategories);
40
- if (input.categories) {
41
- for (const [key, value] of Object.entries(input.categories)) {
42
- if (value !== void 0) {
43
- mergedCategories[key] = {
44
- enabled: (_a = value.enabled) != null ? _a : true,
45
- duration: (_d = (_c = value.duration) != null ? _c : (_b = defaultCategories[key]) == null ? void 0 : _b.duration) != null ? _d : CACHE_TTL_DEFAULTS.DEFAULT
46
- };
47
- }
48
- }
49
- }
50
- setConfig({
51
- enabled: (_e = input.enabled) != null ? _e : true,
52
- redis: input.redis ? {
53
- url: input.redis.url,
54
- token: input.redis.token,
55
- enabled: (_f = input.redis.enabled) != null ? _f : true
56
- } : void 0,
57
- inmemory: {
58
- enabled: (_h = (_g = input.inmemory) == null ? void 0 : _g.enabled) != null ? _h : true,
59
- maxSize: (_j = (_i = input.inmemory) == null ? void 0 : _i.maxSize) != null ? _j : INMEMORY_CACHE_DEFAULTS.MAX_SIZE,
60
- maxMb: (_l = (_k = input.inmemory) == null ? void 0 : _k.maxMb) != null ? _l : INMEMORY_CACHE_DEFAULTS.MAX_MB,
61
- eviction: (_n = (_m = input.inmemory) == null ? void 0 : _m.eviction) != null ? _n : INMEMORY_CACHE_DEFAULTS.EVICTION,
62
- cleanupInterval: (_p = (_o = input.inmemory) == null ? void 0 : _o.cleanupInterval) != null ? _p : INMEMORY_CACHE_DEFAULTS.CLEANUP_INTERVAL
63
- },
64
- ttl: {
65
- DEFAULT: (_r = (_q = input.ttl) == null ? void 0 : _q.DEFAULT) != null ? _r : CACHE_TTL_DEFAULTS.DEFAULT,
66
- SHORT: (_t = (_s = input.ttl) == null ? void 0 : _s.SHORT) != null ? _t : CACHE_TTL_DEFAULTS.SHORT,
67
- LONG: (_v = (_u = input.ttl) == null ? void 0 : _u.LONG) != null ? _v : CACHE_TTL_DEFAULTS.LONG,
68
- GEOIP: (_x = (_w = input.ttl) == null ? void 0 : _w.GEOIP) != null ? _x : CACHE_TTL_DEFAULTS.GEOIP,
69
- SETTINGS: (_z = (_y = input.ttl) == null ? void 0 : _y.SETTINGS) != null ? _z : CACHE_TTL_DEFAULTS.SETTINGS,
70
- ANALYTICS: (_B = (_A = input.ttl) == null ? void 0 : _A.ANALYTICS) != null ? _B : CACHE_TTL_DEFAULTS.ANALYTICS,
71
- USER: (_D = (_C = input.ttl) == null ? void 0 : _C.USER) != null ? _D : CACHE_TTL_DEFAULTS.USER
72
- },
73
- categories: mergedCategories,
74
- fallback: {
75
- redisErrorThresholdGlobal: (_F = (_E = input.fallback) == null ? void 0 : _E.redisErrorThresholdGlobal) != null ? _F : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_GLOBAL,
76
- redisErrorThresholdLocal: (_H = (_G = input.fallback) == null ? void 0 : _G.redisErrorThresholdLocal) != null ? _H : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_LOCAL,
77
- redisReconnectInterval: (_J = (_I = input.fallback) == null ? void 0 : _I.redisReconnectInterval) != null ? _J : CACHE_FALLBACK_DEFAULTS.REDIS_RECONNECT_INTERVAL,
78
- fallbackOnRedisError: (_L = (_K = input.fallback) == null ? void 0 : _K.fallbackOnRedisError) != null ? _L : CACHE_FALLBACK_DEFAULTS.FALLBACK_ON_REDIS_ERROR,
79
- writeToMemory: (_N = (_M = input.fallback) == null ? void 0 : _M.writeToMemory) != null ? _N : CACHE_FALLBACK_DEFAULTS.WRITE_TO_MEMORY
80
- },
81
- health: {
82
- errorRateThreshold: (_P = (_O = input.health) == null ? void 0 : _O.errorRateThreshold) != null ? _P : CACHE_HEALTH_DEFAULTS.ERROR_RATE_THRESHOLD,
83
- hitRateThreshold: (_R = (_Q = input.health) == null ? void 0 : _Q.hitRateThreshold) != null ? _R : CACHE_HEALTH_DEFAULTS.HIT_RATE_THRESHOLD,
84
- reportHitRateThreshold: (_T = (_S = input.health) == null ? void 0 : _S.reportHitRateThreshold) != null ? _T : CACHE_HEALTH_DEFAULTS.REPORT_HIT_RATE_THRESHOLD,
85
- reportResponseTimeThreshold: (_V = (_U = input.health) == null ? void 0 : _U.reportResponseTimeThreshold) != null ? _V : CACHE_HEALTH_DEFAULTS.REPORT_RESPONSE_TIME_THRESHOLD,
86
- reportInvalidationThreshold: (_X = (_W = input.health) == null ? void 0 : _W.reportInvalidationThreshold) != null ? _X : CACHE_HEALTH_DEFAULTS.REPORT_INVALIDATION_THRESHOLD,
87
- reportMinRequests: (_Z = (_Y = input.health) == null ? void 0 : _Y.reportMinRequests) != null ? _Z : CACHE_HEALTH_DEFAULTS.REPORT_MIN_REQUESTS
88
- }
89
- });
90
- }
91
- function getResolvedCacheConfig() {
92
- const config = getConfig();
93
- if (!config) {
94
- throw new ConfigurationError("cache", "Cache config not initialized. Call initializeCache() first.");
95
- }
96
- return config;
97
- }
98
- function resetCache() {
99
- globalThis[GLOBAL_KEY] = void 0;
100
- }
101
-
102
- export {
103
- initializeCache,
104
- getResolvedCacheConfig,
105
- resetCache
106
- };