@litusarchieve18/agricore-utils 1.0.13 → 1.0.15

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/README.md CHANGED
@@ -183,7 +183,11 @@ Run the publish command:
183
183
  Bash
184
184
  npm publish --access public
185
185
  📝 Version History
186
- V1.0.12 — add DocumentMenuMap and refactoring library code to export enum
186
+ V1.0.15 — add some standardized enum and types for CAR
187
+
188
+ V1.0.14 — add DOCUMENT_DISPLAY_INFO do manage the grouping and a little description for UI
189
+
190
+ V1.0.13 — add DocumentMenuMap and refactoring library code to export enum
187
191
 
188
192
  V1.0.12 — add some functionality to add a file tag
189
193
 
@@ -140,7 +140,10 @@ var TaskType = {
140
140
  KML_PARSE: "KML_PARSE",
141
141
  INVOICE_OCR: "INVOICE_OCR",
142
142
  AUDIT_UPLOAD: "AUDIT_UPLOAD",
143
- REPORT_GEN: "REPORT_GEN"
143
+ REPORT_GEN: "REPORT_GEN",
144
+ PDF_STAMPING: "PDF_STAMPING",
145
+ CAR_TEMPLATE_UPLOAD: "CAR_TEMPLATE_UPLOAD",
146
+ CORRECTIVE_ACTION_COMPILE: "CORRECTIVE_ACTION_COMPILE"
144
147
  };
