@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,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* 범용 API 헬퍼 유틸리티
|
|
5
|
+
* 프로젝트 독립적인 재사용 가능한 함수들
|
|
6
|
+
*/
|
|
7
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
8
|
+
import { ZodSchema } from 'zod';
|
|
9
|
+
/**
|
|
10
|
+
* Zod 스키마로 데이터 검증
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const validation = validateAndParse(linkSchema, await req.json());
|
|
15
|
+
* if (!validation.success) return validation.response;
|
|
16
|
+
* const { data } = validation;
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateAndParse<T>(schema: ZodSchema<T>, data: unknown): {
|
|
20
|
+
success: true;
|
|
21
|
+
data: T;
|
|
22
|
+
} | {
|
|
23
|
+
success: false;
|
|
24
|
+
response: NextResponse;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 페이지네이션 파라미터 파싱
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const pagination = parsePagination(req);
|
|
32
|
+
* const { page, limit, skip } = pagination;
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function parsePagination(req: NextRequest, defaultLimit?: number, maxLimit?: number): {
|
|
36
|
+
page: number;
|
|
37
|
+
limit: number;
|
|
38
|
+
skip: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 정렬 파라미터 파싱
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const sort = parseSort(req, 'createdAt', 'desc');
|
|
46
|
+
* const { sortBy, sortOrder } = sort;
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseSort(req: NextRequest, defaultSortBy?: string, defaultOrder?: 'asc' | 'desc'): {
|
|
50
|
+
sortBy: string;
|
|
51
|
+
sortOrder: 'asc' | 'desc';
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 필터 파라미터 파싱
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const filters = parseFilters(req, ['isActive', 'userId', 'search']);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseFilters(req: NextRequest, allowedKeys: string[]): Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* 페이지네이션 응답 생성
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* return createPaginatedResponse(users, total, page, limit);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function createPaginatedResponse<T>(data: T[], total: number, page: number, limit: number): NextResponse;
|
|
71
|
+
/**
|
|
72
|
+
* Admin 권한 확인
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const adminCheck = requireAdmin(user.role);
|
|
77
|
+
* if (!adminCheck.isAdmin) return adminCheck.response;
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function requireAdmin(userRole: string): {
|
|
81
|
+
isAdmin: true;
|
|
82
|
+
} | {
|
|
83
|
+
isAdmin: false;
|
|
84
|
+
response: NextResponse;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Request body 파싱 (에러 핸들링 포함)
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const bodyResult = await parseRequestBody(req);
|
|
92
|
+
* if (!bodyResult.success) return bodyResult.response;
|
|
93
|
+
* const body = bodyResult.data;
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseRequestBody<T = any>(req: NextRequest): Promise<{
|
|
97
|
+
success: true;
|
|
98
|
+
data: T;
|
|
99
|
+
} | {
|
|
100
|
+
success: false;
|
|
101
|
+
response: NextResponse;
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* User Agent 추출
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const userAgent = getUserAgent(req);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function getUserAgent(req: NextRequest): string;
|
|
112
|
+
/**
|
|
113
|
+
* Referer 추출
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const referer = getReferer(req);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function getReferer(req: NextRequest): string | null;
|
|
121
|
+
/**
|
|
122
|
+
* 검색 파라미터 가져오기 (타입 안전)
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const userId = getSearchParam(req, 'userId');
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export declare function getSearchParam(req: NextRequest, key: string, defaultValue?: string): string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Boolean 검색 파라미터 파싱
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const isActive = parseBooleanParam(req, 'isActive');
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function parseBooleanParam(req: NextRequest, key: string, defaultValue?: boolean): boolean | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Number 검색 파라미터 파싱
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const maxCount = parseNumberParam(req, 'maxCount', 100);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function parseNumberParam(req: NextRequest, key: string, defaultValue?: number): number | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPaginatedResponse,
|
|
3
|
+
getReferer,
|
|
4
|
+
getSearchParam,
|
|
5
|
+
getUserAgent,
|
|
6
|
+
parseBooleanParam,
|
|
7
|
+
parseFilters,
|
|
8
|
+
parseNumberParam,
|
|
9
|
+
parsePagination,
|
|
10
|
+
parseRequestBody,
|
|
11
|
+
parseSort,
|
|
12
|
+
requireAdmin,
|
|
13
|
+
validateAndParse
|
|
14
|
+
} from "../chunk-2KAPUVIS.js";
|
|
15
|
+
import "../chunk-Y3OTJH2S.js";
|
|
16
|
+
import "../chunk-ORMEWXMH.js";
|
|
17
|
+
export {
|
|
18
|
+
createPaginatedResponse,
|
|
19
|
+
getReferer,
|
|
20
|
+
getSearchParam,
|
|
21
|
+
getUserAgent,
|
|
22
|
+
parseBooleanParam,
|
|
23
|
+
parseFilters,
|
|
24
|
+
parseNumberParam,
|
|
25
|
+
parsePagination,
|
|
26
|
+
parseRequestBody,
|
|
27
|
+
parseSort,
|
|
28
|
+
requireAdmin,
|
|
29
|
+
validateAndParse
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IQRCodeSettings, IQRCodeDownloadOptions } from '@withwiz/types/qr-code';
|
|
2
|
+
export declare const DEFAULT_QR_SETTINGS: IQRCodeSettings;
|
|
3
|
+
export declare const applyUserBrandToQRSettings: (settings: IQRCodeSettings, userBrand?: {
|
|
4
|
+
brandColor?: string;
|
|
5
|
+
brandLogoUrl?: string;
|
|
6
|
+
}) => IQRCodeSettings;
|
|
7
|
+
export declare const QR_CODE_TEMPLATES: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
settings: IQRCodeSettings;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const downloadQRCode: (svgElement: SVGElement, options: IQRCodeDownloadOptions) => Promise<void>;
|
|
13
|
+
export declare const generateQRCodeUrl: (shortCode: string, baseUrl: string) => string;
|
|
14
|
+
export declare const downloadQRCodeWithLogo: (svgElement: SVGElement, logoDataUrl: string, options: IQRCodeDownloadOptions) => Promise<void>;
|
|
15
|
+
export declare const loadQRSettings: () => IQRCodeSettings;
|
|
16
|
+
export declare const saveQRSettings: (settings: IQRCodeSettings) => void;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "../../chunk-ORMEWXMH.js";
|
|
5
|
+
|
|
6
|
+
// src/utils/client/qr-code.ts
|
|
7
|
+
var DEFAULT_QR_SETTINGS = {
|
|
8
|
+
size: 300,
|
|
9
|
+
// 크기 증가
|
|
10
|
+
color: "#000000",
|
|
11
|
+
bgColor: "#FFFFFF",
|
|
12
|
+
errorCorrectionLevel: "H",
|
|
13
|
+
// 높은 오류 수정 레벨 (로고 삽입 시 필요)
|
|
14
|
+
includeMargin: true,
|
|
15
|
+
marginSize: 4
|
|
16
|
+
// 여백 증가
|
|
17
|
+
};
|
|
18
|
+
var applyUserBrandToQRSettings = (settings, userBrand) => {
|
|
19
|
+
if (!userBrand) return settings;
|
|
20
|
+
return __spreadProps(__spreadValues({}, settings), {
|
|
21
|
+
color: userBrand.brandColor || settings.color,
|
|
22
|
+
logoUrl: userBrand.brandLogoUrl || settings.logoUrl
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var QR_CODE_TEMPLATES = [
|
|
26
|
+
{
|
|
27
|
+
id: "default",
|
|
28
|
+
name: "\uAE30\uBCF8",
|
|
29
|
+
settings: DEFAULT_QR_SETTINGS
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: "dark",
|
|
33
|
+
name: "\uB2E4\uD06C \uD14C\uB9C8",
|
|
34
|
+
settings: __spreadProps(__spreadValues({}, DEFAULT_QR_SETTINGS), {
|
|
35
|
+
color: "#FFFFFF",
|
|
36
|
+
bgColor: "#1F2937"
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "blue",
|
|
41
|
+
name: "\uBE14\uB8E8 \uD14C\uB9C8",
|
|
42
|
+
settings: __spreadProps(__spreadValues({}, DEFAULT_QR_SETTINGS), {
|
|
43
|
+
color: "#2563EB",
|
|
44
|
+
bgColor: "#FFFFFF"
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "green",
|
|
49
|
+
name: "\uADF8\uB9B0 \uD14C\uB9C8",
|
|
50
|
+
settings: __spreadProps(__spreadValues({}, DEFAULT_QR_SETTINGS), {
|
|
51
|
+
color: "#059669",
|
|
52
|
+
bgColor: "#FFFFFF"
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "small",
|
|
57
|
+
name: "\uC791\uC740 \uD06C\uAE30",
|
|
58
|
+
settings: __spreadProps(__spreadValues({}, DEFAULT_QR_SETTINGS), {
|
|
59
|
+
size: 200
|
|
60
|
+
// 최소 크기 증가
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "large",
|
|
65
|
+
name: "\uD070 \uD06C\uAE30",
|
|
66
|
+
settings: __spreadProps(__spreadValues({}, DEFAULT_QR_SETTINGS), {
|
|
67
|
+
size: 512
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
var downloadQRCode = async (svgElement, options) => {
|
|
72
|
+
const { format, filename = "qrcode", quality = 1 } = options;
|
|
73
|
+
if (format === "svg") {
|
|
74
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
75
|
+
const svgBlob = new Blob([svgData], { type: "image/svg+xml;charset=utf-8" });
|
|
76
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
77
|
+
const link = document.createElement("a");
|
|
78
|
+
link.href = svgUrl;
|
|
79
|
+
link.download = `${filename}.svg`;
|
|
80
|
+
document.body.appendChild(link);
|
|
81
|
+
link.click();
|
|
82
|
+
document.body.removeChild(link);
|
|
83
|
+
URL.revokeObjectURL(svgUrl);
|
|
84
|
+
} else {
|
|
85
|
+
const canvas = document.createElement("canvas");
|
|
86
|
+
const ctx = canvas.getContext("2d");
|
|
87
|
+
if (!ctx) return;
|
|
88
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
89
|
+
const img = new Image();
|
|
90
|
+
img.onload = () => {
|
|
91
|
+
canvas.width = img.width;
|
|
92
|
+
canvas.height = img.height;
|
|
93
|
+
ctx.drawImage(img, 0, 0);
|
|
94
|
+
canvas.toBlob(
|
|
95
|
+
(blob) => {
|
|
96
|
+
if (blob) {
|
|
97
|
+
const url = URL.createObjectURL(blob);
|
|
98
|
+
const link = document.createElement("a");
|
|
99
|
+
link.href = url;
|
|
100
|
+
link.download = `${filename}.png`;
|
|
101
|
+
document.body.appendChild(link);
|
|
102
|
+
link.click();
|
|
103
|
+
document.body.removeChild(link);
|
|
104
|
+
URL.revokeObjectURL(url);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"image/png",
|
|
108
|
+
quality
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
img.src = "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svgData)));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var generateQRCodeUrl = (shortCode, baseUrl) => {
|
|
115
|
+
return `${baseUrl}/${shortCode}?src=qr`;
|
|
116
|
+
};
|
|
117
|
+
var downloadQRCodeWithLogo = async (svgElement, logoDataUrl, options) => {
|
|
118
|
+
const { format, filename = "qrcode", quality = 1 } = options;
|
|
119
|
+
if (format === "svg") {
|
|
120
|
+
const svgClone = svgElement.cloneNode(true);
|
|
121
|
+
const logoGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
122
|
+
const logoImage = document.createElementNS("http://www.w3.org/2000/svg", "image");
|
|
123
|
+
logoImage.setAttributeNS("http://www.w3.org/1999/xlink", "href", logoDataUrl);
|
|
124
|
+
logoImage.setAttribute("x", "50%");
|
|
125
|
+
logoImage.setAttribute("y", "50%");
|
|
126
|
+
logoImage.setAttribute("width", "30%");
|
|
127
|
+
logoImage.setAttribute("height", "30%");
|
|
128
|
+
logoImage.setAttribute("transform", "translate(-50%, -50%)");
|
|
129
|
+
logoGroup.appendChild(logoImage);
|
|
130
|
+
svgClone.appendChild(logoGroup);
|
|
131
|
+
const svgData = new XMLSerializer().serializeToString(svgClone);
|
|
132
|
+
const svgBlob = new Blob([svgData], { type: "image/svg+xml;charset=utf-8" });
|
|
133
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
134
|
+
const link = document.createElement("a");
|
|
135
|
+
link.href = svgUrl;
|
|
136
|
+
link.download = `${filename}.svg`;
|
|
137
|
+
document.body.appendChild(link);
|
|
138
|
+
link.click();
|
|
139
|
+
document.body.removeChild(link);
|
|
140
|
+
URL.revokeObjectURL(svgUrl);
|
|
141
|
+
} else {
|
|
142
|
+
const canvas = document.createElement("canvas");
|
|
143
|
+
const ctx = canvas.getContext("2d");
|
|
144
|
+
if (!ctx) return;
|
|
145
|
+
const scale = 2;
|
|
146
|
+
const svgData = new XMLSerializer().serializeToString(svgElement);
|
|
147
|
+
const img = new Image();
|
|
148
|
+
img.onload = () => {
|
|
149
|
+
canvas.width = img.width * scale;
|
|
150
|
+
canvas.height = img.height * scale;
|
|
151
|
+
ctx.imageSmoothingEnabled = true;
|
|
152
|
+
ctx.imageSmoothingQuality = "high";
|
|
153
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
154
|
+
const logoImg = new Image();
|
|
155
|
+
logoImg.onload = () => {
|
|
156
|
+
const logoSize = Math.min(canvas.width, canvas.height) * 0.3;
|
|
157
|
+
const logoX = (canvas.width - logoSize) / 2;
|
|
158
|
+
const logoY = (canvas.height - logoSize) / 2;
|
|
159
|
+
ctx.save();
|
|
160
|
+
ctx.fillStyle = "#FFFFFF";
|
|
161
|
+
ctx.beginPath();
|
|
162
|
+
ctx.arc(logoX + logoSize / 2, logoY + logoSize / 2, logoSize / 2 + 10, 0, 2 * Math.PI);
|
|
163
|
+
ctx.fill();
|
|
164
|
+
ctx.restore();
|
|
165
|
+
ctx.drawImage(logoImg, logoX, logoY, logoSize, logoSize);
|
|
166
|
+
canvas.toBlob(
|
|
167
|
+
(blob) => {
|
|
168
|
+
if (blob) {
|
|
169
|
+
const url = URL.createObjectURL(blob);
|
|
170
|
+
const link = document.createElement("a");
|
|
171
|
+
link.href = url;
|
|
172
|
+
link.download = `${filename}.png`;
|
|
173
|
+
document.body.appendChild(link);
|
|
174
|
+
link.click();
|
|
175
|
+
document.body.removeChild(link);
|
|
176
|
+
URL.revokeObjectURL(url);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"image/png",
|
|
180
|
+
1
|
|
181
|
+
// 최고 품질
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
logoImg.src = logoDataUrl;
|
|
185
|
+
};
|
|
186
|
+
img.src = "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svgData)));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var loadQRSettings = () => {
|
|
190
|
+
if (typeof window === "undefined") return DEFAULT_QR_SETTINGS;
|
|
191
|
+
try {
|
|
192
|
+
const saved = localStorage.getItem("qr-code-settings");
|
|
193
|
+
return saved ? __spreadValues(__spreadValues({}, DEFAULT_QR_SETTINGS), JSON.parse(saved)) : DEFAULT_QR_SETTINGS;
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return DEFAULT_QR_SETTINGS;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var saveQRSettings = (settings) => {
|
|
199
|
+
if (typeof window === "undefined") return;
|
|
200
|
+
try {
|
|
201
|
+
localStorage.setItem("qr-code-settings", JSON.stringify(settings));
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.error("Failed to save QR code settings:", error);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
DEFAULT_QR_SETTINGS,
|
|
208
|
+
QR_CODE_TEMPLATES,
|
|
209
|
+
applyUserBrandToQRSettings,
|
|
210
|
+
downloadQRCode,
|
|
211
|
+
downloadQRCodeWithLogo,
|
|
212
|
+
generateQRCodeUrl,
|
|
213
|
+
loadQRSettings,
|
|
214
|
+
saveQRSettings
|
|
215
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cors
|
|
3
|
+
*
|
|
4
|
+
* CORS 유틸리티 함수
|
|
5
|
+
* - 멀티 도메인 지원: 환경 변수 기반 동적 CORS 설정
|
|
6
|
+
*/
|
|
7
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
8
|
+
/**
|
|
9
|
+
* CORS 설정 옵션
|
|
10
|
+
*/
|
|
11
|
+
export interface CorsConfig {
|
|
12
|
+
/** 기본 URL (선택적) */
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
/** 추가 허용 Origin 목록 */
|
|
15
|
+
additionalOrigins?: string[];
|
|
16
|
+
/** 개발 모드 여부 */
|
|
17
|
+
isDevelopment?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* CORS 설정 초기화
|
|
21
|
+
*/
|
|
22
|
+
export declare function initCorsConfig(config: CorsConfig): void;
|
|
23
|
+
/**
|
|
24
|
+
* 현재 CORS 설정 가져오기
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCorsConfig(): CorsConfig;
|
|
27
|
+
/**
|
|
28
|
+
* 허용된 도메인 목록 (런타임 환경 변수 기반)
|
|
29
|
+
*
|
|
30
|
+
* 우선순위:
|
|
31
|
+
* 1. ALLOWED_ORIGINS 환경 변수 (쉼표로 구분)
|
|
32
|
+
* 2. BASE_URL 또는 NEXT_PUBLIC_BASE_URL에서 자동 추출
|
|
33
|
+
* 3. 개발 환경에서는 localhost 자동 추가
|
|
34
|
+
*/
|
|
35
|
+
export declare function getAllowedOrigins(): string[];
|
|
36
|
+
export declare function isOriginAllowed(origin: string | null | undefined): boolean;
|
|
37
|
+
export declare function setCorsHeaders(response: NextResponse, request?: NextRequest): NextResponse;
|
|
38
|
+
export declare function withCORS(handler: (request: NextRequest) => Promise<Response>): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
39
|
+
export declare function withRestrictedCORS(handler: (request: NextRequest) => Promise<Response>, allowedOrigins?: string[]): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
40
|
+
export declare function withPublicCORS(handler: (request: NextRequest) => Promise<Response>): (request: NextRequest) => Promise<NextResponse<any>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAllowedOrigins,
|
|
3
|
+
getCorsConfig,
|
|
4
|
+
initCorsConfig,
|
|
5
|
+
isOriginAllowed,
|
|
6
|
+
setCorsHeaders,
|
|
7
|
+
withCORS,
|
|
8
|
+
withPublicCORS,
|
|
9
|
+
withRestrictedCORS
|
|
10
|
+
} from "../chunk-GCZOXUDV.js";
|
|
11
|
+
import "../chunk-ORMEWXMH.js";
|
|
12
|
+
export {
|
|
13
|
+
getAllowedOrigins,
|
|
14
|
+
getCorsConfig,
|
|
15
|
+
initCorsConfig,
|
|
16
|
+
isOriginAllowed,
|
|
17
|
+
setCorsHeaders,
|
|
18
|
+
withCORS,
|
|
19
|
+
withPublicCORS,
|
|
20
|
+
withRestrictedCORS
|
|
21
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV Export Utilities
|
|
3
|
+
*
|
|
4
|
+
* CSV 내보내기 공통 유틸리티
|
|
5
|
+
* - 스트리밍 CSV 생성
|
|
6
|
+
* - 배치 처리
|
|
7
|
+
* - 타입 안전한 데이터 변환
|
|
8
|
+
*
|
|
9
|
+
* @created 2025-11-27
|
|
10
|
+
*/
|
|
11
|
+
import { NextResponse } from 'next/server';
|
|
12
|
+
/**
|
|
13
|
+
* CSV 컬럼 정의
|
|
14
|
+
*/
|
|
15
|
+
export interface CsvColumn<T> {
|
|
16
|
+
header: string;
|
|
17
|
+
accessor: keyof T | ((row: T) => string | number | boolean | null | undefined);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* CSV Export 옵션
|
|
21
|
+
*/
|
|
22
|
+
export interface CsvExportOptions<T> {
|
|
23
|
+
/** CSV 파일명 (확장자 제외) */
|
|
24
|
+
filename: string;
|
|
25
|
+
/** 컬럼 정의 */
|
|
26
|
+
columns: CsvColumn<T>[];
|
|
27
|
+
/** BOM 추가 여부 (Excel 호환성) */
|
|
28
|
+
includeBom?: boolean;
|
|
29
|
+
/** 로깅용 컨텍스트 */
|
|
30
|
+
logContext?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 배치 Export 옵션
|
|
34
|
+
*/
|
|
35
|
+
export interface BatchExportOptions<T> extends CsvExportOptions<T> {
|
|
36
|
+
/** 배치 크기 */
|
|
37
|
+
batchSize?: number;
|
|
38
|
+
/** 데이터 페처 함수 */
|
|
39
|
+
fetcher: (cursor?: string) => Promise<{
|
|
40
|
+
data: T[];
|
|
41
|
+
nextCursor?: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* CSV 필드 이스케이프
|
|
46
|
+
* - 쌍따옴표를 이스케이프
|
|
47
|
+
* - 필드를 쌍따옴표로 감싸기
|
|
48
|
+
*/
|
|
49
|
+
export declare function escapeCsvField(value: unknown): string;
|
|
50
|
+
/**
|
|
51
|
+
* 데이터 행을 CSV 문자열로 변환
|
|
52
|
+
*/
|
|
53
|
+
export declare function rowToCsv<T>(row: T, columns: CsvColumn<T>[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* 헤더 행 생성
|
|
56
|
+
*/
|
|
57
|
+
export declare function createCsvHeader<T>(columns: CsvColumn<T>[]): string;
|
|
58
|
+
/**
|
|
59
|
+
* 간단한 CSV Export (메모리에 모든 데이터 로드)
|
|
60
|
+
* - 소규모 데이터에 적합
|
|
61
|
+
* - 최대 10,000 rows 권장
|
|
62
|
+
*/
|
|
63
|
+
export declare function createSimpleCsvResponse<T>(data: T[], options: CsvExportOptions<T>): NextResponse;
|
|
64
|
+
/**
|
|
65
|
+
* 스트리밍 CSV Export (대용량 데이터)
|
|
66
|
+
* - 배치 처리로 메모리 효율적
|
|
67
|
+
* - 대규모 데이터에 적합
|
|
68
|
+
*/
|
|
69
|
+
export declare function createStreamingCsvResponse<T>(options: BatchExportOptions<T>): NextResponse;
|
|
70
|
+
/**
|
|
71
|
+
* 날짜 포맷팅 헬퍼
|
|
72
|
+
*/
|
|
73
|
+
export declare const dateFormatter: {
|
|
74
|
+
/** ISO 형식 (YYYY-MM-DD) */
|
|
75
|
+
iso: (date: Date | null | undefined) => string;
|
|
76
|
+
/** 한국어 형식 */
|
|
77
|
+
korean: (date: Date | null | undefined) => string;
|
|
78
|
+
/** 영어 형식 */
|
|
79
|
+
english: (date: Date | null | undefined) => string;
|
|
80
|
+
/** 커스텀 형식 (date-fns 사용) */
|
|
81
|
+
custom: (date: Date | null | undefined, formatStr: string) => string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Boolean 포맷팅 헬퍼
|
|
85
|
+
*/
|
|
86
|
+
export declare const boolFormatter: {
|
|
87
|
+
/** Active/Inactive */
|
|
88
|
+
activeInactive: (value: boolean) => string;
|
|
89
|
+
/** Yes/No */
|
|
90
|
+
yesNo: (value: boolean) => string;
|
|
91
|
+
/** 1/0 */
|
|
92
|
+
numeric: (value: boolean) => string;
|
|
93
|
+
/** Verified/Not Verified */
|
|
94
|
+
verified: (value: boolean) => string;
|
|
95
|
+
/** 한국어 */
|
|
96
|
+
korean: (value: boolean) => string;
|
|
97
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
boolFormatter,
|
|
3
|
+
createCsvHeader,
|
|
4
|
+
createSimpleCsvResponse,
|
|
5
|
+
createStreamingCsvResponse,
|
|
6
|
+
dateFormatter,
|
|
7
|
+
escapeCsvField,
|
|
8
|
+
rowToCsv
|
|
9
|
+
} from "../chunk-BKGVSC6S.js";
|
|
10
|
+
import "../chunk-EZR55KV2.js";
|
|
11
|
+
import "../chunk-ORMEWXMH.js";
|
|
12
|
+
export {
|
|
13
|
+
boolFormatter,
|
|
14
|
+
createCsvHeader,
|
|
15
|
+
createSimpleCsvResponse,
|
|
16
|
+
createStreamingCsvResponse,
|
|
17
|
+
dateFormatter,
|
|
18
|
+
escapeCsvField,
|
|
19
|
+
rowToCsv
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Message Formatter
|
|
3
|
+
*
|
|
4
|
+
* 사용자 친화적인 에러 메시지로 변환하는 유틸리티
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Redis 에러 메시지를 사용자 친화적으로 정제
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatRedisError(errorMessage: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* 데이터베이스 에러 메시지를 사용자 친화적으로 정제
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatDatabaseError(errorMessage: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 일반적인 에러 메시지를 사용자 친화적으로 정제
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatGenericError(errorMessage: string): string;
|