@vulog/aima-vehicle 1.2.30 → 1.2.31
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.
- package/dist/index.cjs +252 -0
- package/dist/index.d.cts +273 -0
- package/dist/index.d.mts +211 -218
- package/dist/index.mjs +201 -261
- package/package.json +20 -7
- package/src/createVehicle.test.ts +88 -0
- package/src/createVehicle.ts +49 -0
- package/src/getModelVehicles.test.ts +4 -4
- package/src/index.ts +1 -0
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -280
- package/dist/index.js +0 -324
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let zod = require("zod");
|
|
25
|
+
zod = __toESM(zod);
|
|
26
|
+
let _vulog_aima_core = require("@vulog/aima-core");
|
|
27
|
+
//#region src/getModel.ts
|
|
28
|
+
const getModelsById = async (client, id) => {
|
|
29
|
+
return client.get(`boapi/proxy/user/vehicle/fleets/${client.clientOptions.fleetId}/vehicles/models/${id}`).then(({ data }) => data);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/getModelAssets.ts
|
|
33
|
+
const schema$5 = zod.z.object({ id: zod.z.number().int().positive() });
|
|
34
|
+
const getModelByIdAssets = async (client, id) => {
|
|
35
|
+
const result = schema$5.safeParse({ id });
|
|
36
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
37
|
+
return client.get(`boapi/proxy/eds/rest_pub/rest/fleets/${client.clientOptions.fleetId}/models/${id}/`).then(({ data }) => data);
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/getModels.ts
|
|
41
|
+
const getModels = async (client) => {
|
|
42
|
+
return client.get(`boapi/proxy/user/vehicle/fleets/${client.clientOptions.fleetId}/vehicles/models`).then(({ data }) => data);
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/getVehicle.ts
|
|
46
|
+
const schema$4 = zod.z.object({ id: zod.z.string().trim().min(1).uuid() });
|
|
47
|
+
const getVehicleById = async (client, id) => {
|
|
48
|
+
const result = schema$4.safeParse({ id });
|
|
49
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
50
|
+
return client.get(`boapi/proxy/user/vehicle/fleets/${client.clientOptions.fleetId}/vehicles/${result.data.id}`).then(({ data }) => data).catch((error) => {
|
|
51
|
+
if (error.formattedError?.status === 404) return null;
|
|
52
|
+
throw error;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const getVehicleRealTimeById = async (client, id) => {
|
|
56
|
+
const result = schema$4.safeParse({ id });
|
|
57
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
58
|
+
return client.get(`boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles/${result.data.id}`).then(({ data }) => data).catch((error) => {
|
|
59
|
+
if (error.formattedError?.status === 404) return null;
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/getVehicleAssets.ts
|
|
65
|
+
const schema$3 = zod.z.object({ id: zod.z.string().uuid() });
|
|
66
|
+
const getVehicleByIdAssets = async (client, id) => {
|
|
67
|
+
const result = schema$3.safeParse({ id });
|
|
68
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
69
|
+
return client.get(`boapi/proxy/eds/rest_pub/rest/fleets/${client.clientOptions.fleetId}/vehicles/${id}/`).then(({ data }) => data);
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/getVehicles.ts
|
|
73
|
+
/**
|
|
74
|
+
* Fetches a single page of vehicles from the API
|
|
75
|
+
* @param client - The AIMA client instance
|
|
76
|
+
* @param page - The page number to fetch
|
|
77
|
+
* @param pageSize - Number of vehicles per page
|
|
78
|
+
* @returns Promise that resolves to an array of vehicles for the requested page
|
|
79
|
+
*/
|
|
80
|
+
const getVehiclesPage = async (client, page, pageSize) => {
|
|
81
|
+
return (await client.get(`boapi/proxy/user/vehicle/fleets/${client.clientOptions.fleetId}/vehicles?page=${page}&size=${pageSize}`)).data;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Fetches all vehicles from the API using pagination
|
|
85
|
+
* @param client - The AIMA client instance
|
|
86
|
+
* @param pageSize - Number of vehicles per page (default: 500)
|
|
87
|
+
* @returns Promise that resolves to an array of all vehicles
|
|
88
|
+
* @throws Error if more than 50 pages are required to fetch all vehicles
|
|
89
|
+
*/
|
|
90
|
+
const getVehicles = async (client, pageSize = 500) => {
|
|
91
|
+
const result = zod.z.object({ pageSize: zod.z.number().min(1).default(500) }).safeParse({ pageSize });
|
|
92
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
93
|
+
const allVehicles = [];
|
|
94
|
+
let currentPage = 0;
|
|
95
|
+
let hasMorePages = true;
|
|
96
|
+
const MAX_PAGES = 50;
|
|
97
|
+
while (hasMorePages) {
|
|
98
|
+
if (currentPage >= MAX_PAGES) throw new Error(`Maximum page limit (${MAX_PAGES}) reached. This might indicate an issue with the pagination or a very large dataset.`);
|
|
99
|
+
const vehicles = await getVehiclesPage(client, currentPage, result.data.pageSize);
|
|
100
|
+
allVehicles.push(...vehicles);
|
|
101
|
+
hasMorePages = vehicles.length === result.data.pageSize;
|
|
102
|
+
currentPage += 1;
|
|
103
|
+
}
|
|
104
|
+
return allVehicles;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Fetches a single page of real-time vehicle data from the API
|
|
108
|
+
* @param client - The AIMA client instance
|
|
109
|
+
* @param page - The page number to fetch
|
|
110
|
+
* @param pageSize - Number of vehicles per page
|
|
111
|
+
* @param lastUpdatedMillis - Optional timestamp in UTC milliseconds
|
|
112
|
+
* @returns Promise that resolves to an array of real-time vehicle data for the requested page
|
|
113
|
+
*/
|
|
114
|
+
const getVehiclesRealTimePage = async (client, page, pageSize, lastUpdatedMillis) => {
|
|
115
|
+
const queryParams = new URLSearchParams({
|
|
116
|
+
page: page.toString(),
|
|
117
|
+
size: pageSize.toString()
|
|
118
|
+
});
|
|
119
|
+
if (lastUpdatedMillis !== void 0) queryParams.append("lastUpdatedMillis", lastUpdatedMillis.toString());
|
|
120
|
+
return (await client.get(`boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles?${queryParams.toString()}`)).data;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Fetches all real-time vehicle data from the API using pagination
|
|
124
|
+
* @param client - The AIMA client instance
|
|
125
|
+
* @param pageSize - Number of vehicles per page (default: 500)
|
|
126
|
+
* @param lastUpdatedMillis - Optional timestamp in UTC milliseconds. If provided, only vehicles updated after this timestamp will be returned.
|
|
127
|
+
* @returns Promise that resolves to an array of all real-time vehicle data
|
|
128
|
+
* @throws Error if more than 50 pages are required to fetch all vehicles
|
|
129
|
+
* @throws Error if lastUpdatedMillis is in the future
|
|
130
|
+
*/
|
|
131
|
+
const getVehiclesRealTime = async (client, pageSize = 500, lastUpdatedMillis) => {
|
|
132
|
+
const result = zod.z.object({
|
|
133
|
+
pageSize: zod.z.number().min(1).default(500),
|
|
134
|
+
lastUpdatedMillis: zod.z.number().positive().optional()
|
|
135
|
+
}).safeParse({
|
|
136
|
+
pageSize,
|
|
137
|
+
lastUpdatedMillis
|
|
138
|
+
});
|
|
139
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
140
|
+
const allVehicles = [];
|
|
141
|
+
let currentPage = 0;
|
|
142
|
+
let hasMorePages = true;
|
|
143
|
+
const MAX_PAGES = 50;
|
|
144
|
+
if (lastUpdatedMillis !== void 0) {
|
|
145
|
+
if (lastUpdatedMillis > Date.now()) throw new Error("lastUpdatedMillis must be in the past");
|
|
146
|
+
}
|
|
147
|
+
while (hasMorePages) {
|
|
148
|
+
if (currentPage >= MAX_PAGES) throw new Error(`Maximum page limit (${MAX_PAGES}) reached. This might indicate an issue with the pagination or a very large dataset.`);
|
|
149
|
+
const vehicles = await getVehiclesRealTimePage(client, currentPage, result.data.pageSize, result.data.lastUpdatedMillis);
|
|
150
|
+
allVehicles.push(...vehicles);
|
|
151
|
+
hasMorePages = vehicles.length === result.data.pageSize;
|
|
152
|
+
currentPage += 1;
|
|
153
|
+
}
|
|
154
|
+
return allVehicles;
|
|
155
|
+
};
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/pingVehicle.ts
|
|
158
|
+
const schema$2 = zod.z.object({ id: zod.z.string().trim().min(1).uuid() });
|
|
159
|
+
/**
|
|
160
|
+
* Pings a vehicle to check if it is alive (box connected).
|
|
161
|
+
* Returns true if alive (HTTP 200), false if box not connected (code 410, codeStr 'carConnectionProblem'),
|
|
162
|
+
* throws for other errors or invalid id.
|
|
163
|
+
*/
|
|
164
|
+
const pingVehicleById = async (client, id) => {
|
|
165
|
+
const result = schema$2.safeParse({ id });
|
|
166
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
167
|
+
try {
|
|
168
|
+
await client.get(`boapi/proxy/fleetmanager/public/v2/fleets/${client.clientOptions.fleetId}/vehicles/${result.data.id}/ping`);
|
|
169
|
+
return true;
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (error?.response?.data?.codeStr === "carConnectionProblem" && error?.response?.data?.code === 410) return false;
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/enableVehicle.ts
|
|
177
|
+
const schema$1 = zod.default.object({ subStatus: zod.default.string() });
|
|
178
|
+
const enableVehicle = async (client, vehicleId, payload) => {
|
|
179
|
+
const result = schema$1.safeParse(payload);
|
|
180
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
181
|
+
return client.post(`boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles/${vehicleId}/enable`, payload).then(({ data }) => data);
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/disableVehicle.ts
|
|
185
|
+
const schema = zod.default.object({ subStatus: zod.default.string() });
|
|
186
|
+
const disableVehicle = async (client, vehicleId, payload) => {
|
|
187
|
+
const result = schema.safeParse(payload);
|
|
188
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
189
|
+
return client.post(`boapi/proxy/fleetmanager/public/fleets/${client.clientOptions.fleetId}/vehicles/${vehicleId}/disable`, payload).then(({ data }) => data);
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/getModelVehicles.ts
|
|
193
|
+
const getModelVehicles = async (client, options) => {
|
|
194
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().default({}).safeParse(options);
|
|
195
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
196
|
+
const finalOptions = resultOptions.data;
|
|
197
|
+
const searchParams = new URLSearchParams();
|
|
198
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
199
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
200
|
+
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
201
|
+
if (finalOptions.filters) Object.entries(finalOptions.filters).forEach(([key, value]) => {
|
|
202
|
+
if (value === void 0) return;
|
|
203
|
+
searchParams.append(key, value);
|
|
204
|
+
});
|
|
205
|
+
const urlWithParams = `${`boapi/proxy/user/vehicle/fleets/${client.clientOptions.fleetId}/vehicles/models/modelvehicles`}?${searchParams.toString()}`;
|
|
206
|
+
return client.get(urlWithParams).then(({ data, headers }) => {
|
|
207
|
+
return {
|
|
208
|
+
data,
|
|
209
|
+
page: headers.number,
|
|
210
|
+
pageSize: headers.size,
|
|
211
|
+
total: headers.totalelements,
|
|
212
|
+
totalPages: headers.totalpages
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/createVehicle.ts
|
|
218
|
+
const createVehicleBodySchema = zod.z.object({
|
|
219
|
+
vin: zod.z.string().trim().min(1).max(20),
|
|
220
|
+
plate: zod.z.string().trim().min(1).max(16),
|
|
221
|
+
name: zod.z.string().trim().min(1).max(64),
|
|
222
|
+
model: zod.z.object({ id: zod.z.number().int().positive() }),
|
|
223
|
+
vuboxId: zod.z.string().optional(),
|
|
224
|
+
externalId: zod.z.string().max(32).optional(),
|
|
225
|
+
wakeupProvider: zod.z.string().max(16).optional(),
|
|
226
|
+
noBox: zod.z.boolean().optional(),
|
|
227
|
+
published: zod.z.boolean().optional(),
|
|
228
|
+
archived: zod.z.boolean().optional(),
|
|
229
|
+
msisdn: zod.z.string().max(32).optional(),
|
|
230
|
+
iccid: zod.z.string().max(32).optional(),
|
|
231
|
+
imsi: zod.z.string().max(32).optional(),
|
|
232
|
+
residualValue: zod.z.number().optional()
|
|
233
|
+
});
|
|
234
|
+
const createVehicle = async (client, body) => {
|
|
235
|
+
const result = createVehicleBodySchema.safeParse(body);
|
|
236
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
237
|
+
return client.post(`/boapi/proxy/vehicle/fleets/${client.clientOptions.fleetId}/vehicles`, result.data).then(({ data }) => data);
|
|
238
|
+
};
|
|
239
|
+
//#endregion
|
|
240
|
+
exports.createVehicle = createVehicle;
|
|
241
|
+
exports.disableVehicle = disableVehicle;
|
|
242
|
+
exports.enableVehicle = enableVehicle;
|
|
243
|
+
exports.getModelByIdAssets = getModelByIdAssets;
|
|
244
|
+
exports.getModelVehicles = getModelVehicles;
|
|
245
|
+
exports.getModels = getModels;
|
|
246
|
+
exports.getModelsById = getModelsById;
|
|
247
|
+
exports.getVehicleById = getVehicleById;
|
|
248
|
+
exports.getVehicleByIdAssets = getVehicleByIdAssets;
|
|
249
|
+
exports.getVehicleRealTimeById = getVehicleRealTimeById;
|
|
250
|
+
exports.getVehicles = getVehicles;
|
|
251
|
+
exports.getVehiclesRealTime = getVehiclesRealTime;
|
|
252
|
+
exports.pingVehicleById = pingVehicleById;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
|
+
import { PaginableOptions, PaginableResponse } from "@vulog/aima-core";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Represents a vehicle model with its specifications and characteristics
|
|
7
|
+
*/
|
|
8
|
+
type Model = {
|
|
9
|
+
/** Unique identifier of the model */id: number; /** Name of the model (e.g., "C-Zero") */
|
|
10
|
+
name: string; /** Type of energy used by the vehicle (e.g., "ELECTRIC") */
|
|
11
|
+
energyType: string; /** Current status of the model (e.g., "ACTIVE") */
|
|
12
|
+
status: string; /** Number of seats in the vehicle */
|
|
13
|
+
nbOfSeats: number; /** Maximum range/autonomy of the vehicle in kilometers */
|
|
14
|
+
autonomy: number; /** Date when the model was created */
|
|
15
|
+
creationDate: string; /** Date when the model was last updated */
|
|
16
|
+
updateDate: string; /** Description of the model (e.g., brand name) */
|
|
17
|
+
description: string; /** ID of the fleet this model belongs to */
|
|
18
|
+
fleetId: string; /** Type of vehicle (e.g., "CAR") */
|
|
19
|
+
vehicleType: string; /** Type of transmission (e.g., "UNDEFINED") */
|
|
20
|
+
transmission: string; /** Range threshold for out of service status */
|
|
21
|
+
outOfServiceRange: string; /** Range threshold for recovery */
|
|
22
|
+
recoveryRange: string; /** Array of incentive thresholds */
|
|
23
|
+
incentiveThresholds: any[]; /** Range threshold for vehicle redistribution */
|
|
24
|
+
redistributeVehicleChargedEnoughRange: string; /** Indicates if the odometer readings are reliable */
|
|
25
|
+
odometerReliable?: boolean;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Represents a vehicle in the system
|
|
30
|
+
*/
|
|
31
|
+
type Vehicle = {
|
|
32
|
+
/** Unique identifier of the vehicle */id: string; /** Name of the vehicle */
|
|
33
|
+
name: string; /** License plate number */
|
|
34
|
+
plate: string; /** Vehicle Identification Number */
|
|
35
|
+
vin: string; /** Model information of the vehicle */
|
|
36
|
+
model: Model; /** List of options/features installed on the vehicle */
|
|
37
|
+
options: Options[]; /** Date when the vehicle was created */
|
|
38
|
+
createDate: string; /** Date when the vehicle was last updated */
|
|
39
|
+
updateDate: string; /** ID of the fleet this vehicle belongs to */
|
|
40
|
+
fleetId: string; /** External system identifier */
|
|
41
|
+
externalId: string; /** Provider used for vehicle wakeup */
|
|
42
|
+
wakeupProvider?: string; /** Mobile Subscriber Integrated Services Digital Network Number */
|
|
43
|
+
msisdn: string; /** Integrated Circuit Card Identifier */
|
|
44
|
+
iccid: string; /** International Mobile Subscriber Identity */
|
|
45
|
+
imsi?: string; /** Whether the vehicle is published in the system */
|
|
46
|
+
published: boolean; /** Whether the vehicle has no box installed */
|
|
47
|
+
noBox: boolean; /** Whether the vehicle is archived */
|
|
48
|
+
archived: boolean;
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Represents a vehicle option or feature
|
|
53
|
+
*/
|
|
54
|
+
type Options = {
|
|
55
|
+
/** Unique identifier of the option */id: number; /** ID of the fleet this option belongs to */
|
|
56
|
+
fleetId: string; /** Name of the option */
|
|
57
|
+
name: string; /** Type of the option (e.g., "Color", "Gearbox") */
|
|
58
|
+
type: string; /** Description of the option */
|
|
59
|
+
description: string;
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
type Zone = {
|
|
63
|
+
type: string;
|
|
64
|
+
version: number;
|
|
65
|
+
zoneId: string;
|
|
66
|
+
sticky: boolean;
|
|
67
|
+
labels: {
|
|
68
|
+
labelId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
publicName: string;
|
|
71
|
+
}[];
|
|
72
|
+
};
|
|
73
|
+
type VehicleRealTime = {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
plate: string;
|
|
77
|
+
vin: string;
|
|
78
|
+
fleetid: string;
|
|
79
|
+
currentFleetId: string;
|
|
80
|
+
ownerFleetId: string;
|
|
81
|
+
boxid: string;
|
|
82
|
+
vehicle_status: number;
|
|
83
|
+
zones: Zone[];
|
|
84
|
+
releasable: boolean;
|
|
85
|
+
box_status: number;
|
|
86
|
+
autonomy: number;
|
|
87
|
+
autonomy2: number;
|
|
88
|
+
isCharging: boolean;
|
|
89
|
+
battery: number;
|
|
90
|
+
km: number;
|
|
91
|
+
speed: number;
|
|
92
|
+
location: {
|
|
93
|
+
geohash: string;
|
|
94
|
+
cap: number;
|
|
95
|
+
latitude: number;
|
|
96
|
+
longitude: number;
|
|
97
|
+
gpsDate: string;
|
|
98
|
+
lastMovingDate: string;
|
|
99
|
+
};
|
|
100
|
+
endTripLocation: {
|
|
101
|
+
latitude: number;
|
|
102
|
+
longitude: number;
|
|
103
|
+
};
|
|
104
|
+
endZoneIds: [];
|
|
105
|
+
productIds: [];
|
|
106
|
+
isDoorClosed: boolean;
|
|
107
|
+
isDoorLocked: boolean;
|
|
108
|
+
engineOn: boolean;
|
|
109
|
+
immobilizerOn: boolean;
|
|
110
|
+
secureOn: boolean;
|
|
111
|
+
spareLockOn: boolean | null;
|
|
112
|
+
pileLockOn: boolean | null;
|
|
113
|
+
helmetPresent: boolean | null;
|
|
114
|
+
helmet2Present: boolean | null;
|
|
115
|
+
helmetBoxLockOn: boolean | null;
|
|
116
|
+
helmet2LockOn: boolean | null;
|
|
117
|
+
userId: string | null;
|
|
118
|
+
user_locale: string | null;
|
|
119
|
+
rfid: string | null;
|
|
120
|
+
orderId: string | null;
|
|
121
|
+
gatewayUrl: string | null;
|
|
122
|
+
booking_status: number;
|
|
123
|
+
booking_date: string | null;
|
|
124
|
+
expiresOn: boolean | null;
|
|
125
|
+
last_active_date: string;
|
|
126
|
+
last_wakeUp_date: string;
|
|
127
|
+
version: string;
|
|
128
|
+
pricingId: string | null;
|
|
129
|
+
start_date: string | null;
|
|
130
|
+
theorStartDate: string | null;
|
|
131
|
+
theorEndDate: string | null;
|
|
132
|
+
startZones: Zone[];
|
|
133
|
+
endZones: Zone[];
|
|
134
|
+
disabled: boolean;
|
|
135
|
+
outOfServiceReason: string;
|
|
136
|
+
ignitionOffGeohash: string | null;
|
|
137
|
+
geohashNeighbours: string[];
|
|
138
|
+
cleanlinessStatus: boolean;
|
|
139
|
+
needsRedistribution: boolean;
|
|
140
|
+
batteryUnderThreshold: boolean;
|
|
141
|
+
isBeingTowed: boolean;
|
|
142
|
+
automaticallyEnableVehicleAfterRangeRecovery: boolean;
|
|
143
|
+
key: {
|
|
144
|
+
deviceName: string;
|
|
145
|
+
};
|
|
146
|
+
doNotTrack: boolean;
|
|
147
|
+
energyLevel: number;
|
|
148
|
+
lastOosDate: string;
|
|
149
|
+
hasAlerts: boolean;
|
|
150
|
+
firmwareModel: string;
|
|
151
|
+
comeFromApp: string;
|
|
152
|
+
doors: {
|
|
153
|
+
frontLeftClosed: boolean;
|
|
154
|
+
frontRightClosed: boolean;
|
|
155
|
+
rearLeftClosed: boolean;
|
|
156
|
+
rearRightClosed: boolean;
|
|
157
|
+
trunkClosed: boolean;
|
|
158
|
+
hoodClosed: boolean;
|
|
159
|
+
};
|
|
160
|
+
windows: {
|
|
161
|
+
frontLeftClosed: boolean;
|
|
162
|
+
frontRightClosed: boolean;
|
|
163
|
+
rearLeftClosed: boolean;
|
|
164
|
+
rearRightClosed: boolean;
|
|
165
|
+
trunkClosed: boolean;
|
|
166
|
+
};
|
|
167
|
+
doorsAndWindowsClosed: boolean;
|
|
168
|
+
vpChecksum: string;
|
|
169
|
+
firmwareBuildDate: string;
|
|
170
|
+
[key: string]: any;
|
|
171
|
+
};
|
|
172
|
+
type Assets = {
|
|
173
|
+
fleet_id: string;
|
|
174
|
+
model_id: number;
|
|
175
|
+
assets: {
|
|
176
|
+
aid: string;
|
|
177
|
+
type: string;
|
|
178
|
+
url: string | null;
|
|
179
|
+
value: number | null;
|
|
180
|
+
b_value: boolean | null;
|
|
181
|
+
text: string | null;
|
|
182
|
+
[key: string]: any;
|
|
183
|
+
}[];
|
|
184
|
+
[key: string]: any;
|
|
185
|
+
};
|
|
186
|
+
type ModelVehicle = {
|
|
187
|
+
serviceId: string;
|
|
188
|
+
serviceVisibility: 'PUBLIC' | 'PRIVATE';
|
|
189
|
+
modelId: number;
|
|
190
|
+
vehicles: string[];
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/getModel.d.ts
|
|
194
|
+
declare const getModelsById: (client: Client, id: number) => Promise<Model>;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/getModelAssets.d.ts
|
|
197
|
+
declare const getModelByIdAssets: (client: Client, id: number) => Promise<Assets>;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/getModels.d.ts
|
|
200
|
+
declare const getModels: (client: Client) => Promise<Model[]>;
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/getVehicle.d.ts
|
|
203
|
+
declare const getVehicleById: (client: Client, id: string) => Promise<Vehicle | null>;
|
|
204
|
+
declare const getVehicleRealTimeById: (client: Client, id: string) => Promise<VehicleRealTime | null>;
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/getVehicleAssets.d.ts
|
|
207
|
+
declare const getVehicleByIdAssets: (client: Client, id: string) => Promise<Assets>;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/getVehicles.d.ts
|
|
210
|
+
/**
|
|
211
|
+
* Fetches all vehicles from the API using pagination
|
|
212
|
+
* @param client - The AIMA client instance
|
|
213
|
+
* @param pageSize - Number of vehicles per page (default: 500)
|
|
214
|
+
* @returns Promise that resolves to an array of all vehicles
|
|
215
|
+
* @throws Error if more than 50 pages are required to fetch all vehicles
|
|
216
|
+
*/
|
|
217
|
+
declare const getVehicles: (client: Client, pageSize?: number) => Promise<Vehicle[]>;
|
|
218
|
+
/**
|
|
219
|
+
* Fetches all real-time vehicle data from the API using pagination
|
|
220
|
+
* @param client - The AIMA client instance
|
|
221
|
+
* @param pageSize - Number of vehicles per page (default: 500)
|
|
222
|
+
* @param lastUpdatedMillis - Optional timestamp in UTC milliseconds. If provided, only vehicles updated after this timestamp will be returned.
|
|
223
|
+
* @returns Promise that resolves to an array of all real-time vehicle data
|
|
224
|
+
* @throws Error if more than 50 pages are required to fetch all vehicles
|
|
225
|
+
* @throws Error if lastUpdatedMillis is in the future
|
|
226
|
+
*/
|
|
227
|
+
declare const getVehiclesRealTime: (client: Client, pageSize?: number, lastUpdatedMillis?: number) => Promise<VehicleRealTime[]>;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/pingVehicle.d.ts
|
|
230
|
+
/**
|
|
231
|
+
* Pings a vehicle to check if it is alive (box connected).
|
|
232
|
+
* Returns true if alive (HTTP 200), false if box not connected (code 410, codeStr 'carConnectionProblem'),
|
|
233
|
+
* throws for other errors or invalid id.
|
|
234
|
+
*/
|
|
235
|
+
declare const pingVehicleById: (client: Client, id: string) => Promise<boolean>;
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/enableVehicle.d.ts
|
|
238
|
+
type EnableVehicleBody = {
|
|
239
|
+
subStatus: string;
|
|
240
|
+
};
|
|
241
|
+
declare const enableVehicle: (client: Client, vehicleId: string, payload: EnableVehicleBody) => Promise<void>;
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/disableVehicle.d.ts
|
|
244
|
+
type DisableVehicleBody = {
|
|
245
|
+
subStatus: string;
|
|
246
|
+
};
|
|
247
|
+
declare const disableVehicle: (client: Client, vehicleId: string, payload: DisableVehicleBody) => Promise<void>;
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/getModelVehicles.d.ts
|
|
250
|
+
declare const getModelVehicles: (client: Client, options?: PaginableOptions) => Promise<PaginableResponse<ModelVehicle>>;
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/createVehicle.d.ts
|
|
253
|
+
type CreateVehicleBody = {
|
|
254
|
+
vin: string;
|
|
255
|
+
plate: string;
|
|
256
|
+
name: string;
|
|
257
|
+
model: {
|
|
258
|
+
id: number;
|
|
259
|
+
};
|
|
260
|
+
vuboxId?: string;
|
|
261
|
+
externalId?: string;
|
|
262
|
+
wakeupProvider?: string;
|
|
263
|
+
noBox?: boolean;
|
|
264
|
+
published?: boolean;
|
|
265
|
+
archived?: boolean;
|
|
266
|
+
msisdn?: string;
|
|
267
|
+
iccid?: string;
|
|
268
|
+
imsi?: string;
|
|
269
|
+
residualValue?: number;
|
|
270
|
+
};
|
|
271
|
+
declare const createVehicle: (client: Client, body: CreateVehicleBody) => Promise<Vehicle>;
|
|
272
|
+
//#endregion
|
|
273
|
+
export { Assets, CreateVehicleBody, DisableVehicleBody, EnableVehicleBody, Model, ModelVehicle, Options, Vehicle, VehicleRealTime, Zone, createVehicle, disableVehicle, enableVehicle, getModelByIdAssets, getModelVehicles, getModels, getModelsById, getVehicleById, getVehicleByIdAssets, getVehicleRealTimeById, getVehicles, getVehiclesRealTime, pingVehicleById };
|