Skip to main content

Device

type Device = {
  short_id: string;
  hardware_id: string;
  device_type: string;
  name?: string;
  attributes: Record<string, unknown>;
  is_online?: boolean;
  created_at: Date;
  updated_at: Date;
  last_responded_at?: Date;
};

GPS Telemetry

type GPSTelemetry = {
  hardware_id: string;
  timestamp: Date;
  lat: number;
  long: number;
  speed?: number;
};

Battery Telemetry

type BatteryTelemetry = {
  hardware_id: string;
  timestamp: Date;
  battery_voltage: number;
};

Trip

type Trip = {
  hardware_id: string;
  startTime: Date;
  endTime: Date;
  startLocation: { lat: number; long: number };
  endLocation: { lat: number; long: number };
  distance: number;   // meters
  duration: number;    // seconds
  maxSpeed: number;    // km/h
  avgSpeed: number;    // km/h
  pointCount: number;
};

Stop

type Stop = {
  startTime: Date;
  endTime: Date;
  location: { lat: number; long: number };
  duration: number;  // seconds
};

Lock Event

type UnlockSource = "rfid" | "keypad" | "key" | "remote";

type LockEvent = {
  event_id: string;
  hardware_id: string;
  event: "unlock" | "lock";
  timestamp: Date;
  source: UnlockSource;
  code?: string;
  metadata?: Record<string, unknown>;
};
SourcecodemetadataTriggered by
rfidRFID tag value-Device hardware
keypadCode entered-Device hardware
key--Physical key
remote-OptionalAPI call

Trip Configuration

type TripConfig = {
  speedThreshold: number;         // km/h — below this speed is stopped
  minimalTripDuration: number;    // seconds
  minimalTripDistance: number;     // meters
  minimalParkingDuration: number; // seconds
  minimalNoDataDuration: number;  // seconds
  minimalAvgSpeed: number;        // km/h — filters GPS drift
  maxAcceleration: number;        // m/s² — filters GPS spikes
};
A trip is only recorded if it meets all of these criteria:
  • Duration >= minimalTripDuration
  • Distance >= minimalTripDistance
  • Average speed >= minimalAvgSpeed

API User

type UserRole = "user" | "admin";

type ApiUserUsage = {
  total_requests: number;
  last_used_at?: Date;
  first_used_at?: Date;
  requests_today: number;
  last_reset: Date;
};

type ApiUser = {
  user_id: string;
  name: string;
  email?: string;
  role: UserRole;
  is_active: boolean;
  allowed_hardware_ids?: string[] | null;
  created_at: Date;
  updated_at: Date;
  usage: ApiUserUsage;
};
Usage tracking fields:
FieldDescription
total_requestsTotal number of API requests made with this key
last_used_atTimestamp of the most recent request
first_used_atTimestamp of the first request (set on first use)
requests_todayNumber of requests made today (resets at midnight)
last_resetTimestamp when the daily counter was last reset