feat!: release v2 (#6545)

Co-authored-by: Artur <145776561+arturict@users.noreply.github.com>
Co-authored-by: arturict <arturict@users.noreply.github.com>
Co-authored-by: Thomas <thomas@ajnart.fr>
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
Co-authored-by: Danura30082 <danura30082+github@gmail.com>
Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com>
Co-authored-by: ajnart <thomas@ajnart.fr>
Co-authored-by: ajnart <thomas@ajnart.dev>
Co-authored-by: chenjun <chenjun@foxmail.com>
Co-authored-by: Wikibear <wikibear@users.noreply.github.com>
Co-authored-by: Bergasha <bergasha@gmail.com>
Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com>
Co-authored-by: Lucas Araujo <lucas.lra@gmail.com>
Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com>
Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social>
Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com>
Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com>
Co-authored-by: thrawnx <tight.bulb9384@fastmail.com>
Co-authored-by: Chris <58918656+nordada@users.noreply.github.com>
Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com>
Co-authored-by: Yanis <naamaneyanis@gmail.com>
Co-authored-by: Wikibear <me@sej.de>
Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386 -139176

No files matched your search

+158 -22
View File
@@ -6,6 +6,7 @@ import type { AnyPgColumn } from "drizzle-orm/pg-core";
import {
boolean,
customType,
foreignKey,
index,
integer,
pgTable,
@@ -32,18 +33,17 @@ import type {
IntegrationKind,
IntegrationPermission,
IntegrationSecretKind,
LayoutRole,
OnboardingStep,
SearchEngineType,
SectionKind,
SupportedAuthProvider,
WidgetKind,
} from "@homarr/definitions";
import type {
CustomWidgetAuthType,
CustomWidgetDisplayType,
CustomWidgetMethod,
CustomWidgetSecretKind,
} from "@homarr/validation/custom-widget";
import { defaultByteUnitSystem } from "@homarr/common";
import type { ByteUnitSystem } from "@homarr/common";
import type { CustomWidgetSecretKind } from "@homarr/custom-widgets/core";
import { defaultHeaderPreferencesSerialized } from "@homarr/validation/header-preferences";
const customBlob = customType<{ data: Buffer }>({
dataType() {
@@ -83,9 +83,11 @@ export const users = pgTable("user", {
openSearchInNewTab: boolean().default(false).notNull(),
ddgBangs: boolean().default(true).notNull(),
colorScheme: varchar({ length: 5 }).$type<ColorScheme>().default("dark").notNull(),
byteUnitSystem: varchar({ length: 7 }).$type<ByteUnitSystem>().default(defaultByteUnitSystem).notNull(),
firstDayOfWeek: smallint().$type<DayOfWeek>().default(1).notNull(), // Defaults to Monday
pingIconsEnabled: boolean().default(false).notNull(),
enableRightClickOnWidgets: boolean().default(true).notNull(),
headerPreferences: text().default(defaultHeaderPreferencesSerialized).notNull(),
completedManageTour: boolean().default(false).notNull(),
completedBoardTour: boolean().default(false).notNull(),
});
@@ -210,8 +212,8 @@ export const integrations = pgTable(
kind: varchar({ length: 128 }).$type<IntegrationKind>().notNull(),
appId: varchar({ length: 128 }).references(() => apps.id, { onDelete: "set null" }),
},
(integrations) => ({
kindIdx: index("integration__kind_idx").on(integrations.kind),
(table) => ({
kindIdx: index("integration__kind_idx").on(table.kind),
}),
);
@@ -343,7 +345,10 @@ export const layouts = pgTable("layout", {
.notNull()
.references(() => boards.id, { onDelete: "cascade" }),
columnCount: smallint().notNull(),
leftGutterColumnCount: smallint().notNull().default(0),
rightGutterColumnCount: smallint().notNull().default(0),
breakpoint: smallint().notNull().default(0),
role: varchar({ length: 16 }).$type<LayoutRole>().notNull().default("custom"),
});
export const itemLayouts = pgTable(
@@ -480,6 +485,71 @@ export const serverSettings = pgTable("serverSetting", {
value: text().default(emptySuperJSON).notNull(),
});
export const assistantConfigurations = pgTable("assistant_configuration", {
id: varchar({ length: 64 }).notNull().primaryKey().default("default"),
enabled: boolean().notNull().default(false),
webSearchEnabled: boolean().notNull().default(false),
provider: varchar({ length: 32 })
.$type<
| "homarr"
| "openrouter"
| "openai"
| "anthropic"
| "google-gemini"
| "xai"
| "groq"
| "mistral"
| "deepseek"
| "together"
| "ollama"
| "lm-studio"
| "llama-cpp"
| "custom"
>()
.notNull()
.default("openrouter"),
baseUrl: varchar({ length: 2048 }).notNull().default("https://openrouter.ai/api/v1"),
modelDiscoveryPath: varchar({ length: 512 }).default("/models"),
encryptedApiKey: text().$type<`${string}.${string}`>(),
encryptedHeaders: text().$type<`${string}.${string}`>(),
modelId: varchar({ length: 256 }),
updatedAt: timestamp().notNull().defaultNow(),
});
export const assistantThreads = pgTable(
"assistant_thread",
{
id: varchar({ length: 64 }).notNull().primaryKey(),
userId: varchar({ length: 64 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
title: varchar({ length: 256 }),
modelId: varchar({ length: 256 }),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp().notNull().defaultNow(),
},
(thread) => ({
userUpdatedAtIdx: index("assistant_thread__user_id_updated_at_idx").on(thread.userId, thread.updatedAt),
}),
);
export const assistantMessages = pgTable(
"assistant_message",
{
id: varchar({ length: 128 }).notNull().primaryKey(),
threadId: varchar({ length: 64 })
.notNull()
.references(() => assistantThreads.id, { onDelete: "cascade" }),
parentId: varchar({ length: 128 }),
format: varchar({ length: 64 }).notNull().default("ai-sdk/v6"),
content: text().notNull(),
createdAt: timestamp().notNull().defaultNow(),
},
(message) => ({
threadCreatedAtIdx: index("assistant_message__thread_id_created_at_idx").on(message.threadId, message.createdAt),
}),
);
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
user: one(users, {
fields: [apiKeys.userId],
@@ -504,18 +574,65 @@ export const onboarding = pgTable("onboarding", {
previousStep: varchar({ length: 64 }).$type<OnboardingStep>(),
});
export const customWidgetDefinitions = pgTable("custom_widget_definition", {
/**
* Read-only v1 definitions retained during the Custom JSX v2 upgrade.
* Their original physical table names keep the database readable by a v1 binary.
*/
export const legacyCustomWidgetDefinitions = pgTable(
"custom_widget_definition",
{
id: varchar({ length: 64 }).notNull().primaryKey(),
name: varchar({ length: 256 }).notNull(),
description: text(),
iconUrl: text(),
url: text().notNull(),
authType: varchar({ length: 32 }).notNull().default("none"),
headerName: varchar({ length: 256 }),
method: varchar({ length: 16 }).notNull().default("GET"),
requestBody: text(),
displayType: varchar({ length: 32 }).notNull().default("singleValue"),
displayConfig: text().default(emptySuperJSON).notNull(),
enabled: boolean().notNull().default(true),
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
updatedAt: timestamp({ mode: "date" }).notNull().defaultNow(),
creatorId: varchar({ length: 64 }),
},
(table) => ({
creatorFk: foreignKey({
columns: [table.creatorId],
foreignColumns: [users.id],
name: "custom_widget_definition_creator_id_user_id_fk",
}).onDelete("set null"),
}),
);
export const legacyCustomWidgetSecrets = pgTable(
"custom_widget_secret",
{
kind: varchar({ length: 64 }).$type<CustomWidgetSecretKind>().notNull(),
encryptedValue: text("value").$type<`${string}.${string}`>().notNull(),
updatedAt: timestamp().notNull(),
definitionId: varchar({ length: 64 }).notNull(),
},
(table) => ({
compoundKey: primaryKey({ columns: [table.definitionId, table.kind] }),
definitionFk: foreignKey({
columns: [table.definitionId],
foreignColumns: [legacyCustomWidgetDefinitions.id],
name: "custom_widget_secret_definition_id_custom_widget_definition_id_fk",
}).onDelete("cascade"),
}),
);
export const customWidgetDefinitions = pgTable("custom_widget_v2_definition", {
id: varchar({ length: 64 }).notNull().primaryKey(),
name: varchar({ length: 256 }).notNull(),
description: text(),
iconUrl: text(),
url: text().notNull(),
authType: varchar({ length: 32 }).$type<CustomWidgetAuthType>().notNull().default("none"),
headerName: varchar({ length: 256 }),
method: varchar({ length: 16 }).$type<CustomWidgetMethod>().notNull().default("GET"),
requestBody: text(),
displayType: varchar({ length: 32 }).$type<CustomWidgetDisplayType>().notNull().default("singleValue"),
displayConfig: text().default(emptySuperJSON).notNull(),
sources: text().notNull(),
requests: text().notNull(),
options: text().notNull(),
template: text().notNull(),
enabled: boolean().notNull().default(true),
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
updatedAt: timestamp({ mode: "date" }).notNull().defaultNow(),
@@ -523,21 +640,25 @@ export const customWidgetDefinitions = pgTable("custom_widget_definition", {
});
export const customWidgetSecrets = pgTable(
"custom_widget_secret",
"custom_widget_v2_secret",
{
sourceId: varchar({ length: 64 }).notNull(),
kind: varchar({ length: 64 }).$type<CustomWidgetSecretKind>().notNull(),
value: text().$type<`${string}.${string}`>().notNull(),
encryptedValue: text("encrypted_value").$type<`${string}.${string}`>().notNull(),
updatedAt: timestamp()
.$onUpdateFn(() => new Date())
.notNull(),
definitionId: varchar({ length: 64 })
.notNull()
.references(() => customWidgetDefinitions.id, { onDelete: "cascade" }),
definitionId: varchar({ length: 64 }).notNull(),
},
(table) => ({
compoundKey: primaryKey({
columns: [table.definitionId, table.kind],
columns: [table.definitionId, table.sourceId, table.kind],
}),
definitionFk: foreignKey({
columns: [table.definitionId],
foreignColumns: [customWidgetDefinitions.id],
name: "custom_widget_v2_secret_definition_id_fk",
}).onDelete("cascade"),
}),
);
@@ -853,3 +974,18 @@ export const customWidgetSecretRelations = relations(customWidgetSecrets, ({ one
references: [customWidgetDefinitions.id],
}),
}));
export const legacyCustomWidgetDefinitionRelations = relations(legacyCustomWidgetDefinitions, ({ many, one }) => ({
secrets: many(legacyCustomWidgetSecrets),
creator: one(users, {
fields: [legacyCustomWidgetDefinitions.creatorId],
references: [users.id],
}),
}));
export const legacyCustomWidgetSecretRelations = relations(legacyCustomWidgetSecrets, ({ one }) => ({
definition: one(legacyCustomWidgetDefinitions, {
fields: [legacyCustomWidgetSecrets.definitionId],
references: [legacyCustomWidgetDefinitions.id],
}),
}));