feat(xugu): discover and manage scheduler jobs
This commit is contained in:
1 parent
1c0e97b52a
commit
a849979dd1
28 files changed
+731
-42
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
|
||||
export type SidebarObjectKind = "TABLE" | "VIEW" | "MATERIALIZED_VIEW" | "PROCEDURE" | "FUNCTION" | "TRIGGER" | "EVENT" | "SEQUENCE" | "SYNONYM" | "PACKAGE" | "PACKAGE_BODY" | "TYPE" | "TYPE_BODY";
|
||||
export type SidebarObjectKind = "TABLE" | "VIEW" | "MATERIALIZED_VIEW" | "PROCEDURE" | "FUNCTION" | "TRIGGER" | "EVENT" | "SEQUENCE" | "SYNONYM" | "JOB" | "PACKAGE" | "PACKAGE_BODY" | "TYPE" | "TYPE_BODY";
|
||||
|
||||
export interface DatabaseObjectCapabilities {
|
||||
sidebarObjects: SidebarObjectKind[];
|
||||
@@ -168,6 +168,7 @@ export function normalizeSidebarObjectKind(type: string): SidebarObjectKind {
|
||||
if (value.includes("VIEW")) return "VIEW";
|
||||
if (value.includes("SEQ")) return "SEQUENCE";
|
||||
if (value.includes("SYNONYM")) return "SYNONYM";
|
||||
if (value.includes("JOB")) return "JOB";
|
||||
if (value.includes("PROC")) return "PROCEDURE";
|
||||
if (value.includes("FUNC")) return "FUNCTION";
|
||||
return "TABLE";
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
export type XuguSchedulerJobAction = "enable" | "disable" | "run" | "drop";
|
||||
|
||||
/**
|
||||
* Build the DBMS_SCHEDULER statements supported by the first Xugu job
|
||||
* management slice. Scheduler jobs are database-scoped; names are string
|
||||
* arguments rather than schema-qualified identifiers.
|
||||
*/
|
||||
export function buildXuguSchedulerJobSql(action: XuguSchedulerJobAction, name: string): string | null {
|
||||
const jobName = name.trim();
|
||||
if (!jobName) return null;
|
||||
const literal = quoteXuguString(jobName);
|
||||
switch (action) {
|
||||
case "enable":
|
||||
return `EXEC DBMS_SCHEDULER.ENABLE(${literal});`;
|
||||
case "disable":
|
||||
return `EXEC DBMS_SCHEDULER.DISABLE(${literal}, FALSE);`;
|
||||
case "run":
|
||||
return `EXEC DBMS_SCHEDULER.RUN_JOB(${literal}, TRUE);`;
|
||||
case "drop":
|
||||
return `EXEC DBMS_SCHEDULER.DROP_JOB(${literal}, FALSE);`;
|
||||
}
|
||||
}
|
||||
|
||||
function quoteXuguString(value: string): string {
|
||||
return `'${value.replaceAll("'", "''")}'`;
|
||||
}
|
||||
Reference in new issue
Block a user