mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
feat: finish the fleets plugin, add ctx.hosts and host-commands SDK (B4)
This commit is contained in:
1 parent
d2ff5fc78f
commit
3b2c849514
59 files changed
+31807
-2977
No files matched your search
@@ -1615,81 +1615,6 @@ export const homepageLayouts = sqliteTable("homepage_layouts", {
|
||||
});
|
||||
// --- homepage end ---
|
||||
|
||||
// --- fleets begin ---
|
||||
export const fleets = sqliteTable("fleets", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
description: text("description"),
|
||||
color: text("color"),
|
||||
icon: text("icon"),
|
||||
// JSON array of { tag: string } rules, unioned with static fleetMembers at
|
||||
// resolution time. Kept to tag-equality matching for v1.
|
||||
tagRules: text("tag_rules"),
|
||||
syncId: text("sync_id").unique(),
|
||||
createdAt: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
updatedAt: text("updated_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
});
|
||||
|
||||
export const fleetMembers = sqliteTable(
|
||||
"fleet_members",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
fleetId: integer("fleet_id")
|
||||
.notNull()
|
||||
.references(() => fleets.id, { onDelete: "cascade" }),
|
||||
hostId: integer("host_id")
|
||||
.notNull()
|
||||
.references(() => hosts.id, { onDelete: "cascade" }),
|
||||
addedAt: text("added_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
},
|
||||
// fleet_id leads the unique pair, so listing a fleet's hosts is already
|
||||
// served. Finding the fleets a host belongs to starts from host_id.
|
||||
(table) => [
|
||||
uniqueIndex("idx_fleet_members_fleet_host").on(table.fleetId, table.hostId),
|
||||
index("idx_fleet_members_host").on(table.hostId),
|
||||
],
|
||||
);
|
||||
|
||||
// Latest-only inventory snapshot per host, overwritten on each refresh - no
|
||||
// historical log, matching the "latest snapshot only" scope decision.
|
||||
export const fleetInventory = sqliteTable(
|
||||
"fleet_inventory",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
hostId: integer("host_id")
|
||||
.notNull()
|
||||
.references(() => hosts.id, { onDelete: "cascade" }),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
osPrettyName: text("os_pretty_name"),
|
||||
kernel: text("kernel"),
|
||||
architecture: text("architecture"),
|
||||
hostname: text("hostname"),
|
||||
uptimeSeconds: integer("uptime_seconds"),
|
||||
ip: text("ip"),
|
||||
packageManager: text("package_manager"),
|
||||
collectedAt: text("collected_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
},
|
||||
// host_id leads the unique pair; a user's whole inventory is read by user_id.
|
||||
(table) => [
|
||||
uniqueIndex("idx_fleet_inventory_host").on(table.hostId, table.userId),
|
||||
index("idx_fleet_inventory_user").on(table.userId),
|
||||
],
|
||||
);
|
||||
// --- fleets end ---
|
||||
|
||||
|
||||
|
||||
// --- sync begin ---
|
||||
|
||||
Reference in new issue
Block a user