forked from Yara724/api
Map Fanavaran people and licences by party role; allow unlisted base-info lookups.
Resolve driver, owner, and policyholder from participants when they differ, prefer real licence / driverLicenseDate over dummies, and fall back unknown /lookups/fanavaran/{name} to car/base-info/{name} (including vehicle-groups).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -172,8 +172,41 @@ export const FANAVARAN_REMOTE_LOOKUPS: FanavaranRemoteLookupDefinition[] = [
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/cii-validation-status`,
|
||||
cacheFile: "cii-validation-status.json",
|
||||
},
|
||||
{
|
||||
name: "vehicle-groups",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/car/base-info/vehicle-groups`,
|
||||
cacheFile: "vehicle-groups.json",
|
||||
},
|
||||
];
|
||||
|
||||
/** Safe Fanavaran lookup slug: lowercase segments separated by hyphens. */
|
||||
const FANAVARAN_LOOKUP_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
||||
|
||||
/**
|
||||
* Resolve a remote lookup definition.
|
||||
* Known names use the catalogue; unknown slugs fall back to
|
||||
* `car/base-info/{lookupName}` so `/lookups/fanavaran/{name}` works without
|
||||
* a dedicated route or config entry (e.g. vehicle-groups).
|
||||
*/
|
||||
export function resolveFanavaranRemoteLookup(
|
||||
name: string,
|
||||
): FanavaranRemoteLookupDefinition | null {
|
||||
const configured = FANAVARAN_REMOTE_LOOKUPS.find((item) => item.name === name);
|
||||
if (configured) {
|
||||
return configured;
|
||||
}
|
||||
|
||||
if (!FANAVARAN_LOOKUP_NAME_PATTERN.test(name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/car/base-info/${name}`,
|
||||
cacheFile: `${name}.json`,
|
||||
};
|
||||
}
|
||||
|
||||
export const TEJARAT_STATIC_ACCIDENT_FILES = {
|
||||
accidentReason: "ACCIDENT_REASON.json",
|
||||
accidentWay: "ACCIDENT_WAY.json",
|
||||
|
||||
Reference in New Issue
Block a user