@findatruck/aggregator-client 1.4.1 → 1.6.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 +162 -0
- package/dist/index.d.cts +132 -3
- package/dist/index.d.ts +132 -3
- package/dist/index.js +171 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -27,9 +27,21 @@ __export(index_exports, {
|
|
|
27
27
|
CreateAnonymousDriverBodySchema: () => import_shared_schemas2.CreateAnonymousDriverBodySchema,
|
|
28
28
|
DeleteProviderAccountRequestSchema: () => import_shared_schemas2.DeleteProviderAccountRequestSchema,
|
|
29
29
|
DeleteProviderAccountResponseSchema: () => import_shared_schemas2.DeleteProviderAccountResponseSchema,
|
|
30
|
+
DriverDailySummariesResponseSchema: () => import_shared_schemas2.DriverDailySummariesResponseSchema,
|
|
31
|
+
DriverDailySummarySchema: () => import_shared_schemas2.DriverDailySummarySchema,
|
|
32
|
+
DriverEnrichedSummariesRequestSchema: () => import_shared_schemas2.DriverEnrichedSummariesRequestSchema,
|
|
33
|
+
DriverEnrichedSummariesResponseSchema: () => import_shared_schemas2.DriverEnrichedSummariesResponseSchema,
|
|
30
34
|
DriverRankingSchema: () => import_shared_schemas2.DriverRankingSchema,
|
|
31
35
|
DriverRankingsRequestSchema: () => import_shared_schemas2.DriverRankingsRequestSchema,
|
|
32
36
|
DriverRankingsResponseSchema: () => import_shared_schemas2.DriverRankingsResponseSchema,
|
|
37
|
+
DriverTripSchema: () => import_shared_schemas2.DriverTripSchema,
|
|
38
|
+
DriverTripsRequestSchema: () => import_shared_schemas2.DriverTripsRequestSchema,
|
|
39
|
+
DriverTripsResponseSchema: () => import_shared_schemas2.DriverTripsResponseSchema,
|
|
40
|
+
EnrichedPointSchema: () => import_shared_schemas2.EnrichedPointSchema,
|
|
41
|
+
EnrichedStopSchema: () => import_shared_schemas2.EnrichedStopSchema,
|
|
42
|
+
EnrichedTripSummaryRequestSchema: () => import_shared_schemas2.EnrichedTripSummaryRequestSchema,
|
|
43
|
+
EnrichedTripSummaryResponseSchema: () => import_shared_schemas2.EnrichedTripSummaryResponseSchema,
|
|
44
|
+
EnrichedTripSummarySchema: () => import_shared_schemas2.EnrichedTripSummarySchema,
|
|
33
45
|
ManualBatchEntrySchema: () => import_shared_schemas2.ManualBatchEntrySchema,
|
|
34
46
|
ManualBatchRequestSchema: () => import_shared_schemas2.ManualBatchRequestSchema,
|
|
35
47
|
ManualBatchResponseSchema: () => import_shared_schemas2.ManualBatchResponseSchema,
|
|
@@ -91,6 +103,30 @@ var endpoints = {
|
|
|
91
103
|
method: "POST",
|
|
92
104
|
requestSchema: import_shared_schemas.CreateAnonymousDriverBodySchema,
|
|
93
105
|
responseSchema: import_shared_schemas.AnonymousDriverResponseSchema
|
|
106
|
+
},
|
|
107
|
+
driverTrips: {
|
|
108
|
+
path: "/driver/:driver_id/trips",
|
|
109
|
+
method: "GET",
|
|
110
|
+
requestSchema: import_shared_schemas.DriverTripsRequestSchema,
|
|
111
|
+
responseSchema: import_shared_schemas.DriverTripsResponseSchema
|
|
112
|
+
},
|
|
113
|
+
driverDailySummaries: {
|
|
114
|
+
path: "/driver/:driver_id/daily-summaries",
|
|
115
|
+
method: "GET",
|
|
116
|
+
requestSchema: import_shared_schemas.DriverTripsRequestSchema,
|
|
117
|
+
responseSchema: import_shared_schemas.DriverDailySummariesResponseSchema
|
|
118
|
+
},
|
|
119
|
+
enrichedTripSummary: {
|
|
120
|
+
path: "/trips/:id/enriched-summary",
|
|
121
|
+
method: "GET",
|
|
122
|
+
requestSchema: import_shared_schemas.EnrichedTripSummaryRequestSchema,
|
|
123
|
+
responseSchema: import_shared_schemas.EnrichedTripSummaryResponseSchema
|
|
124
|
+
},
|
|
125
|
+
driverEnrichedSummaries: {
|
|
126
|
+
path: "/driver/:driver_id/enriched-summary",
|
|
127
|
+
method: "GET",
|
|
128
|
+
requestSchema: import_shared_schemas.DriverEnrichedSummariesRequestSchema,
|
|
129
|
+
responseSchema: import_shared_schemas.DriverEnrichedSummariesResponseSchema
|
|
94
130
|
}
|
|
95
131
|
};
|
|
96
132
|
|
|
@@ -290,6 +326,120 @@ var AggregatorClient = class {
|
|
|
290
326
|
}
|
|
291
327
|
return responseParseResult.data;
|
|
292
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Gets individual trips for a driver within a date range.
|
|
331
|
+
* Computes on-demand if no trips exist yet.
|
|
332
|
+
*/
|
|
333
|
+
async driverTrips(request) {
|
|
334
|
+
const endpoint = endpoints.driverTrips;
|
|
335
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
336
|
+
if (!parseResult.success) {
|
|
337
|
+
throw new AggregatorClientError(
|
|
338
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
339
|
+
endpoint.path
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
343
|
+
const queryParams = {
|
|
344
|
+
start_date: request.start_date,
|
|
345
|
+
end_date: request.end_date
|
|
346
|
+
};
|
|
347
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
348
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
349
|
+
if (!responseParseResult.success) {
|
|
350
|
+
throw new AggregatorClientError(
|
|
351
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
352
|
+
endpoint.path,
|
|
353
|
+
void 0,
|
|
354
|
+
response
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
return responseParseResult.data;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Gets daily trip summaries for a driver within a date range.
|
|
361
|
+
* Computes on-demand if no summaries exist yet.
|
|
362
|
+
*/
|
|
363
|
+
async driverDailySummaries(request) {
|
|
364
|
+
const endpoint = endpoints.driverDailySummaries;
|
|
365
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
366
|
+
if (!parseResult.success) {
|
|
367
|
+
throw new AggregatorClientError(
|
|
368
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
369
|
+
endpoint.path
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
373
|
+
const queryParams = {
|
|
374
|
+
start_date: request.start_date,
|
|
375
|
+
end_date: request.end_date
|
|
376
|
+
};
|
|
377
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
378
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
379
|
+
if (!responseParseResult.success) {
|
|
380
|
+
throw new AggregatorClientError(
|
|
381
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
382
|
+
endpoint.path,
|
|
383
|
+
void 0,
|
|
384
|
+
response
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
return responseParseResult.data;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Gets an enriched trip summary for a single trip.
|
|
391
|
+
*/
|
|
392
|
+
async enrichedTripSummary(request) {
|
|
393
|
+
const endpoint = endpoints.enrichedTripSummary;
|
|
394
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
395
|
+
if (!parseResult.success) {
|
|
396
|
+
throw new AggregatorClientError(
|
|
397
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
398
|
+
endpoint.path
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
const path = endpoint.path.replace(":id", String(request.trip_id));
|
|
402
|
+
const response = await this.makeGetRequest(path, {});
|
|
403
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
404
|
+
if (!responseParseResult.success) {
|
|
405
|
+
throw new AggregatorClientError(
|
|
406
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
407
|
+
endpoint.path,
|
|
408
|
+
void 0,
|
|
409
|
+
response
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
return responseParseResult.data;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Gets enriched trip summaries for a driver within a date range.
|
|
416
|
+
*/
|
|
417
|
+
async driverEnrichedSummaries(request) {
|
|
418
|
+
const endpoint = endpoints.driverEnrichedSummaries;
|
|
419
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
420
|
+
if (!parseResult.success) {
|
|
421
|
+
throw new AggregatorClientError(
|
|
422
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
423
|
+
endpoint.path
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
427
|
+
const queryParams = {
|
|
428
|
+
start_date: request.start_date,
|
|
429
|
+
end_date: request.end_date
|
|
430
|
+
};
|
|
431
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
432
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
433
|
+
if (!responseParseResult.success) {
|
|
434
|
+
throw new AggregatorClientError(
|
|
435
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
436
|
+
endpoint.path,
|
|
437
|
+
void 0,
|
|
438
|
+
response
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
return responseParseResult.data;
|
|
442
|
+
}
|
|
293
443
|
async makeRequest(path, method, body) {
|
|
294
444
|
const url = `${this.baseUrl}${path}`;
|
|
295
445
|
const response = await fetch(url, {
|
|
@@ -361,9 +511,21 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
|
|
|
361
511
|
CreateAnonymousDriverBodySchema,
|
|
362
512
|
DeleteProviderAccountRequestSchema,
|
|
363
513
|
DeleteProviderAccountResponseSchema,
|
|
514
|
+
DriverDailySummariesResponseSchema,
|
|
515
|
+
DriverDailySummarySchema,
|
|
516
|
+
DriverEnrichedSummariesRequestSchema,
|
|
517
|
+
DriverEnrichedSummariesResponseSchema,
|
|
364
518
|
DriverRankingSchema,
|
|
365
519
|
DriverRankingsRequestSchema,
|
|
366
520
|
DriverRankingsResponseSchema,
|
|
521
|
+
DriverTripSchema,
|
|
522
|
+
DriverTripsRequestSchema,
|
|
523
|
+
DriverTripsResponseSchema,
|
|
524
|
+
EnrichedPointSchema,
|
|
525
|
+
EnrichedStopSchema,
|
|
526
|
+
EnrichedTripSummaryRequestSchema,
|
|
527
|
+
EnrichedTripSummaryResponseSchema,
|
|
528
|
+
EnrichedTripSummarySchema,
|
|
367
529
|
ManualBatchEntrySchema,
|
|
368
530
|
ManualBatchRequestSchema,
|
|
369
531
|
ManualBatchResponseSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse, CreateAnonymousDriverBody, AnonymousDriverResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { AnonymousDriverErrorResponse, AnonymousDriverErrorResponseSchema, AnonymousDriverResponse, AnonymousDriverResponseSchema, CreateAnonymousDriverBody, CreateAnonymousDriverBodySchema, 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';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse, CreateAnonymousDriverBody, AnonymousDriverResponse, DriverTripsRequest, DriverTripsResponse, DriverDailySummariesResponse, EnrichedTripSummaryRequest, EnrichedTripSummaryResponse, DriverEnrichedSummariesRequest, DriverEnrichedSummariesResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { AnonymousDriverErrorResponse, AnonymousDriverErrorResponseSchema, AnonymousDriverResponse, AnonymousDriverResponseSchema, CreateAnonymousDriverBody, CreateAnonymousDriverBodySchema, DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverDailySummariesResponse, DriverDailySummariesResponseSchema, DriverDailySummary, DriverDailySummarySchema, DriverEnrichedSummariesRequest, DriverEnrichedSummariesRequestSchema, DriverEnrichedSummariesResponse, DriverEnrichedSummariesResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, DriverTrip, DriverTripSchema, DriverTripsRequest, DriverTripsRequestSchema, DriverTripsResponse, DriverTripsResponseSchema, EnrichedPoint, EnrichedPointSchema, EnrichedStop, EnrichedStopSchema, EnrichedTripSummary, EnrichedTripSummaryRequest, EnrichedTripSummaryRequestSchema, EnrichedTripSummaryResponse, EnrichedTripSummaryResponseSchema, EnrichedTripSummarySchema, 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
|
/**
|
|
@@ -79,6 +79,24 @@ declare class AggregatorClient {
|
|
|
79
79
|
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
80
80
|
*/
|
|
81
81
|
anonymousDriver(request: CreateAnonymousDriverBody): Promise<AnonymousDriverResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets individual trips for a driver within a date range.
|
|
84
|
+
* Computes on-demand if no trips exist yet.
|
|
85
|
+
*/
|
|
86
|
+
driverTrips(request: DriverTripsRequest): Promise<DriverTripsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets daily trip summaries for a driver within a date range.
|
|
89
|
+
* Computes on-demand if no summaries exist yet.
|
|
90
|
+
*/
|
|
91
|
+
driverDailySummaries(request: DriverTripsRequest): Promise<DriverDailySummariesResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Gets an enriched trip summary for a single trip.
|
|
94
|
+
*/
|
|
95
|
+
enrichedTripSummary(request: EnrichedTripSummaryRequest): Promise<EnrichedTripSummaryResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Gets enriched trip summaries for a driver within a date range.
|
|
98
|
+
*/
|
|
99
|
+
driverEnrichedSummaries(request: DriverEnrichedSummariesRequest): Promise<DriverEnrichedSummariesResponse>;
|
|
82
100
|
private makeRequest;
|
|
83
101
|
private makeGetRequest;
|
|
84
102
|
}
|
|
@@ -158,6 +176,10 @@ declare const endpoints: {
|
|
|
158
176
|
start_date: z.ZodString;
|
|
159
177
|
end_date: z.ZodString;
|
|
160
178
|
state: z.ZodOptional<z.ZodString>;
|
|
179
|
+
source: z.ZodDefault<z.ZodEnum<{
|
|
180
|
+
eld: "eld";
|
|
181
|
+
manual: "manual";
|
|
182
|
+
}>>;
|
|
161
183
|
}, z.core.$strip>;
|
|
162
184
|
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
163
185
|
rank: z.ZodNumber;
|
|
@@ -190,6 +212,10 @@ declare const endpoints: {
|
|
|
190
212
|
location_longitude: z.ZodNumber;
|
|
191
213
|
location_address: z.ZodOptional<z.ZodString>;
|
|
192
214
|
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
215
|
+
heading: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
speed_mph: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
altitude_feet: z.ZodOptional<z.ZodNumber>;
|
|
218
|
+
raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
193
219
|
}, z.core.$strip>>;
|
|
194
220
|
}, z.core.$strip>;
|
|
195
221
|
readonly responseSchema: z.ZodObject<{
|
|
@@ -209,7 +235,11 @@ declare const endpoints: {
|
|
|
209
235
|
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
210
236
|
location_address: z.ZodNullable<z.ZodString>;
|
|
211
237
|
location_state: z.ZodNullable<z.ZodString>;
|
|
212
|
-
|
|
238
|
+
echoed_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
239
|
+
osrm_calculated_miles: z.ZodNullable<z.ZodNumber>;
|
|
240
|
+
heading: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
241
|
+
speed_mph: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
242
|
+
altitude_feet: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
213
243
|
source: z.ZodEnum<{
|
|
214
244
|
eld: "eld";
|
|
215
245
|
manual: "manual";
|
|
@@ -227,6 +257,105 @@ declare const endpoints: {
|
|
|
227
257
|
driver_id: z.ZodString;
|
|
228
258
|
}, z.core.$strip>;
|
|
229
259
|
};
|
|
260
|
+
readonly driverTrips: {
|
|
261
|
+
readonly path: "/driver/:driver_id/trips";
|
|
262
|
+
readonly method: "GET";
|
|
263
|
+
readonly requestSchema: z.ZodObject<{
|
|
264
|
+
driver_id: z.ZodString;
|
|
265
|
+
start_date: z.ZodString;
|
|
266
|
+
end_date: z.ZodString;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
269
|
+
id: z.ZodNumber;
|
|
270
|
+
start_time: z.ZodString;
|
|
271
|
+
end_time: z.ZodString;
|
|
272
|
+
point_count: z.ZodNumber;
|
|
273
|
+
polyline: z.ZodNullable<z.ZodString>;
|
|
274
|
+
highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
275
|
+
total_miles: z.ZodNullable<z.ZodNumber>;
|
|
276
|
+
avg_speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
278
|
+
miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
};
|
|
281
|
+
readonly driverDailySummaries: {
|
|
282
|
+
readonly path: "/driver/:driver_id/daily-summaries";
|
|
283
|
+
readonly method: "GET";
|
|
284
|
+
readonly requestSchema: z.ZodObject<{
|
|
285
|
+
driver_id: z.ZodString;
|
|
286
|
+
start_date: z.ZodString;
|
|
287
|
+
end_date: z.ZodString;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
290
|
+
summary_date: z.ZodString;
|
|
291
|
+
total_miles: z.ZodNumber;
|
|
292
|
+
trip_count: z.ZodNumber;
|
|
293
|
+
point_count: z.ZodNumber;
|
|
294
|
+
polyline: z.ZodNullable<z.ZodString>;
|
|
295
|
+
highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
296
|
+
avg_speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
297
|
+
miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
298
|
+
miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
299
|
+
}, z.core.$strip>>;
|
|
300
|
+
};
|
|
301
|
+
readonly enrichedTripSummary: {
|
|
302
|
+
readonly path: "/trips/:id/enriched-summary";
|
|
303
|
+
readonly method: "GET";
|
|
304
|
+
readonly requestSchema: z.ZodObject<{
|
|
305
|
+
trip_id: z.ZodNumber;
|
|
306
|
+
}, z.core.$strip>;
|
|
307
|
+
readonly responseSchema: z.ZodObject<{
|
|
308
|
+
trip_id: z.ZodNumber;
|
|
309
|
+
driver_id: z.ZodString;
|
|
310
|
+
start_time: z.ZodString;
|
|
311
|
+
end_time: z.ZodString;
|
|
312
|
+
points: z.ZodArray<z.ZodObject<{
|
|
313
|
+
lat: z.ZodNumber;
|
|
314
|
+
lon: z.ZodNumber;
|
|
315
|
+
timestamp: z.ZodString;
|
|
316
|
+
speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
317
|
+
heading: z.ZodNullable<z.ZodNumber>;
|
|
318
|
+
altitude_feet: z.ZodNullable<z.ZodNumber>;
|
|
319
|
+
weather_condition: z.ZodNullable<z.ZodString>;
|
|
320
|
+
temperature_f: z.ZodNullable<z.ZodNumber>;
|
|
321
|
+
visibility_miles: z.ZodNullable<z.ZodNumber>;
|
|
322
|
+
light_condition: z.ZodNullable<z.ZodString>;
|
|
323
|
+
stop: z.ZodNullable<z.ZodObject<{
|
|
324
|
+
duration_seconds: z.ZodNumber;
|
|
325
|
+
}, z.core.$strip>>;
|
|
326
|
+
}, z.core.$strip>>;
|
|
327
|
+
}, z.core.$strip>;
|
|
328
|
+
};
|
|
329
|
+
readonly driverEnrichedSummaries: {
|
|
330
|
+
readonly path: "/driver/:driver_id/enriched-summary";
|
|
331
|
+
readonly method: "GET";
|
|
332
|
+
readonly requestSchema: z.ZodObject<{
|
|
333
|
+
driver_id: z.ZodString;
|
|
334
|
+
start_date: z.ZodString;
|
|
335
|
+
end_date: z.ZodString;
|
|
336
|
+
}, z.core.$strip>;
|
|
337
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
338
|
+
trip_id: z.ZodNumber;
|
|
339
|
+
driver_id: z.ZodString;
|
|
340
|
+
start_time: z.ZodString;
|
|
341
|
+
end_time: z.ZodString;
|
|
342
|
+
points: z.ZodArray<z.ZodObject<{
|
|
343
|
+
lat: z.ZodNumber;
|
|
344
|
+
lon: z.ZodNumber;
|
|
345
|
+
timestamp: z.ZodString;
|
|
346
|
+
speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
347
|
+
heading: z.ZodNullable<z.ZodNumber>;
|
|
348
|
+
altitude_feet: z.ZodNullable<z.ZodNumber>;
|
|
349
|
+
weather_condition: z.ZodNullable<z.ZodString>;
|
|
350
|
+
temperature_f: z.ZodNullable<z.ZodNumber>;
|
|
351
|
+
visibility_miles: z.ZodNullable<z.ZodNumber>;
|
|
352
|
+
light_condition: z.ZodNullable<z.ZodString>;
|
|
353
|
+
stop: z.ZodNullable<z.ZodObject<{
|
|
354
|
+
duration_seconds: z.ZodNumber;
|
|
355
|
+
}, z.core.$strip>>;
|
|
356
|
+
}, z.core.$strip>>;
|
|
357
|
+
}, z.core.$strip>>;
|
|
358
|
+
};
|
|
230
359
|
};
|
|
231
360
|
type EndpointName = keyof typeof endpoints;
|
|
232
361
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse, CreateAnonymousDriverBody, AnonymousDriverResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { AnonymousDriverErrorResponse, AnonymousDriverErrorResponseSchema, AnonymousDriverResponse, AnonymousDriverResponseSchema, CreateAnonymousDriverBody, CreateAnonymousDriverBodySchema, 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';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse, CreateAnonymousDriverBody, AnonymousDriverResponse, DriverTripsRequest, DriverTripsResponse, DriverDailySummariesResponse, EnrichedTripSummaryRequest, EnrichedTripSummaryResponse, DriverEnrichedSummariesRequest, DriverEnrichedSummariesResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { AnonymousDriverErrorResponse, AnonymousDriverErrorResponseSchema, AnonymousDriverResponse, AnonymousDriverResponseSchema, CreateAnonymousDriverBody, CreateAnonymousDriverBodySchema, DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverDailySummariesResponse, DriverDailySummariesResponseSchema, DriverDailySummary, DriverDailySummarySchema, DriverEnrichedSummariesRequest, DriverEnrichedSummariesRequestSchema, DriverEnrichedSummariesResponse, DriverEnrichedSummariesResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, DriverTrip, DriverTripSchema, DriverTripsRequest, DriverTripsRequestSchema, DriverTripsResponse, DriverTripsResponseSchema, EnrichedPoint, EnrichedPointSchema, EnrichedStop, EnrichedStopSchema, EnrichedTripSummary, EnrichedTripSummaryRequest, EnrichedTripSummaryRequestSchema, EnrichedTripSummaryResponse, EnrichedTripSummaryResponseSchema, EnrichedTripSummarySchema, 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
|
/**
|
|
@@ -79,6 +79,24 @@ declare class AggregatorClient {
|
|
|
79
79
|
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
80
80
|
*/
|
|
81
81
|
anonymousDriver(request: CreateAnonymousDriverBody): Promise<AnonymousDriverResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Gets individual trips for a driver within a date range.
|
|
84
|
+
* Computes on-demand if no trips exist yet.
|
|
85
|
+
*/
|
|
86
|
+
driverTrips(request: DriverTripsRequest): Promise<DriverTripsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets daily trip summaries for a driver within a date range.
|
|
89
|
+
* Computes on-demand if no summaries exist yet.
|
|
90
|
+
*/
|
|
91
|
+
driverDailySummaries(request: DriverTripsRequest): Promise<DriverDailySummariesResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Gets an enriched trip summary for a single trip.
|
|
94
|
+
*/
|
|
95
|
+
enrichedTripSummary(request: EnrichedTripSummaryRequest): Promise<EnrichedTripSummaryResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Gets enriched trip summaries for a driver within a date range.
|
|
98
|
+
*/
|
|
99
|
+
driverEnrichedSummaries(request: DriverEnrichedSummariesRequest): Promise<DriverEnrichedSummariesResponse>;
|
|
82
100
|
private makeRequest;
|
|
83
101
|
private makeGetRequest;
|
|
84
102
|
}
|
|
@@ -158,6 +176,10 @@ declare const endpoints: {
|
|
|
158
176
|
start_date: z.ZodString;
|
|
159
177
|
end_date: z.ZodString;
|
|
160
178
|
state: z.ZodOptional<z.ZodString>;
|
|
179
|
+
source: z.ZodDefault<z.ZodEnum<{
|
|
180
|
+
eld: "eld";
|
|
181
|
+
manual: "manual";
|
|
182
|
+
}>>;
|
|
161
183
|
}, z.core.$strip>;
|
|
162
184
|
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
163
185
|
rank: z.ZodNumber;
|
|
@@ -190,6 +212,10 @@ declare const endpoints: {
|
|
|
190
212
|
location_longitude: z.ZodNumber;
|
|
191
213
|
location_address: z.ZodOptional<z.ZodString>;
|
|
192
214
|
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
215
|
+
heading: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
speed_mph: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
altitude_feet: z.ZodOptional<z.ZodNumber>;
|
|
218
|
+
raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
193
219
|
}, z.core.$strip>>;
|
|
194
220
|
}, z.core.$strip>;
|
|
195
221
|
readonly responseSchema: z.ZodObject<{
|
|
@@ -209,7 +235,11 @@ declare const endpoints: {
|
|
|
209
235
|
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
210
236
|
location_address: z.ZodNullable<z.ZodString>;
|
|
211
237
|
location_state: z.ZodNullable<z.ZodString>;
|
|
212
|
-
|
|
238
|
+
echoed_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
239
|
+
osrm_calculated_miles: z.ZodNullable<z.ZodNumber>;
|
|
240
|
+
heading: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
241
|
+
speed_mph: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
242
|
+
altitude_feet: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
213
243
|
source: z.ZodEnum<{
|
|
214
244
|
eld: "eld";
|
|
215
245
|
manual: "manual";
|
|
@@ -227,6 +257,105 @@ declare const endpoints: {
|
|
|
227
257
|
driver_id: z.ZodString;
|
|
228
258
|
}, z.core.$strip>;
|
|
229
259
|
};
|
|
260
|
+
readonly driverTrips: {
|
|
261
|
+
readonly path: "/driver/:driver_id/trips";
|
|
262
|
+
readonly method: "GET";
|
|
263
|
+
readonly requestSchema: z.ZodObject<{
|
|
264
|
+
driver_id: z.ZodString;
|
|
265
|
+
start_date: z.ZodString;
|
|
266
|
+
end_date: z.ZodString;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
269
|
+
id: z.ZodNumber;
|
|
270
|
+
start_time: z.ZodString;
|
|
271
|
+
end_time: z.ZodString;
|
|
272
|
+
point_count: z.ZodNumber;
|
|
273
|
+
polyline: z.ZodNullable<z.ZodString>;
|
|
274
|
+
highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
275
|
+
total_miles: z.ZodNullable<z.ZodNumber>;
|
|
276
|
+
avg_speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
278
|
+
miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
};
|
|
281
|
+
readonly driverDailySummaries: {
|
|
282
|
+
readonly path: "/driver/:driver_id/daily-summaries";
|
|
283
|
+
readonly method: "GET";
|
|
284
|
+
readonly requestSchema: z.ZodObject<{
|
|
285
|
+
driver_id: z.ZodString;
|
|
286
|
+
start_date: z.ZodString;
|
|
287
|
+
end_date: z.ZodString;
|
|
288
|
+
}, z.core.$strip>;
|
|
289
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
290
|
+
summary_date: z.ZodString;
|
|
291
|
+
total_miles: z.ZodNumber;
|
|
292
|
+
trip_count: z.ZodNumber;
|
|
293
|
+
point_count: z.ZodNumber;
|
|
294
|
+
polyline: z.ZodNullable<z.ZodString>;
|
|
295
|
+
highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
296
|
+
avg_speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
297
|
+
miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
298
|
+
miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
299
|
+
}, z.core.$strip>>;
|
|
300
|
+
};
|
|
301
|
+
readonly enrichedTripSummary: {
|
|
302
|
+
readonly path: "/trips/:id/enriched-summary";
|
|
303
|
+
readonly method: "GET";
|
|
304
|
+
readonly requestSchema: z.ZodObject<{
|
|
305
|
+
trip_id: z.ZodNumber;
|
|
306
|
+
}, z.core.$strip>;
|
|
307
|
+
readonly responseSchema: z.ZodObject<{
|
|
308
|
+
trip_id: z.ZodNumber;
|
|
309
|
+
driver_id: z.ZodString;
|
|
310
|
+
start_time: z.ZodString;
|
|
311
|
+
end_time: z.ZodString;
|
|
312
|
+
points: z.ZodArray<z.ZodObject<{
|
|
313
|
+
lat: z.ZodNumber;
|
|
314
|
+
lon: z.ZodNumber;
|
|
315
|
+
timestamp: z.ZodString;
|
|
316
|
+
speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
317
|
+
heading: z.ZodNullable<z.ZodNumber>;
|
|
318
|
+
altitude_feet: z.ZodNullable<z.ZodNumber>;
|
|
319
|
+
weather_condition: z.ZodNullable<z.ZodString>;
|
|
320
|
+
temperature_f: z.ZodNullable<z.ZodNumber>;
|
|
321
|
+
visibility_miles: z.ZodNullable<z.ZodNumber>;
|
|
322
|
+
light_condition: z.ZodNullable<z.ZodString>;
|
|
323
|
+
stop: z.ZodNullable<z.ZodObject<{
|
|
324
|
+
duration_seconds: z.ZodNumber;
|
|
325
|
+
}, z.core.$strip>>;
|
|
326
|
+
}, z.core.$strip>>;
|
|
327
|
+
}, z.core.$strip>;
|
|
328
|
+
};
|
|
329
|
+
readonly driverEnrichedSummaries: {
|
|
330
|
+
readonly path: "/driver/:driver_id/enriched-summary";
|
|
331
|
+
readonly method: "GET";
|
|
332
|
+
readonly requestSchema: z.ZodObject<{
|
|
333
|
+
driver_id: z.ZodString;
|
|
334
|
+
start_date: z.ZodString;
|
|
335
|
+
end_date: z.ZodString;
|
|
336
|
+
}, z.core.$strip>;
|
|
337
|
+
readonly responseSchema: z.ZodArray<z.ZodObject<{
|
|
338
|
+
trip_id: z.ZodNumber;
|
|
339
|
+
driver_id: z.ZodString;
|
|
340
|
+
start_time: z.ZodString;
|
|
341
|
+
end_time: z.ZodString;
|
|
342
|
+
points: z.ZodArray<z.ZodObject<{
|
|
343
|
+
lat: z.ZodNumber;
|
|
344
|
+
lon: z.ZodNumber;
|
|
345
|
+
timestamp: z.ZodString;
|
|
346
|
+
speed_mph: z.ZodNullable<z.ZodNumber>;
|
|
347
|
+
heading: z.ZodNullable<z.ZodNumber>;
|
|
348
|
+
altitude_feet: z.ZodNullable<z.ZodNumber>;
|
|
349
|
+
weather_condition: z.ZodNullable<z.ZodString>;
|
|
350
|
+
temperature_f: z.ZodNullable<z.ZodNumber>;
|
|
351
|
+
visibility_miles: z.ZodNullable<z.ZodNumber>;
|
|
352
|
+
light_condition: z.ZodNullable<z.ZodString>;
|
|
353
|
+
stop: z.ZodNullable<z.ZodObject<{
|
|
354
|
+
duration_seconds: z.ZodNumber;
|
|
355
|
+
}, z.core.$strip>>;
|
|
356
|
+
}, z.core.$strip>>;
|
|
357
|
+
}, z.core.$strip>>;
|
|
358
|
+
};
|
|
230
359
|
};
|
|
231
360
|
type EndpointName = keyof typeof endpoints;
|
|
232
361
|
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,14 @@ import {
|
|
|
13
13
|
ManualBatchRequestSchema,
|
|
14
14
|
ManualBatchResponseSchema,
|
|
15
15
|
CreateAnonymousDriverBodySchema,
|
|
16
|
-
AnonymousDriverResponseSchema
|
|
16
|
+
AnonymousDriverResponseSchema,
|
|
17
|
+
DriverTripsRequestSchema,
|
|
18
|
+
DriverTripsResponseSchema,
|
|
19
|
+
DriverDailySummariesResponseSchema,
|
|
20
|
+
EnrichedTripSummaryRequestSchema,
|
|
21
|
+
EnrichedTripSummaryResponseSchema,
|
|
22
|
+
DriverEnrichedSummariesRequestSchema,
|
|
23
|
+
DriverEnrichedSummariesResponseSchema
|
|
17
24
|
} from "@findatruck/shared-schemas";
|
|
18
25
|
var endpoints = {
|
|
19
26
|
newLogin: {
|
|
@@ -57,6 +64,30 @@ var endpoints = {
|
|
|
57
64
|
method: "POST",
|
|
58
65
|
requestSchema: CreateAnonymousDriverBodySchema,
|
|
59
66
|
responseSchema: AnonymousDriverResponseSchema
|
|
67
|
+
},
|
|
68
|
+
driverTrips: {
|
|
69
|
+
path: "/driver/:driver_id/trips",
|
|
70
|
+
method: "GET",
|
|
71
|
+
requestSchema: DriverTripsRequestSchema,
|
|
72
|
+
responseSchema: DriverTripsResponseSchema
|
|
73
|
+
},
|
|
74
|
+
driverDailySummaries: {
|
|
75
|
+
path: "/driver/:driver_id/daily-summaries",
|
|
76
|
+
method: "GET",
|
|
77
|
+
requestSchema: DriverTripsRequestSchema,
|
|
78
|
+
responseSchema: DriverDailySummariesResponseSchema
|
|
79
|
+
},
|
|
80
|
+
enrichedTripSummary: {
|
|
81
|
+
path: "/trips/:id/enriched-summary",
|
|
82
|
+
method: "GET",
|
|
83
|
+
requestSchema: EnrichedTripSummaryRequestSchema,
|
|
84
|
+
responseSchema: EnrichedTripSummaryResponseSchema
|
|
85
|
+
},
|
|
86
|
+
driverEnrichedSummaries: {
|
|
87
|
+
path: "/driver/:driver_id/enriched-summary",
|
|
88
|
+
method: "GET",
|
|
89
|
+
requestSchema: DriverEnrichedSummariesRequestSchema,
|
|
90
|
+
responseSchema: DriverEnrichedSummariesResponseSchema
|
|
60
91
|
}
|
|
61
92
|
};
|
|
62
93
|
|
|
@@ -256,6 +287,120 @@ var AggregatorClient = class {
|
|
|
256
287
|
}
|
|
257
288
|
return responseParseResult.data;
|
|
258
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Gets individual trips for a driver within a date range.
|
|
292
|
+
* Computes on-demand if no trips exist yet.
|
|
293
|
+
*/
|
|
294
|
+
async driverTrips(request) {
|
|
295
|
+
const endpoint = endpoints.driverTrips;
|
|
296
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
297
|
+
if (!parseResult.success) {
|
|
298
|
+
throw new AggregatorClientError(
|
|
299
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
300
|
+
endpoint.path
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
304
|
+
const queryParams = {
|
|
305
|
+
start_date: request.start_date,
|
|
306
|
+
end_date: request.end_date
|
|
307
|
+
};
|
|
308
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
309
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
310
|
+
if (!responseParseResult.success) {
|
|
311
|
+
throw new AggregatorClientError(
|
|
312
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
313
|
+
endpoint.path,
|
|
314
|
+
void 0,
|
|
315
|
+
response
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
return responseParseResult.data;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Gets daily trip summaries for a driver within a date range.
|
|
322
|
+
* Computes on-demand if no summaries exist yet.
|
|
323
|
+
*/
|
|
324
|
+
async driverDailySummaries(request) {
|
|
325
|
+
const endpoint = endpoints.driverDailySummaries;
|
|
326
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
327
|
+
if (!parseResult.success) {
|
|
328
|
+
throw new AggregatorClientError(
|
|
329
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
330
|
+
endpoint.path
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
334
|
+
const queryParams = {
|
|
335
|
+
start_date: request.start_date,
|
|
336
|
+
end_date: request.end_date
|
|
337
|
+
};
|
|
338
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
339
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
340
|
+
if (!responseParseResult.success) {
|
|
341
|
+
throw new AggregatorClientError(
|
|
342
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
343
|
+
endpoint.path,
|
|
344
|
+
void 0,
|
|
345
|
+
response
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
return responseParseResult.data;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Gets an enriched trip summary for a single trip.
|
|
352
|
+
*/
|
|
353
|
+
async enrichedTripSummary(request) {
|
|
354
|
+
const endpoint = endpoints.enrichedTripSummary;
|
|
355
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
356
|
+
if (!parseResult.success) {
|
|
357
|
+
throw new AggregatorClientError(
|
|
358
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
359
|
+
endpoint.path
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
const path = endpoint.path.replace(":id", String(request.trip_id));
|
|
363
|
+
const response = await this.makeGetRequest(path, {});
|
|
364
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
365
|
+
if (!responseParseResult.success) {
|
|
366
|
+
throw new AggregatorClientError(
|
|
367
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
368
|
+
endpoint.path,
|
|
369
|
+
void 0,
|
|
370
|
+
response
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return responseParseResult.data;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Gets enriched trip summaries for a driver within a date range.
|
|
377
|
+
*/
|
|
378
|
+
async driverEnrichedSummaries(request) {
|
|
379
|
+
const endpoint = endpoints.driverEnrichedSummaries;
|
|
380
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
381
|
+
if (!parseResult.success) {
|
|
382
|
+
throw new AggregatorClientError(
|
|
383
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
384
|
+
endpoint.path
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
const path = endpoint.path.replace(":driver_id", request.driver_id);
|
|
388
|
+
const queryParams = {
|
|
389
|
+
start_date: request.start_date,
|
|
390
|
+
end_date: request.end_date
|
|
391
|
+
};
|
|
392
|
+
const response = await this.makeGetRequest(path, queryParams);
|
|
393
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
394
|
+
if (!responseParseResult.success) {
|
|
395
|
+
throw new AggregatorClientError(
|
|
396
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
397
|
+
endpoint.path,
|
|
398
|
+
void 0,
|
|
399
|
+
response
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
return responseParseResult.data;
|
|
403
|
+
}
|
|
259
404
|
async makeRequest(path, method, body) {
|
|
260
405
|
const url = `${this.baseUrl}${path}`;
|
|
261
406
|
const response = await fetch(url, {
|
|
@@ -338,7 +483,19 @@ import {
|
|
|
338
483
|
ManualBatchTelemetrySchema,
|
|
339
484
|
CreateAnonymousDriverBodySchema as CreateAnonymousDriverBodySchema2,
|
|
340
485
|
AnonymousDriverResponseSchema as AnonymousDriverResponseSchema2,
|
|
341
|
-
AnonymousDriverErrorResponseSchema
|
|
486
|
+
AnonymousDriverErrorResponseSchema,
|
|
487
|
+
DriverTripsRequestSchema as DriverTripsRequestSchema2,
|
|
488
|
+
DriverTripSchema,
|
|
489
|
+
DriverTripsResponseSchema as DriverTripsResponseSchema2,
|
|
490
|
+
DriverDailySummarySchema,
|
|
491
|
+
DriverDailySummariesResponseSchema as DriverDailySummariesResponseSchema2,
|
|
492
|
+
EnrichedTripSummaryRequestSchema as EnrichedTripSummaryRequestSchema2,
|
|
493
|
+
EnrichedTripSummaryResponseSchema as EnrichedTripSummaryResponseSchema2,
|
|
494
|
+
EnrichedTripSummarySchema,
|
|
495
|
+
EnrichedPointSchema,
|
|
496
|
+
EnrichedStopSchema,
|
|
497
|
+
DriverEnrichedSummariesRequestSchema as DriverEnrichedSummariesRequestSchema2,
|
|
498
|
+
DriverEnrichedSummariesResponseSchema as DriverEnrichedSummariesResponseSchema2
|
|
342
499
|
} from "@findatruck/shared-schemas";
|
|
343
500
|
export {
|
|
344
501
|
AggregatorClient,
|
|
@@ -348,9 +505,21 @@ export {
|
|
|
348
505
|
CreateAnonymousDriverBodySchema2 as CreateAnonymousDriverBodySchema,
|
|
349
506
|
DeleteProviderAccountRequestSchema2 as DeleteProviderAccountRequestSchema,
|
|
350
507
|
DeleteProviderAccountResponseSchema2 as DeleteProviderAccountResponseSchema,
|
|
508
|
+
DriverDailySummariesResponseSchema2 as DriverDailySummariesResponseSchema,
|
|
509
|
+
DriverDailySummarySchema,
|
|
510
|
+
DriverEnrichedSummariesRequestSchema2 as DriverEnrichedSummariesRequestSchema,
|
|
511
|
+
DriverEnrichedSummariesResponseSchema2 as DriverEnrichedSummariesResponseSchema,
|
|
351
512
|
DriverRankingSchema,
|
|
352
513
|
DriverRankingsRequestSchema2 as DriverRankingsRequestSchema,
|
|
353
514
|
DriverRankingsResponseSchema2 as DriverRankingsResponseSchema,
|
|
515
|
+
DriverTripSchema,
|
|
516
|
+
DriverTripsRequestSchema2 as DriverTripsRequestSchema,
|
|
517
|
+
DriverTripsResponseSchema2 as DriverTripsResponseSchema,
|
|
518
|
+
EnrichedPointSchema,
|
|
519
|
+
EnrichedStopSchema,
|
|
520
|
+
EnrichedTripSummaryRequestSchema2 as EnrichedTripSummaryRequestSchema,
|
|
521
|
+
EnrichedTripSummaryResponseSchema2 as EnrichedTripSummaryResponseSchema,
|
|
522
|
+
EnrichedTripSummarySchema,
|
|
354
523
|
ManualBatchEntrySchema,
|
|
355
524
|
ManualBatchRequestSchema2 as ManualBatchRequestSchema,
|
|
356
525
|
ManualBatchResponseSchema2 as ManualBatchResponseSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@findatruck/aggregator-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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.15.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"zod": "^4.1.11"
|