@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,91 @@
|
|
|
1
|
+
import "../chunk-ORMEWXMH.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/ip-utils.ts
|
|
4
|
+
function isPrivateIP(ip) {
|
|
5
|
+
if (!ip) return false;
|
|
6
|
+
const privateRanges = [
|
|
7
|
+
/^10\./,
|
|
8
|
+
// 10.0.0.0/8
|
|
9
|
+
/^172\.(1[6-9]|2[0-9]|3[01])\./,
|
|
10
|
+
// 172.16.0.0/12
|
|
11
|
+
/^192\.168\./,
|
|
12
|
+
// 192.168.0.0/16
|
|
13
|
+
/^127\./,
|
|
14
|
+
// 127.0.0.0/8 (localhost)
|
|
15
|
+
/^169\.254\./,
|
|
16
|
+
// 169.254.0.0/16 (link-local)
|
|
17
|
+
/^0\./,
|
|
18
|
+
// 0.0.0.0/8
|
|
19
|
+
/^224\./,
|
|
20
|
+
// 224.0.0.0/4 (multicast)
|
|
21
|
+
/^240\./
|
|
22
|
+
// 240.0.0.0/4 (reserved)
|
|
23
|
+
];
|
|
24
|
+
const ipv6PrivateRanges = [
|
|
25
|
+
/^::1$/,
|
|
26
|
+
// localhost
|
|
27
|
+
/^fe80:/,
|
|
28
|
+
// link-local
|
|
29
|
+
/^fc00:/,
|
|
30
|
+
// unique local
|
|
31
|
+
/^fd00:/
|
|
32
|
+
// unique local
|
|
33
|
+
];
|
|
34
|
+
if (ip.includes(".")) {
|
|
35
|
+
return privateRanges.some((range) => range.test(ip));
|
|
36
|
+
}
|
|
37
|
+
if (ip.includes(":")) {
|
|
38
|
+
return ipv6PrivateRanges.some((range) => range.test(ip));
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function isIPv6(ip) {
|
|
43
|
+
return ip.includes(":");
|
|
44
|
+
}
|
|
45
|
+
function normalizeIP(ip) {
|
|
46
|
+
if (!ip) return "";
|
|
47
|
+
if (isIPv6(ip)) {
|
|
48
|
+
return ip.toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
return ip;
|
|
51
|
+
}
|
|
52
|
+
function extractClientIp(headers) {
|
|
53
|
+
const cf = headers.get("cf-connecting-ip");
|
|
54
|
+
if (cf && isValidIP(cf.trim())) return cf.trim();
|
|
55
|
+
const trueClientIp = headers.get("true-client-ip");
|
|
56
|
+
if (trueClientIp && isValidIP(trueClientIp.trim())) return trueClientIp.trim();
|
|
57
|
+
const xri = headers.get("x-real-ip");
|
|
58
|
+
if (xri && isValidIP(xri.trim())) return xri.trim();
|
|
59
|
+
const xff = headers.get("x-forwarded-for");
|
|
60
|
+
if (xff) {
|
|
61
|
+
const ips = xff.split(",").map((ip) => ip.trim()).filter(Boolean);
|
|
62
|
+
if (ips.length > 0 && isValidIP(ips[0])) {
|
|
63
|
+
return ips[0];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const xc = headers.get("x-client-ip");
|
|
67
|
+
if (xc && isValidIP(xc.trim())) return xc.trim();
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function isValidIP(ip) {
|
|
71
|
+
if (!ip || typeof ip !== "string") return false;
|
|
72
|
+
if (ip.includes(".")) {
|
|
73
|
+
const parts = ip.split(".");
|
|
74
|
+
if (parts.length !== 4) return false;
|
|
75
|
+
return parts.every((part) => {
|
|
76
|
+
const num = parseInt(part, 10);
|
|
77
|
+
return !isNaN(num) && num >= 0 && num <= 255;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (ip.includes(":")) {
|
|
81
|
+
return /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(ip) || /^::1$/.test(ip) || /^::/.test(ip) || /^2001:4860:4860::8888$/.test(ip);
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
extractClientIp,
|
|
87
|
+
isIPv6,
|
|
88
|
+
isPrivateIP,
|
|
89
|
+
isValidIP,
|
|
90
|
+
normalizeIP
|
|
91
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimistic Locking Utility
|
|
3
|
+
*
|
|
4
|
+
* 다중 인스턴스 환경에서 동시 업데이트 충돌을 감지하기 위한 낙관적 락 유틸리티.
|
|
5
|
+
* Prisma의 updateMany + where version 조건을 활용.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 낙관적 락이 적용된 업데이트 실행
|
|
9
|
+
*
|
|
10
|
+
* @param updateFn - Prisma updateMany를 실행하는 함수. count를 반환해야 함.
|
|
11
|
+
* @param entityName - 엔티티 이름 (에러 메시지용)
|
|
12
|
+
* @throws AppError 40901 (Conflict) - 버전 충돌 시
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* await withOptimisticLock(
|
|
17
|
+
* () => prisma.link.updateMany({
|
|
18
|
+
* where: { id: linkId, version: currentVersion },
|
|
19
|
+
* data: { title: newTitle, version: { increment: 1 } },
|
|
20
|
+
* }),
|
|
21
|
+
* 'Link'
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function withOptimisticLock(updateFn: () => Promise<{
|
|
26
|
+
count: number;
|
|
27
|
+
}>, entityName?: string): Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppError
|
|
3
|
+
} from "../chunk-MLGO3HLS.js";
|
|
4
|
+
import "../chunk-Y3OTJH2S.js";
|
|
5
|
+
import "../chunk-ORMEWXMH.js";
|
|
6
|
+
|
|
7
|
+
// src/utils/optimistic-lock.ts
|
|
8
|
+
async function withOptimisticLock(updateFn, entityName = "Record") {
|
|
9
|
+
const result = await updateFn();
|
|
10
|
+
if (result.count === 0) {
|
|
11
|
+
throw new AppError(40904, `${entityName} was modified by another request. Please retry.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
withOptimisticLock
|
|
16
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sanitizer.ts
|
|
3
|
+
*
|
|
4
|
+
* XSS 방지를 위한 입력값 정제(Sanitization) 유틸리티
|
|
5
|
+
* - HTML 태그 제거
|
|
6
|
+
* - 악성 스크립트 방지
|
|
7
|
+
* - 안전한 문자열 처리
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* XSS 방지를 위한 HTML 태그 제거
|
|
11
|
+
* - 모든 HTML 태그 제거
|
|
12
|
+
* - 이스케이프된 HTML 엔티티 처리
|
|
13
|
+
* - 공백 정리
|
|
14
|
+
*
|
|
15
|
+
* @param input - 정제할 문자열
|
|
16
|
+
* @returns 정제된 문자열
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* sanitizeHtml('<script>alert("xss")</script>Hello') // 'Hello'
|
|
20
|
+
* sanitizeHtml('Hello <b>World</b>') // 'Hello World'
|
|
21
|
+
*/
|
|
22
|
+
export declare function sanitizeHtml(input: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* JavaScript 이벤트 핸들러 제거
|
|
25
|
+
* - onclick, onerror 등 이벤트 핸들러 제거
|
|
26
|
+
*
|
|
27
|
+
* @param input - 정제할 문자열
|
|
28
|
+
* @returns 정제된 문자열
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeEventHandlers(input: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* URL에서 JavaScript 프로토콜 제거
|
|
33
|
+
* - javascript:, data: 등 위험한 프로토콜 제거
|
|
34
|
+
*
|
|
35
|
+
* @param url - 검증할 URL
|
|
36
|
+
* @returns 안전한 URL 또는 빈 문자열
|
|
37
|
+
*/
|
|
38
|
+
export declare function sanitizeUrl(url: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* 모든 sanitization을 통합 적용
|
|
41
|
+
* - HTML 태그 제거
|
|
42
|
+
* - 이벤트 핸들러 제거
|
|
43
|
+
* - 공백 정규화
|
|
44
|
+
*
|
|
45
|
+
* @param input - 정제할 문자열
|
|
46
|
+
* @returns 정제된 문자열
|
|
47
|
+
*/
|
|
48
|
+
export declare function sanitizeInput(input: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* 배열의 모든 문자열 요소에 sanitization 적용
|
|
51
|
+
*
|
|
52
|
+
* @param arr - 정제할 문자열 배열
|
|
53
|
+
* @returns 정제된 문자열 배열
|
|
54
|
+
*/
|
|
55
|
+
export declare function sanitizeArray(arr: string[]): string[];
|
|
56
|
+
/**
|
|
57
|
+
* 객체의 문자열 필드에 sanitization 적용
|
|
58
|
+
*
|
|
59
|
+
* @param obj - 정제할 객체
|
|
60
|
+
* @param fields - 정제할 필드 이름 배열
|
|
61
|
+
* @returns 정제된 객체
|
|
62
|
+
*/
|
|
63
|
+
export declare function sanitizeObjectFields<T extends Record<string, unknown>>(obj: T, fields: (keyof T)[]): T;
|
|
64
|
+
declare const _default: {
|
|
65
|
+
sanitizeHtml: typeof sanitizeHtml;
|
|
66
|
+
sanitizeUrl: typeof sanitizeUrl;
|
|
67
|
+
sanitizeInput: typeof sanitizeInput;
|
|
68
|
+
sanitizeArray: typeof sanitizeArray;
|
|
69
|
+
sanitizeObjectFields: typeof sanitizeObjectFields;
|
|
70
|
+
removeEventHandlers: typeof removeEventHandlers;
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removeEventHandlers,
|
|
3
|
+
sanitizeArray,
|
|
4
|
+
sanitizeHtml,
|
|
5
|
+
sanitizeInput,
|
|
6
|
+
sanitizeObjectFields,
|
|
7
|
+
sanitizeUrl,
|
|
8
|
+
sanitizer_default
|
|
9
|
+
} from "../chunk-SR65BF6X.js";
|
|
10
|
+
import "../chunk-ORMEWXMH.js";
|
|
11
|
+
export {
|
|
12
|
+
sanitizer_default as default,
|
|
13
|
+
removeEventHandlers,
|
|
14
|
+
sanitizeArray,
|
|
15
|
+
sanitizeHtml,
|
|
16
|
+
sanitizeInput,
|
|
17
|
+
sanitizeObjectFields,
|
|
18
|
+
sanitizeUrl
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shared-utils (범용 유틸리티)
|
|
3
|
+
*
|
|
4
|
+
* 이 파일은 프로젝트 독립적인 범용 유틸리티만 포함합니다.
|
|
5
|
+
* URL shortener 비즈니스 로직은 <your-project>/utils/ 에 위치합니다.
|
|
6
|
+
*
|
|
7
|
+
* @see <your-project>/utils/alias-validation.ts - Alias 검증 관련 함수
|
|
8
|
+
*/
|
|
9
|
+
import type { IGeoLocationData, IGeoIPResponse } from '@withwiz/types/database';
|
|
10
|
+
export type { IGeoLocationData, IGeoIPResponse };
|
|
11
|
+
export * from './url-normalizer';
|
|
12
|
+
export * from './format-number';
|
|
13
|
+
export * from './short-code-generator';
|
|
14
|
+
/**
|
|
15
|
+
* 에러 메시지 생성 (템플릿 변수 치환)
|
|
16
|
+
*
|
|
17
|
+
* @param code - 에러 코드
|
|
18
|
+
* @param message - 에러 메시지 템플릿
|
|
19
|
+
* @param replacements - 치환할 변수들
|
|
20
|
+
* @returns 에러 객체
|
|
21
|
+
*/
|
|
22
|
+
export declare function createValidationError(code: string, message: string, replacements?: Record<string, string>): {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateShortCode,
|
|
3
|
+
generateUniqueShortCode
|
|
4
|
+
} from "../chunk-5ATB5D6S.js";
|
|
5
|
+
import {
|
|
6
|
+
SUPPORTED_SCHEMES,
|
|
7
|
+
extractScheme,
|
|
8
|
+
getUrlType,
|
|
9
|
+
hasValidScheme,
|
|
10
|
+
isAppScheme,
|
|
11
|
+
isWebUrl,
|
|
12
|
+
normalizeUrl,
|
|
13
|
+
validateUrl
|
|
14
|
+
} from "../chunk-VWODEQ5C.js";
|
|
15
|
+
import {
|
|
16
|
+
formatChartNumber,
|
|
17
|
+
formatNumber
|
|
18
|
+
} from "../chunk-TDZJ6SAI.js";
|
|
19
|
+
import "../chunk-ORMEWXMH.js";
|
|
20
|
+
|
|
21
|
+
// src/utils/shared-utils.ts
|
|
22
|
+
function createValidationError(code, message, replacements = {}) {
|
|
23
|
+
let finalMessage = message;
|
|
24
|
+
Object.entries(replacements).forEach(([key, value]) => {
|
|
25
|
+
finalMessage = finalMessage.replace(`{${key}}`, value);
|
|
26
|
+
});
|
|
27
|
+
return { code, message: finalMessage };
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
SUPPORTED_SCHEMES,
|
|
31
|
+
createValidationError,
|
|
32
|
+
extractScheme,
|
|
33
|
+
formatChartNumber,
|
|
34
|
+
formatNumber,
|
|
35
|
+
generateShortCode,
|
|
36
|
+
generateUniqueShortCode,
|
|
37
|
+
getUrlType,
|
|
38
|
+
hasValidScheme,
|
|
39
|
+
isAppScheme,
|
|
40
|
+
isWebUrl,
|
|
41
|
+
normalizeUrl,
|
|
42
|
+
validateUrl
|
|
43
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 단축 코드 생성 전용 유틸리티
|
|
3
|
+
* 순수 함수로 구현하여 외부 의존성 없음
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 기본 단축 코드 생성 함수
|
|
7
|
+
* @param length - 생성할 코드 길이 (기본값: 8)
|
|
8
|
+
* @returns 생성된 단축 코드
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateShortCode(length?: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* 단축 코드 생성 옵션 인터페이스
|
|
13
|
+
*/
|
|
14
|
+
export interface IShortCodeOptions {
|
|
15
|
+
length?: number;
|
|
16
|
+
maxAttempts?: number;
|
|
17
|
+
checkDuplicate?: (code: string) => Promise<boolean> | boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 중복 검사와 함께 고유한 단축 코드 생성
|
|
21
|
+
* @param options - 생성 옵션
|
|
22
|
+
* @returns 고유한 단축 코드
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateUniqueShortCode(options?: IShortCodeOptions): Promise<string>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 글로벌 서비스를 위한 타임존 유틸리티
|
|
3
|
+
* 데이터베이스: UTC 저장
|
|
4
|
+
* 프론트엔드: 사용자 로컬 타임존 표시
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 현재 시간을 UTC로 반환 (데이터베이스 저장용)
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCurrentUTC(): Date;
|
|
10
|
+
/**
|
|
11
|
+
* UTC 시간을 사용자 로컬 타임존으로 변환
|
|
12
|
+
*/
|
|
13
|
+
export declare function utcToLocal(utcDate: Date | string, timezone?: string): Date;
|
|
14
|
+
/**
|
|
15
|
+
* 사용자 로컬 시간을 UTC로 변환 (데이터베이스 저장용)
|
|
16
|
+
*/
|
|
17
|
+
export declare function localToUTC(localDate: Date | string): Date;
|
|
18
|
+
/**
|
|
19
|
+
* 시간을 사용자 친화적인 형식으로 포맷팅 (로컬 타임존 기준)
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatUserFriendlyDate(date: Date | string, options?: Intl.DateTimeFormatOptions): string;
|
|
22
|
+
/**
|
|
23
|
+
* 간단한 날짜 포맷 (YYYY-MM-DD)
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatSimpleDate(date: Date | string): string;
|
|
26
|
+
/**
|
|
27
|
+
* 간단한 시간 포맷 (HH:MM:SS)
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatSimpleTime(date: Date | string): string;
|
|
30
|
+
/**
|
|
31
|
+
* 전체 날짜 시간 포맷 (YYYY-MM-DD HH:MM:SS)
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatFullDateTime(date: Date | string): string;
|
|
34
|
+
/**
|
|
35
|
+
* 테이블용 날짜 시간 포맷 (2줄 표시)
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatTableDateTime(date: Date | string): {
|
|
38
|
+
date: string;
|
|
39
|
+
time: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Relative time display (e.g., "3h ago", "3d ago")
|
|
43
|
+
*/
|
|
44
|
+
export declare function getRelativeTime(date: Date | string): string;
|
|
45
|
+
/**
|
|
46
|
+
* 타임존 정보 가져오기
|
|
47
|
+
*/
|
|
48
|
+
export declare function getUserTimezone(): string;
|
|
49
|
+
/**
|
|
50
|
+
* 타임존 오프셋 가져오기 (분 단위)
|
|
51
|
+
*/
|
|
52
|
+
export declare function getTimezoneOffset(): number;
|
|
53
|
+
/**
|
|
54
|
+
* UTC 시간을 ISO 문자열로 변환 (API 응답용)
|
|
55
|
+
*/
|
|
56
|
+
export declare function toUTCISOString(date: Date | string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatFullDateTime,
|
|
3
|
+
formatSimpleDate,
|
|
4
|
+
formatSimpleTime,
|
|
5
|
+
formatTableDateTime,
|
|
6
|
+
formatUserFriendlyDate,
|
|
7
|
+
getCurrentUTC,
|
|
8
|
+
getRelativeTime,
|
|
9
|
+
getTimezoneOffset,
|
|
10
|
+
getUserTimezone,
|
|
11
|
+
localToUTC,
|
|
12
|
+
toUTCISOString,
|
|
13
|
+
utcToLocal
|
|
14
|
+
} from "../chunk-TRBKJ7JT.js";
|
|
15
|
+
import "../chunk-ORMEWXMH.js";
|
|
16
|
+
export {
|
|
17
|
+
formatFullDateTime,
|
|
18
|
+
formatSimpleDate,
|
|
19
|
+
formatSimpleTime,
|
|
20
|
+
formatTableDateTime,
|
|
21
|
+
formatUserFriendlyDate,
|
|
22
|
+
getCurrentUTC,
|
|
23
|
+
getRelativeTime,
|
|
24
|
+
getTimezoneOffset,
|
|
25
|
+
getUserTimezone,
|
|
26
|
+
localToUTC,
|
|
27
|
+
toUTCISOString,
|
|
28
|
+
utcToLocal
|
|
29
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 범용 타입 가드 함수들
|
|
3
|
+
*
|
|
4
|
+
* 프로젝트 독립적인 런타임 타입 검증 유틸리티
|
|
5
|
+
* TypeScript의 타입 좁히기를 활용합니다.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* null이 아닌 값인지 확인
|
|
9
|
+
*/
|
|
10
|
+
export declare function isNotNull<T>(value: T | null): value is T;
|
|
11
|
+
/**
|
|
12
|
+
* undefined가 아닌 값인지 확인
|
|
13
|
+
*/
|
|
14
|
+
export declare function isDefined<T>(value: T | undefined): value is T;
|
|
15
|
+
/**
|
|
16
|
+
* null과 undefined가 아닌 값인지 확인
|
|
17
|
+
*/
|
|
18
|
+
export declare function isPresent<T>(value: T | null | undefined): value is T;
|
|
19
|
+
/**
|
|
20
|
+
* 문자열인지 확인
|
|
21
|
+
*/
|
|
22
|
+
export declare function isString(value: unknown): value is string;
|
|
23
|
+
/**
|
|
24
|
+
* 숫자인지 확인
|
|
25
|
+
*/
|
|
26
|
+
export declare function isNumber(value: unknown): value is number;
|
|
27
|
+
/**
|
|
28
|
+
* boolean인지 확인
|
|
29
|
+
*/
|
|
30
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 객체인지 확인 (null 제외)
|
|
33
|
+
*/
|
|
34
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* 배열인지 확인
|
|
37
|
+
*/
|
|
38
|
+
export declare function isArray<T = unknown>(value: unknown): value is T[];
|
|
39
|
+
/**
|
|
40
|
+
* 함수인지 확인
|
|
41
|
+
*/
|
|
42
|
+
export declare function isFunction(value: unknown): value is Function;
|
|
43
|
+
/**
|
|
44
|
+
* 유효한 이메일 형식인지 확인
|
|
45
|
+
*/
|
|
46
|
+
export declare function isValidEmail(value: unknown): value is string;
|
|
47
|
+
/**
|
|
48
|
+
* 유효한 URL 형식인지 확인
|
|
49
|
+
*/
|
|
50
|
+
export declare function isValidUrl(value: unknown): value is string;
|
|
51
|
+
/**
|
|
52
|
+
* 유효한 IPv4 주소인지 확인
|
|
53
|
+
*/
|
|
54
|
+
export declare function isIPv4(value: unknown): value is string;
|
|
55
|
+
/**
|
|
56
|
+
* 유효한 IPv6 주소인지 확인
|
|
57
|
+
*/
|
|
58
|
+
export declare function isIPv6(value: unknown): value is string;
|
|
59
|
+
/**
|
|
60
|
+
* 유효한 IP 주소인지 확인 (IPv4 또는 IPv6)
|
|
61
|
+
*/
|
|
62
|
+
export declare function isIPAddress(value: unknown): value is string;
|
|
63
|
+
/**
|
|
64
|
+
* 유효한 Date 객체인지 확인
|
|
65
|
+
*/
|
|
66
|
+
export declare function isValidDate(value: unknown): value is Date;
|
|
67
|
+
/**
|
|
68
|
+
* ISO 8601 날짜 문자열인지 확인
|
|
69
|
+
*/
|
|
70
|
+
export declare function isISODateString(value: unknown): value is string;
|
|
71
|
+
/**
|
|
72
|
+
* 날짜 문자열로 파싱 가능한지 확인
|
|
73
|
+
*/
|
|
74
|
+
export declare function isDateParseable(value: unknown): value is string | number | Date;
|
|
75
|
+
/**
|
|
76
|
+
* 정렬 순서 타입
|
|
77
|
+
*/
|
|
78
|
+
export type SortOrder = 'asc' | 'desc';
|
|
79
|
+
/**
|
|
80
|
+
* 정렬 순서 타입 가드
|
|
81
|
+
*/
|
|
82
|
+
export declare function isSortOrder(value: unknown): value is SortOrder;
|
|
83
|
+
/**
|
|
84
|
+
* API 성공 응답 타입
|
|
85
|
+
*/
|
|
86
|
+
export interface ApiSuccessResponse<T = unknown> {
|
|
87
|
+
success: true;
|
|
88
|
+
data: T;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* API 에러 응답 타입
|
|
92
|
+
*/
|
|
93
|
+
export interface ApiErrorResponse {
|
|
94
|
+
success: false;
|
|
95
|
+
error: {
|
|
96
|
+
code: string;
|
|
97
|
+
message: string;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* API 응답 유니온 타입
|
|
102
|
+
*/
|
|
103
|
+
export type ApiResponseType<T = unknown> = ApiSuccessResponse<T> | ApiErrorResponse;
|
|
104
|
+
/**
|
|
105
|
+
* API 성공 응답인지 확인
|
|
106
|
+
*/
|
|
107
|
+
export declare function isApiSuccessResponse<T>(response: ApiResponseType<T>): response is ApiSuccessResponse<T>;
|
|
108
|
+
/**
|
|
109
|
+
* API 에러 응답인지 확인
|
|
110
|
+
*/
|
|
111
|
+
export declare function isApiErrorResponse<T>(response: ApiResponseType<T>): response is ApiErrorResponse;
|
|
112
|
+
/**
|
|
113
|
+
* 유효한 JSON 문자열인지 확인
|
|
114
|
+
*/
|
|
115
|
+
export declare function isValidJSON(value: unknown): value is string;
|
|
116
|
+
/**
|
|
117
|
+
* JSON 직렬화 가능한지 확인
|
|
118
|
+
*/
|
|
119
|
+
export declare function isJSONSerializable(value: unknown): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* 빈 문자열인지 확인
|
|
122
|
+
*/
|
|
123
|
+
export declare function isEmptyString(value: unknown): value is '';
|
|
124
|
+
/**
|
|
125
|
+
* 빈 배열인지 확인
|
|
126
|
+
*/
|
|
127
|
+
export declare function isEmptyArray(value: unknown): value is [];
|
|
128
|
+
/**
|
|
129
|
+
* 빈 객체인지 확인
|
|
130
|
+
*/
|
|
131
|
+
export declare function isEmptyObject(value: unknown): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* 빈 값인지 확인 (null, undefined, '', [], {})
|
|
134
|
+
*/
|
|
135
|
+
export declare function isEmpty(value: unknown): boolean;
|
|
136
|
+
declare const _default: {
|
|
137
|
+
isNotNull: typeof isNotNull;
|
|
138
|
+
isDefined: typeof isDefined;
|
|
139
|
+
isPresent: typeof isPresent;
|
|
140
|
+
isString: typeof isString;
|
|
141
|
+
isNumber: typeof isNumber;
|
|
142
|
+
isBoolean: typeof isBoolean;
|
|
143
|
+
isObject: typeof isObject;
|
|
144
|
+
isArray: typeof isArray;
|
|
145
|
+
isFunction: typeof isFunction;
|
|
146
|
+
isValidEmail: typeof isValidEmail;
|
|
147
|
+
isValidUrl: typeof isValidUrl;
|
|
148
|
+
isIPv4: typeof isIPv4;
|
|
149
|
+
isIPv6: typeof isIPv6;
|
|
150
|
+
isIPAddress: typeof isIPAddress;
|
|
151
|
+
isValidDate: typeof isValidDate;
|
|
152
|
+
isISODateString: typeof isISODateString;
|
|
153
|
+
isDateParseable: typeof isDateParseable;
|
|
154
|
+
isSortOrder: typeof isSortOrder;
|
|
155
|
+
isApiSuccessResponse: typeof isApiSuccessResponse;
|
|
156
|
+
isApiErrorResponse: typeof isApiErrorResponse;
|
|
157
|
+
isValidJSON: typeof isValidJSON;
|
|
158
|
+
isJSONSerializable: typeof isJSONSerializable;
|
|
159
|
+
isEmptyString: typeof isEmptyString;
|
|
160
|
+
isEmptyArray: typeof isEmptyArray;
|
|
161
|
+
isEmptyObject: typeof isEmptyObject;
|
|
162
|
+
isEmpty: typeof isEmpty;
|
|
163
|
+
};
|
|
164
|
+
export default _default;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isApiErrorResponse,
|
|
3
|
+
isApiSuccessResponse,
|
|
4
|
+
isArray,
|
|
5
|
+
isBoolean,
|
|
6
|
+
isDateParseable,
|
|
7
|
+
isDefined,
|
|
8
|
+
isEmpty,
|
|
9
|
+
isEmptyArray,
|
|
10
|
+
isEmptyObject,
|
|
11
|
+
isEmptyString,
|
|
12
|
+
isFunction,
|
|
13
|
+
isIPAddress,
|
|
14
|
+
isIPv4,
|
|
15
|
+
isIPv6,
|
|
16
|
+
isISODateString,
|
|
17
|
+
isJSONSerializable,
|
|
18
|
+
isNotNull,
|
|
19
|
+
isNumber,
|
|
20
|
+
isObject,
|
|
21
|
+
isPresent,
|
|
22
|
+
isSortOrder,
|
|
23
|
+
isString,
|
|
24
|
+
isValidDate,
|
|
25
|
+
isValidEmail,
|
|
26
|
+
isValidJSON,
|
|
27
|
+
isValidUrl,
|
|
28
|
+
type_guards_default
|
|
29
|
+
} from "../chunk-EUQATJLI.js";
|
|
30
|
+
import "../chunk-ORMEWXMH.js";
|
|
31
|
+
export {
|
|
32
|
+
type_guards_default as default,
|
|
33
|
+
isApiErrorResponse,
|
|
34
|
+
isApiSuccessResponse,
|
|
35
|
+
isArray,
|
|
36
|
+
isBoolean,
|
|
37
|
+
isDateParseable,
|
|
38
|
+
isDefined,
|
|
39
|
+
isEmpty,
|
|
40
|
+
isEmptyArray,
|
|
41
|
+
isEmptyObject,
|
|
42
|
+
isEmptyString,
|
|
43
|
+
isFunction,
|
|
44
|
+
isIPAddress,
|
|
45
|
+
isIPv4,
|
|
46
|
+
isIPv6,
|
|
47
|
+
isISODateString,
|
|
48
|
+
isJSONSerializable,
|
|
49
|
+
isNotNull,
|
|
50
|
+
isNumber,
|
|
51
|
+
isObject,
|
|
52
|
+
isPresent,
|
|
53
|
+
isSortOrder,
|
|
54
|
+
isString,
|
|
55
|
+
isValidDate,
|
|
56
|
+
isValidEmail,
|
|
57
|
+
isValidJSON,
|
|
58
|
+
isValidUrl
|
|
59
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL 정규화 및 검증 유틸리티
|
|
3
|
+
* 다양한 스키마(http, https, mailto, tel, 앱 스키마 등) 지원
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 지원되는 URL 스키마 목록
|
|
7
|
+
*/
|
|
8
|
+
export declare const SUPPORTED_SCHEMES: string[];
|
|
9
|
+
/**
|
|
10
|
+
* URL이 유효한 스키마를 가지고 있는지 확인
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasValidScheme(url: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* URL에서 스키마 추출
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractScheme(url: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* URL 정규화
|
|
19
|
+
* - 스키마가 없으면 https:// 추가
|
|
20
|
+
* - 이미 유효한 스키마가 있으면 그대로 반환
|
|
21
|
+
* - 공백 제거 및 기본적인 정리
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeUrl(url: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* URL 검증 결과의 메시지 키 (i18n용)
|
|
26
|
+
*/
|
|
27
|
+
export type UrlValidationMessageKey = 'validUrl' | 'urlRequired' | 'unsupportedProtocol' | 'invalidDomain' | 'invalidDomainFormat' | 'invalidEmail' | 'invalidPhone' | 'urlTooLong' | 'invalidUrlFormat';
|
|
28
|
+
/**
|
|
29
|
+
* URL 검증 (다양한 스키마 지원)
|
|
30
|
+
* @param url 검증할 URL
|
|
31
|
+
* @param options.skipNormalization true이면 URL을 정규화하지 않고 검증 (기본: false)
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateUrl(url: string, options?: {
|
|
34
|
+
skipNormalization?: boolean;
|
|
35
|
+
}): {
|
|
36
|
+
isValid: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
messageKey: UrlValidationMessageKey;
|
|
39
|
+
messageParams?: Record<string, string>;
|
|
40
|
+
normalizedUrl?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* URL이 웹 URL인지 확인 (http 또는 https)
|
|
44
|
+
*/
|
|
45
|
+
export declare function isWebUrl(url: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* URL이 앱 스키마인지 확인
|
|
48
|
+
*/
|
|
49
|
+
export declare function isAppScheme(url: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* URL 타입 반환 (웹, 이메일, 전화, 앱 등)
|
|
52
|
+
*/
|
|
53
|
+
export declare function getUrlType(url: string): 'web' | 'email' | 'tel' | 'app' | 'other';
|