@findatruck/aggregator-client 1.5.0 → 1.7.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 CHANGED
@@ -27,9 +27,22 @@ __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,
34
+ DriverNameSchema: () => import_shared_schemas2.DriverNameSchema,
30
35
  DriverRankingSchema: () => import_shared_schemas2.DriverRankingSchema,
31
36
  DriverRankingsRequestSchema: () => import_shared_schemas2.DriverRankingsRequestSchema,
32
37
  DriverRankingsResponseSchema: () => import_shared_schemas2.DriverRankingsResponseSchema,
38
+ DriverTripSchema: () => import_shared_schemas2.DriverTripSchema,
39
+ DriverTripsRequestSchema: () => import_shared_schemas2.DriverTripsRequestSchema,
40
+ DriverTripsResponseSchema: () => import_shared_schemas2.DriverTripsResponseSchema,
41
+ EnrichedPointSchema: () => import_shared_schemas2.EnrichedPointSchema,
42
+ EnrichedStopSchema: () => import_shared_schemas2.EnrichedStopSchema,
43
+ EnrichedTripSummaryRequestSchema: () => import_shared_schemas2.EnrichedTripSummaryRequestSchema,
44
+ EnrichedTripSummaryResponseSchema: () => import_shared_schemas2.EnrichedTripSummaryResponseSchema,
45
+ EnrichedTripSummarySchema: () => import_shared_schemas2.EnrichedTripSummarySchema,
33
46
  ManualBatchEntrySchema: () => import_shared_schemas2.ManualBatchEntrySchema,
34
47
  ManualBatchRequestSchema: () => import_shared_schemas2.ManualBatchRequestSchema,
35
48
  ManualBatchResponseSchema: () => import_shared_schemas2.ManualBatchResponseSchema,
@@ -38,6 +51,11 @@ __export(index_exports, {
38
51
  NewLoginResponseFailureSchema: () => import_shared_schemas2.NewLoginResponseFailureSchema,
39
52
  NewLoginResponseSchema: () => import_shared_schemas2.NewLoginResponseSchema,
40
53
  NewLoginResponseSuccessSchema: () => import_shared_schemas2.NewLoginResponseSuccessSchema,
54
+ PATCH_DRIVER_NAME_MAX_LENGTH: () => import_shared_schemas2.PATCH_DRIVER_NAME_MAX_LENGTH,
55
+ PatchDriverDriverResponseSchema: () => import_shared_schemas2.PatchDriverDriverResponseSchema,
56
+ PatchDriverRequestSchema: () => import_shared_schemas2.PatchDriverRequestSchema,
57
+ PatchDriverResponseSchema: () => import_shared_schemas2.PatchDriverResponseSchema,
58
+ SharedDriverResponseSchema: () => import_shared_schemas2.SharedDriverResponseSchema,
41
59
  StateHeatmapEntrySchema: () => import_shared_schemas2.StateHeatmapEntrySchema,
42
60
  StateHeatmapRequestSchema: () => import_shared_schemas2.StateHeatmapRequestSchema,
43
61
  StateHeatmapResponseSchema: () => import_shared_schemas2.StateHeatmapResponseSchema,
@@ -91,6 +109,36 @@ var endpoints = {
91
109
  method: "POST",
92
110
  requestSchema: import_shared_schemas.CreateAnonymousDriverBodySchema,
93
111
  responseSchema: import_shared_schemas.AnonymousDriverResponseSchema
112
+ },
113
+ driverTrips: {
114
+ path: "/driver/:driver_id/trips",
115
+ method: "GET",
116
+ requestSchema: import_shared_schemas.DriverTripsRequestSchema,
117
+ responseSchema: import_shared_schemas.DriverTripsResponseSchema
118
+ },
119
+ driverDailySummaries: {
120
+ path: "/driver/:driver_id/daily-summaries",
121
+ method: "GET",
122
+ requestSchema: import_shared_schemas.DriverTripsRequestSchema,
123
+ responseSchema: import_shared_schemas.DriverDailySummariesResponseSchema
124
+ },
125
+ enrichedTripSummary: {
126
+ path: "/trips/:id/enriched-summary",
127
+ method: "GET",
128
+ requestSchema: import_shared_schemas.EnrichedTripSummaryRequestSchema,
129
+ responseSchema: import_shared_schemas.EnrichedTripSummaryResponseSchema
130
+ },
131
+ driverEnrichedSummaries: {
132
+ path: "/driver/:driver_id/enriched-summary",
133
+ method: "GET",
134
+ requestSchema: import_shared_schemas.DriverEnrichedSummariesRequestSchema,
135
+ responseSchema: import_shared_schemas.DriverEnrichedSummariesResponseSchema
136
+ },
137
+ patchDriver: {
138
+ path: "/drivers/:id",
139
+ method: "PATCH",
140
+ requestSchema: import_shared_schemas.PatchDriverRequestSchema,
141
+ responseSchema: import_shared_schemas.PatchDriverResponseSchema
94
142
  }
95
143
  };
96
144
 
@@ -290,6 +338,149 @@ var AggregatorClient = class {
290
338
  }
291
339
  return responseParseResult.data;
292
340
  }
