@withwiz/toolkit 0.1.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/README.md +162 -0
- package/dist/auth/adapters/prisma/index.d.ts +43 -0
- package/dist/auth/adapters/prisma/index.js +284 -0
- package/dist/auth/core/email/token-generator.d.ts +43 -0
- package/dist/auth/core/email/token-generator.js +7 -0
- package/dist/auth/core/jwt/client.d.ts +87 -0
- package/dist/auth/core/jwt/client.js +36 -0
- package/dist/auth/core/jwt/index.d.ts +110 -0
- package/dist/auth/core/jwt/index.js +10 -0
- package/dist/auth/core/jwt/types.d.ts +6 -0
- package/dist/auth/core/jwt/types.js +13 -0
- package/dist/auth/core/oauth/index.d.ts +51 -0
- package/dist/auth/core/oauth/index.js +12 -0
- package/dist/auth/core/password/client-helper.d.ts +44 -0
- package/dist/auth/core/password/client-helper.js +28 -0
- package/dist/auth/core/password/index.d.ts +71 -0
- package/dist/auth/core/password/index.js +14 -0
- package/dist/auth/errors/index.d.ts +49 -0
- package/dist/auth/errors/index.js +17 -0
- package/dist/auth/index.d.ts +21 -0
- package/dist/auth/index.js +97 -0
- package/dist/auth/types/index.d.ts +213 -0
- package/dist/auth/types/index.js +13 -0
- package/dist/cache/cache-config.d.ts +73 -0
- package/dist/cache/cache-config.js +12 -0
- package/dist/cache/cache-defaults.d.ts +141 -0
- package/dist/cache/cache-defaults.js +33 -0
- package/dist/cache/cache-env.d.ts +75 -0
- package/dist/cache/cache-env.js +25 -0
- package/dist/cache/cache-factory.d.ts +34 -0
- package/dist/cache/cache-factory.js +28 -0
- package/dist/cache/cache-invalidation.d.ts +90 -0
- package/dist/cache/cache-invalidation.js +24 -0
- package/dist/cache/cache-keys-legacy.d.ts +35 -0
- package/dist/cache/cache-keys-legacy.js +7 -0
- package/dist/cache/cache-redis.d.ts +74 -0
- package/dist/cache/cache-redis.js +24 -0
- package/dist/cache/cache-types.d.ts +151 -0
- package/dist/cache/cache-types.js +9 -0
- package/dist/cache/cache-wrapper.d.ts +27 -0
- package/dist/cache/cache-wrapper.js +22 -0
- package/dist/cache/cache.d.ts +14 -0
- package/dist/cache/cache.js +112 -0
- package/dist/cache/hybrid-cache-manager.d.ts +148 -0
- package/dist/cache/hybrid-cache-manager.js +13 -0
- package/dist/cache/index.d.ts +21 -0
- package/dist/cache/index.js +112 -0
- package/dist/cache/inmemory-cache-manager.d.ts +163 -0
- package/dist/cache/inmemory-cache-manager.js +9 -0
- package/dist/cache/noop-cache-manager.d.ts +36 -0
- package/dist/cache/noop-cache-manager.js +11 -0
- package/dist/cache/redis-cache-manager.d.ts +34 -0
- package/dist/cache/redis-cache-manager.js +11 -0
- package/dist/chunk-26Y7VEYG.js +93 -0
- package/dist/chunk-2DVWSDST.js +119 -0
- package/dist/chunk-2KAPUVIS.js +155 -0
- package/dist/chunk-2TO7WUKK.js +93 -0
- package/dist/chunk-34WAGUT5.js +117 -0
- package/dist/chunk-3DZA6AGS.js +120 -0
- package/dist/chunk-4DPSCTX4.js +212 -0
- package/dist/chunk-4KJXENRM.js +64 -0
- package/dist/chunk-4NWJ3WCZ.js +28 -0
- package/dist/chunk-4ODT3Q4A.js +86 -0
- package/dist/chunk-5ATB5D6S.js +40 -0
- package/dist/chunk-62FLBG6B.js +34 -0
- package/dist/chunk-62Q7DN5G.js +25 -0
- package/dist/chunk-65LHDFU3.js +242 -0
- package/dist/chunk-6C7HQIX4.js +13 -0
- package/dist/chunk-6D3HHYER.js +32 -0
- package/dist/chunk-6LTZCXNC.js +326 -0
- package/dist/chunk-7VJNLGAS.js +110 -0
- package/dist/chunk-7XFHGAJP.js +0 -0
- package/dist/chunk-A6EAAWMK.js +50 -0
- package/dist/chunk-AHDPGRXS.js +51 -0
- package/dist/chunk-AIH3F7JV.js +76 -0
- package/dist/chunk-AIHQBQ3E.js +109 -0
- package/dist/chunk-BKGVSC6S.js +152 -0
- package/dist/chunk-COK4ZXNG.js +0 -0
- package/dist/chunk-DEEJBDJE.js +47 -0
- package/dist/chunk-DH2ZHGW2.js +53 -0
- package/dist/chunk-EBUEBEJX.js +0 -0
- package/dist/chunk-EEUBKZV4.js +54 -0
- package/dist/chunk-EQYTE7WD.js +139 -0
- package/dist/chunk-EUQATJLI.js +180 -0
- package/dist/chunk-EZC6ETFW.js +80 -0
- package/dist/chunk-EZR55KV2.js +249 -0
- package/dist/chunk-F6LCSFSU.js +31 -0
- package/dist/chunk-FOKAATUQ.js +62 -0
- package/dist/chunk-FW3IEJ7H.js +71 -0
- package/dist/chunk-G26T2PRQ.js +53 -0
- package/dist/chunk-G4NI37NN.js +257 -0
- package/dist/chunk-GCZOXUDV.js +132 -0
- package/dist/chunk-GDWEDUHO.js +55 -0
- package/dist/chunk-GL2NANFH.js +434 -0
- package/dist/chunk-GPBOMJSZ.js +136 -0
- package/dist/chunk-H5I5GWAA.js +94 -0
- package/dist/chunk-HGC4CCKB.js +29 -0
- package/dist/chunk-HV3DGSSH.js +447 -0
- package/dist/chunk-I47QEDTX.js +193 -0
- package/dist/chunk-IAJNC34M.js +102 -0
- package/dist/chunk-IHXRF3BH.js +215 -0
- package/dist/chunk-IJEZ7G7S.js +26 -0
- package/dist/chunk-IQQKKUAV.js +151 -0
- package/dist/chunk-JBCDEAMW.js +35 -0
- package/dist/chunk-JLLMTTQ4.js +75 -0
- package/dist/chunk-JS5VI3OW.js +143 -0
- package/dist/chunk-KAWVMIRJ.js +44 -0
- package/dist/chunk-KMCJIL57.js +214 -0
- package/dist/chunk-KWTBD4CM.js +145 -0
- package/dist/chunk-KXAWBFJN.js +310 -0
- package/dist/chunk-L25BNU3E.js +56 -0
- package/dist/chunk-L76O3X3D.js +197 -0
- package/dist/chunk-LNV2E4I6.js +63 -0
- package/dist/chunk-MLGO3HLS.js +329 -0
- package/dist/chunk-MRJE6OX5.js +22 -0
- package/dist/chunk-MYLGYX4K.js +57 -0
- package/dist/chunk-N4YGR5WH.js +310 -0
- package/dist/chunk-OIVXOT2X.js +80 -0
- package/dist/chunk-ORMEWXMH.js +37 -0
- package/dist/chunk-POKGHK3L.js +57 -0
- package/dist/chunk-Q7IP4JMW.js +69 -0
- package/dist/chunk-RJUVBBZG.js +27 -0
- package/dist/chunk-S73334QY.js +89 -0
- package/dist/chunk-SLG26KHZ.js +101 -0
- package/dist/chunk-SR65BF6X.js +82 -0
- package/dist/chunk-SS56XFLI.js +19 -0
- package/dist/chunk-T3LJYAMO.js +277 -0
- package/dist/chunk-TDZJ6SAI.js +34 -0
- package/dist/chunk-TEIYA7U4.js +72 -0
- package/dist/chunk-TMVS4F7E.js +88 -0
- package/dist/chunk-TRBKJ7JT.js +137 -0
- package/dist/chunk-TXGNSECL.js +84 -0
- package/dist/chunk-TZAP5T4N.js +188 -0
- package/dist/chunk-UCYQNHST.js +24 -0
- package/dist/chunk-ULF5RDDX.js +0 -0
- package/dist/chunk-UXQRU3EM.js +167 -0
- package/dist/chunk-V5K5FYU7.js +200 -0
- package/dist/chunk-VDXB5DCY.js +68 -0
- package/dist/chunk-VSGKVZB4.js +47 -0
- package/dist/chunk-VWODEQ5C.js +204 -0
- package/dist/chunk-WDUFQFDP.js +193 -0
- package/dist/chunk-WHR7HPWF.js +126 -0
- package/dist/chunk-WSQMXMTL.js +122 -0
- package/dist/chunk-XHZ5L4FO.js +103 -0
- package/dist/chunk-XPASCCUA.js +404 -0
- package/dist/chunk-XRRPEBKB.js +231 -0
- package/dist/chunk-Y2TUZFCP.js +0 -0
- package/dist/chunk-Y3OTJH2S.js +473 -0
- package/dist/chunk-YBSHN67U.js +161 -0
- package/dist/chunk-YJ3TLEW3.js +100 -0
- package/dist/chunk-YJWLWUFK.js +105 -0
- package/dist/chunk-Z4D4CMDA.js +488 -0
- package/dist/chunk-ZHVUK5OY.js +314 -0
- package/dist/chunk-ZTN4X5FN.js +29 -0
- package/dist/chunk-ZZIKRBJU.js +96 -0
- package/dist/components/ui/Alert.d.ts +12 -0
- package/dist/components/ui/Alert.js +10 -0
- package/dist/components/ui/Badge.d.ts +7 -0
- package/dist/components/ui/Badge.js +8 -0
- package/dist/components/ui/Button.d.ts +7 -0
- package/dist/components/ui/Button.js +8 -0
- package/dist/components/ui/DataTable.d.ts +103 -0
- package/dist/components/ui/DataTable.js +606 -0
- package/dist/components/ui/DomainDisplay.d.ts +12 -0
- package/dist/components/ui/DomainDisplay.js +31 -0
- package/dist/components/ui/Input.d.ts +5 -0
- package/dist/components/ui/Input.js +8 -0
- package/dist/components/ui/Label.d.ts +5 -0
- package/dist/components/ui/Label.js +8 -0
- package/dist/components/ui/Pagination.d.ts +42 -0
- package/dist/components/ui/Pagination.js +20 -0
- package/dist/components/ui/Select.d.ts +15 -0
- package/dist/components/ui/Select.js +27 -0
- package/dist/components/ui/Skeleton.d.ts +6 -0
- package/dist/components/ui/Skeleton.js +8 -0
- package/dist/components/ui/TimezoneDisplay.d.ts +22 -0
- package/dist/components/ui/TimezoneDisplay.js +83 -0
- package/dist/components/ui/Tooltip.d.ts +21 -0
- package/dist/components/ui/Tooltip.js +94 -0
- package/dist/components/ui/WorldMapChart.d.ts +17 -0
- package/dist/components/ui/WorldMapChart.js +250 -0
- package/dist/components/ui/loading-bar.d.ts +20 -0
- package/dist/components/ui/loading-bar.js +15 -0
- package/dist/constants/error-codes.d.ts +389 -0
- package/dist/constants/error-codes.js +27 -0
- package/dist/constants/index.d.ts +11 -0
- package/dist/constants/index.js +85 -0
- package/dist/constants/messages.d.ts +83 -0
- package/dist/constants/messages.js +13 -0
- package/dist/constants/pagination.d.ts +43 -0
- package/dist/constants/pagination.js +15 -0
- package/dist/constants/security.d.ts +66 -0
- package/dist/constants/security.js +23 -0
- package/dist/constants/validation.d.ts +60 -0
- package/dist/constants/validation.js +19 -0
- package/dist/error/ErrorBoundary.d.ts +47 -0
- package/dist/error/app-error.d.ts +144 -0
- package/dist/error/app-error.js +10 -0
- package/dist/error/components/EmptyState.d.ts +50 -0
- package/dist/error/components/ErrorAlert.d.ts +50 -0
- package/dist/error/components/ErrorPage.d.ts +39 -0
- package/dist/error/components/LoadingState.d.ts +37 -0
- package/dist/error/components/index.d.ts +13 -0
- package/dist/error/components/index.js +18 -0
- package/dist/error/core/locale-detector.d.ts +44 -0
- package/dist/error/core/locale-detector.js +9 -0
- package/dist/error/error-display.d.ts +55 -0
- package/dist/error/error-display.js +24 -0
- package/dist/error/error-handler.d.ts +118 -0
- package/dist/error/error-handler.js +18 -0
- package/dist/error/friendly-messages-v2.d.ts +46 -0
- package/dist/error/friendly-messages-v2.js +15 -0
- package/dist/error/friendly-messages.d.ts +22 -0
- package/dist/error/friendly-messages.js +12 -0
- package/dist/error/hooks/index.d.ts +7 -0
- package/dist/error/hooks/index.js +14 -0
- package/dist/error/hooks/useErrorHandler.d.ts +67 -0
- package/dist/error/hooks/useErrorHandler.js +14 -0
- package/dist/error/index.d.ts +26 -0
- package/dist/error/index.js +289 -0
- package/dist/error/logging/error-logger.d.ts +77 -0
- package/dist/error/logging/error-logger.js +10 -0
- package/dist/error/logging/index.d.ts +9 -0
- package/dist/error/logging/index.js +35 -0
- package/dist/error/logging/transports/base.d.ts +30 -0
- package/dist/error/logging/transports/base.js +7 -0
- package/dist/error/logging/transports/console.d.ts +40 -0
- package/dist/error/logging/transports/console.js +9 -0
- package/dist/error/logging/transports/file.d.ts +49 -0
- package/dist/error/logging/transports/file.js +8 -0
- package/dist/error/logging/transports/index.d.ts +12 -0
- package/dist/error/logging/transports/index.js +25 -0
- package/dist/error/logging/transports/sentry.d.ts +44 -0
- package/dist/error/logging/transports/sentry.js +9 -0
- package/dist/error/logging/transports/slack.d.ts +51 -0
- package/dist/error/logging/transports/slack.js +9 -0
- package/dist/error/logging/types.d.ts +83 -0
- package/dist/error/logging/types.js +7 -0
- package/dist/error/messages/en.d.ts +5 -0
- package/dist/error/messages/en.js +7 -0
- package/dist/error/messages/index.d.ts +40 -0
- package/dist/error/messages/index.js +17 -0
- package/dist/error/messages/ko.d.ts +5 -0
- package/dist/error/messages/ko.js +7 -0
- package/dist/error/messages/types.d.ts +30 -0
- package/dist/error/messages/types.js +0 -0
- package/dist/error/recovery/circuit-breaker.d.ts +85 -0
- package/dist/error/recovery/circuit-breaker.js +9 -0
- package/dist/error/recovery/degradation.d.ts +56 -0
- package/dist/error/recovery/degradation.js +7 -0
- package/dist/error/recovery/fallback.d.ts +55 -0
- package/dist/error/recovery/fallback.js +11 -0
- package/dist/error/recovery/index.d.ts +12 -0
- package/dist/error/recovery/index.js +26 -0
- package/dist/error/recovery/retry.d.ts +44 -0
- package/dist/error/recovery/retry.js +7 -0
- package/dist/geolocation/batch-processor.d.ts +33 -0
- package/dist/geolocation/batch-processor.js +10 -0
- package/dist/geolocation/index.d.ts +14 -0
- package/dist/geolocation/index.js +36 -0
- package/dist/geolocation/providers/base-provider.d.ts +33 -0
- package/dist/geolocation/providers/base-provider.js +9 -0
- package/dist/geolocation/providers/index.d.ts +54 -0
- package/dist/geolocation/providers/index.js +29 -0
- package/dist/geolocation/providers/ip-api-provider.d.ts +17 -0
- package/dist/geolocation/providers/ip-api-provider.js +8 -0
- package/dist/geolocation/providers/ipapi-co-provider.d.ts +17 -0
- package/dist/geolocation/providers/ipapi-co-provider.js +8 -0
- package/dist/geolocation/providers/ipgeolocation-provider.d.ts +18 -0
- package/dist/geolocation/providers/ipgeolocation-provider.js +8 -0
- package/dist/geolocation/providers/maxmind-provider.d.ts +18 -0
- package/dist/geolocation/providers/maxmind-provider.js +8 -0
- package/dist/hooks/useDataTable.d.ts +51 -0
- package/dist/hooks/useDataTable.js +149 -0
- package/dist/hooks/useDebounce.d.ts +7 -0
- package/dist/hooks/useDebounce.js +7 -0
- package/dist/hooks/useExitIntent.d.ts +35 -0
- package/dist/hooks/useExitIntent.js +72 -0
- package/dist/hooks/useTimezone.d.ts +19 -0
- package/dist/hooks/useTimezone.js +11 -0
- package/dist/logger/logger.d.ts +11 -0
- package/dist/logger/logger.js +17 -0
- package/dist/middleware/auth.d.ts +87 -0
- package/dist/middleware/auth.js +20 -0
- package/dist/middleware/cors.d.ts +30 -0
- package/dist/middleware/cors.js +10 -0
- package/dist/middleware/error-handler.d.ts +23 -0
- package/dist/middleware/error-handler.js +13 -0
- package/dist/middleware/index.d.ts +16 -0
- package/dist/middleware/index.js +72 -0
- package/dist/middleware/init-request.d.ts +18 -0
- package/dist/middleware/init-request.js +8 -0
- package/dist/middleware/middleware-chain.d.ts +53 -0
- package/dist/middleware/middleware-chain.js +8 -0
- package/dist/middleware/rate-limit.d.ts +82 -0
- package/dist/middleware/rate-limit.js +14 -0
- package/dist/middleware/response-logger.d.ts +22 -0
- package/dist/middleware/response-logger.js +8 -0
- package/dist/middleware/security.d.ts +31 -0
- package/dist/middleware/security.js +9 -0
- package/dist/middleware/types.d.ts +45 -0
- package/dist/middleware/types.js +0 -0
- package/dist/middleware/wrappers.d.ts +91 -0
- package/dist/middleware/wrappers.js +32 -0
- package/dist/storage/r2-storage.d.ts +38 -0
- package/dist/storage/r2-storage.js +105 -0
- package/dist/system/cpu.d.ts +2 -0
- package/dist/system/cpu.js +9 -0
- package/dist/system/disk.d.ts +2 -0
- package/dist/system/disk.js +9 -0
- package/dist/system/environment.d.ts +8 -0
- package/dist/system/environment.js +9 -0
- package/dist/system/health-check.d.ts +26 -0
- package/dist/system/health-check.js +10 -0
- package/dist/system/index.d.ts +51 -0
- package/dist/system/index.js +194 -0
- package/dist/system/memory.d.ts +2 -0
- package/dist/system/memory.js +9 -0
- package/dist/system/network.d.ts +2 -0
- package/dist/system/network.js +9 -0
- package/dist/system/types.d.ts +93 -0
- package/dist/system/types.js +0 -0
- package/dist/system/utils.d.ts +12 -0
- package/dist/system/utils.js +26 -0
- package/dist/types/api.d.ts +80 -0
- package/dist/types/api.js +0 -0
- package/dist/types/database.d.ts +38 -0
- package/dist/types/database.js +0 -0
- package/dist/types/env.d.ts +105 -0
- package/dist/types/env.js +0 -0
- package/dist/types/geoip.d.ts +152 -0
- package/dist/types/geoip.js +0 -0
- package/dist/types/i18n.d.ts +11 -0
- package/dist/types/i18n.js +0 -0
- package/dist/types/qr-code.d.ts +139 -0
- package/dist/types/qr-code.js +75 -0
- package/dist/types/user.d.ts +54 -0
- package/dist/types/user.js +0 -0
- package/dist/utils/api-helpers.d.ts +147 -0
- package/dist/utils/api-helpers.js +30 -0
- package/dist/utils/client/client-utils.d.ts +3 -0
- package/dist/utils/client/client-utils.js +9 -0
- package/dist/utils/client/qr-code.d.ts +16 -0
- package/dist/utils/client/qr-code.js +215 -0
- package/dist/utils/cors.d.ts +40 -0
- package/dist/utils/cors.js +21 -0
- package/dist/utils/csv-export.d.ts +97 -0
- package/dist/utils/csv-export.js +20 -0
- package/dist/utils/error-message-formatter.d.ts +17 -0
- package/dist/utils/error-message-formatter.js +11 -0
- package/dist/utils/error-processor.d.ts +70 -0
- package/dist/utils/error-processor.js +34 -0
- package/dist/utils/format-number.d.ts +17 -0
- package/dist/utils/format-number.js +9 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +160 -0
- package/dist/utils/input-validation.d.ts +88 -0
- package/dist/utils/input-validation.js +223 -0
- package/dist/utils/ip-utils.d.ts +15 -0
- package/dist/utils/ip-utils.js +91 -0
- package/dist/utils/optimistic-lock.d.ts +27 -0
- package/dist/utils/optimistic-lock.js +16 -0
- package/dist/utils/sanitizer.d.ts +72 -0
- package/dist/utils/sanitizer.js +19 -0
- package/dist/utils/shared-utils.d.ts +25 -0
- package/dist/utils/shared-utils.js +43 -0
- package/dist/utils/short-code-generator.d.ts +24 -0
- package/dist/utils/short-code-generator.js +9 -0
- package/dist/utils/timezone.d.ts +56 -0
- package/dist/utils/timezone.js +29 -0
- package/dist/utils/type-guards.d.ts +164 -0
- package/dist/utils/type-guards.js +59 -0
- package/dist/utils/url-normalizer.d.ts +53 -0
- package/dist/utils/url-normalizer.js +21 -0
- package/dist/validators/index.d.ts +7 -0
- package/dist/validators/index.js +13 -0
- package/dist/validators/password-validator.d.ts +86 -0
- package/dist/validators/password-validator.js +13 -0
- package/dist/world_countries-C2WUL2CQ.js +279 -0
- package/package.json +129 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-62FLBG6B.js";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./chunk-ORMEWXMH.js";
|
|
9
|
+
|
|
10
|
+
// src/components/ui/Select.tsx
|
|
11
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
12
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
function Select(_a) {
|
|
15
|
+
var props = __objRest(_a, []);
|
|
16
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Root, __spreadValues({ "data-slot": "select" }, props));
|
|
17
|
+
}
|
|
18
|
+
function SelectGroup(_a) {
|
|
19
|
+
var props = __objRest(_a, []);
|
|
20
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Group, __spreadValues({ "data-slot": "select-group" }, props));
|
|
21
|
+
}
|
|
22
|
+
function SelectValue(_a) {
|
|
23
|
+
var props = __objRest(_a, []);
|
|
24
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Value, __spreadValues({ "data-slot": "select-value" }, props));
|
|
25
|
+
}
|
|
26
|
+
function SelectTrigger(_a) {
|
|
27
|
+
var _b = _a, {
|
|
28
|
+
className,
|
|
29
|
+
size = "default",
|
|
30
|
+
children
|
|
31
|
+
} = _b, props = __objRest(_b, [
|
|
32
|
+
"className",
|
|
33
|
+
"size",
|
|
34
|
+
"children"
|
|
35
|
+
]);
|
|
36
|
+
return /* @__PURE__ */ jsxs(
|
|
37
|
+
SelectPrimitive.Trigger,
|
|
38
|
+
__spreadProps(__spreadValues({
|
|
39
|
+
"data-slot": "select-trigger",
|
|
40
|
+
"data-size": size,
|
|
41
|
+
className: cn(
|
|
42
|
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
43
|
+
className
|
|
44
|
+
)
|
|
45
|
+
}, props), {
|
|
46
|
+
children: [
|
|
47
|
+
children,
|
|
48
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
function SelectContent(_a) {
|
|
54
|
+
var _b = _a, {
|
|
55
|
+
className,
|
|
56
|
+
children,
|
|
57
|
+
position = "popper"
|
|
58
|
+
} = _b, props = __objRest(_b, [
|
|
59
|
+
"className",
|
|
60
|
+
"children",
|
|
61
|
+
"position"
|
|
62
|
+
]);
|
|
63
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
64
|
+
SelectPrimitive.Content,
|
|
65
|
+
__spreadProps(__spreadValues({
|
|
66
|
+
"data-slot": "select-content",
|
|
67
|
+
className: cn(
|
|
68
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
69
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
70
|
+
className
|
|
71
|
+
),
|
|
72
|
+
position
|
|
73
|
+
}, props), {
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
SelectPrimitive.Viewport,
|
|
78
|
+
{
|
|
79
|
+
className: cn(
|
|
80
|
+
"p-1",
|
|
81
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
82
|
+
),
|
|
83
|
+
children
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
) });
|
|
90
|
+
}
|
|
91
|
+
function SelectLabel(_a) {
|
|
92
|
+
var _b = _a, {
|
|
93
|
+
className
|
|
94
|
+
} = _b, props = __objRest(_b, [
|
|
95
|
+
"className"
|
|
96
|
+
]);
|
|
97
|
+
return /* @__PURE__ */ jsx(
|
|
98
|
+
SelectPrimitive.Label,
|
|
99
|
+
__spreadValues({
|
|
100
|
+
"data-slot": "select-label",
|
|
101
|
+
className: cn("text-muted-foreground px-2 py-1.5 text-xs", className)
|
|
102
|
+
}, props)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
function SelectItem(_a) {
|
|
106
|
+
var _b = _a, {
|
|
107
|
+
className,
|
|
108
|
+
children
|
|
109
|
+
} = _b, props = __objRest(_b, [
|
|
110
|
+
"className",
|
|
111
|
+
"children"
|
|
112
|
+
]);
|
|
113
|
+
return /* @__PURE__ */ jsxs(
|
|
114
|
+
SelectPrimitive.Item,
|
|
115
|
+
__spreadProps(__spreadValues({
|
|
116
|
+
"data-slot": "select-item",
|
|
117
|
+
className: cn(
|
|
118
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
119
|
+
className
|
|
120
|
+
)
|
|
121
|
+
}, props), {
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) }) }),
|
|
124
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function SelectSeparator(_a) {
|
|
130
|
+
var _b = _a, {
|
|
131
|
+
className
|
|
132
|
+
} = _b, props = __objRest(_b, [
|
|
133
|
+
"className"
|
|
134
|
+
]);
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
136
|
+
SelectPrimitive.Separator,
|
|
137
|
+
__spreadValues({
|
|
138
|
+
"data-slot": "select-separator",
|
|
139
|
+
className: cn("bg-muted -mx-1 my-1 h-px", className)
|
|
140
|
+
}, props)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
function SelectScrollUpButton(_a) {
|
|
144
|
+
var _b = _a, {
|
|
145
|
+
className
|
|
146
|
+
} = _b, props = __objRest(_b, [
|
|
147
|
+
"className"
|
|
148
|
+
]);
|
|
149
|
+
return /* @__PURE__ */ jsx(
|
|
150
|
+
SelectPrimitive.ScrollUpButton,
|
|
151
|
+
__spreadProps(__spreadValues({
|
|
152
|
+
"data-slot": "select-scroll-up-button",
|
|
153
|
+
className: cn(
|
|
154
|
+
"flex cursor-default items-center justify-center py-1",
|
|
155
|
+
className
|
|
156
|
+
)
|
|
157
|
+
}, props), {
|
|
158
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function SelectScrollDownButton(_a) {
|
|
163
|
+
var _b = _a, {
|
|
164
|
+
className
|
|
165
|
+
} = _b, props = __objRest(_b, [
|
|
166
|
+
"className"
|
|
167
|
+
]);
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
SelectPrimitive.ScrollDownButton,
|
|
170
|
+
__spreadProps(__spreadValues({
|
|
171
|
+
"data-slot": "select-scroll-down-button",
|
|
172
|
+
className: cn(
|
|
173
|
+
"flex cursor-default items-center justify-center py-1",
|
|
174
|
+
className
|
|
175
|
+
)
|
|
176
|
+
}, props), {
|
|
177
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export {
|
|
183
|
+
Select,
|
|
184
|
+
SelectGroup,
|
|
185
|
+
SelectValue,
|
|
186
|
+
SelectTrigger,
|
|
187
|
+
SelectContent,
|
|
188
|
+
SelectLabel,
|
|
189
|
+
SelectItem,
|
|
190
|
+
SelectSeparator,
|
|
191
|
+
SelectScrollUpButton,
|
|
192
|
+
SelectScrollDownButton
|
|
193
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatDatabaseError,
|
|
3
|
+
formatRedisError
|
|
4
|
+
} from "./chunk-OIVXOT2X.js";
|
|
5
|
+
import {
|
|
6
|
+
getPlatform
|
|
7
|
+
} from "./chunk-KWTBD4CM.js";
|
|
8
|
+
import {
|
|
9
|
+
logger
|
|
10
|
+
} from "./chunk-EZR55KV2.js";
|
|
11
|
+
|
|
12
|
+
// src/system/health-check.ts
|
|
13
|
+
async function checkServiceHealth(prismaClient) {
|
|
14
|
+
const platform = getPlatform();
|
|
15
|
+
const services = [];
|
|
16
|
+
if (prismaClient) {
|
|
17
|
+
try {
|
|
18
|
+
const dbStart = Date.now();
|
|
19
|
+
await prismaClient.$queryRaw`SELECT 1`;
|
|
20
|
+
const dbResponseTime = Date.now() - dbStart;
|
|
21
|
+
services.push({
|
|
22
|
+
name: "Database",
|
|
23
|
+
status: "ok",
|
|
24
|
+
message: "\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC5F0\uACB0 \uC815\uC0C1",
|
|
25
|
+
metrics: [
|
|
26
|
+
{ label: "Response Time", value: `${dbResponseTime}ms` },
|
|
27
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
} catch (dbError) {
|
|
31
|
+
const dbResponseTime = Date.now();
|
|
32
|
+
const errorMessage = dbError instanceof Error ? dbError.message : "Unknown error";
|
|
33
|
+
services.push({
|
|
34
|
+
name: "Database",
|
|
35
|
+
status: "error",
|
|
36
|
+
message: `\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC5F0\uACB0 \uC2E4\uD328: ${formatDatabaseError(errorMessage)}`,
|
|
37
|
+
metrics: [
|
|
38
|
+
{ label: "Response Time", value: `${dbResponseTime}ms` },
|
|
39
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
logger.debug("[Health Check] Prisma client not provided, skipping database check");
|
|
45
|
+
services.push({
|
|
46
|
+
name: "Database",
|
|
47
|
+
status: "warning",
|
|
48
|
+
message: "\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC81C\uACF5\uB418\uC9C0 \uC54A\uC74C",
|
|
49
|
+
metrics: [
|
|
50
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const redisStart = Date.now();
|
|
56
|
+
const cacheEnabled = process.env.CACHE_ENABLED !== "false";
|
|
57
|
+
const redisUrl = process.env.UPSTASH_REDIS_REST_URL;
|
|
58
|
+
const redisToken = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
59
|
+
if (!cacheEnabled) {
|
|
60
|
+
services.push({
|
|
61
|
+
name: "Redis",
|
|
62
|
+
status: "warning",
|
|
63
|
+
message: "Redis \uCE90\uC2DC \uBE44\uD65C\uC131\uD654\uB428 (CACHE_ENABLED=false)",
|
|
64
|
+
metrics: [
|
|
65
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
} else if (redisUrl && redisToken && redisUrl.trim() !== "" && redisToken.trim() !== "") {
|
|
69
|
+
try {
|
|
70
|
+
const { checkRedisConnection } = await import("./cache/cache.js");
|
|
71
|
+
const redisStatus = await checkRedisConnection();
|
|
72
|
+
if (redisStatus.success) {
|
|
73
|
+
const redisResponseTime = Date.now() - redisStart;
|
|
74
|
+
services.push({
|
|
75
|
+
name: "Redis",
|
|
76
|
+
status: "ok",
|
|
77
|
+
message: "Redis \uC5F0\uACB0 \uC815\uC0C1",
|
|
78
|
+
metrics: [
|
|
79
|
+
{ label: "Response Time", value: `${redisResponseTime}ms` },
|
|
80
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
const errorMessage = redisStatus.error || "Redis \uC5F0\uACB0 \uC2E4\uD328";
|
|
85
|
+
throw new Error(formatRedisError(errorMessage));
|
|
86
|
+
}
|
|
87
|
+
} catch (redisError) {
|
|
88
|
+
const redisResponseTime = Date.now() - redisStart;
|
|
89
|
+
const errorMessage = redisError instanceof Error ? redisError.message : "Unknown error";
|
|
90
|
+
services.push({
|
|
91
|
+
name: "Redis",
|
|
92
|
+
status: "error",
|
|
93
|
+
message: `Redis \uC5F0\uACB0 \uC2E4\uD328: ${formatRedisError(errorMessage)}`,
|
|
94
|
+
metrics: [
|
|
95
|
+
{ label: "Response Time", value: `${redisResponseTime}ms` },
|
|
96
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
services.push({
|
|
102
|
+
name: "Redis",
|
|
103
|
+
status: "warning",
|
|
104
|
+
message: "Redis \uD658\uACBD \uBCC0\uC218\uAC00 \uC124\uC815\uB418\uC9C0 \uC54A\uC74C",
|
|
105
|
+
metrics: [
|
|
106
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
112
|
+
services.push({
|
|
113
|
+
name: "Redis",
|
|
114
|
+
status: "error",
|
|
115
|
+
message: `Redis \uBAA8\uB4C8 \uB85C\uB4DC \uC2E4\uD328: ${formatRedisError(errorMessage)}`,
|
|
116
|
+
metrics: [
|
|
117
|
+
{ label: "Platform", value: platform === "darwin" ? "macOS" : "Linux" }
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return services;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
checkServiceHealth
|
|
126
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// src/middleware/security.ts
|
|
2
|
+
import { NextResponse } from "next/server";
|
|
3
|
+
var BLOCKED_METHODS = ["TRACE", "TRACK"];
|
|
4
|
+
var ALLOWED_CONTENT_TYPES = [
|
|
5
|
+
"application/json",
|
|
6
|
+
"application/x-www-form-urlencoded",
|
|
7
|
+
"multipart/form-data",
|
|
8
|
+
"text/plain"
|
|
9
|
+
// 일부 클라이언트 호환성을 위해 허용하되 로깅
|
|
10
|
+
];
|
|
11
|
+
var METHODS_REQUIRING_CONTENT_TYPE = ["POST", "PUT", "PATCH"];
|
|
12
|
+
var securityMiddleware = async (context, next) => {
|
|
13
|
+
const { request } = context;
|
|
14
|
+
const method = request.method.toUpperCase();
|
|
15
|
+
if (BLOCKED_METHODS.includes(method)) {
|
|
16
|
+
return new NextResponse(
|
|
17
|
+
JSON.stringify({
|
|
18
|
+
success: false,
|
|
19
|
+
error: {
|
|
20
|
+
code: 40500,
|
|
21
|
+
message: `Method ${method} is not allowed`,
|
|
22
|
+
userMessage: {
|
|
23
|
+
title: "\uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uBA54\uC11C\uB4DC",
|
|
24
|
+
description: `${method} \uBA54\uC11C\uB4DC\uB294 \uBCF4\uC548\uC0C1 \uC774\uC720\uB85C \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,
|
|
25
|
+
action: "\uB2E4\uB978 HTTP \uBA54\uC11C\uB4DC\uB97C \uC0AC\uC6A9\uD574 \uC8FC\uC138\uC694."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
{
|
|
30
|
+
status: 405,
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Allow: "GET, POST, PUT, DELETE, PATCH, OPTIONS"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (METHODS_REQUIRING_CONTENT_TYPE.includes(method)) {
|
|
39
|
+
const contentType = request.headers.get("content-type");
|
|
40
|
+
if (!contentType) {
|
|
41
|
+
const contentLength = request.headers.get("content-length");
|
|
42
|
+
if (contentLength && parseInt(contentLength, 10) > 0) {
|
|
43
|
+
return new NextResponse(
|
|
44
|
+
JSON.stringify({
|
|
45
|
+
success: false,
|
|
46
|
+
error: {
|
|
47
|
+
code: 41500,
|
|
48
|
+
message: "Content-Type header is required for requests with body",
|
|
49
|
+
userMessage: {
|
|
50
|
+
title: "Content-Type \uD544\uC218",
|
|
51
|
+
description: "\uC694\uCCAD \uBCF8\uBB38\uC774 \uC788\uB294 \uACBD\uC6B0 Content-Type \uD5E4\uB354\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.",
|
|
52
|
+
action: "Content-Type: application/json \uD5E4\uB354\uB97C \uCD94\uAC00\uD574 \uC8FC\uC138\uC694."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
{
|
|
57
|
+
status: 415,
|
|
58
|
+
headers: {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
Accept: ALLOWED_CONTENT_TYPES.join(", ")
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (contentType) {
|
|
67
|
+
const normalizedContentType = contentType.split(";")[0].trim().toLowerCase();
|
|
68
|
+
const isAllowed = ALLOWED_CONTENT_TYPES.some(
|
|
69
|
+
(allowed) => normalizedContentType === allowed || normalizedContentType.startsWith(allowed)
|
|
70
|
+
);
|
|
71
|
+
if (!isAllowed) {
|
|
72
|
+
return new NextResponse(
|
|
73
|
+
JSON.stringify({
|
|
74
|
+
success: false,
|
|
75
|
+
error: {
|
|
76
|
+
code: 41501,
|
|
77
|
+
message: `Unsupported Content-Type: ${normalizedContentType}`,
|
|
78
|
+
userMessage: {
|
|
79
|
+
title: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 Content-Type",
|
|
80
|
+
description: `${normalizedContentType}\uC740(\uB294) \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,
|
|
81
|
+
action: "application/json Content-Type\uC744 \uC0AC\uC6A9\uD574 \uC8FC\uC138\uC694."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
{
|
|
86
|
+
status: 415,
|
|
87
|
+
headers: {
|
|
88
|
+
"Content-Type": "application/json",
|
|
89
|
+
Accept: ALLOWED_CONTENT_TYPES.join(", ")
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const response = await next();
|
|
97
|
+
if (!response.headers.has("X-Content-Type-Options")) {
|
|
98
|
+
response.headers.set("X-Content-Type-Options", "nosniff");
|
|
99
|
+
}
|
|
100
|
+
if (!response.headers.has("X-Frame-Options")) {
|
|
101
|
+
response.headers.set("X-Frame-Options", "DENY");
|
|
102
|
+
}
|
|
103
|
+
if (!response.headers.has("X-XSS-Protection")) {
|
|
104
|
+
response.headers.set("X-XSS-Protection", "1; mode=block");
|
|
105
|
+
}
|
|
106
|
+
if (!response.headers.has("Referrer-Policy")) {
|
|
107
|
+
response.headers.set("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
108
|
+
}
|
|
109
|
+
if (!response.headers.has("Permissions-Policy")) {
|
|
110
|
+
response.headers.set("Permissions-Policy", "geolocation=(), microphone=(), camera=()");
|
|
111
|
+
}
|
|
112
|
+
return response;
|
|
113
|
+
};
|
|
114
|
+
function validateSecurityConfiguration() {
|
|
115
|
+
console.log("[Security Middleware] Blocked methods:", BLOCKED_METHODS.join(", "));
|
|
116
|
+
console.log("[Security Middleware] Allowed Content-Types:", ALLOWED_CONTENT_TYPES.join(", "));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
securityMiddleware,
|
|
121
|
+
validateSecurityConfiguration
|
|
122
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/error/core/locale-detector.ts
|
|
2
|
+
var LocaleDetector = class {
|
|
3
|
+
/**
|
|
4
|
+
* 클라이언트 측 로케일 감지
|
|
5
|
+
* 우선순위: localStorage > cookie > navigator.language > 기본값
|
|
6
|
+
*
|
|
7
|
+
* @returns 감지된 로케일
|
|
8
|
+
*/
|
|
9
|
+
static detectClient() {
|
|
10
|
+
if (typeof window === "undefined") {
|
|
11
|
+
return "ko";
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const stored = localStorage.getItem("locale");
|
|
15
|
+
if (stored && this.isValidLocale(stored)) {
|
|
16
|
+
return stored;
|
|
17
|
+
}
|
|
18
|
+
const cookieMatch = document.cookie.split("; ").find((row) => row.startsWith("locale="));
|
|
19
|
+
if (cookieMatch) {
|
|
20
|
+
const locale = cookieMatch.split("=")[1];
|
|
21
|
+
if (this.isValidLocale(locale)) {
|
|
22
|
+
return locale;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const browserLang = navigator.language.split("-")[0].toLowerCase();
|
|
26
|
+
if (this.isValidLocale(browserLang)) {
|
|
27
|
+
return browserLang;
|
|
28
|
+
}
|
|
29
|
+
return "ko";
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return "ko";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 서버 측 로케일 감지
|
|
36
|
+
* 우선순위: Cookie > Accept-Language 헤더 > 기본값
|
|
37
|
+
*
|
|
38
|
+
* @param request - NextRequest 객체
|
|
39
|
+
* @returns 감지된 로케일
|
|
40
|
+
*/
|
|
41
|
+
static detectServer(request) {
|
|
42
|
+
var _a;
|
|
43
|
+
try {
|
|
44
|
+
const cookieLocale = (_a = request.cookies.get("locale")) == null ? void 0 : _a.value;
|
|
45
|
+
if (cookieLocale && this.isValidLocale(cookieLocale)) {
|
|
46
|
+
return cookieLocale;
|
|
47
|
+
}
|
|
48
|
+
const acceptLanguage = request.headers.get("accept-language");
|
|
49
|
+
if (acceptLanguage) {
|
|
50
|
+
const primaryLang = acceptLanguage.split(",")[0].split("-")[0].split(";")[0].toLowerCase().trim();
|
|
51
|
+
if (this.isValidLocale(primaryLang)) {
|
|
52
|
+
return primaryLang;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return "ko";
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return "ko";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 유효한 로케일인지 확인
|
|
62
|
+
*
|
|
63
|
+
* @param locale - 확인할 로케일
|
|
64
|
+
* @returns 유효 여부
|
|
65
|
+
*/
|
|
66
|
+
static isValidLocale(locale) {
|
|
67
|
+
return ["ko", "en", "ja"].includes(locale.toLowerCase());
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 클라이언트에서 로케일 설정 (localStorage + cookie)
|
|
71
|
+
*
|
|
72
|
+
* @param locale - 설정할 로케일
|
|
73
|
+
*/
|
|
74
|
+
static setClientLocale(locale) {
|
|
75
|
+
if (typeof window === "undefined") return;
|
|
76
|
+
try {
|
|
77
|
+
localStorage.setItem("locale", locale);
|
|
78
|
+
const expiresDate = /* @__PURE__ */ new Date();
|
|
79
|
+
expiresDate.setFullYear(expiresDate.getFullYear() + 1);
|
|
80
|
+
document.cookie = `locale=${locale}; expires=${expiresDate.toUTCString()}; path=/; SameSite=Lax`;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("Failed to set locale:", error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 클라이언트에서 로케일 제거
|
|
87
|
+
*/
|
|
88
|
+
static clearClientLocale() {
|
|
89
|
+
if (typeof window === "undefined") return;
|
|
90
|
+
try {
|
|
91
|
+
localStorage.removeItem("locale");
|
|
92
|
+
document.cookie = "locale=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax";
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error("Failed to clear locale:", error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var locale_detector_default = LocaleDetector;
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
LocaleDetector,
|
|
102
|
+
locale_detector_default
|
|
103
|
+
};
|