@vulog/aima-vehicle 1.2.44 → 1.2.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +261 -255
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,246 +1,355 @@
1
1
  # @vulog/aima-vehicle
2
2
 
3
- Vehicle management module for AIMA platform.
3
+ Vehicle and model management CRUD operations, real-time data, services, and options.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```bash
8
- npm i @vulog/aima-client @vulog/aima-core @vulog/aima-vehicle
7
+ ```sh
8
+ npm install @vulog/aima-vehicle @vulog/aima-client @vulog/aima-core
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Initialize Client
14
-
15
- ```javascript
13
+ ```ts
14
+ import { getVehicles, getVehicleById, getVehiclesRealTime } from '@vulog/aima-vehicle';
16
15
  import { getClient } from '@vulog/aima-client';
17
- import { getVehicles, getModelById, getModels, getVehicleById, getVehiclesRealTime } from '@vulog/aima-vehicle';
18
-
19
- const client = getClient({
20
- apiKey: '...',
21
- baseUrl: '...',
22
- clientId: '...',
23
- clientSecret: '...',
24
- fleetId: '...',
25
- });
16
+
17
+ const client = getClient({ ... });
18
+
19
+ const vehicles = await getVehicles(client);
20
+ const vehicle = await getVehicleById(client, 'vehicle-uuid');
21
+ const realTime = await getVehiclesRealTime(client, 500, Date.now() - 3600_000);
26
22
  ```
27
23
 
28
- ### Get All Vehicles
24
+ ## API Reference
29
25
 
30
- Fetches all vehicles with pagination (default page size: 500). The implementation uses an internal `getVehiclesPage` function to fetch individual pages of vehicles.
26
+ ### getModelsById
31
27
 
32
- ```javascript
33
- // Get all vehicles
34
- const vehicles = await getVehicles(client);
28
+ ```ts
29
+ getModelsById(client: Client, id: number): Promise<Model>
30
+ ```
31
+
32
+ Fetches a single vehicle model by ID.
33
+
34
+ | Param | Type | Description |
35
+ | -------- | -------- | ------------------------- |
36
+ | `client` | `Client` | Authenticated AIMA client |
37
+ | `id` | `number` | Model identifier |
38
+
39
+ ---
40
+
41
+ ### getModelByIdAssets
42
+
43
+ ```ts
44
+ getModelByIdAssets(client: Client, id: number): Promise<Assets>
45
+ ```
46
+
47
+ Returns EDS assets for a model.
48
+
49
+ | Param | Type | Description |
50
+ | -------- | -------- | ------------------------- |
51
+ | `client` | `Client` | Authenticated AIMA client |
52
+ | `id` | `number` | Model identifier |
53
+
54
+ ---
55
+
56
+ ### getModels
57
+
58
+ ```ts
59
+ getModels(client: Client): Promise<Model[]>
60
+ ```
35
61
 
36
- // Get all vehicles with custom page size
37
- const vehicles = await getVehicles(client, 1000);
62
+ Returns all vehicle models for the fleet.
63
+
64
+ | Param | Type | Description |
65
+ | -------- | -------- | ------------------------- |
66
+ | `client` | `Client` | Authenticated AIMA client |
67
+
68
+ ---
69
+
70
+ ### getVehicleById
71
+
72
+ ```ts
73
+ getVehicleById(client: Client, id: string): Promise<Vehicle | null>
38
74
  ```
39
75
 
40
- The `getVehicles` function automatically handles pagination and will fetch all available vehicles up to a maximum of 50 pages. If you need to fetch a specific page of vehicles, you can use the internal `getVehiclesPage` function:
76
+ Fetches a vehicle by ID. Returns `null` on 404.
77
+
78
+ | Param | Type | Description |
79
+ | -------- | -------- | ------------------------- |
80
+ | `client` | `Client` | Authenticated AIMA client |
81
+ | `id` | `string` | Vehicle identifier |
41
82
 
