This commit is contained in:
Marshal
2026-07-25 06:05:20 +00:00
254 changed files with 15542 additions and 5375 deletions

View File

@@ -19,6 +19,9 @@ export const RULE_ENGINE_RESOURCE_SLUGS = [
'rates',
'approval-rules',
'yard-distances',
// Keep new slugs at the END: ruleEngineCrudId derives ids from list index,
// so a mid-list insert would shift ids already seeded for later slugs.
'truck-types',
] as const;
export type RuleEngineResourceSlug = (typeof RULE_ENGINE_RESOURCE_SLUGS)[number];
@@ -101,6 +104,7 @@ const RULE_ENGINE_VIEW_IDS: Record<RuleEngineResourceSlug, string> = {
'cargo-types': 'b2000001-0001-4000-8000-000000000001',
'container-types': 'b2000001-0001-4000-8000-000000000003',
'wagon-types': 'b2000001-0001-4000-8000-000000000015',
'truck-types': 'b2000001-0001-4000-8000-00000000001a',
'service-types': 'b2000001-0001-4000-8000-000000000005',
yards: 'b2000001-0001-4000-8000-000000000007',
'shipping-lines': 'b2000001-0001-4000-8000-000000000009',
@@ -123,7 +127,7 @@ const ruleEngineCrudId = (
const n =
RULE_ENGINE_RESOURCE_SLUGS.indexOf(slug) * 3 +
RULE_ENGINE_CRUD_ACTIONS.indexOf(action) +
1; // 1..33
1; // 1..36
return `b2000002-0001-4000-8000-${n.toString(16).padStart(12, '0')}`;
};
@@ -902,41 +906,41 @@ export const POSITION_PERMISSION_PRESETS = {
// permission catalog (all CRUD across bookings, contracts, scheduling,
// fleet, warehouse, mile, finance, settings, staff).
operationsChief: dedupe([...BOOKING_RULE_ENGINE_PERMISSION_KEYS]),
// Dispatcher: warehouse floor operations — receive/GRN, move, load/unload,
// inspect, dispatch, gate, release/deliver, interchange docs, fee invoices,
// plus truck dispatch on the mile legs and read-only operational context.
// Allocation & fee rules are VIEW-ONLY — never create/update/delete.
// Dispatcher: full CRUD on warehouse management (incl. import/export/intercity
// inventory flows) and fleet management, plus truck dispatch on the mile legs
// and operational context. The ONE carve-out: allocation & fee rules stay
// VIEW-ONLY — a dispatcher never creates/updates/deletes those rules.
dispatcher: dedupe([
// Warehouse management — full CRUD.
FREIGHT_PERMS.warehouseDashboard.view,
FREIGHT_PERMS.warehouses.view,
FREIGHT_PERMS.warehouseYards.view,
FREIGHT_PERMS.warehouseZones.view,
FREIGHT_PERMS.warehouseInventory.view,
FREIGHT_PERMS.warehouseInventory.receive,
FREIGHT_PERMS.warehouseInventory.move,
FREIGHT_PERMS.warehouseInventory.load,
FREIGHT_PERMS.warehouseInventory.unload,
FREIGHT_PERMS.warehouseInventory.dispatch,
FREIGHT_PERMS.warehouseInventory.gatePass,
FREIGHT_PERMS.warehouseInventory.release,
FREIGHT_PERMS.warehouseInventory.deliver,
FREIGHT_PERMS.warehouseInventory.inspect,
FREIGHT_PERMS.warehouseInspectionReports.view,
FREIGHT_PERMS.warehouseInspectionReports.create,
FREIGHT_PERMS.warehouseInspectionReports.update,
FREIGHT_PERMS.interchangeDocuments.view,
FREIGHT_PERMS.interchangeDocuments.generate,
FREIGHT_PERMS.interchangeDocuments.acknowledge,
FREIGHT_PERMS.warehouseFeeInvoices.view,
FREIGHT_PERMS.warehouseFeeInvoices.generate,
...Object.values(FREIGHT_PERMS.warehouses),
...Object.values(FREIGHT_PERMS.warehouseYards),
...Object.values(FREIGHT_PERMS.warehouseZones),
...Object.values(FREIGHT_PERMS.warehouseInventory),
...Object.values(FREIGHT_PERMS.warehouseInspectionReports),
...Object.values(FREIGHT_PERMS.interchangeDocuments),
...Object.values(FREIGHT_PERMS.warehouseFeeInvoices),
// View-only on the rules that govern allocation and fees.
FREIGHT_PERMS.warehouseAllocationRules.view,
FREIGHT_PERMS.warehouseFeeRules.view,
// Fleet management — full CRUD.
...Object.values(FREIGHT_PERMS.fleet),
FREIGHT_PERMS.fleetDashboard.view,
...Object.values(FREIGHT_PERMS.fleetReports),
...Object.values(FREIGHT_PERMS.vehicles),
...Object.values(FREIGHT_PERMS.drivers),
...Object.values(FREIGHT_PERMS.tracking),
...Object.values(FREIGHT_PERMS.fuel),
...Object.values(FREIGHT_PERMS.maintenance),
...Object.values(FREIGHT_PERMS.locomotives),
...Object.values(FREIGHT_PERMS.wagons),
...Object.values(FREIGHT_PERMS.trains),
...Object.values(FREIGHT_PERMS.routes),
...Object.values(FREIGHT_PERMS.containers),
...Object.values(FREIGHT_PERMS.cargoes),
// Truck dispatch on the EDR mile legs + operational context.
FREIGHT_PERMS.firstMile.view,
FREIGHT_PERMS.firstMile.assignVehicles,
FREIGHT_PERMS.lastMile.view,
FREIGHT_PERMS.lastMile.assignVehicles,
...Object.values(FREIGHT_PERMS.firstMile),
...Object.values(FREIGHT_PERMS.lastMile),
FREIGHT_PERMS.trainScheduling.view,
FREIGHT_PERMS.bookings.operations,
]),