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
@@ -29,7 +29,7 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = automationRuleInputSchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
const id = db.automationMod.saveAutomationRule(parsed);
|
||||
const id = db.automation.rules.saveAutomationRule(parsed);
|
||||
publishDomainChanged();
|
||||
return ok(id);
|
||||
});
|
||||
@@ -38,10 +38,10 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = deleteEntitySchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
if (!db.settings.belongsToCompany("automation_rules", parsed.id, parsed.companyId)) {
|
||||
if (!db.core.settings.belongsToCompany("automation_rules", parsed.id, parsed.companyId)) {
|
||||
return fail("ENTITY_NOT_FOUND", "Automation rule not found in the current company.");
|
||||
}
|
||||
db.automationMod.deleteAutomationRule(parsed.id, parsed.companyId);
|
||||
db.automation.rules.deleteAutomationRule(parsed.id, parsed.companyId);
|
||||
publishDomainChanged();
|
||||
return ok(true);
|
||||
});
|
||||
@@ -50,10 +50,10 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = toggleAutomationRuleSchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
if (!db.settings.belongsToCompany("automation_rules", parsed.id, parsed.companyId)) {
|
||||
if (!db.core.settings.belongsToCompany("automation_rules", parsed.id, parsed.companyId)) {
|
||||
return fail("ENTITY_NOT_FOUND", "Automation rule not found in the current company.");
|
||||
}
|
||||
db.automationMod.toggleAutomationRule(parsed.id, parsed.companyId, parsed.status);
|
||||
db.automation.rules.toggleAutomationRule(parsed.id, parsed.companyId, parsed.status);
|
||||
publishDomainChanged();
|
||||
return ok(true);
|
||||
});
|
||||
@@ -62,14 +62,14 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = companyIdSchema.parse(companyId);
|
||||
const companyError = ensureCompanyExists(parsed);
|
||||
if (companyError) return companyError;
|
||||
return ok(db.automationMod.getAutomationLog(parsed));
|
||||
return ok(db.automation.rules.getAutomationLog(parsed));
|
||||
});
|
||||
|
||||
registerHandle(IPC_CHANNELS.saveWorkflow, async (_event, payload) => {
|
||||
const parsed = workflowInputSchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
const id = db.automationMod.saveWorkflow(parsed);
|
||||
const id = db.automation.rules.saveWorkflow(parsed);
|
||||
publishDomainChanged();
|
||||
return ok(id);
|
||||
});
|
||||
@@ -78,10 +78,10 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = deleteEntitySchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
if (!db.settings.belongsToCompany("workflow_pipelines", parsed.id, parsed.companyId)) {
|
||||
if (!db.core.settings.belongsToCompany("workflow_pipelines", parsed.id, parsed.companyId)) {
|
||||
return fail("ENTITY_NOT_FOUND", "Workflow not found in the current company.");
|
||||
}
|
||||
db.automationMod.deleteWorkflow(parsed.id, parsed.companyId);
|
||||
db.automation.rules.deleteWorkflow(parsed.id, parsed.companyId);
|
||||
publishDomainChanged();
|
||||
return ok(true);
|
||||
});
|
||||
@@ -90,7 +90,7 @@ export function registerAutomationOperationsHandlers({
|
||||
const parsed = runWorkflowSchema.parse(payload);
|
||||
const companyError = ensureCompanyExists(parsed.companyId);
|
||||
if (companyError) return companyError;
|
||||
if (!db.settings.belongsToCompany("workflow_pipelines", parsed.id, parsed.companyId)) {
|
||||
if (!db.core.settings.belongsToCompany("workflow_pipelines", parsed.id, parsed.companyId)) {
|
||||
return fail("ENTITY_NOT_FOUND", "Workflow not found in the current company.");
|
||||
}
|
||||
await runWorkflowPipeline(parsed.id, parsed.companyId);
|
||||
|
||||
Reference in new issue
Block a user