42
- ```javascript
43
- // Get a specific page of vehicles
44
- const vehiclesPage = await getVehiclesPage(client, 0, 100); // First page, 100 vehicles per page
83
+ ---
84
+
85
+ ### getVehicleRealTimeById
86
+
87
+ ```ts
88
+ getVehicleRealTimeById(client: Client, id: string): Promise<VehicleRealTime | null>
45
89
  ```
46
90
 
47
- Note: `getVehiclesPage` is an internal function and is not exported from the package. It's used internally by `getVehicles` to handle the pagination logic.
91
+ Returns real-time telemetry for a vehicle. Returns `null` on 404.
48
92
 
49
- ### Get Vehicle by ID
93
+ | Param | Type | Description |
94
+ | -------- | -------- | ------------------------- |
95
+ | `client` | `Client` | Authenticated AIMA client |
96
+ | `id` | `string` | Vehicle identifier |
50
97
 
51
- Fetches a specific vehicle by its ID.
98
+ ---
52
99
 
53
- ```javascript
54
- const vehicle = await getVehicleById(client, 'dcb0c41e-4be3-11ea-83a5-024d0cba6da4');
100
+ ### getVehicleByIdAssets
101
+
102
+ ```ts
103
+ getVehicleByIdAssets(client: Client, id: string): Promise<Assets>
55
104
  ```
56
105
 
57
- ### Get All Models
106
+ Returns EDS assets for a vehicle.
107
+
108
+ | Param | Type | Description |
109
+ | -------- | -------- | ------------------------- |
110
+ | `client` | `Client` | Authenticated AIMA client |
111
+ | `id` | `string` | Vehicle identifier |
58
112
 
59
- Fetches all vehicle models.
113
+ ---
60
114
 
61
- ```javascript
62
- const models = await getModels(client);
115
+ ### getVehicles
116
+
117
+ ```ts
118
+ getVehicles(client: Client, pageSize?: number): Promise<Vehicle[]>
63
119
  ```
64
120
 
65
- ### Get Model by ID
121
+ Returns all vehicles in the fleet. Auto-paginates up to 50 pages using the given page size (default 500).
122
+
123
+ | Param | Type | Description |
124
+ | ---------- | -------- | ---------------------------------- |
125
+ | `client` | `Client` | Authenticated AIMA client |
126
+ | `pageSize` | `number` | Results per page (default 500) |
127
+
128
+ ---
66
129
 
67
- Fetches a specific model by its ID.
130
+ ### getVehiclesRealTime
68
131
 
69
- ```javascript
70
- const model = await getModelById(client, 372);
132
+ ```ts
133
+ getVehiclesRealTime(client: Client, pageSize?: number, lastUpdatedMillis?: number): Promise<VehicleRealTime[]>
71
134
  ```
72
135
 
73
- ### Get Real-Time Vehicle Data
136
+ Returns real-time data for all vehicles. Auto-paginates up to 50 pages. `lastUpdatedMillis` must be a past UTC timestamp in milliseconds.
74
137
 
75
- Fetches real-time data for all vehicles with pagination (default page size: 500). The implementation uses an internal `getVehiclesRealTimePage` function to fetch individual pages of real-time vehicle data.
138
+ | Param | Type | Description |
139
+ | ------------------- | -------- | --------------------------------------- |
140
+ | `client` | `Client` | Authenticated AIMA client |
141
+ | `pageSize` | `number` | Results per page (default 500) |
142
+ | `lastUpdatedMillis` | `number` | Only return vehicles updated after this |
76
143
 
