Files
edr-platform/apps/edr-freight-api/src/seed/edr-freight.seed.ts
Marshal 9d81a2e1ee integrate global logistics staff user into seeder
refactor pricing data seeder to fold surcharge types into rates
update route meta subtitle to remove surcharge types
enhance RuleEngineFormDialog to support conditional field visibility
 remove surcharge types from URL constants and related services
add cargo leaf options query for bulk cargo type selection
update RuleEngineResourcePage to utilize cargo leaf options
modify resources configuration to remove surcharge types
implement migration to fold surcharge types into rates
create utility to derive legacy rate types from new rate structure
2026-06-23 23:15:32 +00:00

280 lines
9.5 KiB
TypeScript

import {
BOOKING_RULE_ENGINE_PERMISSIONS,
BOOKING_RULE_ENGINE_PERMISSION_KEYS,
ROLE_PERMISSION_PRESETS,
} from './freight-permissions.registry';
export type FreightSeedRole = {
key: string;
name: { en: string };
permissionKeys: string[];
};
const IAM_PERMISSION_KEYS = {
activateEmployee: "can:activateEmployee",
activateUser: "can:activateUser",
createEmployee: "can:createEmployee",
createPositionPermission: "can:create:position_permission",
createUnit: "can:create:unit",
createUserRole: "can:create:user_role",
deactivateEmployee: "can:deactivateEmployee",
deletePositionPermission: "can:delete:position_permission",
deleteUnit: "can:delete:unit",
deleteUserRole: "can:delete:user_role",
findAllOrganization: "can:find_all:organization",
manageOrganizationAdmin: "manage:organizationAdmin",
manageUnitAdmin: "manage:unitAdmin",
updateUnit: "can:update:unit",
viewPositionPermission: "can:view:position_permission",
viewUserRole: "can:view:user_role",
} as const;
export const EDR_FREIGHT_APPLICATION = {
id: "7f5a2175-c270-495b-bec9-d59ddbdab5d1",
key: "edr_freight_app",
name: {
am: "EDR Freight App",
en: "EDR Freight App",
},
} as const;
const EMPLOYEE_REGISTRATION_PERMISSIONS = [
{
id: "62b5aa2d-4ef6-474d-913a-994568dce1c8",
key: "edr_freight_app:employee_registration:view",
name: { am: "View employee registration", en: "View employee registration" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "8072204d-26de-4e62-88aa-74afd916a0cb",
key: "edr_freight_app:employee_registration:create",
name: { am: "Create employee registration", en: "Create employee registration" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "b7dc55a6-ae7c-4558-8c4e-7d8ce5c7fa08",
key: "edr_freight_app:employee_registration:update",
name: { am: "Update employee registration", en: "Update employee registration" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "7ef06121-bd31-4c0d-b36d-5401b4bfd05c",
key: "edr_freight_app:employee_registration:activate",
name: { am: "Activate employee registration", en: "Activate employee registration" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "2688e144-7f0c-4704-8d59-e92b0c08117a",
key: "edr_freight_app:employee_registration:deactivate",
name: { am: "Deactivate employee registration", en: "Deactivate employee registration" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
const ROLE_ASSIGNMENT_PERMISSIONS = [
{
id: "4de87873-e00d-4330-9b4f-f4fb065f49e0",
key: "edr_freight_app:role_assignment:view",
name: { am: "View role assignment", en: "View role assignment" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "36f022b4-4b94-4220-a46c-df7bd1a1b184",
key: "edr_freight_app:role_assignment:assign",
name: { am: "Assign role", en: "Assign role" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "c1f34177-a0ae-4a46-a24a-3281b9137bab",
key: "edr_freight_app:role_assignment:replace",
name: { am: "Replace role assignment", en: "Replace role assignment" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
const HIERARCHY_UNIT_PERMISSIONS = [
{
id: "2bfa2428-ec40-4588-9b01-dfacce6a2b82",
key: "edr_freight_app:hierarchy_units:view",
name: { am: "View hierarchy units", en: "View hierarchy units" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "1e92daff-9cc7-4a67-9994-879f34bfda16",
key: "edr_freight_app:hierarchy_units:create",
name: { am: "Create hierarchy unit", en: "Create hierarchy unit" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "4ef2d8ad-c627-4448-b4b6-dd6b8b602dc1",
key: "edr_freight_app:hierarchy_units:update",
name: { am: "Update hierarchy unit", en: "Update hierarchy unit" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "15353ac5-246b-42e6-9ac3-eb61c4f1cd22",
key: "edr_freight_app:hierarchy_units:delete",
name: { am: "Delete hierarchy unit", en: "Delete hierarchy unit" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
const HIERARCHY_POSITION_PERMISSIONS = [
{
id: "37ff6f5b-9fb0-4139-af99-22fe54703029",
key: "edr_freight_app:hierarchy_positions:view",
name: { am: "View hierarchy positions", en: "View hierarchy positions" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "af6c091a-6448-4459-a635-c2181efd1de0",
key: "edr_freight_app:hierarchy_positions:create",
name: { am: "Create hierarchy position", en: "Create hierarchy position" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "e78f624d-b570-4cd6-8f16-12090a4a9d31",
key: "edr_freight_app:hierarchy_positions:update",
name: { am: "Update hierarchy position", en: "Update hierarchy position" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "7fba7887-a365-4281-96ea-fb14582b047e",
key: "edr_freight_app:hierarchy_positions:delete",
name: { am: "Delete hierarchy position", en: "Delete hierarchy position" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "a33905ff-f2b8-40b9-a8cf-e2968f6f46fb",
key: "edr_freight_app:hierarchy_positions:change_parent",
name: { am: "Change hierarchy position parent", en: "Change hierarchy position parent" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
const HIERARCHY_EMPLOYEE_ASSIGNMENT_PERMISSIONS = [
{
id: "b6ca90ff-3e95-4af2-bac8-fb298ca62080",
key: "edr_freight_app:hierarchy_employee_assignment:view",
name: { am: "View hierarchy employee assignment", en: "View hierarchy employee assignment" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "0637472f-d6b7-4332-85bb-eaa6a02205c1",
key: "edr_freight_app:hierarchy_employee_assignment:invite",
name: { am: "Invite hierarchy employee assignment", en: "Invite hierarchy employee assignment" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
{
id: "de366c81-b6d1-4cf9-a5f1-a5c8a6fb5e7b",
key: "edr_freight_app:hierarchy_employee_assignment:assign",
name: { am: "Assign hierarchy employee assignment", en: "Assign hierarchy employee assignment" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
const POSITION_TYPE_PERMISSIONS = [
{
id: "f258fb51-2890-4c93-b024-271b09d705d0",
key: "edr_freight_app:position_types:view",
name: { am: "View position types", en: "View position types" },
applicationKey: EDR_FREIGHT_APPLICATION.key,
},
] as const;
export const EDR_FREIGHT_PERMISSIONS = [
...EMPLOYEE_REGISTRATION_PERMISSIONS,
...ROLE_ASSIGNMENT_PERMISSIONS,
...HIERARCHY_UNIT_PERMISSIONS,
...HIERARCHY_POSITION_PERMISSIONS,
...HIERARCHY_EMPLOYEE_ASSIGNMENT_PERMISSIONS,
...POSITION_TYPE_PERMISSIONS,
...BOOKING_RULE_ENGINE_PERMISSIONS,
];
export { BOOKING_RULE_ENGINE_PERMISSION_KEYS } from './freight-permissions.registry';
export const EDR_FREIGHT_ROLES: FreightSeedRole[] = [
{
key: "edr_employee",
name: { en: "EDR Employee" },
permissionKeys: [
"edr_freight_app:employee_registration:view",
"edr_freight_app:role_assignment:view",
"edr_freight_app:hierarchy_units:view",
"edr_freight_app:hierarchy_positions:view",
"edr_freight_app:hierarchy_employee_assignment:view",
"edr_freight_app:position_types:view",
],
},
{
key: "edr_line_staff",
name: { en: "EDR Line Staff" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.lineStaff],
},
{
key: "edr_operations_officer",
name: { en: "EDR Operations Officer" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.operationsOfficer],
},
{
key: "edr_director",
name: { en: "EDR Director" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.director],
},
{
key: "edr_ceo",
name: { en: "EDR CEO" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.ceo],
},
{
key: "edr_finance",
name: { en: "EDR Finance" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.finance],
},
{
key: "edr_marketing",
name: { en: "EDR Marketing" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.marketing],
},
{
key: "edr_global_logistics",
name: { en: "EDR Global Logistics" },
permissionKeys: [...ROLE_PERMISSION_PRESETS.globalLogistics],
},
{
key: "edr_org_manager",
name: { en: "EDR Org Manager" },
permissionKeys: [
...BOOKING_RULE_ENGINE_PERMISSION_KEYS,
...EMPLOYEE_REGISTRATION_PERMISSIONS.map((p) => p.key),
...ROLE_ASSIGNMENT_PERMISSIONS.map((p) => p.key),
...HIERARCHY_UNIT_PERMISSIONS.map((p) => p.key),
...HIERARCHY_POSITION_PERMISSIONS.map((p) => p.key),
...HIERARCHY_EMPLOYEE_ASSIGNMENT_PERMISSIONS.map((p) => p.key),
...POSITION_TYPE_PERMISSIONS.map((p) => p.key),
IAM_PERMISSION_KEYS.createEmployee,
IAM_PERMISSION_KEYS.deactivateEmployee,
IAM_PERMISSION_KEYS.activateEmployee,
IAM_PERMISSION_KEYS.activateUser,
IAM_PERMISSION_KEYS.createUserRole,
IAM_PERMISSION_KEYS.deleteUserRole,
IAM_PERMISSION_KEYS.viewUserRole,
IAM_PERMISSION_KEYS.manageOrganizationAdmin,
IAM_PERMISSION_KEYS.manageUnitAdmin,
IAM_PERMISSION_KEYS.createUnit,
IAM_PERMISSION_KEYS.updateUnit,
IAM_PERMISSION_KEYS.deleteUnit,
IAM_PERMISSION_KEYS.createPositionPermission,
IAM_PERMISSION_KEYS.deletePositionPermission,
IAM_PERMISSION_KEYS.viewPositionPermission,
IAM_PERMISSION_KEYS.findAllOrganization,
],
},
{
key: "edr_customer",
name: { en: "EDR Customer" },
permissionKeys: [],
},
];