@charzing/vehicle-utils 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +121 -121
- package/dist/cjs/index.js +237 -85
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +121 -121
- package/dist/esm/index.mjs +225 -81
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +7 -3
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Firestore } from 'firebase/firestore';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 브랜드 관련 타입 정의
|
|
3
5
|
*/
|
|
@@ -79,7 +81,7 @@ type ModelSlug = string;
|
|
|
79
81
|
/**
|
|
80
82
|
* 모델 매핑 결과
|
|
81
83
|
*/
|
|
82
|
-
interface ModelMapping {
|
|
84
|
+
interface ModelMapping$1 {
|
|
83
85
|
/** Firestore ID (소문자, 하이픈) */
|
|
84
86
|
firestoreId: ModelId;
|
|
85
87
|
/** 한글 모델명 */
|
|
@@ -450,12 +452,63 @@ declare function getStorageBrandName(brandId: BrandId): StorageBrandName;
|
|
|
450
452
|
* // }
|
|
451
453
|
* ```
|
|
452
454
|
*/
|
|
453
|
-
declare function getBrandMapping(brandInput: string): BrandMapping;
|
|
455
|
+
declare function getBrandMapping$1(brandInput: string): BrandMapping;
|
|
454
456
|
/**
|
|
455
457
|
* 지원되는 모든 브랜드 ID 목록
|
|
456
458
|
*/
|
|
457
459
|
declare const SUPPORTED_BRANDS: BrandId[];
|
|
458
460
|
|
|
461
|
+
/**
|
|
462
|
+
* 동적 브랜드 매핑 시스템
|
|
463
|
+
*
|
|
464
|
+
* Firestore에서 실시간으로 브랜드 정보를 조회하여 캐싱
|
|
465
|
+
* 새로운 브랜드 추가 시 코드 수정 불필요
|
|
466
|
+
*/
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Firestore에서 브랜드 정보를 조회하여 캐시 초기화
|
|
470
|
+
*
|
|
471
|
+
* @param firestore - Firestore 인스턴스
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* import { initializeBrandMappings } from '@charzing/vehicle-utils';
|
|
476
|
+
* import { db } from './firebase';
|
|
477
|
+
*
|
|
478
|
+
* // 앱 시작 시 한 번만 호출
|
|
479
|
+
* await initializeBrandMappings(db);
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
declare function initializeBrandMappings(firestore: Firestore): Promise<void>;
|
|
483
|
+
/**
|
|
484
|
+
* 브랜드 매핑 정보 조회
|
|
485
|
+
*
|
|
486
|
+
* @param brandInput - 브랜드명 (한글/영문/ID 모두 가능)
|
|
487
|
+
* @returns 브랜드 매핑 정보 또는 null
|
|
488
|
+
*
|
|
489
|
+
* @throws {Error} 초기화되지 않은 경우
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* getBrandMapping('현대'); // { firestoreId: 'hyundai', ... }
|
|
494
|
+
* getBrandMapping('HYUNDAI'); // { firestoreId: 'hyundai', ... }
|
|
495
|
+
* getBrandMapping('hyundai'); // { firestoreId: 'hyundai', ... }
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
declare function getBrandMapping(brandInput: string): BrandMapping | null;
|
|
499
|
+
/**
|
|
500
|
+
* 초기화 상태 확인
|
|
501
|
+
*/
|
|
502
|
+
declare function isInitialized$1(): boolean;
|
|
503
|
+
/**
|
|
504
|
+
* 캐시 초기화 (테스트용)
|
|
505
|
+
*/
|
|
506
|
+
declare function resetCache$1(): void;
|
|
507
|
+
/**
|
|
508
|
+
* 캐시된 브랜드 수
|
|
509
|
+
*/
|
|
510
|
+
declare function getCachedBrandCount(): number;
|
|
511
|
+
|
|
459
512
|
/**
|
|
460
513
|
* 모델 매핑 유틸리티
|
|
461
514
|
*
|
|
@@ -559,156 +612,103 @@ declare function getModelSlug(modelInput: string): ModelSlug;
|
|
|
559
612
|
* // }
|
|
560
613
|
* ```
|
|
561
614
|
*/
|
|
562
|
-
declare function getModelMapping(modelInput: string, englishName?: string, koreanName?: string): ModelMapping;
|
|
615
|
+
declare function getModelMapping$1(modelInput: string, englishName?: string, koreanName?: string): ModelMapping$1;
|
|
563
616
|
|
|
564
617
|
/**
|
|
565
|
-
*
|
|
618
|
+
* 동적 모델 매핑 시스템
|
|
566
619
|
*
|
|
567
|
-
*
|
|
620
|
+
* Firestore에서 실시간으로 모델 정보를 조회하여 캐싱
|
|
621
|
+
* 새로운 모델 추가 시 코드 수정 불필요
|
|
568
622
|
*/
|
|
569
623
|
|
|
570
624
|
/**
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* @param params - 차량 이미지 파라미터
|
|
574
|
-
* @param extension - 파일 확장자 (기본: 'png')
|
|
575
|
-
* @returns 이미지 파일명
|
|
576
|
-
*
|
|
577
|
-
* @example
|
|
578
|
-
* ```typescript
|
|
579
|
-
* generateImageFilename({
|
|
580
|
-
* brand: 'hyundai',
|
|
581
|
-
* model: 'ioniq-5',
|
|
582
|
-
* year: 2024
|
|
583
|
-
* });
|
|
584
|
-
* // 'hyundai__ioniq-5__2024.png'
|
|
585
|
-
*
|
|
586
|
-
* generateImageFilename({
|
|
587
|
-
* brand: 'mini',
|
|
588
|
-
* model: 'cooper',
|
|
589
|
-
* year: 2025,
|
|
590
|
-
* trim: 'jcw'
|
|
591
|
-
* });
|
|
592
|
-
* // 'mini__cooper__2025__jcw.png'
|
|
593
|
-
*
|
|
594
|
-
* generateImageFilename({
|
|
595
|
-
* brand: 'Tesla',
|
|
596
|
-
* model: 'Model 3',
|
|
597
|
-
* year: 2024,
|
|
598
|
-
* trim: 'Highland'
|
|
599
|
-
* }, 'webp');
|
|
600
|
-
* // 'tesla__model-3__2024__highland.webp'
|
|
601
|
-
* ```
|
|
625
|
+
* 모델 매핑 정보
|
|
602
626
|
*/
|
|
603
|
-
|
|
627
|
+
interface ModelMapping {
|
|
628
|
+
firestoreId: string;
|
|
629
|
+
koreanName: string;
|
|
630
|
+
englishName: string;
|
|
631
|
+
storageName: string;
|
|
632
|
+
brandId: string;
|
|
633
|
+
}
|
|
604
634
|
/**
|
|
605
|
-
*
|
|
635
|
+
* Firestore에서 모델 정보를 조회하여 캐시 초기화
|
|
606
636
|
*
|
|
607
|
-
* @param
|
|
608
|
-
* @
|
|
637
|
+
* @param firestore - Firestore 인스턴스
|
|
638
|
+
* @param brandIds - 초기화할 브랜드 ID 목록 (생략 시 모든 브랜드)
|
|
609
639
|
*
|
|
610
640
|
* @example
|
|
611
641
|
* ```typescript
|
|
612
|
-
*
|
|
613
|
-
*
|
|
642
|
+
* // 모든 브랜드의 모델 초기화
|
|
643
|
+
* await initializeModelMappings(db);
|
|
614
644
|
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
645
|
+
* // 특정 브랜드만 초기화
|
|
646
|
+
* await initializeModelMappings(db, ['hyundai', 'kia']);
|
|
617
647
|
* ```
|
|
618
648
|
*/
|
|
619
|
-
declare function
|
|
649
|
+
declare function initializeModelMappings(firestore: Firestore, brandIds?: string[]): Promise<void>;
|
|
620
650
|
/**
|
|
621
|
-
*
|
|
651
|
+
* 모델 매핑 정보 조회
|
|
652
|
+
*
|
|
653
|
+
* @param brandId - 브랜드 ID
|
|
654
|
+
* @param modelInput - 모델명 (한글/영문/ID 모두 가능)
|
|
655
|
+
* @returns 모델 매핑 정보 또는 null
|
|
622
656
|
*
|
|
623
|
-
* @
|
|
624
|
-
* @returns 유효 여부
|
|
657
|
+
* @throws {Error} 초기화되지 않은 경우
|
|
625
658
|
*
|
|
626
659
|
* @example
|
|
627
660
|
* ```typescript
|
|
628
|
-
*
|
|
629
|
-
*
|
|
661
|
+
* getModelMapping('hyundai', '아이오닉 5'); // { firestoreId: 'ioniq-5', ... }
|
|
662
|
+
* getModelMapping('hyundai', 'IONIQ-5'); // { firestoreId: 'ioniq-5', ... }
|
|
663
|
+
* getModelMapping('hyundai', 'ioniq-5'); // { firestoreId: 'ioniq-5', ... }
|
|
630
664
|
* ```
|
|
631
665
|
*/
|
|
632
|
-
declare function
|
|
633
|
-
|
|
666
|
+
declare function getModelMapping(brandId: string, modelInput: string): ModelMapping | null;
|
|
634
667
|
/**
|
|
635
|
-
*
|
|
668
|
+
* 브랜드의 모든 모델 조회
|
|
636
669
|
*
|
|
637
|
-
*
|
|
670
|
+
* @param brandId - 브랜드 ID
|
|
671
|
+
* @returns 모델 매핑 배열
|
|
672
|
+
*/
|
|
673
|
+
declare function getBrandModels(brandId: string): ModelMapping[];
|
|
674
|
+
/**
|
|
675
|
+
* 초기화 상태 확인
|
|
676
|
+
*/
|
|
677
|
+
declare function isInitialized(): boolean;
|
|
678
|
+
/**
|
|
679
|
+
* 캐시 초기화 (테스트용)
|
|
680
|
+
*/
|
|
681
|
+
declare function resetCache(): void;
|
|
682
|
+
/**
|
|
683
|
+
* 캐시된 모델 수
|
|
638
684
|
*/
|
|
685
|
+
declare function getCachedModelCount(): number;
|
|
639
686
|
|
|
640
687
|
/**
|
|
641
|
-
* 차량 이미지 URL 생성
|
|
688
|
+
* Firebase Storage 차량 이미지 URL/경로 생성 유틸리티
|
|
642
689
|
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* @returns 이미지 다운로드 URL
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* ```typescript
|
|
649
|
-
* generateVehicleImageUrl({
|
|
650
|
-
* brand: 'hyundai',
|
|
651
|
-
* model: 'ioniq-5',
|
|
652
|
-
* year: 2024
|
|
653
|
-
* });
|
|
654
|
-
* // 'https://firebasestorage.googleapis.com/v0/b/charzing-d1600.firebasestorage.app/o/
|
|
655
|
-
* // vehicle-images%2FHYUNDAI%2FIONIQ-5%2F2024%2Fhyundai__ioniq-5__2024.png?alt=media'
|
|
656
|
-
*
|
|
657
|
-
* generateVehicleImageUrl({
|
|
658
|
-
* brand: 'mini',
|
|
659
|
-
* model: 'cooper',
|
|
660
|
-
* year: 2025,
|
|
661
|
-
* trim: 'jcw'
|
|
662
|
-
* });
|
|
663
|
-
* // 'https://firebasestorage.googleapis.com/v0/b/charzing-d1600.firebasestorage.app/o/
|
|
664
|
-
* // vehicle-images%2FMINI%2FCOOPER%2F2025%2Fmini__cooper__2025__jcw.png?alt=media'
|
|
665
|
-
* ```
|
|
690
|
+
* ⚠️ 주의: 이 파일은 순수 함수만 포함합니다.
|
|
691
|
+
* Firebase SDK나 업로드 로직은 포함하지 않습니다.
|
|
666
692
|
*/
|
|
667
|
-
|
|
693
|
+
interface ImagePathParams {
|
|
694
|
+
brandId: string;
|
|
695
|
+
modelId: string;
|
|
696
|
+
year: number;
|
|
697
|
+
trim?: string;
|
|
698
|
+
}
|
|
668
699
|
/**
|
|
669
|
-
* 차량 이미지
|
|
670
|
-
*
|
|
671
|
-
* @param params - 차량 이미지 파라미터
|
|
672
|
-
* @param options - URL 생성 옵션
|
|
673
|
-
* @returns 이미지 경로 정보
|
|
674
|
-
*
|
|
675
|
-
* @example
|
|
676
|
-
* ```typescript
|
|
677
|
-
* getVehicleImagePath({
|
|
678
|
-
* brand: 'hyundai',
|
|
679
|
-
* model: 'ioniq-5',
|
|
680
|
-
* year: 2024
|
|
681
|
-
* });
|
|
682
|
-
* // {
|
|
683
|
-
* // fullPath: 'vehicle-images/HYUNDAI/IONIQ-5/2024/hyundai__ioniq-5__2024.png',
|
|
684
|
-
* // directory: 'vehicle-images/HYUNDAI/IONIQ-5/2024',
|
|
685
|
-
* // filename: 'hyundai__ioniq-5__2024.png',
|
|
686
|
-
* // downloadUrl: 'https://...'
|
|
687
|
-
* // }
|
|
688
|
-
* ```
|
|
700
|
+
* 차량 이미지 파일명 생성
|
|
701
|
+
* 예: kia__niro-ev__2022__standard.png
|
|
689
702
|
*/
|
|
690
|
-
declare function
|
|
703
|
+
declare function generateImageFilename(params: ImagePathParams): string;
|
|
691
704
|
/**
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
*
|
|
698
|
-
* @example
|
|
699
|
-
* ```typescript
|
|
700
|
-
* generateFallbackUrls({
|
|
701
|
-
* brand: 'mini',
|
|
702
|
-
* model: 'cooper',
|
|
703
|
-
* year: 2025,
|
|
704
|
-
* trim: 'jcw'
|
|
705
|
-
* });
|
|
706
|
-
* // [
|
|
707
|
-
* // 'https://.../mini__cooper__2025__jcw.png', // 트림 이미지
|
|
708
|
-
* // 'https://.../mini__cooper__2025.png', // 기본 모델 이미지
|
|
709
|
-
* // ]
|
|
710
|
-
* ```
|
|
705
|
+
* Storage 경로 생성 (업로드용)
|
|
706
|
+
* 예: vehicle-images/KIA/NIRO-EV/2022/kia__niro-ev__2022__standard.png
|
|
707
|
+
*/
|
|
708
|
+
declare function generateStoragePath(params: ImagePathParams): string;
|
|
709
|
+
/**
|
|
710
|
+
* 완전한 Firebase Storage URL 생성 (읽기용)
|
|
711
711
|
*/
|
|
712
|
-
declare function
|
|
712
|
+
declare function generateVehicleImageUrl(params: ImagePathParams): string;
|
|
713
713
|
|
|
714
|
-
export { type BatteryInfo, type Brand, type BrandId, type BrandMapping, type CompletedVehicle, type DriveType, type FirebaseStorageConfig, type ImageFallbackOptions, type ImageFallbackStrategy, type ImageFilename, type ImagePath, type ImageUrlOptions, type Model, type ModelId, type ModelMapping, type ModelSlug, SUPPORTED_BRANDS, type StorageBrandName, type TrimId, type TrimMapping, type TrimSlug, type UserVehicle, type VehicleDetails, type VehicleImageParams, type VehicleModel, type VehicleTrim, type VehicleVariant, convertKoreanToEnglish, findBestModelMatch,
|
|
714
|
+
export { type BatteryInfo, type Brand, type BrandId, type BrandMapping, type CompletedVehicle, type DriveType, type FirebaseStorageConfig, type ImageFallbackOptions, type ImageFallbackStrategy, type ImageFilename, type ImagePath, type ImagePathParams, type ImageUrlOptions, type Model, type ModelId, type ModelMapping$1 as ModelMapping, type ModelSlug, SUPPORTED_BRANDS, type StorageBrandName, type TrimId, type TrimMapping, type TrimSlug, type UserVehicle, type VehicleDetails, type VehicleImageParams, type VehicleModel, type VehicleTrim, type VehicleVariant, convertKoreanToEnglish, findBestModelMatch, generateImageFilename, generateStoragePath, generateVehicleImageUrl, getBrandMapping$1 as getBrandMapping, getBrandModels, getBrandNameEnglish, getBrandNameKorean, getCachedBrandCount, getCachedModelCount, getBrandMapping as getDynamicBrandMapping, getModelMapping as getDynamicModelMapping, getModelMapping$1 as getModelMapping, getModelSlug, getStorageBrandName, initializeBrandMappings, initializeModelMappings, isInitialized$1 as isBrandMappingInitialized, isInitialized as isModelMappingInitialized, normalizeBrandId, normalizeModelId, resetCache$1 as resetBrandCache, resetCache as resetModelCache, toSlug };
|