77
- ```javascript
78
- // Get real-time data for all vehicles
79
- const realTimeVehicles = await getVehiclesRealTime(client);
144
+ ---
80
145
 
81
- // Get real-time data with custom page size
82
- const realTimeVehicles = await getVehiclesRealTime(client, 1000);
146
+ ### pingVehicleById
83
147
 
84
- // Get only vehicles updated after a specific timestamp (in UTC milliseconds)
85
- const lastSyncTime = Date.now() - 24 * 60 * 60 * 1000; // 24 hours ago
86
- const updatedVehicles = await getVehiclesRealTime(client, 500, lastSyncTime);
148
+ ```ts
149
+ pingVehicleById(client: Client, id: string): Promise<boolean>
87
150
  ```
88
151
 
89
- The `getVehiclesRealTime` function automatically handles pagination and will fetch all available vehicles up to a maximum of 50 pages. If you need to fetch a specific page of real-time vehicle data, you can use the internal `getVehiclesRealTimePage` function:
152
+ Checks whether a vehicle's box is connected. Returns `true` if connected.
153
+
154
+ | Param | Type | Description |
155
+ | -------- | -------- | ------------------------- |
156
+ | `client` | `Client` | Authenticated AIMA client |
157
+ | `id` | `string` | Vehicle identifier |
158
+
159
+ ---
90
160
 
91
- ```javascript
92
- // Get a specific page of real-time vehicle data
93
- const realTimeVehiclesPage = await getVehiclesRealTimePage(client, 0, 100); // First page, 100 vehicles per page
161
+ ### enableVehicle
94
162
 
95
- // Get a specific page with lastUpdatedMillis filter
96
- const updatedVehiclesPage = await getVehiclesRealTimePage(client, 0, 100, lastSyncTime);
163
+ ```ts
164
+ enableVehicle(client: Client, vehicleId: string, payload: EnableVehicleBody): Promise<void>
97
165
  ```
98
166
 
99
- Note: `getVehiclesRealTimePage` is an internal function and is not exported from the package. It's used internally by `getVehiclesRealTime` to handle the pagination logic.
167
+ Enables a vehicle.
100
168
 
101
- ### Create a Vehicle
169
+ | Param | Type | Description |
170
+ | ----------- | ------------------- | ------------------------- |
171
+ | `client` | `Client` | Authenticated AIMA client |
172
+ | `vehicleId` | `string` | Vehicle identifier |
173
+ | `payload` | `EnableVehicleBody` | Enable payload |
102
174
 
103
- Creates a new vehicle in the fleet.
175
+ ---
176
+
177
+ ### disableVehicle
178
+
179
+ ```ts
180
+ disableVehicle(client: Client, vehicleId: string, payload: DisableVehicleBody): Promise<void>
181
+ ```
104
182
 
105
- ```javascript
106
- import { createVehicle } from '@vulog/aima-vehicle';
107
-
108
- const vehicle = await createVehicle(client, {
109
- vin: '1HGBH41JXMN109186',
110
- plate: 'AB-123-CD',
111
- name: 'My Vehicle',
112
- model: { id: 372 },
113
- // optional fields
114
- vuboxId: 'vubox-123',
115
- externalId: 'ext-123',
116
- noBox: false,
117
- published: true,
118
- });
183
+ Disables a vehicle.
184
+
185
+ | Param | Type | Description |
186
+ | ----------- | -------------------- | ------------------------- |
187
+ | `client` | `Client` | Authenticated AIMA client |
188
+ | `vehicleId` | `string` | Vehicle identifier |
189
+ | `payload` | `DisableVehicleBody` | Disable payload |
190
+
191
+ ---
192
+
193
+ ### getModelVehicles
194
+
195
+ ```ts
196
+ getModelVehicles(client: Client, options?: PaginableOptions): Promise<PaginableResponse<ModelVehicle>>
119
197
  ```
120
198
 
121
- ### Get Options
199
+ Returns a paginated list of model-to-vehicle mappings.
200
+
201
+ | Param | Type | Description |
202
+ | --------- | ------------------ | ------------------------- |
203
+ | `client` | `Client` | Authenticated AIMA client |
204
+ | `options` | `PaginableOptions` | Pagination options |
122
205
 
123
- Fetches all vehicle options available in the fleet.
206
+ ---
124
207
 
125
- ```javascript
126
- import { getOptions } from '@vulog/aima-vehicle';
208
+ ### createVehicle
127
209
 
128
- const options = await getOptions(client);
210
+ ```ts
211
+ createVehicle(client: Client, body: CreateVehicleBody): Promise<Vehicle>
129
212
  ```
