Files
yara724-api/docs/inquiry-provider-routing.md
T

4.3 KiB

Inquiry provider routing

The running NestJS API routes inquiries through src/sand-hub/sand-hub.service.ts. The class name remains for existing dependency injection; it does not select the provider by tenant anymore.

Inquiry Provider Entry point
Third-party policy by plate ESG /inquiry/carByPlate getCarByPlateInquiry
Third-party policy by national code + VIN ESG /inquiry/carByChassis getCarByChassisInquiry
Person identity ESG /inquiry/person getPersonalInquiry
Sheba ownership ESG /inquiry/sheba getShebaValidation
Car-body policy by plate or VIN Tenant-specific Fanavaran processed policy lookup getCarBodyInquiry
Optional driving-licence / legal vehicle ownership Existing configured SANHUB_* adapter getDrivingLicenseInfo / getCarOwnershipInfo

The ESG endpoints above apply to every tenant. Existing per-client live/mock settings still apply. Disabled inquiries retain their mock behavior; offline third-party plate records are consulted only in disabled mode. No mock or deprecated provider is used as a fallback when a live ESG inquiry fails.

Why Moalem reached the retired login

Previously only CLIENT_ID=8 selected ESG. CLIENT_ID=7 therefore selected the old Tejarat transport for third-party plate inquiries, and the old configurable hub for identity and Sheba. Car-body plate inquiries also used the Tejarat transport unless the Fanavaran profile was Parsian. Car-body VIN inquiries already used Fanavaran.

The retired getTejaratAccessToken, /user/login transport and TEJARAT_INQUIRY_* configuration have been removed from the running API. Both car-body input formats now use the existing Fanavaran lookup. The mapper uses the selected source insurer rather than assuming every car-body result belongs to Parsian. Explicit conflicting insurer codes are rejected.

Deployment settings

Supply these through the API environment, then restart the API:

CLIENT_ID=7
FANAVARAN_CLIENT=moallem
ESG_URL=https://<gateway-host>/<optional-prefix>
ESG_USERNAME=<gateway-username>
ESG_PASSWORD=<gateway-password>

moallem is the existing Fanavaran profile spelling. The explicit FANAVARAN_CLIENT setting takes precedence; when absent, CLIENT_ID=7 now resolves to moallem, and CLIENT_ID=8 still resolves to parsian. Other deployments must select their own Fanavaran profile as before. The selected profile must have its existing Fanavaran credentials/contracts configured.

ESG_URL is the base before /auth/login and /inquiry/...; include any gateway prefix in that value. Trailing slashes are normalized. No internal-IP default is used. The ESG user needs access to all four inquiry types. Birth dates are sent in Jalali YYYY-MM-DD, with dateHasPostfix: 0. The cached ESG token is reused, and an inquiry HTTP 401 clears it before the existing retry.

TEJARAT_INQUIRY_BASE_URL, TEJARAT_INQUIRY_EMAIL and TEJARAT_INQUIRY_PASSWORD are no longer read by the running API and can be removed from deployment configuration. Do not repoint SANHUB_* to ESG: their optional licence/ownership payloads differ, and the ESG repository currently has no matching endpoints. Those two checks keep their existing settings until an explicit replacement contract is provided.

Compatibility and verification

The mapped inquiry fields consumed by the UI remain unchanged. The old getSandHubResponse entry point delegates to ESG and returns the mapped result. New car-body audit records identify their source as FANAVARAN_CAR_BODY_INQUIRY or FANAVARAN_CAR_BODY_VIN_INQUIRY. Historical raw inquiries, audit records and database documents are not rewritten.

scripts/refresh-blame-inquiries.js and scripts/fanavaran-flow-ui-server.js are separate manually run diagnostic tools with their own legacy provider settings. They are not invoked by the running application and have not been migrated by this change; do not use their inquiry shortcuts as evidence of the application's current routing.

Regression tests in sand-hub.esg-routing.spec.ts cover tenant IDs 7, 8 and 15, ESG token reuse/401 refresh, missing configuration, disabled inquiries, Fanavaran plate/VIN routing, source-company checks and optional-check compatibility. Provider HTTP calls in these tests are mocked; deployment still requires valid gateway credentials and connectivity.