@findatruck/shared-schemas 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -32,6 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ConvexUpdate: () => ConvexUpdate,
34
34
  ConvexUpdateNested: () => ConvexUpdateNested,
35
+ DriverIdentity: () => DriverIdentity,
35
36
  DriverLocation: () => DriverLocation,
36
37
  DriverLogin: () => DriverLogin,
37
38
  DriverStatus: () => DriverStatus,
@@ -39,7 +40,10 @@ __export(index_exports, {
39
40
  NewLoginRequest: () => NewLoginRequest,
40
41
  NewLoginResponse: () => NewLoginResponse,
41
42
  NewLoginResponseFailure: () => NewLoginResponseFailure,
42
- NewLoginResponseSuccess: () => NewLoginResponseSuccess
43
+ NewLoginResponseSuccess: () => NewLoginResponseSuccess,
44
+ VehicleIdentity: () => VehicleIdentity,
45
+ decryptRsaOaepSha256B64: () => decryptRsaOaepSha256B64,
46
+ encryptRsaOaepSha256ToB64: () => encryptRsaOaepSha256ToB64
43
47
  });
44
48
  module.exports = __toCommonJS(index_exports);
45
49
 
@@ -101,6 +105,10 @@ var ConvexUpdate = import_zod2.default.object({
101
105
  username: import_zod2.default.string().describe("The driver's login username"),
102
106
  password: import_zod2.default.string().describe("The driver's login password"),
103
107
  driver_id: import_zod2.default.string().optional().describe("The ELD's internal driver ID"),
108
+ driver_first_name: import_zod2.default.string().optional().describe("The driver's first name"),
109
+ driver_last_name: import_zod2.default.string().optional().describe("The driver's last name"),
110
+ driver_name: import_zod2.default.string().optional().describe("The driver's full name"),
111
+ vehicle_id: import_zod2.default.string().optional().describe("The vehicle ID"),
104
112
  driver_status: import_zod2.default.string().describe("The driver's duty status (direct from ELD)"),
105
113
  time_remaining_in_shift: import_zod2.default.number().describe("Seconds remaining in current shift"),
106
114
  time_remaining_till_break: import_zod2.default.number().describe("Seconds remaining until next required break"),
@@ -129,17 +137,54 @@ var DriverLogin = import_zod2.default.object({
129
137
  username: import_zod2.default.string().describe("The driver's login username"),
130
138
  password: import_zod2.default.string().describe("The driver's login password")
131
139
  }).describe("Schema for driver login information");
132
- var ConvexUpdateNested = import_zod2.default.object({
140
+ var DriverIdentity = import_zod2.default.object({
133
141
  driverId: import_zod2.default.string().describe("The ELD's internal driver ID"),
142
+ driverFirstName: import_zod2.default.string().optional().describe("The driver's first name"),
143
+ driverLastName: import_zod2.default.string().optional().describe("The driver's last name"),
144
+ driverName: import_zod2.default.string().optional().describe("The driver's full name")
145
+ }).describe("Schema for identifying the driver");
146
+ var VehicleIdentity = import_zod2.default.object({
147
+ vehicleId: import_zod2.default.string().optional().describe("The vehicle ID")
148
+ }).describe("Schema for identifying the vehicle");
149
+ var ConvexUpdateNested = import_zod2.default.object({
150
+ driver: DriverIdentity,
151
+ vehicle: VehicleIdentity,
134
152
  hoursOfService: HoursOfService,
135
153
  driverLocation: DriverLocation,
136
154
  driverStatus: DriverStatus,
137
155
  driverLogin: DriverLogin
138
156
  }).describe("Nested schema for updating driver ELD status information");
157
+
158
+ // src/security/transit-crypto.ts
159
+ var import_node_crypto = require("crypto");
160
+ function encryptRsaOaepSha256ToB64(plaintext, publicKeyPem) {
161
+ const ciphertext = (0, import_node_crypto.publicEncrypt)(
162
+ {
163
+ key: publicKeyPem,
164
+ padding: import_node_crypto.constants.RSA_PKCS1_OAEP_PADDING,
165
+ oaepHash: "sha256"
166
+ },
167
+ Buffer.from(plaintext, "utf8")
168
+ );
169
+ return ciphertext.toString("base64");
170
+ }
171
+ function decryptRsaOaepSha256B64(ciphertextB64, privateKeyPem, passphrase) {
172
+ const plaintext = (0, import_node_crypto.privateDecrypt)(
173
+ {
174
+ key: privateKeyPem,
175
+ passphrase,
176
+ padding: import_node_crypto.constants.RSA_PKCS1_OAEP_PADDING,
177
+ oaepHash: "sha256"
178
+ },
179
+ Buffer.from(ciphertextB64, "base64")
180
+ );
181
+ return plaintext.toString("utf8");
182
+ }
139
183
  // Annotate the CommonJS export names for ESM import in node:
140
184
  0 && (module.exports = {
141
185
  ConvexUpdate,
142
186
  ConvexUpdateNested,
187
+ DriverIdentity,
143
188
  DriverLocation,
144
189
  DriverLogin,
145
190
  DriverStatus,
@@ -147,5 +192,8 @@ var ConvexUpdateNested = import_zod2.default.object({
147
192
  NewLoginRequest,
148
193
  NewLoginResponse,
149
194
  NewLoginResponseFailure,
150
- NewLoginResponseSuccess
195
+ NewLoginResponseSuccess,
196
+ VehicleIdentity,
197
+ decryptRsaOaepSha256B64,
198
+ encryptRsaOaepSha256ToB64
151
199
  });
package/dist/index.d.cts CHANGED
@@ -150,6 +150,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
150
150
  username: z$1.ZodString;
151
151
  password: z$1.ZodString;
152
152
  driver_id: z$1.ZodOptional<z$1.ZodString>;
153
+ driver_first_name: z$1.ZodOptional<z$1.ZodString>;
154
+ driver_last_name: z$1.ZodOptional<z$1.ZodString>;
155
+ driver_name: z$1.ZodOptional<z$1.ZodString>;
156
+ vehicle_id: z$1.ZodOptional<z$1.ZodString>;
153
157
  driver_status: z$1.ZodString;
154
158
  time_remaining_in_shift: z$1.ZodNumber;
155
159
  time_remaining_till_break: z$1.ZodNumber;
@@ -171,6 +175,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
171
175
  driver_current_location_longitude: number;
172
176
  driver_current_location_address: string;
173
177
  driver_id?: string | undefined;
178
+ driver_first_name?: string | undefined;
179
+ driver_last_name?: string | undefined;
180
+ driver_name?: string | undefined;
181
+ vehicle_id?: string | undefined;
174
182
  }, {
175
183
  providerUrl: string;
176
184
  username: string;
@@ -184,6 +192,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
184
192
  driver_current_location_longitude: number;
185
193
  driver_current_location_address: string;
186
194
  driver_id?: string | undefined;
195
+ driver_first_name?: string | undefined;
196
+ driver_last_name?: string | undefined;
197
+ driver_name?: string | undefined;
198
+ vehicle_id?: string | undefined;
187
199
  }>;
188
200
  type ConvexUpdate = z$1.infer<typeof ConvexUpdate>;
189
201
  declare const HoursOfService: z$1.ZodObject<{
@@ -239,8 +251,55 @@ declare const DriverLogin: z$1.ZodObject<{
239
251
  password: string;
240
252
  }>;
241
253
  type DriverLogin = z$1.infer<typeof DriverLogin>;
242
- declare const ConvexUpdateNested: z$1.ZodObject<{
254
+ declare const DriverIdentity: z$1.ZodObject<{
243
255
  driverId: z$1.ZodString;
256
+ driverFirstName: z$1.ZodOptional<z$1.ZodString>;
257
+ driverLastName: z$1.ZodOptional<z$1.ZodString>;
258
+ driverName: z$1.ZodOptional<z$1.ZodString>;
259
+ }, "strip", z$1.ZodTypeAny, {
260
+ driverId: string;
261
+ driverFirstName?: string | undefined;
262
+ driverLastName?: string | undefined;
263
+ driverName?: string | undefined;
264
+ }, {
265
+ driverId: string;
266
+ driverFirstName?: string | undefined;
267
+ driverLastName?: string | undefined;
268
+ driverName?: string | undefined;
269
+ }>;
270
+ type DriverIdentity = z$1.infer<typeof DriverIdentity>;
271
+ declare const VehicleIdentity: z$1.ZodObject<{
272
+ vehicleId: z$1.ZodOptional<z$1.ZodString>;
273
+ }, "strip", z$1.ZodTypeAny, {
274
+ vehicleId?: string | undefined;
275
+ }, {
276
+ vehicleId?: string | undefined;
277
+ }>;
278
+ type VehicleIdentity = z$1.infer<typeof VehicleIdentity>;
279
+ declare const ConvexUpdateNested: z$1.ZodObject<{
280
+ driver: z$1.ZodObject<{
281
+ driverId: z$1.ZodString;
282
+ driverFirstName: z$1.ZodOptional<z$1.ZodString>;
283
+ driverLastName: z$1.ZodOptional<z$1.ZodString>;
284
+ driverName: z$1.ZodOptional<z$1.ZodString>;
285
+ }, "strip", z$1.ZodTypeAny, {
286
+ driverId: string;
287
+ driverFirstName?: string | undefined;
288
+ driverLastName?: string | undefined;
289
+ driverName?: string | undefined;
290
+ }, {
291
+ driverId: string;
292
+ driverFirstName?: string | undefined;
293
+ driverLastName?: string | undefined;
294
+ driverName?: string | undefined;
295
+ }>;
296
+ vehicle: z$1.ZodObject<{
297
+ vehicleId: z$1.ZodOptional<z$1.ZodString>;
298
+ }, "strip", z$1.ZodTypeAny, {
299
+ vehicleId?: string | undefined;
300
+ }, {
301
+ vehicleId?: string | undefined;
302
+ }>;
244
303
  hoursOfService: z$1.ZodObject<{
245
304
  timeRemainingInShift: z$1.ZodNumber;
246
305
  timeRemainingTillBreak: z$1.ZodNumber;
@@ -291,7 +350,15 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
291
350
  password: string;
292
351
  }>;
293
352
  }, "strip", z$1.ZodTypeAny, {
294
- driverId: string;
353
+ driver: {
354
+ driverId: string;
355
+ driverFirstName?: string | undefined;
356
+ driverLastName?: string | undefined;
357
+ driverName?: string | undefined;
358
+ };
359
+ vehicle: {
360
+ vehicleId?: string | undefined;
361
+ };
295
362
  hoursOfService: {
296
363
  timeRemainingInShift: number;
297
364
  timeRemainingTillBreak: number;
@@ -312,7 +379,15 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
312
379
  password: string;
313
380
  };
314
381
  }, {
315
- driverId: string;
382
+ driver: {
383
+ driverId: string;
384
+ driverFirstName?: string | undefined;
385
+ driverLastName?: string | undefined;
386
+ driverName?: string | undefined;
387
+ };
388
+ vehicle: {
389
+ vehicleId?: string | undefined;
390
+ };
316
391
  hoursOfService: {
317
392
  timeRemainingInShift: number;
318
393
  timeRemainingTillBreak: number;
@@ -335,4 +410,7 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
335
410
  }>;
336
411
  type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
412
 
338
- export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
413
+ declare function encryptRsaOaepSha256ToB64(plaintext: string, publicKeyPem: string): string;
414
+ declare function decryptRsaOaepSha256B64(ciphertextB64: string, privateKeyPem: string, passphrase?: string): string;
415
+
416
+ export { ConvexUpdate, ConvexUpdateNested, DriverIdentity, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess, VehicleIdentity, decryptRsaOaepSha256B64, encryptRsaOaepSha256ToB64 };
package/dist/index.d.ts CHANGED
@@ -150,6 +150,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
150
150
  username: z$1.ZodString;
151
151
  password: z$1.ZodString;
152
152
  driver_id: z$1.ZodOptional<z$1.ZodString>;
153
+ driver_first_name: z$1.ZodOptional<z$1.ZodString>;
154
+ driver_last_name: z$1.ZodOptional<z$1.ZodString>;
155
+ driver_name: z$1.ZodOptional<z$1.ZodString>;
156
+ vehicle_id: z$1.ZodOptional<z$1.ZodString>;
153
157
  driver_status: z$1.ZodString;
154
158
  time_remaining_in_shift: z$1.ZodNumber;
155
159
  time_remaining_till_break: z$1.ZodNumber;
@@ -171,6 +175,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
171
175
  driver_current_location_longitude: number;
172
176
  driver_current_location_address: string;
173
177
  driver_id?: string | undefined;
178
+ driver_first_name?: string | undefined;
179
+ driver_last_name?: string | undefined;
180
+ driver_name?: string | undefined;
181
+ vehicle_id?: string | undefined;
174
182
  }, {
175
183
  providerUrl: string;
176
184
  username: string;
@@ -184,6 +192,10 @@ declare const ConvexUpdate: z$1.ZodObject<{
184
192
  driver_current_location_longitude: number;
185
193
  driver_current_location_address: string;
186
194
  driver_id?: string | undefined;
195
+ driver_first_name?: string | undefined;
196
+ driver_last_name?: string | undefined;
197
+ driver_name?: string | undefined;
198
+ vehicle_id?: string | undefined;
187
199
  }>;
188
200
  type ConvexUpdate = z$1.infer<typeof ConvexUpdate>;
189
201
  declare const HoursOfService: z$1.ZodObject<{
@@ -239,8 +251,55 @@ declare const DriverLogin: z$1.ZodObject<{
239
251
  password: string;
240
252
  }>;
241
253
  type DriverLogin = z$1.infer<typeof DriverLogin>;
242
- declare const ConvexUpdateNested: z$1.ZodObject<{
254
+ declare const DriverIdentity: z$1.ZodObject<{
243
255
  driverId: z$1.ZodString;
256
+ driverFirstName: z$1.ZodOptional<z$1.ZodString>;
257
+ driverLastName: z$1.ZodOptional<z$1.ZodString>;
258
+ driverName: z$1.ZodOptional<z$1.ZodString>;
259
+ }, "strip", z$1.ZodTypeAny, {
260
+ driverId: string;
261
+ driverFirstName?: string | undefined;
262
+ driverLastName?: string | undefined;
263
+ driverName?: string | undefined;
264
+ }, {
265
+ driverId: string;
266
+ driverFirstName?: string | undefined;
267
+ driverLastName?: string | undefined;
268
+ driverName?: string | undefined;
269
+ }>;
270
+ type DriverIdentity = z$1.infer<typeof DriverIdentity>;
271
+ declare const VehicleIdentity: z$1.ZodObject<{
272
+ vehicleId: z$1.ZodOptional<z$1.ZodString>;
273
+ }, "strip", z$1.ZodTypeAny, {
274
+ vehicleId?: string | undefined;
275
+ }, {
276
+ vehicleId?: string | undefined;
277
+ }>;
278
+ type VehicleIdentity = z$1.infer<typeof VehicleIdentity>;
279
+ declare const ConvexUpdateNested: z$1.ZodObject<{
280
+ driver: z$1.ZodObject<{
281
+ driverId: z$1.ZodString;
282
+ driverFirstName: z$1.ZodOptional<z$1.ZodString>;
283
+ driverLastName: z$1.ZodOptional<z$1.ZodString>;
284
+ driverName: z$1.ZodOptional<z$1.ZodString>;
285
+ }, "strip", z$1.ZodTypeAny, {
286
+ driverId: string;
287
+ driverFirstName?: string | undefined;
288
+ driverLastName?: string | undefined;
289
+ driverName?: string | undefined;
290
+ }, {
291
+ driverId: string;
292
+ driverFirstName?: string | undefined;
293
+ driverLastName?: string | undefined;
294
+ driverName?: string | undefined;
295
+ }>;
296
+ vehicle: z$1.ZodObject<{
297
+ vehicleId: z$1.ZodOptional<z$1.ZodString>;
298
+ }, "strip", z$1.ZodTypeAny, {
299
+ vehicleId?: string | undefined;
300
+ }, {
301
+ vehicleId?: string | undefined;
302
+ }>;
244
303
  hoursOfService: z$1.ZodObject<{
245
304
  timeRemainingInShift: z$1.ZodNumber;
246
305
  timeRemainingTillBreak: z$1.ZodNumber;
@@ -291,7 +350,15 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
291
350
  password: string;
292
351
  }>;
293
352
  }, "strip", z$1.ZodTypeAny, {
294
- driverId: string;
353
+ driver: {
354
+ driverId: string;
355
+ driverFirstName?: string | undefined;
356
+ driverLastName?: string | undefined;
357
+ driverName?: string | undefined;
358
+ };
359
+ vehicle: {
360
+ vehicleId?: string | undefined;
361
+ };
295
362
  hoursOfService: {
296
363
  timeRemainingInShift: number;
297
364
  timeRemainingTillBreak: number;
@@ -312,7 +379,15 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
312
379
  password: string;
313
380
  };
314
381
  }, {
315
- driverId: string;
382
+ driver: {
383
+ driverId: string;
384
+ driverFirstName?: string | undefined;
385
+ driverLastName?: string | undefined;
386
+ driverName?: string | undefined;
387
+ };
388
+ vehicle: {
389
+ vehicleId?: string | undefined;
390
+ };
316
391
  hoursOfService: {
317
392
  timeRemainingInShift: number;
318
393
  timeRemainingTillBreak: number;
@@ -335,4 +410,7 @@ declare const ConvexUpdateNested: z$1.ZodObject<{
335
410
  }>;
336
411
  type ConvexUpdateNested = z$1.infer<typeof ConvexUpdateNested>;
337
412
 
338
- export { ConvexUpdate, ConvexUpdateNested, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess };
413
+ declare function encryptRsaOaepSha256ToB64(plaintext: string, publicKeyPem: string): string;
414
+ declare function decryptRsaOaepSha256B64(ciphertextB64: string, privateKeyPem: string, passphrase?: string): string;
415
+
416
+ export { ConvexUpdate, ConvexUpdateNested, DriverIdentity, DriverLocation, DriverLogin, DriverStatus, HoursOfService, NewLoginRequest, NewLoginResponse, NewLoginResponseFailure, NewLoginResponseSuccess, VehicleIdentity, decryptRsaOaepSha256B64, encryptRsaOaepSha256ToB64 };
package/dist/index.js CHANGED
@@ -56,6 +56,10 @@ var ConvexUpdate = z2.object({
56
56
  username: z2.string().describe("The driver's login username"),
57
57
  password: z2.string().describe("The driver's login password"),
58
58
  driver_id: z2.string().optional().describe("The ELD's internal driver ID"),
59
+ driver_first_name: z2.string().optional().describe("The driver's first name"),
60
+ driver_last_name: z2.string().optional().describe("The driver's last name"),
61
+ driver_name: z2.string().optional().describe("The driver's full name"),
62
+ vehicle_id: z2.string().optional().describe("The vehicle ID"),
59
63
  driver_status: z2.string().describe("The driver's duty status (direct from ELD)"),
60
64
  time_remaining_in_shift: z2.number().describe("Seconds remaining in current shift"),
61
65
  time_remaining_till_break: z2.number().describe("Seconds remaining until next required break"),
@@ -84,16 +88,53 @@ var DriverLogin = z2.object({
84
88
  username: z2.string().describe("The driver's login username"),
85
89
  password: z2.string().describe("The driver's login password")
86
90
  }).describe("Schema for driver login information");
87
- var ConvexUpdateNested = z2.object({
91
+ var DriverIdentity = z2.object({
88
92
  driverId: z2.string().describe("The ELD's internal driver ID"),
93
+ driverFirstName: z2.string().optional().describe("The driver's first name"),
94
+ driverLastName: z2.string().optional().describe("The driver's last name"),
95
+ driverName: z2.string().optional().describe("The driver's full name")
96
+ }).describe("Schema for identifying the driver");
97
+ var VehicleIdentity = z2.object({
98
+ vehicleId: z2.string().optional().describe("The vehicle ID")
99
+ }).describe("Schema for identifying the vehicle");
100
+ var ConvexUpdateNested = z2.object({
101
+ driver: DriverIdentity,
102
+ vehicle: VehicleIdentity,
89
103
  hoursOfService: HoursOfService,
90
104
  driverLocation: DriverLocation,
91
105
  driverStatus: DriverStatus,
92
106
  driverLogin: DriverLogin
93
107
  }).describe("Nested schema for updating driver ELD status information");
108
+
109
+ // src/security/transit-crypto.ts
110
+ import { publicEncrypt, privateDecrypt, constants } from "crypto";
111
+ function encryptRsaOaepSha256ToB64(plaintext, publicKeyPem) {
112
+ const ciphertext = publicEncrypt(
113
+ {
114
+ key: publicKeyPem,
115
+ padding: constants.RSA_PKCS1_OAEP_PADDING,
116
+ oaepHash: "sha256"
117
+ },
118
+ Buffer.from(plaintext, "utf8")
119
+ );
120
+ return ciphertext.toString("base64");
121
+ }
122
+ function decryptRsaOaepSha256B64(ciphertextB64, privateKeyPem, passphrase) {
123
+ const plaintext = privateDecrypt(
124
+ {
125
+ key: privateKeyPem,
126
+ passphrase,
127
+ padding: constants.RSA_PKCS1_OAEP_PADDING,
128
+ oaepHash: "sha256"
129
+ },
130
+ Buffer.from(ciphertextB64, "base64")
131
+ );
132
+ return plaintext.toString("utf8");
133
+ }
94
134
  export {
95
135
  ConvexUpdate,
96
136
  ConvexUpdateNested,
137
+ DriverIdentity,
97
138
  DriverLocation,
98
139
  DriverLogin,
99
140
  DriverStatus,
@@ -101,5 +142,8 @@ export {
101
142
  NewLoginRequest,
102
143
  NewLoginResponse,
103
144
  NewLoginResponseFailure,
104
- NewLoginResponseSuccess
145
+ NewLoginResponseSuccess,
146
+ VehicleIdentity,
147
+ decryptRsaOaepSha256B64,
148
+ encryptRsaOaepSha256ToB64
105
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findatruck/shared-schemas",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -19,15 +19,20 @@
19
19
  "scripts": {
20
20
  "build": "tsup src/index.ts --dts --format esm,cjs --out-dir dist --clean",
21
21
  "prepublishOnly": "npm run build",
22
- "prepare": "npm run build"
22
+ "prepare": "npm run build",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "coverage": "vitest run --coverage"
23
26
  },
24
27
  "peerDependencies": {
25
28
  "zod": "^3.23.0"
26
29
  },
27
30
  "devDependencies": {
28
31
  "@changesets/cli": "^2.29.7",
32
+ "@types/node": "^24.7.0",
29
33
  "tsup": "^8.0.0",
30
- "typescript": "^5.6.0",
34
+ "typescript": "^5.9.3",
35
+ "vitest": "^3.2.4",
31
36
  "zod": "^3.23.0"
32
37
  }
33
38
  }