130
213
 
131
- ### Add / Remove Option for Vehicle
214
+ Creates a new vehicle in the fleet.
215
+
216
+ | Param | Type | Description |
217
+ | -------- | ------------------- | ------------------------- |
218
+ | `client` | `Client` | Authenticated AIMA client |
219
+ | `body` | `CreateVehicleBody` | Vehicle creation data |
132
220
 
133
- Add or remove an option to/from a vehicle.
221
+ ---
134
222
 
135
- ```javascript
136
- import { addOptionForVehicle, removeOptionForVehicle } from '@vulog/aima-vehicle';
223
+ ### addServiceForVehicle
137
224
 
138
- const vehicle = await addOptionForVehicle(client, 'vehicle-uuid', 25);
139
- const vehicle = await removeOptionForVehicle(client, 'vehicle-uuid', 25);
225
+ ```ts
226
+ addServiceForVehicle(client: Client, serviceId: string, vehicleId: string): Promise<void>
140
227
  ```
141
228
 
142
- ### Add / Remove Service for Vehicle
229
+ Assigns a service to a vehicle.
143
230
 
144
- Add or remove a service to/from a vehicle.
231
+ | Param | Type | Description |
232
+ | ----------- | -------- | ------------------------- |
233
+ | `client` | `Client` | Authenticated AIMA client |
234
+ | `serviceId` | `string` | Service identifier |
235
+ | `vehicleId` | `string` | Vehicle identifier |
145
236
 
146
- ```javascript
147
- import { addServiceForVehicle, removeServiceForVehicle } from '@vulog/aima-vehicle';
237
+ ---
148
238
 
149
- await addServiceForVehicle(client, 'service-uuid', 'vehicle-uuid');
150
- await removeServiceForVehicle(client, 'service-uuid', 'vehicle-uuid');
239
+ ### removeServiceForVehicle
240
+
241
+ ```ts
242
+ removeServiceForVehicle(client: Client, serviceId: string, vehicleId: string): Promise<void>
151
243
  ```
152
244
 
153
- ### Enable / Disable Vehicle
245
+ Removes a service from a vehicle.
246
+
247
+ | Param | Type | Description |
248
+ | ----------- | -------- | ------------------------- |
249
+ | `client` | `Client` | Authenticated AIMA client |
250
+ | `serviceId` | `string` | Service identifier |
251
+ | `vehicleId` | `string` | Vehicle identifier |
154
252
 
155
- Enable or disable a vehicle with a sub-status.
253
+ ---
156
254
 
157
- ```javascript
158
- import { enableVehicle, disableVehicle } from '@vulog/aima-vehicle';
255
+ ### getOptions
159
256
 
160
- await enableVehicle(client, 'vehicle-uuid', { subStatus: 'AVAILABLE' });
161
- await disableVehicle(client, 'vehicle-uuid', { subStatus: 'MAINTENANCE' });
257
+ ```ts
258
+ getOptions(client: Client): Promise<Options[]>
162
259
  ```
163
260
 
164
- ### Ping Vehicle
261
+ Returns all vehicle options available in the fleet.
165
262
 
166
- Check if a vehicle box is connected.
263
+ | Param | Type | Description |
264
+ | -------- | -------- | ------------------------- |
265
+ | `client` | `Client` | Authenticated AIMA client |
167
266
 
168
- ```javascript
169
- import { pingVehicleById } from '@vulog/aima-vehicle';
267
+ ---
170
268
 
171
- const isConnected = await pingVehicleById(client, 'vehicle-uuid');
172
- // true = connected, false = connection problem
269
+ ### addOptionForVehicle
270
+
271
+ ```ts
272
+ addOptionForVehicle(client: Client, vehicleId: string, optionId: number): Promise<Vehicle>
173
273
  ```
174
274
 