341
+ /**
342
+ * Renames a driver by ID.
343
+ */
344
+ async patchDriver(request) {
345
+ const endpoint = endpoints.patchDriver;
346
+ const parseResult = endpoint.requestSchema.safeParse(request);
347
+ if (!parseResult.success) {
348
+ throw new AggregatorClientError(
349
+ `Invalid request: ${parseResult.error.message}`,
350
+ endpoint.path
351
+ );
352
+ }
353
+ const validated = parseResult.data;
354
+ const path = endpoint.path.replace(":id", validated.driver_id);
355
+ const response = await this.makeRequest(path, endpoint.method, {
356
+ name: validated.name,
357
+ provider_account_id: validated.provider_account_id
358
+ });
359
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
360
+ if (!responseParseResult.success) {
361
+ throw new AggregatorClientError(
362
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
363
+ endpoint.path,
364
+ void 0,
365
+ response
366
+ );
367
+ }
368
+ return responseParseResult.data;
369
+ }
370
+ /**
371
+ * Gets individual trips for a driver within a date range.
372
+ * Computes on-demand if no trips exist yet.
373
+ */
374
+ async driverTrips(request) {
375
+ const endpoint = endpoints.driverTrips;
376
+ const parseResult = endpoint.requestSchema.safeParse(request);
377
+ if (!parseResult.success) {
378
+ throw new AggregatorClientError(
379
+ `Invalid request: ${parseResult.error.message}`,
380
+ endpoint.path
381
+ );
382
+ }
383
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
384
+ const queryParams = {
385
+ start_date: request.start_date,
386
+ end_date: request.end_date
387
+ };
388
+ const response = await this.makeGetRequest(path, queryParams);
389
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
390
+ if (!responseParseResult.success) {
391
+ throw new AggregatorClientError(
392
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
393
+ endpoint.path,
394
+ void 0,
395
+ response
396
+ );
397
+ }
398
+ return responseParseResult.data;
399
+ }
400
+ /**
401
+ * Gets daily trip summaries for a driver within a date range.
402
+ * Computes on-demand if no summaries exist yet.
403
+ */
404
+ async driverDailySummaries(request) {
405
+ const endpoint = endpoints.driverDailySummaries;
406
+ const parseResult = endpoint.requestSchema.safeParse(request);
407
+ if (!parseResult.success) {
408
+ throw new AggregatorClientError(
409
+ `Invalid request: ${parseResult.error.message}`,
410
+ endpoint.path
411
+ );
412
+ }
413
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
414
+ const queryParams = {
415
+ start_date: request.start_date,
416
+ end_date: request.end_date
417
+ };
418
+ const response = await this.makeGetRequest(path, queryParams);
419
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
420
+ if (!responseParseResult.success) {
421
+ throw new AggregatorClientError(
422
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
423
+ endpoint.path,
424
+ void 0,
425
+ response
426
+ );
427
+ }
428
+ return responseParseResult.data;
429
+ }
430
+ /**
431
+ * Gets an enriched trip summary for a single trip.
432
+ */
433
+ async enrichedTripSummary(request) {
434
+ const endpoint = endpoints.enrichedTripSummary;
435
+ const parseResult = endpoint.requestSchema.safeParse(request);
436
+ if (!parseResult.success) {
437
+ throw new AggregatorClientError(
438
+ `Invalid request: ${parseResult.error.message}`,
439
+ endpoint.path
440
+ );
441
+ }
442
+ const path = endpoint.path.replace(":id", String(request.trip_id));
443
+ const response = await this.makeGetRequest(path, {});
444
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
445
+ if (!responseParseResult.success) {
446
+ throw new AggregatorClientError(
447
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
448
+ endpoint.path,
449
+ void 0,
450
+ response
451
+ );
452
+ }
453
+ return responseParseResult.data;
454
+ }
455
+ /**
456
+ * Gets enriched trip summaries for a driver within a date range.
457
+ */
458
+ async driverEnrichedSummaries(request) {
459
+ const endpoint = endpoints.driverEnrichedSummaries;
460
+ const parseResult = endpoint.requestSchema.safeParse(request);
461
+ if (!parseResult.success) {
462
+ throw new AggregatorClientError(
463
+ `Invalid request: ${parseResult.error.message}`,
464
+ endpoint.path
465
+ );
466
+ }
467
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
468
+ const queryParams = {
469
+ start_date: request.start_date,
470
+ end_date: request.end_date
471
+ };
472
+ const response = await this.makeGetRequest(path, queryParams);
473
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
474
+ if (!responseParseResult.success) {
475
+ throw new AggregatorClientError(
476
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
477
+ endpoint.path,
478
+ void 0,
479
+ response
480
+ );
481
+ }
482
+ return responseParseResult.data;
483
+ }
293
484
  async makeRequest(path, method, body) {
294
485
  const url = `${this.baseUrl}${path}`;
295
486
  const response = await fetch(url, {
@@ -361,9 +552,22 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
361
552
  CreateAnonymousDriverBodySchema,
362
553
  DeleteProviderAccountRequestSchema,
363
554
  DeleteProviderAccountResponseSchema,
555
+ DriverDailySummariesResponseSchema,
556
+ DriverDailySummarySchema,
557
+ DriverEnrichedSummariesRequestSchema,
558
+ DriverEnrichedSummariesResponseSchema,
559
+ DriverNameSchema,
364
560
  DriverRankingSchema,
365
561
  DriverRankingsRequestSchema,
366
562
  DriverRankingsResponseSchema,
563
+ DriverTripSchema,
564
+ DriverTripsRequestSchema,
565
+ DriverTripsResponseSchema,
566
+ EnrichedPointSchema,
567
+ EnrichedStopSchema,
568
+ EnrichedTripSummaryRequestSchema,
569
+ EnrichedTripSummaryResponseSchema,
570
+ EnrichedTripSummarySchema,
367
571
  ManualBatchEntrySchema,
368
572
  ManualBatchRequestSchema,
369
573
  ManualBatchResponseSchema,
@@ -372,6 +576,11 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
372
576
  NewLoginResponseFailureSchema,
373
577
  NewLoginResponseSchema,
374
578
  NewLoginResponseSuccessSchema,
579
+ PATCH_DRIVER_NAME_MAX_LENGTH,
580
+ PatchDriverDriverResponseSchema,
581
+ PatchDriverRequestSchema,
582
+ PatchDriverResponseSchema,
583
+ SharedDriverResponseSchema,
375
584
  StateHeatmapEntrySchema,
376
585
  StateHeatmapRequestSchema,
377
586
  StateHeatmapResponseSchema,
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, PatchDriverRequest, PatchDriverResponse, 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, DriverNameSchema, 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, PATCH_DRIVER_NAME_MAX_LENGTH, PatchDriverDriverResponse, PatchDriverDriverResponseSchema, PatchDriverRequest, PatchDriverRequestSchema, PatchDriverResponse, PatchDriverResponseSchema, SharedDriverResponse, SharedDriverResponseSchema, 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,28 @@ 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
+ * Renames a driver by ID.
84
+ */
85
+ patchDriver(request: PatchDriverRequest): Promise<PatchDriverResponse>;
86
+ /**
87
+ * Gets individual trips for a driver within a date range.
88
+ * Computes on-demand if no trips exist yet.
89
+ */
90
+ driverTrips(request: DriverTripsRequest): Promise<DriverTripsResponse>;
91
+ /**
92
+ * Gets daily trip summaries for a driver within a date range.
93
+ * Computes on-demand if no summaries exist yet.
94
+ */
95
+ driverDailySummaries(request: DriverTripsRequest): Promise<DriverDailySummariesResponse>;
96
+ /**
97
+ * Gets an enriched trip summary for a single trip.
98
+ */
99
+ enrichedTripSummary(request: EnrichedTripSummaryRequest): Promise<EnrichedTripSummaryResponse>;
100
+ /**
101
+ * Gets enriched trip summaries for a driver within a date range.
102
+ */
103
+ driverEnrichedSummaries(request: DriverEnrichedSummariesRequest): Promise<DriverEnrichedSummariesResponse>;
82
104
  private makeRequest;
83
105
  private makeGetRequest;
84
106
  }
@@ -158,6 +180,10 @@ declare const endpoints: {
158
180
  start_date: z.ZodString;
159
181
  end_date: z.ZodString;
160
182
  state: z.ZodOptional<z.ZodString>;
183
+ source: z.ZodDefault<z.ZodEnum<{
184
+ eld: "eld";
185
+ manual: "manual";
186
+ }>>;
161
187
  }, z.core.$strip>;
162
188
  readonly responseSchema: z.ZodArray<z.ZodObject<{
163
189
  rank: z.ZodNumber;
@@ -193,6 +219,11 @@ declare const endpoints: {
193
219
  heading: z.ZodOptional<z.ZodNumber>;
194
220
  speed_mph: z.ZodOptional<z.ZodNumber>;
195
221
  altitude_feet: z.ZodOptional<z.ZodNumber>;
222
+ raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
223
+ driving_status: z.ZodOptional<z.ZodEnum<{
224
+ parked: "parked";
225
+ driving: "driving";
226
+ }>>;
196
227
  }, z.core.$strip>>;
197
228
  }, z.core.$strip>;
198
229
  readonly responseSchema: z.ZodObject<{
@@ -212,14 +243,19 @@ declare const endpoints: {
212
243
  previous_location_longitude: z.ZodNullable<z.ZodNumber>;
213
244
  location_address: z.ZodNullable<z.ZodString>;
214
245
  location_state: z.ZodNullable<z.ZodString>;
215
- vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
216
- heading: z.ZodNullable<z.ZodNumber>;
217
- speed_mph: z.ZodNullable<z.ZodNumber>;
218
- altitude_feet: z.ZodNullable<z.ZodNumber>;
246
+ echoed_odometer_miles: z.ZodNullable<z.ZodNumber>;
247
+ osrm_calculated_miles: z.ZodNullable<z.ZodNumber>;
248
+ heading: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
249
+ speed_mph: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
250
+ altitude_feet: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
219
251
  source: z.ZodEnum<{
220
252
  eld: "eld";
221
253
  manual: "manual";
222
254
  }>;
255
+ driving_status: z.ZodNullable<z.ZodEnum<{
256
+ parked: "parked";
257
+ driving: "driving";
258
+ }>>;
223
259
  }, z.core.$strip>>;
224
260
  }, z.core.$strip>;
225
261
  };
@@ -233,6 +269,125 @@ declare const endpoints: {
233
269
  driver_id: z.ZodString;
234
270
  }, z.core.$strip>;
235
271
  };
