@withwiz/toolkit 0.6.0 → 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.
- package/dist/auth/config.d.ts +0 -3
- package/dist/auth/config.js +1 -1
- package/dist/auth/core/jwt/cookie.js +2 -2
- package/dist/auth/core/jwt/index.js +2 -2
- package/dist/auth/handlers/index.js +6 -6
- package/dist/auth/handlers/login.handler.js +3 -3
- package/dist/auth/handlers/logout.handler.js +3 -3
- package/dist/auth/handlers/me.handler.js +2 -2
- package/dist/auth/handlers/oauth-callback.handler.js +3 -3
- package/dist/auth/handlers/refresh.handler.js +3 -3
- package/dist/auth/index.js +2 -2
- package/dist/auth/services/index.js +2 -2
- package/dist/auth/services/login.service.js +2 -2
- package/dist/auth/services/oauth-callback.service.js +2 -2
- package/dist/auth/services/token-refresh.service.js +2 -2
- package/dist/cache/cache-config.js +4 -4
- package/dist/cache/cache-env.js +3 -3
- package/dist/cache/cache-factory.js +12 -12
- package/dist/cache/cache-invalidation.js +13 -13
- package/dist/cache/cache-redis.js +6 -6
- package/dist/cache/cache-wrapper.js +13 -13
- package/dist/cache/cache.js +14 -14
- package/dist/cache/config.d.ts +0 -14
- package/dist/cache/config.js +1 -1
- package/dist/cache/hybrid-cache-manager.js +8 -8
- package/dist/cache/index.js +14 -14
- package/dist/cache/inmemory-cache-manager.js +3 -3
- package/dist/cache/noop-cache-manager.js +5 -5
- package/dist/cache/redis-cache-manager.js +7 -7
- package/dist/{chunk-3ECJUXLM.js → chunk-2KG2G35D.js} +3 -3
- package/dist/{chunk-3AJHXCDG.js → chunk-34IDAA7V.js} +2 -2
- package/dist/{chunk-77BJRPMN.js → chunk-3LVCK2NQ.js} +4 -4
- package/dist/{chunk-W2GBKW2T.js → chunk-545Q34YU.js} +2 -2
- package/dist/{chunk-2VMTIYLX.js → chunk-7DMKTJHU.js} +2 -2
- package/dist/{chunk-O35V6RIF.js → chunk-7UQZH2OH.js} +3 -3
- package/dist/{chunk-7KZRPDQD.js → chunk-A6FKWYO2.js} +2 -2
- package/dist/{chunk-EXJQKCTN.js → chunk-A7TN46LC.js} +4 -4
- package/dist/{chunk-S7OQWKUJ.js → chunk-B6Q7UNCU.js} +1 -1
- package/dist/{chunk-AYZJN32D.js → chunk-CDLCZB6F.js} +10 -15
- package/dist/{chunk-SR3SQL72.js → chunk-CVFVL5FL.js} +2 -2
- package/dist/{chunk-Q6KXN7HL.js → chunk-ENETIGKL.js} +2 -2
- package/dist/{chunk-WNEXLSDB.js → chunk-ERO4PGNO.js} +1 -1
- package/dist/{chunk-BEV7PQM3.js → chunk-F3NGZYL2.js} +1 -1
- package/dist/chunk-FDFPNSKY.js +14 -0
- package/dist/{chunk-G5OMETUS.js → chunk-FDRQUDFH.js} +1 -1
- package/dist/{chunk-MGQV723O.js → chunk-L74XPPH4.js} +1 -1
- package/dist/{chunk-SSS6XSEG.js → chunk-LG6GH4V7.js} +1 -1
- package/dist/{chunk-HHCDMWEF.js → chunk-LGAV5UU2.js} +1 -1
- package/dist/{chunk-3CBGGMIY.js → chunk-LHIVUV7Q.js} +10 -15
- package/dist/{chunk-OHBAELPZ.js → chunk-LMQSV5UK.js} +15 -21
- package/dist/{chunk-A2XAOU55.js → chunk-LNPZZ23G.js} +13 -19
- package/dist/{chunk-X6MGVFT3.js → chunk-LRRQ54YJ.js} +1 -1
- package/dist/chunk-MGBNIDTP.js +100 -0
- package/dist/{chunk-PYVYYO4X.js → chunk-MULM3Q5S.js} +5 -5
- package/dist/{chunk-TEXVRHPF.js → chunk-NOAU2JG7.js} +1 -1
- package/dist/{chunk-WJSMXUZB.js → chunk-NQUYNPSD.js} +1 -1
- package/dist/{chunk-CKK55QFQ.js → chunk-NW3JIRFK.js} +1 -1
- package/dist/{chunk-FI46LV42.js → chunk-O5E36ZIJ.js} +1 -1
- package/dist/{chunk-DBHISLC6.js → chunk-OFSPZUQD.js} +2 -2
- package/dist/{chunk-WRWWB2NU.js → chunk-PT4FA7U4.js} +2 -2
- package/dist/{chunk-VCOA6LMN.js → chunk-QOKDGW3F.js} +1 -1
- package/dist/{chunk-OCI7QCLM.js → chunk-QXIQB6OF.js} +2 -2
- package/dist/{chunk-L5WLPC2T.js → chunk-QXPMO2CO.js} +1 -1
- package/dist/{chunk-LFKPXF5E.js → chunk-RXVX2DCW.js} +2 -2
- package/dist/{chunk-PAF5OGDU.js → chunk-SI2Z26KP.js} +7 -7
- package/dist/{chunk-4BGAE7NU.js → chunk-TLBY3DUK.js} +1 -1
- package/dist/{chunk-IHUQRVPV.js → chunk-UQM35MAO.js} +2 -2
- package/dist/{chunk-G2Q4TI3Q.js → chunk-V3ZIR4UL.js} +1 -1
- package/dist/{chunk-GFWGLWTS.js → chunk-WJWCTCWZ.js} +10 -15
- package/dist/{chunk-CMU52MEQ.js → chunk-WLXAEHKK.js} +2 -2
- package/dist/{chunk-SFPMFVSD.js → chunk-WPW4HXW4.js} +9 -15
- package/dist/{chunk-ON7HZ3PW.js → chunk-WSXOKK6N.js} +1 -1
- package/dist/{chunk-MDTID4D2.js → chunk-XY3ZVORI.js} +1 -1
- package/dist/{chunk-KF3O2DAV.js → chunk-YTXCKIWE.js} +1 -1
- package/dist/{chunk-7JKZBEVB.js → chunk-YX3XMDDI.js} +8 -8
- package/dist/{chunk-CW3INZMV.js → chunk-ZG2XGO44.js} +1 -1
- package/dist/config/common.d.ts +0 -3
- package/dist/config/common.js +1 -1
- package/dist/config/registry.d.ts +3 -18
- package/dist/config/registry.js +1 -4
- package/dist/constants/index.js +14 -14
- package/dist/error/error-handler.js +3 -3
- package/dist/error/index.js +3 -3
- package/dist/geolocation/batch-processor.js +3 -3
- package/dist/geolocation/config.d.ts +0 -3
- package/dist/geolocation/config.js +1 -1
- package/dist/geolocation/index.js +7 -7
- package/dist/geolocation/providers/index.js +4 -4
- package/dist/geolocation/providers/ipgeolocation-provider.js +2 -2
- package/dist/geolocation/providers/maxmind-provider.js +2 -2
- package/dist/initialize.d.ts +3 -2
- package/dist/initialize.js +18 -19
- package/dist/logger/config.d.ts +0 -3
- package/dist/logger/config.js +1 -1
- package/dist/logger/logger.js +2 -2
- package/dist/middleware/auth.js +5 -5
- package/dist/middleware/cors-config.d.ts +0 -3
- package/dist/middleware/cors-config.js +1 -1
- package/dist/middleware/cors.js +4 -4
- package/dist/middleware/error-handler.js +4 -4
- package/dist/middleware/index.js +14 -14
- package/dist/middleware/middleware-chain.js +3 -3
- package/dist/middleware/rate-limit.js +3 -3
- package/dist/middleware/response-logger.js +3 -3
- package/dist/middleware/security.js +3 -3
- package/dist/middleware/wrappers.js +14 -14
- package/dist/storage/config.d.ts +0 -3
- package/dist/storage/config.js +1 -1
- package/dist/storage/r2-storage.js +1 -1
- package/dist/system/cpu.js +4 -4
- package/dist/system/disk.js +4 -4
- package/dist/system/environment.js +8 -8
- package/dist/system/health-check.js +5 -5
- package/dist/system/index.js +13 -13
- package/dist/system/memory.js +4 -4
- package/dist/system/network.js +4 -4
- package/dist/system/utils.js +3 -3
- package/dist/utils/cors.js +3 -3
- package/dist/utils/csv-export.js +3 -3
- package/dist/utils/error-processor.js +3 -3
- package/dist/utils/index.js +7 -7
- package/package.json +1 -1
- package/dist/chunk-6PGZTY4N.js +0 -30
- package/dist/chunk-UCIUAZQT.js +0 -106
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-YUBXS7YI.js";
|
|
5
5
|
import {
|
|
6
6
|
getPlatform
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LRRQ54YJ.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NOAU2JG7.js";
|
|
11
11
|
import {
|
|
12
12
|
getResolvedCacheConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MGBNIDTP.js";
|
|
14
14
|
|
|
15
15
|
// src/system/health-check.ts
|
|
16
16
|
async function checkServiceHealth(prismaClient) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheManager,
|
|
3
3
|
getEffectiveCacheBackend
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YX3XMDDI.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NOAU2JG7.js";
|
|
8
8
|
import {
|
|
9
9
|
getCacheConfig,
|
|
10
10
|
getCacheTTL
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-F3NGZYL2.js";
|
|
12
12
|
import {
|
|
13
13
|
isCacheEnabled
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OFSPZUQD.js";
|
|
15
15
|
|
|
16
16
|
// src/cache/cache-wrapper.ts
|
|
17
17
|
function getCacheBackendLabel() {
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
isRedisGloballyDisabled,
|
|
4
4
|
notifyRedisError,
|
|
5
5
|
resetRedisGlobalState
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UQM35MAO.js";
|
|
7
7
|
import {
|
|
8
8
|
logger
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NOAU2JG7.js";
|
|
10
10
|
import {
|
|
11
11
|
getENV,
|
|
12
12
|
isCacheEnabled
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OFSPZUQD.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRedisGloballyDisabled,
|
|
3
3
|
notifyRedisError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UQM35MAO.js";
|
|
5
5
|
import {
|
|
6
6
|
InMemoryCacheManager
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZG2XGO44.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NOAU2JG7.js";
|
|
11
11
|
import {
|
|
12
12
|
getCacheFallbackConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OFSPZUQD.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
33
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.storage;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
export {
|
|
@@ -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
|
+
};
|
|
@@ -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
|
-
|
|
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
|
-
|
|
15
|
+
globalThis.__withwiz_config.geolocation = {
|
|
22
16
|
ipgeolocationApiKey: config.ipgeolocationApiKey,
|
|
23
17
|
maxmindLicenseKey: config.maxmindLicenseKey
|
|
24
|
-
}
|
|
18
|
+
};
|
|
25
19
|
}
|
|
26
20
|
function getGeolocationConfig() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
level: (
|
|
27
|
-
dir: (
|
|
28
|
-
file: (
|
|
29
|
-
fileEnabled: (
|
|
30
|
-
consoleEnabled: (
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
22
|
+
globalThis.__withwiz_config.auth = {
|
|
30
23
|
jwtSecret: config.jwtSecret,
|
|
31
|
-
accessTokenExpiry: (
|
|
32
|
-
refreshTokenExpiry: (
|
|
33
|
-
cookieSecure: (
|
|
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
|
-
|
|
38
|
-
|
|
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
|
|
35
|
+
return auth;
|
|
42
36
|
}
|
|
43
37
|
function resetAuth() {
|
|
44
|
-
globalThis
|
|
38
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.auth;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export {
|
|
@@ -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-
|
|
3
|
+
} from "./chunk-LRRQ54YJ.js";
|
|
4
4
|
import {
|
|
5
5
|
getGeolocationConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LHIVUV7Q.js";
|
|
7
7
|
import {
|
|
8
8
|
getAuthConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LNPZZ23G.js";
|
|
10
10
|
import {
|
|
11
11
|
getCommonConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WPW4HXW4.js";
|
|
13
13
|
import {
|
|
14
14
|
getResolvedCacheConfig
|
|
15
|
-
} from "./chunk-
|
|
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
|
AUTH_ERROR_CODE_MAP
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XY3ZVORI.js";
|
|
4
4
|
import {
|
|
5
5
|
AppError
|
|
6
6
|
} from "./chunk-EOEMOXNT.js";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-AIH3F7JV.js";
|
|
17
17
|
import {
|
|
18
18
|
logger
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NOAU2JG7.js";
|
|
20
20
|
import {
|
|
21
21
|
__spreadValues
|
|
22
22
|
} from "./chunk-ORMEWXMH.js";
|