@routeflow/types 1.0.0 → 1.0.3

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/src/exports.ts CHANGED
@@ -3,9 +3,13 @@
3
3
  *
4
4
  * Type Flow: Prisma → API DTOs → OpenAPI → here → SDK → Client Apps
5
5
  *
6
- * NOTE: Response/Entity types are defined manually here until the API
7
- * adds proper Response DTOs with @ApiResponse decorators. Once that's done,
8
- * these can be replaced with generated types.
6
+ * IMPORTANT:
7
+ * - Types that have Response DTOs in API are re-exported from generated types
8
+ * - Types WITHOUT Response DTOs (Organization, User, Driver, Run, Stop, etc.)
9
+ * are temporarily defined manually until API adds proper Response DTOs
10
+ *
11
+ * TODO: Once API adds Response DTOs for all entities, convert ALL manual
12
+ * definitions to re-exports from components['schemas']
9
13
  */
10
14
 
11
15
  import type { components, paths, operations } from './index.js';
@@ -16,11 +20,22 @@ export type { components, paths, operations };
16
20
  // ============================================================================
17
21
  // ENUMS (match Prisma schema enums)
18
22
  // ============================================================================
23
+ // These should match the Prisma enums exactly
19
24
 
20
- export type Role = 'ADMIN' | 'DISPATCHER' | 'DRIVER';
25
+ export type Role = 'ADMIN' | 'OWNER' | 'FLEET_MANAGER' | 'DISPATCHER' | 'ACCOUNTING' | 'DRIVER' | 'BROKER';
21
26
 
22
27
  export type RunStatus = 'DRAFT' | 'ASSIGNED' | 'IN_PROGRESS' | 'COMPLETED' | 'CANCELLED';
23
28
 
29
+ export type CancellationReason =
30
+ | 'CUSTOMER_CANCELLED'
31
+ | 'DRIVER_CANCELLED'
32
+ | 'EQUIPMENT_ISSUE'
33
+ | 'WEATHER'
34
+ | 'RATE_DISPUTE'
35
+ | 'SCHEDULING_CONFLICT'
36
+ | 'NO_SHOW'
37
+ | 'OTHER';
38
+
24
39
  export type StopType = 'PICKUP' | 'DELIVERY';
25
40
 
26
41
  export type StopStatus =
@@ -66,10 +81,56 @@ export type DriverDispatchStatus =
66
81
  | 'DISPATCHED'
67
82
  | 'ASSIGNED';
68
83
 
84
+ export type CustomerType = 'BROKER' | 'SHIPPER' | 'CARRIER';
85
+
86
+ export type StatementStatus = 'DRAFT' | 'PENDING' | 'APPROVED' | 'PAID';
87
+
88
+ export type MessageType = 'TEXT' | 'IMAGE' | 'DOCUMENT' | 'SYSTEM';
89
+
90
+ export type ParsedDocumentStatus = 'PENDING' | 'PROCESSED' | 'FAILED' | 'NEEDS_REVIEW';
91
+
92
+ export type ExtractedAssetType = 'DRIVER' | 'TRUCK' | 'TRAILER';
93
+
94
+ export type ExtractedAssetStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'MERGED';
95
+
96
+ // ============================================================================
97
+ // ENTITY TYPES - WITH Response DTOs (✅ Re-exported from generated types)
98
+ // ============================================================================
99
+
100
+ // Customer (has ResponseDto in API)
101
+ export type Customer = components['schemas']['CustomerResponseDto'];
102
+ export type CustomerList = components['schemas']['CustomerListResponseDto'];
103
+
104
+ // Message (has ResponseDto in API)
105
+ export type Message = components['schemas']['MessageResponseDto'];
106
+ export type MessageList = components['schemas']['MessageListResponseDto'];
107
+
108
+ // Statement (has ResponseDto in API)
109
+ export type DriverStatement = components['schemas']['StatementResponseDto'];
110
+ export type StatementList = components['schemas']['StatementListResponseDto'];
111
+
112
+ // Referral (has ResponseDto in API)
113
+ export type Referral = components['schemas']['ReferralResponseDto'];
114
+ export type ReferralList = components['schemas']['ReferralListResponseDto'];
115
+ export type ReferralStats = components['schemas']['ReferralStatsDto'];
116
+
117
+ // Extracted Assets (has ResponseDto in API)
118
+ export type ExtractedAsset = components['schemas']['ExtractedAssetResponseDto'];
119
+ export type ExtractedAssetField = components['schemas']['ExtractedAssetFieldDto'];
120
+ export type ExtractionResult = components['schemas']['ExtractionResultResponseDto'];
121
+ export type PaginatedExtractions = components['schemas']['PaginatedExtractionsResponseDto'];
122
+ export type BulkOperationResult = components['schemas']['BulkOperationResponseDto'];
123
+
124
+ // Smart Parse (has DTOs in API)
125
+ export type SmartParseDocument = components['schemas']['SmartParseDocumentDto'];
126
+ export type SmartParseResult = components['schemas']['SmartParseResultDto'];
127
+ export type SuggestedDriver = components['schemas']['SuggestedDriverDto'];
128
+ export type SuggestedCustomer = components['schemas']['SuggestedCustomerDto'];
129
+
69
130
  // ============================================================================
