A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat(boards): add responsive layout system (#2271)
Meier Lukas7761dc29c809
diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsxindex 0f3454653..e9551af52 100644--- a/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx+++ b/apps/nextjs/src/app/[locale]/boards/(content)/_client.tsx@@ -5,7 +5,7 @@ import { Box, LoadingOverlay, Stack } from "@mantine/core";import type { RouterOutputs } from "@homarr/api";import { clientApi } from "@homarr/api/client";-import { useRequiredBoard } from "@homarr/boards/context";+import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";import { BoardCategorySection } from "~/components/board/sections/category-section";import { BoardEmptySection } from "~/components/board/sections/empty-section";@@ -43,6 +43,7 @@ export const useUpdateBoard = () => {export const ClientBoard = () => {const board = useRequiredBoard();+ const currentLayoutId = useCurrentLayout();const isReady = useIsBoardReady();const fullWidthSortedSections = board.sections@@ -63,9 +64,10 @@ export const ClientBoard = () => {<Stack ref={ref} h="100%" style={{ visibility: isReady ? "visible" : "hidden" }}>{fullWidthSortedSections.map((section) =>section.kind === "empty" ? (- <BoardEmptySection key={section.id} section={section} />+ // Unique keys per layout to always reinitialize the gridstack+ <BoardEmptySection key={`${currentLayoutId}-${section.id}`} section={section} />) : (- <BoardCategorySection key={section.id} section={section} />+ <BoardCategorySection key={`${currentLayoutId}-${section.id}`} section={section} />),)}</Stack>diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsxindex f501e95f9..49be8c37c 100644--- a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx+++ b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx@@ -13,7 +13,7 @@ import { getI18n } from "@homarr/translation/server";import { createMetaTitle } from "~/metadata";import { createBoardLayout } from "../_layout-creator";import type { Board } from "../_types";-import { ClientBoard } from "./_client";+import { DynamicClientBoard } from "./_dynamic-client";import { BoardContentHeaderActions } from "./_header-actions";export type Params = Record<string, unknown>;@@ -37,7 +37,7 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(return (<IntegrationProvider integrations={integrations}>- <ClientBoard />+ <DynamicClientBoard /></IntegrationProvider>);},diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_dynamic-client.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_dynamic-client.tsxnew file mode 100644index 000000000..50b0aff66--- /dev/null+++ b/apps/nextjs/src/app/[locale]/boards/(content)/_dynamic-client.tsx@@ -0,0 +1,7 @@+"use client";++import dynamic from "next/dynamic";++export const DynamicClientBoard = dynamic(() => import("./_client").then((mod) => mod.ClientBoard), {+ ssr: false,+});diff --git a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_layout.tsx b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_layout.tsxindex f0c2eeb9f..99c0a7f41 100644--- a/apps/nextjs/src/app/[locale]/boards/[name]/settings/_layout.tsx+++ b/apps/nextjs/src/app/[locale]/boards/[name]/settings/_layout.tsx@@ -1,43 +1,109 @@"use client";-import { Button, Grid, Group, Input, Slider, Stack } from "@mantine/core";+import { Button, Fieldset, Grid, Group, Input, NumberInput, Slider, Stack, Text, TextInput } from "@mantine/core";+import { clientApi } from "@homarr/api/client";+import { createId } from "@homarr/db/client";import { useZodForm } from "@homarr/form";import { useI18n } from "@homarr/translation/client";import { validation } from "@homarr/validation";import type { Board } from "../../_types";-import { useSavePartialSettingsMutation } from "./_shared";interface Props {board: Board;}export const LayoutSettingsContent = ({ board }: Props) => {const t = useI18n();- const { mutate: savePartialSettings, isPending } = useSavePartialSettingsMutation(board);- const form = useZodForm(validation.board.savePartialSettings.pick({ columnCount: true }).required(), {+ const utils = clientApi.useUtils();+ const { mutate: saveLayouts, isPending } = clientApi.board.saveLayouts.useMutation({+ onSettled() {+ void utils.board.getBoardByName.invalidate({ name: board.name });+ void utils.board.getHomeBoard.invalidate();+ },+ });+ const form = useZodForm(validation.board.saveLayouts.omit({ id: true }).required(), {initialValues: {- columnCount: board.columnCount,+ layouts: board.layouts,},});return (<formonSubmit={form.onSubmit((values) => {- savePartialSettings({+ saveLayouts({id: board.id,...values,});})}><Stack>- <Grid>- <Grid.Col span={{ sm: 12, md: 6 }}>- <Input.Wrapper label={t("board.field.columnCount.label")}>- <Slider mt="xs" min={1} max={24} step={1} {...form.getInputProps("columnCount")} />- </Input.Wrapper>- </Grid.Col>- </Grid>+ <Stack gap="sm">+ <Group justify="space-between" align="center">+ <Text fw={500}>{t("board.setting.section.layout.responsive.title")}</Text>+ <Button+ variant="subtle"+ onClick={() => {+ form.setValues({+ layouts: [+ ...form.values.layouts,+ {+ id: createId(),+ name: "",+ columnCount: 10,+ breakpoint: 0,+ },+ ],+ });+ }}+ >+ {t("board.setting.section.layout.responsive.action.add")}+ </Button>+ </Group>++ {form.values.layouts.map((layout, index) => (+ <Fieldset key={layout.id} legend={layout.name} bg="transparent">+ <Grid>+ <Grid.Col span={{ sm: 12, md: 6 }}>+ <TextInput {...form.getInputProps(`layouts.${index}.name`)} label={t("layout.field.name.label")} />+ </Grid.Col>++ <Grid.Col span={{ sm: 12, md: 6 }}>+ <Input.Wrapper label={t("layout.field.columnCount.label")}>+ <Slider mt="xs" min={1} max={24} step={1} {...form.getInputProps(`layouts.${index}.columnCount`)} />+ </Input.Wrapper>+ </Grid.Col>++ <Grid.Col span={{ sm: 12, md: 6 }}>+ <NumberInput+ {...form.getInputProps(`layouts.${index}.breakpoint`)}+ label={t("layout.field.breakpoint.label")}+ description={t("layout.field.breakpoint.description")}+ />+ </Grid.Col>+ </Grid>+ {form.values.layouts.length >= 2 && (+ <Group justify="end">+ <Button+ variant="subtle"+ onClick={() => {+ form.setValues((previous) =>+ previous.layouts !== undefined && previous.layouts.length >= 2+ ? {+ layouts: form.values.layouts.filter((filteredLayout) => filteredLayout.id !== layout.id),+ }+ : previous,+ );+ }}+ >+ {t("common.action.remove")}+ </Button>+ </Group>+ )}+ </Fieldset>+ ))}+ </Stack>+<Group justify="end"><Button type="submit" loading={isPending} color="teal">{t("common.action.saveChanges")}diff --git a/apps/nextjs/src/app/[locale]/boards/_types.ts b/apps/nextjs/src/app/[locale]/boards/_types.tsindex 929ce8876..7c202fe95 100644--- a/apps/nextjs/src/app/[locale]/boards/_types.ts+++ b/apps/nextjs/src/app/[locale]/boards/_types.ts@@ -3,10 +3,14 @@ import type { WidgetKind } from "@homarr/definitions";export type Board = RouterOutputs["board"]["getHomeBoard"];export type Section = Board["sections"][number];-export type Item = Section["items"][number];+export type Item = Board["items"][number];+export type ItemLayout = Item["layouts"][number];+export type SectionItem = Omit<Item, "layouts"> & ItemLayout & { type: "item" };export type CategorySection = Extract<Section, { kind: "category" }>;export type EmptySection = Extract<Section, { kind: "empty" }>;export type DynamicSection = Extract<Section, { kind: "dynamic" }>;+export type DynamicSectionLayout = DynamicSection["layouts"][number];+export type DynamicSectionItem = Omit<DynamicSection, "layouts"> & DynamicSectionLayout & { type: "section" };export type ItemOfKind<TKind extends WidgetKind> = Extract<Item, { kind: TKind }>;diff --git a/apps/nextjs/src/components/board/items/actions/create-item.ts b/apps/nextjs/src/components/board/items/actions/create-item.tsindex bc46278a5..6525718f9 100644--- a/apps/nextjs/src/components/board/items/actions/create-item.ts+++ b/apps/nextjs/src/components/board/items/actions/create-item.ts@@ -1,9 +1,11 @@+import { getBoardLayouts } from "@homarr/boards/context";import type { Modify } from "@homarr/common/types";import { createId } from "@homarr/db/client";import type { WidgetKind } from "@homarr/definitions";-import type { Board, DynamicSection, EmptySection, Item } from "~/app/[locale]/boards/_types";+import type { Board, EmptySection, Item, ItemLayout } from "~/app/[locale]/boards/_types";import { getFirstEmptyPosition } from "./empty-position";+import { getSectionElements } from "./section-elements";export interface CreateItemInput {kind: WidgetKind;@@ -19,24 +21,11 @@ export const createItemCallback =if (!firstSection) return previous;- const dynamicSectionsOfFirstSection = previous.sections.filter(- (section): section is DynamicSection => section.kind === "dynamic" && section.parentSectionId === firstSection.id,- );- const elements = [...firstSection.items, ...dynamicSectionsOfFirstSection];- const emptyPosition = getFirstEmptyPosition(elements, previous.columnCount);-- if (!emptyPosition) {- console.error("Your board is full");- return previous;- }-const widget = {id: createId(),kind,options: {},- width: 1,- height: 1,- ...emptyPosition,+ layouts: createItemLayouts(previous, firstSection),integrationIds: [],advancedOptions: {customCssClasses: [],@@ -50,13 +39,31 @@ export const createItemCallback =return {...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (section.id !== firstSection.id) return section;- return {- ...section,- items: section.items.concat(widget),- };- }),+ items: previous.items.concat(widget),};};++const createItemLayouts = (board: Board, currentSection: EmptySection): ItemLayout[] => {+ const layouts = getBoardLayouts(board);++ return layouts.map((layoutId) => {+ const boardLayout = board.layouts.find((layout) => layout.id === layoutId);+ const elements = getSectionElements(board, { sectionId: currentSection.id, layoutId });++ const emptyPosition = boardLayout+ ? getFirstEmptyPosition(elements, boardLayout.columnCount)+ : { xOffset: 0, yOffset: 0 };++ if (!emptyPosition) {+ throw new Error("Your board is full");+ }++ return {+ width: 1,+ height: 1,+ ...emptyPosition,+ sectionId: currentSection.id,+ layoutId,+ };+ });+};diff --git a/apps/nextjs/src/components/board/items/actions/duplicate-item.ts b/apps/nextjs/src/components/board/items/actions/duplicate-item.tsindex 2e4688d18..4ba13638a 100644--- a/apps/nextjs/src/components/board/items/actions/duplicate-item.ts+++ b/apps/nextjs/src/components/board/items/actions/duplicate-item.ts@@ -1,7 +1,8 @@import { createId } from "@homarr/db/client";-import type { Board, DynamicSection, EmptySection } from "~/app/[locale]/boards/_types";+import type { Board, EmptySection, ItemLayout, Section } from "~/app/[locale]/boards/_types";import { getFirstEmptyPosition } from "./empty-position";+import { getSectionElements } from "./section-elements";export interface DuplicateItemInput {itemId: string;@@ -10,72 +11,78 @@ export interface DuplicateItemInput {export const duplicateItemCallback =({ itemId }: DuplicateItemInput) =>(previous: Board): Board => {- const itemToDuplicate = previous.sections- .flatMap((section) => section.items.map((item) => ({ ...item, sectionId: section.id })))- .find((item) => item.id === itemId);+ const itemToDuplicate = previous.items.find((item) => item.id === itemId);if (!itemToDuplicate) return previous;- const currentSection = previous.sections.find((section) => section.id === itemToDuplicate.sectionId);- if (!currentSection) return previous;+ const clonedItem = structuredClone(itemToDuplicate);- const dynamicSectionsOfCurrentSection = previous.sections.filter(- (section): section is DynamicSection =>- section.kind === "dynamic" && section.parentSectionId === currentSection.id,- );- const elements = [...currentSection.items, ...dynamicSectionsOfCurrentSection];- let sectionId = currentSection.id;- let emptyPosition = getFirstEmptyPosition(- elements,- currentSection.kind === "dynamic" ? currentSection.width : previous.columnCount,- currentSection.kind === "dynamic" ? currentSection.height : undefined,- {- width: itemToDuplicate.width,- height: itemToDuplicate.height,- },- );-- if (!emptyPosition) {- const firstSection = previous.sections- .filter((section): section is EmptySection => section.kind === "empty")- .sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset)- .at(0);+ return {+ ...previous,+ items: previous.items.concat({+ ...clonedItem,+ id: createId(),+ layouts: clonedItem.layouts.map((layout) => ({+ ...layout,+ ...getNextPosition(previous, layout),+ })),+ }),+ };+ };- if (!firstSection) return previous;+const getNextPosition = (board: Board, layout: ItemLayout): { xOffset: number; yOffset: number; sectionId: string } => {+ const currentSection = board.sections.find((section) => section.id === layout.sectionId);+ if (currentSection) {+ const emptySectionPosition = getEmptySectionPosition(board, layout, currentSection);+ if (emptySectionPosition) {+ return {+ ...emptySectionPosition,+ sectionId: currentSection.id,+ };+ }+ }- const dynamicSectionsOfFirstSection = previous.sections.filter(- (section): section is DynamicSection =>- section.kind === "dynamic" && section.parentSectionId === firstSection.id,- );- const elements = [...firstSection.items, ...dynamicSectionsOfFirstSection];- emptyPosition = getFirstEmptyPosition(elements, previous.columnCount, undefined, {- width: itemToDuplicate.width,- height: itemToDuplicate.height,- });- if (!emptyPosition) {- console.error("Your board is full");- return previous;- }+ const firstSection = board.sections+ .filter((section): section is EmptySection => section.kind === "empty")+ .sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset)+ .at(0);- sectionId = firstSection.id;- }+ if (!firstSection) {+ throw new Error("Your board is full. reason='no first section'");+ }- const widget = structuredClone(itemToDuplicate);- widget.id = createId();- widget.xOffset = emptyPosition.xOffset;- widget.yOffset = emptyPosition.yOffset;- widget.sectionId = sectionId;+ const emptySectionPosition = getEmptySectionPosition(board, layout, firstSection);- const result = {- ...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (section.id !== sectionId) return section;- return {- ...section,- items: section.items.concat(widget),- };- }),- };+ if (!emptySectionPosition) {+ throw new Error("Your board is full. reason='no empty positions'");+ }- return result;+ return {+ ...emptySectionPosition,+ sectionId: firstSection.id,};+};++const getEmptySectionPosition = (+ board: Board,+ layout: ItemLayout,+ section: Section,+): { xOffset: number; yOffset: number } | undefined => {+ const boardLayout = board.layouts.find((boardLayout) => boardLayout.id === layout.layoutId);+ if (!boardLayout) return;++ const sectionElements = getSectionElements(board, { sectionId: layout.sectionId, layoutId: layout.layoutId });+ if (section.kind !== "dynamic") {+ return getFirstEmptyPosition(sectionElements, boardLayout.columnCount, undefined, {+ width: layout.width,+ height: layout.height,+ });+ }++ const sectionLayout = section.layouts.find((sectionLayout) => sectionLayout.layoutId === layout.layoutId);+ if (!sectionLayout) return;++ return getFirstEmptyPosition(sectionElements, sectionLayout.width, sectionLayout.height, {+ width: layout.width,+ height: layout.height,+ });+};diff --git a/apps/nextjs/src/components/board/items/actions/empty-position.ts b/apps/nextjs/src/components/board/items/actions/empty-position.tsindex 23e6b1fc4..fd91c98d2 100644--- a/apps/nextjs/src/components/board/items/actions/empty-position.ts+++ b/apps/nextjs/src/components/board/items/actions/empty-position.ts@@ -1,7 +1,7 @@-import type { Item } from "~/app/[locale]/boards/_types";+import type { SectionItem } from "~/app/[locale]/boards/_types";export const getFirstEmptyPosition = (- elements: Pick<Item, "yOffset" | "xOffset" | "width" | "height">[],+ elements: Pick<SectionItem, "yOffset" | "xOffset" | "width" | "height">[],columnCount: number,rowCount = 9999,size: { width: number; height: number } = { width: 1, height: 1 },diff --git a/apps/nextjs/src/components/board/items/actions/move-and-resize-item.ts b/apps/nextjs/src/components/board/items/actions/move-and-resize-item.tsnew file mode 100644index 000000000..0348b3f06--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/move-and-resize-item.ts@@ -0,0 +1,36 @@+import { getCurrentLayout } from "@homarr/boards/context";++import type { Board } from "~/app/[locale]/boards/_types";++export interface MoveAndResizeItemInput {+ itemId: string;+ xOffset: number;+ yOffset: number;+ width: number;+ height: number;+}++export const moveAndResizeItemCallback =+ ({ itemId, ...layoutInput }: MoveAndResizeItemInput) =>+ (previous: Board): Board => {+ const currentLayout = getCurrentLayout(previous);++ return {+ ...previous,+ items: previous.items.map((item) =>+ item.id !== itemId+ ? item+ : {+ ...item,+ layouts: item.layouts.map((layout) =>+ layout.layoutId !== currentLayout+ ? layout+ : {+ ...layout,+ ...layoutInput,+ },+ ),+ },+ ),+ };+ };diff --git a/apps/nextjs/src/components/board/items/actions/move-item-to-section.ts b/apps/nextjs/src/components/board/items/actions/move-item-to-section.tsnew file mode 100644index 000000000..98d093826--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/move-item-to-section.ts@@ -0,0 +1,37 @@+import { getCurrentLayout } from "@homarr/boards/context";++import type { Board } from "~/app/[locale]/boards/_types";++export interface MoveItemToSectionInput {+ itemId: string;+ sectionId: string;+ xOffset: number;+ yOffset: number;+ width: number;+ height: number;+}++export const moveItemToSectionCallback =+ ({ itemId, ...layoutInput }: MoveItemToSectionInput) =>+ (board: Board): Board => {+ const currentLayout = getCurrentLayout(board);++ return {+ ...board,+ items: board.items.map((item) =>+ item.id !== itemId+ ? item+ : {+ ...item,+ layouts: item.layouts.map((layout) =>+ layout.layoutId !== currentLayout+ ? layout+ : {+ ...layout,+ ...layoutInput,+ },+ ),+ },+ ),+ };+ };diff --git a/apps/nextjs/src/components/board/items/actions/remove-item.ts b/apps/nextjs/src/components/board/items/actions/remove-item.tsnew file mode 100644index 000000000..ab879ddf8--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/remove-item.ts@@ -0,0 +1,12 @@+import type { Board } from "~/app/[locale]/boards/_types";++export interface RemoveItemInput {+ itemId: string;+}++export const removeItemCallback =+ ({ itemId }: RemoveItemInput) =>+ (board: Board): Board => ({+ ...board,+ items: board.items.filter((item) => item.id !== itemId),+ });diff --git a/apps/nextjs/src/components/board/items/actions/section-elements.ts b/apps/nextjs/src/components/board/items/actions/section-elements.tsnew file mode 100644index 000000000..09efc67c8--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/section-elements.ts@@ -0,0 +1,18 @@+import type { Board } from "~/app/[locale]/boards/_types";++export const getSectionElements = (board: Board, { sectionId, layoutId }: { sectionId: string; layoutId: string }) => {+ const dynamicSectionsOfFirstSection = board.sections+ .filter((section) => section.kind === "dynamic")+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ .map(({ layouts, ...section }) => ({ ...section, ...layouts.find((layout) => layout.layoutId === layoutId)! }))+ .filter((section) => section.parentSectionId === sectionId);+ const items = board.items+ .map(({ layouts, ...item }) => ({+ ...item,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ ...layouts.find((layout) => layout.layoutId === layoutId)!,+ }))+ .filter((item) => item.sectionId === sectionId);++ return [...items, ...dynamicSectionsOfFirstSection];+};diff --git a/apps/nextjs/src/components/board/items/actions/test/create-item.spec.ts b/apps/nextjs/src/components/board/items/actions/test/create-item.spec.tsindex a0846241a..b76abdd2c 100644--- a/apps/nextjs/src/components/board/items/actions/test/create-item.spec.ts+++ b/apps/nextjs/src/components/board/items/actions/test/create-item.spec.ts@@ -1,61 +1,109 @@import { describe, expect, test, vi } from "vitest";-import type { Board } from "~/app/[locale]/boards/_types";+import * as boardContext from "@homarr/boards/context";+import { createItemCallback } from "../create-item";-import * as emptyPosition from "../empty-position";-import { createDynamicSection, createEmptySection, createItem } from "./shared";+import * as emptyPositionModule from "../empty-position";+import { BoardMockBuilder } from "./mocks/board-mock";+import { DynamicSectionMockBuilder } from "./mocks/dynamic-section-mock";+import { ItemMockBuilder } from "./mocks/item-mock";+import { LayoutMockBuilder } from "./mocks/layout-mock";describe("item actions create-item", () => {test("should add it to first section", () => {- const spy = vi.spyOn(emptyPosition, "getFirstEmptyPosition");- spy.mockReturnValue({ xOffset: 5, yOffset: 5 });- const input = {- sections: [createEmptySection("1", 2), createEmptySection("2", 0), createEmptySection("3", 1)],- columnCount: 4,- } satisfies Pick<Board, "sections" | "columnCount">;+ // Arrange+ const itemKind = "clock";+ const emptyPosition = { xOffset: 5, yOffset: 5 };+ const firstSectionId = "2";+ const layoutId = "1";++ const layout = new LayoutMockBuilder({ id: layoutId, columnCount: 4 }).build();+ const board = new BoardMockBuilder()+ .addLayout(layout)+ .addLayout()+ .addEmptySection({ id: "1", yOffset: 2 })+ .addEmptySection({ id: firstSectionId, yOffset: 0 })+ .addEmptySection({ id: "3", yOffset: 1 })+ .build();++ const emptyPositionSpy = vi.spyOn(emptyPositionModule, "getFirstEmptyPosition");+ emptyPositionSpy.mockReturnValue(emptyPosition);+ const layoutsSpy = vi.spyOn(boardContext, "getBoardLayouts");+ layoutsSpy.mockReturnValue([layoutId]);+ // Actconst result = createItemCallback({- kind: "clock",- })(input as unknown as Board);+ kind: itemKind,+ })(board);- const firstSection = result.sections.find((section) => section.id === "2");- const item = firstSection?.items.at(0);- expect(item).toEqual(expect.objectContaining({ kind: "clock", xOffset: 5, yOffset: 5 }));- expect(spy).toHaveBeenCalledWith([], input.columnCount);+ // Assert+ const item = result.items.at(0);+ expect(item).toEqual(+ expect.objectContaining({+ kind: itemKind,+ layouts: [+ {+ layoutId,+ height: 1,+ width: 1,+ ...emptyPosition,+ sectionId: firstSectionId,+ },+ ],+ }),+ );+ expect(emptyPositionSpy).toHaveBeenCalledWith([], layout.columnCount);});test("should correctly pass dynamic section and items to getFirstEmptyPosition", () => {- const spy = vi.spyOn(emptyPosition, "getFirstEmptyPosition");- spy.mockReturnValue({ xOffset: 5, yOffset: 5 });- const firstSection = createEmptySection("2", 0);- const expectedItem = createItem({ id: "12", xOffset: 1, yOffset: 2, width: 3, height: 2 });- firstSection.items.push(expectedItem);- const dynamicSectionInFirst = createDynamicSection({- id: "4",- parentSectionId: "2",- yOffset: 0,- xOffset: 0,- width: 2,- height: 2,- });-- const input = {- sections: [- createEmptySection("1", 2),- firstSection,- createEmptySection("3", 1),- dynamicSectionInFirst,- createDynamicSection({ id: "5", parentSectionId: "3", yOffset: 1 }),- ],- columnCount: 4,- } satisfies Pick<Board, "sections" | "columnCount">;+ // Arrange+ const itemKind = "clock";+ const emptyPosition = { xOffset: 5, yOffset: 5 };+ const firstSectionId = "2";+ const layoutId = "1";+ const itemAndSectionPosition = { height: 2, width: 3, yOffset: 2, xOffset: 1 };++ const layout = new LayoutMockBuilder({ id: layoutId, columnCount: 4 }).build();+ const dynamicSectionInFirstSection = new DynamicSectionMockBuilder({ id: "4" })+ .addLayout({ ...itemAndSectionPosition, layoutId, parentSectionId: firstSectionId })+ .build();+ const itemInFirstSection = new ItemMockBuilder({ id: "12" })+ .addLayout({ ...itemAndSectionPosition, layoutId, sectionId: firstSectionId })+ .build();+ const otherDynamicSection = new DynamicSectionMockBuilder({ id: "5" }).addLayout({ layoutId }).build();+ const otherItem = new ItemMockBuilder({ id: "13" }).addLayout({ layoutId }).build();+ const board = new BoardMockBuilder()+ .addLayout(layout)+ .addEmptySection({ id: "1", yOffset: 2 })+ .addEmptySection({ id: firstSectionId, yOffset: 0 })+ .addEmptySection({ id: "3", yOffset: 1 })+ .addSection(dynamicSectionInFirstSection)+ .addSection(otherDynamicSection)+ .addItem(itemInFirstSection)+ .addItem(otherItem)+ .build();++ const spy = vi.spyOn(emptyPositionModule, "getFirstEmptyPosition");+ spy.mockReturnValue(emptyPosition);+ const layoutsSpy = vi.spyOn(boardContext, "getBoardLayouts");+ layoutsSpy.mockReturnValue([layoutId]);+ // Actconst result = createItemCallback({- kind: "clock",- })(input as unknown as Board);+ kind: itemKind,+ })(board);- const firstSectionResult = result.sections.find((section) => section.id === "2");- const item = firstSectionResult?.items.find((item) => item.id !== "12");- expect(item).toEqual(expect.objectContaining({ kind: "clock", xOffset: 5, yOffset: 5 }));- expect(spy).toHaveBeenCalledWith([expectedItem, dynamicSectionInFirst], input.columnCount);+ // Assert+ expect(result.items.length).toBe(3);+ const item = result.items.find((item) => item.id !== itemInFirstSection.id && item.id !== otherItem.id);+ expect(item).toEqual(+ expect.objectContaining({+ kind: itemKind,+ layouts: [{ ...emptyPosition, height: 1, width: 1, sectionId: firstSectionId, layoutId }],+ }),+ );+ expect(spy).toHaveBeenCalledWith(+ [expect.objectContaining(itemAndSectionPosition), expect.objectContaining(itemAndSectionPosition)],+ layout.columnCount,+ );});});diff --git a/apps/nextjs/src/components/board/items/actions/test/duplicate-item.spec.ts b/apps/nextjs/src/components/board/items/actions/test/duplicate-item.spec.tsindex d02e908c0..7bb2fb7ad 100644--- a/apps/nextjs/src/components/board/items/actions/test/duplicate-item.spec.ts+++ b/apps/nextjs/src/components/board/items/actions/test/duplicate-item.spec.ts@@ -1,51 +1,63 @@import { describe, expect, test, vi } from "vitest";-import type { Board } from "~/app/[locale]/boards/_types";import { duplicateItemCallback } from "../duplicate-item";-import * as emptyPosition from "../empty-position";-import { createEmptySection, createItem } from "./shared";+import * as emptyPositionModule from "../empty-position";+import { BoardMockBuilder } from "./mocks/board-mock";+import { ItemMockBuilder } from "./mocks/item-mock";+import { LayoutMockBuilder } from "./mocks/layout-mock";describe("item actions duplicate-item", () => {test("should copy it in the same section", () => {- const spy = vi.spyOn(emptyPosition, "getFirstEmptyPosition");- spy.mockReturnValue({ xOffset: 5, yOffset: 5 });- const currentSection = createEmptySection("2", 1);- const currentItem = createItem({- id: "1",- xOffset: 1,- yOffset: 3,- width: 3,- height: 2,- kind: "minecraftServerStatus",+ // Arrange+ const itemKind = "minecraftServerStatus";+ const emptyPosition = { xOffset: 5, yOffset: 5 };+ const currentSectionId = "2";+ const layoutId = "1";+ const currentItemSize = { height: 2, width: 3 };++ const layout = new LayoutMockBuilder({ id: layoutId, columnCount: 4 }).build();+ const currentItem = new ItemMockBuilder({+ kind: itemKind,integrationIds: ["1"],options: { address: "localhost" },advancedOptions: { customCssClasses: ["test"] },- });- const otherItem = createItem({- id: "2",- });- currentSection.items.push(currentItem, otherItem);- const input = {- columnCount: 10,- sections: [createEmptySection("1", 0), currentSection, createEmptySection("3", 2)],- } satisfies Pick<Board, "sections" | "columnCount">;-- const result = duplicateItemCallback({ itemId: currentItem.id })(input as unknown as Board);-- const section = result.sections.find((section) => section.id === "2");- expect(section?.items.length).toBe(3);- const duplicatedItem = section?.items.find((item) => item.id !== currentItem.id && item.id !== otherItem.id);+ })+ .addLayout({ layoutId, sectionId: currentSectionId, ...currentItemSize })+ .build();+ const otherItem = new ItemMockBuilder({ id: "2" }).addLayout({ layoutId }).build();++ const board = new BoardMockBuilder()+ .addLayout(layout)+ .addItem(currentItem)+ .addItem(otherItem)+ .addEmptySection({ id: "1", yOffset: 2 })+ .addEmptySection({ id: currentSectionId, yOffset: 0 })+ .addEmptySection({ id: "3", yOffset: 1 })+ .build();++ const spy = vi.spyOn(emptyPositionModule, "getFirstEmptyPosition");+ spy.mockReturnValue(emptyPosition);++ // Act+ const result = duplicateItemCallback({ itemId: currentItem.id })(board);++ // Assert+ expect(result.items.length).toBe(3);+ const duplicatedItem = result.items.find((item) => item.id !== currentItem.id && item.id !== otherItem.id);expect(duplicatedItem).toEqual(expect.objectContaining({- kind: "minecraftServerStatus",- xOffset: 5,- yOffset: 5,- width: 3,- height: 2,- integrationIds: ["1"],- options: { address: "localhost" },- advancedOptions: { customCssClasses: ["test"] },+ kind: itemKind,+ integrationIds: currentItem.integrationIds,+ options: currentItem.options,+ advancedOptions: currentItem.advancedOptions,+ layouts: [+ expect.objectContaining({+ ...emptyPosition,+ ...currentItemSize,+ sectionId: currentSectionId,+ }),+ ],}),);});diff --git a/apps/nextjs/src/components/board/items/actions/test/empty-position.spec.ts b/apps/nextjs/src/components/board/items/actions/test/empty-position.spec.tsindex 37eac9a5f..fcc194618 100644--- a/apps/nextjs/src/components/board/items/actions/test/empty-position.spec.ts+++ b/apps/nextjs/src/components/board/items/actions/test/empty-position.spec.ts@@ -109,7 +109,7 @@ describe("get first empty position", () => {});const createElementsFromLayout = (layout: string[][]) => {- const elements: (Pick<Item, "xOffset" | "yOffset" | "width" | "height"> & { char: string })[] = [];+ const elements: (Pick<Item["layouts"][number], "xOffset" | "yOffset" | "width" | "height"> & { char: string })[] = [];for (let yOffset = 0; yOffset < layout.length; yOffset++) {const row = layout[yOffset];if (!row) continue;diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/board-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/board-mock.tsnew file mode 100644index 000000000..1afc2e60e--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/board-mock.ts@@ -0,0 +1,90 @@+import { createId } from "@homarr/db";++import type { Board, DynamicSection, EmptySection, Item, Section } from "~/app/[locale]/boards/_types";+import { DynamicSectionMockBuilder } from "./dynamic-section-mock";+import { EmptySectionMockBuilder } from "./empty-section-mock";+import { ItemMockBuilder } from "./item-mock";+import { LayoutMockBuilder } from "./layout-mock";++export class BoardMockBuilder {+ private readonly board: Board;++ constructor(board?: Partial<Omit<Board, "groupPermissions" | "userPermissions" | "sections" | "items" | "layouts">>) {+ this.board = {+ id: createId(),+ backgroundImageRepeat: "no-repeat",+ backgroundImageAttachment: "scroll",+ backgroundImageSize: "cover",+ backgroundImageUrl: null,+ primaryColor: "#ffffff",+ secondaryColor: "#000000",+ iconColor: null,+ itemRadius: "lg",+ pageTitle: "Board",+ metaTitle: "Board",+ logoImageUrl: null,+ faviconImageUrl: null,+ name: "board",+ opacity: 100,+ isPublic: true,+ disableStatus: false,+ customCss: "",+ creatorId: createId(),+ creator: {+ id: createId(),+ image: null,+ name: "User",+ },+ groupPermissions: [],+ userPermissions: [],+ sections: [],+ items: [],+ layouts: [+ {+ id: createId(),+ name: "Base",+ columnCount: 12,+ breakpoint: 0,+ },+ ],+ ...board,+ };+ }++ public addEmptySection(emptySection?: Partial<EmptySection>): BoardMockBuilder {+ return this.addSection(new EmptySectionMockBuilder(emptySection).build());+ }++ public addDynamicSection(dynamicSection?: Partial<DynamicSection>): BoardMockBuilder {+ return this.addSection(new DynamicSectionMockBuilder(dynamicSection).build());+ }++ public addSection(section: Section): BoardMockBuilder {+ this.board.sections.push(section);+ return this;+ }++ public addSections(sections: Section[]): BoardMockBuilder {+ this.board.sections.push(...sections);+ return this;+ }++ public addItem(item?: Partial<Item>): BoardMockBuilder {+ this.board.items.push(new ItemMockBuilder(item).build());+ return this;+ }++ public addItems(items: Item[]): BoardMockBuilder {+ this.board.items.push(...items);+ return this;+ }++ public addLayout(layout?: Partial<Board["layouts"][number]>): BoardMockBuilder {+ this.board.layouts.push(new LayoutMockBuilder(layout).build());+ return this;+ }++ public build(): Board {+ return this.board;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/category-section-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/category-section-mock.tsnew file mode 100644index 000000000..3958bbbfe--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/category-section-mock.ts@@ -0,0 +1,23 @@+import { createId } from "@homarr/db";++import type { CategorySection } from "~/app/[locale]/boards/_types";++export class CategorySectionMockBuilder {+ private readonly section: CategorySection;++ constructor(section?: Partial<CategorySection>) {+ this.section = {+ id: createId(),+ kind: "category",+ xOffset: 0,+ yOffset: 0,+ name: "Category",+ collapsed: false,+ ...section,+ } satisfies CategorySection;+ }++ public build(): CategorySection {+ return this.section;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.tsnew file mode 100644index 000000000..40fdd059f--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/dynamic-section-mock.ts@@ -0,0 +1,33 @@+import { createId } from "@homarr/db";++import type { DynamicSection } from "~/app/[locale]/boards/_types";++export class DynamicSectionMockBuilder {+ private readonly section: DynamicSection;++ constructor(section?: Partial<DynamicSection>) {+ this.section = {+ id: createId(),+ kind: "dynamic",+ layouts: [],+ ...section,+ } satisfies DynamicSection;+ }++ public addLayout(layout?: Partial<DynamicSection["layouts"][0]>): DynamicSectionMockBuilder {+ this.section.layouts.push({+ layoutId: "1",+ height: 1,+ width: 1,+ xOffset: 0,+ yOffset: 0,+ parentSectionId: "0",+ ...layout,+ } satisfies DynamicSection["layouts"][0]);+ return this;+ }++ public build(): DynamicSection {+ return this.section;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/empty-section-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/empty-section-mock.tsnew file mode 100644index 000000000..a02a0b137--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/empty-section-mock.ts@@ -0,0 +1,21 @@+import { createId } from "@homarr/db";++import type { EmptySection } from "~/app/[locale]/boards/_types";++export class EmptySectionMockBuilder {+ private readonly section: EmptySection;++ constructor(section?: Partial<EmptySection>) {+ this.section = {+ id: createId(),+ kind: "empty",+ xOffset: 0,+ yOffset: 0,+ ...section,+ } satisfies EmptySection;+ }++ public build(): EmptySection {+ return this.section;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/item-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/item-mock.tsnew file mode 100644index 000000000..f7533bd56--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/item-mock.ts@@ -0,0 +1,38 @@+import { createId } from "@homarr/db";++import type { Item } from "~/app/[locale]/boards/_types";++export class ItemMockBuilder {+ private readonly item: Item;++ constructor(item?: Partial<Item>) {+ this.item = {+ id: createId(),+ kind: "app",+ options: {},+ layouts: [],+ integrationIds: [],+ advancedOptions: {+ customCssClasses: [],+ },+ ...item,+ } satisfies Item;+ }++ public addLayout(layout?: Partial<Item["layouts"][0]>): ItemMockBuilder {+ this.item.layouts.push({+ layoutId: "1",+ height: 1,+ width: 1,+ xOffset: 0,+ yOffset: 0,+ sectionId: "0",+ ...layout,+ } satisfies Item["layouts"][0]);+ return this;+ }++ public build(): Item {+ return this.item;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/mocks/layout-mock.ts b/apps/nextjs/src/components/board/items/actions/test/mocks/layout-mock.tsnew file mode 100644index 000000000..a5550394a--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/mocks/layout-mock.ts@@ -0,0 +1,21 @@+import { createId } from "@homarr/db";++import type { Board } from "~/app/[locale]/boards/_types";++export class LayoutMockBuilder {+ private readonly layout: Board["layouts"][number];++ constructor(layout?: Partial<Board["layouts"][number]>) {+ this.layout = {+ id: createId(),+ name: "Base",+ columnCount: 12,+ breakpoint: 0,+ ...layout,+ } satisfies Board["layouts"][0];+ }++ public build(): Board["layouts"][0] {+ return this.layout;+ }+}diff --git a/apps/nextjs/src/components/board/items/actions/test/move-and-resize-item.spec.ts b/apps/nextjs/src/components/board/items/actions/test/move-and-resize-item.spec.tsnew file mode 100644index 000000000..de3e5804b--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/move-and-resize-item.spec.ts@@ -0,0 +1,65 @@+import { describe, expect, test, vi } from "vitest";++import * as boardContext from "@homarr/boards/context";++import { moveAndResizeItemCallback } from "../move-and-resize-item";+import { BoardMockBuilder } from "./mocks/board-mock";+import { ItemMockBuilder } from "./mocks/item-mock";++describe("moveItemToSectionCallback should move item in section", () => {+ test("should move item in section", () => {+ // Arrange+ const itemToMove = "2";+ const layoutId = "1";+ const spy = vi.spyOn(boardContext, "getCurrentLayout");+ spy.mockReturnValue(layoutId);+ const newPosition = {+ xOffset: 20,+ yOffset: 30,+ width: 15,+ height: 17,+ };+ const itemA = new ItemMockBuilder().addLayout({ layoutId }).build();+ const itemB = new ItemMockBuilder({ id: itemToMove }).addLayout({ layoutId }).addLayout().build();+ const itemC = new ItemMockBuilder().addLayout({ layoutId }).build();+ const board = new BoardMockBuilder().addItem(itemA).addItem(itemB).addItem(itemC).build();++ // Act+ const updatedBoard = moveAndResizeItemCallback({ itemId: itemToMove, ...newPosition })(board);++ // Assert+ expect(updatedBoard.items).toHaveLength(3);+ const movedItem = updatedBoard.items.find((item) => item.id === itemToMove);+ expect(movedItem).not.toBeUndefined();+ expect(movedItem?.layouts.find((layout) => layout.layoutId === layoutId)).toEqual(+ expect.objectContaining(newPosition),+ );+ const otherItemLayouts = updatedBoard.items+ .filter((item) => item.id !== itemToMove)+ .flatMap((item) => item.layouts);+ expect(otherItemLayouts).not.toContainEqual(expect.objectContaining(newPosition));+ });+ test("should not move item if item not found", () => {+ // Arrange+ const itemToMove = "2";+ const layoutId = "1";+ const spy = vi.spyOn(boardContext, "getCurrentLayout");+ spy.mockReturnValue(layoutId);+ const newPosition = {+ xOffset: 20,+ yOffset: 30,+ width: 15,+ height: 17,+ };+ const itemA = new ItemMockBuilder().addLayout({ layoutId }).build();+ const itemC = new ItemMockBuilder().addLayout({ layoutId }).build();+ const board = new BoardMockBuilder().addItem(itemA).addItem(itemC).build();++ // Act+ const updatedBoard = moveAndResizeItemCallback({ itemId: itemToMove, ...newPosition })(board);++ // Assert+ expect(updatedBoard.items).toHaveLength(2);+ expect(updatedBoard.items.find((item) => item.layouts.at(0)?.yOffset === newPosition.yOffset)).toBeUndefined();+ });+});diff --git a/apps/nextjs/src/components/board/items/actions/test/move-item-to-section.spec.ts b/apps/nextjs/src/components/board/items/actions/test/move-item-to-section.spec.tsnew file mode 100644index 000000000..41e838ed2--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/move-item-to-section.spec.ts@@ -0,0 +1,67 @@+import { describe, expect, test, vi } from "vitest";++import * as boardContext from "@homarr/boards/context";++import { moveItemToSectionCallback } from "../move-item-to-section";+import { BoardMockBuilder } from "./mocks/board-mock";+import { ItemMockBuilder } from "./mocks/item-mock";++describe("moveItemToSectionCallback should move item to section", () => {+ test("should move item to section", () => {+ // Arrange+ const itemToMove = "2";+ const layoutId = "1";+ const spy = vi.spyOn(boardContext, "getCurrentLayout");+ spy.mockReturnValue(layoutId);+ const newPosition = {+ sectionId: "3",+ xOffset: 20,+ yOffset: 30,+ width: 15,+ height: 17,+ };+ const itemA = new ItemMockBuilder().addLayout({ layoutId }).build();+ const itemB = new ItemMockBuilder({ id: itemToMove }).addLayout({ layoutId }).addLayout().build();+ const itemC = new ItemMockBuilder().addLayout({ layoutId }).build();+ const board = new BoardMockBuilder().addItem(itemA).addItem(itemB).addItem(itemC).build();++ // Act+ const updatedBoard = moveItemToSectionCallback({ itemId: itemToMove, ...newPosition })(board);++ // Assert+ expect(updatedBoard.items).toHaveLength(3);+ const movedItem = updatedBoard.items.find((item) => item.id === itemToMove);+ expect(movedItem).not.toBeUndefined();+ expect(movedItem?.layouts.find((layout) => layout.layoutId === layoutId)).toEqual(+ expect.objectContaining(newPosition),+ );+ const otherItemLayouts = updatedBoard.items+ .filter((item) => item.id !== itemToMove)+ .flatMap((item) => item.layouts);+ expect(otherItemLayouts).not.toContainEqual(expect.objectContaining(newPosition));+ });+ test("should not move item if item not found", () => {+ // Arrange+ const itemToMove = "2";+ const layoutId = "1";+ const spy = vi.spyOn(boardContext, "getCurrentLayout");+ spy.mockReturnValue(layoutId);+ const newPosition = {+ sectionId: "3",+ xOffset: 20,+ yOffset: 30,+ width: 15,+ height: 17,+ };+ const itemA = new ItemMockBuilder().addLayout({ layoutId }).build();+ const itemC = new ItemMockBuilder().addLayout({ layoutId }).build();+ const board = new BoardMockBuilder().addItem(itemA).addItem(itemC).build();++ // Act+ const updatedBoard = moveItemToSectionCallback({ itemId: itemToMove, ...newPosition })(board);++ // Assert+ expect(updatedBoard.items).toHaveLength(2);+ expect(updatedBoard.items.find((item) => item.layouts.at(0)?.sectionId === newPosition.sectionId)).toBeUndefined();+ });+});diff --git a/apps/nextjs/src/components/board/items/actions/test/remove-item.spec.ts b/apps/nextjs/src/components/board/items/actions/test/remove-item.spec.tsnew file mode 100644index 000000000..baa59e275--- /dev/null+++ b/apps/nextjs/src/components/board/items/actions/test/remove-item.spec.ts@@ -0,0 +1,37 @@+import { describe, expect, test } from "vitest";++import { removeItemCallback } from "../remove-item";+import { BoardMockBuilder } from "./mocks/board-mock";++describe("removeItemCallback should remove item from board", () => {+ test("should remove correct item from board", () => {+ // Arrange+ const itemIdToRemove = "2";+ const board = new BoardMockBuilder()+ .addItem({ id: "1" })+ .addItem({ id: itemIdToRemove })+ .addItem({ id: "3" })+ .build();++ // Act+ const updatedBoard = removeItemCallback({ itemId: itemIdToRemove })(board);++ // Assert+ const itemIds = updatedBoard.items.map((item) => item.id);+ expect(itemIds).toHaveLength(2);+ expect(itemIds).not.toContain(itemIdToRemove);+ });+ test("should not remove item if item not found", () => {+ // Arrange+ const itemIdToRemove = "2";+ const board = new BoardMockBuilder().addItem({ id: "1" }).addItem({ id: "3" }).build();++ // Act+ const updatedBoard = removeItemCallback({ itemId: itemIdToRemove })(board);++ // Assert+ const itemIds = updatedBoard.items.map((item) => item.id);+ expect(itemIds).toHaveLength(2);+ expect(itemIds).not.toContain(itemIdToRemove);+ });+});diff --git a/apps/nextjs/src/components/board/items/actions/test/shared.ts b/apps/nextjs/src/components/board/items/actions/test/shared.tsdeleted file mode 100644index af3329f49..000000000--- a/apps/nextjs/src/components/board/items/actions/test/shared.ts+++ /dev/null@@ -1,32 +0,0 @@-import type { DynamicSection, EmptySection, Item } from "~/app/[locale]/boards/_types";--export const createEmptySection = (id: string, yOffset: number): EmptySection => ({- id,- kind: "empty",- yOffset,- xOffset: 0,- items: [],-});--export const createDynamicSection = (section: Omit<Partial<DynamicSection>, "kind">): DynamicSection => ({- id: section.id ?? "0",- kind: "dynamic",- parentSectionId: section.parentSectionId ?? "0",- height: section.height ?? 1,- width: section.width ?? 1,- yOffset: section.yOffset ?? 0,- xOffset: section.xOffset ?? 0,- items: section.items ?? [],-});--export const createItem = (item: Partial<Item>): Item => ({- id: item.id ?? "0",- width: item.width ?? 1,- height: item.height ?? 1,- yOffset: item.yOffset ?? 0,- xOffset: item.xOffset ?? 0,- kind: item.kind ?? "clock",- integrationIds: item.integrationIds ?? [],- options: item.options ?? {},- advancedOptions: item.advancedOptions ?? { customCssClasses: [] },-});diff --git a/apps/nextjs/src/components/board/items/item-actions.tsx b/apps/nextjs/src/components/board/items/item-actions.tsxindex bdda5793f..609cfa0aa 100644--- a/apps/nextjs/src/components/board/items/item-actions.tsx+++ b/apps/nextjs/src/components/board/items/item-actions.tsx@@ -3,30 +3,16 @@ import { useCallback } from "react";import { useUpdateBoard } from "@homarr/boards/updater";import type { BoardItemAdvancedOptions } from "@homarr/validation";-import type { Item } from "~/app/[locale]/boards/_types";import type { CreateItemInput } from "./actions/create-item";import { createItemCallback } from "./actions/create-item";import type { DuplicateItemInput } from "./actions/duplicate-item";import { duplicateItemCallback } from "./actions/duplicate-item";--interface MoveAndResizeItem {- itemId: string;- xOffset: number;- yOffset: number;- width: number;- height: number;-}-interface MoveItemToSection {- itemId: string;- sectionId: string;- xOffset: number;- yOffset: number;- width: number;- height: number;-}-interface RemoveItem {- itemId: string;-}+import type { MoveAndResizeItemInput } from "./actions/move-and-resize-item";+import { moveAndResizeItemCallback } from "./actions/move-and-resize-item";+import type { MoveItemToSectionInput } from "./actions/move-item-to-section";+import { moveItemToSectionCallback } from "./actions/move-item-to-section";+import type { RemoveItemInput } from "./actions/remove-item";+import { removeItemCallback } from "./actions/remove-item";interface UpdateItemOptions {itemId: string;@@ -62,164 +48,55 @@ export const useItemActions = () => {const updateItemOptions = useCallback(({ itemId, newOptions }: UpdateItemOptions) => {- updateBoard((previous) => {- return {- ...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (!section.items.some((item) => item.id === itemId)) return section;- return {- ...section,- items: section.items.map((item) => {- // Return same item if item is not the one we're changing- if (item.id !== itemId) return item;- return {- ...item,- options: newOptions,- };- }),- };- }),- };- });+ updateBoard((previous) => ({+ ...previous,+ items: previous.items.map((item) => (item.id !== itemId ? item : { ...item, options: newOptions })),+ }));},[updateBoard],);const updateItemAdvancedOptions = useCallback(({ itemId, newAdvancedOptions }: UpdateItemAdvancedOptions) => {- updateBoard((previous) => {- return {- ...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (!section.items.some((item) => item.id === itemId)) return section;- return {- ...section,- items: section.items.map((item) => {- // Return same item if item is not the one we're changing- if (item.id !== itemId) return item;- return {- ...item,- advancedOptions: newAdvancedOptions,- };- }),- };- }),- };- });+ updateBoard((previous) => ({+ ...previous,+ items: previous.items.map((item) =>+ item.id !== itemId ? item : { ...item, advancedOptions: newAdvancedOptions },+ ),+ }));},[updateBoard],);const updateItemIntegrations = useCallback(({ itemId, newIntegrations }: UpdateItemIntegrations) => {- updateBoard((previous) => {- return {- ...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (!section.items.some((item) => item.id === itemId)) return section;- return {- ...section,- items: section.items.map((item) => {- // Return same item if item is not the one we're moving- if (item.id !== itemId) return item;- return {- ...item,- ...("integrationIds" in item ? { integrationIds: newIntegrations } : {}),- };- }),- };- }),- };- });+ updateBoard((previous) => ({+ ...previous,+ items: previous.items.map((item) =>+ item.id !== itemId || !("integrationIds" in item) ? item : { ...item, integrationIds: newIntegrations },+ ),+ }));},[updateBoard],);const moveAndResizeItem = useCallback(- ({ itemId, ...positionProps }: MoveAndResizeItem) => {- updateBoard((previous) => ({- ...previous,- sections: previous.sections.map((section) => {- // Return same section if item is not in it- if (!section.items.some((item) => item.id === itemId)) return section;- return {- ...section,- items: section.items.map((item) => {- // Return same item if item is not the one we're moving- if (item.id !== itemId) return item;- return {- ...item,- ...positionProps,- } satisfies Item;- }),- };- }),- }));+ (input: MoveAndResizeItemInput) => {+ updateBoard(moveAndResizeItemCallback(input));},[updateBoard],);const moveItemToSection = useCallback(- ({ itemId, sectionId, ...positionProps }: MoveItemToSection) => {- updateBoard((previous) => {- const currentSection = previous.sections.find((section) => section.items.some((item) => item.id === itemId));-- // If item is in the same section (on initial loading) don't do anything- if (!currentSection) {- return previous;- }-- const currentItem = currentSection.items.find((item) => item.id === itemId);- if (!currentItem) {- return previous;- }-- if (currentSection.id === sectionId && currentItem.xOffset) {- return previous;- }-- return {- ...previous,- sections: previous.sections.map((section) => {- // Return sections without item if not section where it is moved to- if (section.id !== sectionId)- return {- ...section,- items: section.items.filter((item) => item.id !== itemId),- };-- // Return section and add item to it- return {- ...section,- items: section.items- .filter((item) => item.id !== itemId)- .concat({- ...currentItem,- ...positionProps,- }),- };- }),- };- });+ (input: MoveItemToSectionInput) => {+ updateBoard(moveItemToSectionCallback(input));},[updateBoard],);const removeItem = useCallback(- ({ itemId }: RemoveItem) => {- updateBoard((previous) => {- return {- ...previous,- // Filter removed item out of items array- sections: previous.sections.map((section) => ({- ...section,- items: section.items.filter((item) => item.id !== itemId),- })),- };- });+ ({ itemId }: RemoveItemInput) => {+ updateBoard(removeItemCallback({ itemId }));},[updateBoard],);diff --git a/apps/nextjs/src/components/board/items/item-content.tsx b/apps/nextjs/src/components/board/items/item-content.tsxindex 8166ea96c..b486a20cf 100644--- a/apps/nextjs/src/components/board/items/item-content.tsx+++ b/apps/nextjs/src/components/board/items/item-content.tsx@@ -11,13 +11,13 @@ import { useSettings } from "@homarr/settings";import { loadWidgetDynamic, reduceWidgetOptionsWithDefaultValues, widgetImports } from "@homarr/widgets";import { WidgetError } from "@homarr/widgets/errors";-import type { Item } from "~/app/[locale]/boards/_types";+import type { SectionItem } from "~/app/[locale]/boards/_types";import classes from "../sections/item.module.css";import { useItemActions } from "./item-actions";import { BoardItemMenu } from "./item-menu";interface BoardItemContentProps {- item: Item;+ item: SectionItem;}export const BoardItemContent = ({ item }: BoardItemContentProps) => {@@ -50,7 +50,7 @@ export const BoardItemContent = ({ item }: BoardItemContentProps) => {};interface InnerContentProps {- item: Item;+ item: SectionItem;width: number;height: number;}diff --git a/apps/nextjs/src/components/board/items/item-menu.tsx b/apps/nextjs/src/components/board/items/item-menu.tsxindex 3d01f8aaf..e7072fea4 100644--- a/apps/nextjs/src/components/board/items/item-menu.tsx+++ b/apps/nextjs/src/components/board/items/item-menu.tsx@@ -10,7 +10,7 @@ import { useI18n, useScopedI18n } from "@homarr/translation/client";import { widgetImports } from "@homarr/widgets";import { WidgetEditModal } from "@homarr/widgets/modals";-import type { Item } from "~/app/[locale]/boards/_types";+import type { SectionItem } from "~/app/[locale]/boards/_types";import { useSectionContext } from "../sections/section-context";import { useItemActions } from "./item-actions";import { ItemMoveModal } from "./item-move-modal";@@ -21,7 +21,7 @@ export const BoardItemMenu = ({resetErrorBoundary,}: {offset: number;- item: Item;+ item: SectionItem;resetErrorBoundary?: () => void;}) => {const refResetErrorBoundaryOnNextRender = useRef(false);diff --git a/apps/nextjs/src/components/board/items/item-move-modal.tsx b/apps/nextjs/src/components/board/items/item-move-modal.tsxindex d93e4b26b..7257fcb49 100644--- a/apps/nextjs/src/components/board/items/item-move-modal.tsx+++ b/apps/nextjs/src/components/board/items/item-move-modal.tsx@@ -7,11 +7,11 @@ import type { GridStack } from "@homarr/gridstack";import { createModal } from "@homarr/modals";import { useI18n, useScopedI18n } from "@homarr/translation/client";-import type { Item } from "~/app/[locale]/boards/_types";+import type { Item, SectionItem } from "~/app/[locale]/boards/_types";interface InnerProps {gridStack: GridStack;- item: Pick<Item, "id" | "xOffset" | "yOffset" | "width" | "height">;+ item: Pick<SectionItem, "id" | "width" | "height" | "xOffset" | "yOffset">;columnCount: number;}@@ -47,7 +47,7 @@ export const ItemMoveModal = createModal<InnerProps>(({ actions, innerProps }) =);const handleSubmit = useCallback(- (values: Omit<InnerProps["item"], "id">) => {+ (values: Pick<Item["layouts"][number], "height" | "width" | "xOffset" | "yOffset">) => {const gridItem = innerProps.gridStack.getGridItems().find((item) => item.getAttribute("data-id") === innerProps.item.id);diff --git a/apps/nextjs/src/components/board/sections/category/actions/remove-category.ts b/apps/nextjs/src/components/board/sections/category/actions/remove-category.tsindex 19ec37601..cfb0879c1 100644--- a/apps/nextjs/src/components/board/sections/category/actions/remove-category.ts+++ b/apps/nextjs/src/components/board/sections/category/actions/remove-category.ts@@ -1,4 +1,6 @@-import type { Board, CategorySection, DynamicSection, EmptySection, Section } from "~/app/[locale]/boards/_types";+import { getBoardLayouts } from "@homarr/boards/context";++import type { Board, CategorySection, EmptySection, Section } from "~/app/[locale]/boards/_types";export interface RemoveCategoryInput {id: string;@@ -28,84 +30,121 @@ export const removeCategoryCallback =return previous;}- // Calculate the yOffset for the items in the currentCategory and removedWrapper to add them with the same offset to the aboveWrapper- const aboveYOffset = Math.max(- calculateYHeightWithOffsetForItems(aboveSection),- calculateYHeightWithOffsetForDynamicSections(previous.sections, aboveSection.id),- );- const categoryYOffset = Math.max(- calculateYHeightWithOffsetForItems(currentCategory),- calculateYHeightWithOffsetForDynamicSections(previous.sections, currentCategory.id),- );+ const aboveYOffsets = getBoardLayouts(previous).map((layoutId) => {+ return {+ layoutId,+ yOffset: Math.max(+ calculateYHeightWithOffsetForItemLayouts(previous, { sectionId: aboveSection.id, layoutId }),+ calculateYHeightWithOffsetForDynamicSectionLayouts(previous.sections, {+ sectionId: aboveSection.id,+ layoutId,+ }),+ ),+ };+ });- const previousCategoryItems = currentCategory.items.map((item) => ({- ...item,- yOffset: item.yOffset + aboveYOffset,- }));- const previousBelowWrapperItems = removedSection.items.map((item) => ({- ...item,- yOffset: item.yOffset + aboveYOffset + categoryYOffset,- }));+ const categoryYOffsets = getBoardLayouts(previous).map((layoutId) => {+ return {+ layoutId,+ yOffset: Math.max(+ calculateYHeightWithOffsetForItemLayouts(previous, { sectionId: currentCategory.id, layoutId }),+ calculateYHeightWithOffsetForDynamicSectionLayouts(previous.sections, {+ sectionId: currentCategory.id,+ layoutId,+ }),+ ),+ };+ });return {...previous,- sections: [- ...previous.sections.filter((section) => section.yOffset < aboveSection.yOffset && section.kind !== "dynamic"),- {- ...aboveSection,- items: [...aboveSection.items, ...previousCategoryItems, ...previousBelowWrapperItems],- },- ...previous.sections- .filter(- (section): section is CategorySection | EmptySection =>- section.yOffset > removedSection.yOffset && section.kind !== "dynamic",- )- .map((section) => ({- ...section,- position: section.yOffset - 2,- })),- ...previous.sections- .filter((section): section is DynamicSection => section.kind === "dynamic")- .map((dynamicSection) => {- // Move dynamic sections from removed section to above section with required yOffset- if (dynamicSection.parentSectionId === removedSection.id) {- return {- ...dynamicSection,- yOffset: dynamicSection.yOffset + aboveYOffset + categoryYOffset,- parentSectionId: aboveSection.id,- };- }-- // Move dynamic sections from category to above section with required yOffset- if (dynamicSection.parentSectionId === currentCategory.id) {- return {- ...dynamicSection,- yOffset: dynamicSection.yOffset + aboveYOffset,- parentSectionId: aboveSection.id,- };- }-- return dynamicSection;- }),- ],+ sections: previous.sections+ .filter((section) => section.id !== currentCategory.id && section.id !== removedSection.id)+ .map((section) =>+ section.kind === "dynamic"+ ? {+ ...section,+ layouts: section.layouts.map((layout) => {+ const aboveYOffset = aboveYOffsets.find(({ layoutId }) => layout.layoutId === layoutId)?.yOffset ?? 0;+ const categoryYOffset =+ categoryYOffsets.find(({ layoutId }) => layout.layoutId === layoutId)?.yOffset ?? 0;++ if (layout.parentSectionId === currentCategory.id) {+ return {+ ...layout,+ yOffset: layout.yOffset + aboveYOffset,+ parentSectionId: aboveSection.id,+ };+ }++ if (layout.parentSectionId === removedSection.id) {+ return {+ ...layout,+ yOffset: layout.yOffset + aboveYOffset + categoryYOffset,+ parentSectionId: aboveSection.id,+ };+ }++ return layout;+ }),+ }+ : section,+ ),++ items: previous.items.map((item) => ({+ ...item,+ layouts: item.layouts.map((layout) => {+ const aboveYOffset = aboveYOffsets.find(({ layoutId }) => layout.layoutId === layoutId)?.yOffset ?? 0;+ const categoryYOffset = categoryYOffsets.find(({ layoutId }) => layout.layoutId === layoutId)?.yOffset ?? 0;++ if (layout.sectionId === currentCategory.id) {+ return {+ ...layout,+ yOffset: layout.yOffset + aboveYOffset,+ sectionId: aboveSection.id,+ };+ }++ if (layout.sectionId === removedSection.id) {+ return {+ ...layout,+ yOffset: layout.yOffset + aboveYOffset + categoryYOffset,+ sectionId: aboveSection.id,+ };+ }++ return layout;+ }),+ })),};};-const calculateYHeightWithOffsetForDynamicSections = (sections: Section[], sectionId: string) => {- return sections.reduce((acc, section) => {- if (section.kind !== "dynamic" || section.parentSectionId !== sectionId) {+const calculateYHeightWithOffsetForDynamicSectionLayouts = (+ sections: Section[],+ { sectionId, layoutId }: { sectionId: string; layoutId: string },+) => {+ return sections+ .filter((section) => section.kind === "dynamic")+ .map((section) => section.layouts.find((layout) => layout.layoutId === layoutId))+ .filter((layout) => layout !== undefined)+ .filter((layout) => layout.parentSectionId === sectionId)+ .reduce((acc, layout) => {+ const yHeightWithOffset = layout.yOffset + layout.height;+ if (yHeightWithOffset > acc) return yHeightWithOffset;return acc;- }-- const yHeightWithOffset = section.yOffset + section.height;- if (yHeightWithOffset > acc) return yHeightWithOffset;- return acc;- }, 0);+ }, 0);};-const calculateYHeightWithOffsetForItems = (section: Section) =>- section.items.reduce((acc, item) => {- const yHeightWithOffset = item.yOffset + item.height;- if (yHeightWithOffset > acc) return yHeightWithOffset;- return acc;- }, 0);+const calculateYHeightWithOffsetForItemLayouts = (+ board: Board,+ { sectionId, layoutId }: { sectionId: string; layoutId: string },+) =>+ board.items+ .map((item) => item.layouts.find((layout) => layout.layoutId === layoutId))+ .filter((layout) => layout !== undefined)+ .filter((layout) => layout.sectionId === sectionId)+ .reduce((acc, layout) => {+ const yHeightWithOffset = layout.yOffset + layout.height;+ if (yHeightWithOffset > acc) return yHeightWithOffset;+ return acc;+ }, 0);diff --git a/apps/nextjs/src/components/board/sections/category/actions/test/move-category.spec.ts b/apps/nextjs/src/components/board/sections/category/actions/test/move-category.spec.tsindex 9c244524a..6a0c9da4b 100644--- a/apps/nextjs/src/components/board/sections/category/actions/test/move-category.spec.ts+++ b/apps/nextjs/src/components/board/sections/category/actions/test/move-category.spec.ts@@ -73,5 +73,7 @@ const createSections = (categoryCount: number) => {};const sortSections = (sections: Section[]) => {- return sections.sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset);+ return sections+ .filter((section) => section.kind !== "dynamic")+ .sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset);};diff --git a/apps/nextjs/src/components/board/sections/category/actions/test/remove-category.spec.ts b/apps/nextjs/src/components/board/sections/category/actions/test/remove-category.spec.tsindex bc70df222..0aaf2c7a5 100644--- a/apps/nextjs/src/components/board/sections/category/actions/test/remove-category.spec.ts+++ b/apps/nextjs/src/components/board/sections/category/actions/test/remove-category.spec.ts@@ -1,7 +1,14 @@/* eslint-disable @typescript-eslint/no-non-null-assertion */-import { describe, expect, test } from "vitest";+import { describe, expect, test, vi } from "vitest";-import type { DynamicSection, Item, Section } from "~/app/[locale]/boards/_types";+import * as boardContext from "@homarr/boards/context";++import type { DynamicSection, Section } from "~/app/[locale]/boards/_types";+import { BoardMockBuilder } from "~/components/board/items/actions/test/mocks/board-mock";+import { CategorySectionMockBuilder } from "~/components/board/items/actions/test/mocks/category-section-mock";+import { DynamicSectionMockBuilder } from "~/components/board/items/actions/test/mocks/dynamic-section-mock";+import { EmptySectionMockBuilder } from "~/components/board/items/actions/test/mocks/empty-section-mock";+import { ItemMockBuilder } from "~/components/board/items/actions/test/mocks/item-mock";import { removeCategoryCallback } from "../remove-category";describe("Remove Category", () => {@@ -13,114 +20,126 @@ describe("Remove Category", () => {])("should remove category",(removeId, initialYOffsets, expectedYOffsets, expectedRemovals, expectedLocationOfItems) => {- const sections = createSections(initialYOffsets);-+ // Arrange+ const layoutId = "1";const input = removeId.toString();- const result = removeCategoryCallback({ id: input })({ sections } as never);+ const board = new BoardMockBuilder()+ .addLayout({ id: layoutId })+ .addSections(createSections(initialYOffsets))+ .addItems(createSectionItems(initialYOffsets, layoutId))+ .build();++ vi.spyOn(boardContext, "getBoardLayouts").mockReturnValue([layoutId]);++ // Act+ const result = removeCategoryCallback({ id: input })(board);+ // Assertexpect(result.sections.map((section) => parseInt(section.id, 10))).toEqual(expectedYOffsets);expectedRemovals.forEach((expectedRemoval) => {expect(result.sections.find((section) => section.id === expectedRemoval.toString())).toBeUndefined();});- const aboveSection = result.sections.find((section) => section.id === expectedLocationOfItems.toString());- expect(aboveSection?.items.map((item) => parseInt(item.id, 10))).toEqual(- expect.arrayContaining(expectedRemovals),+ const aboveSectionItems = result.items.filter(+ (item) => item.layouts[0]?.sectionId === expectedLocationOfItems.toString(),);+ expect(aboveSectionItems.map((item) => parseInt(item.id, 10))).toEqual(expect.arrayContaining(expectedRemovals));},);test("should correctly move items to above empty section", () => {+ // Arrange+ const layoutId = "1";+ const sectionIds = {+ above: "2",+ category: "3",+ below: "4",+ dynamic: "7",+ };const initialYOffsets = [0, 1, 2, 3, 4, 5, 6];- const sections: Section[] = createSections(initialYOffsets);- const aboveSection = sections.find((section) => section.yOffset === 2)!;- aboveSection.items = [- createItem({ id: "above-1" }),- createItem({ id: "above-2", yOffset: 3, xOffset: 2, height: 2 }),- ];- const removedCategory = sections.find((section) => section.yOffset === 3)!;- removedCategory.items = [- createItem({ id: "category-1" }),- createItem({ id: "category-2", yOffset: 2, xOffset: 4, width: 4 }),- ];- const removedEmptySection = sections.find((section) => section.yOffset === 4)!;- removedEmptySection.items = [- createItem({ id: "below-1", xOffset: 5 }),- createItem({ id: "below-2", yOffset: 1, xOffset: 1, height: 2 }),- ];- sections.push(- createDynamicSection({- id: "7",- parentSectionId: "3",- yOffset: 7,- height: 3,- items: [createItem({ id: "dynamic-1" })],- }),- );-- const input = "3";-- const result = removeCategoryCallback({ id: input })({ sections } as never);+ const board = new BoardMockBuilder()+ .addLayout({ id: layoutId })+ .addSections(createSections(initialYOffsets))+ .addItems(createSectionItems([0, 1, 5, 6], layoutId)) // Only add items to other sections+ .addDynamicSection(+ new DynamicSectionMockBuilder({ id: sectionIds.dynamic })+ .addLayout({ layoutId, parentSectionId: sectionIds.category, yOffset: 7, height: 3 })+ .build(),+ )+ .addItem(new ItemMockBuilder({ id: "above-1" }).addLayout({ layoutId, sectionId: sectionIds.above }).build())+ .addItem(+ new ItemMockBuilder({ id: "above-2" })+ .addLayout({ layoutId, sectionId: sectionIds.above, yOffset: 3, xOffset: 2, height: 2 })+ .build(),+ )+ .addItem(+ new ItemMockBuilder({ id: "category-1" }).addLayout({ layoutId, sectionId: sectionIds.category }).build(),+ )+ .addItem(+ new ItemMockBuilder({ id: "category-2" })+ .addLayout({ layoutId, sectionId: sectionIds.category, yOffset: 2, xOffset: 4, width: 4 })+ .build(),+ )+ .addItem(+ new ItemMockBuilder({ id: "below-1" }).addLayout({ layoutId, sectionId: sectionIds.below, xOffset: 5 }).build(),+ )+ .addItem(+ new ItemMockBuilder({ id: "below-2" })+ .addLayout({ layoutId, sectionId: sectionIds.below, yOffset: 1, xOffset: 1, height: 2 })+ .build(),+ )+ .addItem(new ItemMockBuilder({ id: "dynamic-1" }).addLayout({ layoutId, sectionId: sectionIds.dynamic }).build())+ .build();++ vi.spyOn(boardContext, "getBoardLayouts").mockReturnValue([layoutId]);++ // Act+ const result = removeCategoryCallback({ id: sectionIds.category })(board);++ // Assertexpect(result.sections.map((section) => parseInt(section.id, 10))).toEqual([0, 1, 2, 5, 6, 7]);- const aboveSectionResult = result.sections.find((section) => section.id === "2")!;- expect(aboveSectionResult.items).toEqual(- expect.arrayContaining([- createItem({ id: "above-1" }),- createItem({ id: "above-2", yOffset: 3, xOffset: 2, height: 2 }),- createItem({ id: "category-1", yOffset: 5 }),- createItem({ id: "category-2", yOffset: 7, xOffset: 4, width: 4 }),- createItem({ id: "below-1", yOffset: 15, xOffset: 5 }),- createItem({ id: "below-2", yOffset: 16, xOffset: 1, height: 2 }),- ]),- );+ const aboveSectionItems = result.items.filter((item) => item.layouts[0]?.sectionId === sectionIds.above);+ expect(aboveSectionItems.length).toBe(6);++ expect(+ aboveSectionItems+ .map((item) => ({+ ...item,+ ...item.layouts[0]!,+ }))+ .sort((itemA, itemB) => itemA.yOffset - itemB.yOffset),+ ).toEqual([+ expect.objectContaining({ id: "above-1", yOffset: 0, xOffset: 0 }),+ expect.objectContaining({ id: "above-2", yOffset: 3, xOffset: 2, height: 2 }),+ expect.objectContaining({ id: "category-1", yOffset: 5, xOffset: 0 }),+ expect.objectContaining({ id: "category-2", yOffset: 7, xOffset: 4, width: 4 }),+ expect.objectContaining({ id: "below-1", yOffset: 15, xOffset: 5 }),+ expect.objectContaining({ id: "below-2", yOffset: 16, xOffset: 1, height: 2 }),+ ]);+const dynamicSection = result.sections.find((section): section is DynamicSection => section.id === "7")!;- expect(dynamicSection.yOffset).toBe(12);- expect(dynamicSection.parentSectionId).toBe("2");+ expect(dynamicSection.layouts.at(0)?.yOffset).toBe(12);+ expect(dynamicSection.layouts[0]?.parentSectionId).toBe("2");});});-const createItem = (item: Partial<{ id: string; width: number; height: number; yOffset: number; xOffset: number }>) => {- return {- id: item.id ?? "0",- kind: "app",- options: {},- advancedOptions: {- customCssClasses: [],- },- height: item.height ?? 1,- width: item.width ?? 1,- yOffset: item.yOffset ?? 0,- xOffset: item.xOffset ?? 0,- integrationIds: [],- } satisfies Item;-};--const createDynamicSection = (- section: Partial<- Pick<DynamicSection, "id" | "height" | "width" | "yOffset" | "xOffset" | "parentSectionId" | "items">- >,-) => {- return {- id: section.id ?? "0",- kind: "dynamic",- height: section.height ?? 1,- width: section.width ?? 1,- yOffset: section.yOffset ?? 0,- xOffset: section.xOffset ?? 0,- parentSectionId: section.parentSectionId ?? "0",- items: section.items ?? [],- } satisfies DynamicSection;+const createSections = (initialYOffsets: number[]) => {+ return initialYOffsets.map((yOffset, index) =>+ index % 2 === 0+ ? new EmptySectionMockBuilder({+ id: yOffset.toString(),+ yOffset,+ }).build()+ : new CategorySectionMockBuilder({+ id: yOffset.toString(),+ yOffset,+ }).build(),+ ) satisfies Section[];};-const createSections = (initialYOffsets: number[]) => {- return initialYOffsets.map((yOffset, index) => ({- id: yOffset.toString(),- kind: index % 2 === 0 ? "empty" : "category",- name: "Category",- collapsed: false,- yOffset,- xOffset: 0,- items: [createItem({ id: yOffset.toString() })],- })) satisfies Section[];+const createSectionItems = (initialYOffsets: number[], layoutId: string) => {+ return initialYOffsets.map((yOffset) =>+ new ItemMockBuilder({ id: yOffset.toString() }).addLayout({ layoutId, sectionId: yOffset.toString() }).build(),+ );};diff --git a/apps/nextjs/src/components/board/sections/category/category-actions.ts b/apps/nextjs/src/components/board/sections/category/category-actions.tsindex 3007be754..c2679897e 100644--- a/apps/nextjs/src/components/board/sections/category/category-actions.ts+++ b/apps/nextjs/src/components/board/sections/category/category-actions.ts@@ -3,7 +3,7 @@ import { useCallback } from "react";import { useUpdateBoard } from "@homarr/boards/updater";import { createId } from "@homarr/db/client";-import type { CategorySection, EmptySection } from "~/app/[locale]/boards/_types";+import type { CategorySection, EmptySection, Section } from "~/app/[locale]/boards/_types";import type { MoveCategoryInput } from "./actions/move-category";import { moveCategoryCallback } from "./actions/move-category";import type { RemoveCategoryInput } from "./actions/remove-category";@@ -41,14 +41,12 @@ export const useCategoryActions = () => {yOffset,xOffset: 0,collapsed: false,- items: [],},{id: createId(),kind: "empty",yOffset: yOffset + 1,xOffset: 0,- items: [],},// Place sections after the new category...previous.sections@@ -60,7 +58,7 @@ export const useCategoryActions = () => {...section,yOffset: section.yOffset + 2,})),- ],+ ] satisfies Section[],}));},[updateBoard],@@ -91,16 +89,14 @@ export const useCategoryActions = () => {yOffset: lastYOffset + 1,xOffset: 0,collapsed: false,- items: [],},{id: createId(),kind: "empty",yOffset: lastYOffset + 2,xOffset: 0,- items: [],},- ],+ ] satisfies Section[],};});},diff --git a/apps/nextjs/src/components/board/sections/category/category-menu-actions.tsx b/apps/nextjs/src/components/board/sections/category/category-menu-actions.tsxindex 6b89fb54c..cd5aca6df 100644--- a/apps/nextjs/src/components/board/sections/category/category-menu-actions.tsx+++ b/apps/nextjs/src/components/board/sections/category/category-menu-actions.tsx@@ -1,6 +1,7 @@import { useCallback } from "react";import { fetchApi } from "@homarr/api/client";+import { getCurrentLayout, useRequiredBoard } from "@homarr/boards/context";import { createId } from "@homarr/db/client";import { useConfirmModal, useModalAction } from "@homarr/modals";import { useSettings } from "@homarr/settings";@@ -16,6 +17,7 @@ export const useCategoryMenuActions = (category: CategorySection) => {const { openConfirmModal } = useConfirmModal();const { addCategory, moveCategory, removeCategory, renameCategory } = useCategoryActions();const t = useI18n();+ const board = useRequiredBoard();const createCategoryAtYOffset = useCallback((position: number) => {@@ -102,7 +104,14 @@ export const useCategoryMenuActions = (category: CategorySection) => {const settings = useSettings();const openAllInNewTabs = useCallback(async () => {- const appIds = filterByItemKind(category.items, settings, "app").map((item) => {+ const currentLayoutId = getCurrentLayout(board);+ const appIds = filterByItemKind(+ board.items.filter(+ (item) => item.layouts.find((layout) => layout.layoutId === currentLayoutId)?.sectionId === category.id,+ ),+ settings,+ "app",+ ).map((item) => {return item.options.appId;});@@ -121,7 +130,7 @@ export const useCategoryMenuActions = (category: CategorySection) => {});break;}- }, [category, t, openConfirmModal, settings]);+ }, [category, board, t, openConfirmModal, settings]);return {addCategoryAbove,diff --git a/apps/nextjs/src/components/board/sections/content.tsx b/apps/nextjs/src/components/board/sections/content.tsxindex c51894342..9c6e475d4 100644--- a/apps/nextjs/src/components/board/sections/content.tsx+++ b/apps/nextjs/src/components/board/sections/content.tsx@@ -1,16 +1,16 @@import { useMemo } from "react";-import { useRequiredBoard } from "@homarr/boards/context";+import type { GridItemHTMLElement } from "@homarr/gridstack";-import type { DynamicSection, Item, Section } from "~/app/[locale]/boards/_types";+import type { DynamicSectionItem, SectionItem } from "~/app/[locale]/boards/_types";import { BoardItemContent } from "../items/item-content";import { BoardDynamicSection } from "./dynamic-section";import { GridStackItem } from "./gridstack/gridstack-item";import { useSectionContext } from "./section-context";+import { useSectionItems } from "./use-section-items";export const SectionContent = () => {- const { section, innerSections, refs } = useSectionContext();- const board = useRequiredBoard();+ const { innerSections, items, refs } = useSectionContext();/*** IMPORTANT: THE ORDER OF THE BELOW ITEMS HAS TO MATCH THE ORDER OF@@ -18,41 +18,52 @@ export const SectionContent = () => {* @see https://github.com/homarr-labs/homarr/pull/1770*/const sortedItems = useMemo(() => {- return [- ...section.items.map((item) => ({ ...item, type: "item" as const })),- ...innerSections.map((section) => ({ ...section, type: "section" as const })),- ].sort((itemA, itemB) => {+ return [...items, ...innerSections].sort((itemA, itemB) => {if (itemA.yOffset === itemB.yOffset) {return itemA.xOffset - itemB.xOffset;}return itemA.yOffset - itemB.yOffset;});- }, [section.items, innerSections]);+ }, [items, innerSections]);return (<>{sortedItems.map((item) => (- <GridStackItem- key={item.id}- innerRef={refs.items.current[item.id]}- width={item.width}- height={item.height}- xOffset={item.xOffset}- yOffset={item.yOffset}- kind={item.kind}- id={item.id}- type={item.type}- minWidth={item.type === "section" ? getMinSize("x", item.items, board.sections, item.id) : undefined}- minHeight={item.type === "section" ? getMinSize("y", item.items, board.sections, item.id) : undefined}- >- {item.type === "item" ? <BoardItemContent item={item} /> : <BoardDynamicSection section={item} />}- </GridStackItem>+ <Item key={item.id} item={item} innerRef={refs.items.current[item.id]} />))}</>);};+interface ItemProps {+ item: DynamicSectionItem | SectionItem;+ innerRef: React.RefObject<GridItemHTMLElement | null> | undefined;+}++const Item = ({ item, innerRef }: ItemProps) => {+ const minWidth = useMinSize(item, "x");+ const minHeight = useMinSize(item, "y");++ return (+ <GridStackItem+ key={item.id}+ innerRef={innerRef}+ width={item.width}+ height={item.height}+ xOffset={item.xOffset}+ yOffset={item.yOffset}+ kind={item.kind}+ id={item.id}+ type={item.type}+ minWidth={minWidth}+ minHeight={minHeight}+ >+ {item.type === "item" ? <BoardItemContent item={item} /> : <BoardDynamicSection section={item} />}+ </GridStackItem>+ );+};+/*** Calculates the min width / height of a section by taking the maximum of* the sum of the offset and size of all items and dynamic sections inside.@@ -62,16 +73,13 @@ export const SectionContent = () => {* @param parentSectionId the id of the section we want to calculate the min size for* @returns the min size*/-const getMinSize = (direction: "x" | "y", items: Item[], sections: Section[], parentSectionId: string) => {+const useMinSize = (item: DynamicSectionItem | SectionItem, direction: "x" | "y") => {+ const { items, innerSections } = useSectionItems(item.id);+ if (item.type === "item") return undefined;+const size = direction === "x" ? "width" : "height";return Math.max(...items.map((item) => item[`${direction}Offset`] + item[size]),- ...sections- .filter(- (section): section is DynamicSection =>- section.kind === "dynamic" && section.parentSectionId === parentSectionId,- )- .map((item) => item[`${direction}Offset`] + item[size]),- 1, // Minimum size+ ...innerSections.map((item) => item[`${direction}Offset`] + item[size]),);};diff --git a/apps/nextjs/src/components/board/sections/dynamic-section.tsx b/apps/nextjs/src/components/board/sections/dynamic-section.tsxindex a35937d44..b2cb0b417 100644--- a/apps/nextjs/src/components/board/sections/dynamic-section.tsx+++ b/apps/nextjs/src/components/board/sections/dynamic-section.tsx@@ -1,18 +1,19 @@import { Box, Card } from "@mantine/core";-import { useRequiredBoard } from "@homarr/boards/context";+import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";-import type { DynamicSection } from "~/app/[locale]/boards/_types";+import type { DynamicSectionItem } from "~/app/[locale]/boards/_types";import { BoardDynamicSectionMenu } from "./dynamic/dynamic-menu";import { GridStack } from "./gridstack/gridstack";import classes from "./item.module.css";interface Props {- section: DynamicSection;+ section: DynamicSectionItem;}export const BoardDynamicSection = ({ section }: Props) => {const board = useRequiredBoard();+ const currentLayoutId = useCurrentLayout();return (<Box className="grid-stack-item-content"><Card@@ -29,7 +30,8 @@ export const BoardDynamicSection = ({ section }: Props) => {radius={board.itemRadius}p={0}>- <GridStack section={section} className="min-row" />+ {/* Use unique key by layout to reinitialize gridstack */}+ <GridStack key={`${currentLayoutId}-${section.id}`} section={section} className="min-row" /></Card><BoardDynamicSectionMenu section={section} /></Box>diff --git a/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.ts b/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.tsnew file mode 100644index 000000000..eea8deebd--- /dev/null+++ b/apps/nextjs/src/components/board/sections/dynamic/actions/add-dynamic-section.ts@@ -0,0 +1,51 @@+import { getBoardLayouts } from "@homarr/boards/context";+import { createId } from "@homarr/db/client";++import type { Board, DynamicSection, DynamicSectionLayout, EmptySection } from "~/app/[locale]/boards/_types";+import { getFirstEmptyPosition } from "~/components/board/items/actions/empty-position";+import { getSectionElements } from "~/components/board/items/actions/section-elements";++export const addDynamicSectionCallback = () => (board: Board) => {+ const firstSection = board.sections+ .filter((section) => section.kind === "empty")+ .sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset)+ .at(0);++ if (!firstSection) return board;++ const newSection = {+ id: createId(),+ kind: "dynamic",+ layouts: createDynamicSectionLayouts(board, firstSection),+ } satisfies DynamicSection;++ return {+ ...board,+ sections: board.sections.concat(newSection as unknown as DynamicSection),+ };+};++const createDynamicSectionLayouts = (board: Board, currentSection: EmptySection): DynamicSectionLayout[] => {+ const layouts = getBoardLayouts(board);++ return layouts.map((layoutId) => {+ const boardLayout = board.layouts.find((layout) => layout.id === layoutId);+ const elements = getSectionElements(board, { sectionId: currentSection.id, layoutId });++ const emptyPosition = boardLayout+ ? getFirstEmptyPosition(elements, boardLayout.columnCount)+ : { xOffset: 0, yOffset: 0 };++ if (!emptyPosition) {+ throw new Error("Your board is full");+ }++ return {+ width: 1,+ height: 1,+ ...emptyPosition,+ parentSectionId: currentSection.id,+ layoutId,+ };+ });+};diff --git a/apps/nextjs/src/components/board/sections/dynamic/actions/remove-dynamic-section.ts b/apps/nextjs/src/components/board/sections/dynamic/actions/remove-dynamic-section.tsnew file mode 100644index 000000000..da329433f--- /dev/null+++ b/apps/nextjs/src/components/board/sections/dynamic/actions/remove-dynamic-section.ts@@ -0,0 +1,62 @@+import type { Board, DynamicSection } from "~/app/[locale]/boards/_types";++export interface RemoveDynamicSectionInput {+ id: string;+}++export const removeDynamicSectionCallback =+ ({ id }: RemoveDynamicSectionInput) =>+ (board: Board): Board => {+ const sectionToRemove = board.sections.find(+ (section): section is DynamicSection => section.id === id && section.kind === "dynamic",+ );+ if (!sectionToRemove) return board;++ return {+ ...board,+ sections: board.sections+ .filter((section) => section.id !== id)+ .map((section) => {+ if (section.kind !== "dynamic") return section;++ // Change xOffset and yOffset of sections that were below the removed section and set parentSectionId to the parent of the removed section+ return {+ ...section,+ layouts: section.layouts.map((layout) => {+ if (layout.parentSectionId !== sectionToRemove.id) return layout;++ const removedSectionLayout = sectionToRemove.layouts.find(+ (layoutToRemove) => layoutToRemove.layoutId === layout.layoutId,+ );+ if (!removedSectionLayout) throw new Error("Layout not found");++ return {+ ...layout,+ xOffset: layout.xOffset + removedSectionLayout.xOffset,+ yOffset: layout.yOffset + removedSectionLayout.yOffset,+ parentSectionId: removedSectionLayout.parentSectionId,+ };+ }),+ };+ }),+ // Move all items in dynamic section to parent of the removed section+ items: board.items.map((item) => ({+ ...item,+ layouts: item.layouts.map((layout) => {+ if (layout.sectionId !== sectionToRemove.id) return layout;++ const removedSectionLayout = sectionToRemove.layouts.find(+ (layoutToRemove) => layoutToRemove.layoutId === layout.layoutId,+ );+ if (!removedSectionLayout) throw new Error("Layout not found");++ return {+ ...layout,+ xOffset: layout.xOffset + removedSectionLayout.xOffset,+ yOffset: layout.yOffset + removedSectionLayout.yOffset,+ sectionId: removedSectionLayout.parentSectionId,+ };+ }),+ })),+ };+ };diff --git a/apps/nextjs/src/components/board/sections/dynamic/dynamic-actions.ts b/apps/nextjs/src/components/board/sections/dynamic/dynamic-actions.tsindex d27bd907e..2684bdea4 100644--- a/apps/nextjs/src/components/board/sections/dynamic/dynamic-actions.ts+++ b/apps/nextjs/src/components/board/sections/dynamic/dynamic-actions.ts@@ -1,83 +1,21 @@import { useCallback } from "react";import { useUpdateBoard } from "@homarr/boards/updater";-import { createId } from "@homarr/db/client";-import type { DynamicSection, EmptySection } from "~/app/[locale]/boards/_types";--interface RemoveDynamicSection {- id: string;-}+import { addDynamicSectionCallback } from "./actions/add-dynamic-section";+import type { RemoveDynamicSectionInput } from "./actions/remove-dynamic-section";+import { removeDynamicSectionCallback } from "./actions/remove-dynamic-section";export const useDynamicSectionActions = () => {const { updateBoard } = useUpdateBoard();const addDynamicSection = useCallback(() => {- updateBoard((previous) => {- const lastSection = previous.sections- .filter((section): section is EmptySection => section.kind === "empty")- .sort((sectionA, sectionB) => sectionB.yOffset - sectionA.yOffset)[0];-- if (!lastSection) return previous;-- const newSection = {- id: createId(),- kind: "dynamic",- height: 1,- width: 1,- items: [],- parentSectionId: lastSection.id,- // We omit xOffset and yOffset because gridstack will use the first available position- } satisfies Omit<DynamicSection, "xOffset" | "yOffset">;-- return {- ...previous,- sections: previous.sections.concat(newSection as unknown as DynamicSection),- };- });+ updateBoard(addDynamicSectionCallback());}, [updateBoard]);const removeDynamicSection = useCallback(- ({ id }: RemoveDynamicSection) => {- updateBoard((previous) => {- const sectionToRemove = previous.sections.find(- (section): section is DynamicSection => section.id === id && section.kind === "dynamic",- );- if (!sectionToRemove) return previous;-- return {- ...previous,- sections: previous.sections- .filter((section) => section.id !== id)- .map((section) => {- if (section.id === sectionToRemove.parentSectionId) {- return {- ...section,- // Add items from the removed section to the parent section- items: section.items.concat(- sectionToRemove.items.map((item) => ({- ...item,- xOffset: sectionToRemove.xOffset + item.xOffset,- yOffset: sectionToRemove.yOffset + item.yOffset,- })),- ),- };- }-- if (section.kind === "dynamic" && section.parentSectionId === sectionToRemove.id) {- // Change xOffset and yOffset of sections that were below the removed section and set parentSectionId to the parent of the removed section- return {- ...section,- parentSectionId: sectionToRemove.parentSectionId,- yOffset: section.yOffset + sectionToRemove.yOffset,- xOffset: section.xOffset + sectionToRemove.xOffset,- };- }-- return section;- }),- };- });+ (input: RemoveDynamicSectionInput) => {+ updateBoard(removeDynamicSectionCallback(input));},[updateBoard],);diff --git a/apps/nextjs/src/components/board/sections/dynamic/dynamic-menu.tsx b/apps/nextjs/src/components/board/sections/dynamic/dynamic-menu.tsxindex e1910d363..3f38c8681 100644--- a/apps/nextjs/src/components/board/sections/dynamic/dynamic-menu.tsx+++ b/apps/nextjs/src/components/board/sections/dynamic/dynamic-menu.tsx@@ -5,10 +5,10 @@ import { useEditMode } from "@homarr/boards/edit-mode";import { useConfirmModal } from "@homarr/modals";import { useI18n, useScopedI18n } from "@homarr/translation/client";-import type { DynamicSection } from "~/app/[locale]/boards/_types";+import type { DynamicSectionItem } from "~/app/[locale]/boards/_types";import { useDynamicSectionActions } from "./dynamic-actions";-export const BoardDynamicSectionMenu = ({ section }: { section: DynamicSection }) => {+export const BoardDynamicSectionMenu = ({ section }: { section: DynamicSectionItem }) => {const t = useI18n();const tDynamic = useScopedI18n("section.dynamic");const { removeDynamicSection } = useDynamicSectionActions();diff --git a/apps/nextjs/src/components/board/sections/empty-section.tsx b/apps/nextjs/src/components/board/sections/empty-section.tsxindex de474760f..62e39b94d 100644--- a/apps/nextjs/src/components/board/sections/empty-section.tsx+++ b/apps/nextjs/src/components/board/sections/empty-section.tsx@@ -11,14 +11,15 @@ interface Props {}export const BoardEmptySection = ({ section }: Props) => {- const { itemIds } = useSectionItems(section);+ const { items, innerSections } = useSectionItems(section.id);+ const totalLength = items.length + innerSections.length;const [isEditMode] = useEditMode();return (<GridStacksection={section}style={{ transitionDuration: "0s" }}- className={combineClasses("min-row", itemIds.length > 0 || isEditMode ? undefined : "grid-stack-empty-wrapper")}+ className={combineClasses("min-row", totalLength > 0 || isEditMode ? undefined : "grid-stack-empty-wrapper")}/>);};diff --git a/apps/nextjs/src/components/board/sections/gridstack/gridstack.tsx b/apps/nextjs/src/components/board/sections/gridstack/gridstack.tsxindex d2761cba7..e851e5c2a 100644--- a/apps/nextjs/src/components/board/sections/gridstack/gridstack.tsx+++ b/apps/nextjs/src/components/board/sections/gridstack/gridstack.tsx@@ -4,23 +4,24 @@ import type { BoxProps } from "@mantine/core";import { Box } from "@mantine/core";import combineClasses from "clsx";-import type { Section } from "~/app/[locale]/boards/_types";+import type { DynamicSectionItem, Section } from "~/app/[locale]/boards/_types";import { SectionContent } from "../content";import { SectionProvider } from "../section-context";import { useSectionItems } from "../use-section-items";import { useGridstack } from "./use-gridstack";interface Props extends BoxProps {- section: Section;+ section: Exclude<Section, { kind: "dynamic" }> | DynamicSectionItem;}export const GridStack = ({ section, ...props }: Props) => {- const { itemIds, innerSections } = useSectionItems(section);+ const { items, innerSections } = useSectionItems(section.id);+ const itemIds = [...items, ...innerSections].map((item) => item.id);const { refs } = useGridstack(section, itemIds);return (- <SectionProvider value={{ section, innerSections, refs }}>+ <SectionProvider value={{ section, items, innerSections, refs }}><Box{...props}data-kind={section.kind}diff --git a/apps/nextjs/src/components/board/sections/gridstack/use-gridstack.ts b/apps/nextjs/src/components/board/sections/gridstack/use-gridstack.tsindex 251bb1d42..4f2fef067 100644--- a/apps/nextjs/src/components/board/sections/gridstack/use-gridstack.ts+++ b/apps/nextjs/src/components/board/sections/gridstack/use-gridstack.ts@@ -2,7 +2,7 @@ import type { RefObject } from "react";import { createRef, useCallback, useEffect, useRef } from "react";import { useElementSize } from "@mantine/hooks";-import { useRequiredBoard } from "@homarr/boards/context";+import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";import { useEditMode } from "@homarr/boards/edit-mode";import type { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode } from "@homarr/gridstack";@@ -68,10 +68,13 @@ export const useGridstack = (section: Omit<Section, "items">, itemIds: string[])const board = useRequiredBoard();+ const currentLayoutId = useCurrentLayout();+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const currentLayout = board.layouts.find((layout) => layout.id === currentLayoutId)!;const columnCount =section.kind === "dynamic" && "width" in section && typeof section.width === "number"? section.width- : board.columnCount;+ : currentLayout.columnCount;const itemRefKeys = Object.keys(itemRefs.current);// define items in itemRefs for easy access and reference to itemsdiff --git a/apps/nextjs/src/components/board/sections/section-actions.tsx b/apps/nextjs/src/components/board/sections/section-actions.tsxindex 6403d2175..f61f51552 100644--- a/apps/nextjs/src/components/board/sections/section-actions.tsx+++ b/apps/nextjs/src/components/board/sections/section-actions.tsx@@ -1,5 +1,6 @@import { useCallback } from "react";+import { getCurrentLayout } from "@homarr/boards/context";import { useUpdateBoard } from "@homarr/boards/updater";interface MoveAndResizeInnerSection {@@ -28,9 +29,19 @@ export const useSectionActions = () => {sections: previous.sections.map((section) => {// Return same section if section is not the one we're movingif (section.id !== innerSectionId) return section;+ if (section.kind !== "dynamic") return section;++ const currentLayout = getCurrentLayout(previous);+return {...section,- ...positionProps,+ layouts: section.layouts.map((layout) => {+ if (layout.layoutId !== currentLayout) return layout;+ return {+ ...layout,+ ...positionProps,+ };+ }),};}),}));@@ -46,10 +57,20 @@ export const useSectionActions = () => {sections: previous.sections.map((section) => {// Return section without changes when not the section we're movingif (section.id !== innerSectionId) return section;+ if (section.kind !== "dynamic") return section;++ const currentLayout = getCurrentLayout(previous);+return {...section,- ...positionProps,- parentSectionId: sectionId,+ layouts: section.layouts.map((layout) => {+ if (layout.layoutId !== currentLayout) return layout;+ return {+ ...layout,+ ...positionProps,+ parentSectionId: sectionId,+ };+ }),};}),};diff --git a/apps/nextjs/src/components/board/sections/section-context.ts b/apps/nextjs/src/components/board/sections/section-context.tsindex fa325ddcb..c01d05d7c 100644--- a/apps/nextjs/src/components/board/sections/section-context.ts+++ b/apps/nextjs/src/components/board/sections/section-context.ts@@ -1,11 +1,12 @@import { createContext, useContext } from "react";-import type { Section } from "~/app/[locale]/boards/_types";+import type { DynamicSectionItem, Section, SectionItem } from "~/app/[locale]/boards/_types";import type { UseGridstackRefs } from "./gridstack/use-gridstack";interface SectionContextProps {- section: Section;- innerSections: Exclude<Section, { kind: "category" } | { kind: "empty" }>[];+ section: Exclude<Section, { kind: "dynamic" }> | DynamicSectionItem;+ innerSections: DynamicSectionItem[];+ items: SectionItem[];refs: UseGridstackRefs;}diff --git a/apps/nextjs/src/components/board/sections/use-section-items.ts b/apps/nextjs/src/components/board/sections/use-section-items.tsindex 7e31f8643..ecdc30f53 100644--- a/apps/nextjs/src/components/board/sections/use-section-items.ts+++ b/apps/nextjs/src/components/board/sections/use-section-items.ts@@ -1,16 +1,53 @@-import { useRequiredBoard } from "@homarr/boards/context";+import { useMemo } from "react";-import type { Section } from "~/app/[locale]/boards/_types";+import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";-export const useSectionItems = (section: Section) => {+import type { DynamicSectionItem, SectionItem } from "~/app/[locale]/boards/_types";++export const useSectionItems = (sectionId: string): { innerSections: DynamicSectionItem[]; items: SectionItem[] } => {const board = useRequiredBoard();- const innerSections = board.sections.filter(- (innerSection): innerSection is Exclude<Section, { kind: "category" } | { kind: "empty" }> =>- innerSection.kind === "dynamic" && innerSection.parentSectionId === section.id,+ const currentLayoutId = useCurrentLayout();++ const innerSections = useMemo(+ () =>+ board.sections+ .filter((innerSection) => innerSection.kind === "dynamic")+ .map(({ layouts, ...innerSection }) => {+ const layout = layouts.find((layout) => layout.layoutId === currentLayoutId);++ if (!layout) return null;++ return {+ ...layout,+ ...innerSection,+ type: "section" as const,+ };+ })+ .filter((item) => item !== null)+ .filter((innerSection) => innerSection.parentSectionId === sectionId),+ [board.sections, currentLayoutId, sectionId],+ );++ const items = useMemo(+ () =>+ board.items+ .map(({ layouts, ...item }) => {+ const layout = layouts.find((layout) => layout.layoutId === currentLayoutId);+ if (!layout) return null;++ return {+ ...layout,+ ...item,+ type: "item" as const,+ };+ })+ .filter((item) => item !== null)+ .filter((item) => item.sectionId === sectionId),+ [board.items, currentLayoutId, sectionId],);return {innerSections,- itemIds: section.items.map((item) => item.id).concat(innerSections.map((section) => section.id)),+ items,};};diff --git a/packages/api/src/middlewares/integration.ts b/packages/api/src/middlewares/integration.tsindex adc0bc20f..8df7f1d3f 100644--- a/packages/api/src/middlewares/integration.ts+++ b/packages/api/src/middlewares/integration.ts@@ -37,15 +37,7 @@ export const createOneIntegrationMiddleware = <TKind extends IntegrationKind>(userPermissions: true,items: {with: {- item: {- with: {- section: {- columns: {- boardId: true,- },- },- },- },+ item: true,},},},@@ -107,15 +99,7 @@ export const createManyIntegrationMiddleware = <TKind extends IntegrationKind>(secrets: true,items: {with: {- item: {- with: {- section: {- columns: {- boardId: true,- },- },- },- },+ item: true,},},userPermissions: true,diff --git a/packages/api/src/router/app/app-access-control.ts b/packages/api/src/router/app/app-access-control.tsindex d4254cb75..0f5a0a478 100644--- a/packages/api/src/router/app/app-access-control.ts+++ b/packages/api/src/router/app/app-access-control.ts@@ -21,21 +21,16 @@ const getAllAppIdsOnPublicBoardsAsync = async () => {const itemsWithApps = await db.query.items.findMany({where: or(eq(items.kind, "app"), eq(items.kind, "bookmarks")),with: {- section: {- columns: {}, // Nothing- with: {- board: {- columns: {- isPublic: true,- },- },+ board: {+ columns: {+ isPublic: true,},},},});return itemsWithApps- .filter((item) => item.section.board.isPublic)+ .filter((item) => item.board.isPublic).flatMap((item) => {if (item.kind === "app") {const parsedOptions = SuperJSON.parse<WidgetComponentProps<"app">["options"]>(item.options);diff --git a/packages/api/src/router/board.ts b/packages/api/src/router/board.tsindex 435703a1e..900b49ca6 100644--- a/packages/api/src/router/board.ts+++ b/packages/api/src/router/board.ts@@ -6,6 +6,7 @@ import { constructBoardPermissions } from "@homarr/auth/shared";import type { DeviceType } from "@homarr/common/server";import type { Database, InferInsertModel, InferSelectModel, SQL } from "@homarr/db";import { and, asc, createId, eq, handleTransactionsAsync, inArray, isNull, like, not, or } from "@homarr/db";+import { createDbInsertCollectionWithoutTransaction } from "@homarr/db/collection";import { getServerSettingByKeyAsync } from "@homarr/db/queries";import {boardGroupPermissions,@@ -17,8 +18,11 @@ import {integrationGroupPermissions,integrationItems,integrationUserPermissions,+ itemLayouts,items,+ layouts,sectionCollapseStates,+ sectionLayouts,sections,users,} from "@homarr/db/schema";@@ -28,10 +32,11 @@ import { importOldmarrAsync } from "@homarr/old-import";import { importJsonFileSchema } from "@homarr/old-import/shared";import { oldmarrConfigSchema } from "@homarr/old-schema";import type { BoardItemAdvancedOptions } from "@homarr/validation";-import { createSectionSchema, sharedItemSchema, validation, zodUnionFromArray } from "@homarr/validation";+import { sectionSchema, sharedItemSchema, validation, zodUnionFromArray } from "@homarr/validation";import { createTRPCRouter, permissionRequiredProcedure, protectedProcedure, publicProcedure } from "../trpc";import { throwIfActionForbiddenAsync } from "./board/board-access";+import { generateResponsiveGridFor } from "./board/grid-algorithm";export const boardRouter = createTRPCRouter({exists: permissionRequiredProcedure@@ -239,50 +244,31 @@ export const boardRouter = createTRPCRouter({.input(validation.board.create).mutation(async ({ ctx, input }) => {const boardId = createId();- await handleTransactionsAsync(ctx.db, {- async handleAsync(db, schema) {- await db.transaction(async (transaction) => {- await transaction.insert(schema.boards).values({- id: boardId,- name: input.name,- isPublic: input.isPublic,- columnCount: input.columnCount,- creatorId: ctx.session.user.id,- });- await transaction.insert(schema.sections).values({- id: createId(),- kind: "empty",- xOffset: 0,- yOffset: 0,- boardId,- });- });- },- handleSync(db) {- db.transaction((transaction) => {- transaction- .insert(boards)- .values({- id: boardId,- name: input.name,- isPublic: input.isPublic,- columnCount: input.columnCount,- creatorId: ctx.session.user.id,- })- .run();- transaction- .insert(sections)- .values({- id: createId(),- kind: "empty",- xOffset: 0,- yOffset: 0,- boardId,- })- .run();- });- },++ const createBoardCollection = createDbInsertCollectionWithoutTransaction(["boards", "sections", "layouts"]);++ createBoardCollection.boards.push({+ id: boardId,+ name: input.name,+ isPublic: input.isPublic,+ creatorId: ctx.session.user.id,+ });+ createBoardCollection.sections.push({+ id: createId(),+ kind: "empty",+ xOffset: 0,+ yOffset: 0,+ boardId,});+ createBoardCollection.layouts.push({+ id: createId(),+ name: "Base",+ columnCount: input.columnCount,+ breakpoint: 0,+ boardId,+ });++ await createBoardCollection.insertAllAsync(ctx.db);}),duplicateBoard: permissionRequiredProcedure.requiresPermission("board-create")@@ -294,13 +280,17 @@ export const boardRouter = createTRPCRouter({const board = await ctx.db.query.boards.findFirst({where: eq(boards.id, input.id),with: {+ layouts: true,sections: {with: {- items: {- with: {- integrations: true,- },- },+ collapseStates: true,+ layouts: true,+ },+ },+ items: {+ with: {+ layouts: true,+ integrations: true,},},},@@ -313,27 +303,77 @@ export const boardRouter = createTRPCRouter({});}- const { sections: boardSections, ...boardProps } = board;+ const { sections: boardSections, items: boardItems, layouts: boardLayouts, ...boardProps } = board;const newBoardId = createId();- const sectionMap = new Map<string, string>(boardSections.map((section) => [section.id, createId()]));- const sectionsToInsert: InferInsertModel<typeof sections>[] = boardSections.map(({ items: _, ...section }) => ({- ...section,- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- id: sectionMap.get(section.id)!,++ const layoutsMap = new Map<string, string>(boardLayouts.map((layout) => [layout.id, createId()]));+ const layoutsToInsert = boardLayouts.map((layout) => ({+ ...layout,// eslint-disable-next-line @typescript-eslint/no-non-null-assertion- parentSectionId: section.parentSectionId ? sectionMap.get(section.parentSectionId)! : null,+ id: layoutsMap.get(layout.id)!,boardId: newBoardId,}));- const flatItems = boardSections.flatMap((section) => section.items);- const itemMap = new Map<string, string>(flatItems.map((item) => [item.id, createId()]));- const itemsToInsert: InferInsertModel<typeof items>[] = flatItems.map(({ integrations: _, ...item }) => ({- ...item,- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- id: itemMap.get(item.id)!,- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- sectionId: sectionMap.get(item.sectionId)!,- }));++ const sectionMap = new Map<string, string>(boardSections.map((section) => [section.id, createId()]));+ const sectionsToInsert: InferInsertModel<typeof sections>[] = boardSections.map(+ ({ collapseStates: _, layouts: _layouts, ...section }) => ({+ ...section,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ id: sectionMap.get(section.id)!,+ boardId: newBoardId,+ }),+ );++ const sectionLayoutsToInsert: InferInsertModel<typeof sectionLayouts>[] = boardSections.flatMap((section) =>+ section.layouts.map(+ (layoutSection): InferInsertModel<typeof sectionLayouts> => ({+ ...layoutSection,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ layoutId: layoutsMap.get(layoutSection.layoutId)!,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ sectionId: sectionMap.get(layoutSection.sectionId)!,+ parentSectionId: layoutSection.parentSectionId+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ sectionMap.get(layoutSection.parentSectionId)!+ : layoutSection.parentSectionId,+ }),+ ),+ );+ const sectionCollapseStatesToInsert: InferInsertModel<typeof sectionCollapseStates>[] = boardSections.flatMap(+ (section) =>+ section.collapseStates.map(+ (collapseState): InferInsertModel<typeof sectionCollapseStates> => ({+ ...collapseState,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ sectionId: sectionMap.get(collapseState.sectionId)!,+ }),+ ),+ );++ const itemMap = new Map<string, string>(boardItems.map((item) => [item.id, createId()]));+ const itemsToInsert: InferInsertModel<typeof items>[] = boardItems.map(+ ({ integrations: _, layouts: _layouts, ...item }) => ({+ ...item,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ id: itemMap.get(item.id)!,+ boardId: newBoardId,+ }),+ );++ const itemLayoutsToInsert: InferInsertModel<typeof itemLayouts>[] = boardItems.flatMap((item) =>+ item.layouts.map(+ (layoutSection): InferInsertModel<typeof itemLayouts> => ({+ ...layoutSection,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ sectionId: sectionMap.get(layoutSection.sectionId)!,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ itemId: itemMap.get(layoutSection.itemId)!,+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ layoutId: layoutsMap.get(layoutSection.layoutId)!,+ }),+ ),+ );// Creates a list with all integration ids the user has access toconst hasAccessForAll = ctx.session.user.permissions.includes("integration-use-all");@@ -354,7 +394,7 @@ export const boardRouter = createTRPCRouter({).then((result) => result.map((row) => row.id));- const itemIntegrationsToInsert = flatItems.flatMap((item) =>+ const itemIntegrationsToInsert = boardItems.flatMap((item) =>item.integrations// Restrict integrations to only those the user has access to.filter(({ integrationId }) => integrationIdsWithAccess.includes(integrationId) || hasAccessForAll)@@ -375,14 +415,30 @@ export const boardRouter = createTRPCRouter({creatorId: ctx.session.user.id,});+ if (layoutsToInsert.length > 0) {+ await transaction.insert(schema.layouts).values(layoutsToInsert);+ }+if (sectionsToInsert.length > 0) {await transaction.insert(schema.sections).values(sectionsToInsert);}+ if (sectionLayoutsToInsert.length > 0) {+ await transaction.insert(schema.sectionLayouts).values(sectionLayoutsToInsert);+ }++ if (sectionCollapseStatesToInsert.length > 0) {+ await transaction.insert(schema.sectionCollapseStates).values(sectionCollapseStatesToInsert);+ }+if (itemsToInsert.length > 0) {await transaction.insert(schema.items).values(itemsToInsert);}+ if (itemLayoutsToInsert.length > 0) {+ await transaction.insert(schema.itemLayouts).values(itemLayoutsToInsert);+ }+if (itemIntegrationsToInsert.length > 0) {await transaction.insert(schema.integrationItems).values(itemIntegrationsToInsert);}@@ -400,14 +456,30 @@ export const boardRouter = createTRPCRouter({}).run();+ if (layoutsToInsert.length > 0) {+ transaction.insert(layouts).values(layoutsToInsert).run();+ }+if (sectionsToInsert.length > 0) {transaction.insert(sections).values(sectionsToInsert).run();}+ if (sectionLayoutsToInsert.length > 0) {+ transaction.insert(sectionLayouts).values(sectionLayoutsToInsert).run();+ }++ if (sectionCollapseStatesToInsert.length > 0) {+ transaction.insert(sectionCollapseStates).values(sectionCollapseStatesToInsert).run();+ }+if (itemsToInsert.length > 0) {transaction.insert(items).values(itemsToInsert).run();}+ if (itemLayoutsToInsert.length > 0) {+ transaction.insert(itemLayouts).values(itemLayoutsToInsert).run();+ }+if (itemIntegrationsToInsert.length > 0) {transaction.insert(integrationItems).values(itemIntegrationsToInsert).run();}@@ -487,6 +559,131 @@ export const boardRouter = createTRPCRouter({return await getFullBoardWithWhereAsync(ctx.db, boardWhere, ctx.session?.user.id ?? null);}),+ saveLayouts: protectedProcedure.input(validation.board.saveLayouts).mutation(async ({ ctx, input }) => {+ await throwIfActionForbiddenAsync(ctx, eq(boards.id, input.id), "modify");++ const board = await getFullBoardWithWhereAsync(ctx.db, eq(boards.id, input.id), ctx.session.user.id);++ const addedLayouts = filterAddedItems(input.layouts, board.layouts);++ const layoutsToInsert: InferInsertModel<typeof layouts>[] = [];+ const itemSectionLayoutsToInsert: InferInsertModel<typeof itemLayouts>[] = [];+ const sectionLayoutsToInsert: InferInsertModel<typeof sectionLayouts>[] = [];++ for (const addedLayout of addedLayouts) {+ const layoutId = createId();++ layoutsToInsert.push({+ id: layoutId,+ name: addedLayout.name,+ columnCount: addedLayout.columnCount,+ breakpoint: addedLayout.breakpoint,+ boardId: board.id,+ });++ const sortedLayouts = board.layouts.sort((layoutA, layoutB) => layoutA.columnCount - layoutB.columnCount);+ // Fallback to biggest if none exists with columnCount bigger than addedLayout.columnCount+ const layoutToClone =+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ sortedLayouts.find((layout) => layout.columnCount >= addedLayout.columnCount) ?? sortedLayouts.at(-1)!;++ const updatedBoardLayout = getUpdatedBoardLayout(board, {+ previous: {+ layoutId: layoutToClone.id,+ columnCount: layoutToClone.columnCount,+ },+ current: {+ layoutId,+ columnCount: addedLayout.columnCount,+ },+ });++ itemSectionLayoutsToInsert.push(...updatedBoardLayout.itemSectionLayouts);+ sectionLayoutsToInsert.push(...updatedBoardLayout.sectionLayouts);+ }++ if (layoutsToInsert.length > 0) {+ await ctx.db.insert(layouts).values(layoutsToInsert);+ }++ if (itemSectionLayoutsToInsert.length > 0) {+ await ctx.db.insert(itemLayouts).values(itemSectionLayoutsToInsert);+ }++ if (sectionLayoutsToInsert.length > 0) {+ await ctx.db.insert(sectionLayouts).values(sectionLayoutsToInsert);+ }++ const updatedLayouts = filterUpdatedItems(input.layouts, board.layouts);+ for (const updatedLayout of updatedLayouts) {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const dbLayout = board.layouts.find((layout) => layout.id === updatedLayout.id)!;++ if (dbLayout.columnCount !== updatedLayout.columnCount) {+ const updatedBoardLayout = getUpdatedBoardLayout(board, {+ previous: {+ layoutId: dbLayout.id,+ columnCount: dbLayout.columnCount,+ },+ current: {+ layoutId: dbLayout.id,+ columnCount: updatedLayout.columnCount,+ },+ });++ for (const itemSectionLayout of updatedBoardLayout.itemSectionLayouts) {+ await ctx.db+ .update(itemLayouts)+ .set({+ height: itemSectionLayout.height,+ width: itemSectionLayout.width,+ xOffset: itemSectionLayout.xOffset,+ yOffset: itemSectionLayout.yOffset,+ sectionId: itemSectionLayout.sectionId,+ })+ .where(+ and(+ eq(itemLayouts.itemId, itemSectionLayout.itemId),+ eq(itemLayouts.layoutId, itemSectionLayout.layoutId),+ ),+ );+ }++ for (const sectionLayout of updatedBoardLayout.sectionLayouts) {+ await ctx.db+ .update(sectionLayouts)+ .set({+ height: sectionLayout.height,+ width: sectionLayout.width,+ xOffset: sectionLayout.xOffset,+ yOffset: sectionLayout.yOffset,+ parentSectionId: sectionLayout.parentSectionId,+ })+ .where(+ and(+ eq(sectionLayouts.sectionId, sectionLayout.sectionId),+ eq(sectionLayouts.layoutId, sectionLayout.layoutId),+ ),+ );+ }+ }++ await ctx.db+ .update(layouts)+ .set({+ name: updatedLayout.name,+ columnCount: updatedLayout.columnCount,+ breakpoint: updatedLayout.breakpoint,+ })+ .where(eq(layouts.id, updatedLayout.id));+ }++ const removedLayouts = filterRemovedItems(input.layouts, board.layouts);+ const removedLayoutIds = removedLayouts.map((layout) => layout.id);+ if (removedLayoutIds.length > 0) {+ await ctx.db.delete(layouts).where(inArray(layouts.id, removedLayoutIds));+ }+ }),savePartialBoardSettings: protectedProcedure.input(validation.board.savePartialSettings.and(z.object({ id: z.string() }))).mutation(async ({ ctx, input }) => {@@ -507,19 +704,16 @@ export const boardRouter = createTRPCRouter({backgroundImageRepeat: input.backgroundImageRepeat,backgroundImageSize: input.backgroundImageSize,- // color settings+ // appearance settingsprimaryColor: input.primaryColor,secondaryColor: input.secondaryColor,opacity: input.opacity,iconColor: input.iconColor,+ itemRadius: input.itemRadius,// custom csscustomCss: input.customCss,- // layout settings- columnCount: input.columnCount,- itemRadius: input.itemRadius,-// Behavior settingsdisableStatus: input.disableStatus,})@@ -540,49 +734,70 @@ export const boardRouter = createTRPCRouter({addedSections.map((section) => ({id: section.id,kind: section.kind,- yOffset: section.yOffset,- xOffset: section.kind === "dynamic" ? section.xOffset : 0,- height: "height" in section ? section.height : null,- width: "width" in section ? section.width : null,- parentSectionId: "parentSectionId" in section ? section.parentSectionId : null,+ yOffset: section.kind !== "dynamic" ? section.yOffset : null,+ xOffset: section.kind === "dynamic" ? null : 0,name: "name" in section ? section.name : null,boardId: dbBoard.id,})),);- }- const inputItems = input.sections.flatMap((section) =>- section.items.map((item) => ({ ...item, sectionId: section.id })),- );- const dbItems = dbBoard.sections.flatMap((section) =>- section.items.map((item) => ({ ...item, sectionId: section.id })),- );+ if (addedSections.some((section) => section.kind === "dynamic")) {+ await transaction.insert(schema.sectionLayouts).values(+ addedSections+ .filter((section) => section.kind === "dynamic")+ .flatMap((section) =>+ section.layouts.map(+ (sectionLayout): InferInsertModel<typeof schema.sectionLayouts> => ({+ layoutId: sectionLayout.layoutId,+ sectionId: section.id,+ parentSectionId: sectionLayout.parentSectionId,+ height: sectionLayout.height,+ width: sectionLayout.width,+ xOffset: sectionLayout.xOffset,+ yOffset: sectionLayout.yOffset,+ }),+ ),+ ),+ );+ }+ }- const addedItems = filterAddedItems(inputItems, dbItems);+ const addedItems = filterAddedItems(input.items, dbBoard.items);if (addedItems.length > 0) {await transaction.insert(schema.items).values(addedItems.map((item) => ({id: item.id,kind: item.kind,- height: item.height,- width: item.width,- xOffset: item.xOffset,- yOffset: item.yOffset,options: superjson.stringify(item.options),advancedOptions: superjson.stringify(item.advancedOptions),- sectionId: item.sectionId,+ boardId: dbBoard.id,})),);+ await transaction.insert(schema.itemLayouts).values(+ addedItems.flatMap((item) =>+ item.layouts.map(+ (layoutSection): InferInsertModel<typeof schema.itemLayouts> => ({+ layoutId: layoutSection.layoutId,+ sectionId: layoutSection.sectionId,+ itemId: item.id,+ height: layoutSection.height,+ width: layoutSection.width,+ xOffset: layoutSection.xOffset,+ yOffset: layoutSection.yOffset,+ }),+ ),+ ),+ );}- const inputIntegrationRelations = inputItems.flatMap(({ integrationIds, id: itemId }) =>+ const inputIntegrationRelations = input.items.flatMap(({ integrationIds, id: itemId }) =>integrationIds.map((integrationId) => ({integrationId,itemId,})),);- const dbIntegrationRelations = dbItems.flatMap(({ integrationIds, id: itemId }) =>+ const dbIntegrationRelations = dbBoard.items.flatMap(({ integrationIds, id: itemId }) =>integrationIds.map((integrationId) => ({integrationId,itemId,@@ -606,22 +821,35 @@ export const boardRouter = createTRPCRouter({);}- const updatedItems = filterUpdatedItems(inputItems, dbItems);+ const updatedItems = filterUpdatedItems(input.items, dbBoard.items);for (const item of updatedItems) {await transaction.update(schema.items).set({kind: item.kind,- height: item.height,- width: item.width,- xOffset: item.xOffset,- yOffset: item.yOffset,options: superjson.stringify(item.options),advancedOptions: superjson.stringify(item.advancedOptions),- sectionId: item.sectionId,})- .where(eq(items.id, item.id));+ .where(eq(schema.items.id, item.id));++ for (const itemSectionLayout of item.layouts) {+ await transaction+ .update(schema.itemLayouts)+ .set({+ height: itemSectionLayout.height,+ width: itemSectionLayout.width,+ xOffset: itemSectionLayout.xOffset,+ yOffset: itemSectionLayout.yOffset,+ sectionId: itemSectionLayout.sectionId,+ })+ .where(+ and(+ eq(schema.itemLayouts.itemId, item.id),+ eq(schema.itemLayouts.layoutId, itemSectionLayout.layoutId),+ ),+ );+ }}const updatedSections = filterUpdatedItems(input.sections, dbBoard.sections);@@ -631,15 +859,31 @@ export const boardRouter = createTRPCRouter({await transaction.update(schema.sections).set({- yOffset: section.yOffset,- xOffset: section.xOffset,- height: prev?.kind === "dynamic" && "height" in section ? section.height : null,- width: prev?.kind === "dynamic" && "width" in section ? section.width : null,- parentSectionId:- prev?.kind === "dynamic" && "parentSectionId" in section ? section.parentSectionId : null,+ yOffset: prev?.kind !== "dynamic" && "yOffset" in section ? section.yOffset : null,+ xOffset: prev?.kind !== "dynamic" && "yOffset" in section ? 0 : null,name: prev?.kind === "category" && "name" in section ? section.name : null,})- .where(eq(sections.id, section.id));+ .where(eq(schema.sections.id, section.id));++ if (section.kind !== "dynamic") continue;++ for (const sectionLayout of section.layouts) {+ await transaction+ .update(schema.sectionLayouts)+ .set({+ height: sectionLayout.height,+ width: sectionLayout.width,+ xOffset: sectionLayout.xOffset,+ yOffset: sectionLayout.yOffset,+ parentSectionId: sectionLayout.parentSectionId,+ })+ .where(+ and(+ eq(schema.sectionLayouts.sectionId, section.id),+ eq(schema.sectionLayouts.layoutId, sectionLayout.layoutId),+ ),+ );+ }}const removedIntegrationRelations = dbIntegrationRelations.filter(@@ -662,18 +906,18 @@ export const boardRouter = createTRPCRouter({);}- const removedItems = filterRemovedItems(inputItems, dbItems);+ const removedItems = filterRemovedItems(input.items, dbBoard.items);const itemIds = removedItems.map((item) => item.id);if (itemIds.length > 0) {- await transaction.delete(schema.items).where(inArray(items.id, itemIds));+ await transaction.delete(schema.items).where(inArray(schema.items.id, itemIds));}const removedSections = filterRemovedItems(input.sections, dbBoard.sections);const sectionIds = removedSections.map((section) => section.id);if (sectionIds.length > 0) {- await transaction.delete(schema.sections).where(inArray(sections.id, sectionIds));+ await transaction.delete(schema.sections).where(inArray(schema.sections.id, sectionIds));}});},@@ -688,26 +932,39 @@ export const boardRouter = createTRPCRouter({addedSections.map((section) => ({id: section.id,kind: section.kind,- yOffset: section.yOffset,- xOffset: section.kind === "dynamic" ? section.xOffset : 0,- height: "height" in section ? section.height : null,- width: "width" in section ? section.width : null,- parentSectionId: "parentSectionId" in section ? section.parentSectionId : null,+ yOffset: section.kind !== "dynamic" ? section.yOffset : null,+ xOffset: section.kind === "dynamic" ? null : 0,name: "name" in section ? section.name : null,boardId: dbBoard.id,})),).run();- }- const inputItems = input.sections.flatMap((section) =>- section.items.map((item) => ({ ...item, sectionId: section.id })),- );- const dbItems = dbBoard.sections.flatMap((section) =>- section.items.map((item) => ({ ...item, sectionId: section.id })),- );+ if (addedSections.some((section) => section.kind === "dynamic")) {+ transaction+ .insert(sectionLayouts)+ .values(+ addedSections+ .filter((section) => section.kind === "dynamic")+ .flatMap((section) =>+ section.layouts.map(+ (sectionLayout): InferInsertModel<typeof sectionLayouts> => ({+ layoutId: sectionLayout.layoutId,+ sectionId: section.id,+ parentSectionId: sectionLayout.parentSectionId,+ height: sectionLayout.height,+ width: sectionLayout.width,+ xOffset: sectionLayout.xOffset,+ yOffset: sectionLayout.yOffset,+ }),+ ),+ ),+ )+ .run();+ }+ }- const addedItems = filterAddedItems(inputItems, dbItems);+ const addedItems = filterAddedItems(input.items, dbBoard.items);if (addedItems.length > 0) {transaction@@ -716,25 +973,39 @@ export const boardRouter = createTRPCRouter({addedItems.map((item) => ({id: item.id,kind: item.kind,- height: item.height,- width: item.width,- xOffset: item.xOffset,- yOffset: item.yOffset,options: superjson.stringify(item.options),advancedOptions: superjson.stringify(item.advancedOptions),- sectionId: item.sectionId,+ boardId: dbBoard.id,})),).run();+ transaction+ .insert(itemLayouts)+ .values(+ addedItems.flatMap((item) =>+ item.layouts.map(+ (layoutSection): InferInsertModel<typeof itemLayouts> => ({+ layoutId: layoutSection.layoutId,+ sectionId: layoutSection.sectionId,+ itemId: item.id,+ height: layoutSection.height,+ width: layoutSection.width,+ xOffset: layoutSection.xOffset,+ yOffset: layoutSection.yOffset,+ }),+ ),+ ),+ )+ .run();}- const inputIntegrationRelations = inputItems.flatMap(({ integrationIds, id: itemId }) =>+ const inputIntegrationRelations = input.items.flatMap(({ integrationIds, id: itemId }) =>integrationIds.map((integrationId) => ({integrationId,itemId,})),);- const dbIntegrationRelations = dbItems.flatMap(({ integrationIds, id: itemId }) =>+ const dbIntegrationRelations = dbBoard.items.flatMap(({ integrationIds, id: itemId }) =>integrationIds.map((integrationId) => ({integrationId,itemId,@@ -761,23 +1032,32 @@ export const boardRouter = createTRPCRouter({.run();}- const updatedItems = filterUpdatedItems(inputItems, dbItems);+ const updatedItems = filterUpdatedItems(input.items, dbBoard.items);for (const item of updatedItems) {transaction.update(items).set({kind: item.kind,- height: item.height,- width: item.width,- xOffset: item.xOffset,- yOffset: item.yOffset,options: superjson.stringify(item.options),advancedOptions: superjson.stringify(item.advancedOptions),- sectionId: item.sectionId,}).where(eq(items.id, item.id)).run();++ for (const itemSectionLayout of item.layouts) {+ transaction+ .update(itemLayouts)+ .set({+ height: itemSectionLayout.height,+ width: itemSectionLayout.width,+ xOffset: itemSectionLayout.xOffset,+ yOffset: itemSectionLayout.yOffset,+ sectionId: itemSectionLayout.sectionId,+ })+ .where(and(eq(itemLayouts.itemId, item.id), eq(itemLayouts.layoutId, itemSectionLayout.layoutId)))+ .run();+ }}const updatedSections = filterUpdatedItems(input.sections, dbBoard.sections);@@ -787,16 +1067,30 @@ export const boardRouter = createTRPCRouter({transaction.update(sections).set({- yOffset: section.yOffset,- xOffset: section.xOffset,- height: prev?.kind === "dynamic" && "height" in section ? section.height : null,- width: prev?.kind === "dynamic" && "width" in section ? section.width : null,- parentSectionId:- prev?.kind === "dynamic" && "parentSectionId" in section ? section.parentSectionId : null,+ yOffset: prev?.kind !== "dynamic" && "yOffset" in section ? section.yOffset : null,+ xOffset: prev?.kind !== "dynamic" && "yOffset" in section ? 0 : null,name: prev?.kind === "category" && "name" in section ? section.name : null,}).where(eq(sections.id, section.id)).run();++ if (section.kind !== "dynamic") continue;++ for (const sectionLayout of section.layouts) {+ transaction+ .update(sectionLayouts)+ .set({+ height: sectionLayout.height,+ width: sectionLayout.width,+ xOffset: sectionLayout.xOffset,+ yOffset: sectionLayout.yOffset,+ parentSectionId: sectionLayout.parentSectionId,+ })+ .where(+ and(eq(sectionLayouts.sectionId, section.id), eq(sectionLayouts.layoutId, sectionLayout.layoutId)),+ )+ .run();+ }}const removedIntegrationRelations = dbIntegrationRelations.filter(@@ -820,7 +1114,7 @@ export const boardRouter = createTRPCRouter({.run();}- const removedItems = filterRemovedItems(inputItems, dbItems);+ const removedItems = filterRemovedItems(input.items, dbBoard.items);const itemIds = removedItems.map((item) => item.id);if (itemIds.length > 0) {@@ -1086,6 +1380,123 @@ const noBoardWithSimilarNameAsync = async (db: Database, name: string, ignoredId}};+const getUpdatedBoardLayout = (+ board: Awaited<ReturnType<typeof getFullBoardWithWhereAsync>>,+ options: {+ previous: {+ layoutId: string;+ columnCount: number;+ };+ current: {+ layoutId: string;+ columnCount: number;+ };+ },+) => {+ const itemSectionLayoutsCollection: InferInsertModel<typeof itemLayouts>[] = [];+ const sectionLayoutsCollection: InferInsertModel<typeof sectionLayouts>[] = [];++ const elements = getElementsForLayout(board, options.previous.layoutId);+ const rootSections = board.sections.filter((section) => section.kind !== "dynamic");++ for (const rootSection of rootSections) {+ const result = generateResponsiveGridFor({+ items: elements,+ previousWidth: options.previous.columnCount,+ width: options.current.columnCount,+ sectionId: rootSection.id,+ });++ itemSectionLayoutsCollection.push(+ ...board.items+ .map((item): InferInsertModel<typeof itemLayouts> | null => {+ const currentElement = result.items.find((element) => element.type === "item" && element.id === item.id);++ if (!currentElement) {+ return null;+ }++ return {+ itemId: item.id,+ layoutId: options.current.layoutId,+ sectionId: currentElement.sectionId,+ height: currentElement.height,+ width: currentElement.width,+ xOffset: currentElement.xOffset,+ yOffset: currentElement.yOffset,+ };+ })+ .filter((item) => item !== null),+ );++ sectionLayoutsCollection.push(+ ...board.sections+ .filter((section) => section.kind === "dynamic")+ .map((section): InferInsertModel<typeof sectionLayouts> | null => {+ const currentElement = result.items.find(+ (element) => element.type === "section" && element.id === section.id,+ );++ if (!currentElement) {+ return null;+ }++ return {+ layoutId: options.current.layoutId,+ sectionId: section.id,+ parentSectionId: currentElement.sectionId,+ height: currentElement.height,+ width: currentElement.width,+ xOffset: currentElement.xOffset,+ yOffset: currentElement.yOffset,+ };+ })+ .filter((section) => section !== null),+ );+ }++ return {+ itemSectionLayouts: itemSectionLayoutsCollection,+ sectionLayouts: sectionLayoutsCollection,+ };+};++const getElementsForLayout = (board: Awaited<ReturnType<typeof getFullBoardWithWhereAsync>>, layoutId: string) => {+ const sectionElements = board.sections+ .filter((section) => section.kind === "dynamic")+ .map((section) => {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const clonedLayout = section.layouts.find((sectionLayout) => sectionLayout.layoutId === layoutId)!;++ return {+ id: section.id,+ type: "section" as const,+ height: clonedLayout.height,+ width: clonedLayout.width,+ xOffset: clonedLayout.xOffset,+ yOffset: clonedLayout.yOffset,+ sectionId: clonedLayout.parentSectionId,+ };+ });++ const itemElements = board.items.map((item) => {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const clonedLayout = item.layouts.find((itemLayout) => itemLayout.layoutId === layoutId)!;++ return {+ id: item.id,+ type: "item" as const,+ height: clonedLayout.height,+ width: clonedLayout.width,+ xOffset: clonedLayout.xOffset,+ yOffset: clonedLayout.yOffset,+ sectionId: clonedLayout.sectionId,+ };+ });++ return [...itemElements, ...sectionElements];+};+const getFullBoardWithWhereAsync = async (db: Database, where: SQL<unknown>, userId: string | null) => {const groupsOfCurrentUser = await db.query.groupMembers.findMany({where: eq(groupMembers.userId, userId ?? ""),@@ -1105,17 +1516,20 @@ const getFullBoardWithWhereAsync = async (db: Database, where: SQL<unknown>, usecollapseStates: {where: eq(sectionCollapseStates.userId, userId ?? ""),},- items: {+ layouts: true,+ },+ },+ items: {+ with: {+ integrations: {with: {- integrations: {- with: {- integration: true,- },- },+ integration: true,},},+ layouts: true,},},+ layouts: true,userPermissions: {where: eq(boardUserPermissions.userId, userId ?? ""),columns: {@@ -1135,20 +1549,43 @@ const getFullBoardWithWhereAsync = async (db: Database, where: SQL<unknown>, use});}- const { sections, ...otherBoardProperties } = board;+ const { sections, items, layouts, ...otherBoardProperties } = board;return {...otherBoardProperties,+ layouts: layouts+ .map(({ boardId: _, ...layout }) => layout)+ .sort((layoutA, layoutB) => layoutA.breakpoint - layoutB.breakpoint),sections: sections.map(({ collapseStates, ...section }) =>parseSection({...section,+ xOffset: section.xOffset,+ yOffset: section.yOffset,+ layouts: section.layouts.map((layout) => ({+ xOffset: layout.xOffset,+ yOffset: layout.yOffset,+ width: layout.width,+ height: layout.height,+ parentSectionId: layout.parentSectionId,+ layoutId: layout.layoutId,+ })),collapsed: collapseStates.at(0)?.collapsed ?? false,- items: section.items.map(({ integrations: itemIntegrations, ...item }) => ({- ...item,- integrationIds: itemIntegrations.map((item) => item.integration.id),- advancedOptions: superjson.parse<BoardItemAdvancedOptions>(item.advancedOptions),- options: superjson.parse<Record<string, unknown>>(item.options),+ }),+ ),+ items: items.map(({ integrations: itemIntegrations, ...item }) =>+ parseItem({+ ...item,+ layouts: item.layouts.map((layout) => ({+ xOffset: layout.xOffset,+ yOffset: layout.yOffset,+ width: layout.width,+ height: layout.height,+ layoutId: layout.layoutId,+ sectionId: layout.sectionId,})),+ integrationIds: itemIntegrations.map((item) => item.integration.id),+ advancedOptions: superjson.parse<BoardItemAdvancedOptions>(item.advancedOptions),+ options: superjson.parse<Record<string, unknown>>(item.options),}),),};@@ -1162,8 +1599,17 @@ const forKind = <T extends WidgetKind>(kind: T) =>const outputItemSchema = zodUnionFromArray(widgetKinds.map((kind) => forKind(kind))).and(sharedItemSchema);+const parseItem = (item: unknown) => {+ const result = outputItemSchema.safeParse(item);++ if (!result.success) {+ throw new Error(result.error.message);+ }+ return result.data;+};+const parseSection = (section: unknown) => {- const result = createSectionSchema(outputItemSchema).safeParse(section);+ const result = sectionSchema.safeParse(section);if (!result.success) {throw new Error(result.error.message);diff --git a/packages/api/src/router/board/grid-algorithm.ts b/packages/api/src/router/board/grid-algorithm.tsnew file mode 100644index 000000000..cccc61056--- /dev/null+++ b/packages/api/src/router/board/grid-algorithm.ts@@ -0,0 +1,186 @@+export interface GridAlgorithmItem {+ id: string;+ type: "item" | "section";+ width: number;+ height: number;+ xOffset: number;+ yOffset: number;+ sectionId: string;+}++interface GridAlgorithmInput {+ items: GridAlgorithmItem[];+ width: number;+ previousWidth: number;+ sectionId: string;+}++interface GridAlgorithmOutput {+ height: number;+ items: GridAlgorithmItem[];+}++export const generateResponsiveGridFor = ({+ items,+ previousWidth,+ width,+ sectionId,+}: GridAlgorithmInput): GridAlgorithmOutput => {+ const itemsOfCurrentSection = items+ .filter((item) => item.sectionId === sectionId)+ .sort((itemA, itemB) =>+ itemA.yOffset === itemB.yOffset ? itemA.xOffset - itemB.xOffset : itemA.yOffset - itemB.yOffset,+ );+ const normalizedItems = normalizeItems(itemsOfCurrentSection, width);++ if (itemsOfCurrentSection.length === 0) {+ return {+ height: 0,+ items: [],+ };+ }++ const newItems: GridAlgorithmItem[] = [];++ // Fix height of dynamic sections+ const dynamicSectionHeightMap = new Map<string, number>();+ const dynamicSectionsOfCurrentSection = normalizedItems.filter((item) => item.type === "section");+ for (const dynamicSection of dynamicSectionsOfCurrentSection) {+ const result = generateResponsiveGridFor({+ items,+ previousWidth: dynamicSection.previousWidth,+ width: dynamicSection.width,+ sectionId: dynamicSection.id,+ });+ newItems.push(...result.items);+ dynamicSectionHeightMap.set(dynamicSection.id, result.height);+ }++ // Return same positions for items in the current section+ if (width >= previousWidth) {+ return {+ height: Math.max(...itemsOfCurrentSection.map((item) => item.yOffset + item.height)),+ items: newItems.concat(normalizedItems),+ };+ }++ const occupied2d: boolean[][] = [];++ for (const item of normalizedItems) {+ const itemWithHeight = {+ ...item,+ height: item.type === "section" ? Math.max(dynamicSectionHeightMap.get(item.id) ?? 1, item.height) : item.height,+ };+ const position = nextFreeSpot(occupied2d, itemWithHeight, width);+ if (!position) throw new Error("No free spot available");++ addItemToOccupied(occupied2d, itemWithHeight, position, width);+ newItems.push({+ ...itemWithHeight,+ xOffset: position.x,+ yOffset: position.y,+ });+ }++ return {+ height: occupied2d.length,+ items: newItems,+ };+};++/**+ * Reduces the width of the items to fit the new column count.+ * @param items items to normalize+ * @param columnCount new column count+ */+const normalizeItems = (items: GridAlgorithmItem[], columnCount: number) => {+ return items.map((item) => ({ ...item, previousWidth: item.width, width: Math.min(columnCount, item.width) }));+};++/**+ * Adds the item to the occupied spots.+ * @param occupied2d array of occupied spots+ * @param item item to place+ * @param position position to place the item+ */+const addItemToOccupied = (+ occupied2d: boolean[][],+ item: GridAlgorithmItem,+ position: { x: number; y: number },+ columnCount: number,+) => {+ for (let yOffset = 0; yOffset < item.height; yOffset++) {+ let row = occupied2d[position.y + yOffset];+ if (!row) {+ addRow(occupied2d, columnCount);+ // After adding it, it must exist+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ row = occupied2d[position.y + yOffset]!;+ }++ for (let xOffset = 0; xOffset < item.width; xOffset++) {+ row[position.x + xOffset] = true;+ }+ }+};++/**+ * Adds a new row to the grid.+ * @param occupied2d array of occupied spots+ * @param columnCount column count of section+ */+const addRow = (occupied2d: boolean[][], columnCount: number) => {+ occupied2d.push(new Array<boolean>(columnCount).fill(false));+};++/**+ * Searches for the next free spot in the grid.+ * @param occupied2d array of occupied spots+ * @param item item to place+ * @param columnCount column count of section+ * @returns the position of the next free spot or null if no spot is available+ */+const nextFreeSpot = (occupied2d: boolean[][], item: GridAlgorithmItem, columnCount: number) => {+ for (let offsetY = 0; offsetY < 99999; offsetY++) {+ for (let offsetX = 0; offsetX < columnCount; offsetX++) {+ if (hasHorizontalSpace(columnCount, item, offsetX) && isFree(occupied2d, item, { x: offsetX, y: offsetY })) {+ return { x: offsetX, y: offsetY };+ }+ }+ }++ return null;+};++/**+ * Check if the item fits into the grid horizontally.+ * @param columnCount available width+ * @param item item to place+ * @param offsetX current x position+ * @returns true if the item fits horizontally+ */+const hasHorizontalSpace = (columnCount: number, item: GridAlgorithmItem, offsetX: number) => {+ return offsetX + item.width <= columnCount;+};++/**+ * Check if the spot is free.+ * @param occupied2d array of occupied spots+ * @param item item to place+ * @param position position to check+ * @returns true if the spot is free+ */+const isFree = (occupied2d: boolean[][], item: GridAlgorithmItem, position: { x: number; y: number }) => {+ for (let yOffset = 0; yOffset < item.height; yOffset++) {+ const row = occupied2d[position.y + yOffset];+ if (!row) return true; // Empty row is free++ for (let xOffset = 0; xOffset < item.width; xOffset++) {+ if (row[position.x + xOffset]) {+ return false;+ }+ }+ }++ return true;+};diff --git a/packages/api/src/router/board/test/grid-algorithm.spec.ts b/packages/api/src/router/board/test/grid-algorithm.spec.tsnew file mode 100644index 000000000..6d73a4386--- /dev/null+++ b/packages/api/src/router/board/test/grid-algorithm.spec.ts@@ -0,0 +1,378 @@+import { createId } from "@paralleldrive/cuid2";+import { describe, expect, test } from "vitest";++import type { GridAlgorithmItem } from "../grid-algorithm";+import { generateResponsiveGridFor } from "../grid-algorithm";++const ROOT_SECTION_ID = "section";++/**+ * If you want to see how the layouts progress between the different layouts, you can find images here:+ * https://github.com/homarr-labs/architecture-documentation/tree/main/grid-algorithm#graphical-representation-of-the-algorithm+ */+describe("Grid Algorithm", () => {+ test.each(itemTests)("should convert a grid with %i columns to a grid with %i columns", (_, _ignored, item) => {+ const input = generateInputFromText(item.input);++ const result = generateResponsiveGridFor({+ items: input,+ width: item.outputColumnCount,+ previousWidth: item.inputColumnCount,+ sectionId: ROOT_SECTION_ID,+ });++ const output = generateOutputText(result.items, item.outputColumnCount);++ expect(output).toBe(item.output);+ });+ test.each(dynamicSectionTests)(+ "should convert a grid with dynamic sections from 16 columns to %i columns",+ (_, testInput) => {+ const outerDynamicSectionId = "b";+ const innerDynamicSectionId = "f";+ const items = [+ algoItem({ id: "a", width: 2, height: 2 }),+ algoItem({ id: outerDynamicSectionId, type: "section", width: 12, height: 3, yOffset: 2 }),+ algoItem({ id: "a", width: 2, sectionId: outerDynamicSectionId }),+ algoItem({ id: "b", width: 4, sectionId: outerDynamicSectionId, xOffset: 2 }),+ algoItem({ id: "c", width: 2, sectionId: outerDynamicSectionId, xOffset: 6 }),+ algoItem({ id: "d", width: 1, sectionId: outerDynamicSectionId, xOffset: 8 }),+ algoItem({ id: "e", width: 3, sectionId: outerDynamicSectionId, xOffset: 9 }),+ algoItem({+ id: innerDynamicSectionId,+ type: "section",+ width: 8,+ height: 2,+ yOffset: 1,+ sectionId: outerDynamicSectionId,+ }),+ algoItem({ id: "a", width: 2, sectionId: innerDynamicSectionId }),+ algoItem({ id: "b", width: 5, xOffset: 2, sectionId: innerDynamicSectionId }),+ algoItem({ id: "c", width: 1, height: 2, xOffset: 7, sectionId: innerDynamicSectionId }),+ algoItem({ id: "d", width: 7, yOffset: 1, sectionId: innerDynamicSectionId }),+ algoItem({ id: "g", width: 4, yOffset: 1, sectionId: outerDynamicSectionId, xOffset: 8 }),+ algoItem({ id: "h", width: 3, yOffset: 2, sectionId: outerDynamicSectionId, xOffset: 8 }),+ algoItem({ id: "i", width: 1, yOffset: 2, sectionId: outerDynamicSectionId, xOffset: 11 }),+ algoItem({ id: "c", width: 5, yOffset: 5 }),+ ];++ const newItems = generateResponsiveGridFor({+ items,+ width: testInput.outputColumns,+ previousWidth: 16,+ sectionId: ROOT_SECTION_ID,+ });++ const rootItems = newItems.items.filter((item) => item.sectionId === ROOT_SECTION_ID);+ const outerSection = items.find((item) => item.id === outerDynamicSectionId);+ const outerItems = newItems.items.filter((item) => item.sectionId === outerDynamicSectionId);+ const innerSection = items.find((item) => item.id === innerDynamicSectionId);+ const innerItems = newItems.items.filter((item) => item.sectionId === innerDynamicSectionId);++ expect(generateOutputText(rootItems, testInput.outputColumns)).toBe(testInput.root);+ expect(generateOutputText(outerItems, Math.min(testInput.outputColumns, outerSection?.width ?? 999))).toBe(+ testInput.outer,+ );+ expect(generateOutputText(innerItems, Math.min(testInput.outputColumns, innerSection?.width ?? 999))).toBe(+ testInput.inner,+ );+ },+ );+});++const algoItem = (item: Partial<GridAlgorithmItem>): GridAlgorithmItem => ({+ id: createId(),+ type: "item",+ width: 1,+ height: 1,+ xOffset: 0,+ yOffset: 0,+ sectionId: ROOT_SECTION_ID,+ ...item,+});++const sixteenColumns = `+abbccccddddeeefg+hbbccccddddeeeij+klllmmmmmnneeeop+qlllmmmmmnnrrrst+ulllmmmmmnnrrrvw+xyz äö`;++// Just add two empty columns to the right+const eighteenColumns = sixteenColumns+ .split("\n")+ .map((line, index) => (index === 0 ? line : `${line} `))+ .join("\n");++const tenColumns = `+abbcccceee+fbbcccceee+ddddghieee+ddddjklllo+mmmmmplllq+mmmmmslllt+mmmmmnnrrr+uvwxynnrrr+zäö nn `;++const sixColumns = `+abbfgh+ibbjko+ccccnn+ccccnn+ddddnn+ddddpq+eeelll+eeelll+eeelll+mmmmms+mmmmmt+mmmmmu+rrrvwx+rrryzä+ö `;+const threeColumns = `+abb+fbb+ccc+ccc+ddd+ddd+eee+eee+eee+ghi+jko+lll+lll+lll+mmm+mmm+mmm+nnp+nnq+nns+rrr+rrr+tuv+wxy+zäö`;++const itemTests = [+ {+ input: sixteenColumns,+ inputColumnCount: 16,+ output: sixteenColumns,+ outputColumnCount: 16,+ },+ {+ input: sixteenColumns,+ inputColumnCount: 16,+ output: eighteenColumns,+ outputColumnCount: 18,+ },+ {+ input: sixteenColumns,+ inputColumnCount: 16,+ output: tenColumns,+ outputColumnCount: 10,+ },+ {+ input: sixteenColumns,+ inputColumnCount: 16,+ output: sixColumns,+ outputColumnCount: 6,+ },+ {+ input: sixteenColumns,+ inputColumnCount: 16,+ output: threeColumns,+ outputColumnCount: 3,+ },+].map((item) => [item.inputColumnCount, item.outputColumnCount, item] as const);++const dynamicSectionTests = [+ {+ outputColumns: 16,+ root: `+aa+aa+bbbbbbbbbbbb+bbbbbbbbbbbb+bbbbbbbbbbbb+ccccc `,+ outer: `+aabbbbccdeee+ffffffffgggg+ffffffffhhhi`,+ inner: `+aabbbbbc+dddddddc`,+ },+ {+ outputColumns: 10,+ root: `+aaccccc+aa+bbbbbbbbbb+bbbbbbbbbb+bbbbbbbbbb+bbbbbbbbbb`,+ outer: `+aabbbbccdi+eeegggghhh+ffffffff+ffffffff `,+ inner: `+aabbbbbc+dddddddc`,+ },+ {+ outputColumns: 6,+ root: `+aa+aa+bbbbbb+bbbbbb+bbbbbb+bbbbbb+bbbbbb+bbbbbb+bbbbbb+ccccc `,+ outer: `+aabbbb+ccdeee+ffffff+ffffff+ffffff+ggggi+hhh `,+ inner: `+aa c+bbbbbc+dddddd`,+ },+ {+ outputColumns: 3,+ root: `+aa+aa+bbb+bbb+bbb+bbb+bbb+bbb+bbb+bbb+bbb+bbb+bbb+ccc`,+ outer: `+aad+bbb+cci+eee+fff+fff+fff+fff+fff+ggg+hhh`,+ inner: `+aa+bbb+c+c+ddd`,+ },+].map((item) => [item.outputColumns, item] as const);++const generateInputFromText = (text: string) => {+ const lines = text.split("\n").slice(1); // Remove first empty row+ const items: GridAlgorithmItem[] = [];+ for (let yOffset = 0; yOffset < lines.length; yOffset++) {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const line = lines[yOffset]!;+ for (let xOffset = 0; xOffset < line.length; xOffset++) {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const char = line[xOffset]!;+ if (char === " ") continue;+ if (items.some((item) => item.id === char)) continue;+ items.push({+ id: char,+ type: "item",+ width: getWidth(line, xOffset, char),+ height: getHeight(lines, { x: xOffset, y: yOffset }, char),+ xOffset,+ yOffset,+ sectionId: ROOT_SECTION_ID,+ });+ }+ }++ return items;+};++const generateOutputText = (items: GridAlgorithmItem[], columnCount: number) => {+ const occupied2d: string[][] = [];+ for (const item of items) {+ addItemToOccupied(occupied2d, item, { x: item.xOffset, y: item.yOffset }, columnCount);+ }++ return `\n${occupied2d.map((row) => row.join("")).join("\n")}`;+};++const getWidth = (line: string, offset: number, char: string) => {+ const row = line.split("");+ let width = 1;+ for (let xOffset = offset + 1; xOffset < row.length; xOffset++) {+ if (row[xOffset] === char) {+ width++;+ } else {+ break;+ }+ }+ return width;+};++const getHeight = (lines: string[], position: { x: number; y: number }, char: string) => {+ let height = 1;+ for (let yOffset = position.y + 1; yOffset < lines.length; yOffset++) {+ if (lines[yOffset]?.[position.x] === char) {+ height++;+ } else {+ break;+ }+ }+ return height;+};++const addItemToOccupied = (+ occupied2d: string[][],+ item: GridAlgorithmItem,+ position: { x: number; y: number },+ columnCount: number,+) => {+ for (let yOffset = 0; yOffset < item.height; yOffset++) {+ let row = occupied2d[position.y + yOffset];+ if (!row) {+ addRow(occupied2d, columnCount);+ // After adding it, it must exist+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ row = occupied2d[position.y + yOffset]!;+ }++ for (let xOffset = 0; xOffset < item.width; xOffset++) {+ row[position.x + xOffset] = item.id;+ }+ }+};++const addRow = (occupied2d: string[][], columnCount: number) => {+ occupied2d.push(new Array<string>(columnCount).fill(" "));+};diff --git a/packages/api/src/router/test/board.spec.ts b/packages/api/src/router/test/board.spec.tsindex 5c80ad2c0..bf57263b1 100644--- a/packages/api/src/router/test/board.spec.ts+++ b/packages/api/src/router/test/board.spec.ts@@ -2,8 +2,8 @@ import SuperJSON from "superjson";import { describe, expect, it, test, vi } from "vitest";import type { Session } from "@homarr/auth";-import type { Database } from "@homarr/db";-import { createId, eq } from "@homarr/db";+import type { Database, InferInsertModel } from "@homarr/db";+import { and, createId, eq, not } from "@homarr/db";import {boardGroupPermissions,boards,@@ -13,7 +13,10 @@ import {groups,integrationItems,integrations,+ itemLayouts,items,+ layouts,+ sectionLayouts,sections,serverSettings,users,@@ -304,17 +307,27 @@ describe("createBoard should create a new board", () => {await caller.createBoard({ name: "newBoard", columnCount: 24, isPublic: true });// Assert- const dbBoard = await db.query.boards.findFirst();+ const dbBoard = await db.query.boards.findFirst({+ with: {+ sections: true,+ layouts: true,+ },+ });expect(dbBoard).toBeDefined();expect(dbBoard?.name).toBe("newBoard");- expect(dbBoard?.columnCount).toBe(24);expect(dbBoard?.isPublic).toBe(true);expect(dbBoard?.creatorId).toBe(defaultCreatorId);- const dbSection = await db.query.sections.findFirst();- expect(dbSection).toBeDefined();- expect(dbSection?.boardId).toBe(dbBoard?.id);- expect(dbSection?.kind).toBe("empty");+ expect(dbBoard?.sections.length).toBe(1);+ const firstSection = dbBoard?.sections.at(0);+ expect(firstSection?.kind).toBe("empty");+ expect(firstSection?.xOffset).toBe(0);+ expect(firstSection?.yOffset).toBe(0);++ expect(dbBoard?.layouts.length).toBe(1);+ const firstLayout = dbBoard?.layouts.at(0);+ expect(firstLayout?.columnCount).toBe(24);+ expect(firstLayout?.breakpoint).toBe(0);});test("should throw error when user has no board-create permission", async () => {@@ -587,7 +600,6 @@ describe("savePartialBoardSettings should save general settings", () => {const newBackgroundImageSize = "cover";const newBackgroundImageRepeat = "repeat";const newBackgroundImageUrl = "http://background.image/url.png";- const newColumnCount = 2;const newCustomCss = "body { background-color: blue; }";const newOpacity = 0.8;const newPrimaryColor = "#0000ff";@@ -605,7 +617,6 @@ describe("savePartialBoardSettings should save general settings", () => {backgroundImageRepeat: newBackgroundImageRepeat,backgroundImageSize: newBackgroundImageSize,backgroundImageUrl: newBackgroundImageUrl,- columnCount: newColumnCount,customCss: newCustomCss,opacity: newOpacity,primaryColor: newPrimaryColor,@@ -626,7 +637,6 @@ describe("savePartialBoardSettings should save general settings", () => {expect(dbBoard?.backgroundImageRepeat).toBe(newBackgroundImageRepeat);expect(dbBoard?.backgroundImageSize).toBe(newBackgroundImageSize);expect(dbBoard?.backgroundImageUrl).toBe(newBackgroundImageUrl);- expect(dbBoard?.columnCount).toBe(newColumnCount);expect(dbBoard?.customCss).toBe(newCustomCss);expect(dbBoard?.opacity).toBe(newOpacity);expect(dbBoard?.primaryColor).toBe(newPrimaryColor);@@ -668,9 +678,9 @@ describe("saveBoard should save full board", () => {kind: "empty",yOffset: 0,xOffset: 0,- items: [],},],+ items: [],});const board = await db.query.boards.findFirst({@@ -695,7 +705,7 @@ describe("saveBoard should save full board", () => {const db = createDb();const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });- const { boardId, itemId, sectionId } = await createFullBoardAsync(db, "default");+ const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");await caller.saveBoard({id: boardId,@@ -705,19 +715,25 @@ describe("saveBoard should save full board", () => {kind: "empty",yOffset: 0,xOffset: 0,- items: [+ },+ ],+ items: [+ {+ id: createId(),+ kind: "clock",+ options: { is24HourFormat: true },+ integrationIds: [],+ layouts: [{- id: createId(),- kind: "clock",- options: { is24HourFormat: true },- integrationIds: [],+ layoutId,+ sectionId,height: 1,width: 1,xOffset: 0,yOffset: 0,- advancedOptions: {},},],+ advancedOptions: {},},],});@@ -725,11 +741,8 @@ describe("saveBoard should save full board", () => {const board = await db.query.boards.findFirst({where: eq(boards.id, boardId),with: {- sections: {- with: {- items: true,- },- },+ sections: true,+ items: true,},});@@ -739,9 +752,8 @@ describe("saveBoard should save full board", () => {const definedBoard = expectToBeDefined(board);expect(definedBoard.sections.length).toBe(1);- const firstSection = expectToBeDefined(definedBoard.sections[0]);- expect(firstSection.items.length).toBe(1);- expect(firstSection.items[0]?.id).not.toBe(itemId);+ expect(definedBoard.items.length).toBe(1);+ expect(definedBoard.items[0]?.id).not.toBe(itemId);expect(item).toBeUndefined();expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");});@@ -756,7 +768,7 @@ describe("saveBoard should save full board", () => {url: "http://localhost:3000",} as const;- const { boardId, itemId, integrationId, sectionId } = await createFullBoardAsync(db, "default");+ const { boardId, itemId, integrationId, sectionId, layoutId } = await createFullBoardAsync(db, "default");await db.insert(integrations).values(anotherIntegration);await caller.saveBoard({@@ -767,19 +779,25 @@ describe("saveBoard should save full board", () => {kind: "empty",xOffset: 0,yOffset: 0,- items: [+ },+ ],+ items: [+ {+ id: itemId,+ kind: "clock",+ options: { is24HourFormat: true },+ integrationIds: [anotherIntegration.id],+ layouts: [{- id: itemId,- kind: "clock",- options: { is24HourFormat: true },- integrationIds: [anotherIntegration.id],+ layoutId,+ sectionId,height: 1,width: 1,xOffset: 0,yOffset: 0,- advancedOptions: {},},],+ advancedOptions: {},},],});@@ -787,13 +805,10 @@ describe("saveBoard should save full board", () => {const board = await db.query.boards.findFirst({where: eq(boards.id, boardId),with: {- sections: {+ sections: true,+ items: {with: {- items: {- with: {- integrations: true,- },- },+ integrations: true,},},},@@ -805,9 +820,8 @@ describe("saveBoard should save full board", () => {const definedBoard = expectToBeDefined(board);expect(definedBoard.sections.length).toBe(1);- const firstSection = expectToBeDefined(definedBoard.sections[0]);- expect(firstSection.items.length).toBe(1);- const firstItem = expectToBeDefined(firstSection.items[0]);+ expect(definedBoard.items.length).toBe(1);+ const firstItem = expectToBeDefined(definedBoard.items[0]);expect(firstItem.integrations.length).toBe(1);expect(firstItem.integrations[0]?.integrationId).not.toBe(integrationId);expect(integration).toBeUndefined();@@ -830,7 +844,6 @@ describe("saveBoard should save full board", () => {id: newSectionId,xOffset: 0,yOffset: 1,- items: [],...partialSection,},{@@ -838,9 +851,9 @@ describe("saveBoard should save full board", () => {kind: "empty",xOffset: 0,yOffset: 0,- items: [],},],+ items: [],});const board = await db.query.boards.findFirst({@@ -873,7 +886,7 @@ describe("saveBoard should save full board", () => {const db = createDb();const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });- const { boardId, sectionId } = await createFullBoardAsync(db, "default");+ const { boardId, sectionId, layoutId } = await createFullBoardAsync(db, "default");const newItemId = createId();await caller.saveBoard({@@ -884,19 +897,25 @@ describe("saveBoard should save full board", () => {kind: "empty",yOffset: 0,xOffset: 0,- items: [+ },+ ],+ items: [+ {+ id: newItemId,+ kind: "clock",+ options: { is24HourFormat: true },+ integrationIds: [],+ layouts: [{- id: newItemId,- kind: "clock",- options: { is24HourFormat: true },- integrationIds: [],+ layoutId,+ sectionId,height: 1,width: 1,xOffset: 3,yOffset: 2,- advancedOptions: {},},],+ advancedOptions: {},},],});@@ -904,9 +923,10 @@ describe("saveBoard should save full board", () => {const board = await db.query.boards.findFirst({where: eq(boards.id, boardId),with: {- sections: {+ sections: true,+ items: {with: {- items: true,+ layouts: true,},},},@@ -918,17 +938,18 @@ describe("saveBoard should save full board", () => {const definedBoard = expectToBeDefined(board);expect(definedBoard.sections.length).toBe(1);- const firstSection = expectToBeDefined(definedBoard.sections[0]);- expect(firstSection.items.length).toBe(1);- const addedItem = expectToBeDefined(firstSection.items.find((item) => item.id === newItemId));+ expect(definedBoard.items.length).toBe(1);+ const addedItem = expectToBeDefined(definedBoard.items.find((item) => item.id === newItemId));expect(addedItem).toBeDefined();expect(addedItem.id).toBe(newItemId);expect(addedItem.kind).toBe("clock");expect(addedItem.options).toBe(SuperJSON.stringify({ is24HourFormat: true }));- expect(addedItem.height).toBe(1);- expect(addedItem.width).toBe(1);- expect(addedItem.xOffset).toBe(3);- expect(addedItem.yOffset).toBe(2);+ const firstLayout = expectToBeDefined(addedItem.layouts[0]);+ expect(firstLayout.sectionId).toBe(sectionId);+ expect(firstLayout.height).toBe(1);+ expect(firstLayout.width).toBe(1);+ expect(firstLayout.xOffset).toBe(3);+ expect(firstLayout.yOffset).toBe(2);expect(item).toBeDefined();expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");});@@ -943,7 +964,7 @@ describe("saveBoard should save full board", () => {url: "http://plex.local",} as const;- const { boardId, itemId, sectionId } = await createFullBoardAsync(db, "default");+ const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");await db.insert(integrations).values(integration);await caller.saveBoard({@@ -954,19 +975,25 @@ describe("saveBoard should save full board", () => {kind: "empty",xOffset: 0,yOffset: 0,- items: [+ },+ ],+ items: [+ {+ id: itemId,+ kind: "clock",+ options: { is24HourFormat: true },+ integrationIds: [integration.id],+ layouts: [{- id: itemId,- kind: "clock",- options: { is24HourFormat: true },- integrationIds: [integration.id],+ sectionId,+ layoutId,height: 1,width: 1,xOffset: 0,yOffset: 0,- advancedOptions: {},},],+ advancedOptions: {},},],});@@ -974,13 +1001,10 @@ describe("saveBoard should save full board", () => {const board = await db.query.boards.findFirst({where: eq(boards.id, boardId),with: {- sections: {+ sections: true,+ items: {with: {- items: {- with: {- integrations: true,- },- },+ integrations: true,},},},@@ -992,9 +1016,7 @@ describe("saveBoard should save full board", () => {const definedBoard = expectToBeDefined(board);expect(definedBoard.sections.length).toBe(1);- const firstSection = expectToBeDefined(definedBoard.sections[0]);- expect(firstSection.items.length).toBe(1);- const firstItem = expectToBeDefined(firstSection.items.find((item) => item.id === itemId));+ const firstItem = expectToBeDefined(definedBoard.items.find((item) => item.id === itemId));expect(firstItem.integrations.length).toBe(1);expect(firstItem.integrations[0]?.integrationId).toBe(integration.id);expect(integrationItem).toBeDefined();@@ -1025,7 +1047,6 @@ describe("saveBoard should save full board", () => {xOffset: 0,name: "Test",collapsed: true,- items: [],},{id: newSectionId,@@ -1034,9 +1055,9 @@ describe("saveBoard should save full board", () => {yOffset: 0,xOffset: 0,collapsed: false,- items: [],},],+ items: [],});const board = await db.query.boards.findFirst({@@ -1064,7 +1085,7 @@ describe("saveBoard should save full board", () => {const db = createDb();const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });- const { boardId, itemId, sectionId } = await createFullBoardAsync(db, "default");+ const { boardId, itemId, sectionId, layoutId } = await createFullBoardAsync(db, "default");await caller.saveBoard({id: boardId,@@ -1074,19 +1095,25 @@ describe("saveBoard should save full board", () => {kind: "empty",yOffset: 0,xOffset: 0,- items: [+ },+ ],+ items: [+ {+ id: itemId,+ kind: "clock",+ options: { is24HourFormat: false },+ integrationIds: [],+ layouts: [{- id: itemId,- kind: "clock",- options: { is24HourFormat: false },- integrationIds: [],+ layoutId,+ sectionId,height: 3,width: 2,xOffset: 7,yOffset: 5,- advancedOptions: {},},],+ advancedOptions: {},},],});@@ -1094,9 +1121,10 @@ describe("saveBoard should save full board", () => {const board = await db.query.boards.findFirst({where: eq(boards.id, boardId),with: {- sections: {+ sections: true,+ items: {with: {- items: true,+ layouts: true,},},},@@ -1104,16 +1132,17 @@ describe("saveBoard should save full board", () => {const definedBoard = expectToBeDefined(board);expect(definedBoard.sections.length).toBe(1);- const firstSection = expectToBeDefined(definedBoard.sections[0]);- expect(firstSection.items.length).toBe(1);- const firstItem = expectToBeDefined(firstSection.items.find((item) => item.id === itemId));+ expect(definedBoard.items.length).toBe(1);+ const firstItem = expectToBeDefined(definedBoard.items.find((item) => item.id === itemId));expect(firstItem.id).toBe(itemId);expect(firstItem.kind).toBe("clock");expect(SuperJSON.parse<{ is24HourFormat: boolean }>(firstItem.options).is24HourFormat).toBe(false);- expect(firstItem.height).toBe(3);- expect(firstItem.width).toBe(2);- expect(firstItem.xOffset).toBe(7);- expect(firstItem.yOffset).toBe(5);+ const firstLayout = expectToBeDefined(firstItem.layouts[0]);+ expect(firstLayout.sectionId).toBe(sectionId);+ expect(firstLayout.height).toBe(3);+ expect(firstLayout.width).toBe(2);+ expect(firstLayout.xOffset).toBe(7);+ expect(firstLayout.yOffset).toBe(5);expect(spy).toHaveBeenCalledWith(expect.anything(), expect.anything(), "modify");});it("should fail when board not found", async () => {@@ -1124,6 +1153,7 @@ describe("saveBoard should save full board", () => {await caller.saveBoard({id: "nonExistentBoardId",sections: [],+ items: [],});await expect(actAsync()).rejects.toThrowError("Board not found");@@ -1293,6 +1323,165 @@ describe("saveGroupBoardPermissions should save group board permissions", () =>);});+const createExistingLayout = (id: string) => ({+ id,+ name: "Base",+ columnCount: 10,+ breakpoint: 0,+});+const createNewLayout = (columnCount: number) => ({+ id: createId(),+ name: "New layout",+ columnCount,+ breakpoint: 1400,+});+describe("saveLayouts should save layout changes", () => {+ test("should add layout when not present in database", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { boardId, layoutId } = await createFullBoardAsync(db, "default");+ const newLayout = createNewLayout(12);++ // Act+ await caller.saveLayouts({+ id: boardId,+ layouts: [createExistingLayout(layoutId), newLayout],+ });++ // Assert+ const layout = await db.query.layouts.findFirst({+ where: not(eq(layouts.id, layoutId)),+ });++ const definedLayout = expectToBeDefined(layout);+ expect(definedLayout.name).toBe(newLayout.name);+ expect(definedLayout.columnCount).toBe(newLayout.columnCount);+ expect(definedLayout.breakpoint).toBe(newLayout.breakpoint);+ });+ test("should add items and dynamic sections generated from grid-algorithm when new layout is added", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");+ const assignments = await createItemsAndSectionsAsync(db, {+ boardId,+ layoutId,+ sectionId,+ });+ const newLayout = createNewLayout(3);++ // Act+ await caller.saveLayouts({+ id: boardId,+ layouts: [createExistingLayout(layoutId), newLayout],+ });++ // Assert+ const layout = await db.query.layouts.findFirst({+ where: not(eq(layouts.id, layoutId)),+ });+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ await expectLayoutForRootLayoutAsync(db, sectionId, layout!.id, {+ ...assignments.inRoot,+ a: itemId,+ });+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ await expectLayoutForDynamicSectionAsync(db, assignments.inRoot.f, layout!.id, assignments.inDynamicSection);+ });+ test("should update layout when present in input", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { boardId, layoutId } = await createFullBoardAsync(db, "default");+ const updatedLayout = createExistingLayout(layoutId);+ updatedLayout.breakpoint = 1400;+ updatedLayout.name = "Updated layout";++ // Act+ await caller.saveLayouts({+ id: boardId,+ layouts: [updatedLayout],+ });++ // Assert+ const layout = await db.query.layouts.findFirst({+ where: eq(layouts.id, layoutId),+ });++ const definedLayout = expectToBeDefined(layout);+ expect(definedLayout.name).toBe(updatedLayout.name);+ expect(definedLayout.columnCount).toBe(updatedLayout.columnCount);+ expect(definedLayout.breakpoint).toBe(updatedLayout.breakpoint);+ });+ test("should update position of items when column count changes", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { boardId, layoutId, sectionId, itemId } = await createFullBoardAsync(db, "default");+ const assignments = await createItemsAndSectionsAsync(db, {+ boardId,+ layoutId,+ sectionId,+ });+ const updatedLayout = createExistingLayout(layoutId);+ updatedLayout.columnCount = 3;++ // Act+ await caller.saveLayouts({+ id: boardId,+ layouts: [updatedLayout],+ });++ // Assert+ await expectLayoutForRootLayoutAsync(db, sectionId, layoutId, {+ ...assignments.inRoot,+ a: itemId,+ });+ await expectLayoutForDynamicSectionAsync(db, assignments.inRoot.f, layoutId, assignments.inDynamicSection);+ });+ test("should remove layout when not present in input", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { boardId, layoutId } = await createFullBoardAsync(db, "default");++ // Act+ await caller.saveLayouts({+ id: boardId,+ layouts: [createNewLayout(12)],+ });++ // Assert+ const layout = await db.query.layouts.findFirst({+ where: eq(layouts.id, layoutId),+ });+ expect(layout).toBeUndefined();+ });+ test("should fail when board not found", async () => {+ // Arrange+ const db = createDb();+ const caller = boardRouter.createCaller({ db, deviceType: undefined, session: defaultSession });++ const { layoutId } = await createFullBoardAsync(db, "default");++ // Act+ const actAsync = async () =>+ await caller.saveLayouts({+ id: createId(),+ layouts: [createExistingLayout(layoutId)],+ });++ // Assert+ await expect(actAsync()).rejects.toThrowError("Board not found");+ });+});+const expectInputToBeFullBoardWithName = (input: RouterOutputs["board"]["getHomeBoard"],props: { name: string } & Awaited<ReturnType<typeof createFullBoardAsync>>,@@ -1302,8 +1491,8 @@ const expectInputToBeFullBoardWithName = (expect(input.sections.length).toBe(1);const firstSection = expectToBeDefined(input.sections[0]);expect(firstSection.id).toBe(props.sectionId);- expect(firstSection.items.length).toBe(1);- const firstItem = expectToBeDefined(firstSection.items[0]);+ expect(input.items.length).toBe(1);+ const firstItem = expectToBeDefined(input.items[0]);expect(firstItem.id).toBe(props.itemId);expect(firstItem.kind).toBe("clock");if (firstItem.kind === "clock") {@@ -1326,6 +1515,15 @@ const createFullBoardAsync = async (db: Database, name: string) => {creatorId: defaultCreatorId,});+ const layoutId = createId();+ await db.insert(layouts).values({+ id: layoutId,+ name: "Base",+ columnCount: 10,+ breakpoint: 0,+ boardId,+ });+const sectionId = createId();await db.insert(sections).values({id: sectionId,@@ -1339,12 +1537,18 @@ const createFullBoardAsync = async (db: Database, name: string) => {await db.insert(items).values({id: itemId,kind: "clock",+ boardId,+ options: SuperJSON.stringify({ is24HourFormat: true }),+ });++ await db.insert(itemLayouts).values({height: 1,width: 1,xOffset: 0,yOffset: 0,sectionId,- options: SuperJSON.stringify({ is24HourFormat: true }),+ itemId,+ layoutId,});const integrationId = createId();@@ -1363,7 +1567,226 @@ const createFullBoardAsync = async (db: Database, name: string) => {return {boardId,sectionId,+ layoutId,itemId,integrationId,};};++const addItemAsync = async (+ db: Database,+ item: Partial<Pick<InferInsertModel<typeof itemLayouts>, "height" | "width" | "xOffset" | "yOffset">> & {+ sectionId: string;+ layoutId: string;+ boardId: string;+ },+) => {+ const itemId = createId();+ await db.insert(items).values({+ id: itemId,+ kind: "clock",+ boardId: item.boardId,+ options: SuperJSON.stringify({ is24HourFormat: true }),+ });+ await db.insert(itemLayouts).values({+ itemId,+ layoutId: item.layoutId,+ sectionId: item.sectionId,+ height: item.height ?? 1,+ width: item.width ?? 1,+ xOffset: item.xOffset ?? 0,+ yOffset: item.yOffset ?? 0,+ });+ return itemId;+};++const addDynamicSectionAsync = async (+ db: Database,+ section: Partial<Pick<InferInsertModel<typeof sectionLayouts>, "xOffset" | "yOffset" | "width" | "height">> & {+ parentSectionId: string;+ boardId: string;+ layoutId: string;+ },+) => {+ const sectionId = createId();+ await db.insert(sections).values({+ id: sectionId,+ kind: "dynamic",+ boardId: section.boardId,+ });+ await db.insert(sectionLayouts).values({+ parentSectionId: section.parentSectionId,+ layoutId: section.layoutId,+ sectionId,+ xOffset: section.xOffset ?? 0,+ yOffset: section.yOffset ?? 0,+ width: section.width ?? 1,+ height: section.height ?? 1,+ });+ return sectionId;+};++const createItemsAndSectionsAsync = async (+ db: Database,+ options: { boardId: string; sectionId: string; layoutId: string },+) => {+ const { boardId, layoutId, sectionId } = options;+ // From:+ // abbbbbccdd+ // efffffccdd+ // efffffggdd+ // efffffgg+ // To:+ // a+ // bbb+ // cce+ // cce+ // dde+ // dd+ // dd+ // fff+ // fff+ // fff+ // fff+ // gg+ // gg+ const itemB = await addItemAsync(db, { boardId, layoutId, sectionId, xOffset: 1, width: 5 });+ const itemC = await addItemAsync(db, { boardId, layoutId, sectionId, xOffset: 6, width: 2, height: 2 });+ const itemD = await addItemAsync(db, { boardId, layoutId, sectionId, xOffset: 8, width: 2, height: 3 });+ const itemE = await addItemAsync(db, { boardId, layoutId, sectionId, yOffset: 1, height: 3 });+ const sectionF = await addDynamicSectionAsync(db, {+ yOffset: 1,+ xOffset: 1,+ width: 5,+ height: 3,+ parentSectionId: sectionId,+ boardId,+ layoutId,+ });+ const sectionG = await addDynamicSectionAsync(db, {+ yOffset: 2,+ xOffset: 6,+ width: 2,+ height: 2,+ parentSectionId: sectionId,+ boardId,+ layoutId,+ });+ // From:+ // hhhhh+ // iiijj+ // iii+ // To:+ // hhh+ // iii+ // iii+ // jj+ const itemH = await addItemAsync(db, { boardId, layoutId, sectionId: sectionF, width: 5 });+ const itemI = await addItemAsync(db, { boardId, layoutId, sectionId: sectionF, width: 3, height: 2, yOffset: 1 });+ const itemJ = await addItemAsync(db, { boardId, layoutId, sectionId: sectionF, width: 2, yOffset: 1, xOffset: 2 });++ return {+ inRoot: {+ b: itemB,+ c: itemC,+ d: itemD,+ e: itemE,+ f: sectionF,+ g: sectionG,+ },+ inDynamicSection: {+ h: itemH,+ i: itemI,+ j: itemJ,+ },+ };+};++const expectLayoutForRootLayoutAsync = async (+ db: Database,+ sectionId: string,+ layoutId: string,+ assignments: Record<string, string>,+) => {+ await expectLayoutInSectionAsync(+ db,+ sectionId,+ layoutId,+ `+a+bbb+cce+cce+dde+dd+dd+fff+fff+fff+fff+gg+gg`,+ assignments,+ );+};++const expectLayoutForDynamicSectionAsync = async (+ db: Database,+ sectionId: string,+ layoutId: string,+ assignments: Record<string, string>,+) => {+ await expectLayoutInSectionAsync(+ db,+ sectionId,+ layoutId,+ `+hhh+iii+iii+jj`,+ assignments,+ );+};++const expectLayoutInSectionAsync = async (+ db: Database,+ sectionId: string,+ layoutId: string,+ layout: string,+ assignments: Record<string, string>,+) => {+ const itemsInSection = await db.query.itemLayouts.findMany({+ where: and(eq(itemLayouts.sectionId, sectionId), eq(itemLayouts.layoutId, layoutId)),+ });+ const sectionsInSection = await db.query.sectionLayouts.findMany({+ where: and(eq(sectionLayouts.parentSectionId, sectionId), eq(sectionLayouts.layoutId, layoutId)),+ });+ const entries = [...itemsInSection, ...sectionsInSection];++ const lines = layout.split("\n").slice(1);+ const keys = Object.keys(assignments);+ const positions: Record<string, { x: number; y: number; w: number; h: number }> = {};+ for (let yOffset = 0; yOffset < lines.length; yOffset++) {+ const line = lines[yOffset];+ if (!line) continue;+ for (let xOffset = 0; xOffset < line.length; xOffset++) {+ const char = line[xOffset];+ if (!char) continue;+ if (!keys.includes(char)) continue;+ if (char in positions) continue;+ const width = line.split("").filter((lineChar) => lineChar === char).length;+ const height = lines.slice(yOffset).filter((line) => line.substring(xOffset).startsWith(char)).length;+ positions[char] = { x: xOffset, y: yOffset, w: width, h: height };+ }+ }++ for (const [key, { x, y, w, h }] of Object.entries(positions)) {+ const entry = entries.find((entry) => ("itemId" in entry ? entry.itemId : entry.sectionId) === assignments[key]);+ expect(entry, `Expect entry for ${key} to be defined in assignments=${JSON.stringify(assignments)}`).toBeDefined();+ expect(entry?.xOffset, `Expect xOffset of entry for ${key} to be ${x} for entry=${JSON.stringify(entry)}`).toBe(x);+ expect(entry?.yOffset, `Expect yOffset of entry for ${key} to be ${y} for entry=${JSON.stringify(entry)}`).toBe(y);+ expect(entry?.width, `Expect width of entry for ${key} to be ${w} for entry=${JSON.stringify(entry)}`).toBe(w);+ expect(entry?.height, `Expect height of entry for ${key} to be ${h} for entry=${JSON.stringify(entry)}`).toBe(h);+ }+};diff --git a/packages/api/src/router/widgets/notebook.ts b/packages/api/src/router/widgets/notebook.tsindex 994a15e4c..53d4e0fdd 100644--- a/packages/api/src/router/widgets/notebook.ts+++ b/packages/api/src/router/widgets/notebook.ts@@ -19,16 +19,9 @@ export const notebookRouter = createTRPCRouter({.mutation(async ({ ctx, input }) => {const item = await ctx.db.query.items.findFirst({where: eq(items.id, input.itemId),- with: {- section: {- columns: {- boardId: true,- },- },- },});- if (!item || item.section.boardId !== input.boardId) {+ if (!item || item.boardId !== input.boardId) {throw new TRPCError({code: "NOT_FOUND",message: "Specified item was not found",diff --git a/packages/auth/permissions/integration-query-permissions.ts b/packages/auth/permissions/integration-query-permissions.tsindex 13d65aca8..aff03d6e9 100644--- a/packages/auth/permissions/integration-query-permissions.ts+++ b/packages/auth/permissions/integration-query-permissions.ts@@ -11,9 +11,7 @@ interface Integration {id: string;items: {item: {- section: {- boardId: string;- };+ boardId: string;};}[];userPermissions: {@@ -56,7 +54,7 @@ export const hasQueryAccessToIntegrationsAsync = async (const integrationsWithBoardIds = integrationsWithoutUseAccessAndWithoutBoardViewAllAccess.map((integration) => ({id: integration.id,- anyOfBoardIds: integration.items.map(({ item }) => item.section.boardId),+ anyOfBoardIds: integration.items.map(({ item }) => item.boardId),}));const permissionsOfCurrentUserWhenPresent = await db.query.boardUserPermissions.findMany({diff --git a/packages/auth/permissions/test/integration-query-permissions.spec.ts b/packages/auth/permissions/test/integration-query-permissions.spec.tsindex fd2c1dca3..0ee04f913 100644--- a/packages/auth/permissions/test/integration-query-permissions.spec.ts+++ b/packages/auth/permissions/test/integration-query-permissions.spec.ts@@ -29,13 +29,13 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aconst integrations = [{id: "1",- items: [{ item: { section: { boardId: "1" } } }],+ items: [{ item: { boardId: "1" } }],userPermissions: [],groupPermissions: [],},{id: "2",- items: [{ item: { section: { boardId: "2" } } }],+ items: [{ item: { boardId: "2" } }],userPermissions: [],groupPermissions: [],},@@ -63,7 +63,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aconst integrations = [{id: "1",- items: [{ item: { section: { boardId: "1" } } }],+ items: [{ item: { boardId: "1" } }],userPermissions: [],groupPermissions: [],},@@ -131,9 +131,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -145,16 +143,12 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -189,9 +183,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -203,9 +195,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -240,9 +230,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -254,16 +242,12 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -300,9 +284,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -314,9 +296,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -353,9 +333,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -367,9 +345,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -401,9 +377,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -415,16 +389,12 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -452,9 +422,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -466,16 +434,12 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -502,9 +466,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -516,9 +478,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -543,9 +503,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -557,9 +515,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},],@@ -585,9 +541,7 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],@@ -599,16 +553,12 @@ describe("hasQueryAccessToIntegrationsAsync should check if the user has query aitems: [{item: {- section: {- boardId: "2",- },+ boardId: "2",},},{item: {- section: {- boardId: "1",- },+ boardId: "1",},},],diff --git a/packages/boards/src/context.tsx b/packages/boards/src/context.tsxindex ab2af5c74..a099f64c7 100644--- a/packages/boards/src/context.tsx+++ b/packages/boards/src/context.tsx@@ -1,7 +1,7 @@"use client";import type { PropsWithChildren } from "react";-import { createContext, useContext, useEffect } from "react";+import { createContext, useCallback, useContext, useEffect, useState } from "react";import { usePathname } from "next/navigation";import type { RouterOutputs } from "@homarr/api";@@ -10,7 +10,7 @@ import { clientApi } from "@homarr/api/client";import { updateBoardName } from "./updater";const BoardContext = createContext<{- board: RouterOutputs["board"]["getHomeBoard"];+ board: RouterOutputs["board"]["getBoardByName"];} | null>(null);export const BoardProvider = ({@@ -68,3 +68,43 @@ export const useOptionalBoard = () => {return context?.board ?? null;};++export const getCurrentLayout = (board: RouterOutputs["board"]["getBoardByName"]) => {+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ if (typeof window === "undefined") return board.layouts.at(0)!.id;++ const sortedLayouts = board.layouts.sort((layoutA, layoutB) => layoutB.breakpoint - layoutA.breakpoint);++ // Fallback to smallest if none exists with breakpoint smaller than window width+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ return sortedLayouts.find((layout) => layout.breakpoint <= window.innerWidth)?.id ?? sortedLayouts.at(0)!.id;+};++export const useCurrentLayout = () => {+ const board = useRequiredBoard();+ const [currentLayout, setCurrentLayout] = useState(getCurrentLayout(board));++ const onResize = useCallback(() => {+ setCurrentLayout(getCurrentLayout(board));+ }, [board]);++ useEffect(() => {+ if (typeof window === "undefined") return;+ window.addEventListener("resize", onResize);++ return () => {+ window.removeEventListener("resize", onResize);+ };+ }, [onResize]);++ return currentLayout;+};++export const getBoardLayouts = (board: RouterOutputs["board"]["getBoardByName"]) =>+ board.layouts.map((layout) => layout.id);++export const useLayouts = () => {+ const board = useRequiredBoard();++ return getBoardLayouts(board);+};diff --git a/packages/old-import/src/import/collections/common.ts b/packages/db/collection.tssimilarity index 56%rename from packages/old-import/src/import/collections/common.tsrename to packages/db/collection.tsindex a7ad01da4..1bcbb9316 100644--- a/packages/old-import/src/import/collections/common.ts+++ b/packages/db/collection.ts@@ -1,12 +1,18 @@+import type { InferInsertModel } from "drizzle-orm";+import { objectEntries } from "@homarr/common";-import type { Database, HomarrDatabaseMysql, InferInsertModel } from "@homarr/db";-import * as schema from "@homarr/db/schema";++import type { HomarrDatabase, HomarrDatabaseMysql } from "./driver";+import { env } from "./env";+import * as schema from "./schema";type TableKey = {[K in keyof typeof schema]: (typeof schema)[K] extends { _: { brand: "Table" } } ? K : never;}[keyof typeof schema];-export const createDbInsertCollection = <TTableKey extends TableKey>(tablesInInsertOrder: TTableKey[]) => {+export const createDbInsertCollectionForTransaction = <TTableKey extends TableKey>(+ tablesInInsertOrder: TTableKey[],+) => {const context = tablesInInsertOrder.reduce((acc, key) => {acc[key] = [];@@ -17,7 +23,7 @@ export const createDbInsertCollection = <TTableKey extends TableKey>(tablesInInsreturn {...context,- insertAll: (db: Database) => {+ insertAll: (db: HomarrDatabase) => {db.transaction((transaction) => {for (const [key, values] of objectEntries(context)) {if (values.length >= 1) {@@ -41,3 +47,21 @@ export const createDbInsertCollection = <TTableKey extends TableKey>(tablesInIns},};};++export const createDbInsertCollectionWithoutTransaction = <TTableKey extends TableKey>(+ tablesInInsertOrder: TTableKey[],+) => {+ const { insertAll, insertAllAsync, ...collection } = createDbInsertCollectionForTransaction(tablesInInsertOrder);++ return {+ ...collection,+ insertAllAsync: async (db: HomarrDatabase) => {+ if (env.DB_DRIVER !== "mysql2") {+ insertAll(db);+ return;+ }++ await insertAllAsync(db as unknown as HomarrDatabaseMysql);+ },+ };+};diff --git a/packages/db/migrations/mysql/0029_add_layouts.sql b/packages/db/migrations/mysql/0029_add_layouts.sqlnew file mode 100644index 000000000..3dd2ba727--- /dev/null+++ b/packages/db/migrations/mysql/0029_add_layouts.sql@@ -0,0 +1,50 @@+CREATE TABLE `item_layout` (+ `item_id` varchar(64) NOT NULL,+ `section_id` varchar(64) NOT NULL,+ `layout_id` varchar(64) NOT NULL,+ `x_offset` int NOT NULL,+ `y_offset` int NOT NULL,+ `width` int NOT NULL,+ `height` int NOT NULL,+ CONSTRAINT `item_layout_item_id_section_id_layout_id_pk` PRIMARY KEY(`item_id`,`section_id`,`layout_id`)+);+--> statement-breakpoint+CREATE TABLE `layout` (+ `id` varchar(64) NOT NULL,+ `name` varchar(32) NOT NULL,+ `board_id` varchar(64) NOT NULL,+ `column_count` tinyint NOT NULL,+ `breakpoint` smallint NOT NULL DEFAULT 0,+ CONSTRAINT `layout_id` PRIMARY KEY(`id`)+);+--> statement-breakpoint+CREATE TABLE `section_layout` (+ `section_id` varchar(64) NOT NULL,+ `layout_id` varchar(64) NOT NULL,+ `parent_section_id` varchar(64),+ `x_offset` int NOT NULL,+ `y_offset` int NOT NULL,+ `width` int NOT NULL,+ `height` int NOT NULL,+ CONSTRAINT `section_layout_section_id_layout_id_pk` PRIMARY KEY(`section_id`,`layout_id`)+);+--> statement-breakpoint+ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_item_id_item_id_fk` FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `item_layout` ADD CONSTRAINT `item_layout_layout_id_layout_id_fk` FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `layout` ADD CONSTRAINT `layout_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_section_id_section_id_fk` FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_layout_id_layout_id_fk` FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+ALTER TABLE `section_layout` ADD CONSTRAINT `section_layout_parent_section_id_section_id_fk` FOREIGN KEY (`parent_section_id`) REFERENCES `section`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+INSERT INTO `layout`(`id`, `name`, `board_id`, `column_count`) SELECT `id`, 'Base', `id`, `column_count` FROM `board`;+--> statement-breakpoint+INSERT INTO `item_layout`(`item_id`, `section_id`, `layout_id`, `x_offset`, `y_offset`, `width`, `height`) SELECT `item`.`id`, `section`.`id`, `board`.`id`, `item`.`x_offset`, `item`.`y_offset`, `item`.`width`, `item`.`height` FROM `board` LEFT JOIN `section` ON `section`.`board_id`=`board`.`id` LEFT JOIN `item` ON `item`.`section_id`=`section`.`id` WHERE `item`.`id` IS NOT NULL;+--> statement-breakpoint+INSERT INTO `section_layout`(`section_id`, `layout_id`, `parent_section_id`, `x_offset`, `y_offset`, `width`, `height`) SELECT `section`.`id`, `board`.`id`, `section`.`parent_section_id`, `section`.`x_offset`, `section`.`y_offset`, `section`.`width`, `section`.`height` FROM `board` LEFT JOIN `section` ON `section`.`board_id`=`board`.`id` WHERE `section`.`id` IS NOT NULL AND `section`.`kind` = 'dynamic';diff --git a/packages/db/migrations/mysql/0030_migrate_item_and_section_for_layouts.sql b/packages/db/migrations/mysql/0030_migrate_item_and_section_for_layouts.sqlnew file mode 100644index 000000000..cb1aad714--- /dev/null+++ b/packages/db/migrations/mysql/0030_migrate_item_and_section_for_layouts.sql@@ -0,0 +1,36 @@+-- Custom SQL migration file, put your code below! --+ALTER TABLE `item` DROP FOREIGN KEY `item_section_id_section_id_fk`;+--> statement-breakpoint+ALTER TABLE `section` DROP FOREIGN KEY `section_parent_section_id_section_id_fk`;+--> statement-breakpoint+ALTER TABLE `section` MODIFY COLUMN `x_offset` int;+--> statement-breakpoint+ALTER TABLE `section` MODIFY COLUMN `y_offset` int;+--> statement-breakpoint+ALTER TABLE `item` ADD `board_id` varchar(64);+--> statement-breakpoint+ALTER TABLE `item` ADD CONSTRAINT `item_board_id_board_id_fk` FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON DELETE cascade ON UPDATE no action;+--> statement-breakpoint+UPDATE `item` JOIN `section` ON `item`.`section_id`=`section`.`id` SET `item`.`board_id` = `section`.`board_id`;+--> statement-breakpoint+ALTER TABLE `item` MODIFY COLUMN `board_id` varchar(64) NOT NULL;+--> statement-breakpoint+ALTER TABLE `board` DROP COLUMN `column_count`;+--> statement-breakpoint+ALTER TABLE `item` DROP COLUMN `section_id`;+--> statement-breakpoint+ALTER TABLE `item` DROP COLUMN `x_offset`;+--> statement-breakpoint+ALTER TABLE `item` DROP COLUMN `y_offset`;+--> statement-breakpoint+ALTER TABLE `item` DROP COLUMN `width`;+--> statement-breakpoint+ALTER TABLE `item` DROP COLUMN `height`;+--> statement-breakpoint+ALTER TABLE `section` DROP COLUMN `width`;+--> statement-breakpoint+ALTER TABLE `section` DROP COLUMN `height`;+--> statement-breakpoint+ALTER TABLE `section` DROP COLUMN `parent_section_id`;+--> statement-breakpoint+UPDATE `section` SET `x_offset` = NULL, `y_offset` = NULL WHERE `kind` = 'dynamic';\ No newline at end of filediff --git a/packages/db/migrations/mysql/meta/0029_snapshot.json b/packages/db/migrations/mysql/meta/0029_snapshot.jsonnew file mode 100644index 000000000..a36417579--- /dev/null+++ b/packages/db/migrations/mysql/meta/0029_snapshot.json@@ -0,0 +1,2012 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "1467982f-9448-4711-8430-ba6273b6d97d",+ "prevId": "2360d4b4-15c7-484f-a546-ffd6c39972f2",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "userId_idx": {+ "name": "userId_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "account_provider_provider_account_id_pk": {+ "name": "account_provider_provider_account_id_pk",+ "columns": ["provider", "provider_account_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "apiKey": {+ "name": "apiKey",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "api_key": {+ "name": "api_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "apiKey_user_id_user_id_fk": {+ "name": "apiKey_user_id_user_id_fk",+ "tableFrom": "apiKey",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "apiKey_id": {+ "name": "apiKey_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "app": {+ "name": "app",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "href": {+ "name": "href",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ping_url": {+ "name": "ping_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "app_id": {+ "name": "app_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "boardGroupPermission": {+ "name": "boardGroupPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardGroupPermission_board_id_board_id_fk": {+ "name": "boardGroupPermission_board_id_board_id_fk",+ "tableFrom": "boardGroupPermission",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "boardGroupPermission_group_id_group_id_fk": {+ "name": "boardGroupPermission_group_id_group_id_fk",+ "tableFrom": "boardGroupPermission",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "boardGroupPermission_board_id_group_id_permission_pk": {+ "name": "boardGroupPermission_board_id_group_id_permission_pk",+ "columns": ["board_id", "group_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "boardUserPermission": {+ "name": "boardUserPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardUserPermission_board_id_board_id_fk": {+ "name": "boardUserPermission_board_id_board_id_fk",+ "tableFrom": "boardUserPermission",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "boardUserPermission_user_id_user_id_fk": {+ "name": "boardUserPermission_user_id_user_id_fk",+ "tableFrom": "boardUserPermission",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "boardUserPermission_board_id_user_id_permission_pk": {+ "name": "boardUserPermission_board_id_user_id_permission_pk",+ "columns": ["board_id", "user_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "board": {+ "name": "board",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_public": {+ "name": "is_public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "page_title": {+ "name": "page_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "meta_title": {+ "name": "meta_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "logo_image_url": {+ "name": "logo_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "favicon_image_url": {+ "name": "favicon_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_url": {+ "name": "background_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_attachment": {+ "name": "background_image_attachment",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('fixed')"+ },+ "background_image_repeat": {+ "name": "background_image_repeat",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('no-repeat')"+ },+ "background_image_size": {+ "name": "background_image_size",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('cover')"+ },+ "primary_color": {+ "name": "primary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('#fa5252')"+ },+ "secondary_color": {+ "name": "secondary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('#fd7e14')"+ },+ "opacity": {+ "name": "opacity",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 100+ },+ "custom_css": {+ "name": "custom_css",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_color": {+ "name": "icon_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "item_radius": {+ "name": "item_radius",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('lg')"+ },+ "disable_status": {+ "name": "disable_status",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "board_creator_id_user_id_fk": {+ "name": "board_creator_id_user_id_fk",+ "tableFrom": "board",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "board_id": {+ "name": "board_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "board_name_unique": {+ "name": "board_name_unique",+ "columns": ["name"]+ }+ },+ "checkConstraint": {}+ },+ "groupMember": {+ "name": "groupMember",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupMember_group_id_group_id_fk": {+ "name": "groupMember_group_id_group_id_fk",+ "tableFrom": "groupMember",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "groupMember_user_id_user_id_fk": {+ "name": "groupMember_user_id_user_id_fk",+ "tableFrom": "groupMember",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "groupMember_group_id_user_id_pk": {+ "name": "groupMember_group_id_user_id_pk",+ "columns": ["group_id", "user_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "groupPermission": {+ "name": "groupPermission",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupPermission_group_id_group_id_fk": {+ "name": "groupPermission_group_id_group_id_fk",+ "tableFrom": "groupPermission",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "group": {+ "name": "group",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "owner_id": {+ "name": "owner_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "smallint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "group_owner_id_user_id_fk": {+ "name": "group_owner_id_user_id_fk",+ "tableFrom": "group",+ "tableTo": "user",+ "columnsFrom": ["owner_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "group_home_board_id_board_id_fk": {+ "name": "group_home_board_id_board_id_fk",+ "tableFrom": "group",+ "tableTo": "board",+ "columnsFrom": ["home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "group_mobile_home_board_id_board_id_fk": {+ "name": "group_mobile_home_board_id_board_id_fk",+ "tableFrom": "group",+ "tableTo": "board",+ "columnsFrom": ["mobile_home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "group_id": {+ "name": "group_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "group_name_unique": {+ "name": "group_name_unique",+ "columns": ["name"]+ }+ },+ "checkConstraint": {}+ },+ "iconRepository": {+ "name": "iconRepository",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(150)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "iconRepository_id": {+ "name": "iconRepository_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "icon": {+ "name": "icon",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(250)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_repository_id": {+ "name": "icon_repository_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "icon_icon_repository_id_iconRepository_id_fk": {+ "name": "icon_icon_repository_id_iconRepository_id_fk",+ "tableFrom": "icon",+ "tableTo": "iconRepository",+ "columnsFrom": ["icon_repository_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "icon_id": {+ "name": "icon_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationGroupPermissions": {+ "name": "integrationGroupPermissions",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationGroupPermissions_integration_id_integration_id_fk": {+ "name": "integrationGroupPermissions_integration_id_integration_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integrationGroupPermissions_group_id_group_id_fk": {+ "name": "integrationGroupPermissions_group_id_group_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integration_group_permission__pk": {+ "name": "integration_group_permission__pk",+ "columns": ["integration_id", "group_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integration_item": {+ "name": "integration_item",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integration_item_item_id_item_id_fk": {+ "name": "integration_item_item_id_item_id_fk",+ "tableFrom": "integration_item",+ "tableTo": "item",+ "columnsFrom": ["item_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integration_item_integration_id_integration_id_fk": {+ "name": "integration_item_integration_id_integration_id_fk",+ "tableFrom": "integration_item",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integration_item_item_id_integration_id_pk": {+ "name": "integration_item_item_id_integration_id_pk",+ "columns": ["item_id", "integration_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationSecret": {+ "name": "integrationSecret",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration_secret__kind_idx": {+ "name": "integration_secret__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ },+ "integration_secret__updated_at_idx": {+ "name": "integration_secret__updated_at_idx",+ "columns": ["updated_at"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "integrationSecret_integration_id_integration_id_fk": {+ "name": "integrationSecret_integration_id_integration_id_fk",+ "tableFrom": "integrationSecret",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integrationSecret_integration_id_kind_pk": {+ "name": "integrationSecret_integration_id_kind_pk",+ "columns": ["integration_id", "kind"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationUserPermission": {+ "name": "integrationUserPermission",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationUserPermission_integration_id_integration_id_fk": {+ "name": "integrationUserPermission_integration_id_integration_id_fk",+ "tableFrom": "integrationUserPermission",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integrationUserPermission_user_id_user_id_fk": {+ "name": "integrationUserPermission_user_id_user_id_fk",+ "tableFrom": "integrationUserPermission",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integrationUserPermission_integration_id_user_id_permission_pk": {+ "name": "integrationUserPermission_integration_id_user_id_permission_pk",+ "columns": ["integration_id", "user_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integration": {+ "name": "integration",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration__kind_idx": {+ "name": "integration__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "integration_id": {+ "name": "integration_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "invite": {+ "name": "invite",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiration_date": {+ "name": "expiration_date",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "invite_creator_id_user_id_fk": {+ "name": "invite_creator_id_user_id_fk",+ "tableFrom": "invite",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "invite_id": {+ "name": "invite_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "invite_token_unique": {+ "name": "invite_token_unique",+ "columns": ["token"]+ }+ },+ "checkConstraint": {}+ },+ "item_layout": {+ "name": "item_layout",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_layout_item_id_item_id_fk": {+ "name": "item_layout_item_id_item_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "item",+ "columnsFrom": ["item_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "item_layout_section_id_section_id_fk": {+ "name": "item_layout_section_id_section_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "item_layout_layout_id_layout_id_fk": {+ "name": "item_layout_layout_id_layout_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "layout",+ "columnsFrom": ["layout_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "item_layout_item_id_section_id_layout_id_pk": {+ "name": "item_layout_item_id_section_id_layout_id_pk",+ "columns": ["item_id", "section_id", "layout_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "item": {+ "name": "item",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ },+ "advanced_options": {+ "name": "advanced_options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_board_id_board_id_fk": {+ "name": "item_board_id_board_id_fk",+ "tableFrom": "item",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "item_id": {+ "name": "item_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "layout": {+ "name": "layout",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "column_count": {+ "name": "column_count",+ "type": "tinyint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "breakpoint": {+ "name": "breakpoint",+ "type": "smallint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "layout_board_id_board_id_fk": {+ "name": "layout_board_id_board_id_fk",+ "tableFrom": "layout",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "layout_id": {+ "name": "layout_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "media": {+ "name": "media",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "BLOB",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "size": {+ "name": "size",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "media_creator_id_user_id_fk": {+ "name": "media_creator_id_user_id_fk",+ "tableFrom": "media",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "media_id": {+ "name": "media_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "onboarding": {+ "name": "onboarding",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "step": {+ "name": "step",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "previous_step": {+ "name": "previous_step",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "onboarding_id": {+ "name": "onboarding_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "search_engine": {+ "name": "search_engine",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "short": {+ "name": "short",+ "type": "varchar(8)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "url_template": {+ "name": "url_template",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'generic'"+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "search_engine_integration_id_integration_id_fk": {+ "name": "search_engine_integration_id_integration_id_fk",+ "tableFrom": "search_engine",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "search_engine_id": {+ "name": "search_engine_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "search_engine_short_unique": {+ "name": "search_engine_short_unique",+ "columns": ["short"]+ }+ },+ "checkConstraint": {}+ },+ "section_collapse_state": {+ "name": "section_collapse_state",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "collapsed": {+ "name": "collapsed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_collapse_state_user_id_user_id_fk": {+ "name": "section_collapse_state_user_id_user_id_fk",+ "tableFrom": "section_collapse_state",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_collapse_state_section_id_section_id_fk": {+ "name": "section_collapse_state_section_id_section_id_fk",+ "tableFrom": "section_collapse_state",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "section_collapse_state_user_id_section_id_pk": {+ "name": "section_collapse_state_user_id_section_id_pk",+ "columns": ["user_id", "section_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "section_layout": {+ "name": "section_layout",+ "columns": {+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "parent_section_id": {+ "name": "parent_section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_layout_section_id_section_id_fk": {+ "name": "section_layout_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_layout_layout_id_layout_id_fk": {+ "name": "section_layout_layout_id_layout_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "layout",+ "columnsFrom": ["layout_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_layout_parent_section_id_section_id_fk": {+ "name": "section_layout_parent_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "section",+ "columnsFrom": ["parent_section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "section_layout_section_id_layout_id_pk": {+ "name": "section_layout_section_id_layout_id_pk",+ "columns": ["section_id", "layout_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "section": {+ "name": "section",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_board_id_board_id_fk": {+ "name": "section_board_id_board_id_fk",+ "tableFrom": "section",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "section_id": {+ "name": "section_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "serverSetting": {+ "name": "serverSetting",+ "columns": {+ "setting_key": {+ "name": "setting_key",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "serverSetting_setting_key": {+ "name": "serverSetting_setting_key",+ "columns": ["setting_key"]+ }+ },+ "uniqueConstraints": {+ "serverSetting_settingKey_unique": {+ "name": "serverSetting_settingKey_unique",+ "columns": ["setting_key"]+ }+ },+ "checkConstraint": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "session_token": {+ "name": "session_token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "session_session_token": {+ "name": "session_session_token",+ "columns": ["session_token"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'credentials'"+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "default_search_engine_id": {+ "name": "default_search_engine_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "open_search_in_new_tab": {+ "name": "open_search_in_new_tab",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "color_scheme": {+ "name": "color_scheme",+ "type": "varchar(5)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'dark'"+ },+ "first_day_of_week": {+ "name": "first_day_of_week",+ "type": "tinyint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "ping_icons_enabled": {+ "name": "ping_icons_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_home_board_id_board_id_fk": {+ "name": "user_home_board_id_board_id_fk",+ "tableFrom": "user",+ "tableTo": "board",+ "columnsFrom": ["home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_mobile_home_board_id_board_id_fk": {+ "name": "user_mobile_home_board_id_board_id_fk",+ "tableFrom": "user",+ "tableTo": "board",+ "columnsFrom": ["mobile_home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_default_search_engine_id_search_engine_id_fk": {+ "name": "user_default_search_engine_id_search_engine_id_fk",+ "tableFrom": "user",+ "tableTo": "search_engine",+ "columnsFrom": ["default_search_engine_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "user_id": {+ "name": "user_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "verificationToken": {+ "name": "verificationToken",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verificationToken_identifier_token_pk": {+ "name": "verificationToken_identifier_token_pk",+ "columns": ["identifier", "token"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}diff --git a/packages/db/migrations/mysql/meta/0030_snapshot.json b/packages/db/migrations/mysql/meta/0030_snapshot.jsonnew file mode 100644index 000000000..b09566bae--- /dev/null+++ b/packages/db/migrations/mysql/meta/0030_snapshot.json@@ -0,0 +1,2012 @@+{+ "id": "8ddad056-e26e-43fe-a075-d24d5bc03463",+ "prevId": "1467982f-9448-4711-8430-ba6273b6d97d",+ "version": "5",+ "dialect": "mysql",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "userId_idx": {+ "name": "userId_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "account_provider_provider_account_id_pk": {+ "name": "account_provider_provider_account_id_pk",+ "columns": ["provider", "provider_account_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "apiKey": {+ "name": "apiKey",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "api_key": {+ "name": "api_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "apiKey_user_id_user_id_fk": {+ "name": "apiKey_user_id_user_id_fk",+ "tableFrom": "apiKey",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "apiKey_id": {+ "name": "apiKey_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "app": {+ "name": "app",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "href": {+ "name": "href",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ping_url": {+ "name": "ping_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "app_id": {+ "name": "app_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "boardGroupPermission": {+ "name": "boardGroupPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardGroupPermission_board_id_board_id_fk": {+ "name": "boardGroupPermission_board_id_board_id_fk",+ "tableFrom": "boardGroupPermission",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "boardGroupPermission_group_id_group_id_fk": {+ "name": "boardGroupPermission_group_id_group_id_fk",+ "tableFrom": "boardGroupPermission",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "boardGroupPermission_board_id_group_id_permission_pk": {+ "name": "boardGroupPermission_board_id_group_id_permission_pk",+ "columns": ["board_id", "group_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "boardUserPermission": {+ "name": "boardUserPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardUserPermission_board_id_board_id_fk": {+ "name": "boardUserPermission_board_id_board_id_fk",+ "tableFrom": "boardUserPermission",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "boardUserPermission_user_id_user_id_fk": {+ "name": "boardUserPermission_user_id_user_id_fk",+ "tableFrom": "boardUserPermission",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "boardUserPermission_board_id_user_id_permission_pk": {+ "name": "boardUserPermission_board_id_user_id_permission_pk",+ "columns": ["board_id", "user_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "board": {+ "name": "board",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(256)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_public": {+ "name": "is_public",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "page_title": {+ "name": "page_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "meta_title": {+ "name": "meta_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "logo_image_url": {+ "name": "logo_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "favicon_image_url": {+ "name": "favicon_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_url": {+ "name": "background_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_attachment": {+ "name": "background_image_attachment",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('fixed')"+ },+ "background_image_repeat": {+ "name": "background_image_repeat",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('no-repeat')"+ },+ "background_image_size": {+ "name": "background_image_size",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('cover')"+ },+ "primary_color": {+ "name": "primary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('#fa5252')"+ },+ "secondary_color": {+ "name": "secondary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('#fd7e14')"+ },+ "opacity": {+ "name": "opacity",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 100+ },+ "custom_css": {+ "name": "custom_css",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_color": {+ "name": "icon_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "item_radius": {+ "name": "item_radius",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('lg')"+ },+ "disable_status": {+ "name": "disable_status",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "board_creator_id_user_id_fk": {+ "name": "board_creator_id_user_id_fk",+ "tableFrom": "board",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {+ "board_id": {+ "name": "board_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "board_name_unique": {+ "name": "board_name_unique",+ "columns": ["name"]+ }+ },+ "checkConstraint": {}+ },+ "groupMember": {+ "name": "groupMember",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupMember_group_id_group_id_fk": {+ "name": "groupMember_group_id_group_id_fk",+ "tableFrom": "groupMember",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "groupMember_user_id_user_id_fk": {+ "name": "groupMember_user_id_user_id_fk",+ "tableFrom": "groupMember",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "groupMember_group_id_user_id_pk": {+ "name": "groupMember_group_id_user_id_pk",+ "columns": ["group_id", "user_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "groupPermission": {+ "name": "groupPermission",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupPermission_group_id_group_id_fk": {+ "name": "groupPermission_group_id_group_id_fk",+ "tableFrom": "groupPermission",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "group": {+ "name": "group",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "owner_id": {+ "name": "owner_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "smallint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "group_owner_id_user_id_fk": {+ "name": "group_owner_id_user_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["owner_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "group_home_board_id_board_id_fk": {+ "name": "group_home_board_id_board_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "group_mobile_home_board_id_board_id_fk": {+ "name": "group_mobile_home_board_id_board_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["mobile_home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {+ "group_id": {+ "name": "group_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "group_name_unique": {+ "name": "group_name_unique",+ "columns": ["name"]+ }+ },+ "checkConstraint": {}+ },+ "iconRepository": {+ "name": "iconRepository",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "varchar(150)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "iconRepository_id": {+ "name": "iconRepository_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "icon": {+ "name": "icon",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(250)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_repository_id": {+ "name": "icon_repository_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "icon_icon_repository_id_iconRepository_id_fk": {+ "name": "icon_icon_repository_id_iconRepository_id_fk",+ "tableFrom": "icon",+ "columnsFrom": ["icon_repository_id"],+ "tableTo": "iconRepository",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "icon_id": {+ "name": "icon_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationGroupPermissions": {+ "name": "integrationGroupPermissions",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationGroupPermissions_integration_id_integration_id_fk": {+ "name": "integrationGroupPermissions_integration_id_integration_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integrationGroupPermissions_group_id_group_id_fk": {+ "name": "integrationGroupPermissions_group_id_group_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integration_group_permission__pk": {+ "name": "integration_group_permission__pk",+ "columns": ["integration_id", "group_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integration_item": {+ "name": "integration_item",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integration_item_item_id_item_id_fk": {+ "name": "integration_item_item_id_item_id_fk",+ "tableFrom": "integration_item",+ "columnsFrom": ["item_id"],+ "tableTo": "item",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integration_item_integration_id_integration_id_fk": {+ "name": "integration_item_integration_id_integration_id_fk",+ "tableFrom": "integration_item",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integration_item_item_id_integration_id_pk": {+ "name": "integration_item_item_id_integration_id_pk",+ "columns": ["item_id", "integration_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationSecret": {+ "name": "integrationSecret",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "varchar(16)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration_secret__kind_idx": {+ "name": "integration_secret__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ },+ "integration_secret__updated_at_idx": {+ "name": "integration_secret__updated_at_idx",+ "columns": ["updated_at"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "integrationSecret_integration_id_integration_id_fk": {+ "name": "integrationSecret_integration_id_integration_id_fk",+ "tableFrom": "integrationSecret",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integrationSecret_integration_id_kind_pk": {+ "name": "integrationSecret_integration_id_kind_pk",+ "columns": ["integration_id", "kind"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integrationUserPermission": {+ "name": "integrationUserPermission",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationUserPermission_integration_id_integration_id_fk": {+ "name": "integrationUserPermission_integration_id_integration_id_fk",+ "tableFrom": "integrationUserPermission",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integrationUserPermission_user_id_user_id_fk": {+ "name": "integrationUserPermission_user_id_user_id_fk",+ "tableFrom": "integrationUserPermission",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integrationUserPermission_integration_id_user_id_permission_pk": {+ "name": "integrationUserPermission_integration_id_user_id_permission_pk",+ "columns": ["integration_id", "user_id", "permission"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "integration": {+ "name": "integration",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "varchar(128)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration__kind_idx": {+ "name": "integration__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "integration_id": {+ "name": "integration_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "invite": {+ "name": "invite",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiration_date": {+ "name": "expiration_date",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "invite_creator_id_user_id_fk": {+ "name": "invite_creator_id_user_id_fk",+ "tableFrom": "invite",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "invite_id": {+ "name": "invite_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "invite_token_unique": {+ "name": "invite_token_unique",+ "columns": ["token"]+ }+ },+ "checkConstraint": {}+ },+ "item_layout": {+ "name": "item_layout",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_layout_item_id_item_id_fk": {+ "name": "item_layout_item_id_item_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["item_id"],+ "tableTo": "item",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "item_layout_section_id_section_id_fk": {+ "name": "item_layout_section_id_section_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "item_layout_layout_id_layout_id_fk": {+ "name": "item_layout_layout_id_layout_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["layout_id"],+ "tableTo": "layout",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "item_layout_item_id_section_id_layout_id_pk": {+ "name": "item_layout_item_id_section_id_layout_id_pk",+ "columns": ["item_id", "section_id", "layout_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "item": {+ "name": "item",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ },+ "advanced_options": {+ "name": "advanced_options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_board_id_board_id_fk": {+ "name": "item_board_id_board_id_fk",+ "tableFrom": "item",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "item_id": {+ "name": "item_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "layout": {+ "name": "layout",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "column_count": {+ "name": "column_count",+ "type": "tinyint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "breakpoint": {+ "name": "breakpoint",+ "type": "smallint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "layout_board_id_board_id_fk": {+ "name": "layout_board_id_board_id_fk",+ "tableFrom": "layout",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "layout_id": {+ "name": "layout_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "media": {+ "name": "media",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "BLOB",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "size": {+ "name": "size",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(now())"+ },+ "creator_id": {+ "name": "creator_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "media_creator_id_user_id_fk": {+ "name": "media_creator_id_user_id_fk",+ "tableFrom": "media",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {+ "media_id": {+ "name": "media_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "onboarding": {+ "name": "onboarding",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "step": {+ "name": "step",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "previous_step": {+ "name": "previous_step",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "onboarding_id": {+ "name": "onboarding_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "search_engine": {+ "name": "search_engine",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "short": {+ "name": "short",+ "type": "varchar(8)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "url_template": {+ "name": "url_template",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'generic'"+ },+ "integration_id": {+ "name": "integration_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "search_engine_integration_id_integration_id_fk": {+ "name": "search_engine_integration_id_integration_id_fk",+ "tableFrom": "search_engine",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "search_engine_id": {+ "name": "search_engine_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {+ "search_engine_short_unique": {+ "name": "search_engine_short_unique",+ "columns": ["short"]+ }+ },+ "checkConstraint": {}+ },+ "section_collapse_state": {+ "name": "section_collapse_state",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "collapsed": {+ "name": "collapsed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_collapse_state_user_id_user_id_fk": {+ "name": "section_collapse_state_user_id_user_id_fk",+ "tableFrom": "section_collapse_state",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_collapse_state_section_id_section_id_fk": {+ "name": "section_collapse_state_section_id_section_id_fk",+ "tableFrom": "section_collapse_state",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "section_collapse_state_user_id_section_id_pk": {+ "name": "section_collapse_state_user_id_section_id_pk",+ "columns": ["user_id", "section_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "section_layout": {+ "name": "section_layout",+ "columns": {+ "section_id": {+ "name": "section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "parent_section_id": {+ "name": "parent_section_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_layout_section_id_section_id_fk": {+ "name": "section_layout_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_layout_layout_id_layout_id_fk": {+ "name": "section_layout_layout_id_layout_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["layout_id"],+ "tableTo": "layout",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_layout_parent_section_id_section_id_fk": {+ "name": "section_layout_parent_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["parent_section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "section_layout_section_id_layout_id_pk": {+ "name": "section_layout_section_id_layout_id_pk",+ "columns": ["section_id", "layout_id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "section": {+ "name": "section",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "int",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_board_id_board_id_fk": {+ "name": "section_board_id_board_id_fk",+ "tableFrom": "section",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "section_id": {+ "name": "section_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "serverSetting": {+ "name": "serverSetting",+ "columns": {+ "setting_key": {+ "name": "setting_key",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "('{\"json\": {}}')"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "serverSetting_setting_key": {+ "name": "serverSetting_setting_key",+ "columns": ["setting_key"]+ }+ },+ "uniqueConstraints": {+ "serverSetting_settingKey_unique": {+ "name": "serverSetting_settingKey_unique",+ "columns": ["setting_key"]+ }+ },+ "checkConstraint": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "session_token": {+ "name": "session_token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "session_session_token": {+ "name": "session_session_token",+ "columns": ["session_token"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'credentials'"+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "default_search_engine_id": {+ "name": "default_search_engine_id",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "open_search_in_new_tab": {+ "name": "open_search_in_new_tab",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "color_scheme": {+ "name": "color_scheme",+ "type": "varchar(5)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'dark'"+ },+ "first_day_of_week": {+ "name": "first_day_of_week",+ "type": "tinyint",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "ping_icons_enabled": {+ "name": "ping_icons_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_home_board_id_board_id_fk": {+ "name": "user_home_board_id_board_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "user_mobile_home_board_id_board_id_fk": {+ "name": "user_mobile_home_board_id_board_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["mobile_home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "user_default_search_engine_id_search_engine_id_fk": {+ "name": "user_default_search_engine_id_search_engine_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["default_search_engine_id"],+ "tableTo": "search_engine",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {+ "user_id": {+ "name": "user_id",+ "columns": ["id"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "verificationToken": {+ "name": "verificationToken",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "varchar(64)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "varchar(512)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verificationToken_identifier_token_pk": {+ "name": "verificationToken_identifier_token_pk",+ "columns": ["identifier", "token"]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}diff --git a/packages/db/migrations/mysql/meta/_journal.json b/packages/db/migrations/mysql/meta/_journal.jsonindex e7dd4f04b..448ff0de3 100644--- a/packages/db/migrations/mysql/meta/_journal.json+++ b/packages/db/migrations/mysql/meta/_journal.json@@ -204,6 +204,20 @@"when": 1740086765989,"tag": "0028_add_app_ping_url","breakpoints": true+ },+ {+ "idx": 29,+ "version": "5",+ "when": 1740255915876,+ "tag": "0029_add_layouts",+ "breakpoints": true+ },+ {+ "idx": 30,+ "version": "5",+ "when": 1740256006328,+ "tag": "0030_migrate_item_and_section_for_layouts",+ "breakpoints": true}]}diff --git a/packages/db/migrations/sqlite/0029_add_layouts.sql b/packages/db/migrations/sqlite/0029_add_layouts.sqlnew file mode 100644index 000000000..92b349924--- /dev/null+++ b/packages/db/migrations/sqlite/0029_add_layouts.sql@@ -0,0 +1,42 @@+CREATE TABLE `item_layout` (+ `item_id` text NOT NULL,+ `section_id` text NOT NULL,+ `layout_id` text NOT NULL,+ `x_offset` integer NOT NULL,+ `y_offset` integer NOT NULL,+ `width` integer NOT NULL,+ `height` integer NOT NULL,+ PRIMARY KEY(`item_id`, `section_id`, `layout_id`),+ FOREIGN KEY (`item_id`) REFERENCES `item`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE TABLE `layout` (+ `id` text PRIMARY KEY NOT NULL,+ `name` text NOT NULL,+ `board_id` text NOT NULL,+ `column_count` integer NOT NULL,+ `breakpoint` integer DEFAULT 0 NOT NULL,+ FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+CREATE TABLE `section_layout` (+ `section_id` text NOT NULL,+ `layout_id` text NOT NULL,+ `parent_section_id` text,+ `x_offset` integer NOT NULL,+ `y_offset` integer NOT NULL,+ `width` integer NOT NULL,+ `height` integer NOT NULL,+ PRIMARY KEY(`section_id`, `layout_id`),+ FOREIGN KEY (`section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`layout_id`) REFERENCES `layout`(`id`) ON UPDATE no action ON DELETE cascade,+ FOREIGN KEY (`parent_section_id`) REFERENCES `section`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+INSERT INTO "layout"("id", "name", "board_id", "column_count") SELECT id, 'Base', id, column_count FROM board;+--> statement-breakpoint+INSERT INTO "item_layout"("item_id", "section_id", "layout_id", "x_offset", "y_offset", "width", "height") SELECT item.id, section.id, board.id, item.x_offset, item.y_offset, item.width, item.height FROM board LEFT JOIN section ON section.board_id=board.id LEFT JOIN item ON item.section_id=section.id WHERE item.id IS NOT NULL;+--> statement-breakpoint+INSERT INTO "section_layout"("section_id", "layout_id", "parent_section_id", "x_offset", "y_offset", "width", "height") SELECT section.id, board.id, section.parent_section_id, section.x_offset, section.y_offset, section.width, section.height FROM board LEFT JOIN section ON section.board_id=board.id WHERE section.id IS NOT NULL AND section.kind = 'dynamic';diff --git a/packages/db/migrations/sqlite/0030_migrate_item_and_section_for_layouts.sql b/packages/db/migrations/sqlite/0030_migrate_item_and_section_for_layouts.sqlnew file mode 100644index 000000000..2d458b28c--- /dev/null+++ b/packages/db/migrations/sqlite/0030_migrate_item_and_section_for_layouts.sql@@ -0,0 +1,47 @@+-- Custom SQL migration file, put your code below! --+COMMIT TRANSACTION;+--> statement-breakpoint+PRAGMA foreign_keys=OFF;+--> statement-breakpoint+BEGIN TRANSACTION;+--> statement-breakpoint+CREATE TABLE `__new_item` (+ `id` text PRIMARY KEY NOT NULL,+ `board_id` text NOT NULL,+ `kind` text NOT NULL,+ `options` text DEFAULT '{"json": {}}' NOT NULL,+ `advanced_options` text DEFAULT '{"json": {}}' NOT NULL,+ FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+INSERT INTO `__new_item`("id", "board_id", "kind", "options", "advanced_options") SELECT "item"."id", "section"."board_id", "item"."kind", "item"."options", "item"."advanced_options" FROM `item` LEFT JOIN `section` ON section.id=item.section_id;+--> statement-breakpoint+DROP TABLE `item`;+--> statement-breakpoint+ALTER TABLE `__new_item` RENAME TO `item`;+--> statement-breakpoint+CREATE TABLE `__new_section` (+ `id` text PRIMARY KEY NOT NULL,+ `board_id` text NOT NULL,+ `kind` text NOT NULL,+ `x_offset` integer,+ `y_offset` integer,+ `name` text,+ FOREIGN KEY (`board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE cascade+);+--> statement-breakpoint+INSERT INTO `__new_section`("id", "board_id", "kind", "x_offset", "y_offset", "name") SELECT "id", "board_id", "kind", "x_offset", "y_offset", "name" FROM `section`;+--> statement-breakpoint+DROP TABLE `section`;+--> statement-breakpoint+ALTER TABLE `__new_section` RENAME TO `section`;+--> statement-breakpoint+UPDATE `section` SET `x_offset` = NULL, `y_offset` = NULL WHERE `kind` = 'dynamic';+--> statement-breakpoint+ALTER TABLE `board` DROP COLUMN `column_count`;+--> statement-breakpoint+COMMIT TRANSACTION;+--> statement-breakpoint+PRAGMA foreign_keys=ON;+--> statement-breakpoint+BEGIN TRANSACTION;\ No newline at end of filediff --git a/packages/db/migrations/sqlite/meta/0029_snapshot.json b/packages/db/migrations/sqlite/meta/0029_snapshot.jsonnew file mode 100644index 000000000..6ebc6ce11--- /dev/null+++ b/packages/db/migrations/sqlite/meta/0029_snapshot.json@@ -0,0 +1,1932 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "b5807e12-890a-4aa3-aa72-7eadbe1b86da",+ "prevId": "10f541df-4585-4507-86d5-da7bd1e77de6",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "userId_idx": {+ "name": "userId_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "account_provider_provider_account_id_pk": {+ "columns": ["provider", "provider_account_id"],+ "name": "account_provider_provider_account_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "apiKey": {+ "name": "apiKey",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "api_key": {+ "name": "api_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "apiKey_user_id_user_id_fk": {+ "name": "apiKey_user_id_user_id_fk",+ "tableFrom": "apiKey",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "app": {+ "name": "app",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "href": {+ "name": "href",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ping_url": {+ "name": "ping_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "boardGroupPermission": {+ "name": "boardGroupPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardGroupPermission_board_id_board_id_fk": {+ "name": "boardGroupPermission_board_id_board_id_fk",+ "tableFrom": "boardGroupPermission",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "boardGroupPermission_group_id_group_id_fk": {+ "name": "boardGroupPermission_group_id_group_id_fk",+ "tableFrom": "boardGroupPermission",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "boardGroupPermission_board_id_group_id_permission_pk": {+ "columns": ["board_id", "group_id", "permission"],+ "name": "boardGroupPermission_board_id_group_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "boardUserPermission": {+ "name": "boardUserPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardUserPermission_board_id_board_id_fk": {+ "name": "boardUserPermission_board_id_board_id_fk",+ "tableFrom": "boardUserPermission",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "boardUserPermission_user_id_user_id_fk": {+ "name": "boardUserPermission_user_id_user_id_fk",+ "tableFrom": "boardUserPermission",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "boardUserPermission_board_id_user_id_permission_pk": {+ "columns": ["board_id", "user_id", "permission"],+ "name": "boardUserPermission_board_id_user_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "board": {+ "name": "board",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_public": {+ "name": "is_public",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "page_title": {+ "name": "page_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "meta_title": {+ "name": "meta_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "logo_image_url": {+ "name": "logo_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "favicon_image_url": {+ "name": "favicon_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_url": {+ "name": "background_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_attachment": {+ "name": "background_image_attachment",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'fixed'"+ },+ "background_image_repeat": {+ "name": "background_image_repeat",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'no-repeat'"+ },+ "background_image_size": {+ "name": "background_image_size",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'cover'"+ },+ "primary_color": {+ "name": "primary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#fa5252'"+ },+ "secondary_color": {+ "name": "secondary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#fd7e14'"+ },+ "opacity": {+ "name": "opacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 100+ },+ "custom_css": {+ "name": "custom_css",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_color": {+ "name": "icon_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "item_radius": {+ "name": "item_radius",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'lg'"+ },+ "disable_status": {+ "name": "disable_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "board_name_unique": {+ "name": "board_name_unique",+ "columns": ["name"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "board_creator_id_user_id_fk": {+ "name": "board_creator_id_user_id_fk",+ "tableFrom": "board",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "groupMember": {+ "name": "groupMember",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupMember_group_id_group_id_fk": {+ "name": "groupMember_group_id_group_id_fk",+ "tableFrom": "groupMember",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "groupMember_user_id_user_id_fk": {+ "name": "groupMember_user_id_user_id_fk",+ "tableFrom": "groupMember",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "groupMember_group_id_user_id_pk": {+ "columns": ["group_id", "user_id"],+ "name": "groupMember_group_id_user_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "groupPermission": {+ "name": "groupPermission",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupPermission_group_id_group_id_fk": {+ "name": "groupPermission_group_id_group_id_fk",+ "tableFrom": "groupPermission",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "group": {+ "name": "group",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "owner_id": {+ "name": "owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "group_name_unique": {+ "name": "group_name_unique",+ "columns": ["name"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "group_owner_id_user_id_fk": {+ "name": "group_owner_id_user_id_fk",+ "tableFrom": "group",+ "tableTo": "user",+ "columnsFrom": ["owner_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "group_home_board_id_board_id_fk": {+ "name": "group_home_board_id_board_id_fk",+ "tableFrom": "group",+ "tableTo": "board",+ "columnsFrom": ["home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "group_mobile_home_board_id_board_id_fk": {+ "name": "group_mobile_home_board_id_board_id_fk",+ "tableFrom": "group",+ "tableTo": "board",+ "columnsFrom": ["mobile_home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "iconRepository": {+ "name": "iconRepository",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "icon": {+ "name": "icon",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_repository_id": {+ "name": "icon_repository_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "icon_icon_repository_id_iconRepository_id_fk": {+ "name": "icon_icon_repository_id_iconRepository_id_fk",+ "tableFrom": "icon",+ "tableTo": "iconRepository",+ "columnsFrom": ["icon_repository_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationGroupPermissions": {+ "name": "integrationGroupPermissions",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationGroupPermissions_integration_id_integration_id_fk": {+ "name": "integrationGroupPermissions_integration_id_integration_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integrationGroupPermissions_group_id_group_id_fk": {+ "name": "integrationGroupPermissions_group_id_group_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "tableTo": "group",+ "columnsFrom": ["group_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integrationGroupPermissions_integration_id_group_id_permission_pk": {+ "columns": ["integration_id", "group_id", "permission"],+ "name": "integrationGroupPermissions_integration_id_group_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integration_item": {+ "name": "integration_item",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integration_item_item_id_item_id_fk": {+ "name": "integration_item_item_id_item_id_fk",+ "tableFrom": "integration_item",+ "tableTo": "item",+ "columnsFrom": ["item_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integration_item_integration_id_integration_id_fk": {+ "name": "integration_item_integration_id_integration_id_fk",+ "tableFrom": "integration_item",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integration_item_item_id_integration_id_pk": {+ "columns": ["item_id", "integration_id"],+ "name": "integration_item_item_id_integration_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationSecret": {+ "name": "integrationSecret",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration_secret__kind_idx": {+ "name": "integration_secret__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ },+ "integration_secret__updated_at_idx": {+ "name": "integration_secret__updated_at_idx",+ "columns": ["updated_at"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "integrationSecret_integration_id_integration_id_fk": {+ "name": "integrationSecret_integration_id_integration_id_fk",+ "tableFrom": "integrationSecret",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integrationSecret_integration_id_kind_pk": {+ "columns": ["integration_id", "kind"],+ "name": "integrationSecret_integration_id_kind_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationUserPermission": {+ "name": "integrationUserPermission",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationUserPermission_integration_id_integration_id_fk": {+ "name": "integrationUserPermission_integration_id_integration_id_fk",+ "tableFrom": "integrationUserPermission",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "integrationUserPermission_user_id_user_id_fk": {+ "name": "integrationUserPermission_user_id_user_id_fk",+ "tableFrom": "integrationUserPermission",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "integrationUserPermission_integration_id_user_id_permission_pk": {+ "columns": ["integration_id", "user_id", "permission"],+ "name": "integrationUserPermission_integration_id_user_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integration": {+ "name": "integration",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration__kind_idx": {+ "name": "integration__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "invite": {+ "name": "invite",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiration_date": {+ "name": "expiration_date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "invite_token_unique": {+ "name": "invite_token_unique",+ "columns": ["token"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "invite_creator_id_user_id_fk": {+ "name": "invite_creator_id_user_id_fk",+ "tableFrom": "invite",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "item_layout": {+ "name": "item_layout",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_layout_item_id_item_id_fk": {+ "name": "item_layout_item_id_item_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "item",+ "columnsFrom": ["item_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "item_layout_section_id_section_id_fk": {+ "name": "item_layout_section_id_section_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "item_layout_layout_id_layout_id_fk": {+ "name": "item_layout_layout_id_layout_id_fk",+ "tableFrom": "item_layout",+ "tableTo": "layout",+ "columnsFrom": ["layout_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "item_layout_item_id_section_id_layout_id_pk": {+ "columns": ["item_id", "section_id", "layout_id"],+ "name": "item_layout_item_id_section_id_layout_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "item": {+ "name": "item",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ },+ "advanced_options": {+ "name": "advanced_options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_board_id_board_id_fk": {+ "name": "item_board_id_board_id_fk",+ "tableFrom": "item",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "layout": {+ "name": "layout",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "column_count": {+ "name": "column_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "breakpoint": {+ "name": "breakpoint",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "layout_board_id_board_id_fk": {+ "name": "layout_board_id_board_id_fk",+ "tableFrom": "layout",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "media": {+ "name": "media",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "blob",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(unixepoch())"+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "media_creator_id_user_id_fk": {+ "name": "media_creator_id_user_id_fk",+ "tableFrom": "media",+ "tableTo": "user",+ "columnsFrom": ["creator_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "onboarding": {+ "name": "onboarding",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "step": {+ "name": "step",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "previous_step": {+ "name": "previous_step",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "search_engine": {+ "name": "search_engine",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "short": {+ "name": "short",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "url_template": {+ "name": "url_template",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'generic'"+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "search_engine_short_unique": {+ "name": "search_engine_short_unique",+ "columns": ["short"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "search_engine_integration_id_integration_id_fk": {+ "name": "search_engine_integration_id_integration_id_fk",+ "tableFrom": "search_engine",+ "tableTo": "integration",+ "columnsFrom": ["integration_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section_collapse_state": {+ "name": "section_collapse_state",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "collapsed": {+ "name": "collapsed",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_collapse_state_user_id_user_id_fk": {+ "name": "section_collapse_state_user_id_user_id_fk",+ "tableFrom": "section_collapse_state",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_collapse_state_section_id_section_id_fk": {+ "name": "section_collapse_state_section_id_section_id_fk",+ "tableFrom": "section_collapse_state",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "section_collapse_state_user_id_section_id_pk": {+ "columns": ["user_id", "section_id"],+ "name": "section_collapse_state_user_id_section_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section_layout": {+ "name": "section_layout",+ "columns": {+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "parent_section_id": {+ "name": "parent_section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_layout_section_id_section_id_fk": {+ "name": "section_layout_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "section",+ "columnsFrom": ["section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_layout_layout_id_layout_id_fk": {+ "name": "section_layout_layout_id_layout_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "layout",+ "columnsFrom": ["layout_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "section_layout_parent_section_id_section_id_fk": {+ "name": "section_layout_parent_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "tableTo": "section",+ "columnsFrom": ["parent_section_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "section_layout_section_id_layout_id_pk": {+ "columns": ["section_id", "layout_id"],+ "name": "section_layout_section_id_layout_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section": {+ "name": "section",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_board_id_board_id_fk": {+ "name": "section_board_id_board_id_fk",+ "tableFrom": "section",+ "tableTo": "board",+ "columnsFrom": ["board_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "serverSetting": {+ "name": "serverSetting",+ "columns": {+ "setting_key": {+ "name": "setting_key",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ }+ },+ "indexes": {+ "serverSetting_settingKey_unique": {+ "name": "serverSetting_settingKey_unique",+ "columns": ["setting_key"],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "session_token": {+ "name": "session_token",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": ["user_id"],+ "columnsTo": ["id"],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'credentials'"+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "default_search_engine_id": {+ "name": "default_search_engine_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "open_search_in_new_tab": {+ "name": "open_search_in_new_tab",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "color_scheme": {+ "name": "color_scheme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'dark'"+ },+ "first_day_of_week": {+ "name": "first_day_of_week",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "ping_icons_enabled": {+ "name": "ping_icons_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_home_board_id_board_id_fk": {+ "name": "user_home_board_id_board_id_fk",+ "tableFrom": "user",+ "tableTo": "board",+ "columnsFrom": ["home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_mobile_home_board_id_board_id_fk": {+ "name": "user_mobile_home_board_id_board_id_fk",+ "tableFrom": "user",+ "tableTo": "board",+ "columnsFrom": ["mobile_home_board_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "user_default_search_engine_id_search_engine_id_fk": {+ "name": "user_default_search_engine_id_search_engine_id_fk",+ "tableFrom": "user",+ "tableTo": "search_engine",+ "columnsFrom": ["default_search_engine_id"],+ "columnsTo": ["id"],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "verificationToken": {+ "name": "verificationToken",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verificationToken_identifier_token_pk": {+ "columns": ["identifier", "token"],+ "name": "verificationToken_identifier_token_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}diff --git a/packages/db/migrations/sqlite/meta/0030_snapshot.json b/packages/db/migrations/sqlite/meta/0030_snapshot.jsonnew file mode 100644index 000000000..610dfae2f--- /dev/null+++ b/packages/db/migrations/sqlite/meta/0030_snapshot.json@@ -0,0 +1,1932 @@+{+ "id": "49edf955-6b9c-4cf2-aa99-f6c1aa6309b4",+ "prevId": "b5807e12-890a-4aa3-aa72-7eadbe1b86da",+ "version": "6",+ "dialect": "sqlite",+ "tables": {+ "account": {+ "name": "account",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "provider_account_id": {+ "name": "provider_account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "token_type": {+ "name": "token_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "session_state": {+ "name": "session_state",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "userId_idx": {+ "name": "userId_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "account_provider_provider_account_id_pk": {+ "columns": ["provider", "provider_account_id"],+ "name": "account_provider_provider_account_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "apiKey": {+ "name": "apiKey",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "api_key": {+ "name": "api_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "apiKey_user_id_user_id_fk": {+ "name": "apiKey_user_id_user_id_fk",+ "tableFrom": "apiKey",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "app": {+ "name": "app",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "href": {+ "name": "href",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ping_url": {+ "name": "ping_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "boardGroupPermission": {+ "name": "boardGroupPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardGroupPermission_board_id_board_id_fk": {+ "name": "boardGroupPermission_board_id_board_id_fk",+ "tableFrom": "boardGroupPermission",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "boardGroupPermission_group_id_group_id_fk": {+ "name": "boardGroupPermission_group_id_group_id_fk",+ "tableFrom": "boardGroupPermission",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "boardGroupPermission_board_id_group_id_permission_pk": {+ "columns": ["board_id", "group_id", "permission"],+ "name": "boardGroupPermission_board_id_group_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "boardUserPermission": {+ "name": "boardUserPermission",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "boardUserPermission_board_id_board_id_fk": {+ "name": "boardUserPermission_board_id_board_id_fk",+ "tableFrom": "boardUserPermission",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "boardUserPermission_user_id_user_id_fk": {+ "name": "boardUserPermission_user_id_user_id_fk",+ "tableFrom": "boardUserPermission",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "boardUserPermission_board_id_user_id_permission_pk": {+ "columns": ["board_id", "user_id", "permission"],+ "name": "boardUserPermission_board_id_user_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "board": {+ "name": "board",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_public": {+ "name": "is_public",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "page_title": {+ "name": "page_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "meta_title": {+ "name": "meta_title",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "logo_image_url": {+ "name": "logo_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "favicon_image_url": {+ "name": "favicon_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_url": {+ "name": "background_image_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "background_image_attachment": {+ "name": "background_image_attachment",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'fixed'"+ },+ "background_image_repeat": {+ "name": "background_image_repeat",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'no-repeat'"+ },+ "background_image_size": {+ "name": "background_image_size",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'cover'"+ },+ "primary_color": {+ "name": "primary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#fa5252'"+ },+ "secondary_color": {+ "name": "secondary_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#fd7e14'"+ },+ "opacity": {+ "name": "opacity",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 100+ },+ "custom_css": {+ "name": "custom_css",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "icon_color": {+ "name": "icon_color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "item_radius": {+ "name": "item_radius",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'lg'"+ },+ "disable_status": {+ "name": "disable_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {+ "board_name_unique": {+ "name": "board_name_unique",+ "columns": ["name"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "board_creator_id_user_id_fk": {+ "name": "board_creator_id_user_id_fk",+ "tableFrom": "board",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "groupMember": {+ "name": "groupMember",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupMember_group_id_group_id_fk": {+ "name": "groupMember_group_id_group_id_fk",+ "tableFrom": "groupMember",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "groupMember_user_id_user_id_fk": {+ "name": "groupMember_user_id_user_id_fk",+ "tableFrom": "groupMember",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "groupMember_group_id_user_id_pk": {+ "columns": ["group_id", "user_id"],+ "name": "groupMember_group_id_user_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "groupPermission": {+ "name": "groupPermission",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "groupPermission_group_id_group_id_fk": {+ "name": "groupPermission_group_id_group_id_fk",+ "tableFrom": "groupPermission",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "group": {+ "name": "group",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "owner_id": {+ "name": "owner_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "group_name_unique": {+ "name": "group_name_unique",+ "columns": ["name"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "group_owner_id_user_id_fk": {+ "name": "group_owner_id_user_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["owner_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "group_home_board_id_board_id_fk": {+ "name": "group_home_board_id_board_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "group_mobile_home_board_id_board_id_fk": {+ "name": "group_mobile_home_board_id_board_id_fk",+ "tableFrom": "group",+ "columnsFrom": ["mobile_home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "iconRepository": {+ "name": "iconRepository",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "icon": {+ "name": "icon",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "checksum": {+ "name": "checksum",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "icon_repository_id": {+ "name": "icon_repository_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "icon_icon_repository_id_iconRepository_id_fk": {+ "name": "icon_icon_repository_id_iconRepository_id_fk",+ "tableFrom": "icon",+ "columnsFrom": ["icon_repository_id"],+ "tableTo": "iconRepository",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationGroupPermissions": {+ "name": "integrationGroupPermissions",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationGroupPermissions_integration_id_integration_id_fk": {+ "name": "integrationGroupPermissions_integration_id_integration_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integrationGroupPermissions_group_id_group_id_fk": {+ "name": "integrationGroupPermissions_group_id_group_id_fk",+ "tableFrom": "integrationGroupPermissions",+ "columnsFrom": ["group_id"],+ "tableTo": "group",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integrationGroupPermissions_integration_id_group_id_permission_pk": {+ "columns": ["integration_id", "group_id", "permission"],+ "name": "integrationGroupPermissions_integration_id_group_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integration_item": {+ "name": "integration_item",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integration_item_item_id_item_id_fk": {+ "name": "integration_item_item_id_item_id_fk",+ "tableFrom": "integration_item",+ "columnsFrom": ["item_id"],+ "tableTo": "item",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integration_item_integration_id_integration_id_fk": {+ "name": "integration_item_integration_id_integration_id_fk",+ "tableFrom": "integration_item",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integration_item_item_id_integration_id_pk": {+ "columns": ["item_id", "integration_id"],+ "name": "integration_item_item_id_integration_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationSecret": {+ "name": "integrationSecret",+ "columns": {+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration_secret__kind_idx": {+ "name": "integration_secret__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ },+ "integration_secret__updated_at_idx": {+ "name": "integration_secret__updated_at_idx",+ "columns": ["updated_at"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "integrationSecret_integration_id_integration_id_fk": {+ "name": "integrationSecret_integration_id_integration_id_fk",+ "tableFrom": "integrationSecret",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integrationSecret_integration_id_kind_pk": {+ "columns": ["integration_id", "kind"],+ "name": "integrationSecret_integration_id_kind_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integrationUserPermission": {+ "name": "integrationUserPermission",+ "columns": {+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "permission": {+ "name": "permission",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "integrationUserPermission_integration_id_integration_id_fk": {+ "name": "integrationUserPermission_integration_id_integration_id_fk",+ "tableFrom": "integrationUserPermission",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "integrationUserPermission_user_id_user_id_fk": {+ "name": "integrationUserPermission_user_id_user_id_fk",+ "tableFrom": "integrationUserPermission",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "integrationUserPermission_integration_id_user_id_permission_pk": {+ "columns": ["integration_id", "user_id", "permission"],+ "name": "integrationUserPermission_integration_id_user_id_permission_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "integration": {+ "name": "integration",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "integration__kind_idx": {+ "name": "integration__kind_idx",+ "columns": ["kind"],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "invite": {+ "name": "invite",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expiration_date": {+ "name": "expiration_date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "invite_token_unique": {+ "name": "invite_token_unique",+ "columns": ["token"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "invite_creator_id_user_id_fk": {+ "name": "invite_creator_id_user_id_fk",+ "tableFrom": "invite",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "item_layout": {+ "name": "item_layout",+ "columns": {+ "item_id": {+ "name": "item_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_layout_item_id_item_id_fk": {+ "name": "item_layout_item_id_item_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["item_id"],+ "tableTo": "item",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "item_layout_section_id_section_id_fk": {+ "name": "item_layout_section_id_section_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "item_layout_layout_id_layout_id_fk": {+ "name": "item_layout_layout_id_layout_id_fk",+ "tableFrom": "item_layout",+ "columnsFrom": ["layout_id"],+ "tableTo": "layout",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "item_layout_item_id_section_id_layout_id_pk": {+ "columns": ["item_id", "section_id", "layout_id"],+ "name": "item_layout_item_id_section_id_layout_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "item": {+ "name": "item",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "options": {+ "name": "options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ },+ "advanced_options": {+ "name": "advanced_options",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "item_board_id_board_id_fk": {+ "name": "item_board_id_board_id_fk",+ "tableFrom": "item",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "layout": {+ "name": "layout",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "column_count": {+ "name": "column_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "breakpoint": {+ "name": "breakpoint",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "layout_board_id_board_id_fk": {+ "name": "layout_board_id_board_id_fk",+ "tableFrom": "layout",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "media": {+ "name": "media",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "blob",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "size": {+ "name": "size",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "(unixepoch())"+ },+ "creator_id": {+ "name": "creator_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "media_creator_id_user_id_fk": {+ "name": "media_creator_id_user_id_fk",+ "tableFrom": "media",+ "columnsFrom": ["creator_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "onboarding": {+ "name": "onboarding",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "step": {+ "name": "step",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "previous_step": {+ "name": "previous_step",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "search_engine": {+ "name": "search_engine",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "icon_url": {+ "name": "icon_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "short": {+ "name": "short",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "url_template": {+ "name": "url_template",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'generic'"+ },+ "integration_id": {+ "name": "integration_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "search_engine_short_unique": {+ "name": "search_engine_short_unique",+ "columns": ["short"],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "search_engine_integration_id_integration_id_fk": {+ "name": "search_engine_integration_id_integration_id_fk",+ "tableFrom": "search_engine",+ "columnsFrom": ["integration_id"],+ "tableTo": "integration",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section_collapse_state": {+ "name": "section_collapse_state",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "collapsed": {+ "name": "collapsed",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_collapse_state_user_id_user_id_fk": {+ "name": "section_collapse_state_user_id_user_id_fk",+ "tableFrom": "section_collapse_state",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_collapse_state_section_id_section_id_fk": {+ "name": "section_collapse_state_section_id_section_id_fk",+ "tableFrom": "section_collapse_state",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "section_collapse_state_user_id_section_id_pk": {+ "columns": ["user_id", "section_id"],+ "name": "section_collapse_state_user_id_section_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section_layout": {+ "name": "section_layout",+ "columns": {+ "section_id": {+ "name": "section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "layout_id": {+ "name": "layout_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "parent_section_id": {+ "name": "parent_section_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "width": {+ "name": "width",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "height": {+ "name": "height",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_layout_section_id_section_id_fk": {+ "name": "section_layout_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_layout_layout_id_layout_id_fk": {+ "name": "section_layout_layout_id_layout_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["layout_id"],+ "tableTo": "layout",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ },+ "section_layout_parent_section_id_section_id_fk": {+ "name": "section_layout_parent_section_id_section_id_fk",+ "tableFrom": "section_layout",+ "columnsFrom": ["parent_section_id"],+ "tableTo": "section",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {+ "section_layout_section_id_layout_id_pk": {+ "columns": ["section_id", "layout_id"],+ "name": "section_layout_section_id_layout_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "section": {+ "name": "section",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "board_id": {+ "name": "board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "x_offset": {+ "name": "x_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "y_offset": {+ "name": "y_offset",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "section_board_id_board_id_fk": {+ "name": "section_board_id_board_id_fk",+ "tableFrom": "section",+ "columnsFrom": ["board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "serverSetting": {+ "name": "serverSetting",+ "columns": {+ "setting_key": {+ "name": "setting_key",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"json\": {}}'"+ }+ },+ "indexes": {+ "serverSetting_settingKey_unique": {+ "name": "serverSetting_settingKey_unique",+ "columns": ["setting_key"],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "session": {+ "name": "session",+ "columns": {+ "session_token": {+ "name": "session_token",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "user_id_idx": {+ "name": "user_id_idx",+ "columns": ["user_id"],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "columnsFrom": ["user_id"],+ "tableTo": "user",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "cascade"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "user": {+ "name": "user",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "email_verified": {+ "name": "email_verified",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "salt": {+ "name": "salt",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'credentials'"+ },+ "home_board_id": {+ "name": "home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mobile_home_board_id": {+ "name": "mobile_home_board_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "default_search_engine_id": {+ "name": "default_search_engine_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "open_search_in_new_tab": {+ "name": "open_search_in_new_tab",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "color_scheme": {+ "name": "color_scheme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'dark'"+ },+ "first_day_of_week": {+ "name": "first_day_of_week",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "ping_icons_enabled": {+ "name": "ping_icons_enabled",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_home_board_id_board_id_fk": {+ "name": "user_home_board_id_board_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "user_mobile_home_board_id_board_id_fk": {+ "name": "user_mobile_home_board_id_board_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["mobile_home_board_id"],+ "tableTo": "board",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ },+ "user_default_search_engine_id_search_engine_id_fk": {+ "name": "user_default_search_engine_id_search_engine_id_fk",+ "tableFrom": "user",+ "columnsFrom": ["default_search_engine_id"],+ "tableTo": "search_engine",+ "columnsTo": ["id"],+ "onUpdate": "no action",+ "onDelete": "set null"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "verificationToken": {+ "name": "verificationToken",+ "columns": {+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires": {+ "name": "expires",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "verificationToken_identifier_token_pk": {+ "columns": ["identifier", "token"],+ "name": "verificationToken_identifier_token_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ },+ "internal": {+ "indexes": {}+ }+}diff --git a/packages/db/migrations/sqlite/meta/_journal.json b/packages/db/migrations/sqlite/meta/_journal.jsonindex c39f7a9e0..d89c196ff 100644--- a/packages/db/migrations/sqlite/meta/_journal.json+++ b/packages/db/migrations/sqlite/meta/_journal.json@@ -204,6 +204,20 @@"when": 1740086746417,"tag": "0028_add_app_ping_url","breakpoints": true+ },+ {+ "idx": 29,+ "version": "6",+ "when": 1740255687392,+ "tag": "0029_add_layouts",+ "breakpoints": true+ },+ {+ "idx": 30,+ "version": "6",+ "when": 1740255968549,+ "tag": "0030_migrate_item_and_section_for_layouts",+ "breakpoints": true}]}diff --git a/packages/db/package.json b/packages/db/package.jsonindex f9bcc0aba..cf5f20fcc 100644--- a/packages/db/package.json+++ b/packages/db/package.json@@ -7,6 +7,7 @@"exports": {".": "./index.ts","./client": "./client.ts",+ "./collection": "./collection.ts","./schema": "./schema/index.ts","./test": "./test/index.ts","./queries": "./queries/index.ts",diff --git a/packages/db/schema/index.ts b/packages/db/schema/index.tsindex 51b5025ea..f9bcd4e53 100644--- a/packages/db/schema/index.ts+++ b/packages/db/schema/index.ts@@ -36,6 +36,9 @@ export const {users,verificationTokens,sectionCollapseStates,+ layouts,+ itemLayouts,+ sectionLayouts,} = schema;export type User = InferSelectModel<typeof schema.users>;diff --git a/packages/db/schema/mysql.ts b/packages/db/schema/mysql.tsindex 9592dec12..885faae29 100644--- a/packages/db/schema/mysql.ts+++ b/packages/db/schema/mysql.ts@@ -280,7 +280,6 @@ export const boards = mysqlTable("board", {secondaryColor: text().default("#fd7e14").notNull(),opacity: int().default(100).notNull(),customCss: text(),- columnCount: int().default(10).notNull(),iconColor: text(),itemRadius: text().$type<MantineSize>().default("lg").notNull(),disableStatus: boolean().default(false).notNull(),@@ -322,20 +321,73 @@ export const boardGroupPermissions = mysqlTable(}),);+export const layouts = mysqlTable("layout", {+ id: varchar({ length: 64 }).notNull().primaryKey(),+ name: varchar({ length: 32 }).notNull(),+ boardId: varchar({ length: 64 })+ .notNull()+ .references(() => boards.id, { onDelete: "cascade" }),+ columnCount: tinyint().notNull(),+ breakpoint: smallint().notNull().default(0),+});++export const itemLayouts = mysqlTable(+ "item_layout",+ {+ itemId: varchar({ length: 64 })+ .notNull()+ .references(() => items.id, { onDelete: "cascade" }),+ sectionId: varchar({ length: 64 })+ .notNull()+ .references(() => sections.id, { onDelete: "cascade" }),+ layoutId: varchar({ length: 64 })+ .notNull()+ .references(() => layouts.id, { onDelete: "cascade" }),+ xOffset: int().notNull(),+ yOffset: int().notNull(),+ width: int().notNull(),+ height: int().notNull(),+ },+ (table) => ({+ compoundKey: primaryKey({+ columns: [table.itemId, table.sectionId, table.layoutId],+ }),+ }),+);++export const sectionLayouts = mysqlTable(+ "section_layout",+ {+ sectionId: varchar({ length: 64 })+ .notNull()+ .references(() => sections.id, { onDelete: "cascade" }),+ layoutId: varchar({ length: 64 })+ .notNull()+ .references(() => layouts.id, { onDelete: "cascade" }),+ parentSectionId: varchar({ length: 64 }).references((): AnyMySqlColumn => sections.id, {+ onDelete: "cascade",+ }),+ xOffset: int().notNull(),+ yOffset: int().notNull(),+ width: int().notNull(),+ height: int().notNull(),+ },+ (table) => ({+ compoundKey: primaryKey({+ columns: [table.sectionId, table.layoutId],+ }),+ }),+);+export const sections = mysqlTable("section", {id: varchar({ length: 64 }).notNull().primaryKey(),boardId: varchar({ length: 64 }).notNull().references(() => boards.id, { onDelete: "cascade" }),kind: text().$type<SectionKind>().notNull(),- xOffset: int().notNull(),- yOffset: int().notNull(),- width: int(),- height: int(),+ xOffset: int(),+ yOffset: int(),name: text(),- parentSectionId: varchar({ length: 64 }).references((): AnyMySqlColumn => sections.id, {- onDelete: "cascade",- }),});export const sectionCollapseStates = mysqlTable(@@ -358,14 +410,10 @@ export const sectionCollapseStates = mysqlTable(export const items = mysqlTable("item", {id: varchar({ length: 64 }).notNull().primaryKey(),- sectionId: varchar({ length: 64 })+ boardId: varchar({ length: 64 }).notNull()- .references(() => sections.id, { onDelete: "cascade" }),+ .references(() => boards.id, { onDelete: "cascade" }),kind: text().$type<WidgetKind>().notNull(),- xOffset: int().notNull(),- yOffset: int().notNull(),- width: int().notNull(),- height: int().notNull(),options: text().default('{"json": {}}').notNull(), // empty superjson objectadvancedOptions: text().default('{"json": {}}').notNull(), // empty superjson object});@@ -590,12 +638,14 @@ export const integrationSecretRelations = relations(integrationSecrets, ({ one }export const boardRelations = relations(boards, ({ many, one }) => ({sections: many(sections),+ items: many(items),creator: one(users, {fields: [boards.creatorId],references: [users.id],}),userPermissions: many(boardUserPermissions),groupPermissions: many(boardGroupPermissions),+ layouts: many(layouts),groupHomes: many(groups, {relationName: "groupRelations__board__homeBoardId",}),@@ -605,12 +655,17 @@ export const boardRelations = relations(boards, ({ many, one }) => ({}));export const sectionRelations = relations(sections, ({ many, one }) => ({- items: many(items),board: one(boards, {fields: [sections.boardId],references: [boards.id],}),collapseStates: many(sectionCollapseStates),+ layouts: many(sectionLayouts, {+ relationName: "sectionLayoutRelations__section__sectionId",+ }),+ children: many(sectionLayouts, {+ relationName: "sectionLayoutRelations__section__parentSectionId",+ }),}));export const sectionCollapseStateRelations = relations(sectionCollapseStates, ({ one }) => ({@@ -625,11 +680,12 @@ export const sectionCollapseStateRelations = relations(sectionCollapseStates, ({}));export const itemRelations = relations(items, ({ one, many }) => ({- section: one(sections, {- fields: [items.sectionId],- references: [sections.id],- }),integrations: many(integrationItems),+ layouts: many(itemLayouts),+ board: one(boards, {+ fields: [items.boardId],+ references: [boards.id],+ }),}));export const integrationItemRelations = relations(integrationItems, ({ one }) => ({@@ -650,3 +706,44 @@ export const searchEngineRelations = relations(searchEngines, ({ one, many }) =>}),usersWithDefault: many(users),}));++export const itemLayoutRelations = relations(itemLayouts, ({ one }) => ({+ item: one(items, {+ fields: [itemLayouts.itemId],+ references: [items.id],+ }),+ section: one(sections, {+ fields: [itemLayouts.sectionId],+ references: [sections.id],+ }),+ layout: one(layouts, {+ fields: [itemLayouts.layoutId],+ references: [layouts.id],+ }),+}));++export const sectionLayoutRelations = relations(sectionLayouts, ({ one }) => ({+ section: one(sections, {+ fields: [sectionLayouts.sectionId],+ references: [sections.id],+ relationName: "sectionLayoutRelations__section__sectionId",+ }),+ layout: one(layouts, {+ fields: [sectionLayouts.layoutId],+ references: [layouts.id],+ }),+ parentSection: one(sections, {+ fields: [sectionLayouts.parentSectionId],+ references: [sections.id],+ relationName: "sectionLayoutRelations__section__parentSectionId",+ }),+}));++export const layoutRelations = relations(layouts, ({ one, many }) => ({+ items: many(itemLayouts),+ sections: many(sectionLayouts),+ board: one(boards, {+ fields: [layouts.boardId],+ references: [boards.id],+ }),+}));diff --git a/packages/db/schema/sqlite.ts b/packages/db/schema/sqlite.tsindex 2635744ba..2d5a4a8e3 100644--- a/packages/db/schema/sqlite.ts+++ b/packages/db/schema/sqlite.ts@@ -265,7 +265,6 @@ export const boards = sqliteTable("board", {secondaryColor: text().default("#fd7e14").notNull(),opacity: int().default(100).notNull(),customCss: text(),- columnCount: int().default(10).notNull(),iconColor: text(),itemRadius: text().$type<MantineSize>().default("lg").notNull(),disableStatus: int({ mode: "boolean" }).default(false).notNull(),@@ -307,20 +306,73 @@ export const boardGroupPermissions = sqliteTable(}),);+export const layouts = sqliteTable("layout", {+ id: text().notNull().primaryKey(),+ name: text().notNull(),+ boardId: text()+ .notNull()+ .references(() => boards.id, { onDelete: "cascade" }),+ columnCount: int().notNull(),+ breakpoint: int().notNull().default(0),+});++export const itemLayouts = sqliteTable(+ "item_layout",+ {+ itemId: text()+ .notNull()+ .references(() => items.id, { onDelete: "cascade" }),+ sectionId: text()+ .notNull()+ .references(() => sections.id, { onDelete: "cascade" }),+ layoutId: text()+ .notNull()+ .references(() => layouts.id, { onDelete: "cascade" }),+ xOffset: int().notNull(),+ yOffset: int().notNull(),+ width: int().notNull(),+ height: int().notNull(),+ },+ (table) => ({+ compoundKey: primaryKey({+ columns: [table.itemId, table.sectionId, table.layoutId],+ }),+ }),+);++export const sectionLayouts = sqliteTable(+ "section_layout",+ {+ sectionId: text()+ .notNull()+ .references(() => sections.id, { onDelete: "cascade" }),+ layoutId: text()+ .notNull()+ .references(() => layouts.id, { onDelete: "cascade" }),+ parentSectionId: text().references((): AnySQLiteColumn => sections.id, {+ onDelete: "cascade",+ }),+ xOffset: int().notNull(),+ yOffset: int().notNull(),+ width: int().notNull(),+ height: int().notNull(),+ },+ (table) => ({+ compoundKey: primaryKey({+ columns: [table.sectionId, table.layoutId],+ }),+ }),+);+export const sections = sqliteTable("section", {id: text().notNull().primaryKey(),boardId: text().notNull().references(() => boards.id, { onDelete: "cascade" }),kind: text().$type<SectionKind>().notNull(),- xOffset: int().notNull(),- yOffset: int().notNull(),- width: int(),- height: int(),+ xOffset: int(),+ yOffset: int(),name: text(),- parentSectionId: text().references((): AnySQLiteColumn => sections.id, {- onDelete: "cascade",- }),});export const sectionCollapseStates = sqliteTable(@@ -343,14 +395,10 @@ export const sectionCollapseStates = sqliteTable(export const items = sqliteTable("item", {id: text().notNull().primaryKey(),- sectionId: text()+ boardId: text().notNull()- .references(() => sections.id, { onDelete: "cascade" }),+ .references(() => boards.id, { onDelete: "cascade" }),kind: text().$type<WidgetKind>().notNull(),- xOffset: int().notNull(),- yOffset: int().notNull(),- width: int().notNull(),- height: int().notNull(),options: text().default('{"json": {}}').notNull(), // empty superjson objectadvancedOptions: text().default('{"json": {}}').notNull(), // empty superjson object});@@ -576,12 +624,14 @@ export const integrationSecretRelations = relations(integrationSecrets, ({ one }export const boardRelations = relations(boards, ({ many, one }) => ({sections: many(sections),+ items: many(items),creator: one(users, {fields: [boards.creatorId],references: [users.id],}),userPermissions: many(boardUserPermissions),groupPermissions: many(boardGroupPermissions),+ layouts: many(layouts),groupHomes: many(groups, {relationName: "groupRelations__board__homeBoardId",}),@@ -591,12 +641,17 @@ export const boardRelations = relations(boards, ({ many, one }) => ({}));export const sectionRelations = relations(sections, ({ many, one }) => ({- items: many(items),board: one(boards, {fields: [sections.boardId],references: [boards.id],}),collapseStates: many(sectionCollapseStates),+ layouts: many(sectionLayouts, {+ relationName: "sectionLayoutRelations__section__sectionId",+ }),+ children: many(sectionLayouts, {+ relationName: "sectionLayoutRelations__section__parentSectionId",+ }),}));export const sectionCollapseStateRelations = relations(sectionCollapseStates, ({ one }) => ({@@ -611,11 +666,12 @@ export const sectionCollapseStateRelations = relations(sectionCollapseStates, ({}));export const itemRelations = relations(items, ({ one, many }) => ({- section: one(sections, {- fields: [items.sectionId],- references: [sections.id],- }),integrations: many(integrationItems),+ layouts: many(itemLayouts),+ board: one(boards, {+ fields: [items.boardId],+ references: [boards.id],+ }),}));export const integrationItemRelations = relations(integrationItems, ({ one }) => ({@@ -636,3 +692,44 @@ export const searchEngineRelations = relations(searchEngines, ({ one, many }) =>}),usersWithDefault: many(users),}));++export const itemLayoutRelations = relations(itemLayouts, ({ one }) => ({+ item: one(items, {+ fields: [itemLayouts.itemId],+ references: [items.id],+ }),+ section: one(sections, {+ fields: [itemLayouts.sectionId],+ references: [sections.id],+ }),+ layout: one(layouts, {+ fields: [itemLayouts.layoutId],+ references: [layouts.id],+ }),+}));++export const sectionLayoutRelations = relations(sectionLayouts, ({ one }) => ({+ section: one(sections, {+ fields: [sectionLayouts.sectionId],+ references: [sections.id],+ relationName: "sectionLayoutRelations__section__sectionId",+ }),+ layout: one(layouts, {+ fields: [sectionLayouts.layoutId],+ references: [layouts.id],+ }),+ parentSection: one(sections, {+ fields: [sectionLayouts.parentSectionId],+ references: [sections.id],+ relationName: "sectionLayoutRelations__section__parentSectionId",+ }),+}));++export const layoutRelations = relations(layouts, ({ one, many }) => ({+ items: many(itemLayouts),+ sections: many(sectionLayouts),+ board: one(boards, {+ fields: [layouts.boardId],+ references: [boards.id],+ }),+}));diff --git a/packages/modals-collection/src/boards/import-board-modal.tsx b/packages/modals-collection/src/boards/import-board-modal.tsxindex 71fdbcb26..ba3f8060a 100644--- a/packages/modals-collection/src/boards/import-board-modal.tsx+++ b/packages/modals-collection/src/boards/import-board-modal.tsx@@ -1,5 +1,5 @@import { useState } from "react";-import { Button, FileInput, Group, Radio, Stack, TextInput } from "@mantine/core";+import { Button, FileInput, Group, Stack, TextInput } from "@mantine/core";import { IconFileUpload } from "@tabler/icons-react";import { z } from "zod";@@ -12,13 +12,12 @@ import { OldmarrImportAppsSettings, SidebarBehaviourSelect } from "@homarr/old-iimport type { OldmarrImportConfiguration } from "@homarr/old-import/shared";import { oldmarrImportConfigurationSchema, superRefineJsonImportFile } from "@homarr/old-import/shared";import { oldmarrConfigSchema } from "@homarr/old-schema";-import { useI18n, useScopedI18n } from "@homarr/translation/client";+import { useScopedI18n } from "@homarr/translation/client";import { useBoardNameStatus } from "./add-board-modal";export const ImportBoardModal = createModal(({ actions }) => {const tOldImport = useScopedI18n("board.action.oldImport");- const t = useI18n();const tCommon = useScopedI18n("common");const [fileValid, setFileValid] = useState(true);const form = useZodForm(@@ -33,7 +32,6 @@ export const ImportBoardModal = createModal(({ actions }) => {file: null!,configuration: {onlyImportApps: false,- screenSize: "lg",sidebarBehaviour: "last-section",name: "",},@@ -136,19 +134,6 @@ export const ImportBoardModal = createModal(({ actions }) => {{...form.getInputProps("configuration.name")}/>- <Radio.Group- withAsterisk- label={tOldImport("form.screenSize.label")}- description={t("board.action.oldImport.form.screenSize.description")}- {...form.getInputProps("configuration.screenSize")}- >- <Group mt="xs">- <Radio value="sm" label={t("board.action.oldImport.form.screenSize.option.sm")} />- <Radio value="md" label={t("board.action.oldImport.form.screenSize.option.md")} />- <Radio value="lg" label={t("board.action.oldImport.form.screenSize.option.lg")} />- </Group>- </Radio.Group>-<SidebarBehaviourSelect {...form.getInputProps("configuration.sidebarBehaviour")} /><Group justify="end">diff --git a/packages/old-import/src/analyse/analyse-oldmarr-import.ts b/packages/old-import/src/analyse/analyse-oldmarr-import.tsindex 0dc21ec82..1edaf11f1 100644--- a/packages/old-import/src/analyse/analyse-oldmarr-import.ts+++ b/packages/old-import/src/analyse/analyse-oldmarr-import.ts@@ -29,7 +29,7 @@ export const analyseOldmarrImportAsync = async (file: File) => {}return {- name: entry.name,+ name: entry.name.replace(".json", ""),config: result.data ?? null,isError: !result.success,};diff --git a/packages/old-import/src/components/initial-oldmarr-import.tsx b/packages/old-import/src/components/initial-oldmarr-import.tsxindex 58eba33f6..a87a8f651 100644--- a/packages/old-import/src/components/initial-oldmarr-import.tsx+++ b/packages/old-import/src/components/initial-oldmarr-import.tsx@@ -4,7 +4,6 @@ import SuperJSON from "superjson";import { revalidatePathActionAsync } from "@homarr/common/client";import { useModalAction } from "@homarr/modals";-import { boardSizes } from "@homarr/old-schema";// We don't have access to the API client here, so we need to import it from the API package// In the future we should consider having the used router also in this package@@ -13,7 +12,6 @@ import type { AnalyseResult } from "../analyse/analyse-oldmarr-import";import { prepareMultipleImports } from "../prepare/prepare-multiple";import type { InitialOldmarrImportSettings } from "../settings";import { defaultSidebarBehaviour } from "../settings";-import type { BoardSelectionMap, BoardSizeRecord } from "./initial/board-selection-card";import { BoardSelectionCard } from "./initial/board-selection-card";import { ImportSettingsCard } from "./initial/import-settings-card";import { ImportSummaryCard } from "./initial/import-summary-card";@@ -25,8 +23,8 @@ interface InitialOldmarrImportProps {}export const InitialOldmarrImport = ({ file, analyseResult }: InitialOldmarrImportProps) => {- const [boardSelections, setBoardSelections] = useState<BoardSelectionMap>(- new Map(createDefaultSelections(analyseResult.configs)),+ const [boardSelections, setBoardSelections] = useState<Map<string, boolean>>(+ new Map(analyseResult.configs.filter(({ config }) => config !== null).map(({ name }) => [name, true])),);const [settings, setSettings] = useState<InitialOldmarrImportSettings>({onlyImportApps: false,@@ -94,19 +92,3 @@ export const InitialOldmarrImport = ({ file, analyseResult }: InitialOldmarrImpo</Stack>);};--const createDefaultSelections = (configs: AnalyseResult["configs"]) => {- return configs- .map(({ name, config }) => {- if (!config) return null;-- const shapes = config.apps.flatMap((app) => app.shape).concat(config.widgets.flatMap((widget) => widget.shape));- const boardSizeRecord = boardSizes.reduce<BoardSizeRecord>((acc, size) => {- const allInclude = shapes.every((shape) => Boolean(shape[size]));- acc[size] = allInclude ? true : null;- return acc;- }, {} as BoardSizeRecord);- return [name, boardSizeRecord];- })- .filter((selection): selection is [string, BoardSizeRecord] => Boolean(selection));-};diff --git a/packages/old-import/src/components/initial/board-selection-card.tsx b/packages/old-import/src/components/initial/board-selection-card.tsxindex 485b0a8ec..475d65a08 100644--- a/packages/old-import/src/components/initial/board-selection-card.tsx+++ b/packages/old-import/src/components/initial/board-selection-card.tsx@@ -1,14 +1,9 @@import type { ChangeEvent } from "react";import { Anchor, Card, Checkbox, Group, Stack, Text } from "@mantine/core";-import { objectEntries, objectKeys } from "@homarr/common";-import { boardSizes } from "@homarr/old-schema";import { useI18n, useScopedI18n } from "@homarr/translation/client";-type BoardSize = (typeof boardSizes)[number];--export type BoardSizeRecord = Record<BoardSize, boolean | null>;-export type BoardSelectionMap = Map<string, BoardSizeRecord>;+export type BoardSelectionMap = Map<string, boolean>;interface BoardSelectionCardProps {selections: BoardSelectionMap;@@ -16,12 +11,9 @@ interface BoardSelectionCardProps {}const allChecked = (map: BoardSelectionMap) => {- return [...map.values()].every((selection) => groupChecked(selection));+ return [...map.values()].every((selection) => selection);};-const groupChecked = (selection: BoardSizeRecord) =>- objectEntries(selection).every(([_, value]) => value === true || value === null);-export const BoardSelectionCard = ({ selections, updateSelections }: BoardSelectionCardProps) => {const tBoardSelection = useScopedI18n("init.step.import.boardSelection");const t = useI18n();@@ -29,50 +21,14 @@ export const BoardSelectionCard = ({ selections, updateSelections }: BoardSelectconst handleToggleAll = () => {updateSelections((selections) => {- const updated = new Map(selections);-- [...selections.entries()].forEach(([name, selection]) => {- objectKeys(selection).forEach((size) => {- if (selection[size] === null) return;- selection[size] = !areAllChecked;- });-- updated.set(name, selection);- });-- return updated;+ return new Map([...selections.keys()].map((name) => [name, !areAllChecked] as const));});};- const registerToggleGroup = (name: string) => (event: ChangeEvent<HTMLInputElement>) => {+ const registerToggle = (name: string) => (event: ChangeEvent<HTMLInputElement>) => {updateSelections((selections) => {const updated = new Map(selections);- const selection = selections.get(name);-- if (!selection) return updated;-- objectKeys(selection).forEach((size) => {- if (selection[size] === null) return;- selection[size] = event.target.checked;- });-- updated.set(name, selection);-- return updated;- });- };-- const registerToggle = (name: string, size: BoardSize) => (event: ChangeEvent<HTMLInputElement>) => {- updateSelections((selections) => {- const updated = new Map(selections);- const selection = selections.get(name);-- if (!selection) return updated;-- selection[size] = event.target.checked;-- updated.set(name, selection);-+ updated.set(name, event.target.checked);return updated;});};@@ -100,53 +56,17 @@ export const BoardSelectionCard = ({ selections, updateSelections }: BoardSelect</Stack><Stack gap="sm">- {[...selections.entries()].map(([name, selection]) => (+ {[...selections.entries()].map(([name, selected]) => (<Card key={name} withBorder>- <Group justify="space-between" align="center" visibleFrom="md">- <Checkbox- checked={groupChecked(selection)}- onChange={registerToggleGroup(name)}- label={- <Text fw={500} size="sm">- {name}- </Text>- }- />- <Group>- {boardSizes.map((size) => (- <Checkbox- key={size}- disabled={selection[size] === null}- checked={selection[size] ?? undefined}- onChange={registerToggle(name, size)}- label={t(`board.action.oldImport.form.screenSize.option.${size}`)}- />- ))}- </Group>- </Group>- <Stack hiddenFrom="md">- <Checkbox- checked={groupChecked(selection)}- onChange={registerToggleGroup(name)}- label={- <Text fw={500} size="sm">- {name}- </Text>- }- />- <Stack gap="sm" ps="sm">- {objectEntries(selection)- .filter(([_, value]) => value !== null)- .map(([size, value]) => (- <Checkbox- key={size}- checked={value ?? undefined}- onChange={registerToggle(name, size)}- label={`screenSize.${size}`}- />- ))}- </Stack>- </Stack>+ <Checkbox+ checked={selected}+ onChange={registerToggle(name)}+ label={+ <Text fw={500} size="sm">+ {name}+ </Text>+ }+ /></Card>))}</Stack>diff --git a/packages/old-import/src/import-apps.ts b/packages/old-import/src/import-apps.tsdeleted file mode 100644index 3c1930a48..000000000--- a/packages/old-import/src/import-apps.ts+++ /dev/null@@ -1,160 +0,0 @@-import { createId, inArray } from "@homarr/db";-import type { Database, InferInsertModel, InferSelectModel } from "@homarr/db";-import { apps as appsTable } from "@homarr/db/schema";-import { logger } from "@homarr/log";-import type { OldmarrApp } from "@homarr/old-schema";--import type { BookmarkApp } from "./widgets/definitions/bookmark";--type DbAppWithoutId = Omit<InferSelectModel<typeof appsTable>, "id">;--interface AppMapping extends DbAppWithoutId {- ids: string[];- newId: string;- exists: boolean;-}--export const insertAppsAsync = async (- db: Database,- apps: OldmarrApp[],- bookmarkApps: BookmarkApp[],- distinctAppsByHref: boolean,- configName: string,-) => {- logger.info(- `Importing old homarr apps configuration=${configName} distinctAppsByHref=${distinctAppsByHref} apps=${apps.length}`,- );-- const existingAppsWithHref = distinctAppsByHref- ? await db.query.apps.findMany({- where: inArray(appsTable.href, [- ...new Set(apps.map((app) => app.url).concat(bookmarkApps.map((app) => app.href))),- ]),- })- : [];-- logger.debug(`Found existing apps with href count=${existingAppsWithHref.length}`);-- // Generate mappings for all apps from old to new ids- const appMappings: AppMapping[] = [];- addMappingFor(apps, appMappings, existingAppsWithHref, convertApp);- addMappingFor(bookmarkApps, appMappings, existingAppsWithHref, convertBookmarkApp);-- logger.debug(`Mapping apps count=${appMappings.length}`);-- const appsToCreate = appMappings- .filter((app) => !app.exists)- .map(- (app) =>- ({- id: app.newId,- name: app.name,- iconUrl: app.iconUrl,- href: app.href,- description: app.description,- }) satisfies InferInsertModel<typeof appsTable>,- );-- logger.debug(`Creating apps count=${appsToCreate.length}`);-- if (appsToCreate.length > 0) {- await db.insert(appsTable).values(appsToCreate);- }-- logger.info(`Imported apps count=${appsToCreate.length}`);-- // Generates a map from old key to new key for all apps- return new Map(- appMappings- .map((app) => app.ids.map((id) => ({ id, newId: app.newId })))- .flat()- .map(({ id, newId }) => [id, newId]),- );-};--/**- * Creates a callback to be used in a find method that compares the old app with the new app- * @param app either an oldmarr app or a bookmark app- * @param convertApp a function that converts the app to a new app- * @returns a callback that compares the old app with the new app and returns true if they are the same- */-const createFindCallback = <TApp extends OldmarrApp | BookmarkApp>(- app: TApp,- convertApp: (app: TApp) => DbAppWithoutId,-) => {- const oldApp = convertApp(app);-- return (dbApp: DbAppWithoutId) =>- oldApp.href === dbApp.href &&- oldApp.name === dbApp.name &&- oldApp.iconUrl === dbApp.iconUrl &&- oldApp.description === dbApp.description;-};--/**- * Adds mappings for the given apps to the appMappings array- * @param apps apps to add mappings for- * @param appMappings existing app mappings- * @param existingAppsWithHref existing apps with href- * @param convertApp a function that converts the app to a new app- */-const addMappingFor = <TApp extends OldmarrApp | BookmarkApp>(- apps: TApp[],- appMappings: AppMapping[],- existingAppsWithHref: InferSelectModel<typeof appsTable>[],- convertApp: (app: TApp) => DbAppWithoutId,-) => {- for (const app of apps) {- const previous = appMappings.find(createFindCallback(app, convertApp));- if (previous) {- previous.ids.push(app.id);- continue;- }-- const existing = existingAppsWithHref.find(createFindCallback(app, convertApp));- if (existing) {- appMappings.push({- ids: [app.id],- newId: existing.id,- name: existing.name,- href: existing.href,- iconUrl: existing.iconUrl,- description: existing.description,- pingUrl: existing.pingUrl,- exists: true,- });- continue;- }-- appMappings.push({- ids: [app.id],- newId: createId(),- ...convertApp(app),- exists: false,- });- }-};--/**- * Converts an oldmarr app to a new app- * @param app oldmarr app- * @returns new app- */-const convertApp = (app: OldmarrApp): DbAppWithoutId => ({- name: app.name,- href: app.behaviour.externalUrl === "" ? app.url : app.behaviour.externalUrl,- iconUrl: app.appearance.iconUrl,- description: app.behaviour.tooltipDescription ?? null,- pingUrl: app.url.length > 0 ? app.url : null,-});--/**- * Converts a bookmark app to a new app- * @param app bookmark app- * @returns new app- */-const convertBookmarkApp = (app: BookmarkApp): DbAppWithoutId => ({- ...app,- description: null,- pingUrl: null,-});diff --git a/packages/old-import/src/import-board.ts b/packages/old-import/src/import-board.tsdeleted file mode 100644index 737de5f56..000000000--- a/packages/old-import/src/import-board.ts+++ /dev/null@@ -1,35 +0,0 @@-import type { Database } from "@homarr/db";-import { createId } from "@homarr/db";-import { boards } from "@homarr/db/schema";-import { logger } from "@homarr/log";-import type { OldmarrConfig } from "@homarr/old-schema";--import { mapColor } from "./mappers/map-colors";-import { mapColumnCount } from "./mappers/map-column-count";-import type { OldmarrImportConfiguration } from "./settings";--export const insertBoardAsync = async (db: Database, old: OldmarrConfig, configuration: OldmarrImportConfiguration) => {- logger.info(`Importing old homarr board configuration=${old.configProperties.name}`);- const boardId = createId();- await db.insert(boards).values({- id: boardId,- name: configuration.name,- backgroundImageAttachment: old.settings.customization.backgroundImageAttachment,- backgroundImageUrl: old.settings.customization.backgroundImageUrl,- backgroundImageRepeat: old.settings.customization.backgroundImageRepeat,- backgroundImageSize: old.settings.customization.backgroundImageSize,- columnCount: mapColumnCount(old, configuration.screenSize),- faviconImageUrl: old.settings.customization.faviconUrl,- isPublic: old.settings.access.allowGuests,- logoImageUrl: old.settings.customization.logoImageUrl,- pageTitle: old.settings.customization.pageTitle,- metaTitle: old.settings.customization.metaTitle,- opacity: old.settings.customization.appOpacity,- primaryColor: mapColor(old.settings.customization.colors.primary, "#fa5252"),- secondaryColor: mapColor(old.settings.customization.colors.secondary, "#fd7e14"),- });-- logger.info(`Imported board id=${boardId}`);-- return boardId;-};diff --git a/packages/old-import/src/import-error.ts b/packages/old-import/src/import-error.tsindex 9c0fd3687..8485aa3b9 100644--- a/packages/old-import/src/import-error.ts+++ b/packages/old-import/src/import-error.ts@@ -1,6 +1,4 @@-import type { OldmarrConfig } from "@homarr/old-schema";--import type { OldmarrImportConfiguration } from "./settings";+import type { BoardSize, OldmarrConfig } from "@homarr/old-schema";export class OldHomarrImportError extends Error {constructor(oldConfig: OldmarrConfig, cause: unknown) {@@ -11,7 +9,7 @@ export class OldHomarrImportError extends Error {}export class OldHomarrScreenSizeError extends Error {- constructor(type: "app" | "widget", id: string, screenSize: OldmarrImportConfiguration["screenSize"]) {+ constructor(type: "app" | "widget", id: string, screenSize: BoardSize) {super(`Screen size not found for type=${type} id=${id} screenSize=${screenSize}`);}}diff --git a/packages/old-import/src/import-items.ts b/packages/old-import/src/import-items.tsdeleted file mode 100644index ae4a6fad6..000000000--- a/packages/old-import/src/import-items.ts+++ /dev/null@@ -1,101 +0,0 @@-import SuperJSON from "superjson";--import type { Database } from "@homarr/db";-import { createId } from "@homarr/db";-import { items } from "@homarr/db/schema";-import { logger } from "@homarr/log";-import type { OldmarrApp, OldmarrWidget } from "@homarr/old-schema";--import type { WidgetComponentProps } from "../../widgets/src/definition";-import { OldHomarrScreenSizeError } from "./import-error";-import type { OldmarrImportConfiguration } from "./settings";-import { mapKind } from "./widgets/definitions";-import { mapOptions } from "./widgets/options";--export const insertItemsAsync = async (- db: Database,- widgets: OldmarrWidget[],- apps: OldmarrApp[],- appsMap: Map<string, string>,- sectionIdMaps: Map<string, string>,- configuration: OldmarrImportConfiguration,-) => {- logger.info(`Importing old homarr items widgets=${widgets.length} apps=${apps.length}`);-- for (const widget of widgets) {- // All items should have been moved to the last wrapper- if (widget.area.type === "sidebar") {- continue;- }-- const kind = mapKind(widget.type);-- logger.debug(`Mapped widget kind id=${widget.id} previous=${widget.type} current=${kind}`);-- if (!kind) {- logger.error(`Widget has no kind id=${widget.id} type=${widget.type}`);- continue;- }-- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- const sectionId = sectionIdMaps.get(widget.area.properties.id)!;-- logger.debug(`Inserting widget id=${widget.id} sectionId=${sectionId}`);-- const screenSizeShape = widget.shape[configuration.screenSize];- if (!screenSizeShape) {- throw new OldHomarrScreenSizeError("widget", widget.id, configuration.screenSize);- }-- await db.insert(items).values({- id: createId(),- sectionId,- height: screenSizeShape.size.height,- width: screenSizeShape.size.width,- xOffset: screenSizeShape.location.x,- yOffset: screenSizeShape.location.y,- kind,- options: SuperJSON.stringify(mapOptions(widget.type, widget.properties, appsMap)),- });-- logger.debug(`Inserted widget id=${widget.id} sectionId=${sectionId}`);- }-- for (const app of apps) {- // All items should have been moved to the last wrapper- if (app.area.type === "sidebar") {- continue;- }-- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- const sectionId = sectionIdMaps.get(app.area.properties.id)!;-- logger.debug(`Inserting app name=${app.name} sectionId=${sectionId}`);-- const screenSizeShape = app.shape[configuration.screenSize];- if (!screenSizeShape) {- throw new OldHomarrScreenSizeError("app", app.id, configuration.screenSize);- }-- await db.insert(items).values({- id: createId(),- sectionId,- height: screenSizeShape.size.height,- width: screenSizeShape.size.width,- xOffset: screenSizeShape.location.x,- yOffset: screenSizeShape.location.y,- kind: "app",- options: SuperJSON.stringify({- // it's safe to assume that the app exists in the map- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- appId: appsMap.get(app.id)!,- openInNewTab: app.behaviour.isOpeningNewTab,- pingEnabled: app.network.enabledStatusChecker,- showDescriptionTooltip: app.behaviour.tooltipDescription !== "",- showTitle: app.appearance.appNameStatus === "normal",- } satisfies WidgetComponentProps<"app">["options"]),- });-- logger.debug(`Inserted app name=${app.name} sectionId=${sectionId}`);- }-};diff --git a/packages/old-import/src/import/collections/board-collection.ts b/packages/old-import/src/import/collections/board-collection.tsindex 7178485d5..671ac10c9 100644--- a/packages/old-import/src/import/collections/board-collection.ts+++ b/packages/old-import/src/import/collections/board-collection.ts@@ -1,20 +1,31 @@import { createId } from "@homarr/db";+import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";import { logger } from "@homarr/log";+import type { BoardSize } from "@homarr/old-schema";+import { boardSizes, getBoardSizeName } from "@homarr/old-schema";import { fixSectionIssues } from "../../fix-section-issues";import { mapBoard } from "../../mappers/map-board";+import { mapBreakpoint } from "../../mappers/map-breakpoint";+import { mapColumnCount } from "../../mappers/map-column-count";import { moveWidgetsAndAppsIfMerge } from "../../move-widgets-and-apps-merge";import { prepareItems } from "../../prepare/prepare-items";import type { prepareMultipleImports } from "../../prepare/prepare-multiple";import { prepareSections } from "../../prepare/prepare-sections";import type { InitialOldmarrImportSettings } from "../../settings";-import { createDbInsertCollection } from "./common";export const createBoardInsertCollection = ({ preparedApps, preparedBoards }: Omit<ReturnType<typeof prepareMultipleImports>, "preparedIntegrations">,settings: InitialOldmarrImportSettings,) => {- const insertCollection = createDbInsertCollection(["apps", "boards", "sections", "items"]);+ const insertCollection = createDbInsertCollectionForTransaction([+ "apps",+ "boards",+ "layouts",+ "sections",+ "items",+ "itemLayouts",+ ]);logger.info("Preparing boards for insert collection");const appsMap = new Map(@@ -49,7 +60,6 @@ export const createBoardInsertCollection = (const { wrappers, categories, wrapperIdsToMerge } = fixSectionIssues(board.config);const { apps, widgets } = moveWidgetsAndAppsIfMerge(board.config, wrapperIdsToMerge, {...settings,- screenSize: board.size,name: board.name,});@@ -58,6 +68,25 @@ export const createBoardInsertCollection = (const mappedBoard = mapBoard(board);logger.debug(`Mapped board fileName=${board.name} boardId=${mappedBoard.id}`);insertCollection.boards.push(mappedBoard);++ const layoutMapping = boardSizes.reduce(+ (acc, size) => {+ acc[size] = createId();+ return acc;+ },+ {} as Record<BoardSize, string>,+ );++ insertCollection.layouts.push(+ ...boardSizes.map((size) => ({+ id: layoutMapping[size],+ boardId: mappedBoard.id,+ columnCount: mapColumnCount(board.config, size),+ breakpoint: mapBreakpoint(size),+ name: getBoardSizeName(size),+ })),+ );+const preparedSections = prepareSections(mappedBoard.id, { wrappers, categories });for (const section of preparedSections.values()) {@@ -65,8 +94,11 @@ export const createBoardInsertCollection = (}logger.debug(`Added sections to board insert collection count=${insertCollection.sections.length}`);- const preparedItems = prepareItems({ apps, widgets }, board.size, appsMap, preparedSections);- preparedItems.forEach((item) => insertCollection.items.push(item));+ const preparedItems = prepareItems({ apps, widgets }, appsMap, preparedSections, layoutMapping, mappedBoard.id);+ preparedItems.forEach(({ layouts, ...item }) => {+ insertCollection.items.push(item);+ insertCollection.itemLayouts.push(...layouts);+ });logger.debug(`Added items to board insert collection count=${insertCollection.items.length}`);});diff --git a/packages/old-import/src/import/collections/integration-collection.ts b/packages/old-import/src/import/collections/integration-collection.tsindex 1f67481dd..4a891a808 100644--- a/packages/old-import/src/import/collections/integration-collection.ts+++ b/packages/old-import/src/import/collections/integration-collection.ts@@ -1,15 +1,15 @@import { encryptSecret } from "@homarr/common/server";+import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";import { logger } from "@homarr/log";import { mapAndDecryptIntegrations } from "../../mappers/map-integration";import type { PreparedIntegration } from "../../prepare/prepare-integrations";-import { createDbInsertCollection } from "./common";export const createIntegrationInsertCollection = (preparedIntegrations: PreparedIntegration[],encryptionToken: string | null | undefined,) => {- const insertCollection = createDbInsertCollection(["integrations", "integrationSecrets"]);+ const insertCollection = createDbInsertCollectionForTransaction(["integrations", "integrationSecrets"]);if (preparedIntegrations.length === 0) {return insertCollection;diff --git a/packages/old-import/src/import/collections/user-collection.ts b/packages/old-import/src/import/collections/user-collection.tsindex f006e7a57..4a25fcb99 100644--- a/packages/old-import/src/import/collections/user-collection.ts+++ b/packages/old-import/src/import/collections/user-collection.ts@@ -1,16 +1,21 @@import { createId } from "@homarr/db";+import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";import { credentialsAdminGroup } from "@homarr/definitions";import { logger } from "@homarr/log";import { mapAndDecryptUsers } from "../../mappers/map-user";import type { OldmarrImportUser } from "../../user-schema";-import { createDbInsertCollection } from "./common";export const createUserInsertCollection = (importUsers: OldmarrImportUser[],encryptionToken: string | null | undefined,) => {- const insertCollection = createDbInsertCollection(["users", "groups", "groupMembers", "groupPermissions"]);+ const insertCollection = createDbInsertCollectionForTransaction([+ "users",+ "groups",+ "groupMembers",+ "groupPermissions",+ ]);if (importUsers.length === 0) {return insertCollection;diff --git a/packages/old-import/src/import/input.ts b/packages/old-import/src/import/input.tsindex 3ea7119aa..f60cdd0f7 100644--- a/packages/old-import/src/import/input.ts+++ b/packages/old-import/src/import/input.ts@@ -4,14 +4,7 @@ import { zfd } from "zod-form-data";import { initialOldmarrImportSettings } from "../settings";-const boardSelectionMapSchema = z.map(- z.string(),- z.object({- sm: z.boolean().nullable(),- md: z.boolean().nullable(),- lg: z.boolean().nullable(),- }),-);+const boardSelectionMapSchema = z.map(z.string(), z.boolean());export const importInitialOldmarrInputSchema = zfd.formData({file: zfd.file(),diff --git a/packages/old-import/src/mappers/map-board.ts b/packages/old-import/src/mappers/map-board.tsindex 28a9dfa26..1e2153bef 100644--- a/packages/old-import/src/mappers/map-board.ts+++ b/packages/old-import/src/mappers/map-board.ts@@ -4,7 +4,6 @@ import type { boards } from "@homarr/db/schema";import type { prepareMultipleImports } from "../prepare/prepare-multiple";import { mapColor } from "./map-colors";-import { mapColumnCount } from "./map-column-count";type PreparedBoard = ReturnType<typeof prepareMultipleImports>["preparedBoards"][number];@@ -15,7 +14,6 @@ export const mapBoard = (preparedBoard: PreparedBoard): InferInsertModel<typeofbackgroundImageUrl: preparedBoard.config.settings.customization.backgroundImageUrl,backgroundImageRepeat: preparedBoard.config.settings.customization.backgroundImageRepeat,backgroundImageSize: preparedBoard.config.settings.customization.backgroundImageSize,- columnCount: mapColumnCount(preparedBoard.config, preparedBoard.size),faviconImageUrl: preparedBoard.config.settings.customization.faviconUrl,isPublic: preparedBoard.config.settings.access.allowGuests,logoImageUrl: preparedBoard.config.settings.customization.logoImageUrl,diff --git a/packages/old-import/src/mappers/map-breakpoint.ts b/packages/old-import/src/mappers/map-breakpoint.tsnew file mode 100644index 000000000..67e74be5b--- /dev/null+++ b/packages/old-import/src/mappers/map-breakpoint.ts@@ -0,0 +1,18 @@+import type { BoardSize } from "@homarr/old-schema";++/**+ * Copied from https://github.com/ajnart/homarr/blob/274eaa92084a8be4d04a69a87f9920860a229128/src/components/Dashboard/Wrappers/gridstack/store.tsx#L21-L30+ * @param screenSize board size+ * @returns layout breakpoint for the board+ */+export const mapBreakpoint = (screenSize: BoardSize) => {+ switch (screenSize) {+ case "lg":+ return 1400;+ case "md":+ return 800;+ case "sm":+ default:+ return 0;+ }+};diff --git a/packages/old-import/src/mappers/map-column-count.ts b/packages/old-import/src/mappers/map-column-count.tsindex f2ac5c09c..5aedc26cf 100644--- a/packages/old-import/src/mappers/map-column-count.ts+++ b/packages/old-import/src/mappers/map-column-count.ts@@ -1,8 +1,6 @@-import type { OldmarrConfig } from "@homarr/old-schema";+import type { BoardSize, OldmarrConfig } from "@homarr/old-schema";-import type { OldmarrImportConfiguration } from "../settings";--export const mapColumnCount = (old: OldmarrConfig, screenSize: OldmarrImportConfiguration["screenSize"]) => {+export const mapColumnCount = (old: OldmarrConfig, screenSize: BoardSize) => {switch (screenSize) {case "lg":return old.settings.customization.gridstack.columnCountLarge;diff --git a/packages/old-import/src/mappers/map-item.ts b/packages/old-import/src/mappers/map-item.tsindex a4faeed58..91ba5b95c 100644--- a/packages/old-import/src/mappers/map-item.ts+++ b/packages/old-import/src/mappers/map-item.ts@@ -2,9 +2,10 @@ import SuperJSON from "superjson";import type { InferInsertModel } from "@homarr/db";import { createId } from "@homarr/db";-import type { items } from "@homarr/db/schema";+import type { itemLayouts, items } from "@homarr/db/schema";import { logger } from "@homarr/log";import type { BoardSize, OldmarrApp, OldmarrWidget } from "@homarr/old-schema";+import { boardSizes } from "@homarr/old-schema";import type { WidgetComponentProps } from "../../../widgets/src/definition";import { mapKind } from "../widgets/definitions";@@ -12,30 +13,23 @@ import { mapOptions } from "../widgets/options";export const mapApp = (app: OldmarrApp,- boardSize: BoardSize,appsMap: Map<string, { id: string }>,sectionMap: Map<string, { id: string }>,-): InferInsertModel<typeof items> | null => {+ layoutMap: Record<BoardSize, string>,+ boardId: string,+): (InferInsertModel<typeof items> & { layouts: InferInsertModel<typeof itemLayouts>[] }) | null => {if (app.area.type === "sidebar") throw new Error("Mapping app in sidebar is not supported");- const shapeForSize = app.shape[boardSize];- if (!shapeForSize) {- throw new Error(`Failed to find a shape for appId='${app.id}' screenSize='${boardSize}'`);- }-const sectionId = sectionMap.get(app.area.properties.id)?.id;if (!sectionId) {logger.warn(`Failed to find section for app appId='${app.id}' sectionId='${app.area.properties.id}'. Removing app`);return null;}+ const itemId = createId();return {- id: createId(),- sectionId,- height: shapeForSize.size.height,- width: shapeForSize.size.width,- xOffset: shapeForSize.location.x,- yOffset: shapeForSize.location.y,+ id: itemId,+ boardId,kind: "app",options: SuperJSON.stringify({// it's safe to assume that the app exists in the map@@ -46,22 +40,34 @@ export const mapApp = (showDescriptionTooltip: app.behaviour.tooltipDescription !== "",showTitle: app.appearance.appNameStatus === "normal",} satisfies WidgetComponentProps<"app">["options"]),+ layouts: boardSizes.map((size) => {+ const shapeForSize = app.shape[size];+ if (!shapeForSize) {+ throw new Error(`Failed to find a shape for appId='${app.id}' screenSize='${size}'`);+ }++ return {+ itemId,+ height: shapeForSize.size.height,+ width: shapeForSize.size.width,+ xOffset: shapeForSize.location.x,+ yOffset: shapeForSize.location.y,+ sectionId,+ layoutId: layoutMap[size],+ };+ }),};};export const mapWidget = (widget: OldmarrWidget,- boardSize: BoardSize,appsMap: Map<string, { id: string }>,sectionMap: Map<string, { id: string }>,-): InferInsertModel<typeof items> | null => {+ layoutMap: Record<BoardSize, string>,+ boardId: string,+): (InferInsertModel<typeof items> & { layouts: InferInsertModel<typeof itemLayouts>[] }) | null => {if (widget.area.type === "sidebar") throw new Error("Mapping widget in sidebar is not supported");- const shapeForSize = widget.shape[boardSize];- if (!shapeForSize) {- throw new Error(`Failed to find a shape for widgetId='${widget.id}' screenSize='${boardSize}'`);- }-const kind = mapKind(widget.type);if (!kind) {logger.warn(`Failed to map widget type='${widget.type}'. It's no longer supported`);@@ -76,13 +82,10 @@ export const mapWidget = (return null;}+ const itemId = createId();return {- id: createId(),- sectionId,- height: shapeForSize.size.height,- width: shapeForSize.size.width,- xOffset: shapeForSize.location.x,- yOffset: shapeForSize.location.y,+ id: itemId,+ boardId,kind,options: SuperJSON.stringify(mapOptions(@@ -91,5 +94,21 @@ export const mapWidget = (new Map([...appsMap.entries()].map(([key, value]) => [key, value.id])),),),+ layouts: boardSizes.map((size) => {+ const shapeForSize = widget.shape[size];+ if (!shapeForSize) {+ throw new Error(`Failed to find a shape for widgetId='${widget.id}' screenSize='${size}'`);+ }++ return {+ itemId,+ height: shapeForSize.size.height,+ width: shapeForSize.size.width,+ xOffset: shapeForSize.location.x,+ yOffset: shapeForSize.location.y,+ sectionId,+ layoutId: layoutMap[size],+ };+ }),};};diff --git a/packages/old-import/src/move-widgets-and-apps-merge.ts b/packages/old-import/src/move-widgets-and-apps-merge.tsindex 68abcb351..2cb773a9f 100644--- a/packages/old-import/src/move-widgets-and-apps-merge.ts+++ b/packages/old-import/src/move-widgets-and-apps-merge.ts@@ -1,6 +1,7 @@import { objectEntries } from "@homarr/common";import { logger } from "@homarr/log";-import type { OldmarrApp, OldmarrConfig, OldmarrWidget } from "@homarr/old-schema";+import type { BoardSize, OldmarrApp, OldmarrConfig, OldmarrWidget } from "@homarr/old-schema";+import { boardSizes } from "@homarr/old-schema";import { OldHomarrScreenSizeError } from "./import-error";import { mapColumnCount } from "./mappers/map-column-count";@@ -28,9 +29,21 @@ export const moveWidgetsAndAppsIfMerge = (logger.debug(`Merging wrappers at the end of the board count=${wrapperIdsToMerge.length}`);- let offset = 0;+ const offsets = boardSizes.reduce(+ (previous, screenSize) => {+ previous[screenSize] = 0;+ return previous;+ },+ {} as Record<BoardSize, number>,+ );for (const id of wrapperIdsToMerge) {- let requiredHeight = 0;+ const requiredHeights = boardSizes.reduce(+ (previous, screenSize) => {+ previous[screenSize] = 0;+ return previous;+ },+ {} as Record<BoardSize, number>,+ );const affected = affectedMap.get(id);if (!affected) {continue;@@ -44,18 +57,20 @@ export const moveWidgetsAndAppsIfMerge = (// Move item to first wrapperapp.area.properties.id = firstId;- const screenSizeShape = app.shape[configuration.screenSize];- if (!screenSizeShape) {- throw new OldHomarrScreenSizeError("app", app.id, configuration.screenSize);- }+ for (const screenSize of boardSizes) {+ const screenSizeShape = app.shape[screenSize];+ if (!screenSizeShape) {+ throw new OldHomarrScreenSizeError("app", app.id, screenSize);+ }- // Find the highest widget in the wrapper to increase the offset accordingly- if (screenSizeShape.location.y + screenSizeShape.size.height > requiredHeight) {- requiredHeight = screenSizeShape.location.y + screenSizeShape.size.height;- }+ // Find the highest widget in the wrapper to increase the offset accordingly+ if (screenSizeShape.location.y + screenSizeShape.size.height > requiredHeights[screenSize]) {+ requiredHeights[screenSize] = screenSizeShape.location.y + screenSizeShape.size.height;+ }- // Move item down as much as needed to not overlap with other items- screenSizeShape.location.y += offset;+ // Move item down as much as needed to not overlap with other items+ screenSizeShape.location.y += offsets[screenSize];+ }}for (const widget of widgets) {@@ -63,21 +78,25 @@ export const moveWidgetsAndAppsIfMerge = (// Move item to first wrapperwidget.area.properties.id = firstId;- const screenSizeShape = widget.shape[configuration.screenSize];- if (!screenSizeShape) {- throw new OldHomarrScreenSizeError("widget", widget.id, configuration.screenSize);- }+ for (const screenSize of boardSizes) {+ const screenSizeShape = widget.shape[screenSize];+ if (!screenSizeShape) {+ throw new OldHomarrScreenSizeError("widget", widget.id, screenSize);+ }- // Find the highest widget in the wrapper to increase the offset accordingly- if (screenSizeShape.location.y + screenSizeShape.size.height > requiredHeight) {- requiredHeight = screenSizeShape.location.y + screenSizeShape.size.height;- }+ // Find the highest widget in the wrapper to increase the offset accordingly+ if (screenSizeShape.location.y + screenSizeShape.size.height > requiredHeights[screenSize]) {+ requiredHeights[screenSize] = screenSizeShape.location.y + screenSizeShape.size.height;+ }- // Move item down as much as needed to not overlap with other items- screenSizeShape.location.y += offset;+ // Move item down as much as needed to not overlap with other items+ screenSizeShape.location.y += offsets[screenSize];+ }}- offset += requiredHeight;+ for (const screenSize of boardSizes) {+ offsets[screenSize] += requiredHeights[screenSize];+ }}if (configuration.sidebarBehaviour === "last-section") {@@ -86,14 +105,18 @@ export const moveWidgetsAndAppsIfMerge = (old.settings.customization.layout.enabledLeftSidebar ||areas.some((area) => area.type === "sidebar" && area.properties.location === "left")) {- offset = moveWidgetsAndAppsInLeftSidebar(old, firstId, offset, configuration.screenSize);+ for (const screenSize of boardSizes) {+ offsets[screenSize] = moveWidgetsAndAppsInLeftSidebar(old, firstId, offsets[screenSize], screenSize);+ }}if (old.settings.customization.layout.enabledRightSidebar ||areas.some((area) => area.type === "sidebar" && area.properties.location === "right")) {- moveWidgetsAndAppsInRightSidebar(old, firstId, offset, configuration.screenSize);+ for (const screenSize of boardSizes) {+ moveWidgetsAndAppsInRightSidebar(old, firstId, offsets[screenSize], screenSize);+ }}} else {// Remove all widgets and apps in the sidebar@@ -110,7 +133,7 @@ const moveWidgetsAndAppsInLeftSidebar = (old: OldmarrConfig,firstId: string,offset: number,- screenSize: OldmarrImportConfiguration["screenSize"],+ screenSize: BoardSize,) => {const columnCount = mapColumnCount(old, screenSize);let requiredHeight = updateItems({@@ -186,7 +209,7 @@ const moveWidgetsAndAppsInRightSidebar = (old: OldmarrConfig,firstId: string,offset: number,- screenSize: OldmarrImportConfiguration["screenSize"],+ screenSize: BoardSize,) => {const columnCount = mapColumnCount(old, screenSize);const xOffsetDelta = Math.max(columnCount - 2, 0);@@ -255,10 +278,7 @@ const moveWidgetsAndAppsInRightSidebar = (});};-const createItemSnapshot = (- item: OldmarrApp | OldmarrWidget,- screenSize: OldmarrImportConfiguration["screenSize"],-) => ({+const createItemSnapshot = (item: OldmarrApp | OldmarrWidget, screenSize: BoardSize) => ({x: item.shape[screenSize]?.location.x,y: item.shape[screenSize]?.location.y,height: item.shape[screenSize]?.size.height,@@ -285,7 +305,7 @@ const updateItems = (options: {items: (OldmarrApp | OldmarrWidget)[];filter: (item: OldmarrApp | OldmarrWidget) => boolean;update: (item: OldmarrApp | OldmarrWidget) => void;- screenSize: OldmarrImportConfiguration["screenSize"];+ screenSize: BoardSize;}) => {const items = options.items.filter(options.filter);let requiredHeight = 0;diff --git a/packages/old-import/src/prepare/prepare-boards.ts b/packages/old-import/src/prepare/prepare-boards.tsindex 76dc2bc2f..e6bcbe1db 100644--- a/packages/old-import/src/prepare/prepare-boards.ts+++ b/packages/old-import/src/prepare/prepare-boards.ts@@ -1,34 +1,6 @@-import { objectEntries } from "@homarr/common";-import type { BoardSize } from "@homarr/old-schema";-import type { ValidAnalyseConfig } from "../analyse/types";import type { BoardSelectionMap } from "../components/initial/board-selection-card";-const boardSizeSuffix: Record<BoardSize, string> = {- lg: "large",- md: "medium",- sm: "small",-};--export const createBoardName = (fileName: string, boardSize: BoardSize) => {- return `${fileName.replace(".json", "")}-${boardSizeSuffix[boardSize]}`;-};-export const prepareBoards = (analyseConfigs: ValidAnalyseConfig[], selections: BoardSelectionMap) => {- return analyseConfigs.flatMap(({ name, config }) => {- const selectedSizes = selections.get(name);- if (!selectedSizes) return [];-- return objectEntries(selectedSizes)- .map(([size, selected]) => {- if (!selected) return null;-- return {- name: createBoardName(name, size),- size,- config,- };- })- .filter((board) => board !== null);- });+ return analyseConfigs.filter(({ name }) => selections.get(name));};diff --git a/packages/old-import/src/prepare/prepare-items.ts b/packages/old-import/src/prepare/prepare-items.tsindex b099433cf..f9c9d55d4 100644--- a/packages/old-import/src/prepare/prepare-items.ts+++ b/packages/old-import/src/prepare/prepare-items.ts@@ -4,11 +4,12 @@ import { mapApp, mapWidget } from "../mappers/map-item";export const prepareItems = ({ apps, widgets }: Pick<OldmarrConfig, "apps" | "widgets">,- boardSize: BoardSize,appsMap: Map<string, { id: string }>,sectionMap: Map<string, { id: string }>,+ layoutMap: Record<BoardSize, string>,+ boardId: string,) =>widgets- .map((widget) => mapWidget(widget, boardSize, appsMap, sectionMap))- .concat(apps.map((app) => mapApp(app, boardSize, appsMap, sectionMap)))+ .map((widget) => mapWidget(widget, appsMap, sectionMap, layoutMap, boardId))+ .concat(apps.map((app) => mapApp(app, appsMap, sectionMap, layoutMap, boardId))).filter((widget) => widget !== null);diff --git a/packages/old-import/src/prepare/prepare-single.ts b/packages/old-import/src/prepare/prepare-single.tsindex c762beada..cf1544555 100644--- a/packages/old-import/src/prepare/prepare-single.ts+++ b/packages/old-import/src/prepare/prepare-single.ts@@ -8,14 +8,6 @@ export const prepareSingleImport = (config: OldmarrConfig, settings: OldmarrImporeturn {preparedApps: prepareApps(validAnalyseConfigs),- preparedBoards: settings.onlyImportApps- ? []- : [- {- name: settings.name,- size: settings.screenSize,- config,- },- ],+ preparedBoards: settings.onlyImportApps ? [] : validAnalyseConfigs,};};diff --git a/packages/old-import/src/settings.ts b/packages/old-import/src/settings.tsindex a0700c8a0..9c2fb2f9e 100644--- a/packages/old-import/src/settings.ts+++ b/packages/old-import/src/settings.ts@@ -1,8 +1,7 @@import { z } from "zod";import { zfd } from "zod-form-data";-import { boardSizes } from "@homarr/old-schema";-import { validation, zodEnumFromArray } from "@homarr/validation";+import { validation } from "@homarr/validation";import { createCustomErrorParams } from "@homarr/validation/form";export const sidebarBehaviours = ["remove-items", "last-section"] as const;@@ -12,7 +11,6 @@ export type SidebarBehaviour = (typeof sidebarBehaviours)[number];export const oldmarrImportConfigurationSchema = z.object({name: validation.board.name,onlyImportApps: z.boolean().default(false),- screenSize: zodEnumFromArray(boardSizes).default("lg"),sidebarBehaviour: z.enum(sidebarBehaviours).default(defaultSidebarBehaviour),});diff --git a/packages/old-schema/src/index.ts b/packages/old-schema/src/index.tsindex c328cd8e7..40528c09d 100644--- a/packages/old-schema/src/index.ts+++ b/packages/old-schema/src/index.ts@@ -3,5 +3,5 @@ export { oldmarrConfigSchema } from "./config";export type { OldmarrApp, OldmarrIntegrationType } from "./app";export type { OldmarrWidget, OldmarrWidgetKind } from "./widget";export { oldmarrWidgetKinds } from "./widget";-export { boardSizes } from "./tile";+export { boardSizes, getBoardSizeName } from "./tile";export type { BoardSize } from "./tile";diff --git a/packages/old-schema/src/tile.ts b/packages/old-schema/src/tile.tsindex 92c66d5af..2331fbdbe 100644--- a/packages/old-schema/src/tile.ts+++ b/packages/old-schema/src/tile.ts@@ -58,3 +58,15 @@ export const tileBaseSchema = z.object({export const boardSizes = objectKeys(shapeSchema._def.shape());export type BoardSize = (typeof boardSizes)[number];++export const getBoardSizeName = (size: BoardSize) => {+ switch (size) {+ case "md":+ return "medium";+ case "sm":+ return "small";+ case "lg":+ default:+ return "large";+ }+};diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.jsonindex 59cf82a17..5a4adf486 100644--- a/packages/translation/src/lang/en.json+++ b/packages/translation/src/lang/en.json@@ -2142,7 +2142,13 @@"unrecognizedLink": "The provided link is not recognized and won't preview, it might still work."},"layout": {- "title": "Layout"+ "title": "Layout",+ "responsive": {+ "title": "Responsive layouts",+ "action": {+ "add": "Add layout"+ }+ }},"background": {"title": "Background"@@ -2250,6 +2256,20 @@}}},+ "layout": {+ "field": {+ "name": {+ "label": "Name"+ },+ "columnCount": {+ "label": "Column count"+ },+ "breakpoint": {+ "label": "Breakpoint",+ "description": "Layout will be used on all screens larger than this breakpoint until the next bigger breakpoint."+ }+ }+ },"management": {"metaTitle": "Management","title": {diff --git a/packages/validation/src/board.ts b/packages/validation/src/board.tsindex e8af6f9cd..973c582f3 100644--- a/packages/validation/src/board.ts+++ b/packages/validation/src/board.ts@@ -9,7 +9,7 @@ import {import { zodEnumFromArray } from "./enums";import { createSavePermissionsSchema } from "./permissions";-import { commonItemSchema, createSectionSchema } from "./shared";+import { commonItemSchema, sectionSchema } from "./shared";const hexColorSchema = z.string().regex(/^#[0-9A-Fa-f]{6}$/);@@ -62,16 +62,28 @@ const savePartialSettingsSchema = zsecondaryColor: hexColorSchema,opacity: z.number().min(0).max(100),customCss: z.string().max(16384),- columnCount: z.number().min(1).max(24),iconColor: hexColorNullableSchema,itemRadius: z.union([z.literal("xs"), z.literal("sm"), z.literal("md"), z.literal("lg"), z.literal("xl")]),disableStatus: z.boolean(),}).partial();+const saveLayoutsSchema = z.object({+ id: z.string(),+ layouts: z.array(+ z.object({+ id: z.string(),+ name: z.string().trim().nonempty().max(32),+ columnCount: z.number().min(1).max(24),+ breakpoint: z.number().min(0).max(32767),+ }),+ ),+});+const saveSchema = z.object({id: z.string(),- sections: z.array(createSectionSchema(commonItemSchema)),+ sections: z.array(sectionSchema),+ items: z.array(commonItemSchema),});const createSchema = z.object({ name: boardNameSchema, columnCount: z.number().min(1).max(24), isPublic: z.boolean() });@@ -96,6 +108,7 @@ export const boardSchemas = {name: boardNameSchema,byName: byNameSchema,savePartialSettings: savePartialSettingsSchema,+ saveLayouts: saveLayoutsSchema,save: saveSchema,create: createSchema,duplicate: duplicateSchema,diff --git a/packages/validation/src/index.ts b/packages/validation/src/index.tsindex 955031786..d57bc47e9 100644--- a/packages/validation/src/index.ts+++ b/packages/validation/src/index.ts@@ -29,7 +29,7 @@ export const validation = {};export {- createSectionSchema,+ sectionSchema,itemAdvancedOptionsSchema,sharedItemSchema,type BoardItemAdvancedOptions,diff --git a/packages/validation/src/shared.ts b/packages/validation/src/shared.tsindex af23810e8..a0eda19be 100644--- a/packages/validation/src/shared.ts+++ b/packages/validation/src/shared.ts@@ -21,10 +21,16 @@ export type BoardItemAdvancedOptions = z.infer<typeof itemAdvancedOptionsSchema>export const sharedItemSchema = z.object({id: z.string(),- xOffset: z.number(),- yOffset: z.number(),- height: z.number(),- width: z.number(),+ layouts: z.array(+ z.object({+ layoutId: z.string(),+ yOffset: z.number(),+ xOffset: z.number(),+ width: z.number(),+ height: z.number(),+ sectionId: z.string(),+ }),+ ),integrationIds: z.array(z.string()),advancedOptions: itemAdvancedOptionsSchema,});@@ -36,37 +42,35 @@ export const commonItemSchema = z}).and(sharedItemSchema);-const createCategorySchema = <TItemSchema extends z.ZodTypeAny>(itemSchema: TItemSchema) =>- z.object({- id: z.string(),- name: z.string(),- kind: z.literal("category"),- yOffset: z.number(),- xOffset: z.number(),- items: z.array(itemSchema),- collapsed: z.boolean(),- });+const categorySectionSchema = z.object({+ id: z.string(),+ name: z.string(),+ kind: z.literal("category"),+ yOffset: z.number(),+ xOffset: z.number(),+ collapsed: z.boolean(),+});-const createEmptySchema = <TItemSchema extends z.ZodTypeAny>(itemSchema: TItemSchema) =>- z.object({- id: z.string(),- kind: z.literal("empty"),- yOffset: z.number(),- xOffset: z.number(),- items: z.array(itemSchema),- });+const emptySectionSchema = z.object({+ id: z.string(),+ kind: z.literal("empty"),+ yOffset: z.number(),+ xOffset: z.number(),+});-const createDynamicSchema = <TItemSchema extends z.ZodTypeAny>(itemSchema: TItemSchema) =>- z.object({- id: z.string(),- kind: z.literal("dynamic"),- yOffset: z.number(),- xOffset: z.number(),- width: z.number(),- height: z.number(),- items: z.array(itemSchema),- parentSectionId: z.string(),- });+const dynamicSectionSchema = z.object({+ id: z.string(),+ kind: z.literal("dynamic"),+ layouts: z.array(+ z.object({+ layoutId: z.string(),+ yOffset: z.number(),+ xOffset: z.number(),+ width: z.number(),+ height: z.number(),+ parentSectionId: z.string(),+ }),+ ),+});-export const createSectionSchema = <TItemSchema extends z.ZodTypeAny>(itemSchema: TItemSchema) =>- z.union([createCategorySchema(itemSchema), createEmptySchema(itemSchema), createDynamicSchema(itemSchema)]);+export const sectionSchema = z.union([categorySectionSchema, emptySectionSchema, dynamicSectionSchema]);