@vulog/aima-search
v1.2.48
Published
Global search — search users and vehicles by query string.
Downloads
540
Readme
@vulog/aima-search
Global search — search users and vehicles by query string.
Installation
npm install @vulog/aima-search @vulog/aima-client @vulog/aima-coreUsage
import { getClient } from '@vulog/aima-client';
import { search } from '@vulog/aima-search';
const client = getClient({ ... });
const results = await search(client, 'john');
for (const result of results) {
if (result.type === 'user') {
console.log(result.email);
} else if (result.type === 'vehicules') {
console.log(result.plate);
}
}API Reference
search
search(client: Client, query: string): Promise<Search[]>Searches users and vehicles across the fleet. query must be a non-empty string (validated with Zod). The query is URL-encoded before being sent to the API.
| Param | Type | Description |
| -------- | -------- | ------------------------- |
| client | Client | Authenticated AIMA client |
| query | string | Non-empty search query |
Returns: Promise<Search[]>
Types
Search
Discriminated union on the type field:
type Search = SearchUser | SearchVehicle;SearchUser
{
id: string | null;
fleetid: string | null; // all-lowercase, as returned by the API
name: string | null;
type: 'user';
username: string | null;
firstname: string | null;
lastname: string | null;
email: string | null;
phone: string | null;
}SearchVehicle
{
id: string | null;
fleetid: string | null; // all-lowercase, as returned by the API
name: string | null;
type: 'vehicules'; // French plural, as returned by the API
plate: string | null;
vehiculename: string | null;
modelname: string | null;
vuboxid: string | null;
}Note:
fleetidis all-lowercase (not camelCase) andtypefor vehicles is'vehicules'(French plural) — both match the raw API response shape.