70
- // ENTITY TYPES (Response types - match Prisma models)
71
- // TODO: Replace with generated types once API has Response DTOs
131
+ // ENTITY TYPES - WITHOUT Response DTOs (⚠️ Temporary manual definitions)
72
132
  // ============================================================================
133
+ // TODO: Replace with re-exports once API adds Response DTOs
73
134
 
74
135
  export interface Organization {
75
136
  id: string;
@@ -111,19 +172,30 @@ export interface Driver {
111
172
  export interface Run {
112
173
  id: string;
113
174
  name: string;
175
+ loadNumber: string | null;
114
176
  status: RunStatus;
115
177
  plannedDate: string;
116
178
  plannedEndDate: string | null;
117
179
  startedAt: string | null;
118
180
  completedAt: string | null;
181
+ cancelledAt: string | null;
182
+ cancellationReason: CancellationReason | null;
183
+ cancellationNotes: string | null;
119
184
  totalDistance: number | null;
120
185
  totalDuration: number | null;
186
+ totalPay: number | null;
187
+ equipmentType: string | null;
188
+ commodityDesc: string | null;
189
+ weight: number | null;
121
190
  orgId: string;
122
191
  driverId: string | null;
192
+ customerId: string | null;
123
193
  createdById: string;
194
+ cancelledById: string | null;
124
195
  createdAt: string;
125
196
  updatedAt: string;
126
197
  driver?: User;
198
+ customer?: Customer;
127
199
  stops?: Stop[];
128
200
  documents?: Document[];
129
201
  }
@@ -133,12 +205,14 @@ export interface Stop {
133
205
  sequence: number;
134
206
  type: StopType;
135
207
  status: StopStatus;
208
+ facilityName: string | null;
136
209
  address: string;
137
210
  lat: number;
138
211
  lng: number;
139
212
  contactName: string | null;
140
213
  contactPhone: string | null;
141
214
  notes: string | null;
215
+ referenceNumber: string | null;
142
216
  timeWindowStart: string | null;
143
217
  timeWindowEnd: string | null;
144
218
  arrivedAt: string | null;
@@ -248,6 +322,33 @@ export interface CompanyDocument {
248
322
  updatedAt: string;
249
323
  }
250
324
 
325
+ export interface ParsedDocument {
326
+ id: string;
327
+ originalFileUrl: string;
328
+ fileName: string | null;
329
+ mimeType: string | null;
330
+ fileSize: number | null;
331
+ status: ParsedDocumentStatus;
332
+ parsedData: Record<string, unknown> | null;
333
+ confidence: number | null;
334
+ errorMessage: string | null;
335
+ createdRunId: string | null;
336
+ matchedCustomerId: string | null;
337
+ suggestedDriverId: string | null;
338
+ uploadedById: string;
339
+ orgId: string;
340
+ createdAt: string;
341
+ updatedAt: string;
342
+ }
343
+
344
+ export interface StatementLineItem {
345
+ description: string;
346
+ type: 'EARNING' | 'DEDUCTION';
347
+ amount: number;
348
+ runId?: string;
349
+ loadNumber?: string;
350
+ }
351
+
251
352
  // ============================================================================
252
353
  // AUTH RESPONSE TYPES
253
354
  // ============================================================================
@@ -312,43 +413,77 @@ export interface TodaysRunsResponse {
312
413
  }
313
414
 
314
415
  // ============================================================================
315
- // REQUEST DTOs (from OpenAPI - these are generated)
416
+ // REQUEST DTOs ( Re-exported from generated types)
316
417
  // ============================================================================
317
418
 
419
+ // Auth DTOs
318
420
  export type RegisterDto = components['schemas']['RegisterDto'];
319
421
  export type LoginDto = components['schemas']['LoginDto'];
320
422
  export type TelegramAuthDto = components['schemas']['TelegramAuthDto'];
321
423
  export type TelegramLinkDto = components['schemas']['TelegramLinkDto'];
322
424
  export type RefreshTokenDto = components['schemas']['RefreshTokenDto'];
323
425
 
426
+ // User DTOs
324
427
  export type CreateUserDto = components['schemas']['CreateUserDto'];
325
428
  export type UpdateUserDto = components['schemas']['UpdateUserDto'];
326
429
  export type LinkTelegramDto = components['schemas']['LinkTelegramDto'];
327
430
 
431
+ // Organization DTOs
328
432
  export type CreateOrgDto = components['schemas']['CreateOrgDto'];
329
433
  export type UpdateOrgDto = components['schemas']['UpdateOrgDto'];
330
434
  export type InviteUserDto = components['schemas']['InviteUserDto'];
331
435
 
436
+ // Run DTOs
332
437
  export type CreateRunDto = components['schemas']['CreateRunDto'];
333
438
  export type UpdateRunDto = components['schemas']['UpdateRunDto'];
334
439
  export type AssignDriverDto = components['schemas']['AssignDriverDto'];
335
440
 
441
+ // Stop DTOs
336
442
  export type CreateStopDto = components['schemas']['CreateStopDto'];
337
443
  export type UpdateStopDto = components['schemas']['UpdateStopDto'];
338
444
  export type ReorderStopsDto = components['schemas']['ReorderStopsDto'];
339
445
  export type UpdateStopStatusDto = components['schemas']['UpdateStopStatusDto'];
340
446
 
447
+ // Document DTOs
341
448
  export type CreateDocumentDto = components['schemas']['CreateDocumentDto'];
342
449
  export type CreateCompanyDocumentDto = components['schemas']['CreateCompanyDocumentDto'];
343
450
 
451
+ // Magic Link DTOs
344
452
  export type CreateMagicLinkDto = components['schemas']['CreateMagicLinkDto'];
345
453
 
454
+ // Asset DTOs
346
455
  export type CreateTruckDto = components['schemas']['CreateTruckDto'];
347
456
  export type UpdateTruckDto = components['schemas']['UpdateTruckDto'];
348
457
  export type CreateTrailerDto = components['schemas']['CreateTrailerDto'];
349
458
  export type UpdateTrailerDto = components['schemas']['UpdateTrailerDto'];
350
459
  export type AssignAssetDto = components['schemas']['AssignAssetDto'];
351
460
 
461
+ // Customer DTOs
462
+ export type CreateCustomerDto = components['schemas']['CreateCustomerDto'];
463
+ export type UpdateCustomerDto = components['schemas']['UpdateCustomerDto'];
464
+
465
+ // Message DTOs
466
+ export type CreateMessageDto = components['schemas']['CreateMessageDto'];
467
+ export type MarkReadDto = components['schemas']['MarkReadDto'];
468
+
469
+ // Statement DTOs
470
+ export type CreateStatementDto = components['schemas']['CreateStatementDto'];
471
+ export type UpdateStatementDto = components['schemas']['UpdateStatementDto'];
472
+ export type GenerateStatementDto = components['schemas']['GenerateStatementDto'];
473
+
474
+ // Referral DTOs
475
+ export type CreateReferralDto = components['schemas']['CreateReferralDto'];
476
+ export type UpdateReferralDto = components['schemas']['UpdateReferralDto'];
477
+
478
+ // Document Processing DTOs
479
+ export type ParseRateConDto = components['schemas']['ParseRateConDto'];
480
+ export type ExtractAssetsDto = components['schemas']['ExtractAssetsDto'];
481
+ export type ApproveExtractionDto = components['schemas']['ApproveExtractionDto'];
482
+ export type RejectExtractionDto = components['schemas']['RejectExtractionDto'];
483
+ export type MergeExtractionDto = components['schemas']['MergeExtractionDto'];
484
+ export type BulkApproveDto = components['schemas']['BulkApproveDto'];
485
+ export type BulkRejectDto = components['schemas']['BulkRejectDto'];
486
+
352
487
  // ============================================================================
353
488
  // REQUEST TYPE ALIASES (for SDK compatibility)
354
489
  // ============================================================================
@@ -364,6 +499,17 @@ export type UpdateRunRequest = UpdateRunDto;
364
499
  export type CreateStopRequest = CreateStopDto;
365
500
  export type UpdateStopRequest = UpdateStopDto;
366
501
 
502
+ export type CreateCustomerRequest = CreateCustomerDto;
503
+ export type UpdateCustomerRequest = UpdateCustomerDto;
504
+
505
+ export type CreateMessageRequest = CreateMessageDto;
506
+
507
+ export type CreateStatementRequest = CreateStatementDto;
508
+ export type UpdateStatementRequest = UpdateStatementDto;
509
+
510
+ export type CreateReferralRequest = CreateReferralDto;
511
+ export type UpdateReferralRequest = UpdateReferralDto;
512
+
367
513
  // ============================================================================
368
514
  // PAGINATION TYPES
369
515
  // ============================================================================
@@ -385,6 +531,9 @@ export type PaginatedStops = PaginatedResponse<Stop>;
385
531
  export type PaginatedDrivers = PaginatedResponse<User>;
386
532
  export type PaginatedTrucks = PaginatedResponse<Truck>;
387
533
  export type PaginatedTrailers = PaginatedResponse<Trailer>;
534
+ export type PaginatedCustomers = PaginatedResponse<Customer>;
535
+ export type PaginatedStatements = PaginatedResponse<DriverStatement>;
536
+ export type PaginatedMessages = PaginatedResponse<Message>;
388
537
 
389
538
  // ============================================================================
390
539
  // TYPE HELPERS
@@ -400,3 +549,6 @@ export type QueryParams<T extends keyof paths, M extends keyof paths[T]> =
400
549
 
401
550
  export type RequestBody<T extends keyof paths, M extends keyof paths[T]> =
402
551
  paths[T][M] extends { requestBody: { content: { 'application/json': infer B } } } ? B : never;
552
+
553
+ export type ResponseBody<T extends keyof paths, M extends keyof paths[T]> =
554
+ paths[T][M] extends { responses: { 200: { content: { 'application/json': infer R } } } } ? R : never;