All files / routes/admin taxonomy.config.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                        4x                                     4x                                 4x        
// Taxonomy Type Configuration
import * as schema from "../../db/schema";
 
export type TaxonomyType =
	| "businessTypes"
	| "timelineCategories"
	| "customerSegments"
	| "projectScales"
	| "serviceCategories"
	| "materialTags"
	| "brands"
	| "roomTypes"
	| "cities"
	| "zones"
	| "localities"
	| "cityServices"
	| "cityBhkTypes";
 
// Map taxonomy types to their corresponding schema tables
// Note: roomTypes is handled specially due to different primary key structure
export const TAXONOMY_TABLES = {
	businessTypes: schema.businessTypes,
	timelineCategories: schema.timelineCategories,
	customerSegments: schema.customerSegments,
	projectScales: schema.projectScales,
	serviceCategories: schema.serviceCategories,
	materialTags: schema.materialTags,
	brands: schema.brands,
	cities: schema.cities,
	zones: schema.zones,
	localities: schema.localities,
	cityServices: schema.cityServices,
	cityBhkTypes: schema.cityBhkTypes,
} as const;
 
// Tables with standard id/name fields (excludes roomTypes which uses code/displayName)
export type StandardTaxonomyType = Exclude<TaxonomyType, "roomTypes">;
 
// Define required fields for each taxonomy type
export const REQUIRED_FIELDS: Record<TaxonomyType, string[]> = {
	businessTypes: ["name"],
	timelineCategories: ["name"],
	customerSegments: ["name"],
	projectScales: ["name"],
	serviceCategories: ["name"],
	materialTags: ["name", "category"],
	brands: ["name", "category"],
	roomTypes: ["code", "displayName"],
	cities: ["name", "state"],
	zones: ["name", "cityId"],
	localities: ["name", "zoneId"],
	cityServices: ["cityId", "slug", "name"],
	cityBhkTypes: ["cityId", "slug", "label", "bhkCount"],
};
 
// List of all valid taxonomy types (includes both standard and special types)
export const ALL_TAXONOMY_TYPES = [
	...Object.keys(TAXONOMY_TABLES),
	"roomTypes",
];