forked from Yara724/api
fanavaran configs seeding
This commit is contained in:
@@ -42,7 +42,15 @@ export interface FanavaranPayloadDefaults {
|
||||
AccidentCityId: number;
|
||||
AccidentReportTypeId: number;
|
||||
AccidentVehicleUsedId: number;
|
||||
/**
|
||||
* GEN.03 base claim — کارشناس مسئول پرونده مالی
|
||||
* (must NOT be the assessor role used on GEN.08).
|
||||
*/
|
||||
ClaimExpertId: number;
|
||||
/**
|
||||
* GEN.08 expertise — کارشناس ارزیاب خسارت ثالث مالی / وکیل معتمد / کارشناس تحقیق
|
||||
* (Parsian: 29; Tejaratno proven: 2709).
|
||||
*/
|
||||
ExpertiseClaimExpertId: number;
|
||||
CompensationReferenceId: number;
|
||||
CulpritLicenceTypeId: number;
|
||||
@@ -63,15 +71,14 @@ export interface FanavaranClientProfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared codebook-ish defaults used when a tenant has not supplied its own
|
||||
* ClaimExpertId / plaque ids yet. Moallem auth is real; ClaimExpertId may need
|
||||
* a Moallem-specific value from Fanavaran lookups after first deploy.
|
||||
* Shared codebook-ish defaults. Each tenant must override ClaimExpertId /
|
||||
* ExpertiseClaimExpertId (they are different Fanavaran roles).
|
||||
*/
|
||||
const SHARED_FANAVARAN_DEFAULTS: FanavaranPayloadDefaults = {
|
||||
AccidentCityId: 701,
|
||||
AccidentReportTypeId: 155,
|
||||
AccidentVehicleUsedId: 1,
|
||||
ClaimExpertId: 2709,
|
||||
ClaimExpertId: 4543092,
|
||||
ExpertiseClaimExpertId: 2709,
|
||||
CompensationReferenceId: 167,
|
||||
CulpritLicenceTypeId: 2,
|
||||
@@ -85,7 +92,12 @@ const SHARED_FANAVARAN_DEFAULTS: FanavaranPayloadDefaults = {
|
||||
ClaimFileTypeId: 23,
|
||||
};
|
||||
|
||||
const FANAVARAN_CLIENT_PROFILES: Record<
|
||||
/**
|
||||
* Seed / code fallback profiles. On app boot these are inserted into
|
||||
* `fanavaranClientConfigs` only when a key is missing (never overwrite DB edits).
|
||||
* Runtime reads prefer the in-memory cache loaded from Mongo.
|
||||
*/
|
||||
export const SEED_FANAVARAN_CLIENT_PROFILES: Record<
|
||||
FanavaranClientKey,
|
||||
FanavaranClientProfile
|
||||
> = {
|
||||
@@ -102,7 +114,9 @@ const FANAVARAN_CLIENT_PROFILES: Record<
|
||||
},
|
||||
defaults: {
|
||||
...SHARED_FANAVARAN_DEFAULTS,
|
||||
ClaimExpertId: 2709,
|
||||
// GEN.03 — کارشناس مسئول پرونده مالی
|
||||
ClaimExpertId: 4543092,
|
||||
// GEN.08 — ارزیاب (proven successful submit 2026-07-18 ClaimExpertId: 2709)
|
||||
ExpertiseClaimExpertId: 2709,
|
||||
ClaimFileTypeId: 23,
|
||||
},
|
||||
@@ -120,7 +134,9 @@ const FANAVARAN_CLIENT_PROFILES: Record<
|
||||
},
|
||||
defaults: {
|
||||
...SHARED_FANAVARAN_DEFAULTS,
|
||||
// GEN.03 — مسئول پرونده مالی (Fanavaran example used 154; west branch 4662)
|
||||
ClaimExpertId: 154,
|
||||
// GEN.08 — ارزیاب خسارت ثالث مالی (رسول کرکی / شعبه غرب → 29)
|
||||
ExpertiseClaimExpertId: 29,
|
||||
ClaimFileTypeId: 70,
|
||||
},
|
||||
@@ -136,14 +152,34 @@ const FANAVARAN_CLIENT_PROFILES: Record<
|
||||
contractId: "304",
|
||||
location: "30900",
|
||||
},
|
||||
// ClaimExpertId / ClaimFileTypeId not yet confirmed for Moallem — start from
|
||||
// shared Fanavaran codebook defaults and override after lookup.
|
||||
// Expert role ids not confirmed for Moallem yet — start from shared shape.
|
||||
defaults: {
|
||||
...SHARED_FANAVARAN_DEFAULTS,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/** @deprecated Use SEED_FANAVARAN_CLIENT_PROFILES — kept alias for older imports. */
|
||||
export const FANAVARAN_CLIENT_PROFILES = SEED_FANAVARAN_CLIENT_PROFILES;
|
||||
|
||||
/**
|
||||
* Runtime cache filled by FanavaranClientConfigService on boot from Mongo.
|
||||
* Until then (and in unit tests), callers fall back to seed profiles.
|
||||
*/
|
||||
let runtimeProfiles: Partial<
|
||||
Record<FanavaranClientKey, FanavaranClientProfile>
|
||||
> | null = null;
|
||||
|
||||
export function setFanavaranClientProfilesCache(
|
||||
profiles: Partial<Record<FanavaranClientKey, FanavaranClientProfile>>,
|
||||
): void {
|
||||
runtimeProfiles = profiles;
|
||||
}
|
||||
|
||||
export function clearFanavaranClientProfilesCache(): void {
|
||||
runtimeProfiles = null;
|
||||
}
|
||||
|
||||
/** Resolve active Fanavaran tenant from env (`FANAVARAN_CLIENT`) with optional CLIENT_ID fallback. */
|
||||
export function resolveFanavaranClientKey(): FanavaranClientKey {
|
||||
const explicit = process.env.FANAVARAN_CLIENT?.trim().toLowerCase();
|
||||
@@ -160,17 +196,19 @@ export function resolveFanavaranClientKey(): FanavaranClientKey {
|
||||
}
|
||||
|
||||
export function resolveFanavaranClientProfile(): FanavaranClientProfile {
|
||||
return FANAVARAN_CLIENT_PROFILES[resolveFanavaranClientKey()];
|
||||
return getFanavaranClientProfile(resolveFanavaranClientKey());
|
||||
}
|
||||
|
||||
export function getFanavaranClientProfile(
|
||||
clientKey: FanavaranClientKey,
|
||||
): FanavaranClientProfile {
|
||||
return FANAVARAN_CLIENT_PROFILES[clientKey];
|
||||
return (
|
||||
runtimeProfiles?.[clientKey] ?? SEED_FANAVARAN_CLIENT_PROFILES[clientKey]
|
||||
);
|
||||
}
|
||||
|
||||
export function listFanavaranClientProfiles(): FanavaranClientProfile[] {
|
||||
return FANAVARAN_CLIENT_KEYS.map((key) => FANAVARAN_CLIENT_PROFILES[key]);
|
||||
return FANAVARAN_CLIENT_KEYS.map((key) => getFanavaranClientProfile(key));
|
||||
}
|
||||
|
||||
export function fanavaranPreviewPath(
|
||||
|
||||
Reference in New Issue
Block a user