272
+ readonly driverTrips: {
273
+ readonly path: "/driver/:driver_id/trips";
274
+ readonly method: "GET";
275
+ readonly requestSchema: z.ZodObject<{
276
+ driver_id: z.ZodString;
277
+ start_date: z.ZodString;
278
+ end_date: z.ZodString;
279
+ }, z.core.$strip>;
280
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
281
+ id: z.ZodNumber;
282
+ start_time: z.ZodString;
283
+ end_time: z.ZodString;
284
+ point_count: z.ZodNumber;
285
+ polyline: z.ZodNullable<z.ZodString>;
286
+ highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
287
+ total_miles: z.ZodNullable<z.ZodNumber>;
288
+ avg_speed_mph: z.ZodNullable<z.ZodNumber>;
289
+ miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
290
+ miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
291
+ }, z.core.$strip>>;
292
+ };
293
+ readonly driverDailySummaries: {
294
+ readonly path: "/driver/:driver_id/daily-summaries";
295
+ readonly method: "GET";
296
+ readonly requestSchema: z.ZodObject<{
297
+ driver_id: z.ZodString;
298
+ start_date: z.ZodString;
299
+ end_date: z.ZodString;
300
+ }, z.core.$strip>;
301
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
302
+ summary_date: z.ZodString;
303
+ total_miles: z.ZodNumber;
304
+ trip_count: z.ZodNumber;
305
+ point_count: z.ZodNumber;
306
+ polyline: z.ZodNullable<z.ZodString>;
307
+ highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
308
+ avg_speed_mph: z.ZodNullable<z.ZodNumber>;
309
+ miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
310
+ miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
311
+ }, z.core.$strip>>;
312
+ };
313
+ readonly enrichedTripSummary: {
314
+ readonly path: "/trips/:id/enriched-summary";
315
+ readonly method: "GET";
316
+ readonly requestSchema: z.ZodObject<{
317
+ trip_id: z.ZodNumber;
318
+ }, z.core.$strip>;
319
+ readonly responseSchema: z.ZodObject<{
320
+ trip_id: z.ZodNumber;
321
+ driver_id: z.ZodString;
322
+ start_time: z.ZodString;
323
+ end_time: z.ZodString;
324
+ points: z.ZodArray<z.ZodObject<{
325
+ lat: z.ZodNumber;
326
+ lon: z.ZodNumber;
327
+ timestamp: z.ZodString;
328
+ speed_mph: z.ZodNullable<z.ZodNumber>;
329
+ heading: z.ZodNullable<z.ZodNumber>;
330
+ altitude_feet: z.ZodNullable<z.ZodNumber>;
331
+ weather_condition: z.ZodNullable<z.ZodString>;
332
+ temperature_f: z.ZodNullable<z.ZodNumber>;
333
+ visibility_miles: z.ZodNullable<z.ZodNumber>;
334
+ light_condition: z.ZodNullable<z.ZodString>;
335
+ stop: z.ZodNullable<z.ZodObject<{
336
+ duration_seconds: z.ZodNumber;
337
+ }, z.core.$strip>>;
338
+ }, z.core.$strip>>;
339
+ }, z.core.$strip>;
340
+ };
341
+ readonly driverEnrichedSummaries: {
342
+ readonly path: "/driver/:driver_id/enriched-summary";
343
+ readonly method: "GET";
344
+ readonly requestSchema: z.ZodObject<{
345
+ driver_id: z.ZodString;
346
+ start_date: z.ZodString;
347
+ end_date: z.ZodString;
348
+ }, z.core.$strip>;
349
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
350
+ trip_id: z.ZodNumber;
351
+ driver_id: z.ZodString;
352
+ start_time: z.ZodString;
353
+ end_time: z.ZodString;
354
+ points: z.ZodArray<z.ZodObject<{
355
+ lat: z.ZodNumber;
356
+ lon: z.ZodNumber;
357
+ timestamp: z.ZodString;
358
+ speed_mph: z.ZodNullable<z.ZodNumber>;
359
+ heading: z.ZodNullable<z.ZodNumber>;
360
+ altitude_feet: z.ZodNullable<z.ZodNumber>;
361
+ weather_condition: z.ZodNullable<z.ZodString>;
362
+ temperature_f: z.ZodNullable<z.ZodNumber>;
363
+ visibility_miles: z.ZodNullable<z.ZodNumber>;
364
+ light_condition: z.ZodNullable<z.ZodString>;
365
+ stop: z.ZodNullable<z.ZodObject<{
366
+ duration_seconds: z.ZodNumber;
367
+ }, z.core.$strip>>;
368
+ }, z.core.$strip>>;
369
+ }, z.core.$strip>>;
370
+ };
371
+ readonly patchDriver: {
372
+ readonly path: "/drivers/:id";
373
+ readonly method: "PATCH";
374
+ readonly requestSchema: z.ZodObject<{
375
+ driver_id: z.ZodUUID;
376
+ provider_account_id: z.ZodUUID;
377
+ name: z.ZodString;
378
+ }, z.core.$strip>;
379
+ readonly responseSchema: z.ZodObject<{
380
+ message: z.ZodString;
381
+ driver: z.ZodObject<{
382
+ id: z.ZodUUID;
383
+ created_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
384
+ updated_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
385
+ name: z.ZodString;
386
+ eld_external_id: z.ZodString;
387
+ is_placeholder: z.ZodBoolean;
388
+ }, z.core.$strict>;
389
+ }, z.core.$strip>;
390
+ };
236
391
  };
