@findatruck/shared-schemas 2.17.0 → 2.19.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/browser.cjs +115 -16
- package/dist/browser.d.cts +87 -1
- package/dist/browser.d.ts +87 -1
- package/dist/browser.js +19 -1
- package/dist/{chunk-S53TIE72.js → chunk-P4S46OZI.js} +106 -16
- package/dist/index.cjs +291 -190
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +23 -3
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(browser_exports, {
|
|
|
35
35
|
ConvexDriverSchema: () => ConvexDriverSchema,
|
|
36
36
|
ConvexUpdate: () => ConvexUpdate,
|
|
37
37
|
ConvexUpdateSchema: () => ConvexUpdateSchema,
|
|
38
|
+
DRIVER_NAME_FORBIDDEN_CHAR_PATTERN: () => DRIVER_NAME_FORBIDDEN_CHAR_PATTERN,
|
|
39
|
+
DriverNameSchema: () => DriverNameSchema,
|
|
38
40
|
NewLoginRequest: () => NewLoginRequest,
|
|
39
41
|
NewLoginRequestSchema: () => NewLoginRequestSchema,
|
|
40
42
|
NewLoginResponse: () => NewLoginResponse,
|
|
@@ -43,7 +45,14 @@ __export(browser_exports, {
|
|
|
43
45
|
NewLoginResponseSchema: () => NewLoginResponseSchema,
|
|
44
46
|
NewLoginResponseSuccess: () => NewLoginResponseSuccess,
|
|
45
47
|
NewLoginResponseSuccessSchema: () => NewLoginResponseSuccessSchema,
|
|
48
|
+
PATCH_DRIVER_NAME_MAX_LENGTH: () => PATCH_DRIVER_NAME_MAX_LENGTH,
|
|
49
|
+
PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH: () => PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH,
|
|
50
|
+
PatchDriverDriverResponseSchema: () => PatchDriverDriverResponseSchema,
|
|
51
|
+
PatchDriverRequestSchema: () => PatchDriverRequestSchema,
|
|
52
|
+
PatchDriverResponseSchema: () => PatchDriverResponseSchema,
|
|
46
53
|
ScrapeStatus: () => ScrapeStatus,
|
|
54
|
+
SharedDriverResponseSchema: () => SharedDriverResponseSchema,
|
|
55
|
+
TruckTypeSchema: () => TruckTypeSchema,
|
|
47
56
|
UpdateScrapeStatusMessage: () => UpdateScrapeStatusMessage,
|
|
48
57
|
ValidatePasswordRequestSchema: () => ValidatePasswordRequestSchema,
|
|
49
58
|
ValidatePasswordResponseSchema: () => ValidatePasswordResponseSchema
|
|
@@ -145,8 +154,89 @@ var BatchConvexUpdateSchema = import_zod2.default.object({
|
|
|
145
154
|
var ConvexUpdate = ConvexUpdateSchema;
|
|
146
155
|
var BatchConvexUpdate = BatchConvexUpdateSchema;
|
|
147
156
|
|
|
148
|
-
// src/schemas/
|
|
157
|
+
// src/schemas/drivers/driver.ts
|
|
149
158
|
var import_zod3 = __toESM(require("zod"), 1);
|
|
159
|
+
var SharedDriverResponseSchema = import_zod3.default.object({
|
|
160
|
+
// The `drivers.id` column is a Postgres UUID (migration 0001), and every
|
|
161
|
+
// input-side schema (`IdParamsSchema`, `PatchDriverRequestSchema.driver_id`)
|
|
162
|
+
// is already `z.uuid()`. Tightening the response side keeps the contract
|
|
163
|
+
// symmetric — a client that statically relies on `id` being UUID-shaped on
|
|
164
|
+
// input can rely on the same on output. `eld_external_id` stays loose
|
|
165
|
+
// because providers emit non-UUID identifiers there.
|
|
166
|
+
id: import_zod3.default.uuid(),
|
|
167
|
+
name: import_zod3.default.string(),
|
|
168
|
+
eld_external_id: import_zod3.default.string(),
|
|
169
|
+
license_number: import_zod3.default.string().nullable(),
|
|
170
|
+
license_state: import_zod3.default.string().nullable(),
|
|
171
|
+
license_expiration_date: import_zod3.default.string().nullable(),
|
|
172
|
+
license_class: import_zod3.default.string().nullable(),
|
|
173
|
+
is_placeholder: import_zod3.default.boolean(),
|
|
174
|
+
created_at: import_zod3.default.union([import_zod3.default.string(), import_zod3.default.date()]),
|
|
175
|
+
updated_at: import_zod3.default.union([import_zod3.default.string(), import_zod3.default.date()]),
|
|
176
|
+
truck_type: import_zod3.default.string().nullable(),
|
|
177
|
+
last_location_latitude: import_zod3.default.number().nullable(),
|
|
178
|
+
last_location_longitude: import_zod3.default.number().nullable()
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// src/schemas/drivers/patch-driver.ts
|
|
182
|
+
var import_zod4 = __toESM(require("zod"), 1);
|
|
183
|
+
var PATCH_DRIVER_NAME_MAX_LENGTH = 255;
|
|
184
|
+
var PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH = 100;
|
|
185
|
+
var DRIVER_NAME_FORBIDDEN_RANGES = [
|
|
186
|
+
[0, 31],
|
|
187
|
+
// C0 controls (includes NUL, CR, LF, TAB)
|
|
188
|
+
[127, 159],
|
|
189
|
+
// DEL + C1 controls
|
|
190
|
+
[8203, 8205],
|
|
191
|
+
// ZWSP, ZWNJ, ZWJ
|
|
192
|
+
[65279, 65279],
|
|
193
|
+
// BOM / ZWNBSP
|
|
194
|
+
[8234, 8238],
|
|
195
|
+
// bidi overrides
|
|
196
|
+
[8294, 8297]
|
|
197
|
+
// bidi isolates
|
|
198
|
+
];
|
|
199
|
+
var buildForbiddenCharPattern = () => {
|
|
200
|
+
const cls = DRIVER_NAME_FORBIDDEN_RANGES.map(([lo, hi]) => {
|
|
201
|
+
const loEsc = "\\u" + lo.toString(16).padStart(4, "0");
|
|
202
|
+
if (lo === hi) return loEsc;
|
|
203
|
+
const hiEsc = "\\u" + hi.toString(16).padStart(4, "0");
|
|
204
|
+
return `${loEsc}-${hiEsc}`;
|
|
205
|
+
}).join("");
|
|
206
|
+
return new RegExp(`[${cls}]`);
|
|
207
|
+
};
|
|
208
|
+
var DRIVER_NAME_FORBIDDEN_CHAR_PATTERN = buildForbiddenCharPattern();
|
|
209
|
+
var DriverNameSchema = import_zod4.default.string().trim().min(1).max(PATCH_DRIVER_NAME_MAX_LENGTH).refine(
|
|
210
|
+
(s) => !DRIVER_NAME_FORBIDDEN_CHAR_PATTERN.test(s),
|
|
211
|
+
{
|
|
212
|
+
message: "name contains disallowed control, zero-width, or bidirectional-override characters"
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
var TruckTypeSchema = import_zod4.default.string().trim().min(1).max(PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH);
|
|
216
|
+
var PatchDriverRequestSchema = import_zod4.default.object({
|
|
217
|
+
driver_id: import_zod4.default.uuid(),
|
|
218
|
+
name: DriverNameSchema.optional(),
|
|
219
|
+
truck_type: TruckTypeSchema.nullable().optional()
|
|
220
|
+
}).refine(
|
|
221
|
+
(d) => d.name !== void 0 || d.truck_type !== void 0,
|
|
222
|
+
{ message: "At least one of name or truck_type must be provided" }
|
|
223
|
+
);
|
|
224
|
+
var PatchDriverDriverResponseSchema = SharedDriverResponseSchema.pick({
|
|
225
|
+
id: true,
|
|
226
|
+
name: true,
|
|
227
|
+
eld_external_id: true,
|
|
228
|
+
is_placeholder: true,
|
|
229
|
+
truck_type: true,
|
|
230
|
+
created_at: true,
|
|
231
|
+
updated_at: true
|
|
232
|
+
}).strict();
|
|
233
|
+
var PatchDriverResponseSchema = import_zod4.default.object({
|
|
234
|
+
message: import_zod4.default.string(),
|
|
235
|
+
driver: PatchDriverDriverResponseSchema
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// src/schemas/providerAccounts/update-status.ts
|
|
239
|
+
var import_zod5 = __toESM(require("zod"), 1);
|
|
150
240
|
var ScrapeStatus = /* @__PURE__ */ ((ScrapeStatus2) => {
|
|
151
241
|
ScrapeStatus2["NEW_LOGIN_RECEIVED"] = "NEW_LOGIN_RECEIVED";
|
|
152
242
|
ScrapeStatus2["LOGIN_IN_PROGRESS"] = "LOGIN_IN_PROGRESS";
|
|
@@ -159,25 +249,25 @@ var ScrapeStatus = /* @__PURE__ */ ((ScrapeStatus2) => {
|
|
|
159
249
|
ScrapeStatus2["DATA_FETCH_FAILED"] = "DATA_FETCH_FAILED";
|
|
160
250
|
return ScrapeStatus2;
|
|
161
251
|
})(ScrapeStatus || {});
|
|
162
|
-
var UpdateScrapeStatusMessage =
|
|
163
|
-
status:
|
|
164
|
-
correctPassword:
|
|
165
|
-
externalProviderAccountId:
|
|
166
|
-
username:
|
|
167
|
-
provider_url:
|
|
168
|
-
driverCount:
|
|
169
|
-
providerSlug:
|
|
252
|
+
var UpdateScrapeStatusMessage = import_zod5.default.object({
|
|
253
|
+
status: import_zod5.default.nativeEnum(ScrapeStatus).describe("The current status of the scrape process"),
|
|
254
|
+
correctPassword: import_zod5.default.boolean().optional().describe("Indicates if the provided password was correct, if applicable"),
|
|
255
|
+
externalProviderAccountId: import_zod5.default.string().describe("The external identifier for the provider account (convex ID or similar)"),
|
|
256
|
+
username: import_zod5.default.string().describe("The username of the provider account whose status is being updated"),
|
|
257
|
+
provider_url: import_zod5.default.string().describe("The URL of the ELD provider"),
|
|
258
|
+
driverCount: import_zod5.default.number().optional().describe("The number of drivers associated with the account, if applicable"),
|
|
259
|
+
providerSlug: import_zod5.default.string().optional().describe("The slug identifier for the provider")
|
|
170
260
|
}).describe("Schema for update status messages");
|
|
171
261
|
|
|
172
262
|
// src/schemas/providerAccounts/validate-password.ts
|
|
173
|
-
var
|
|
174
|
-
var ValidatePasswordRequestSchema =
|
|
175
|
-
providerAccountId:
|
|
176
|
-
encryptedPassword:
|
|
263
|
+
var import_zod6 = require("zod");
|
|
264
|
+
var ValidatePasswordRequestSchema = import_zod6.z.object({
|
|
265
|
+
providerAccountId: import_zod6.z.string().min(1).describe("The unique identifier of the provider account in postgres to validate the password for"),
|
|
266
|
+
encryptedPassword: import_zod6.z.string().min(1).describe("The encrypted password to validate against the stored password")
|
|
177
267
|
}).describe("Request schema for validating a provider account password");
|
|
178
|
-
var ValidatePasswordResponseSchema =
|
|
179
|
-
isValid:
|
|
180
|
-
driverIds:
|
|
268
|
+
var ValidatePasswordResponseSchema = import_zod6.z.object({
|
|
269
|
+
isValid: import_zod6.z.boolean().describe("Indicates if the provided password is valid"),
|
|
270
|
+
driverIds: import_zod6.z.array(import_zod6.z.string()).describe("List of driver IDs associated with the provider account")
|
|
181
271
|
}).describe("Response schema for password validation");
|
|
182
272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
183
273
|
0 && (module.exports = {
|
|
@@ -186,6 +276,8 @@ var ValidatePasswordResponseSchema = import_zod4.z.object({
|
|
|
186
276
|
ConvexDriverSchema,
|
|
187
277
|
ConvexUpdate,
|
|
188
278
|
ConvexUpdateSchema,
|
|
279
|
+
DRIVER_NAME_FORBIDDEN_CHAR_PATTERN,
|
|
280
|
+
DriverNameSchema,
|
|
189
281
|
NewLoginRequest,
|
|
190
282
|
NewLoginRequestSchema,
|
|
191
283
|
NewLoginResponse,
|
|
@@ -194,7 +286,14 @@ var ValidatePasswordResponseSchema = import_zod4.z.object({
|
|
|
194
286
|
NewLoginResponseSchema,
|
|
195
287
|
NewLoginResponseSuccess,
|
|
196
288
|
NewLoginResponseSuccessSchema,
|
|
289
|
+
PATCH_DRIVER_NAME_MAX_LENGTH,
|
|
290
|
+
PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH,
|
|
291
|
+
PatchDriverDriverResponseSchema,
|
|
292
|
+
PatchDriverRequestSchema,
|
|
293
|
+
PatchDriverResponseSchema,
|
|
197
294
|
ScrapeStatus,
|
|
295
|
+
SharedDriverResponseSchema,
|
|
296
|
+
TruckTypeSchema,
|
|
198
297
|
UpdateScrapeStatusMessage,
|
|
199
298
|
ValidatePasswordRequestSchema,
|
|
200
299
|
ValidatePasswordResponseSchema
|
package/dist/browser.d.cts
CHANGED
|
@@ -291,6 +291,92 @@ declare const BatchConvexUpdate: z$1.ZodObject<{
|
|
|
291
291
|
}, z$1.core.$strip>;
|
|
292
292
|
type BatchConvexUpdate = BatchConvexUpdateData;
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Canonical wire-format schema for a Driver returned by the aggregator over HTTP.
|
|
296
|
+
*
|
|
297
|
+
* Uses `z.union([z.string(), z.date()])` for timestamp fields so the same schema can
|
|
298
|
+
* be used on the server (where pg returns `Date` objects and Fastify serializes them
|
|
299
|
+
* to ISO strings via `JSON.stringify`) and on the client (where they arrive as ISO
|
|
300
|
+
* strings).
|
|
301
|
+
*
|
|
302
|
+
* Single source of truth for the Driver shape across HTTP response schemas — both
|
|
303
|
+
* the aggregator's `DriverResponseSchema` and shared `PatchDriverResponseSchema`
|
|
304
|
+
* should import from here so adding a new column requires only one update.
|
|
305
|
+
*/
|
|
306
|
+
declare const SharedDriverResponseSchema: z$1.ZodObject<{
|
|
307
|
+
id: z$1.ZodUUID;
|
|
308
|
+
name: z$1.ZodString;
|
|
309
|
+
eld_external_id: z$1.ZodString;
|
|
310
|
+
license_number: z$1.ZodNullable<z$1.ZodString>;
|
|
311
|
+
license_state: z$1.ZodNullable<z$1.ZodString>;
|
|
312
|
+
license_expiration_date: z$1.ZodNullable<z$1.ZodString>;
|
|
313
|
+
license_class: z$1.ZodNullable<z$1.ZodString>;
|
|
314
|
+
is_placeholder: z$1.ZodBoolean;
|
|
315
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
316
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
317
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
318
|
+
last_location_latitude: z$1.ZodNullable<z$1.ZodNumber>;
|
|
319
|
+
last_location_longitude: z$1.ZodNullable<z$1.ZodNumber>;
|
|
320
|
+
}, z$1.core.$strip>;
|
|
321
|
+
type SharedDriverResponse = z$1.infer<typeof SharedDriverResponseSchema>;
|
|
322
|
+
|
|
323
|
+
declare const PATCH_DRIVER_NAME_MAX_LENGTH = 255;
|
|
324
|
+
declare const PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH = 100;
|
|
325
|
+
declare const DRIVER_NAME_FORBIDDEN_CHAR_PATTERN: RegExp;
|
|
326
|
+
declare const DriverNameSchema: z$1.ZodString;
|
|
327
|
+
declare const TruckTypeSchema: z$1.ZodString;
|
|
328
|
+
declare const PatchDriverRequestSchema: z$1.ZodObject<{
|
|
329
|
+
driver_id: z$1.ZodUUID;
|
|
330
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
331
|
+
truck_type: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
332
|
+
}, z$1.core.$strip>;
|
|
333
|
+
/**
|
|
334
|
+
* Slim driver shape returned from PATCH /drivers/:id.
|
|
335
|
+
*
|
|
336
|
+
* Intentionally narrower than `SharedDriverResponseSchema` (used by GET) — a
|
|
337
|
+
* rename should not be a backdoor for harvesting license PII.
|
|
338
|
+
*
|
|
339
|
+
* Omitted fields and rationale:
|
|
340
|
+
* - `license_number`, `license_state`, `license_expiration_date`,
|
|
341
|
+
* `license_class`: PII. A rename has no need to surface these and exposing
|
|
342
|
+
* them would turn the endpoint into a license-harvesting oracle.
|
|
343
|
+
* - `last_location_latitude`, `last_location_longitude`: also PII (driver
|
|
344
|
+
* real-time position) and unrelated to the rename outcome. A caller who
|
|
345
|
+
* needs the latest location should call `GET /drivers/:id`, where the full
|
|
346
|
+
* shape is intentional.
|
|
347
|
+
*
|
|
348
|
+
* `.strict()` makes Zod fail-loud on any extra property — so if a future
|
|
349
|
+
* server change accidentally re-introduces `license_*` (or any other field)
|
|
350
|
+
* into the PATCH response, both server-side response serialization (via
|
|
351
|
+
* `fastify-type-provider-zod`) AND client-side `safeParse` reject it, instead
|
|
352
|
+
* of Zod's default `strip` mode quietly dropping the extras. Defense in depth
|
|
353
|
+
* for the PII-omission contract above.
|
|
354
|
+
*/
|
|
355
|
+
declare const PatchDriverDriverResponseSchema: z$1.ZodObject<{
|
|
356
|
+
id: z$1.ZodUUID;
|
|
357
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
358
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
359
|
+
name: z$1.ZodString;
|
|
360
|
+
eld_external_id: z$1.ZodString;
|
|
361
|
+
is_placeholder: z$1.ZodBoolean;
|
|
362
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
363
|
+
}, z$1.core.$strict>;
|
|
364
|
+
declare const PatchDriverResponseSchema: z$1.ZodObject<{
|
|
365
|
+
message: z$1.ZodString;
|
|
366
|
+
driver: z$1.ZodObject<{
|
|
367
|
+
id: z$1.ZodUUID;
|
|
368
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
369
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
370
|
+
name: z$1.ZodString;
|
|
371
|
+
eld_external_id: z$1.ZodString;
|
|
372
|
+
is_placeholder: z$1.ZodBoolean;
|
|
373
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
374
|
+
}, z$1.core.$strict>;
|
|
375
|
+
}, z$1.core.$strip>;
|
|
376
|
+
type PatchDriverRequest = z$1.infer<typeof PatchDriverRequestSchema>;
|
|
377
|
+
type PatchDriverResponse = z$1.infer<typeof PatchDriverResponseSchema>;
|
|
378
|
+
type PatchDriverDriverResponse = z$1.infer<typeof PatchDriverDriverResponseSchema>;
|
|
379
|
+
|
|
294
380
|
declare enum ScrapeStatus {
|
|
295
381
|
NEW_LOGIN_RECEIVED = "NEW_LOGIN_RECEIVED",
|
|
296
382
|
LOGIN_IN_PROGRESS = "LOGIN_IN_PROGRESS",
|
|
@@ -332,4 +418,4 @@ declare const ValidatePasswordResponseSchema: z.ZodObject<{
|
|
|
332
418
|
type ValidatePasswordRequest = ValidatePasswordRequestData;
|
|
333
419
|
type ValidatePasswordResponse = ValidatePasswordResponseData;
|
|
334
420
|
|
|
335
|
-
export { BatchConvexUpdate, type BatchConvexUpdateData, BatchConvexUpdateSchema, type ConvexDriverData, ConvexDriverSchema, ConvexUpdate, type ConvexUpdateData, ConvexUpdateSchema, NewLoginRequest, type NewLoginRequestData, NewLoginRequestSchema, NewLoginResponse, type NewLoginResponseData, NewLoginResponseFailure, type NewLoginResponseFailureData, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, type NewLoginResponseSuccessData, NewLoginResponseSuccessSchema, type PublicProviderData, type PublicUserData, ScrapeStatus, UpdateScrapeStatusMessage, type ValidatePasswordRequest, type ValidatePasswordRequestData, ValidatePasswordRequestSchema, type ValidatePasswordResponse, type ValidatePasswordResponseData, ValidatePasswordResponseSchema };
|
|
421
|
+
export { BatchConvexUpdate, type BatchConvexUpdateData, BatchConvexUpdateSchema, type ConvexDriverData, ConvexDriverSchema, ConvexUpdate, type ConvexUpdateData, ConvexUpdateSchema, DRIVER_NAME_FORBIDDEN_CHAR_PATTERN, DriverNameSchema, NewLoginRequest, type NewLoginRequestData, NewLoginRequestSchema, NewLoginResponse, type NewLoginResponseData, NewLoginResponseFailure, type NewLoginResponseFailureData, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, type NewLoginResponseSuccessData, NewLoginResponseSuccessSchema, PATCH_DRIVER_NAME_MAX_LENGTH, PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH, type PatchDriverDriverResponse, PatchDriverDriverResponseSchema, type PatchDriverRequest, PatchDriverRequestSchema, type PatchDriverResponse, PatchDriverResponseSchema, type PublicProviderData, type PublicUserData, ScrapeStatus, type SharedDriverResponse, SharedDriverResponseSchema, TruckTypeSchema, UpdateScrapeStatusMessage, type ValidatePasswordRequest, type ValidatePasswordRequestData, ValidatePasswordRequestSchema, type ValidatePasswordResponse, type ValidatePasswordResponseData, ValidatePasswordResponseSchema };
|
package/dist/browser.d.ts
CHANGED
|
@@ -291,6 +291,92 @@ declare const BatchConvexUpdate: z$1.ZodObject<{
|
|
|
291
291
|
}, z$1.core.$strip>;
|
|
292
292
|
type BatchConvexUpdate = BatchConvexUpdateData;
|
|
293
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Canonical wire-format schema for a Driver returned by the aggregator over HTTP.
|
|
296
|
+
*
|
|
297
|
+
* Uses `z.union([z.string(), z.date()])` for timestamp fields so the same schema can
|
|
298
|
+
* be used on the server (where pg returns `Date` objects and Fastify serializes them
|
|
299
|
+
* to ISO strings via `JSON.stringify`) and on the client (where they arrive as ISO
|
|
300
|
+
* strings).
|
|
301
|
+
*
|
|
302
|
+
* Single source of truth for the Driver shape across HTTP response schemas — both
|
|
303
|
+
* the aggregator's `DriverResponseSchema` and shared `PatchDriverResponseSchema`
|
|
304
|
+
* should import from here so adding a new column requires only one update.
|
|
305
|
+
*/
|
|
306
|
+
declare const SharedDriverResponseSchema: z$1.ZodObject<{
|
|
307
|
+
id: z$1.ZodUUID;
|
|
308
|
+
name: z$1.ZodString;
|
|
309
|
+
eld_external_id: z$1.ZodString;
|
|
310
|
+
license_number: z$1.ZodNullable<z$1.ZodString>;
|
|
311
|
+
license_state: z$1.ZodNullable<z$1.ZodString>;
|
|
312
|
+
license_expiration_date: z$1.ZodNullable<z$1.ZodString>;
|
|
313
|
+
license_class: z$1.ZodNullable<z$1.ZodString>;
|
|
314
|
+
is_placeholder: z$1.ZodBoolean;
|
|
315
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
316
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
317
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
318
|
+
last_location_latitude: z$1.ZodNullable<z$1.ZodNumber>;
|
|
319
|
+
last_location_longitude: z$1.ZodNullable<z$1.ZodNumber>;
|
|
320
|
+
}, z$1.core.$strip>;
|
|
321
|
+
type SharedDriverResponse = z$1.infer<typeof SharedDriverResponseSchema>;
|
|
322
|
+
|
|
323
|
+
declare const PATCH_DRIVER_NAME_MAX_LENGTH = 255;
|
|
324
|
+
declare const PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH = 100;
|
|
325
|
+
declare const DRIVER_NAME_FORBIDDEN_CHAR_PATTERN: RegExp;
|
|
326
|
+
declare const DriverNameSchema: z$1.ZodString;
|
|
327
|
+
declare const TruckTypeSchema: z$1.ZodString;
|
|
328
|
+
declare const PatchDriverRequestSchema: z$1.ZodObject<{
|
|
329
|
+
driver_id: z$1.ZodUUID;
|
|
330
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
331
|
+
truck_type: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
332
|
+
}, z$1.core.$strip>;
|
|
333
|
+
/**
|
|
334
|
+
* Slim driver shape returned from PATCH /drivers/:id.
|
|
335
|
+
*
|
|
336
|
+
* Intentionally narrower than `SharedDriverResponseSchema` (used by GET) — a
|
|
337
|
+
* rename should not be a backdoor for harvesting license PII.
|
|
338
|
+
*
|
|
339
|
+
* Omitted fields and rationale:
|
|
340
|
+
* - `license_number`, `license_state`, `license_expiration_date`,
|
|
341
|
+
* `license_class`: PII. A rename has no need to surface these and exposing
|
|
342
|
+
* them would turn the endpoint into a license-harvesting oracle.
|
|
343
|
+
* - `last_location_latitude`, `last_location_longitude`: also PII (driver
|
|
344
|
+
* real-time position) and unrelated to the rename outcome. A caller who
|
|
345
|
+
* needs the latest location should call `GET /drivers/:id`, where the full
|
|
346
|
+
* shape is intentional.
|
|
347
|
+
*
|
|
348
|
+
* `.strict()` makes Zod fail-loud on any extra property — so if a future
|
|
349
|
+
* server change accidentally re-introduces `license_*` (or any other field)
|
|
350
|
+
* into the PATCH response, both server-side response serialization (via
|
|
351
|
+
* `fastify-type-provider-zod`) AND client-side `safeParse` reject it, instead
|
|
352
|
+
* of Zod's default `strip` mode quietly dropping the extras. Defense in depth
|
|
353
|
+
* for the PII-omission contract above.
|
|
354
|
+
*/
|
|
355
|
+
declare const PatchDriverDriverResponseSchema: z$1.ZodObject<{
|
|
356
|
+
id: z$1.ZodUUID;
|
|
357
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
358
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
359
|
+
name: z$1.ZodString;
|
|
360
|
+
eld_external_id: z$1.ZodString;
|
|
361
|
+
is_placeholder: z$1.ZodBoolean;
|
|
362
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
363
|
+
}, z$1.core.$strict>;
|
|
364
|
+
declare const PatchDriverResponseSchema: z$1.ZodObject<{
|
|
365
|
+
message: z$1.ZodString;
|
|
366
|
+
driver: z$1.ZodObject<{
|
|
367
|
+
id: z$1.ZodUUID;
|
|
368
|
+
created_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
369
|
+
updated_at: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodDate]>;
|
|
370
|
+
name: z$1.ZodString;
|
|
371
|
+
eld_external_id: z$1.ZodString;
|
|
372
|
+
is_placeholder: z$1.ZodBoolean;
|
|
373
|
+
truck_type: z$1.ZodNullable<z$1.ZodString>;
|
|
374
|
+
}, z$1.core.$strict>;
|
|
375
|
+
}, z$1.core.$strip>;
|
|
376
|
+
type PatchDriverRequest = z$1.infer<typeof PatchDriverRequestSchema>;
|
|
377
|
+
type PatchDriverResponse = z$1.infer<typeof PatchDriverResponseSchema>;
|
|
378
|
+
type PatchDriverDriverResponse = z$1.infer<typeof PatchDriverDriverResponseSchema>;
|
|
379
|
+
|
|
294
380
|
declare enum ScrapeStatus {
|
|
295
381
|
NEW_LOGIN_RECEIVED = "NEW_LOGIN_RECEIVED",
|
|
296
382
|
LOGIN_IN_PROGRESS = "LOGIN_IN_PROGRESS",
|
|
@@ -332,4 +418,4 @@ declare const ValidatePasswordResponseSchema: z.ZodObject<{
|
|
|
332
418
|
type ValidatePasswordRequest = ValidatePasswordRequestData;
|
|
333
419
|
type ValidatePasswordResponse = ValidatePasswordResponseData;
|
|
334
420
|
|
|
335
|
-
export { BatchConvexUpdate, type BatchConvexUpdateData, BatchConvexUpdateSchema, type ConvexDriverData, ConvexDriverSchema, ConvexUpdate, type ConvexUpdateData, ConvexUpdateSchema, NewLoginRequest, type NewLoginRequestData, NewLoginRequestSchema, NewLoginResponse, type NewLoginResponseData, NewLoginResponseFailure, type NewLoginResponseFailureData, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, type NewLoginResponseSuccessData, NewLoginResponseSuccessSchema, type PublicProviderData, type PublicUserData, ScrapeStatus, UpdateScrapeStatusMessage, type ValidatePasswordRequest, type ValidatePasswordRequestData, ValidatePasswordRequestSchema, type ValidatePasswordResponse, type ValidatePasswordResponseData, ValidatePasswordResponseSchema };
|
|
421
|
+
export { BatchConvexUpdate, type BatchConvexUpdateData, BatchConvexUpdateSchema, type ConvexDriverData, ConvexDriverSchema, ConvexUpdate, type ConvexUpdateData, ConvexUpdateSchema, DRIVER_NAME_FORBIDDEN_CHAR_PATTERN, DriverNameSchema, NewLoginRequest, type NewLoginRequestData, NewLoginRequestSchema, NewLoginResponse, type NewLoginResponseData, NewLoginResponseFailure, type NewLoginResponseFailureData, NewLoginResponseFailureSchema, NewLoginResponseSchema, NewLoginResponseSuccess, type NewLoginResponseSuccessData, NewLoginResponseSuccessSchema, PATCH_DRIVER_NAME_MAX_LENGTH, PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH, type PatchDriverDriverResponse, PatchDriverDriverResponseSchema, type PatchDriverRequest, PatchDriverRequestSchema, type PatchDriverResponse, PatchDriverResponseSchema, type PublicProviderData, type PublicUserData, ScrapeStatus, type SharedDriverResponse, SharedDriverResponseSchema, TruckTypeSchema, UpdateScrapeStatusMessage, type ValidatePasswordRequest, type ValidatePasswordRequestData, ValidatePasswordRequestSchema, type ValidatePasswordResponse, type ValidatePasswordResponseData, ValidatePasswordResponseSchema };
|
package/dist/browser.js
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
ConvexDriverSchema,
|
|
5
5
|
ConvexUpdate,
|
|
6
6
|
ConvexUpdateSchema,
|
|
7
|
+
DRIVER_NAME_FORBIDDEN_CHAR_PATTERN,
|
|
8
|
+
DriverNameSchema,
|
|
7
9
|
NewLoginRequest,
|
|
8
10
|
NewLoginRequestSchema,
|
|
9
11
|
NewLoginResponse,
|
|
@@ -12,17 +14,26 @@ import {
|
|
|
12
14
|
NewLoginResponseSchema,
|
|
13
15
|
NewLoginResponseSuccess,
|
|
14
16
|
NewLoginResponseSuccessSchema,
|
|
17
|
+
PATCH_DRIVER_NAME_MAX_LENGTH,
|
|
18
|
+
PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH,
|
|
19
|
+
PatchDriverDriverResponseSchema,
|
|
20
|
+
PatchDriverRequestSchema,
|
|
21
|
+
PatchDriverResponseSchema,
|
|
15
22
|
ScrapeStatus,
|
|
23
|
+
SharedDriverResponseSchema,
|
|
24
|
+
TruckTypeSchema,
|
|
16
25
|
UpdateScrapeStatusMessage,
|
|
17
26
|
ValidatePasswordRequestSchema,
|
|
18
27
|
ValidatePasswordResponseSchema
|
|
19
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-P4S46OZI.js";
|
|
20
29
|
export {
|
|
21
30
|
BatchConvexUpdate,
|
|
22
31
|
BatchConvexUpdateSchema,
|
|
23
32
|
ConvexDriverSchema,
|
|
24
33
|
ConvexUpdate,
|
|
25
34
|
ConvexUpdateSchema,
|
|
35
|
+
DRIVER_NAME_FORBIDDEN_CHAR_PATTERN,
|
|
36
|
+
DriverNameSchema,
|
|
26
37
|
NewLoginRequest,
|
|
27
38
|
NewLoginRequestSchema,
|
|
28
39
|
NewLoginResponse,
|
|
@@ -31,7 +42,14 @@ export {
|
|
|
31
42
|
NewLoginResponseSchema,
|
|
32
43
|
NewLoginResponseSuccess,
|
|
33
44
|
NewLoginResponseSuccessSchema,
|
|
45
|
+
PATCH_DRIVER_NAME_MAX_LENGTH,
|
|
46
|
+
PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH,
|
|
47
|
+
PatchDriverDriverResponseSchema,
|
|
48
|
+
PatchDriverRequestSchema,
|
|
49
|
+
PatchDriverResponseSchema,
|
|
34
50
|
ScrapeStatus,
|
|
51
|
+
SharedDriverResponseSchema,
|
|
52
|
+
TruckTypeSchema,
|
|
35
53
|
UpdateScrapeStatusMessage,
|
|
36
54
|
ValidatePasswordRequestSchema,
|
|
37
55
|
ValidatePasswordResponseSchema
|
|
@@ -93,8 +93,89 @@ var BatchConvexUpdateSchema = z2.object({
|
|
|
93
93
|
var ConvexUpdate = ConvexUpdateSchema;
|
|
94
94
|
var BatchConvexUpdate = BatchConvexUpdateSchema;
|
|
95
95
|
|
|
96
|
-
// src/schemas/
|
|
96
|
+
// src/schemas/drivers/driver.ts
|
|
97
97
|
import z3 from "zod";
|
|
98
|
+
var SharedDriverResponseSchema = z3.object({
|
|
99
|
+
// The `drivers.id` column is a Postgres UUID (migration 0001), and every
|
|
100
|
+
// input-side schema (`IdParamsSchema`, `PatchDriverRequestSchema.driver_id`)
|
|
101
|
+
// is already `z.uuid()`. Tightening the response side keeps the contract
|
|
102
|
+
// symmetric — a client that statically relies on `id` being UUID-shaped on
|
|
103
|
+
// input can rely on the same on output. `eld_external_id` stays loose
|
|
104
|
+
// because providers emit non-UUID identifiers there.
|
|
105
|
+
id: z3.uuid(),
|
|
106
|
+
name: z3.string(),
|
|
107
|
+
eld_external_id: z3.string(),
|
|
108
|
+
license_number: z3.string().nullable(),
|
|
109
|
+
license_state: z3.string().nullable(),
|
|
110
|
+
license_expiration_date: z3.string().nullable(),
|
|
111
|
+
license_class: z3.string().nullable(),
|
|
112
|
+
is_placeholder: z3.boolean(),
|
|
113
|
+
created_at: z3.union([z3.string(), z3.date()]),
|
|
114
|
+
updated_at: z3.union([z3.string(), z3.date()]),
|
|
115
|
+
truck_type: z3.string().nullable(),
|
|
116
|
+
last_location_latitude: z3.number().nullable(),
|
|
117
|
+
last_location_longitude: z3.number().nullable()
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// src/schemas/drivers/patch-driver.ts
|
|
121
|
+
import z4 from "zod";
|
|
122
|
+
var PATCH_DRIVER_NAME_MAX_LENGTH = 255;
|
|
123
|
+
var PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH = 100;
|
|
124
|
+
var DRIVER_NAME_FORBIDDEN_RANGES = [
|
|
125
|
+
[0, 31],
|
|
126
|
+
// C0 controls (includes NUL, CR, LF, TAB)
|
|
127
|
+
[127, 159],
|
|
128
|
+
// DEL + C1 controls
|
|
129
|
+
[8203, 8205],
|
|
130
|
+
// ZWSP, ZWNJ, ZWJ
|
|
131
|
+
[65279, 65279],
|
|
132
|
+
// BOM / ZWNBSP
|
|
133
|
+
[8234, 8238],
|
|
134
|
+
// bidi overrides
|
|
135
|
+
[8294, 8297]
|
|
136
|
+
// bidi isolates
|
|
137
|
+
];
|
|
138
|
+
var buildForbiddenCharPattern = () => {
|
|
139
|
+
const cls = DRIVER_NAME_FORBIDDEN_RANGES.map(([lo, hi]) => {
|
|
140
|
+
const loEsc = "\\u" + lo.toString(16).padStart(4, "0");
|
|
141
|
+
if (lo === hi) return loEsc;
|
|
142
|
+
const hiEsc = "\\u" + hi.toString(16).padStart(4, "0");
|
|
143
|
+
return `${loEsc}-${hiEsc}`;
|
|
144
|
+
}).join("");
|
|
145
|
+
return new RegExp(`[${cls}]`);
|
|
146
|
+
};
|
|
147
|
+
var DRIVER_NAME_FORBIDDEN_CHAR_PATTERN = buildForbiddenCharPattern();
|
|
148
|
+
var DriverNameSchema = z4.string().trim().min(1).max(PATCH_DRIVER_NAME_MAX_LENGTH).refine(
|
|
149
|
+
(s) => !DRIVER_NAME_FORBIDDEN_CHAR_PATTERN.test(s),
|
|
150
|
+
{
|
|
151
|
+
message: "name contains disallowed control, zero-width, or bidirectional-override characters"
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
var TruckTypeSchema = z4.string().trim().min(1).max(PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH);
|
|
155
|
+
var PatchDriverRequestSchema = z4.object({
|
|
156
|
+
driver_id: z4.uuid(),
|
|
157
|
+
name: DriverNameSchema.optional(),
|
|
158
|
+
truck_type: TruckTypeSchema.nullable().optional()
|
|
159
|
+
}).refine(
|
|
160
|
+
(d) => d.name !== void 0 || d.truck_type !== void 0,
|
|
161
|
+
{ message: "At least one of name or truck_type must be provided" }
|
|
162
|
+
);
|
|
163
|
+
var PatchDriverDriverResponseSchema = SharedDriverResponseSchema.pick({
|
|
164
|
+
id: true,
|
|
165
|
+
name: true,
|
|
166
|
+
eld_external_id: true,
|
|
167
|
+
is_placeholder: true,
|
|
168
|
+
truck_type: true,
|
|
169
|
+
created_at: true,
|
|
170
|
+
updated_at: true
|
|
171
|
+
}).strict();
|
|
172
|
+
var PatchDriverResponseSchema = z4.object({
|
|
173
|
+
message: z4.string(),
|
|
174
|
+
driver: PatchDriverDriverResponseSchema
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// src/schemas/providerAccounts/update-status.ts
|
|
178
|
+
import z5 from "zod";
|
|
98
179
|
var ScrapeStatus = /* @__PURE__ */ ((ScrapeStatus2) => {
|
|
99
180
|
ScrapeStatus2["NEW_LOGIN_RECEIVED"] = "NEW_LOGIN_RECEIVED";
|
|
100
181
|
ScrapeStatus2["LOGIN_IN_PROGRESS"] = "LOGIN_IN_PROGRESS";
|
|
@@ -107,25 +188,25 @@ var ScrapeStatus = /* @__PURE__ */ ((ScrapeStatus2) => {
|
|
|
107
188
|
ScrapeStatus2["DATA_FETCH_FAILED"] = "DATA_FETCH_FAILED";
|
|
108
189
|
return ScrapeStatus2;
|
|
109
190
|
})(ScrapeStatus || {});
|
|
110
|
-
var UpdateScrapeStatusMessage =
|
|
111
|
-
status:
|
|
112
|
-
correctPassword:
|
|
113
|
-
externalProviderAccountId:
|
|
114
|
-
username:
|
|
115
|
-
provider_url:
|
|
116
|
-
driverCount:
|
|
117
|
-
providerSlug:
|
|
191
|
+
var UpdateScrapeStatusMessage = z5.object({
|
|
192
|
+
status: z5.nativeEnum(ScrapeStatus).describe("The current status of the scrape process"),
|
|
193
|
+
correctPassword: z5.boolean().optional().describe("Indicates if the provided password was correct, if applicable"),
|
|
194
|
+
externalProviderAccountId: z5.string().describe("The external identifier for the provider account (convex ID or similar)"),
|
|
195
|
+
username: z5.string().describe("The username of the provider account whose status is being updated"),
|
|
196
|
+
provider_url: z5.string().describe("The URL of the ELD provider"),
|
|
197
|
+
driverCount: z5.number().optional().describe("The number of drivers associated with the account, if applicable"),
|
|
198
|
+
providerSlug: z5.string().optional().describe("The slug identifier for the provider")
|
|
118
199
|
}).describe("Schema for update status messages");
|
|
119
200
|
|
|
120
201
|
// src/schemas/providerAccounts/validate-password.ts
|
|
121
|
-
import { z as
|
|
122
|
-
var ValidatePasswordRequestSchema =
|
|
123
|
-
providerAccountId:
|
|
124
|
-
encryptedPassword:
|
|
202
|
+
import { z as z6 } from "zod";
|
|
203
|
+
var ValidatePasswordRequestSchema = z6.object({
|
|
204
|
+
providerAccountId: z6.string().min(1).describe("The unique identifier of the provider account in postgres to validate the password for"),
|
|
205
|
+
encryptedPassword: z6.string().min(1).describe("The encrypted password to validate against the stored password")
|
|
125
206
|
}).describe("Request schema for validating a provider account password");
|
|
126
|
-
var ValidatePasswordResponseSchema =
|
|
127
|
-
isValid:
|
|
128
|
-
driverIds:
|
|
207
|
+
var ValidatePasswordResponseSchema = z6.object({
|
|
208
|
+
isValid: z6.boolean().describe("Indicates if the provided password is valid"),
|
|
209
|
+
driverIds: z6.array(z6.string()).describe("List of driver IDs associated with the provider account")
|
|
129
210
|
}).describe("Response schema for password validation");
|
|
130
211
|
|
|
131
212
|
export {
|
|
@@ -142,6 +223,15 @@ export {
|
|
|
142
223
|
BatchConvexUpdateSchema,
|
|
143
224
|
ConvexUpdate,
|
|
144
225
|
BatchConvexUpdate,
|
|
226
|
+
SharedDriverResponseSchema,
|
|
227
|
+
PATCH_DRIVER_NAME_MAX_LENGTH,
|
|
228
|
+
PATCH_DRIVER_TRUCK_TYPE_MAX_LENGTH,
|
|
229
|
+
DRIVER_NAME_FORBIDDEN_CHAR_PATTERN,
|
|
230
|
+
DriverNameSchema,
|
|
231
|
+
TruckTypeSchema,
|
|
232
|
+
PatchDriverRequestSchema,
|
|
233
|
+
PatchDriverDriverResponseSchema,
|
|
234
|
+
PatchDriverResponseSchema,
|
|
145
235
|
ScrapeStatus,
|
|
146
236
|
UpdateScrapeStatusMessage,
|
|
147
237
|
ValidatePasswordRequestSchema,
|