@findatruck/aggregator-client 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +74 -0
- package/dist/index.d.cts +60 -2
- package/dist/index.d.ts +60 -2
- package/dist/index.js +80 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -22,9 +22,15 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AggregatorClient: () => AggregatorClient,
|
|
24
24
|
AggregatorClientError: () => AggregatorClientError,
|
|
25
|
+
DeleteProviderAccountRequestSchema: () => import_shared_schemas2.DeleteProviderAccountRequestSchema,
|
|
26
|
+
DeleteProviderAccountResponseSchema: () => import_shared_schemas2.DeleteProviderAccountResponseSchema,
|
|
25
27
|
DriverRankingSchema: () => import_shared_schemas2.DriverRankingSchema,
|
|
26
28
|
DriverRankingsRequestSchema: () => import_shared_schemas2.DriverRankingsRequestSchema,
|
|
27
29
|
DriverRankingsResponseSchema: () => import_shared_schemas2.DriverRankingsResponseSchema,
|
|
30
|
+
ManualBatchEntrySchema: () => import_shared_schemas2.ManualBatchEntrySchema,
|
|
31
|
+
ManualBatchRequestSchema: () => import_shared_schemas2.ManualBatchRequestSchema,
|
|
32
|
+
ManualBatchResponseSchema: () => import_shared_schemas2.ManualBatchResponseSchema,
|
|
33
|
+
ManualBatchTelemetrySchema: () => import_shared_schemas2.ManualBatchTelemetrySchema,
|
|
28
34
|
NewLoginRequestSchema: () => import_shared_schemas2.NewLoginRequestSchema,
|
|
29
35
|
NewLoginResponseFailureSchema: () => import_shared_schemas2.NewLoginResponseFailureSchema,
|
|
30
36
|
NewLoginResponseSchema: () => import_shared_schemas2.NewLoginResponseSchema,
|
|
@@ -53,6 +59,12 @@ var endpoints = {
|
|
|
53
59
|
requestSchema: import_shared_schemas.ValidatePasswordRequestSchema,
|
|
54
60
|
responseSchema: import_shared_schemas.ValidatePasswordResponseSchema
|
|
55
61
|
},
|
|
62
|
+
deleteProviderAccount: {
|
|
63
|
+
path: "/provider-account/delete",
|
|
64
|
+
method: "POST",
|
|
65
|
+
requestSchema: import_shared_schemas.DeleteProviderAccountRequestSchema,
|
|
66
|
+
responseSchema: import_shared_schemas.DeleteProviderAccountResponseSchema
|
|
67
|
+
},
|
|
56
68
|
driverRankings: {
|
|
57
69
|
path: "/telemetry/driver-rankings",
|
|
58
70
|
method: "GET",
|
|
@@ -64,6 +76,12 @@ var endpoints = {
|
|
|
64
76
|
method: "GET",
|
|
65
77
|
requestSchema: import_shared_schemas.StateHeatmapRequestSchema,
|
|
66
78
|
responseSchema: import_shared_schemas.StateHeatmapResponseSchema
|
|
79
|
+
},
|
|
80
|
+
manualBatch: {
|
|
81
|
+
path: "/telemetry/manual/batch",
|
|
82
|
+
method: "POST",
|
|
83
|
+
requestSchema: import_shared_schemas.ManualBatchRequestSchema,
|
|
84
|
+
responseSchema: import_shared_schemas.ManualBatchResponseSchema
|
|
67
85
|
}
|
|
68
86
|
};
|
|
69
87
|
|
|
@@ -134,6 +152,31 @@ var AggregatorClient = class {
|
|
|
134
152
|
}
|
|
135
153
|
return responseParseResult.data;
|
|
136
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Deletes a provider account by its external ID.
|
|
157
|
+
* Returns success status.
|
|
158
|
+
*/
|
|
159
|
+
async deleteProviderAccount(request) {
|
|
160
|
+
const endpoint = endpoints.deleteProviderAccount;
|
|
161
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
162
|
+
if (!parseResult.success) {
|
|
163
|
+
throw new AggregatorClientError(
|
|
164
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
165
|
+
endpoint.path
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
169
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
170
|
+
if (!responseParseResult.success) {
|
|
171
|
+
throw new AggregatorClientError(
|
|
172
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
173
|
+
endpoint.path,
|
|
174
|
+
void 0,
|
|
175
|
+
response
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return responseParseResult.data;
|
|
179
|
+
}
|
|
137
180
|
/**
|
|
138
181
|
* Gets all drivers ranked by miles driven within a time range.
|
|
139
182
|
* Optionally filter by state.
|
|
@@ -189,6 +232,31 @@ var AggregatorClient = class {
|
|
|
189
232
|
}
|
|
190
233
|
return responseParseResult.data;
|
|
191
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
237
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
238
|
+
*/
|
|
239
|
+
async manualBatch(request) {
|
|
240
|
+
const endpoint = endpoints.manualBatch;
|
|
241
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
242
|
+
if (!parseResult.success) {
|
|
243
|
+
throw new AggregatorClientError(
|
|
244
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
245
|
+
endpoint.path
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
249
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
250
|
+
if (!responseParseResult.success) {
|
|
251
|
+
throw new AggregatorClientError(
|
|
252
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
253
|
+
endpoint.path,
|
|
254
|
+
void 0,
|
|
255
|
+
response
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
return responseParseResult.data;
|
|
259
|
+
}
|
|
192
260
|
async makeRequest(path, method, body) {
|
|
193
261
|
const url = `${this.baseUrl}${path}`;
|
|
194
262
|
const response = await fetch(url, {
|
|
@@ -253,9 +321,15 @@ var import_shared_schemas2 = require("@findatruck/shared-schemas");
|
|
|
253
321
|
0 && (module.exports = {
|
|
254
322
|
AggregatorClient,
|
|
255
323
|
AggregatorClientError,
|
|
324
|
+
DeleteProviderAccountRequestSchema,
|
|
325
|
+
DeleteProviderAccountResponseSchema,
|
|
256
326
|
DriverRankingSchema,
|
|
257
327
|
DriverRankingsRequestSchema,
|
|
258
328
|
DriverRankingsResponseSchema,
|
|
329
|
+
ManualBatchEntrySchema,
|
|
330
|
+
ManualBatchRequestSchema,
|
|
331
|
+
ManualBatchResponseSchema,
|
|
332
|
+
ManualBatchTelemetrySchema,
|
|
259
333
|
NewLoginRequestSchema,
|
|
260
334
|
NewLoginResponseFailureSchema,
|
|
261
335
|
NewLoginResponseSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, ManualBatchEntry, ManualBatchEntrySchema, ManualBatchRequest, ManualBatchRequestSchema, ManualBatchResponse, ManualBatchResponseSchema, ManualBatchTelemetry, ManualBatchTelemetrySchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -55,6 +55,11 @@ declare class AggregatorClient {
|
|
|
55
55
|
* Returns whether the password is valid and the associated driver IDs.
|
|
56
56
|
*/
|
|
57
57
|
validatePassword(request: ValidatePasswordRequest): Promise<ValidatePasswordResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes a provider account by its external ID.
|
|
60
|
+
* Returns success status.
|
|
61
|
+
*/
|
|
62
|
+
deleteProviderAccount(request: DeleteProviderAccountRequest): Promise<DeleteProviderAccountResponse>;
|
|
58
63
|
/**
|
|
59
64
|
* Gets all drivers ranked by miles driven within a time range.
|
|
60
65
|
* Optionally filter by state.
|
|
@@ -65,6 +70,11 @@ declare class AggregatorClient {
|
|
|
65
70
|
* Returns the count and percentage of telemetry points in each state.
|
|
66
71
|
*/
|
|
67
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>;
|
|
68
78
|
private makeRequest;
|
|
69
79
|
private makeGetRequest;
|
|
70
80
|
}
|
|
@@ -127,6 +137,16 @@ declare const endpoints: {
|
|
|
127
137
|
driverIds: z.ZodArray<z.ZodString>;
|
|
128
138
|
}, z.core.$strip>;
|
|
129
139
|
};
|
|
140
|
+
readonly deleteProviderAccount: {
|
|
141
|
+
readonly path: "/provider-account/delete";
|
|
142
|
+
readonly method: "POST";
|
|
143
|
+
readonly requestSchema: z.ZodObject<{
|
|
144
|
+
providerAccountId: z.ZodString;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
readonly responseSchema: z.ZodObject<{
|
|
147
|
+
success: z.ZodBoolean;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
};
|
|
130
150
|
readonly driverRankings: {
|
|
131
151
|
readonly path: "/telemetry/driver-rankings";
|
|
132
152
|
readonly method: "GET";
|
|
@@ -155,6 +175,44 @@ declare const endpoints: {
|
|
|
155
175
|
percentage: z.ZodNumber;
|
|
156
176
|
}, z.core.$strip>>;
|
|
157
177
|
};
|
|
178
|
+
readonly manualBatch: {
|
|
179
|
+
readonly path: "/telemetry/manual/batch";
|
|
180
|
+
readonly method: "POST";
|
|
181
|
+
readonly requestSchema: z.ZodObject<{
|
|
182
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
183
|
+
driver_id: z.ZodString;
|
|
184
|
+
timestamp: z.ZodString;
|
|
185
|
+
location_latitude: z.ZodNumber;
|
|
186
|
+
location_longitude: z.ZodNumber;
|
|
187
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
188
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
readonly responseSchema: z.ZodObject<{
|
|
192
|
+
message: z.ZodString;
|
|
193
|
+
inserted_count: z.ZodNumber;
|
|
194
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
195
|
+
id: z.ZodNumber;
|
|
196
|
+
driver_id: z.ZodString;
|
|
197
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
198
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
199
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
200
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
201
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
202
|
+
location_latitude: z.ZodNumber;
|
|
203
|
+
location_longitude: z.ZodNumber;
|
|
204
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
205
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
206
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
207
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
208
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
source: z.ZodEnum<{
|
|
210
|
+
eld: "eld";
|
|
211
|
+
manual: "manual";
|
|
212
|
+
}>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
};
|
|
158
216
|
};
|
|
159
217
|
type EndpointName = keyof typeof endpoints;
|
|
160
218
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse } from '@findatruck/shared-schemas';
|
|
2
|
-
export { DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
1
|
+
import { NewLoginRequest, NewLoginResponse, ValidatePasswordRequest, ValidatePasswordResponse, DeleteProviderAccountRequest, DeleteProviderAccountResponse, DriverRankingsRequest, DriverRankingsResponse, StateHeatmapRequest, StateHeatmapResponse, ManualBatchRequest, ManualBatchResponse } from '@findatruck/shared-schemas';
|
|
2
|
+
export { DeleteProviderAccountRequest, DeleteProviderAccountRequestSchema, DeleteProviderAccountResponse, DeleteProviderAccountResponseSchema, DriverRanking, DriverRankingSchema, DriverRankingsRequest, DriverRankingsRequestSchema, DriverRankingsResponse, DriverRankingsResponseSchema, ManualBatchEntry, ManualBatchEntrySchema, ManualBatchRequest, ManualBatchRequestSchema, ManualBatchResponse, ManualBatchResponseSchema, ManualBatchTelemetry, ManualBatchTelemetrySchema, NewLoginRequest, NewLoginRequestSchema, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, NewLoginResponseSuccessSchema, StateHeatmapEntry, StateHeatmapEntrySchema, StateHeatmapRequest, StateHeatmapRequestSchema, StateHeatmapResponse, StateHeatmapResponseSchema, ValidatePasswordRequest, ValidatePasswordRequestSchema, ValidatePasswordResponse, ValidatePasswordResponseSchema } from '@findatruck/shared-schemas';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -55,6 +55,11 @@ declare class AggregatorClient {
|
|
|
55
55
|
* Returns whether the password is valid and the associated driver IDs.
|
|
56
56
|
*/
|
|
57
57
|
validatePassword(request: ValidatePasswordRequest): Promise<ValidatePasswordResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Deletes a provider account by its external ID.
|
|
60
|
+
* Returns success status.
|
|
61
|
+
*/
|
|
62
|
+
deleteProviderAccount(request: DeleteProviderAccountRequest): Promise<DeleteProviderAccountResponse>;
|
|
58
63
|
/**
|
|
59
64
|
* Gets all drivers ranked by miles driven within a time range.
|
|
60
65
|
* Optionally filter by state.
|
|
@@ -65,6 +70,11 @@ declare class AggregatorClient {
|
|
|
65
70
|
* Returns the count and percentage of telemetry points in each state.
|
|
66
71
|
*/
|
|
67
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>;
|
|
68
78
|
private makeRequest;
|
|
69
79
|
private makeGetRequest;
|
|
70
80
|
}
|
|
@@ -127,6 +137,16 @@ declare const endpoints: {
|
|
|
127
137
|
driverIds: z.ZodArray<z.ZodString>;
|
|
128
138
|
}, z.core.$strip>;
|
|
129
139
|
};
|
|
140
|
+
readonly deleteProviderAccount: {
|
|
141
|
+
readonly path: "/provider-account/delete";
|
|
142
|
+
readonly method: "POST";
|
|
143
|
+
readonly requestSchema: z.ZodObject<{
|
|
144
|
+
providerAccountId: z.ZodString;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
readonly responseSchema: z.ZodObject<{
|
|
147
|
+
success: z.ZodBoolean;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
};
|
|
130
150
|
readonly driverRankings: {
|
|
131
151
|
readonly path: "/telemetry/driver-rankings";
|
|
132
152
|
readonly method: "GET";
|
|
@@ -155,6 +175,44 @@ declare const endpoints: {
|
|
|
155
175
|
percentage: z.ZodNumber;
|
|
156
176
|
}, z.core.$strip>>;
|
|
157
177
|
};
|
|
178
|
+
readonly manualBatch: {
|
|
179
|
+
readonly path: "/telemetry/manual/batch";
|
|
180
|
+
readonly method: "POST";
|
|
181
|
+
readonly requestSchema: z.ZodObject<{
|
|
182
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
183
|
+
driver_id: z.ZodString;
|
|
184
|
+
timestamp: z.ZodString;
|
|
185
|
+
location_latitude: z.ZodNumber;
|
|
186
|
+
location_longitude: z.ZodNumber;
|
|
187
|
+
location_address: z.ZodOptional<z.ZodString>;
|
|
188
|
+
vehicle_odometer_miles: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
readonly responseSchema: z.ZodObject<{
|
|
192
|
+
message: z.ZodString;
|
|
193
|
+
inserted_count: z.ZodNumber;
|
|
194
|
+
telemetry: z.ZodArray<z.ZodObject<{
|
|
195
|
+
id: z.ZodNumber;
|
|
196
|
+
driver_id: z.ZodString;
|
|
197
|
+
timestamp: z.ZodUnion<readonly [z.ZodString, z.ZodDate]>;
|
|
198
|
+
remaining_drive_time_in_seconds: z.ZodNumber;
|
|
199
|
+
remaining_shift_time_in_seconds: z.ZodNumber;
|
|
200
|
+
remaining_cycle_time_in_seconds: z.ZodNumber;
|
|
201
|
+
remaining_break_time_in_seconds: z.ZodNumber;
|
|
202
|
+
location_latitude: z.ZodNumber;
|
|
203
|
+
location_longitude: z.ZodNumber;
|
|
204
|
+
previous_location_latitude: z.ZodNullable<z.ZodNumber>;
|
|
205
|
+
previous_location_longitude: z.ZodNullable<z.ZodNumber>;
|
|
206
|
+
location_address: z.ZodNullable<z.ZodString>;
|
|
207
|
+
location_state: z.ZodNullable<z.ZodString>;
|
|
208
|
+
vehicle_odometer_miles: z.ZodNullable<z.ZodNumber>;
|
|
209
|
+
source: z.ZodEnum<{
|
|
210
|
+
eld: "eld";
|
|
211
|
+
manual: "manual";
|
|
212
|
+
}>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
};
|
|
158
216
|
};
|
|
159
217
|
type EndpointName = keyof typeof endpoints;
|
|
160
218
|
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,14 @@ import {
|
|
|
4
4
|
NewLoginResponseSchema,
|
|
5
5
|
ValidatePasswordRequestSchema,
|
|
6
6
|
ValidatePasswordResponseSchema,
|
|
7
|
+
DeleteProviderAccountRequestSchema,
|
|
8
|
+
DeleteProviderAccountResponseSchema,
|
|
7
9
|
DriverRankingsRequestSchema,
|
|
8
10
|
DriverRankingsResponseSchema,
|
|
9
11
|
StateHeatmapRequestSchema,
|
|
10
|
-
StateHeatmapResponseSchema
|
|
12
|
+
StateHeatmapResponseSchema,
|
|
13
|
+
ManualBatchRequestSchema,
|
|
14
|
+
ManualBatchResponseSchema
|
|
11
15
|
} from "@findatruck/shared-schemas";
|
|
12
16
|
var endpoints = {
|
|
13
17
|
newLogin: {
|
|
@@ -22,6 +26,12 @@ var endpoints = {
|
|
|
22
26
|
requestSchema: ValidatePasswordRequestSchema,
|
|
23
27
|
responseSchema: ValidatePasswordResponseSchema
|
|
24
28
|
},
|
|
29
|
+
deleteProviderAccount: {
|
|
30
|
+
path: "/provider-account/delete",
|
|
31
|
+
method: "POST",
|
|
32
|
+
requestSchema: DeleteProviderAccountRequestSchema,
|
|
33
|
+
responseSchema: DeleteProviderAccountResponseSchema
|
|
34
|
+
},
|
|
25
35
|
driverRankings: {
|
|
26
36
|
path: "/telemetry/driver-rankings",
|
|
27
37
|
method: "GET",
|
|
@@ -33,6 +43,12 @@ var endpoints = {
|
|
|
33
43
|
method: "GET",
|
|
34
44
|
requestSchema: StateHeatmapRequestSchema,
|
|
35
45
|
responseSchema: StateHeatmapResponseSchema
|
|
46
|
+
},
|
|
47
|
+
manualBatch: {
|
|
48
|
+
path: "/telemetry/manual/batch",
|
|
49
|
+
method: "POST",
|
|
50
|
+
requestSchema: ManualBatchRequestSchema,
|
|
51
|
+
responseSchema: ManualBatchResponseSchema
|
|
36
52
|
}
|
|
37
53
|
};
|
|
38
54
|
|
|
@@ -103,6 +119,31 @@ var AggregatorClient = class {
|
|
|
103
119
|
}
|
|
104
120
|
return responseParseResult.data;
|
|
105
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Deletes a provider account by its external ID.
|
|
124
|
+
* Returns success status.
|
|
125
|
+
*/
|
|
126
|
+
async deleteProviderAccount(request) {
|
|
127
|
+
const endpoint = endpoints.deleteProviderAccount;
|
|
128
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
129
|
+
if (!parseResult.success) {
|
|
130
|
+
throw new AggregatorClientError(
|
|
131
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
132
|
+
endpoint.path
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
136
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
137
|
+
if (!responseParseResult.success) {
|
|
138
|
+
throw new AggregatorClientError(
|
|
139
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
140
|
+
endpoint.path,
|
|
141
|
+
void 0,
|
|
142
|
+
response
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
return responseParseResult.data;
|
|
146
|
+
}
|
|
106
147
|
/**
|
|
107
148
|
* Gets all drivers ranked by miles driven within a time range.
|
|
108
149
|
* Optionally filter by state.
|
|
@@ -158,6 +199,31 @@ var AggregatorClient = class {
|
|
|
158
199
|
}
|
|
159
200
|
return responseParseResult.data;
|
|
160
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Submits a batch of manual GPS telemetry entries.
|
|
204
|
+
* Used for non-ELD sources (external GPS trackers, etc.).
|
|
205
|
+
*/
|
|
206
|
+
async manualBatch(request) {
|
|
207
|
+
const endpoint = endpoints.manualBatch;
|
|
208
|
+
const parseResult = endpoint.requestSchema.safeParse(request);
|
|
209
|
+
if (!parseResult.success) {
|
|
210
|
+
throw new AggregatorClientError(
|
|
211
|
+
`Invalid request: ${parseResult.error.message}`,
|
|
212
|
+
endpoint.path
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
const response = await this.makeRequest(endpoint.path, endpoint.method, request);
|
|
216
|
+
const responseParseResult = endpoint.responseSchema.safeParse(response);
|
|
217
|
+
if (!responseParseResult.success) {
|
|
218
|
+
throw new AggregatorClientError(
|
|
219
|
+
`Invalid response from aggregator: ${responseParseResult.error.message}`,
|
|
220
|
+
endpoint.path,
|
|
221
|
+
void 0,
|
|
222
|
+
response
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return responseParseResult.data;
|
|
226
|
+
}
|
|
161
227
|
async makeRequest(path, method, body) {
|
|
162
228
|
const url = `${this.baseUrl}${path}`;
|
|
163
229
|
const response = await fetch(url, {
|
|
@@ -224,19 +290,31 @@ import {
|
|
|
224
290
|
NewLoginResponseFailureSchema,
|
|
225
291
|
ValidatePasswordRequestSchema as ValidatePasswordRequestSchema2,
|
|
226
292
|
ValidatePasswordResponseSchema as ValidatePasswordResponseSchema2,
|
|
293
|
+
DeleteProviderAccountRequestSchema as DeleteProviderAccountRequestSchema2,
|
|
294
|
+
DeleteProviderAccountResponseSchema as DeleteProviderAccountResponseSchema2,
|
|
227
295
|
DriverRankingsRequestSchema as DriverRankingsRequestSchema2,
|
|
228
296
|
DriverRankingsResponseSchema as DriverRankingsResponseSchema2,
|
|
229
297
|
DriverRankingSchema,
|
|
230
298
|
StateHeatmapRequestSchema as StateHeatmapRequestSchema2,
|
|
231
299
|
StateHeatmapResponseSchema as StateHeatmapResponseSchema2,
|
|
232
|
-
StateHeatmapEntrySchema
|
|
300
|
+
StateHeatmapEntrySchema,
|
|
301
|
+
ManualBatchRequestSchema as ManualBatchRequestSchema2,
|
|
302
|
+
ManualBatchResponseSchema as ManualBatchResponseSchema2,
|
|
303
|
+
ManualBatchEntrySchema,
|
|
304
|
+
ManualBatchTelemetrySchema
|
|
233
305
|
} from "@findatruck/shared-schemas";
|
|
234
306
|
export {
|
|
235
307
|
AggregatorClient,
|
|
236
308
|
AggregatorClientError,
|
|
309
|
+
DeleteProviderAccountRequestSchema2 as DeleteProviderAccountRequestSchema,
|
|
310
|
+
DeleteProviderAccountResponseSchema2 as DeleteProviderAccountResponseSchema,
|
|
237
311
|
DriverRankingSchema,
|
|
238
312
|
DriverRankingsRequestSchema2 as DriverRankingsRequestSchema,
|
|
239
313
|
DriverRankingsResponseSchema2 as DriverRankingsResponseSchema,
|
|
314
|
+
ManualBatchEntrySchema,
|
|
315
|
+
ManualBatchRequestSchema2 as ManualBatchRequestSchema,
|
|
316
|
+
ManualBatchResponseSchema2 as ManualBatchResponseSchema,
|
|
317
|
+
ManualBatchTelemetrySchema,
|
|
240
318
|
NewLoginRequestSchema2 as NewLoginRequestSchema,
|
|
241
319
|
NewLoginResponseFailureSchema,
|
|
242
320
|
NewLoginResponseSchema2 as NewLoginResponseSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@findatruck/aggregator-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test:watch": "vitest"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@findatruck/shared-schemas": "^2.
|
|
26
|
+
"@findatruck/shared-schemas": "^2.12.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"zod": "^4.1.11"
|