237
392
  type EndpointName = keyof typeof endpoints;
238
393
 
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, PatchDriverRequest, PatchDriverResponse, 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, DriverNameSchema, 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, PATCH_DRIVER_NAME_MAX_LENGTH, PatchDriverDriverResponse, PatchDriverDriverResponseSchema, PatchDriverRequest, PatchDriverRequestSchema, PatchDriverResponse, PatchDriverResponseSchema, SharedDriverResponse, SharedDriverResponseSchema, 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,28 @@ 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
+ * Renames a driver by ID.
84
+ */
85
+ patchDriver(request: PatchDriverRequest): Promise<PatchDriverResponse>;
86
+ /**
87
+ * Gets individual trips for a driver within a date range.
88
+ * Computes on-demand if no trips exist yet.
89
+ */
90
+ driverTrips(request: DriverTripsRequest): Promise<DriverTripsResponse>;
91
+ /**
92
+ * Gets daily trip summaries for a driver within a date range.
93
+ * Computes on-demand if no summaries exist yet.
94
+ */
95
+ driverDailySummaries(request: DriverTripsRequest): Promise<DriverDailySummariesResponse>;
96
+ /**
97
+ * Gets an enriched trip summary for a single trip.
98
+ */
99
+ enrichedTripSummary(request: EnrichedTripSummaryRequest): Promise<EnrichedTripSummaryResponse>;
100
+ /**
101
+ * Gets enriched trip summaries for a driver within a date range.
102
+ */
103
+ driverEnrichedSummaries(request: DriverEnrichedSummariesRequest): Promise<DriverEnrichedSummariesResponse>;
82
104
  private makeRequest;
