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