refactor(db): group database domain modules
This commit is contained in:
1 parent
e43a89096d
commit
6da0a58769
160 files changed
+2124
-1999
No files matched your search
@@ -6,7 +6,7 @@ function safeGetAgent(db: AppDatabase, agentId: string | null | undefined) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return db.entityCrud.getAgent(agentId);
|
||||
return db.core.entity.getAgent(agentId);
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.startsWith("Agent not found:")) {
|
||||
return null;
|
||||
@@ -46,14 +46,14 @@ export function hasManagementAuthority(agent: { role: string; title: string; dep
|
||||
}
|
||||
|
||||
function hasOrganizationPermission(db: AppDatabase, agentId: string) {
|
||||
return db.agents.hasAgentPermission(agentId, "organization_manage");
|
||||
return db.core.agents.hasAgentPermission(agentId, "organization_manage");
|
||||
}
|
||||
|
||||
function managesAgent(db: AppDatabase, managerId: string, targetAgentId: string): boolean {
|
||||
if (managerId === targetAgentId) {
|
||||
return true;
|
||||
}
|
||||
return db.agents.getChainOfCommand(targetAgentId).some((agent) => agent.id === managerId);
|
||||
return db.core.agents.getChainOfCommand(targetAgentId).some((agent) => agent.id === managerId);
|
||||
}
|
||||
|
||||
export function canControlAgent(db: AppDatabase, companyId: string, actorAgentId: string, targetAgentId: string): boolean {
|
||||
@@ -96,7 +96,7 @@ export function canRequestHire(db: AppDatabase, companyId: string, agentId: stri
|
||||
if (canManageOrganization(db, companyId, agentId)) {
|
||||
return true;
|
||||
}
|
||||
if (db.agents.getDirectReports(agentId, companyId).length > 0) {
|
||||
if (db.core.agents.getDirectReports(agentId, companyId).length > 0) {
|
||||
return true;
|
||||
}
|
||||
return hasManagementAuthority(agent);
|
||||
@@ -154,9 +154,9 @@ function getDepartmentLeadCandidateId(
|
||||
.filter((candidate) => candidate.id !== excludeAgentId)
|
||||
.map((candidate) => ({
|
||||
id: candidate.id,
|
||||
hasReports: db.agents.getDirectReports(candidate.id, companyId).length > 0,
|
||||
hasReports: db.core.agents.getDirectReports(candidate.id, companyId).length > 0,
|
||||
leadershipScore: hasManagementAuthority(candidate) ? 1 : 0,
|
||||
chainDepth: db.agents.getChainOfCommand(candidate.id).length,
|
||||
chainDepth: db.core.agents.getChainOfCommand(candidate.id).length,
|
||||
createdAt: candidate.createdAt,
|
||||
}))
|
||||
.filter((candidate) => candidate.hasReports || candidate.leadershipScore > 0)
|
||||
@@ -187,7 +187,7 @@ export function resolveHireReportsTo(
|
||||
}
|
||||
|
||||
if (!department) {
|
||||
return requester?.id ?? db.agents.getCeoForCompany(companyId)?.id ?? null;
|
||||
return requester?.id ?? db.core.agents.getCeoForCompany(companyId)?.id ?? null;
|
||||
}
|
||||
|
||||
if (requester && (requester.department === department || !requester.reportsTo)) {
|
||||
@@ -203,7 +203,7 @@ export function resolveHireReportsTo(
|
||||
return requester.id;
|
||||
}
|
||||
|
||||
return db.agents.getCeoForCompany(companyId)?.id ?? null;
|
||||
return db.core.agents.getCeoForCompany(companyId)?.id ?? null;
|
||||
}
|
||||
|
||||
function normalizeComparableText(value: string): string {
|
||||
@@ -281,7 +281,7 @@ export function canAssignTask(db: AppDatabase, companyId: string, actorAgentId:
|
||||
if (!targetAgentId || targetAgentId === actorAgentId) {
|
||||
return true;
|
||||
}
|
||||
if (!db.settings.belongsToCompany("agents", targetAgentId, companyId)) {
|
||||
if (!db.core.settings.belongsToCompany("agents", targetAgentId, companyId)) {
|
||||
return false;
|
||||
}
|
||||
if (canManageOrganization(db, companyId, actorAgentId)) {
|
||||
|
||||
Reference in new issue
Block a user