83
105
  private makeGetRequest;
84
106
  }
@@ -158,6 +180,10 @@ declare const endpoints: {
158
180
  start_date: z.ZodString;
159
181
  end_date: z.ZodString;
160
182
  state: z.ZodOptional<z.ZodString>;
183
+ source: z.ZodDefault<z.ZodEnum<{
184
+ eld: "eld";
185
+ manual: "manual";
186
+ }>>;
161
187
  }, z.core.$strip>;
162
188
  readonly responseSchema: z.ZodArray<z.ZodObject<{
163
189
  rank: z.ZodNumber;
@@ -193,6 +219,11 @@ declare const endpoints: {
193
219
  heading: z.ZodOptional<z.ZodNumber>;
194
220
  speed_mph: z.ZodOptional<z.ZodNumber>;
195
221
  altitude_feet: z.ZodOptional<z.ZodNumber>;
222
+ raw: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
223
+ driving_status: z.ZodOptional<z.ZodEnum<{
224
+ parked: "parked";
225
+ driving: "driving";
226
+ }>>;
196
227
  }, z.core.$strip>>;
197
228
  }, z.core.$strip>;
198
229
  readonly responseSchema: z.ZodObject<{
@@ -212,14 +243,19 @@ declare const endpoints: {
212
243
  previous_location_longitude: z.ZodNullable<z.ZodNumber>;
213
244
  location_address: z.ZodNullable<z.ZodString>;
214
245
  location_state: z.ZodNullable<z.ZodString>;
215
- vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
216
- heading: z.ZodNullable<z.ZodNumber>;
217
- speed_mph: z.ZodNullable<z.ZodNumber>;
218
- altitude_feet: z.ZodNullable<z.ZodNumber>;
246
+ echoed_odometer_miles: z.ZodNullable<z.ZodNumber>;
247
+ osrm_calculated_miles: z.ZodNullable<z.ZodNumber>;
248
+ heading: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
249
+ speed_mph: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
250
+ altitude_feet: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
219
251
  source: z.ZodEnum<{
220
252
  eld: "eld";
221
253
  manual: "manual";
222
254
  }>;
255
+ driving_status: z.ZodNullable<z.ZodEnum<{
256
+ parked: "parked";
257
+ driving: "driving";
258
+ }>>;
223
259
  }, z.core.$strip>>;
224
260
  }, z.core.$strip>;
225
261
  };
@@ -233,6 +269,125 @@ declare const endpoints: {
233
269
  driver_id: z.ZodString;
234
270
  }, z.core.$strip>;
235
271
  };
