feat: finish the fleets plugin, add ctx.hosts and host-commands SDK (B4)

This commit is contained in:
LukeGus committed 2026-09-23 11:24:16 -05:00
1 parent d2ff5fc78f
commit 3b2c849514
59 files changed
+31807 -2977

No files matched your search

@@ -0,0 +1,42 @@
-- fleets 0001: adopt_fleets
-- Generated by termix-plugin migrations. Review before committing.
CREATE TABLE IF NOT EXISTS `fleets` (
`id` int AUTO_INCREMENT PRIMARY KEY,
`user_id` varchar(255) NOT NULL,
`name` text NOT NULL,
`description` text,
`color` text,
`icon` text,
`tag_rules` text,
`sync_id` varchar(255) UNIQUE,
`created_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
`updated_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);
RENAME TABLE `fleets` TO `p_fleets_fleets`;
CREATE TABLE IF NOT EXISTS `fleet_members` (
`id` int AUTO_INCREMENT PRIMARY KEY,
`fleet_id` int NOT NULL,
`host_id` int NOT NULL,
`added_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
FOREIGN KEY (`fleet_id`) REFERENCES `p_fleets_fleets` (`id`) ON DELETE CASCADE,
FOREIGN KEY (`host_id`) REFERENCES `ssh_data` (`id`) ON DELETE CASCADE
);
RENAME TABLE `fleet_members` TO `p_fleets_members`;
CREATE TABLE IF NOT EXISTS `fleet_inventory` (
`id` int AUTO_INCREMENT PRIMARY KEY,
`host_id` int NOT NULL,
`user_id` varchar(255) NOT NULL,
`os_pretty_name` text,
`kernel` text,
`architecture` text,
`hostname` text,
`uptime_seconds` int,
`ip` text,
`package_manager` text,
`collected_at` text NOT NULL DEFAULT (CURRENT_TIMESTAMP),
FOREIGN KEY (`host_id`) REFERENCES `ssh_data` (`id`) ON DELETE CASCADE,
FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);
RENAME TABLE `fleet_inventory` TO `p_fleets_inventory`;
@@ -0,0 +1,46 @@
-- fleets 0001: adopt_fleets
-- Generated by termix-plugin migrations. Review before committing.
CREATE TABLE IF NOT EXISTS "fleets" (
"id" serial PRIMARY KEY,
"user_id" varchar(255) NOT NULL,
"name" text NOT NULL,
"description" text,
"color" text,
"icon" text,
"tag_rules" text,
"sync_id" varchar(255) UNIQUE,
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE
);
ALTER TABLE "fleets" RENAME TO "p_fleets_fleets";
CREATE TABLE IF NOT EXISTS "fleet_members" (
"id" serial PRIMARY KEY,
"fleet_id" integer NOT NULL,
"host_id" integer NOT NULL,
"added_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("fleet_id") REFERENCES "p_fleets_fleets" ("id") ON DELETE CASCADE,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_members_fleet_host" ON "fleet_members" ("fleet_id", "host_id");
CREATE INDEX IF NOT EXISTS "idx_fleet_members_host" ON "fleet_members" ("host_id");
ALTER TABLE "fleet_members" RENAME TO "p_fleets_members";
CREATE TABLE IF NOT EXISTS "fleet_inventory" (
"id" serial PRIMARY KEY,
"host_id" integer NOT NULL,
"user_id" varchar(255) NOT NULL,
"os_pretty_name" text,
"kernel" text,
"architecture" text,
"hostname" text,
"uptime_seconds" integer,
"ip" text,
"package_manager" text,
"collected_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_inventory_host" ON "fleet_inventory" ("host_id", "user_id");
CREATE INDEX IF NOT EXISTS "idx_fleet_inventory_user" ON "fleet_inventory" ("user_id");
ALTER TABLE "fleet_inventory" RENAME TO "p_fleets_inventory";
+141
View File
@@ -0,0 +1,141 @@
{
"version": 1,
"tables": {
"fleets": {
"columns": {
"id": {
"type": "id",
"primaryKey": true,
"notNull": true
},
"userId": {
"type": "refUser",
"length": 255,
"notNull": true
},
"name": {
"type": "text",
"notNull": true
},
"description": {
"type": "text"
},
"color": {
"type": "text"
},
"icon": {
"type": "text"
},
"tagRules": {
"type": "text"
},
"syncId": {
"type": "text",
"unique": true
},
"createdAt": {
"type": "text",
"notNull": true,
"defaultNow": true
},
"updatedAt": {
"type": "text",
"notNull": true,
"defaultNow": true
}
},
"indexes": [],
"adopts": "fleets"
},
"members": {
"columns": {
"id": {
"type": "id",
"primaryKey": true,
"notNull": true
},
"fleetId": {
"type": "integer",
"notNull": true
},
"hostId": {
"type": "refHost",
"notNull": true
},
"addedAt": {
"type": "text",
"notNull": true,
"defaultNow": true
}
},
"indexes": [
{
"name": "idx_fleet_members_fleet_host",
"columns": ["fleetId", "hostId"],
"unique": true
},
{
"name": "idx_fleet_members_host",
"columns": ["hostId"]
}
],
"adopts": "fleet_members"
},
"inventory": {
"columns": {
"id": {
"type": "id",
"primaryKey": true,
"notNull": true
},
"hostId": {
"type": "refHost",
"notNull": true
},
"userId": {
"type": "refUser",
"length": 255,
"notNull": true
},
"osPrettyName": {
"type": "text"
},
"kernel": {
"type": "text"
},
"architecture": {
"type": "text"
},
"hostname": {
"type": "text"
},
"uptimeSeconds": {
"type": "integer"
},
"ip": {
"type": "text"
},
"packageManager": {
"type": "text"
},
"collectedAt": {
"type": "text",
"notNull": true,
"defaultNow": true
}
},
"indexes": [
{
"name": "idx_fleet_inventory_host",
"columns": ["hostId", "userId"],
"unique": true
},
{
"name": "idx_fleet_inventory_user",
"columns": ["userId"]
}
],
"adopts": "fleet_inventory"
}
}
}
@@ -0,0 +1,46 @@
-- fleets 0001: adopt_fleets
-- Generated by termix-plugin migrations. Review before committing.
CREATE TABLE IF NOT EXISTS "fleets" (
"id" integer PRIMARY KEY AUTOINCREMENT,
"user_id" text NOT NULL,
"name" text NOT NULL,
"description" text,
"color" text,
"icon" text,
"tag_rules" text,
"sync_id" text UNIQUE,
"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE
);
ALTER TABLE "fleets" RENAME TO "p_fleets_fleets";
CREATE TABLE IF NOT EXISTS "fleet_members" (
"id" integer PRIMARY KEY AUTOINCREMENT,
"fleet_id" integer NOT NULL,
"host_id" integer NOT NULL,
"added_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("fleet_id") REFERENCES "p_fleets_fleets" ("id") ON DELETE CASCADE,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_members_fleet_host" ON "fleet_members" ("fleet_id", "host_id");
CREATE INDEX IF NOT EXISTS "idx_fleet_members_host" ON "fleet_members" ("host_id");
ALTER TABLE "fleet_members" RENAME TO "p_fleets_members";
CREATE TABLE IF NOT EXISTS "fleet_inventory" (
"id" integer PRIMARY KEY AUTOINCREMENT,
"host_id" integer NOT NULL,
"user_id" text NOT NULL,
"os_pretty_name" text,
"kernel" text,
"architecture" text,
"hostname" text,
"uptime_seconds" integer,
"ip" text,
"package_manager" text,
"collected_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY ("host_id") REFERENCES "ssh_data" ("id") ON DELETE CASCADE,
FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_fleet_inventory_host" ON "fleet_inventory" ("host_id", "user_id");
CREATE INDEX IF NOT EXISTS "idx_fleet_inventory_user" ON "fleet_inventory" ("user_id");
ALTER TABLE "fleet_inventory" RENAME TO "p_fleets_inventory";