@findatruck/aggregator-client 1.2.0 → 1.4.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 +75 -0
- package/dist/index.d.cts +59 -2
- package/dist/index.d.ts +59 -2
- package/dist/index.js +81 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -22,11 +22,18 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AggregatorClient: () => AggregatorClient,
|
|
24
24
|
AggregatorClientError: () => AggregatorClientError,
|
|
25
|
+
AnonymousDriverErrorResponseSchema: () => import_shared_schemas2.AnonymousDriverErrorResponseSchema,
|
|
26
|
+
AnonymousDriverResponseSchema: () => import_shared_schemas2.AnonymousDriverResponseSchema,
|
|
27
|
+
CreateAnonymousDriverBodySchema: () => import_shared_schemas2.CreateAnonymousDriverBodySchema,
|
|
25
28
|
DeleteProviderAccountRequestSchema: () => import_shared_schemas2.DeleteProviderAccountRequestSchema,
|
|
26
29
|
DeleteProviderAccountResponseSchema: () => import_shared_schemas2.DeleteProviderAccountResponseSchema,
|
|
27
30
|
DriverRankingSchema: () => import_shared_schemas2.DriverRankingSchema,
|
|
28
31
|
DriverRankingsRequestSchema: () => import_shared_schemas2.DriverRankingsRequestSchema,
|
|
29
32
|
DriverRankingsResponseSchema: () => import_shared_schemas2.DriverRankingsResponseSchema,
|
|
33
|
+
ManualBatchEntrySchema: () => import_shared_schemas2.ManualBatchEntrySchema,
|
|
34
|
+
ManualBatchRequestSchema: () => import_shared_schemas2.ManualBatchRequestSchema,
|
|
35
|
+
ManualBatchResponseSchema: () => import_shared_schemas2.ManualBatchResponseSchema,
|
|
36
|
+
ManualBatchTelemetrySchema: () => import_shared_schemas2.ManualBatchTelemetrySchema,
|
|
30
37
|
NewLoginRequestSchema: () => import_shared_schemas2.NewLoginRequestSchema,
|
|
31
38
|
NewLoginResponseFailureSchema: () => import_shared_schemas2.NewLoginResponseFailureSchema,
|
|
32
39
|
NewLoginResponseSchema: () => import_shared_schemas2.NewLoginResponseSchema,
|
|
@@ -72,6 +79,18 @@ var endpoints = {
|
|
|
72
79
|
method: "GET",
|
|
73
80
|
requestSchema: import_shared_schemas.StateHeatmapRequestSchema,
|
|
74
81
|
responseSchema: import_shared_schemas.StateHeatmapResponseSchema
|
|
82
|
+
},
|
|
83
|
+
manualBatch: {
|
|
84
|
+
path: "/telemetry/manual/batch",
|
|
85
|
+
method: "POST",
|
|
86
|
+
requestSchema: import_shared_schemas.ManualBatchRequestSchema,
|
|
87
|
+
responseSchema: import_shared_schemas.ManualBatchResponseSchema
|
|
88
|
+
},
|
|
89
|
+
anonymousDriver: {
|
|
90
|
+
path: "/anonymous-driver",
|
|
91
|
+
method: "POST",
|
|
92
|
+
requestSchema: import_shared_schemas.CreateAnonymousDriverBodySchema,
|
|
93
|
+
responseSchema: import_shared_schemas.AnonymousDriverResponseSchema
|
|
75
94
|
}
|
|
76
95
|
};
|
|
77
96
|
|
|
@@ -222,6 +241,55 @@ var AggregatorClient = class {
|
|
|
222
241
|
}
|
|
223
242
|
return responseParseResult.data;
|
|
224
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
246
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
247
|
+
*/
|
|
248
|
+
async manualBatch(request) {
|
|
249
|
+
const endpoint = endpoints.manualBatch;
|
|
250
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
251
|
+
if (!parseResult.success) {
|
|
252
|
+
throw new AggregatorClientError(
|
|
253
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
254
|
+
endpoint.path
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
258
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
259
|
+
if (!responseParseResult.success) {
|
|
260
|
+
throw new AggregatorClientError(
|
|
261
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
262
|
+
endpoint.path,
|
|
263
|
+
void 0,
|
|
264
|
+
response
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
return responseParseResult.data;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
271
|
+
*/
|
|
272
|
+
async anonymousDriver(request) {
|
|
273
|
+
const endpoint = endpoints.anonymousDriver;
|
|
274
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
275
|
+
if (!parseResult.success) {
|
|
276
|
+
throw new AggregatorClientError(
|
|
277
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
278
|
+
endpoint.path
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
282
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
283
|
+
if (!responseParseResult.success) {
|
|
284
|
+
throw new AggregatorClientError(
|
|
285
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
286
|
+
endpoint.path,
|
|
287
|
+
void 0,
|
|
288
|
+
response
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
return responseParseResult.data;
|
|
292
|
+
}
|
|
225
293
|
async makeRequest(path, method, body) {
|
|
226
294
|
const url = `${this.baseUrl}${path}`;
|
|
227
295
|
const response = await fetch(url, {
|
|
@@ -286,11 +354,18 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
|
|
|
286
354
|
0 && (module.exports = {
|
|
287
355
|
AggregatorClient,
|
|
288
356
|
AggregatorClientError,
|
|
357
|
+
AnonymousDriverErrorResponseSchema,
|
|
358
|
+
AnonymousDriverResponseSchema,
|
|
359
|
+
CreateAnonymousDriverBodySchema,
|
|
289
360
|
DeleteProviderAccountRequestSchema,
|
|
290
361
|
DeleteProviderAccountResponseSchema,
|
|
291
362
|
DriverRankingSchema,
|
|
292
363
|
DriverRankingsRequestSchema,
|
|
293
364
|
DriverRankingsResponseSchema,
|
|
365
|
+
ManualBatchEntrySchema,
|
|
366
|
+
ManualBatchRequestSchema,
|
|
367
|
+
ManualBatchResponseSchema,
|
|
368
|
+
ManualBatchTelemetrySchema,
|
|
294
369
|
NewLoginRequestSchema,
|
|
295
370
|
NewLoginResponseFailureSchema,
|
|
296
371
|
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, 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';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -70,6 +70,15 @@ 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>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
80
|
+
*/
|
|
81
|
+
anonymousDriver(request: CreateAnonymousDriverBody): Promise<AnonymousDriverResponse>;
|
|
73
82
|
private makeRequest;
|
|
74
83
|
private makeGetRequest;
|
|
75
84
|
}
|
|
@@ -170,6 +179,54 @@ declare const endpoints: {
|
|
|
170
179
|
percentage: z.ZodNumber;
|
|
171
180
|
}, z.core.$strip>>;
|
|
172
181
|
};
|
|
182
|
+
readonly manualBatch: {
|
|
183
|
+
readonly path: "/telemetry/manual/batch";
|
|
184
|
+
readonly method: "POST";
|
|
185
|
+
readonly requestSchema: z.ZodObject<{
|
|
186
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
187
|
+
driver_id: z.ZodString;
|
|
188
|
+
timestamp: z.ZodString;
|
|
189
|
+
location_latitude: z.ZodNumber;
|
|
190
|
+
location_longitude: z.ZodNumber;
|
|
191
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
192
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
readonly responseSchema: z.ZodObject<{
|
|
196
|
+
message: z.ZodString;
|
|
197
|
+
inserted_count: z.ZodNumber;
|
|
198
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
199
|
+
id: z.ZodNumber;
|
|
200
|
+
driver_id: z.ZodString;
|
|
201
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
202
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
203
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
204
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
205
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
206
|
+
location_latitude: z.ZodNumber;
|
|
207
|
+
location_longitude: z.ZodNumber;
|
|
208
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
210
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
211
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
212
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
213
|
+
source: z.ZodEnum<{
|
|
214
|
+
eld: "eld";
|
|
215
|
+
manual: "manual";
|
|
216
|
+
}>;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
};
|
|
220
|
+
readonly anonymousDriver: {
|
|
221
|
+
readonly path: "/anonymous-driver";
|
|
222
|
+
readonly method: "POST";
|
|
223
|
+
readonly requestSchema: z.ZodObject<{
|
|
224
|
+
convex_user_id: z.ZodString;
|
|
225
|
+
}, z.core.$strip>;
|
|
226
|
+
readonly responseSchema: z.ZodObject<{
|
|
227
|
+
driver_id: z.ZodString;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
};
|
|
173
230
|
};
|
|
174
231
|
type EndpointName = keyof typeof endpoints;
|
|
175
232
|
|
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, 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';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -70,6 +70,15 @@ 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>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
80
|
+
*/
|
|
81
|
+
anonymousDriver(request: CreateAnonymousDriverBody): Promise<AnonymousDriverResponse>;
|
|
73
82
|
private makeRequest;
|
|
74
83
|
private makeGetRequest;
|
|
75
84
|
}
|
|
@@ -170,6 +179,54 @@ declare const endpoints: {
|
|
|
170
179
|
percentage: z.ZodNumber;
|
|
171
180
|
}, z.core.$strip>>;
|
|
172
181
|
};
|
|
182
|
+
readonly manualBatch: {
|
|
183
|
+
readonly path: "/telemetry/manual/batch";
|
|
184
|
+
readonly method: "POST";
|
|
185
|
+
readonly requestSchema: z.ZodObject<{
|
|
186
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
187
|
+
driver_id: z.ZodString;
|
|
188
|
+
timestamp: z.ZodString;
|
|
189
|
+
location_latitude: z.ZodNumber;
|
|
190
|
+
location_longitude: z.ZodNumber;
|
|
191
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
192
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
readonly responseSchema: z.ZodObject<{
|
|
196
|
+
message: z.ZodString;
|
|
197
|
+
inserted_count: z.ZodNumber;
|
|
198
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
199
|
+
id: z.ZodNumber;
|
|
200
|
+
driver_id: z.ZodString;
|
|
201
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
202
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
203
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
204
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
205
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
206
|
+
location_latitude: z.ZodNumber;
|
|
207
|
+
location_longitude: z.ZodNumber;
|
|
208
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
210
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
211
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
212
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
213
|
+
source: z.ZodEnum<{
|
|
214
|
+
eld: "eld";
|
|
215
|
+
manual: "manual";
|
|
216
|
+
}>;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
};
|
|
220
|
+
readonly anonymousDriver: {
|
|
221
|
+
readonly path: "/anonymous-driver";
|
|
222
|
+
readonly method: "POST";
|
|
223
|
+
readonly requestSchema: z.ZodObject<{
|
|
224
|
+
convex_user_id: z.ZodString;
|
|
225
|
+
}, z.core.$strip>;
|
|
226
|
+
readonly responseSchema: z.ZodObject<{
|
|
227
|
+
driver_id: z.ZodString;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
};
|
|
173
230
|
};
|
|
174
231
|
type EndpointName = keyof typeof endpoints;
|
|
175
232
|
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,11 @@ import {
|
|
|
9
9
|
DriverRankingsRequestSchema,
|
|
10
10
|
DriverRankingsResponseSchema,
|
|
11
11
|
StateHeatmapRequestSchema,
|
|
12
|
-
StateHeatmapResponseSchema
|
|
12
|
+
StateHeatmapResponseSchema,
|
|
13
|
+
ManualBatchRequestSchema,
|
|
14
|
+
ManualBatchResponseSchema,
|
|
15
|
+
CreateAnonymousDriverBodySchema,
|
|
16
|
+
AnonymousDriverResponseSchema
|
|
13
17
|
} from "@findatruck/shared-schemas";
|
|
14
18
|
var endpoints = {
|
|
15
19
|
newLogin: {
|
|
@@ -41,6 +45,18 @@ var endpoints = {
|
|
|
41
45
|
method: "GET",
|
|
42
46
|
requestSchema: StateHeatmapRequestSchema,
|
|
43
47
|
responseSchema: StateHeatmapResponseSchema
|
|
48
|
+
},
|
|
49
|
+
manualBatch: {
|
|
50
|
+
path: "/telemetry/manual/batch",
|
|
51
|
+
method: "POST",
|
|
52
|
+
requestSchema: ManualBatchRequestSchema,
|
|
53
|
+
responseSchema: ManualBatchResponseSchema
|
|
54
|
+
},
|
|
55
|
+
anonymousDriver: {
|
|
56
|
+
path: "/anonymous-driver",
|
|
57
|
+
method: "POST",
|
|
58
|
+
requestSchema: CreateAnonymousDriverBodySchema,
|
|
59
|
+
responseSchema: AnonymousDriverResponseSchema
|
|
44
60
|
}
|
|
45
61
|
};
|
|
46
62
|
|
|
@@ -191,6 +207,55 @@ var AggregatorClient = class {
|
|
|
191
207
|
}
|
|
192
208
|
return responseParseResult.data;
|
|
193
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
212
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
213
|
+
*/
|
|
214
|
+
async manualBatch(request) {
|
|
215
|
+
const endpoint = endpoints.manualBatch;
|
|
216
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
217
|
+
if (!parseResult.success) {
|
|
218
|
+
throw new AggregatorClientError(
|
|
219
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
220
|
+
endpoint.path
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
224
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
225
|
+
if (!responseParseResult.success) {
|
|
226
|
+
throw new AggregatorClientError(
|
|
227
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
228
|
+
endpoint.path,
|
|
229
|
+
void 0,
|
|
230
|
+
response
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
return responseParseResult.data;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Creates an anonymous driver for GPS-only users without ELD login.
|
|
237
|
+
*/
|
|
238
|
+
async anonymousDriver(request) {
|
|
239
|
+
const endpoint = endpoints.anonymousDriver;
|
|
240
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
241
|
+
if (!parseResult.success) {
|
|
242
|
+
throw new AggregatorClientError(
|
|
243
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
244
|
+
endpoint.path
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
248
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
249
|
+
if (!responseParseResult.success) {
|
|
250
|
+
throw new AggregatorClientError(
|
|
251
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
252
|
+
endpoint.path,
|
|
253
|
+
void 0,
|
|
254
|
+
response
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
return responseParseResult.data;
|
|
258
|
+
}
|
|
194
259
|
async makeRequest(path, method, body) {
|
|
195
260
|
const url = `${this.baseUrl}${path}`;
|
|
196
261
|
const response = await fetch(url, {
|
|
@@ -264,16 +329,30 @@ import {
|
|
|
264
329
|
DriverRankingSchema,
|
|
265
330
|
StateHeatmapRequestSchema as StateHeatmapRequestSchema2,
|
|
266
331
|
StateHeatmapResponseSchema as StateHeatmapResponseSchema2,
|
|
267
|
-
StateHeatmapEntrySchema
|
|
332
|
+
StateHeatmapEntrySchema,
|
|
333
|
+
ManualBatchRequestSchema as ManualBatchRequestSchema2,
|
|
334
|
+
ManualBatchResponseSchema as ManualBatchResponseSchema2,
|
|
335
|
+
ManualBatchEntrySchema,
|
|
336
|
+
ManualBatchTelemetrySchema,
|
|
337
|
+
CreateAnonymousDriverBodySchema as CreateAnonymousDriverBodySchema2,
|
|
338
|
+
AnonymousDriverResponseSchema as AnonymousDriverResponseSchema2,
|
|
339
|
+
AnonymousDriverErrorResponseSchema
|
|
268
340
|
} from "@findatruck/shared-schemas";
|
|
269
341
|
export {
|
|
270
342
|
AggregatorClient,
|
|
271
343
|
AggregatorClientError,
|
|
344
|
+
AnonymousDriverErrorResponseSchema,
|
|
345
|
+
AnonymousDriverResponseSchema2 as AnonymousDriverResponseSchema,
|
|
346
|
+
CreateAnonymousDriverBodySchema2 as CreateAnonymousDriverBodySchema,
|
|
272
347
|
DeleteProviderAccountRequestSchema2 as DeleteProviderAccountRequestSchema,
|
|
273
348
|
DeleteProviderAccountResponseSchema2 as DeleteProviderAccountResponseSchema,
|
|
274
349
|
DriverRankingSchema,
|
|
275
350
|
DriverRankingsRequestSchema2 as DriverRankingsRequestSchema,
|
|
276
351
|
DriverRankingsResponseSchema2 as DriverRankingsResponseSchema,
|
|
352
|
+
ManualBatchEntrySchema,
|
|
353
|
+
ManualBatchRequestSchema2 as ManualBatchRequestSchema,
|
|
354
|
+
ManualBatchResponseSchema2 as ManualBatchResponseSchema,
|
|
355
|
+
ManualBatchTelemetrySchema,
|
|
277
356
|
NewLoginRequestSchema2 as NewLoginRequestSchema,
|
|
278
357
|
NewLoginResponseFailureSchema,
|
|
279
358
|
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.4.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.14.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"zod": "^4.1.11"
|