272
+ readonly driverTrips: {
273
+ readonly path: "/driver/:driver_id/trips";
274
+ readonly method: "GET";
275
+ readonly requestSchema: z.ZodObject<{
276
+ driver_id: z.ZodString;
277
+ start_date: z.ZodString;
278
+ end_date: z.ZodString;
279
+ }, z.core.$strip>;
280
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
281
+ id: z.ZodNumber;
282
+ start_time: z.ZodString;
283
+ end_time: z.ZodString;
284
+ point_count: z.ZodNumber;
285
+ polyline: z.ZodNullable<z.ZodString>;
286
+ highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
287
+ total_miles: z.ZodNullable<z.ZodNumber>;
288
+ avg_speed_mph: z.ZodNullable<z.ZodNumber>;
289
+ miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
290
+ miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
291
+ }, z.core.$strip>>;
292
+ };
293
+ readonly driverDailySummaries: {
294
+ readonly path: "/driver/:driver_id/daily-summaries";
295
+ readonly method: "GET";
296
+ readonly requestSchema: z.ZodObject<{
297
+ driver_id: z.ZodString;
298
+ start_date: z.ZodString;
299
+ end_date: z.ZodString;
300
+ }, z.core.$strip>;
301
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
302
+ summary_date: z.ZodString;
303
+ total_miles: z.ZodNumber;
304
+ trip_count: z.ZodNumber;
305
+ point_count: z.ZodNumber;
306
+ polyline: z.ZodNullable<z.ZodString>;
307
+ highways: z.ZodNullable<z.ZodArray<z.ZodString>>;
308
+ avg_speed_mph: z.ZodNullable<z.ZodNumber>;
309
+ miles_by_weather: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
310
+ miles_by_light: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNumber>>;
311
+ }, z.core.$strip>>;
312
+ };
313
+ readonly enrichedTripSummary: {
314
+ readonly path: "/trips/:id/enriched-summary";
315
+ readonly method: "GET";
316
+ readonly requestSchema: z.ZodObject<{
317
+ trip_id: z.ZodNumber;
318
+ }, z.core.$strip>;
319
+ readonly responseSchema: z.ZodObject<{
320
+ trip_id: z.ZodNumber;
321
+ driver_id: z.ZodString;
322
+ start_time: z.ZodString;
323
+ end_time: z.ZodString;
324
+ points: z.ZodArray<z.ZodObject<{
325
+ lat: z.ZodNumber;
326
+ lon: z.ZodNumber;
327
+ timestamp: z.ZodString;
328
+ speed_mph: z.ZodNullable<z.ZodNumber>;
329
+ heading: z.ZodNullable<z.ZodNumber>;
330
+ altitude_feet: z.ZodNullable<z.ZodNumber>;
331
+ weather_condition: z.ZodNullable<z.ZodString>;
332
+ temperature_f: z.ZodNullable<z.ZodNumber>;
333
+ visibility_miles: z.ZodNullable<z.ZodNumber>;
334
+ light_condition: z.ZodNullable<z.ZodString>;
335
+ stop: z.ZodNullable<z.ZodObject<{
336
+ duration_seconds: z.ZodNumber;
337
+ }, z.core.$strip>>;
338
+ }, z.core.$strip>>;
339
+ }, z.core.$strip>;
340
+ };
341
+ readonly driverEnrichedSummaries: {
342
+ readonly path: "/driver/:driver_id/enriched-summary";
343
+ readonly method: "GET";
344
+ readonly requestSchema: z.ZodObject<{
345
+ driver_id: z.ZodString;
346
+ start_date: z.ZodString;
347
+ end_date: z.ZodString;
348
+ }, z.core.$strip>;
349
+ readonly responseSchema: z.ZodArray<z.ZodObject<{
350
+ trip_id: z.ZodNumber;
351
+ driver_id: z.ZodString;
352
+ start_time: z.ZodString;
353
+ end_time: z.ZodString;
354
+ points: z.ZodArray<z.ZodObject<{
355
+ lat: z.ZodNumber;
356
+ lon: z.ZodNumber;
357
+ timestamp: z.ZodString;
358
+ speed_mph: z.ZodNullable<z.ZodNumber>;
359
+ heading: z.ZodNullable<z.ZodNumber>;
360
+ altitude_feet: z.ZodNullable<z.ZodNumber>;
361
+ weather_condition: z.ZodNullable<z.ZodString>;
362
+ temperature_f: z.ZodNullable<z.ZodNumber>;
363
+ visibility_miles: z.ZodNullable<z.ZodNumber>;
364
+ light_condition: z.ZodNullable<z.ZodString>;
365
+ stop: z.ZodNullable<z.ZodObject<{
366
+ duration_seconds: z.ZodNumber;
367
+ }, z.core.$strip>>;
368
+ }, z.core.$strip>>;
369
+ }, z.core.$strip>>;
370
+ };
371
+ readonly patchDriver: {
372
+ readonly path: "/drivers/:id";
373
+ readonly method: "PATCH";
374
+ readonly requestSchema: z.ZodObject<{
375
+ driver_id: z.ZodUUID;
376
+ provider_account_id: z.ZodUUID;
377
+ name: z.ZodString;
378
+ }, z.core.$strip>;
379
+ readonly responseSchema: z.ZodObject<{
380
+ message: z.ZodString;
381
+ driver: z.ZodObject<{
382
+ id: z.ZodUUID;
383
+ created_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
384
+ updated_at: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
385
+ name: z.ZodString;
386
+ eld_external_id: z.ZodString;
387
+ is_placeholder: z.ZodBoolean;
388
+ }, z.core.$strict>;
389
+ }, z.core.$strip>;
390
+ };
236
391
  };
237
392
  type EndpointName = keyof typeof endpoints;
238
393
 
package/dist/index.js CHANGED
@@ -13,7 +13,16 @@ 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,
24
+ PatchDriverRequestSchema,
25
+ PatchDriverResponseSchema
17
26
  } from "@findatruck/shared-schemas";
