@findatruck/aggregator-client 1.2.0 → 1.3.0
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 +39 -0
- package/dist/index.d.cts +45 -2
- package/dist/index.d.ts +45 -2
- package/dist/index.js +43 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,10 @@ __export(index_exports, {
|
|
|
27
27
|
DriverRankingSchema: () => import_shared_schemas2.DriverRankingSchema,
|
|
28
28
|
DriverRankingsRequestSchema: () => import_shared_schemas2.DriverRankingsRequestSchema,
|
|
29
29
|
DriverRankingsResponseSchema: () => import_shared_schemas2.DriverRankingsResponseSchema,
|
|
30
|
+
ManualBatchEntrySchema: () => import_shared_schemas2.ManualBatchEntrySchema,
|
|
31
|
+
ManualBatchRequestSchema: () => import_shared_schemas2.ManualBatchRequestSchema,
|
|
32
|
+
ManualBatchResponseSchema: () => import_shared_schemas2.ManualBatchResponseSchema,
|
|
33
|
+
ManualBatchTelemetrySchema: () => import_shared_schemas2.ManualBatchTelemetrySchema,
|
|
30
34
|
NewLoginRequestSchema: () => import_shared_schemas2.NewLoginRequestSchema,
|
|
31
35
|
NewLoginResponseFailureSchema: () => import_shared_schemas2.NewLoginResponseFailureSchema,
|
|
32
36
|
NewLoginResponseSchema: () => import_shared_schemas2.NewLoginResponseSchema,
|
|
@@ -72,6 +76,12 @@ var endpoints = {
|
|
|
72
76
|
method: "GET",
|
|
73
77
|
requestSchema: import_shared_schemas.StateHeatmapRequestSchema,
|
|
74
78
|
responseSchema: import_shared_schemas.StateHeatmapResponseSchema
|
|
79
|
+
},
|
|
80
|
+
manualBatch: {
|
|
81
|
+
path: "/telemetry/manual/batch",
|
|
82
|
+
method: "POST",
|
|
83
|
+
requestSchema: import_shared_schemas.ManualBatchRequestSchema,
|
|
84
|
+
responseSchema: import_shared_schemas.ManualBatchResponseSchema
|
|
75
85
|
}
|
|
76
86
|
};
|
|
77
87
|
|
|
@@ -222,6 +232,31 @@ var AggregatorClient = class {
|
|
|
222
232
|
}
|
|
223
233
|
return responseParseResult.data;
|
|
224
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
237
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
238
|
+
*/
|
|
239
|
+
async manualBatch(request) {
|
|
240
|
+
const endpoint = endpoints.manualBatch;
|
|
241
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
242
|
+
if (!parseResult.success) {
|
|
243
|
+
throw new AggregatorClientError(
|
|
244
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
245
|
+
endpoint.path
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
249
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
250
|
+
if (!responseParseResult.success) {
|
|
251
|
+
throw new AggregatorClientError(
|
|
252
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
253
|
+
endpoint.path,
|
|
254
|
+
void 0,
|
|
255
|
+
response
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
return responseParseResult.data;
|
|
259
|
+
}
|
|
225
260
|
async makeRequest(path, method, body) {
|
|
226
261
|
const url = `${this.baseUrl}${path}`;
|
|
227
262
|
const response = await fetch(url, {
|
|
@@ -291,6 +326,10 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
|
|
|
291
326
|
DriverRankingSchema,
|
|
292
327
|
DriverRankingsRequestSchema,
|
|
293
328
|
DriverRankingsResponseSchema,
|
|
329
|
+
ManualBatchEntrySchema,
|
|
330
|
+
ManualBatchRequestSchema,
|
|
331
|
+
ManualBatchResponseSchema,
|
|
332
|
+
ManualBatchTelemetrySchema,
|
|
294
333
|
NewLoginRequestSchema,
|
|
295
334
|
NewLoginResponseFailureSchema,
|
|
296
335
|
NewLoginResponseSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, ManualBatchEntry, ManualBatchEntrySchema, ManualBatchRequest, ManualBatchRequestSchema, ManualBatchResponse, ManualBatchResponseSchema, ManualBatchTelemetry, ManualBatchTelemetrySchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -70,6 +70,11 @@ declare class AggregatorClient {
|
|
|
70
70
|
* Returns the count and percentage of telemetry points in each state.
|
|
71
71
|
*/
|
|
72
72
|
stateHeatmap(request: StateHeatmapRequest): Promise<StateHeatmapResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
75
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
76
|
+
*/
|
|
77
|
+
manualBatch(request: ManualBatchRequest): Promise<ManualBatchResponse>;
|
|
73
78
|
private makeRequest;
|
|
74
79
|
private makeGetRequest;
|
|
75
80
|
}
|
|
@@ -170,6 +175,44 @@ declare const endpoints: {
|
|
|
170
175
|
percentage: z.ZodNumber;
|
|
171
176
|
}, z.core.$strip>>;
|
|
172
177
|
};
|
|
178
|
+
readonly manualBatch: {
|
|
179
|
+
readonly path: "/telemetry/manual/batch";
|
|
180
|
+
readonly method: "POST";
|
|
181
|
+
readonly requestSchema: z.ZodObject<{
|
|
182
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
183
|
+
driver_id: z.ZodString;
|
|
184
|
+
timestamp: z.ZodString;
|
|
185
|
+
location_latitude: z.ZodNumber;
|
|
186
|
+
location_longitude: z.ZodNumber;
|
|
187
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
188
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
readonly responseSchema: z.ZodObject<{
|
|
192
|
+
message: z.ZodString;
|
|
193
|
+
inserted_count: z.ZodNumber;
|
|
194
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
195
|
+
id: z.ZodNumber;
|
|
196
|
+
driver_id: z.ZodString;
|
|
197
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
198
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
199
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
200
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
201
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
202
|
+
location_latitude: z.ZodNumber;
|
|
203
|
+
location_longitude: z.ZodNumber;
|
|
204
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
205
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
206
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
207
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
208
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
source: z.ZodEnum<{
|
|
210
|
+
eld: "eld";
|
|
211
|
+
manual: "manual";
|
|
212
|
+
}>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
};
|
|
173
216
|
};
|
|
174
217
|
type EndpointName = keyof typeof endpoints;
|
|
175
218
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, ManualBatchEntry, ManualBatchEntrySchema, ManualBatchRequest, ManualBatchRequestSchema, ManualBatchResponse, ManualBatchResponseSchema, ManualBatchTelemetry, ManualBatchTelemetrySchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -70,6 +70,11 @@ declare class AggregatorClient {
|
|
|
70
70
|
* Returns the count and percentage of telemetry points in each state.
|
|
71
71
|
*/
|
|
72
72
|
stateHeatmap(request: StateHeatmapRequest): Promise<StateHeatmapResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
75
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
76
|
+
*/
|
|
77
|
+
manualBatch(request: ManualBatchRequest): Promise<ManualBatchResponse>;
|
|
73
78
|
private makeRequest;
|
|
74
79
|
private makeGetRequest;
|
|
75
80
|
}
|
|
@@ -170,6 +175,44 @@ declare const endpoints: {
|
|
|
170
175
|
percentage: z.ZodNumber;
|
|
171
176
|
}, z.core.$strip>>;
|
|
172
177
|
};
|
|
178
|
+
readonly manualBatch: {
|
|
179
|
+
readonly path: "/telemetry/manual/batch";
|
|
180
|
+
readonly method: "POST";
|
|
181
|
+
readonly requestSchema: z.ZodObject<{
|
|
182
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
183
|
+
driver_id: z.ZodString;
|
|
184
|
+
timestamp: z.ZodString;
|
|
185
|
+
location_latitude: z.ZodNumber;
|
|
186
|
+
location_longitude: z.ZodNumber;
|
|
187
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
188
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
readonly responseSchema: z.ZodObject<{
|
|
192
|
+
message: z.ZodString;
|
|
193
|
+
inserted_count: z.ZodNumber;
|
|
194
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
195
|
+
id: z.ZodNumber;
|
|
196
|
+
driver_id: z.ZodString;
|
|
197
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
198
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
199
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
200
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
201
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
202
|
+
location_latitude: z.ZodNumber;
|
|
203
|
+
location_longitude: z.ZodNumber;
|
|
204
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
205
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
206
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
207
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
208
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
source: z.ZodEnum<{
|
|
210
|
+
eld: "eld";
|
|
211
|
+
manual: "manual";
|
|
212
|
+
}>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
};
|
|
173
216
|
};
|
|
174
217
|
type EndpointName = keyof typeof endpoints;
|
|
175
218
|
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
DriverRankingsRequestSchema,
|
|
10
10
|
DriverRankingsResponseSchema,
|
|
11
11
|
StateHeatmapRequestSchema,
|
|
12
|
-
StateHeatmapResponseSchema
|
|
12
|
+
StateHeatmapResponseSchema,
|
|
13
|
+
ManualBatchRequestSchema,
|
|
14
|
+
ManualBatchResponseSchema
|
|
13
15
|
} from "@findatruck/shared-schemas";
|
|
14
16
|
var endpoints = {
|
|
15
17
|
newLogin: {
|
|
@@ -41,6 +43,12 @@ var endpoints = {
|
|
|
41
43
|
method: "GET",
|
|
42
44
|
requestSchema: StateHeatmapRequestSchema,
|
|
43
45
|
responseSchema: StateHeatmapResponseSchema
|
|
46
|
+
},
|
|
47
|
+
manualBatch: {
|
|
48
|
+
path: "/telemetry/manual/batch",
|
|
49
|
+
method: "POST",
|
|
50
|
+
requestSchema: ManualBatchRequestSchema,
|
|
51
|
+
responseSchema: ManualBatchResponseSchema
|
|
44
52
|
}
|
|
45
53
|
};
|
|
46
54
|
|
|
@@ -191,6 +199,31 @@ var AggregatorClient = class {
|
|
|
191
199
|
}
|
|
192
200
|
return responseParseResult.data;
|
|
193
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
204
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
205
|
+
*/
|
|
206
|
+
async manualBatch(request) {
|
|
207
|
+
const endpoint = endpoints.manualBatch;
|
|
208
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
209
|
+
if (!parseResult.success) {
|
|
210
|
+
throw new AggregatorClientError(
|
|
211
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
212
|
+
endpoint.path
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
216
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
217
|
+
if (!responseParseResult.success) {
|
|
218
|
+
throw new AggregatorClientError(
|
|
219
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
220
|
+
endpoint.path,
|
|
221
|
+
void 0,
|
|
222
|
+
response
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return responseParseResult.data;
|
|
226
|
+
}
|
|
194
227
|
async makeRequest(path, method, body) {
|
|
195
228
|
const url = `${this.baseUrl}${path}`;
|
|
196
229
|
const response = await fetch(url, {
|
|
@@ -264,7 +297,11 @@ import {
|
|
|
264
297
|
DriverRankingSchema,
|
|
265
298
|
StateHeatmapRequestSchema as StateHeatmapRequestSchema2,
|
|
266
299
|
StateHeatmapResponseSchema as StateHeatmapResponseSchema2,
|
|
267
|
-
StateHeatmapEntrySchema
|
|
300
|
+
StateHeatmapEntrySchema,
|
|
301
|
+
ManualBatchRequestSchema as ManualBatchRequestSchema2,
|
|
302
|
+
ManualBatchResponseSchema as ManualBatchResponseSchema2,
|
|
303
|
+
ManualBatchEntrySchema,
|
|
304
|
+
ManualBatchTelemetrySchema
|
|
268
305
|
} from "@findatruck/shared-schemas";
|
|
269
306
|
export {
|
|
270
307
|
AggregatorClient,
|
|
@@ -274,6 +311,10 @@ export {
|
|
|
274
311
|
DriverRankingSchema,
|
|
275
312
|
DriverRankingsRequestSchema2 as DriverRankingsRequestSchema,
|
|
276
313
|
DriverRankingsResponseSchema2 as DriverRankingsResponseSchema,
|
|
314
|
+
ManualBatchEntrySchema,
|
|
315
|
+
ManualBatchRequestSchema2 as ManualBatchRequestSchema,
|
|
316
|
+
ManualBatchResponseSchema2 as ManualBatchResponseSchema,
|
|
317
|
+
ManualBatchTelemetrySchema,
|
|
277
318
|
NewLoginRequestSchema2 as NewLoginRequestSchema,
|
|
278
319
|
NewLoginResponseFailureSchema,
|
|
279
320
|
NewLoginResponseSchema2 as NewLoginResponseSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@findatruck/aggregator-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@findatruck/shared-schemas": "^2.
|
|
26
|
+
"@findatruck/shared-schemas": "^2.12.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"zod": "^4.1.11"
|