@delpa/mt-prisma 0.12.0 → 0.14.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.
@@ -63,6 +63,55 @@ enum FuelType {
63
63
  GAS
64
64
  }
65
65
 
66
+ enum PackagingType {
67
+ BOX
68
+ PALLET
69
+ CRATE
70
+ BARREL
71
+ BAG
72
+ ROLL
73
+ BUNDLE
74
+ CONTAINER
75
+ LOOSE
76
+ OTHER
77
+ }
78
+
79
+ enum ProductCategory {
80
+ ELECTRONICS
81
+ FOOD_BEVERAGE
82
+ PHARMACEUTICALS
83
+ TEXTILES
84
+ MACHINERY
85
+ CHEMICALS
86
+ CONSTRUCTION
87
+ AUTOMOTIVE
88
+ AGRICULTURE
89
+ FURNITURE
90
+ PAPER
91
+ PLASTICS
92
+ METALS
93
+ GLASS
94
+ OTHER
95
+ }
96
+
97
+ enum ProductSubcategory {
98
+ RAW_MATERIALS
99
+ FINISHED_GOODS
100
+ SEMI_FINISHED
101
+ SPARE_PARTS
102
+ CONSUMABLES
103
+ HAZARDOUS
104
+ FRAGILE
105
+ PERISHABLE
106
+ REFRIGERATED
107
+ FROZEN
108
+ BULK
109
+ LIQUID
110
+ OVERSIZED
111
+ HIGH_VALUE
112
+ OTHER
113
+ }
114
+
66
115
  enum AddressType {
67
116
  PICKUP
68
117
  DELIVERY
@@ -90,6 +139,48 @@ enum EquipmentStatus {
90
139
  MAINTENANCE
91
140
  }
92
141
 
142
+ enum GpsProviders {
143
+ BEERMAN
144
+ GETRAK
145
+ GPS_GLOBAL
146
+ GPS_CHILE
147
+ IGPS
148
+ MAVI_GPS
149
+ MICHELIN
150
+ RED_GPS
151
+ TRUCK_CONTROL
152
+ GYG
153
+ ONIX
154
+ SASCAR
155
+ }
156
+
157
+ model Product {
158
+ id String @id @default(uuid()) @db.Uuid
159
+ client_id String @db.Uuid
160
+ description String
161
+ sku String @unique
162
+ quantity Int @default(0)
163
+ packaging_type PackagingType @default(BOX)
164
+ category ProductCategory @default(OTHER)
165
+ subcategory ProductSubcategory @default(OTHER)
166
+ dimension_unit DimensionUnits @default(CM)
167
+ length Float?
168
+ width Float?
169
+ height Float?
170
+ weight_unit WeightUnits @default(KG)
171
+ weight Float?
172
+ is_active Boolean @default(true)
173
+ created_at DateTime @default(now())
174
+ updated_at DateTime @updatedAt
175
+
176
+ client Client @relation(fields: [client_id], references: [id], onDelete: Cascade)
177
+
178
+ @@index([client_id])
179
+ @@index([sku])
180
+ @@index([category])
181
+ @@map("products")
182
+ }
183
+
93
184
  model Client {
94
185
  id String @id @default(uuid()) @db.Uuid
95
186
  tax_id String?
@@ -107,6 +198,7 @@ model Client {
107
198
  contacts ClientContact[]
108
199
  orders_as_shipper Order[] @relation("shipper_client")
109
200
  handling_units_as_consignee HandlingUnit[]
201
+ products Product[]
110
202
 
111
203
  @@index([company_id])
112
204
  @@index([created_by])
@@ -184,6 +276,9 @@ model companies {
184
276
  vehicles Vehicle[]
185
277
  user_companies UserCompany[]
186
278
  equipments Equipment[]
279
+ form_templates FormTemplate[]
280
+ form_responses FormResponse[]
281
+ forms Form[]
187
282
 
188
283
  @@map("companies")
189
284
  }
@@ -234,9 +329,13 @@ model User {
234
329
  created_at DateTime @default(now())
235
330
  updated_at DateTime @updatedAt
236
331
 
237
- routes Route[]
238
- user_companies UserCompany[]
239
- sessions Session[]
332
+ routes Route[]
333
+ user_companies UserCompany[]
334
+ sessions Session[]
335
+ driverLocations DriverLocation[]
336
+ form_templates_created FormTemplate[]
337
+ form_responses FormResponse[]
338
+ forms_created Form[] @relation("FormCreator")
240
339
 
241
340
  @@map("users")
242
341
  }
@@ -322,11 +421,12 @@ model Vehicle {
322
421
  created_at DateTime @default(now())
323
422
  updated_at DateTime @updatedAt
324
423
 
325
- brand VehicleBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
326
- model VehicleModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
327
- company companies? @relation(fields: [company_id], references: [id], onDelete: Cascade)
328
- routes Route[]
329
- equipments Equipment[]
424
+ brand VehicleBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
425
+ model VehicleModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
426
+ company companies? @relation(fields: [company_id], references: [id], onDelete: Cascade)
427
+ routes Route[]
428
+ equipments Equipment[]
429
+ vehicleLocations VehicleLocation[]
330
430
 
331
431
  @@index([company_id])
332
432
  @@index([brand_id])
@@ -478,10 +578,11 @@ model Equipment {
478
578
  created_at DateTime @default(now())
479
579
  updated_at DateTime @updatedAt
480
580
 
481
- brand EquipmentBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
482
- model EquipmentModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
483
- company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
484
- vehicle Vehicle? @relation(fields: [vehicle_id], references: [id], onDelete: SetNull)
581
+ brand EquipmentBrand? @relation(fields: [brand_id], references: [id], onDelete: SetNull)
582
+ model EquipmentModel? @relation(fields: [model_id], references: [id], onDelete: SetNull)
583
+ company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
584
+ vehicle Vehicle? @relation(fields: [vehicle_id], references: [id], onDelete: SetNull)
585
+ vehicleLocations VehicleLocation[]
485
586
 
486
587
  @@index([company_id])
487
588
  @@index([brand_id])
@@ -490,3 +591,225 @@ model Equipment {
490
591
  @@index([plate])
491
592
  @@map("equipments")
492
593
  }
594
+
595
+ model VehicleLocation {
596
+ id String @id @default(uuid()) @db.Uuid
597
+ vehicle_id String? @db.Uuid
598
+ equiment_id String? @db.Uuid
599
+ provider GpsProviders?
600
+ plate String?
601
+ temperature Float?
602
+ voltage String?
603
+ odometer String?
604
+ batery_level String?
605
+ stopped_time String?
606
+ ignition_status Boolean?
607
+ current_speed Float?
608
+ latitude Float?
609
+ longitude Float?
610
+ metadata Json? @default("{}")
611
+ created_at DateTime @default(now())
612
+ updated_at DateTime @updatedAt
613
+
614
+ vehicle Vehicle? @relation(fields: [vehicle_id], references: [id], onDelete: SetNull)
615
+ equipment Equipment? @relation(fields: [equiment_id], references: [id], onDelete: SetNull)
616
+
617
+ @@index([vehicle_id])
618
+ @@index([equiment_id])
619
+ @@index([provider])
620
+ @@index([plate])
621
+ @@index([created_at])
622
+ @@map("vehicle_locations")
623
+ }
624
+
625
+ model DriverLocation {
626
+ id String @id @default(uuid()) @db.Uuid
627
+ driver_id String @db.Uuid
628
+ latitude Float
629
+ longitude Float
630
+ created_at DateTime @default(now())
631
+ updated_at DateTime @updatedAt
632
+
633
+ driver User @relation(fields: [driver_id], references: [id], onDelete: Cascade)
634
+
635
+ @@index([driver_id])
636
+ @@index([created_at])
637
+ @@map("driver_locations")
638
+ }
639
+
640
+ // ============================================
641
+ // FORMS - Form Templates, Fields and Responses
642
+ // ============================================
643
+
644
+ enum FieldType {
645
+ TEXT
646
+ TEXTAREA
647
+ NUMBER
648
+ EMAIL
649
+ PHONE
650
+ DATE
651
+ DATETIME
652
+ TIME
653
+ SELECT
654
+ MULTISELECT
655
+ CHECKBOX
656
+ RADIO
657
+ FILE
658
+ IMAGE
659
+ SIGNATURE
660
+ LOCATION
661
+ }
662
+
663
+ enum FormResponseStatus {
664
+ DRAFT
665
+ SUBMITTED
666
+ APPROVED
667
+ REJECTED
668
+ }
669
+
670
+ model FormTemplate {
671
+ id String @id @default(uuid()) @db.Uuid
672
+ name String
673
+ description String?
674
+ company_id String? @db.Uuid
675
+ is_active Boolean @default(true)
676
+ is_global Boolean @default(false)
677
+ category String?
678
+ version Int @default(1)
679
+ created_by String? @db.Uuid
680
+ created_at DateTime @default(now())
681
+ updated_at DateTime @updatedAt
682
+
683
+ company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
684
+ created_by_user User? @relation(fields: [created_by], references: [id], onDelete: SetNull)
685
+ fields TemplateField[]
686
+ responses FormResponse[]
687
+ forms Form[]
688
+
689
+ @@index([company_id])
690
+ @@index([is_global])
691
+ @@index([category])
692
+ @@index([is_active])
693
+ @@map("form_templates")
694
+ }
695
+
696
+ model TemplateField {
697
+ id String @id @default(uuid()) @db.Uuid
698
+ template_id String @db.Uuid
699
+ label String
700
+ field_type FieldType
701
+ placeholder String?
702
+ help_text String?
703
+ is_required Boolean @default(false)
704
+ order Int @default(0)
705
+ options Json?
706
+ validations Json?
707
+ default_value String?
708
+ conditional_logic Json?
709
+ created_at DateTime @default(now())
710
+ updated_at DateTime @updatedAt
711
+
712
+ template FormTemplate @relation(fields: [template_id], references: [id], onDelete: Cascade)
713
+
714
+ @@index([template_id])
715
+ @@map("template_fields")
716
+ }
717
+
718
+ model FormResponse {
719
+ id String @id @default(uuid()) @db.Uuid
720
+ template_id String? @db.Uuid
721
+ form_id String? @db.Uuid
722
+ entity_type String
723
+ entity_id String @db.Uuid
724
+ company_id String? @db.Uuid
725
+ respondent_id String? @db.Uuid
726
+ responses Json
727
+ status FormResponseStatus @default(DRAFT)
728
+ submitted_at DateTime?
729
+ created_at DateTime @default(now())
730
+ updated_at DateTime @updatedAt
731
+
732
+ template FormTemplate? @relation(fields: [template_id], references: [id])
733
+ form Form? @relation(fields: [form_id], references: [id])
734
+ company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
735
+ respondent User? @relation(fields: [respondent_id], references: [id], onDelete: SetNull)
736
+
737
+ @@index([template_id])
738
+ @@index([form_id])
739
+ @@index([entity_type, entity_id])
740
+ @@index([company_id])
741
+ @@index([status])
742
+ @@map("form_responses")
743
+ }
744
+
745
+ // ============================================
746
+ // FORMS - Created forms from templates
747
+ // ============================================
748
+
749
+ enum FormTargetType {
750
+ DRIVER
751
+ VEHICLE
752
+ COMPANY_PARTNER
753
+ CLIENT
754
+ ORDER
755
+ ROUTE
756
+ }
757
+
758
+ enum FormStatus {
759
+ ACTIVE
760
+ COMPLETED
761
+ CANCELLED
762
+ EXPIRED
763
+ }
764
+
765
+ model Form {
766
+ id String @id @default(uuid()) @db.Uuid
767
+ name String
768
+ description String?
769
+ template_id String? @db.Uuid
770
+ company_id String? @db.Uuid
771
+ target_type FormTargetType
772
+ target_ids String[] @db.Uuid
773
+ is_required Boolean @default(false)
774
+ due_date DateTime?
775
+ status FormStatus @default(ACTIVE)
776
+ created_by String? @db.Uuid
777
+ created_at DateTime @default(now())
778
+ updated_at DateTime @updatedAt
779
+
780
+ template FormTemplate? @relation(fields: [template_id], references: [id], onDelete: SetNull)
781
+ company companies? @relation(fields: [company_id], references: [id], onDelete: SetNull)
782
+ created_by_user User? @relation("FormCreator", fields: [created_by], references: [id], onDelete: SetNull)
783
+ fields FormField[]
784
+ responses FormResponse[]
785
+
786
+ @@index([company_id])
787
+ @@index([template_id])
788
+ @@index([target_type])
789
+ @@index([status])
790
+ @@index([due_date])
791
+ @@map("forms")
792
+ }
793
+
794
+ model FormField {
795
+ id String @id @default(uuid()) @db.Uuid
796
+ form_id String @db.Uuid
797
+ source_field_id String? @db.Uuid
798
+ label String
799
+ field_type FieldType
800
+ placeholder String?
801
+ help_text String?
802
+ is_required Boolean @default(false)
803
+ order Int @default(0)
804
+ options Json?
805
+ validations Json?
806
+ default_value String?
807
+ conditional_logic Json?
808
+ created_at DateTime @default(now())
809
+ updated_at DateTime @updatedAt
810
+
811
+ form Form @relation(fields: [form_id], references: [id], onDelete: Cascade)
812
+
813
+ @@index([form_id])
814
+ @@map("form_fields")
815
+ }