18
27
  var endpoints = {
19
28
  newLogin: {
@@ -57,6 +66,36 @@ var endpoints = {
57
66
  method: "POST",
58
67
  requestSchema: CreateAnonymousDriverBodySchema,
59
68
  responseSchema: AnonymousDriverResponseSchema
69
+ },
70
+ driverTrips: {
71
+ path: "/driver/:driver_id/trips",
72
+ method: "GET",
73
+ requestSchema: DriverTripsRequestSchema,
74
+ responseSchema: DriverTripsResponseSchema
75
+ },
76
+ driverDailySummaries: {
77
+ path: "/driver/:driver_id/daily-summaries",
78
+ method: "GET",
79
+ requestSchema: DriverTripsRequestSchema,
80
+ responseSchema: DriverDailySummariesResponseSchema
81
+ },
82
+ enrichedTripSummary: {
83
+ path: "/trips/:id/enriched-summary",
84
+ method: "GET",
85
+ requestSchema: EnrichedTripSummaryRequestSchema,
86
+ responseSchema: EnrichedTripSummaryResponseSchema
87
+ },
88
+ driverEnrichedSummaries: {
89
+ path: "/driver/:driver_id/enriched-summary",
90
+ method: "GET",
91
+ requestSchema: DriverEnrichedSummariesRequestSchema,
92
+ responseSchema: DriverEnrichedSummariesResponseSchema
93
+ },
94
+ patchDriver: {
95
+ path: "/drivers/:id",
96
+ method: "PATCH",
97
+ requestSchema: PatchDriverRequestSchema,
98
+ responseSchema: PatchDriverResponseSchema
60
99
  }
61
100
  };
62
101
 
@@ -256,6 +295,149 @@ var AggregatorClient = class {
256
295
  }
257
296
  return responseParseResult.data;
258
297
  }