145
148
  var TaskStatus = {
146
149
  PENDING: "PENDING",
@@ -499,6 +502,194 @@ var DocumentType = /* @__PURE__ */ ((DocumentType2) => {
499
502
  DocumentType2["SENSITIVE_IDENTITY"] = "SENSITIVE_IDENTITY";
500
503
  return DocumentType2;
501
504
  })(DocumentType || {});
505
+ var DocumentCategory = /* @__PURE__ */ ((DocumentCategory2) => {
506
+ DocumentCategory2["AGRONOMY_TESTING"] = "Agronomy & Testing";
507
+ DocumentCategory2["FARM_OPERATIONS"] = "Farm Operations";
508
+ DocumentCategory2["COMPLIANCE_QA"] = "Compliance & Quality";
509
+ DocumentCategory2["INVENTORY_LOG"] = "Inventory & Logistics";
510
+ DocumentCategory2["ASSETS_MAINT"] = "Assets & Maintenance";
511
+ DocumentCategory2["HR_LEGAL_SAFETY"] = "HR, Legal & Safety";
512
+ DocumentCategory2["FINANCE_ADMIN"] = "Finance & Admin";
513
+ return DocumentCategory2;
514
+ })(DocumentCategory || {});
515
+ var DOCUMENT_DISPLAY_INFO = {
516
+ // --- AGRONOMY & TESTING ---
517
+ ["SOIL_TEST" /* SOIL_TEST */]: {
518
+ label: "Soil Analysis",
519
+ description: "Detailed lab results for soil nutrients, pH, and health.",
520
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
521
+ },
522
+ ["LEAF_TEST" /* LEAF_TEST */]: {
523
+ label: "Leaf & Tissue Test",
524
+ description: "Nutrient analysis of plant tissue samples.",
525
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
526
+ },
527
+ ["WATER_TEST" /* WATER_TEST */]: {
528
+ label: "Water Quality Test",
529
+ description: "Testing for irrigation suitability and microbial levels.",
530
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
531
+ },
532
+ ["MRL_TESTING" /* MRL_TESTING */]: {
533
+ label: "MRL Residue Analysis",
534
+ description: "Maximum Residue Limit reports for chemical compliance.",
535
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
536
+ },
537
+ ["HEAVY_METAL" /* HEAVY_METAL */]: {
538
+ label: "Heavy Metal Analysis",
539
+ description: "Testing for lead, cadmium, and other metal contaminants.",
540
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
541
+ },
542
+ ["MICROBIAL" /* MICROBIAL */]: {
543
+ label: "Microbial Testing",
544
+ description: "Pathogen detection reports (e.g., E. coli, Salmonella).",
545
+ category: "Agronomy & Testing" /* AGRONOMY_TESTING */
546
+ },
547
+ // --- FARM OPERATIONS ---
548
+ ["SPRAY_RECORD" /* SPRAY_RECORD */]: {
549
+ label: "Spray Operations",
550
+ description: "Chemical application logs and weather conditions.",
551
+ category: "Farm Operations" /* FARM_OPERATIONS */
552
+ },
553
+ ["FERTIGATION_RECORD" /* FERTIGATION_RECORD */]: {
554
+ label: "Fertigation Logs",
555
+ description: "Records of liquid fertilizer applied via irrigation.",
556
+ category: "Farm Operations" /* FARM_OPERATIONS */
557
+ },
558
+ ["FERTILIZER_RECORD" /* FERTILIZER_RECORD */]: {
559
+ label: "Fertilizer Records",
560
+ description: "Manual granular or bulk fertilizer application logs.",
561
+ category: "Farm Operations" /* FARM_OPERATIONS */
562
+ },
563
+ ["HARVEST_LOG" /* HARVEST_LOG */]: {
564
+ label: "Harvest Manifests",
565
+ description: "Daily picking volumes and block yield data.",
566
+ category: "Farm Operations" /* FARM_OPERATIONS */
567
+ },
568
+ ["PACKHOUSE_INSPECTION" /* PACKHOUSE_INSPECTION */]: {
569
+ label: "Packhouse Inspections",
570
+ description: "Quality and hygiene checks conducted in the packhouse.",
571
+ category: "Farm Operations" /* FARM_OPERATIONS */
572
+ },
573
+ ["MAPPING_TRAFIC_MANAGEMENT" /* MAPPING_TRAFIC_MANAGEMENT */]: {
574
+ label: "Traffic Management",
575
+ description: "Maps and rules for vehicle and heavy machinery movement.",
576
+ category: "Farm Operations" /* FARM_OPERATIONS */
577
+ },
578
+ // --- COMPLIANCE & QUALITY ---
579
+ ["QA" /* QA */]: {
580
+ label: "Quality Assurance",
581
+ description: "General product quality checks and grading standards.",
582
+ category: "Compliance & Quality" /* COMPLIANCE_QA */
583
+ },
584
+ ["PEST" /* PEST */]: {
585
+ label: "Pest & Disease Monitoring",
586
+ description: "Scouting reports and pest pressure assessments.",
587
+ category: "Compliance & Quality" /* COMPLIANCE_QA */
588
+ },
589
+ ["AUDIT_REPORT" /* AUDIT_REPORT */]: {
590
+ label: "External Audit Reports",
591
+ description: "Final results from Freshcare, GlobalGAP, or Organic audits.",
592
+ category: "Compliance & Quality" /* COMPLIANCE_QA */
593
+ },
594
+ ["RISK_ASSESSMENTS" /* RISK_ASSESSMENTS */]: {
595
+ label: "Risk Assessments",
596
+ description: "Operational hazard identification and safety mitigations.",
597
+ category: "Compliance & Quality" /* COMPLIANCE_QA */
598
+ },
599
+ // --- ASSETS & MAINTENANCE ---
600
+ ["SERVICING_MAINTENANCE" /* SERVICING_MAINTENANCE */]: {
601
+ label: "Equipment Maintenance",
602
+ description: "Service history and repair logs for farm machinery.",
603
+ category: "Assets & Maintenance" /* ASSETS_MAINT */
604
+ },
605
+ ["EQUIPMENT_CALIBRATION_RECORD" /* EQUIPMENT_CALIBRATION_RECORD */]: {
606
+ label: "Calibration Records",
607
+ description: "Accuracy checks for sprayers, scales, and moisture probes.",
608
+ category: "Assets & Maintenance" /* ASSETS_MAINT */
609
+ },
610
+ ["CLEANING" /* CLEANING */]: {
611
+ label: "Sanitation Logs",
612
+ description: "Daily/weekly cleaning schedules for tools and facilities.",
613
+ category: "Assets & Maintenance" /* ASSETS_MAINT */
614
+ },
615
+ ["MAPPING_FARM_MAPS" /* MAPPING_FARM_MAPS */]: {
616
+ label: "Farm Infrastructure Maps",
617
+ description: "Layouts of blocks, irrigation, and fixed assets.",
618
+ category: "Assets & Maintenance" /* ASSETS_MAINT */
619
+ },
620
+ // --- INVENTORY & LOGISTICS ---
621
+ ["INVENTORY_CHEMICALS" /* INVENTORY_CHEMICALS */]: {
622
+ label: "Chemical Inventory",
623
+ description: "Manifests for stored pesticides and fertilizers.",
624
+ category: "Inventory & Logistics" /* INVENTORY_LOG */
625
+ },
626
+ ["INVENTORY_BOX_CARTON" /* INVENTORY_BOX_CARTON */]: {
627
+ label: "Packaging Inventory",
628
+ description: "Stock levels for cartons, bins, and packaging materials.",
629
+ category: "Inventory & Logistics" /* INVENTORY_LOG */
630
+ },
631
+ ["INVENTORY_CONSUMABLES" /* INVENTORY_CONSUMABLES */]: {
632
+ label: "General Consumables",
633
+ description: "Stock tracking for fuel, PPE, and workshop supplies.",
634
+ category: "Inventory & Logistics" /* INVENTORY_LOG */
635
+ },
636
+ ["STOCKTAKE" /* STOCKTAKE */]: {
637
+ label: "Physical Stocktake",
638
+ description: "Periodic audits of physical vs. recorded stock levels.",
639
+ category: "Inventory & Logistics" /* INVENTORY_LOG */
640
+ },
641
+ ["STOCKTAKE_MSDS" /* STOCKTAKE_MSDS */]: {
642
+ label: "MSDS / Safety Data",
643
+ description: "Material Safety Data Sheets for stored chemicals.",
644
+ category: "Inventory & Logistics" /* INVENTORY_LOG */
645
+ },
646
+ // --- HR, LEGAL & SAFETY ---
647
+ ["TRAINING_RECORDS" /* TRAINING_RECORDS */]: {
648
+ label: "Staff Inductions",
649
+ description: "General staff onboarding and safety training logs.",
650
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
651
+ },
652
+ ["TRAINING_CERTIFICATE" /* TRAINING_CERTIFICATE */]: {
653
+ label: "Training Certificates",
654
+ description: "External licenses, ChemCert, and first aid tickets.",
655
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
656
+ },
657
+ ["SOPS" /* SOPS */]: {
658
+ label: "Standard Procedures (SOPs)",
659
+ description: "Formalized instructions for farm and packhouse tasks.",
660
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
661
+ },
662
+ ["LEGAL_CONTRACT" /* LEGAL_CONTRACT */]: {
663
+ label: "Legal Contracts",
664
+ description: "Lease agreements, supply contracts, and employment terms.",
665
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
666
+ },
667
+ ["INCIDENT_REPORT" /* INCIDENT_REPORT */]: {
668
+ label: "Incident Reports",
669
+ description: "Logs of injuries, near-misses, or property damage.",
670
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
671
+ },
672
+ ["SENSITIVE_IDENTITY" /* SENSITIVE_IDENTITY */]: {
673
+ label: "Identity & Visas",
674
+ description: "Sensitive data: Passports, ID cards, and work permits.",
675
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
676
+ },
677
+ ["MAPPING_EMERGENCY" /* MAPPING_EMERGENCY */]: {
678
+ label: "Emergency Response Maps",
679
+ description: "Evacuation routes and emergency assembly points.",
680
+ category: "HR, Legal & Safety" /* HR_LEGAL_SAFETY */
681
+ },
682
+ // --- FINANCE & ADMIN ---
683
+ ["INVOICE" /* INVOICE */]: {
684
+ label: "Supplier Invoices",
685
+ description: "Billing records for inputs, utilities, and services.",
686
+ category: "Finance & Admin" /* FINANCE_ADMIN */
687
+ }
688
+ };
689
+ var CATEGORY_TABS = [
690
+ "All",
691
+ ...Object.values(DocumentCategory)
692
+ ];
502
693
  var DOCUMENT_MENU_MAP = {
503
694
  ["SPRAY_RECORD" /* SPRAY_RECORD */]: [RESOURCE_PATHS.farmManagement],
504
695
  ["FERTIGATION_RECORD" /* FERTIGATION_RECORD */]: [RESOURCE_PATHS.farmManagement],
@@ -534,6 +725,36 @@ var DOCUMENT_MENU_MAP = {
534
725
  ["AUDIT_REPORT" /* AUDIT_REPORT */]: [RESOURCE_PATHS.safetyAuditing, RESOURCE_PATHS.dashboard],
535
726
  ["SENSITIVE_IDENTITY" /* SENSITIVE_IDENTITY */]: [RESOURCE_PATHS.adminUserRoster]
536
727
  };
728
+ var SIGNATURE_MODES = {
729
+ TYPED_NAME: "typed_name",
730
+ DRAWN_IMAGE: "drawn_image",
731
+ UPLOADED_IMAGE: "uploaded_image"
732
+ };
733
+ var CORRECTIVE_ACTION_STATUSES = {
734
+ DRAFT: "draft",
735
+ GENERATED: "generated",
736
+ REVIEWED: "reviewed",
737
+ CLOSED: "closed",
738
+ FAILED: "failed"
739
+ };
740
+ var TEMPLATE_SCOPE_LEVELS = {
741
+ FACILITY: "facility",
742
+ LEGAL_ENTITY: "legalEntity",
743
+ COMPANY: "company"
744
+ };
745
+ var CORRECTIVE_ACTION_GENERATION_SOURCES = {
746
+ CREATE: "CREATE",
747
+ RECREATE: "RECREATE"
748
+ };
749
+ var CAR_SUPPORTED_EVIDENCE_MIME_TYPES = [
750
+ "application/pdf",
751
+ "image/png",
752
+ "image/jpeg"
753
+ ];
754
+ var CAR_SUPPORTED_SIGNATURE_MIME_TYPES = [
755
+ "image/png",
756
+ "image/jpeg"
757
+ ];
537
758
 
538
759
  export {
539
760
  MOD,
@@ -581,5 +802,14 @@ export {
581
802
  EVERYONE,
582
803
  RESOURCE_REQUIREMENTS,
583
804
  DocumentType,
584
- DOCUMENT_MENU_MAP
805
+ DocumentCategory,
806
+ DOCUMENT_DISPLAY_INFO,
807
+ CATEGORY_TABS,
808
+ DOCUMENT_MENU_MAP,
809
+ SIGNATURE_MODES,
810
+ CORRECTIVE_ACTION_STATUSES,
811
+ TEMPLATE_SCOPE_LEVELS,
812
+ CORRECTIVE_ACTION_GENERATION_SOURCES,
813
+ CAR_SUPPORTED_EVIDENCE_MIME_TYPES,
814
+ CAR_SUPPORTED_SIGNATURE_MIME_TYPES
585
815
  };
@@ -76,6 +76,82 @@ interface InfrastructureFields {
76
76
  facilityId: string | null;
77
77
  authScopeId: string;
78
78
  }
79
+ /**
80
+ * Base44 ID alias for readability only.
81
+ * Still just string at runtime.
82
+ */
83
+ type Base44Id = string;
84
+ /**
85
+ * Canonical UUID alias for readability only.
86
+ */
87
+ type CanonicalId = string;
88
+ /**
89
+ * Derived union types from constants.
90
+ */
91
+ type SignatureMode = typeof SIGNATURE_MODES[keyof typeof SIGNATURE_MODES];
92
+ type CorrectiveActionStatus = typeof CORRECTIVE_ACTION_STATUSES[keyof typeof CORRECTIVE_ACTION_STATUSES];
93
+ type FileUploadTaskType = typeof TaskType[keyof typeof TaskType];
94
+ type TemplateScopeLevel = typeof TEMPLATE_SCOPE_LEVELS[keyof typeof TEMPLATE_SCOPE_LEVELS];
95
+ type CorrectiveActionGenerationSource = typeof CORRECTIVE_ACTION_GENERATION_SOURCES[keyof typeof CORRECTIVE_ACTION_GENERATION_SOURCES];
96
+ type CarSupportedEvidenceMimeType = typeof CAR_SUPPORTED_EVIDENCE_MIME_TYPES[number];
97
+ type CarSupportedSignatureMimeType = typeof CAR_SUPPORTED_SIGNATURE_MIME_TYPES[number];
98
+ /**
99
+ * Shared signature payload used by create/preview CAR requests.
100
+ * typed_name stores text only.
101
+ * drawn_image / uploaded_image store a FileAsset Base44 ID.
102
+ */
103
+ type SignatureInput = {
104
+ mode: typeof SIGNATURE_MODES.TYPED_NAME;
105
+ typedName: string;
106
+ fileAssetId?: null;
107
+ } | {
108
+ mode: typeof SIGNATURE_MODES.DRAWN_IMAGE | typeof SIGNATURE_MODES.UPLOADED_IMAGE;
109
+ typedName?: null;
110
+ fileAssetId: Base44Id;
111
+ };
112
+ /**
113
+ * Optional normalized signature value that can also be reused inside entities later.
114
+ * Useful if you want one stable shape for mapped/flattened signature data.
115
+ */
116
+ type NormalizedSignatureValue = {
117
+ mode: SignatureMode;
118
+ typedName?: string | null;
119
+ fileAssetId?: Base44Id | null;
120
+ };
121
+ /**
122
+ * Metadata stored inside FileUploadTask for CAR compilation.
123
+ * Keep this lean: execution references only, not full form content.
124
+ */
125
+ type CorrectiveActionCompileTaskMetadata = {
126
+ correctiveActionId: Base44Id;
127
+ companyAuditDetailResponseId: Base44Id;
128
+ companyAuditHeaderId: Base44Id;
129
+ templateAssetId: Base44Id;
130
+ resolvedTemplateScopeLevel: TemplateScopeLevel;
131
+ operationalSettingsId: Base44Id;
132
+ supportingEvidenceFileIds: Base44Id[];
133
+ appendSupportingEvidenceInOrder: true;
134
+ linkCompiledPdfToResponseEvidence: true;
135
+ linkOriginalSupportingEvidenceToResponseEvidence: true;
136
+ generationSource: CorrectiveActionGenerationSource;
137
+ previousCorrectiveActionId: Base44Id | null;
138
+ };
139
+ /**
140
+ * FileAsset.metadata shape for CAR templates.
141
+ * Stored on the uploaded template PDF asset.
142
+ */
143
+ type CarTemplateFileMetadata = {
144
+ templateType: 'CAR';
145
+ stampingZone: {
146
+ xPct: number;
147
+ yPct: number;
148
+ wPct: number;
149
+ hPct: number;
150
+ };
151
+ pageNumber: number;
152
+ applyToAllPages: boolean;
153
+ promotedAt?: string;
154
+ };
79
155
 
80
156
  declare const MOD: {
81
157
  readonly OPERATIONS: "OPR";
@@ -185,11 +261,18 @@ declare const NotificationMode: {
185
261
  readonly EXTERNAL_EMAIL: "external_email";
186
262
  readonly NONE: "none";
187
263
  };
264
+ /**
265
+ * FileUploadTask type for CAR compilation worker.
266
+ * Reused between service layer and async worker.
267
+ */
188
268
  declare const TaskType: {
189
269
  readonly KML_PARSE: "KML_PARSE";
190
270
  readonly INVOICE_OCR: "INVOICE_OCR";
191
271
  readonly AUDIT_UPLOAD: "AUDIT_UPLOAD";
192
272
  readonly REPORT_GEN: "REPORT_GEN";
273
+ readonly PDF_STAMPING: "PDF_STAMPING";
274
+ readonly CAR_TEMPLATE_UPLOAD: "CAR_TEMPLATE_UPLOAD";
275
+ readonly CORRECTIVE_ACTION_COMPILE: "CORRECTIVE_ACTION_COMPILE";
193
276
  };
194
277
  declare const TaskStatus: {
195
278
  readonly PENDING: "PENDING";
@@ -397,6 +480,73 @@ declare enum DocumentType {
397
480
  AUDIT_REPORT = "AUDIT_REPORT",
398
481
  SENSITIVE_IDENTITY = "SENSITIVE_IDENTITY"
399
482
  }
483
+ declare enum DocumentCategory {
484
+ AGRONOMY_TESTING = "Agronomy & Testing",
485
+ FARM_OPERATIONS = "Farm Operations",
486
+ COMPLIANCE_QA = "Compliance & Quality",
487
+ INVENTORY_LOG = "Inventory & Logistics",
488
+ ASSETS_MAINT = "Assets & Maintenance",
489
+ HR_LEGAL_SAFETY = "HR, Legal & Safety",
490
+ FINANCE_ADMIN = "Finance & Admin"
491
+ }
492
+ declare const DOCUMENT_DISPLAY_INFO: Record<DocumentType, {
493
+ label: string;
494
+ description: string;
495
+ category: DocumentCategory;
496
+ }>;
497
+ declare const CATEGORY_TABS: string[];
400
498
  declare const DOCUMENT_MENU_MAP: Record<DocumentType, string[]>;
499
+ /**
500
+ * Signature modes supported by CAR and similar official document flows.
501
+ * Use this for both frontend UI selectors and backend validation.
502
+ */
503
+ declare const SIGNATURE_MODES: {
504
+ readonly TYPED_NAME: "typed_name";
505
+ readonly DRAWN_IMAGE: "drawn_image";
506
+ readonly UPLOADED_IMAGE: "uploaded_image";
507
+ };
508
+ /**
509
+ * Corrective Action lifecycle states.
510
+ * draft = record created, generation not finalized yet
511
+ * generated = compiled PDF created and linked successfully
512
+ * reviewed = optional later review completed
513
+ * closed = final business closure
514
+ * failed = generation failed
515
+ */
516
+ declare const CORRECTIVE_ACTION_STATUSES: {
517
+ readonly DRAFT: "draft";
518
+ readonly GENERATED: "generated";
519
+ readonly REVIEWED: "reviewed";
520
+ readonly CLOSED: "closed";
521
+ readonly FAILED: "failed";
522
+ };
523
+ /**
524
+ * Scope level used when resolving templates from OperationalSettings.
525
+ * Resolution precedence is facility -> legalEntity -> company.
526
+ */
527
+ declare const TEMPLATE_SCOPE_LEVELS: {
528
+ readonly FACILITY: "facility";
529
+ readonly LEGAL_ENTITY: "legalEntity";
530
+ readonly COMPANY: "company";
531
+ };
532
+ /**
533
+ * Generation source for CAR creation.
534
+ * CREATE = fresh new CAR
535
+ * RECREATE = new CAR created from a failed prior CAR
536
+ */
537
+ declare const CORRECTIVE_ACTION_GENERATION_SOURCES: {
538
+ readonly CREATE: "CREATE";
539
+ readonly RECREATE: "RECREATE";
540
+ };
541
+ /**
542
+ * Allowed supporting evidence mime types for CAR.
543
+ * Used by frontend upload filter and backend validation.
544
+ */
545
+ declare const CAR_SUPPORTED_EVIDENCE_MIME_TYPES: readonly ["application/pdf", "image/png", "image/jpeg"];
546
+ /**
547
+ * Allowed mime types for signature file uploads.
548
+ * Drawn signatures usually become PNG; uploaded signatures should stay image-only.
549
+ */
550
+ declare const CAR_SUPPORTED_SIGNATURE_MIME_TYPES: readonly ["image/png", "image/jpeg"];
401
551
 
402
- export { TaskType as $, ACCESS_RANK as A, RESOURCE_REQUIREMENTS as B, CAT as C, DOCUMENT_MENU_MAP as D, ERROR_DICTIONARY as E, FORM_REGISTRY as F, ROLE_SECTIONS_BY_KEY as G, HarvestMethod as H, type InfrastructureFields as I, RelationshipType as J, type ResolvedError as K, LinkedStatus as L, MOD as M, NettingType as N, OrderStatus as O, type PermissionLevel as P, type ResourceOverrides as Q, RESOURCE_MODULE_MAP as R, type ResourceRequirement as S, RowOrientation as T, SENTINEL_UUID as U, type ScopeType as V, SoilTexture as W, TASK_TYPE_REGISTRY as X, type TabConfig as Y, TargetEntityType as Z, TaskStatus as _, ACT as a, type TaskTypeConfig as a0, TransactionType as a1, TrellisType as a2, UserPrivilege as a3, UserRole as a4, type UserRoleType as a5, VigorRating as a6, WaterSource as a7, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type CompanyConfig as k, CropCycleStatus as l, DocumentType as m, EVERYONE as n, EmitterType as o, EnabledModule as p, FacilityType as q, type FormMeta as r, MODULE_LABELS as s, MicroclimateZone as t, MimeType as u, type ModCode as v, NotificationMode as w, PhysicalState as x, PlantingMethod as y, RESOURCE_PATHS as z };
552
+ export { PlantingMethod as $, ACCESS_RANK as A, type Base44Id as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, DOCUMENT_DISPLAY_INFO as D, DocumentType as E, ERROR_DICTIONARY as F, EVERYONE as G, EmitterType as H, EnabledModule as I, FORM_REGISTRY as J, FacilityType as K, type FileUploadTaskType as L, type FormMeta as M, HarvestMethod as N, type InfrastructureFields as O, LinkedStatus as P, MOD as Q, MODULE_LABELS as R, MicroclimateZone as S, MimeType as T, type ModCode as U, NettingType as V, type NormalizedSignatureValue as W, NotificationMode as X, OrderStatus as Y, type PermissionLevel as Z, PhysicalState as _, ACT as a, RESOURCE_MODULE_MAP as a0, RESOURCE_PATHS as a1, RESOURCE_REQUIREMENTS as a2, ROLE_SECTIONS_BY_KEY as a3, RelationshipType as a4, type ResolvedError as a5, type ResourceOverrides as a6, type ResourceRequirement as a7, RowOrientation as a8, SENTINEL_UUID as a9, SIGNATURE_MODES as aa, type ScopeType as ab, type SignatureInput as ac, type SignatureMode as ad, SoilTexture as ae, TASK_TYPE_REGISTRY as af, TEMPLATE_SCOPE_LEVELS as ag, type TabConfig as ah, TargetEntityType as ai, TaskStatus as aj, TaskType as ak, type TaskTypeConfig as al, type TemplateScopeLevel as am, TransactionType as an, TrellisType as ao, UserPrivilege as ap, UserRole as aq, type UserRoleType as ar, VigorRating as as, WaterSource as at, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as k, CAT as l, CATEGORY_TABS as m, CORRECTIVE_ACTION_GENERATION_SOURCES as n, CORRECTIVE_ACTION_STATUSES as o, type CanonicalId as p, type CarSupportedEvidenceMimeType as q, type CarSupportedSignatureMimeType as r, type CarTemplateFileMetadata as s, type CompanyConfig as t, type CorrectiveActionCompileTaskMetadata as u, type CorrectiveActionGenerationSource as v, type CorrectiveActionStatus as w, CropCycleStatus as x, DOCUMENT_MENU_MAP as y, DocumentCategory as z };
@@ -76,6 +76,82 @@ interface InfrastructureFields {
76
76
  facilityId: string | null;
77
77
  authScopeId: string;
78
78
  }
79
+ /**
80
+ * Base44 ID alias for readability only.
81
+ * Still just string at runtime.
82
+ */
83
+ type Base44Id = string;
84
+ /**
85
+ * Canonical UUID alias for readability only.
86
+ */
87
+ type CanonicalId = string;
88
+ /**
89
+ * Derived union types from constants.
90
+ */
91
+ type SignatureMode = typeof SIGNATURE_MODES[keyof typeof SIGNATURE_MODES];
92
+ type CorrectiveActionStatus = typeof CORRECTIVE_ACTION_STATUSES[keyof typeof CORRECTIVE_ACTION_STATUSES];
93
+ type FileUploadTaskType = typeof TaskType[keyof typeof TaskType];
94
+ type TemplateScopeLevel = typeof TEMPLATE_SCOPE_LEVELS[keyof typeof TEMPLATE_SCOPE_LEVELS];
95
+ type CorrectiveActionGenerationSource = typeof CORRECTIVE_ACTION_GENERATION_SOURCES[keyof typeof CORRECTIVE_ACTION_GENERATION_SOURCES];
96
+ type CarSupportedEvidenceMimeType = typeof CAR_SUPPORTED_EVIDENCE_MIME_TYPES[number];
97
+ type CarSupportedSignatureMimeType = typeof CAR_SUPPORTED_SIGNATURE_MIME_TYPES[number];
98
+ /**
99
+ * Shared signature payload used by create/preview CAR requests.
100
+ * typed_name stores text only.
101
+ * drawn_image / uploaded_image store a FileAsset Base44 ID.
102
+ */
103
+ type SignatureInput = {
104
+ mode: typeof SIGNATURE_MODES.TYPED_NAME;
105
+ typedName: string;
106
+ fileAssetId?: null;
107
+ } | {
108
+ mode: typeof SIGNATURE_MODES.DRAWN_IMAGE | typeof SIGNATURE_MODES.UPLOADED_IMAGE;
109
+ typedName?: null;
110
+ fileAssetId: Base44Id;
111
+ };
112
+ /**
113
+ * Optional normalized signature value that can also be reused inside entities later.
114
+ * Useful if you want one stable shape for mapped/flattened signature data.
115
+ */
116
+ type NormalizedSignatureValue = {
117
+ mode: SignatureMode;
118
+ typedName?: string | null;
119
+ fileAssetId?: Base44Id | null;
120
+ };
121
+ /**
122
+ * Metadata stored inside FileUploadTask for CAR compilation.
123
+ * Keep this lean: execution references only, not full form content.
124
+ */
125
+ type CorrectiveActionCompileTaskMetadata = {
126
+ correctiveActionId: Base44Id;
127
+ companyAuditDetailResponseId: Base44Id;
128
+ companyAuditHeaderId: Base44Id;
129
+ templateAssetId: Base44Id;
130
+ resolvedTemplateScopeLevel: TemplateScopeLevel;
131
+ operationalSettingsId: Base44Id;
132
+ supportingEvidenceFileIds: Base44Id[];
133
+ appendSupportingEvidenceInOrder: true;
134
+ linkCompiledPdfToResponseEvidence: true;
135
+ linkOriginalSupportingEvidenceToResponseEvidence: true;
136
+ generationSource: CorrectiveActionGenerationSource;
137
+ previousCorrectiveActionId: Base44Id | null;
138
+ };
139
+ /**
140
+ * FileAsset.metadata shape for CAR templates.
141
+ * Stored on the uploaded template PDF asset.
142
+ */
143
+ type CarTemplateFileMetadata = {
144
+ templateType: 'CAR';
145
+ stampingZone: {
146
+ xPct: number;
147
+ yPct: number;
148
+ wPct: number;
149
+ hPct: number;
150
+ };
151
+ pageNumber: number;
152
+ applyToAllPages: boolean;
153
+ promotedAt?: string;
154
+ };
79
155
 
80
156
  declare const MOD: {
81
157
  readonly OPERATIONS: "OPR";
@@ -185,11 +261,18 @@ declare const NotificationMode: {
185
261
  readonly EXTERNAL_EMAIL: "external_email";
186
262
  readonly NONE: "none";
187
263
  };
264
+ /**
265
+ * FileUploadTask type for CAR compilation worker.
266
+ * Reused between service layer and async worker.
267
+ */
188
268
  declare const TaskType: {
189
269
  readonly KML_PARSE: "KML_PARSE";
190
270
  readonly INVOICE_OCR: "INVOICE_OCR";
191
271
  readonly AUDIT_UPLOAD: "AUDIT_UPLOAD";
192
272
  readonly REPORT_GEN: "REPORT_GEN";
273
+ readonly PDF_STAMPING: "PDF_STAMPING";
274
+ readonly CAR_TEMPLATE_UPLOAD: "CAR_TEMPLATE_UPLOAD";
275
+ readonly CORRECTIVE_ACTION_COMPILE: "CORRECTIVE_ACTION_COMPILE";
193
276
  };
194
277
  declare const TaskStatus: {
195
278
  readonly PENDING: "PENDING";
@@ -397,6 +480,73 @@ declare enum DocumentType {
397
480
  AUDIT_REPORT = "AUDIT_REPORT",
398
481
  SENSITIVE_IDENTITY = "SENSITIVE_IDENTITY"
399
482
  }
483
+ declare enum DocumentCategory {
484
+ AGRONOMY_TESTING = "Agronomy & Testing",
485
+ FARM_OPERATIONS = "Farm Operations",
486
+ COMPLIANCE_QA = "Compliance & Quality",
487
+ INVENTORY_LOG = "Inventory & Logistics",
488
+ ASSETS_MAINT = "Assets & Maintenance",
489
+ HR_LEGAL_SAFETY = "HR, Legal & Safety",
490
+ FINANCE_ADMIN = "Finance & Admin"
491
+ }
492
+ declare const DOCUMENT_DISPLAY_INFO: Record<DocumentType, {
493
+ label: string;
494
+ description: string;
495
+ category: DocumentCategory;
496
+ }>;
497
+ declare const CATEGORY_TABS: string[];
400
498
  declare const DOCUMENT_MENU_MAP: Record<DocumentType, string[]>;
499
+ /**
500
+ * Signature modes supported by CAR and similar official document flows.
501
+ * Use this for both frontend UI selectors and backend validation.
502
+ */
503
+ declare const SIGNATURE_MODES: {
504
+ readonly TYPED_NAME: "typed_name";
505
+ readonly DRAWN_IMAGE: "drawn_image";
506
+ readonly UPLOADED_IMAGE: "uploaded_image";
507
+ };
508
+ /**
509
+ * Corrective Action lifecycle states.
510
+ * draft = record created, generation not finalized yet
511
+ * generated = compiled PDF created and linked successfully
512
+ * reviewed = optional later review completed
513
+ * closed = final business closure
514
+ * failed = generation failed
515
+ */
516
+ declare const CORRECTIVE_ACTION_STATUSES: {
517
+ readonly DRAFT: "draft";
518
+ readonly GENERATED: "generated";
519
+ readonly REVIEWED: "reviewed";
520
+ readonly CLOSED: "closed";
521
+ readonly FAILED: "failed";
522
+ };
523
+ /**
524
+ * Scope level used when resolving templates from OperationalSettings.
525
+ * Resolution precedence is facility -> legalEntity -> company.
526
+ */
527
+ declare const TEMPLATE_SCOPE_LEVELS: {
528
+ readonly FACILITY: "facility";
529
+ readonly LEGAL_ENTITY: "legalEntity";
530
+ readonly COMPANY: "company";
531
+ };
532
+ /**
533
+ * Generation source for CAR creation.
534
+ * CREATE = fresh new CAR
535
+ * RECREATE = new CAR created from a failed prior CAR
536
+ */
537
+ declare const CORRECTIVE_ACTION_GENERATION_SOURCES: {
538
+ readonly CREATE: "CREATE";
539
+ readonly RECREATE: "RECREATE";
540
+ };
541
+ /**
542
+ * Allowed supporting evidence mime types for CAR.
543
+ * Used by frontend upload filter and backend validation.
544
+ */
545
+ declare const CAR_SUPPORTED_EVIDENCE_MIME_TYPES: readonly ["application/pdf", "image/png", "image/jpeg"];
546
+ /**
547
+ * Allowed mime types for signature file uploads.
548
+ * Drawn signatures usually become PNG; uploaded signatures should stay image-only.
549
+ */
550
+ declare const CAR_SUPPORTED_SIGNATURE_MIME_TYPES: readonly ["image/png", "image/jpeg"];
401
551
 
402
- export { TaskType as $, ACCESS_RANK as A, RESOURCE_REQUIREMENTS as B, CAT as C, DOCUMENT_MENU_MAP as D, ERROR_DICTIONARY as E, FORM_REGISTRY as F, ROLE_SECTIONS_BY_KEY as G, HarvestMethod as H, type InfrastructureFields as I, RelationshipType as J, type ResolvedError as K, LinkedStatus as L, MOD as M, NettingType as N, OrderStatus as O, type PermissionLevel as P, type ResourceOverrides as Q, RESOURCE_MODULE_MAP as R, type ResourceRequirement as S, RowOrientation as T, SENTINEL_UUID as U, type ScopeType as V, SoilTexture as W, TASK_TYPE_REGISTRY as X, type TabConfig as Y, TargetEntityType as Z, TaskStatus as _, ACT as a, type TaskTypeConfig as a0, TransactionType as a1, TrellisType as a2, UserPrivilege as a3, UserRole as a4, type UserRoleType as a5, VigorRating as a6, WaterSource as a7, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, type CompanyConfig as k, CropCycleStatus as l, DocumentType as m, EVERYONE as n, EmitterType as o, EnabledModule as p, FacilityType as q, type FormMeta as r, MODULE_LABELS as s, MicroclimateZone as t, MimeType as u, type ModCode as v, NotificationMode as w, PhysicalState as x, PlantingMethod as y, RESOURCE_PATHS as z };
552
+ export { PlantingMethod as $, ACCESS_RANK as A, type Base44Id as B, CAR_SUPPORTED_EVIDENCE_MIME_TYPES as C, DOCUMENT_DISPLAY_INFO as D, DocumentType as E, ERROR_DICTIONARY as F, EVERYONE as G, EmitterType as H, EnabledModule as I, FORM_REGISTRY as J, FacilityType as K, type FileUploadTaskType as L, type FormMeta as M, HarvestMethod as N, type InfrastructureFields as O, LinkedStatus as P, MOD as Q, MODULE_LABELS as R, MicroclimateZone as S, MimeType as T, type ModCode as U, NettingType as V, type NormalizedSignatureValue as W, NotificationMode as X, OrderStatus as Y, type PermissionLevel as Z, PhysicalState as _, ACT as a, RESOURCE_MODULE_MAP as a0, RESOURCE_PATHS as a1, RESOURCE_REQUIREMENTS as a2, ROLE_SECTIONS_BY_KEY as a3, RelationshipType as a4, type ResolvedError as a5, type ResourceOverrides as a6, type ResourceRequirement as a7, RowOrientation as a8, SENTINEL_UUID as a9, SIGNATURE_MODES as aa, type ScopeType as ab, type SignatureInput as ac, type SignatureMode as ad, SoilTexture as ae, TASK_TYPE_REGISTRY as af, TEMPLATE_SCOPE_LEVELS as ag, type TabConfig as ah, TargetEntityType as ai, TaskStatus as aj, TaskType as ak, type TaskTypeConfig as al, type TemplateScopeLevel as am, TransactionType as an, TrellisType as ao, UserPrivilege as ap, UserRole as aq, type UserRoleType as ar, VigorRating as as, WaterSource as at, AccessLevel as b, type AccessLevelType as c, type AgriCoreSession as d, ApprovalStatus as e, ApprovalType as f, AuditStatus as g, AuditType as h, type AuthScopeFields as i, type AvailableScope as j, CAR_SUPPORTED_SIGNATURE_MIME_TYPES as k, CAT as l, CATEGORY_TABS as m, CORRECTIVE_ACTION_GENERATION_SOURCES as n, CORRECTIVE_ACTION_STATUSES as o, type CanonicalId as p, type CarSupportedEvidenceMimeType as q, type CarSupportedSignatureMimeType as r, type CarTemplateFileMetadata as s, type CompanyConfig as t, type CorrectiveActionCompileTaskMetadata as u, type CorrectiveActionGenerationSource as v, type CorrectiveActionStatus as w, CropCycleStatus as x, DOCUMENT_MENU_MAP as y, DocumentCategory as z };
@@ -1 +1 @@
1
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, c as AccessLevelType, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, C as CAT, l as CropCycleStatus, D as DOCUMENT_MENU_MAP, m as DocumentType, E as ERROR_DICTIONARY, n as EVERYONE, o as EmitterType, p as EnabledModule, F as FORM_REGISTRY, q as FacilityType, H as HarvestMethod, L as LinkedStatus, M as MOD, s as MODULE_LABELS, t as MicroclimateZone, u as MimeType, v as ModCode, N as NettingType, w as NotificationMode, O as OrderStatus, x as PhysicalState, y as PlantingMethod, R as RESOURCE_MODULE_MAP, z as RESOURCE_PATHS, B as RESOURCE_REQUIREMENTS, G as ROLE_SECTIONS_BY_KEY, J as RelationshipType, S as ResourceRequirement, T as RowOrientation, U as SENTINEL_UUID, W as SoilTexture, X as TASK_TYPE_REGISTRY, Z as TargetEntityType, _ as TaskStatus, $ as TaskType, a1 as TransactionType, a2 as TrellisType, a3 as UserPrivilege, a4 as UserRole, a5 as UserRoleType, a6 as VigorRating, a7 as WaterSource } from './constants-DxCjnH4L.mjs';
1
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, c as AccessLevelType, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, k as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, l as CAT, m as CATEGORY_TABS, n as CORRECTIVE_ACTION_GENERATION_SOURCES, o as CORRECTIVE_ACTION_STATUSES, x as CropCycleStatus, D as DOCUMENT_DISPLAY_INFO, y as DOCUMENT_MENU_MAP, z as DocumentCategory, E as DocumentType, F as ERROR_DICTIONARY, G as EVERYONE, H as EmitterType, I as EnabledModule, J as FORM_REGISTRY, K as FacilityType, N as HarvestMethod, P as LinkedStatus, Q as MOD, R as MODULE_LABELS, S as MicroclimateZone, T as MimeType, U as ModCode, V as NettingType, X as NotificationMode, Y as OrderStatus, _ as PhysicalState, $ as PlantingMethod, a0 as RESOURCE_MODULE_MAP, a1 as RESOURCE_PATHS, a2 as RESOURCE_REQUIREMENTS, a3 as ROLE_SECTIONS_BY_KEY, a4 as RelationshipType, a7 as ResourceRequirement, a8 as RowOrientation, a9 as SENTINEL_UUID, aa as SIGNATURE_MODES, ae as SoilTexture, af as TASK_TYPE_REGISTRY, ag as TEMPLATE_SCOPE_LEVELS, ai as TargetEntityType, aj as TaskStatus, ak as TaskType, an as TransactionType, ao as TrellisType, ap as UserPrivilege, aq as UserRole, ar as UserRoleType, as as VigorRating, at as WaterSource } from './constants-DOmJizGn.mjs';
@@ -1 +1 @@
1
- export { A as ACCESS_RANK, a as ACT, b as AccessLevel, c as AccessLevelType, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, C as CAT, l as CropCycleStatus, D as DOCUMENT_MENU_MAP, m as DocumentType, E as ERROR_DICTIONARY, n as EVERYONE, o as EmitterType, p as EnabledModule, F as FORM_REGISTRY, q as FacilityType, H as HarvestMethod, L as LinkedStatus, M as MOD, s as MODULE_LABELS, t as MicroclimateZone, u as MimeType, v as ModCode, N as NettingType, w as NotificationMode, O as OrderStatus, x as PhysicalState, y as PlantingMethod, R as RESOURCE_MODULE_MAP, z as RESOURCE_PATHS, B as RESOURCE_REQUIREMENTS, G as ROLE_SECTIONS_BY_KEY, J as RelationshipType, S as ResourceRequirement, T as RowOrientation, U as SENTINEL_UUID, W as SoilTexture, X as TASK_TYPE_REGISTRY, Z as TargetEntityType, _ as TaskStatus, $ as TaskType, a1 as TransactionType, a2 as TrellisType, a3 as UserPrivilege, a4 as UserRole, a5 as UserRoleType, a6 as VigorRating, a7 as WaterSource } from './constants-DxCjnH4L.js';
1
+ export { A as ACCESS_RANK, a as ACT, b as AccessLevel, c as AccessLevelType, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, k as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, l as CAT, m as CATEGORY_TABS, n as CORRECTIVE_ACTION_GENERATION_SOURCES, o as CORRECTIVE_ACTION_STATUSES, x as CropCycleStatus, D as DOCUMENT_DISPLAY_INFO, y as DOCUMENT_MENU_MAP, z as DocumentCategory, E as DocumentType, F as ERROR_DICTIONARY, G as EVERYONE, H as EmitterType, I as EnabledModule, J as FORM_REGISTRY, K as FacilityType, N as HarvestMethod, P as LinkedStatus, Q as MOD, R as MODULE_LABELS, S as MicroclimateZone, T as MimeType, U as ModCode, V as NettingType, X as NotificationMode, Y as OrderStatus, _ as PhysicalState, $ as PlantingMethod, a0 as RESOURCE_MODULE_MAP, a1 as RESOURCE_PATHS, a2 as RESOURCE_REQUIREMENTS, a3 as ROLE_SECTIONS_BY_KEY, a4 as RelationshipType, a7 as ResourceRequirement, a8 as RowOrientation, a9 as SENTINEL_UUID, aa as SIGNATURE_MODES, ae as SoilTexture, af as TASK_TYPE_REGISTRY, ag as TEMPLATE_SCOPE_LEVELS, ai as TargetEntityType, aj as TaskStatus, ak as TaskType, an as TransactionType, ao as TrellisType, ap as UserPrivilege, aq as UserRole, ar as UserRoleType, as as VigorRating, at as WaterSource } from './constants-DOmJizGn.js';