feat: add the operations layer for declared plugin actions

This commit is contained in:
LukeGus committed 2026-11-03 22:28:54 -06:00
1 parent b87fe3c6a5
commit cc725c7889
54 files changed
+22319 -8

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
CREATE TABLE `operation_approvals` (
`id` varchar(255) NOT NULL,
`run_id` varchar(255) NOT NULL,
`requested_by` text,
`reason` text,
`allow_self` boolean NOT NULL DEFAULT false,
`status` varchar(255) NOT NULL,
`decided_by` text,
`comment` text,
`created_at` text NOT NULL,
`expires_at` varchar(255) NOT NULL,
`decided_at` text,
CONSTRAINT `operation_approvals_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `operation_events` (
`id` varchar(255) NOT NULL,
`event_id` text NOT NULL,
`plugin_id` text NOT NULL,
`host_id` int,
`severity` text,
`payload` text,
`run_id` text,
`created_at` varchar(255) NOT NULL,
CONSTRAINT `operation_events_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `operation_runs` (
`id` varchar(255) NOT NULL,
`action_id` text NOT NULL,
`action_version` int NOT NULL DEFAULT 1,
`plugin_id` text NOT NULL,
`plugin_version` text NOT NULL,
`user_id` varchar(255),
`username` text NOT NULL,
`origin` text NOT NULL,
`host_id` int,
`host_name` text,
`batch_id` varchar(255),
`dry_run` boolean NOT NULL DEFAULT false,
`risk` text NOT NULL,
`status` varchar(255) NOT NULL,
`summary` text,
`changed` boolean,
`input` text,
`sealed_input` text,
`output` text,
`undo_input` text,
`error` text,
`error_code` text,
`undo_of` text,
`idempotency_key` text,
`created_at` varchar(255) NOT NULL,
`started_at` text,
`finished_at` text,
CONSTRAINT `operation_runs_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
ALTER TABLE `api_keys` ADD `scopes` text;--> statement-breakpoint
ALTER TABLE `operation_approvals` ADD CONSTRAINT `operation_approvals_run_id_operation_runs_id_fk` FOREIGN KEY (`run_id`) REFERENCES `operation_runs`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE `operation_runs` ADD CONSTRAINT `operation_runs_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE INDEX `idx_operation_approvals_status` ON `operation_approvals` (`status`,`expires_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_approvals_run` ON `operation_approvals` (`run_id`);--> statement-breakpoint
CREATE INDEX `idx_operation_events_created` ON `operation_events` (`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_events_host_created` ON `operation_events` (`host_id`,`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_created` ON `operation_runs` (`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_user_created` ON `operation_runs` (`user_id`,`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_host_created` ON `operation_runs` (`host_id`,`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_status` ON `operation_runs` (`status`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_batch` ON `operation_runs` (`batch_id`);
File diff suppressed because it is too large. Load diff
+7
View File
@@ -547,6 +547,13 @@
"when": 1793304929772,
"tag": "0077_shared_folder_auth_overrides",
"breakpoints": true
},
{
"idx": 78,
"version": "5",
"when": 1793765383557,
"tag": "0078_sweet_king_cobra",
"breakpoints": true
}
]
}
@@ -0,0 +1,67 @@
CREATE TABLE "operation_approvals" (
"id" varchar(255) PRIMARY KEY NOT NULL,
"run_id" varchar(255) NOT NULL,
"requested_by" text,
"reason" text,
"allow_self" boolean DEFAULT false NOT NULL,
"status" varchar(255) NOT NULL,
"decided_by" text,
"comment" text,
"created_at" text NOT NULL,
"expires_at" varchar(255) NOT NULL,
"decided_at" text
);
--> statement-breakpoint
CREATE TABLE "operation_events" (
"id" varchar(255) PRIMARY KEY NOT NULL,
"event_id" text NOT NULL,
"plugin_id" text NOT NULL,
"host_id" integer,
"severity" text,
"payload" text,
"run_id" text,
"created_at" varchar(255) NOT NULL
);
--> statement-breakpoint
CREATE TABLE "operation_runs" (
"id" varchar(255) PRIMARY KEY NOT NULL,
"action_id" text NOT NULL,
"action_version" integer DEFAULT 1 NOT NULL,
"plugin_id" text NOT NULL,
"plugin_version" text NOT NULL,
"user_id" varchar(255),
"username" text NOT NULL,
"origin" text NOT NULL,
"host_id" integer,
"host_name" text,
"batch_id" varchar(255),
"dry_run" boolean DEFAULT false NOT NULL,
"risk" text NOT NULL,
"status" varchar(255) NOT NULL,
"summary" text,
"changed" boolean,
"input" text,
"sealed_input" text,
"output" text,
"undo_input" text,
"error" text,
"error_code" text,
"undo_of" text,
"idempotency_key" text,
"created_at" varchar(255) NOT NULL,
"started_at" text,
"finished_at" text
);
--> statement-breakpoint
ALTER TABLE "api_keys" ADD COLUMN "scopes" text;--> statement-breakpoint
ALTER TABLE "operation_approvals" ADD CONSTRAINT "operation_approvals_run_id_operation_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."operation_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "operation_runs" ADD CONSTRAINT "operation_runs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "idx_operation_approvals_status" ON "operation_approvals" USING btree ("status","expires_at");--> statement-breakpoint
CREATE INDEX "idx_operation_approvals_run" ON "operation_approvals" USING btree ("run_id");--> statement-breakpoint
CREATE INDEX "idx_operation_events_created" ON "operation_events" USING btree ("created_at");--> statement-breakpoint
CREATE INDEX "idx_operation_events_host_created" ON "operation_events" USING btree ("host_id","created_at");--> statement-breakpoint
CREATE INDEX "idx_operation_runs_created" ON "operation_runs" USING btree ("created_at");--> statement-breakpoint
CREATE INDEX "idx_operation_runs_user_created" ON "operation_runs" USING btree ("user_id","created_at");--> statement-breakpoint
CREATE INDEX "idx_operation_runs_host_created" ON "operation_runs" USING btree ("host_id","created_at");--> statement-breakpoint
CREATE INDEX "idx_operation_runs_status" ON "operation_runs" USING btree ("status");--> statement-breakpoint
CREATE INDEX "idx_operation_runs_batch" ON "operation_runs" USING btree ("batch_id");
File diff suppressed because it is too large. Load diff
+7
View File
@@ -547,6 +547,13 @@
"when": 1793304928399,
"tag": "0077_shared_folder_auth_overrides",
"breakpoints": true
},
{
"idx": 78,
"version": "7",
"when": 1793765382955,
"tag": "0078_clean_living_mummy",
"breakpoints": true
}
]
}
@@ -0,0 +1,67 @@
CREATE TABLE `operation_approvals` (
`id` text PRIMARY KEY NOT NULL,
`run_id` text NOT NULL,
`requested_by` text,
`reason` text,
`allow_self` integer DEFAULT false NOT NULL,
`status` text NOT NULL,
`decided_by` text,
`comment` text,
`created_at` text NOT NULL,
`expires_at` text NOT NULL,
`decided_at` text,
FOREIGN KEY (`run_id`) REFERENCES `operation_runs`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `idx_operation_approvals_status` ON `operation_approvals` (`status`,`expires_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_approvals_run` ON `operation_approvals` (`run_id`);--> statement-breakpoint
CREATE TABLE `operation_events` (
`id` text PRIMARY KEY NOT NULL,
`event_id` text NOT NULL,
`plugin_id` text NOT NULL,
`host_id` integer,
`severity` text,
`payload` text,
`run_id` text,
`created_at` text NOT NULL
);
--> statement-breakpoint
CREATE INDEX `idx_operation_events_created` ON `operation_events` (`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_events_host_created` ON `operation_events` (`host_id`,`created_at`);--> statement-breakpoint
CREATE TABLE `operation_runs` (
`id` text PRIMARY KEY NOT NULL,
`action_id` text NOT NULL,
`action_version` integer DEFAULT 1 NOT NULL,
`plugin_id` text NOT NULL,
`plugin_version` text NOT NULL,
`user_id` text,
`username` text NOT NULL,
`origin` text NOT NULL,
`host_id` integer,
`host_name` text,
`batch_id` text,
`dry_run` integer DEFAULT false NOT NULL,
`risk` text NOT NULL,
`status` text NOT NULL,
`summary` text,
`changed` integer,
`input` text,
`sealed_input` text,
`output` text,
`undo_input` text,
`error` text,
`error_code` text,
`undo_of` text,
`idempotency_key` text,
`created_at` text NOT NULL,
`started_at` text,
`finished_at` text,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
);
--> statement-breakpoint
CREATE INDEX `idx_operation_runs_created` ON `operation_runs` (`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_user_created` ON `operation_runs` (`user_id`,`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_host_created` ON `operation_runs` (`host_id`,`created_at`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_status` ON `operation_runs` (`status`);--> statement-breakpoint
CREATE INDEX `idx_operation_runs_batch` ON `operation_runs` (`batch_id`);--> statement-breakpoint
ALTER TABLE `api_keys` ADD `scopes` text;
File diff suppressed because it is too large. Load diff
+7
View File
@@ -512,6 +512,13 @@
"when": 1793304926942,
"tag": "0072_shared_folder_auth_overrides",
"breakpoints": true
},
{
"idx": 73,
"version": "6",
"when": 1793765382283,
"tag": "0073_dazzling_amazoness",
"breakpoints": true
}
]
}