175
- ### Get Model Vehicles
275
+ Adds an option to a vehicle. Returns the updated vehicle.
276
+
277
+ | Param | Type | Description |
278
+ | ----------- | -------- | ------------------------- |
279
+ | `client` | `Client` | Authenticated AIMA client |
280
+ | `vehicleId` | `string` | Vehicle identifier |
281
+ | `optionId` | `number` | Option identifier |
176
282
 
177
- Fetches paginated model vehicle listings.
283
+ ---
178
284
 
179
- ```javascript
180
- import { getModelVehicles } from '@vulog/aima-vehicle';
285
+ ### removeOptionForVehicle
181
286
 
182
- const result = await getModelVehicles(client, {
183
- page: 0,
184
- pageSize: 50,
185
- sort: 'modelId',
186
- sortDirection: 'DESC',
187
- });
287
+ ```ts
288
+ removeOptionForVehicle(client: Client, vehicleId: string, optionId: number): Promise<Vehicle>
188
289
  ```
189
290
 
291
+ Removes an option from a vehicle. Returns the updated vehicle.
292
+
293
+ | Param | Type | Description |
294
+ | ----------- | -------- | ------------------------- |
295
+ | `client` | `Client` | Authenticated AIMA client |
296
+ | `vehicleId` | `string` | Vehicle identifier |
297
+ | `optionId` | `number` | Option identifier |
298
+
190
299
  ## Types
191
300
 
192
301
  ### Vehicle
193
302
 
194
- ```typescript
195
- interface Vehicle {
196
- id: string;
197
- name: string;
198
- plate: string;
199
- vin: string;
200
- model: Model;
201
- options: Options[];
202
- createDate: string;
203
- updateDate: string;
204
- fleetId: string;
205
- externalId: string;
206
- wakeupProvider?: string;
207
- msisdn: string;
208
- iccid: string;
209
- imsi?: string;
210
- published: boolean;
211
- noBox: boolean;
212
- archived: boolean;
303
+ Fleet vehicle data including `id`, `name`, `plate`, `vin`, `model`, `options`, `fleetId`, `published`, `archived`, `noBox`, `msisdn`, `iccid`, and optional `wakeupProvider`, `imsi`, `residualValue`.
304
+
305
+ ### VehicleRealTime
306
+
307
+ Real-time vehicle telemetry including location, battery, booking state, door/window status, zone membership, and box connectivity.
308
+
309
+ ### Model
310
+
311
+ Vehicle model definition including `id`, `name`, `energyType`, `vehicleType`, `transmission`, `nbOfSeats`, `autonomy`, `fleetId`.
312
+
313
+ ### Assets
314
+
315
+ ```ts
316
+ {
317
+ fleet_id: string;
318
+ model_id: number;
319
+ assets: {
320
+ aid: string;
321
+ type: string;
322
+ url: string;
323
+ value: string;
324
+ b_value: string;
325
+ text: string;
326
+ }[];
213
327
  }
214
328
  ```
215
329
 
216
- ### Model
330
+ ### ModelVehicle
217
331
 
218
- ```typescript
219
- interface Model {
220
- id: number;
221
- name: string;
222
- energyType: string;
223
- status: string;
224
- nbOfSeats: number;
225
- autonomy: number;
226
- creationDate: string;
227
- updateDate: string;
228
- description: string;
229
- fleetId: string;
230
- vehicleType: string;
231
- transmission: string;
232
- outOfServiceRange: string;
233
- recoveryRange: string;
234
- incentiveThresholds: any[];
235
- redistributeVehicleChargedEnoughRange: string;
236
- odometerReliable?: boolean;
332
+ ```ts
333
+ {
334
+ serviceId: string;
335
+ serviceVisibility: 'PUBLIC' | 'PRIVATE';
336
+ modelId: number;
337
+ vehicles: string[];
237
338
  }
238
339
  ```
239
340
 
341
+ ### CreateVehicleBody
342
+
343
+ Vehicle creation data. Optional fields include `wakeupProvider`, `archived`, `msisdn`, `iccid`, `imsi`, `residualValue`.
344
+
345
+ ### EnableVehicleBody / DisableVehicleBody
346
+
347
+ Payloads for enabling and disabling a vehicle.
348
+
240
349
  ### Options
241
350
 
242
- ```typescript
243
- interface Options {
351
+ ```ts
352
+ {
244
353
  id: number;
245
354
  fleetId: string;
246
355
  name: string;
@@ -248,106 +357,3 @@ interface Options {
248
357
  description: string;
249
358
  }
250
359
  ```
251
-
252
- ### VehicleRealTime
253
-
254
- ```typescript
255
- interface VehicleRealTime {
256
- id: string;
257
- name: string;
258
- plate: string;
259
- vin: string;
260
- fleetid: string;
261
- currentFleetId: string;
262
- ownerFleetId: string;
263
- boxid: string;
264
- vehicle_status: number;
265
- zones: Zone[];
266
- releasable: boolean;
267
- box_status: number;
268
- autonomy: number;
269
- autonomy2: number;
270
- isCharging: boolean;
271
- battery: number;
272
- km: number;
273
- speed: number;
274
- location: {
275
- geohash: string;
276
- cap: number;
277
- latitude: number;
278
- longitude: number;
279
- gpsDate: string;
280
- lastMovingDate: string;
281
- };
282
- endTripLocation: {
283
- latitude: number;
284
- longitude: number;
285
- };
286
- endZoneIds: [];
287
- productIds: [];
288
- isDoorClosed: boolean;
289
- isDoorLocked: boolean;
290
- engineOn: boolean;
291
- immobilizerOn: boolean;
292
- secureOn: boolean;
293
- spareLockOn: boolean | null;
294
- pileLockOn: boolean | null;
295
- helmetPresent: boolean | null;
296
- helmet2Present: boolean | null;
297
- helmetBoxLockOn: boolean | null;
298
- helmet2LockOn: boolean | null;
299
- userId: string | null;
300
- user_locale: string | null;
301
- rfid: string | null;
302
- orderId: string | null;
303
- gatewayUrl: string | null;
304
- booking_status: number;
305
- booking_date: string | null;
306
- expiresOn: boolean | null;
307
- last_active_date: string;
308
- last_wakeUp_date: string;
309
- version: string;
310
- pricingId: string | null;
311
- start_date: string | null;
312
- theorStartDate: string | null;
313
- theorEndDate: string | null;
314
- startZones: Zone[];
315
- endZones: Zone[];
316
- disabled: boolean;
317
- outOfServiceReason: string;
318
- ignitionOffGeohash: string | null;
319
- geohashNeighbours: string[];
320
- cleanlinessStatus: boolean;
321
- needsRedistribution: boolean;
322
- batteryUnderThreshold: boolean;
323
- isBeingTowed: boolean;
324
- automaticallyEnableVehicleAfterRangeRecovery: boolean;
325
- key: {
326
- deviceName: string;
327
- };
328
- doNotTrack: boolean;
329
- energyLevel: number;
330
- lastOosDate: string;
331
- hasAlerts: boolean;
332
- firmwareModel: string;
333
- comeFromApp: string;
334
- doors: {
335
- frontLeftClosed: boolean;
336
- frontRightClosed: boolean;
337
- rearLeftClosed: boolean;
338
- rearRightClosed: boolean;
339
- trunkClosed: boolean;
340
- hoodClosed: boolean;
341
- };
342
- windows: {
343
- frontLeftClosed: boolean;
344
- frontRightClosed: boolean;
345
- rearLeftClosed: boolean;
346
- rearRightClosed: boolean;
347
- trunkClosed: boolean;
348
- };
349
- doorsAndWindowsClosed: boolean;
350
- vpChecksum: string;
351
- firmwareBuildDate: string;
352
- }
353
- ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-vehicle",
3
3
  "type": "module",
4
- "version": "1.2.44",
4
+ "version": "1.2.46",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -32,8 +32,8 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.44",
36
- "@vulog/aima-core": "1.2.44"
35
+ "@vulog/aima-client": "1.2.46",
36
+ "@vulog/aima-core": "1.2.46"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^4.3.6"