298
+ /**
299
+ * Renames a driver by ID.
300
+ */
301
+ async patchDriver(request) {
302
+ const endpoint = endpoints.patchDriver;
303
+ const parseResult = endpoint.requestSchema.safeParse(request);
304
+ if (!parseResult.success) {
305
+ throw new AggregatorClientError(
306
+ `Invalid request: ${parseResult.error.message}`,
307
+ endpoint.path
308
+ );
309
+ }
310
+ const validated = parseResult.data;
311
+ const path = endpoint.path.replace(":id", validated.driver_id);
312
+ const response = await this.makeRequest(path, endpoint.method, {
313
+ name: validated.name,
314
+ provider_account_id: validated.provider_account_id
315
+ });
316
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
317
+ if (!responseParseResult.success) {
318
+ throw new AggregatorClientError(
319
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
320
+ endpoint.path,
321
+ void 0,
322
+ response
323
+ );
324
+ }
325
+ return responseParseResult.data;
326
+ }
327
+ /**
328
+ * Gets individual trips for a driver within a date range.
329
+ * Computes on-demand if no trips exist yet.
330
+ */
331
+ async driverTrips(request) {
332
+ const endpoint = endpoints.driverTrips;
333
+ const parseResult = endpoint.requestSchema.safeParse(request);
334
+ if (!parseResult.success) {
335
+ throw new AggregatorClientError(
336
+ `Invalid request: ${parseResult.error.message}`,
337
+ endpoint.path
338
+ );
339
+ }
340
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
341
+ const queryParams = {
342
+ start_date: request.start_date,
343
+ end_date: request.end_date
344
+ };
345
+ const response = await this.makeGetRequest(path, queryParams);
346
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
347
+ if (!responseParseResult.success) {
348
+ throw new AggregatorClientError(
349
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
350
+ endpoint.path,
351
+ void 0,
352
+ response
353
+ );
354
+ }
355
+ return responseParseResult.data;
356
+ }
357
+ /**
358
+ * Gets daily trip summaries for a driver within a date range.
359
+ * Computes on-demand if no summaries exist yet.
360
+ */
361
+ async driverDailySummaries(request) {
362
+ const endpoint = endpoints.driverDailySummaries;
363
+ const parseResult = endpoint.requestSchema.safeParse(request);
364
+ if (!parseResult.success) {
365
+ throw new AggregatorClientError(
366
+ `Invalid request: ${parseResult.error.message}`,
367
+ endpoint.path
368
+ );
369
+ }
370
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
371
+ const queryParams = {
372
+ start_date: request.start_date,
373
+ end_date: request.end_date
374
+ };
375
+ const response = await this.makeGetRequest(path, queryParams);
376
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
377
+ if (!responseParseResult.success) {
378
+ throw new AggregatorClientError(
379
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
380
+ endpoint.path,
381
+ void 0,
382
+ response
383
+ );
384
+ }
385
+ return responseParseResult.data;
386
+ }
387
+ /**
388
+ * Gets an enriched trip summary for a single trip.
389
+ */
390
+ async enrichedTripSummary(request) {
391
+ const endpoint = endpoints.enrichedTripSummary;
392
+ const parseResult = endpoint.requestSchema.safeParse(request);
393
+ if (!parseResult.success) {
394
+ throw new AggregatorClientError(
395
+ `Invalid request: ${parseResult.error.message}`,
396
+ endpoint.path
397
+ );
398
+ }
399
+ const path = endpoint.path.replace(":id", String(request.trip_id));
400
+ const response = await this.makeGetRequest(path, {});
401
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
402
+ if (!responseParseResult.success) {
403
+ throw new AggregatorClientError(
404
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
405
+ endpoint.path,
406
+ void 0,
407
+ response
408
+ );
409
+ }
410
+ return responseParseResult.data;
411
+ }
412
+ /**
413
+ * Gets enriched trip summaries for a driver within a date range.
414
+ */
415
+ async driverEnrichedSummaries(request) {
416
+ const endpoint = endpoints.driverEnrichedSummaries;
417
+ const parseResult = endpoint.requestSchema.safeParse(request);
418
+ if (!parseResult.success) {
419
+ throw new AggregatorClientError(
420
+ `Invalid request: ${parseResult.error.message}`,
421
+ endpoint.path
422
+ );
423
+ }
424
+ const path = endpoint.path.replace(":driver_id", request.driver_id);
425
+ const queryParams = {
426
+ start_date: request.start_date,
427
+ end_date: request.end_date
428
+ };
429
+ const response = await this.makeGetRequest(path, queryParams);
430
+ const responseParseResult = endpoint.responseSchema.safeParse(response);
431
+ if (!responseParseResult.success) {
432
+ throw new AggregatorClientError(
433
+ `Invalid response from aggregator: ${responseParseResult.error.message}`,
434
+ endpoint.path,
435
+ void 0,
436
+ response
437
+ );
438
+ }
439
+ return responseParseResult.data;
440
+ }
259
441
  async makeRequest(path, method, body) {
260
442
  const url = `${this.baseUrl}${path}`;
261
443
  const response = await fetch(url, {
@@ -338,7 +520,25 @@ import {
338
520
  ManualBatchTelemetrySchema,
339
521
  CreateAnonymousDriverBodySchema as CreateAnonymousDriverBodySchema2,
340
522
  AnonymousDriverResponseSchema as AnonymousDriverResponseSchema2,
341
- AnonymousDriverErrorResponseSchema
523
+ AnonymousDriverErrorResponseSchema,
524
+ DriverTripsRequestSchema as DriverTripsRequestSchema2,
525
+ DriverTripSchema,
526
+ DriverTripsResponseSchema as DriverTripsResponseSchema2,
527
+ DriverDailySummarySchema,
528
+ DriverDailySummariesResponseSchema as DriverDailySummariesResponseSchema2,
529
+ EnrichedTripSummaryRequestSchema as EnrichedTripSummaryRequestSchema2,
530
+ EnrichedTripSummaryResponseSchema as EnrichedTripSummaryResponseSchema2,
531
+ EnrichedTripSummarySchema,
532
+ EnrichedPointSchema,
533
+ EnrichedStopSchema,
534
+ DriverEnrichedSummariesRequestSchema as DriverEnrichedSummariesRequestSchema2,
535
+ DriverEnrichedSummariesResponseSchema as DriverEnrichedSummariesResponseSchema2,
536
+ PatchDriverRequestSchema as PatchDriverRequestSchema2,
537
+ PatchDriverResponseSchema as PatchDriverResponseSchema2,
538
+ PatchDriverDriverResponseSchema,
539
+ PATCH_DRIVER_NAME_MAX_LENGTH,
540
+ DriverNameSchema,
541
+ SharedDriverResponseSchema
342
542
  } from "@findatruck/shared-schemas";
343
543
  export {
344
544
  AggregatorClient,
@@ -348,9 +548,22 @@ export {
348
548
  CreateAnonymousDriverBodySchema2 as CreateAnonymousDriverBodySchema,
349
549
  DeleteProviderAccountRequestSchema2 as DeleteProviderAccountRequestSchema,
350
550
  DeleteProviderAccountResponseSchema2 as DeleteProviderAccountResponseSchema,
551
+ DriverDailySummariesResponseSchema2 as DriverDailySummariesResponseSchema,
552
+ DriverDailySummarySchema,
553
+ DriverEnrichedSummariesRequestSchema2 as DriverEnrichedSummariesRequestSchema,
554
+ DriverEnrichedSummariesResponseSchema2 as DriverEnrichedSummariesResponseSchema,
555
+ DriverNameSchema,
351
556
  DriverRankingSchema,
352
557
  DriverRankingsRequestSchema2 as DriverRankingsRequestSchema,
353
558
  DriverRankingsResponseSchema2 as DriverRankingsResponseSchema,
559
+ DriverTripSchema,
560
+ DriverTripsRequestSchema2 as DriverTripsRequestSchema,
561
+ DriverTripsResponseSchema2 as DriverTripsResponseSchema,
562
+ EnrichedPointSchema,
563
+ EnrichedStopSchema,
564
+ EnrichedTripSummaryRequestSchema2 as EnrichedTripSummaryRequestSchema,
565
+ EnrichedTripSummaryResponseSchema2 as EnrichedTripSummaryResponseSchema,
566
+ EnrichedTripSummarySchema,
354
567
  ManualBatchEntrySchema,
355
568
  ManualBatchRequestSchema2 as ManualBatchRequestSchema,
356
569
  ManualBatchResponseSchema2 as ManualBatchResponseSchema,
@@ -359,6 +572,11 @@ export {
359
572
  NewLoginResponseFailureSchema,
360
573
  NewLoginResponseSchema2 as NewLoginResponseSchema,
361
574
  NewLoginResponseSuccessSchema,
575
+ PATCH_DRIVER_NAME_MAX_LENGTH,
576
+ PatchDriverDriverResponseSchema,
577
+ PatchDriverRequestSchema2 as PatchDriverRequestSchema,
578
+ PatchDriverResponseSchema2 as PatchDriverResponseSchema,
579
+ SharedDriverResponseSchema,
362
580
  StateHeatmapEntrySchema,
363
581
  StateHeatmapRequestSchema2 as StateHeatmapRequestSchema,
364
582
  StateHeatmapResponseSchema2 as StateHeatmapResponseSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findatruck/aggregator-client",
3
- "version": "1.5.0",
3
+ "version": "1.7.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.15.0"
26
+ "@findatruck/shared-schemas": "^2.18.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "zod": "^4.1.11"