Compare commits

..
Author SHA1 Message Date
Thomas Camlong 8203ca0c63 fix: add lazyConnect to Redis client to prevent build-time connection errors 2026-05-22 09:31:29 +02:00
Thomas Camlong 5e5492818a test: add tests for Redis lazy-init and startup retry logic 2026-05-22 09:06:40 +02:00
Thomas Camlong a6ec5f789d fix: resolve Redis null client crashes on startup
After #5600 merged tasks/websocket into the Next.js process,
`createRedisConnection()` returns `null` because `CI=true` is baked into
the bundle at build time. This causes `TypeError: Cannot read properties
of null` on every `.publish()` / `.get()` call during cron job startup.

- Remove the CI/DISABLE_REDIS_LOGS null guard from createRedisConnection
- Lazy-init all Redis clients to avoid build-time evaluation
- Add a Redis readiness retry loop before starting cron jobs
2026-05-21 16:33:43 +02:00
122 changed files with 4740 additions and 1679 deletions

No files matched your search

+6 -3
View File
@@ -3,6 +3,9 @@ version = 1
[[analyzers]] [[analyzers]]
name = "javascript" name = "javascript"
[analyzers.meta] [analyzers.meta]
plugins = ["react"] plugins = ["react"]
environment = ["nodejs"] environment = ["nodejs"]
[[transformers]]
name = "prettier"
-1
View File
@@ -33,7 +33,6 @@ body:
options: options:
# The below comment is used to insert a new version with on-release.yml # The below comment is used to insert a new version with on-release.yml
#NEXT_VERSION# #NEXT_VERSION#
- 1.62.0
- 1.61.0 - 1.61.0
- 1.60.1-beta.1 - 1.60.1-beta.1
- 1.60.0 - 1.60.0
+1 -33
View File
@@ -24,38 +24,6 @@ env:
TURBO_SCM_HEAD: ${{ github.sha }} TURBO_SCM_HEAD: ${{ github.sha }}
jobs: jobs:
lint-format-autofix:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Setup
uses: ./tooling/github/setup
- name: Get changed files
id: changed
run: |
FILES=$(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}...HEAD -- '*.ts' '*.tsx' '*.js' '*.jsx' | tr '\n' ' ')
echo "files=$FILES" >> $GITHUB_OUTPUT
- name: Auto-fix lint + format
if: steps.changed.outputs.files != ''
run: |
pnpm exec oxlint --fix ${{ steps.changed.outputs.files }} || true
pnpm exec oxfmt --write ${{ steps.changed.outputs.files }}
- name: Commit fixes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: auto-fix lint and format"
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
@@ -86,7 +54,7 @@ jobs:
uses: ./tooling/github/setup uses: ./tooling/github/setup
- name: Format - name: Format
run: pnpm turbo format --affected --continue run: pnpm turbo format --affected --continue -- --cache --cache-location node_modules/.cache/.prettiercache
typecheck: typecheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
-7
View File
@@ -1,7 +0,0 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 120,
"endOfLine": "lf",
"sortPackageJson": true,
"ignorePatterns": ["**/*.cjs", "**/lang/**", "static-data/**", "CHANGELOG.md"]
}
-37
View File
@@ -1,37 +0,0 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["eslint", "typescript", "unicorn", "oxc", "react", "import", "jsx-a11y"],
"categories": {
"correctness": "error",
"suspicious": "warn",
"pedantic": "off",
"perf": "off",
"style": "off",
"restriction": "off",
"nursery": "off"
},
"rules": {
"eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
"typescript/consistent-type-imports": ["warn", { "prefer": "type-imports", "fixStyle": "separate-type-imports" }],
"typescript/no-non-null-assertion": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"unicorn/no-new-array": "warn",
"unicorn/no-useless-spread": "warn",
"unicorn/no-useless-length-check": "warn",
"unicorn/no-useless-fallback-in-spread": "warn",
"jsx-a11y/prefer-tag-over-role": "warn",
"oxc/const-comparisons": "warn",
"react-hooks/exhaustive-deps": "warn",
"react/no-children-prop": "warn",
"jsx-a11y/no-autofocus": "warn",
"jsx-a11y/img-redundant-alt": "warn",
"react/react-in-jsx-scope": "off"
},
"options": {
"reportUnusedDisableDirectives": "off"
},
"ignorePatterns": ["**/*.config.js", "**/*.config.mjs", "**/*.cjs", "**/lang/*.d.json.ts", ".next/**"],
"settings": {
"react": { "version": "19" }
}
}
+2 -1
View File
@@ -31,5 +31,6 @@ scopeRangeRegex: "(?:const|let|var)\\s+t\\s*=\\s*(?:await\\s+)?(?:getScopedI18n|
# refactorTemplates: # refactorTemplates:
# - i18n.get("$1") # - i18n.get("$1")
# If set to true, only enables this custom framework (will disable all built-in frameworks) # If set to true, only enables this custom framework (will disable all built-in frameworks)
monopoly: true monopoly: true
+15 -5
View File
@@ -15,7 +15,9 @@
"request": "launch", "request": "launch",
"command": "pnpm docker:dev", "command": "pnpm docker:dev",
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"] "skipFiles": [
"<node_internals>/**"
]
}, },
{ {
"name": "lint fix", "name": "lint fix",
@@ -23,7 +25,9 @@
"request": "launch", "request": "launch",
"command": "pnpm lint:fix", "command": "pnpm lint:fix",
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"] "skipFiles": [
"<node_internals>/**"
]
}, },
{ {
"name": "format fix", "name": "format fix",
@@ -31,7 +35,9 @@
"request": "launch", "request": "launch",
"command": "pnpm format:fix", "command": "pnpm format:fix",
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"] "skipFiles": [
"<node_internals>/**"
]
}, },
{ {
"name": "db push", "name": "db push",
@@ -63,7 +69,9 @@
"request": "launch", "request": "launch",
"command": "pnpm test", "command": "pnpm test",
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"] "skipFiles": [
"<node_internals>/**"
]
}, },
{ {
"name": "test ui", "name": "test ui",
@@ -71,7 +79,9 @@
"request": "launch", "request": "launch",
"command": "pnpm test:ui", "command": "pnpm test:ui",
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"] "skipFiles": [
"<node_internals>/**"
]
} }
] ]
} }
+14 -3
View File
@@ -1,6 +1,13 @@
{ {
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"eslint.experimental.useFlatConfig": true,
"typescript.tsdk": "node_modules\\typescript\\lib", "typescript.tsdk": "node_modules\\typescript\\lib",
"js/ts.implicitProjectConfig.experimentalDecorators": true, "js/ts.implicitProjectConfig.experimentalDecorators": true,
"prettier.configPath": "./tooling/prettier/index.mjs",
"cSpell.words": [ "cSpell.words": [
"ajnart", "ajnart",
"cqmin", "cqmin",
@@ -27,7 +34,11 @@
], ],
"i18n-ally.dirStructure": "auto", "i18n-ally.dirStructure": "auto",
"i18n-ally.displayLanguage": "en", "i18n-ally.displayLanguage": "en",
"i18n-ally.enabledFrameworks": ["custom"], "i18n-ally.enabledFrameworks": [
"i18n-ally.localesPaths": ["packages/translation/src/lang"], "custom"
"i18n-ally.keystyle": "nested" ],
"i18n-ally.localesPaths": [
"packages/translation/src/lang",
],
"i18n-ally.keystyle": "nested",
} }
-6
View File
@@ -1,9 +1,3 @@
## [1.61.1](https://github.com/homarr-labs/homarr/compare/v1.61.0...v1.61.1) (2026-05-18)
### Bug Fixes
* **downloads-widget:** increase name column default width ratio ([e9142c0](https://github.com/homarr-labs/homarr/commit/e9142c0dbcaca6cd9215b5292a2d139d96919b51))
## [1.61.1-beta.1](https://github.com/homarr-labs/homarr/compare/v1.61.0...v1.61.1-beta.1) (2026-05-08) ## [1.61.1-beta.1](https://github.com/homarr-labs/homarr/compare/v1.61.0...v1.61.1-beta.1) (2026-05-08)
### Performance Improvements ### Performance Improvements
+30
View File
@@ -0,0 +1,30 @@
import baseConfig from "@homarr/eslint-config/base";
import nextjsConfig from "@homarr/eslint-config/nextjs";
import reactConfig from "@homarr/eslint-config/react";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [".next/**"],
},
...baseConfig,
...reactConfig,
...nextjsConfig,
{
files: ["public/sw.js"],
languageOptions: {
globals: {
self: "readonly",
clients: "readonly",
skipWaiting: "readonly",
importScripts: "readonly",
caches: "readonly",
fetch: "readonly",
},
},
rules: {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
},
},
];
+7 -2
View File
@@ -7,12 +7,13 @@
"build": "pnpm with-env next build", "build": "pnpm with-env next build",
"clean": "git clean -xdf .next .turbo node_modules", "clean": "git clean -xdf .next .turbo node_modules",
"dev": "pnpm with-env next dev", "dev": "pnpm with-env next dev",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"start": "pnpm with-env next start", "start": "pnpm with-env next start",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --" "with-env": "dotenv -e ../../.env --"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@dnd-kit/core": "catalog:", "@dnd-kit/core": "catalog:",
"@dnd-kit/modifiers": "catalog:", "@dnd-kit/modifiers": "catalog:",
@@ -91,6 +92,8 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/chroma-js": "catalog:", "@types/chroma-js": "catalog:",
"@types/node": "catalog:", "@types/node": "catalog:",
@@ -99,7 +102,9 @@
"@types/react-dom": "catalog:", "@types/react-dom": "catalog:",
"@types/swagger-ui-react": "catalog:", "@types/swagger-ui-react": "catalog:",
"concurrently": "catalog:", "concurrently": "catalog:",
"eslint": "catalog:",
"node-loader": "catalog:", "node-loader": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -1,27 +1,70 @@
"use client"; "use client";
import { Box, Stack } from "@mantine/core"; import { useCallback, useRef } from "react";
import { Box, LoadingOverlay, Stack } from "@mantine/core";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context"; import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
import { BoardCategorySection } from "~/components/board/sections/category-section"; import { BoardCategorySection } from "~/components/board/sections/category-section";
import { BoardEmptySection } from "~/components/board/sections/empty-section"; import { BoardEmptySection } from "~/components/board/sections/empty-section";
import { BoardBackgroundVideo } from "~/components/layout/background"; import { BoardBackgroundVideo } from "~/components/layout/background";
import { fullHeightWithoutHeaderAndFooter } from "~/constants";
import { useIsBoardReady } from "./_ready-context";
let boardName: string | null = null;
export const updateBoardName = (name: string | null) => {
boardName = name;
};
type UpdateCallback = (prev: RouterOutputs["board"]["getHomeBoard"]) => RouterOutputs["board"]["getHomeBoard"];
export const useUpdateBoard = () => {
const utils = clientApi.useUtils();
const updateBoard = useCallback(
(updaterWithoutUndefined: UpdateCallback) => {
if (!boardName) {
throw new Error("Board name is not set");
}
utils.board.getBoardByName.setData({ name: boardName }, (previous) =>
previous ? updaterWithoutUndefined(previous) : previous,
);
},
[utils],
);
return {
updateBoard,
};
};
export const ClientBoard = () => { export const ClientBoard = () => {
const board = useRequiredBoard(); const board = useRequiredBoard();
const currentLayoutId = useCurrentLayout(); const currentLayoutId = useCurrentLayout();
const isReady = useIsBoardReady();
const fullWidthSortedSections = board.sections const fullWidthSortedSections = board.sections
.filter((section) => section.kind === "empty" || section.kind === "category") .filter((section) => section.kind === "empty" || section.kind === "category")
.sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset); .sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset);
const ref = useRef<HTMLDivElement>(null);
return ( return (
<Box h="100%" pos="relative"> <Box h="100%" pos="relative">
<BoardBackgroundVideo /> <BoardBackgroundVideo />
<Stack h="100%"> <LoadingOverlay
visible={!isReady}
transitionProps={{ duration: 500 }}
loaderProps={{ size: "lg" }}
h={fullHeightWithoutHeaderAndFooter}
/>
<Stack ref={ref} h="100%" style={{ visibility: isReady ? "visible" : "hidden" }}>
{fullWidthSortedSections.map((section) => {fullWidthSortedSections.map((section) =>
section.kind === "empty" ? ( section.kind === "empty" ? (
// Unique keys per layout to always reinitialize the gridstack
<BoardEmptySection key={`${currentLayoutId}-${section.id}`} section={section} /> <BoardEmptySection key={`${currentLayoutId}-${section.id}`} section={section} />
) : ( ) : (
<BoardCategorySection key={`${currentLayoutId}-${section.id}`} section={section} /> <BoardCategorySection key={`${currentLayoutId}-${section.id}`} section={section} />
@@ -41,11 +41,13 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(
}), }),
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax
page: async ({ params }: { params: Promise<TParams> }) => { page: async ({ params }: { params: Promise<TParams> }) => {
const resolvedParams = await params; const session = await auth();
const integrations = await getIntegrationsWithPermissionsAsync(session);
const board = await getInitialBoard(await params);
const queryClient = getQueryClient(); const queryClient = getQueryClient();
const [board, session] = await Promise.all([getInitialBoard(resolvedParams), auth()]); // Prefetch item data
const itemsMap = board.items.reduce((acc, item) => { const itemsMap = board.items.reduce((acc, item) => {
const existing = acc.get(item.kind); const existing = acc.get(item.kind);
if (existing) { if (existing) {
@@ -56,20 +58,17 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(
return acc; return acc;
}, new Map<WidgetKind, Item[]>()); }, new Map<WidgetKind, Item[]>());
const [integrations] = await Promise.all([ for (const [kind, items] of itemsMap) {
getIntegrationsWithPermissionsAsync(session), await prefetchForKindAsync(kind, queryClient, items).catch((error) => {
...Array.from(itemsMap).map(([kind, items]) => logger.error(
prefetchForKindAsync(kind, queryClient, items).catch((error) => { new ErrorWithMetadata(
logger.error( "Failed to prefetch widget",
new ErrorWithMetadata( { widgetKind: kind, itemCount: items.length },
"Failed to prefetch widget", { cause: error },
{ widgetKind: kind, itemCount: items.length }, ),
{ cause: error }, );
), });
); }
}),
),
]);
return ( return (
<HydrationBoundary state={dehydrate(queryClient)}> <HydrationBoundary state={dehydrate(queryClient)}>
@@ -1,19 +1,42 @@
"use client"; "use client";
import type { PropsWithChildren } from "react"; import type { PropsWithChildren } from "react";
import { createContext, useCallback, useContext } from "react"; import { createContext, useCallback, useContext, useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import { clientApi } from "@homarr/api/client";
import { useRequiredBoard } from "@homarr/boards/context";
const BoardReadyContext = createContext<{ const BoardReadyContext = createContext<{
isReady: boolean;
markAsReady: (id: string) => void; markAsReady: (id: string) => void;
} | null>(null); } | null>(null);
export const BoardReadyProvider = ({ children }: PropsWithChildren) => { export const BoardReadyProvider = ({ children }: PropsWithChildren) => {
// eslint-disable-next-line @typescript-eslint/no-empty-function const pathname = usePathname();
const markAsReady = useCallback((_id: string) => {}, []); const utils = clientApi.useUtils();
const board = useRequiredBoard();
const [readySections, setReadySections] = useState<string[]>([]);
// Reset sections required for ready state
useEffect(() => {
return () => {
setReadySections([]);
};
}, [pathname, utils]);
useEffect(() => {
setReadySections((previous) => previous.filter((id) => board.sections.some((section) => section.id === id)));
}, [board.sections.length, setReadySections]);
const markAsReady = useCallback((id: string) => {
setReadySections((previous) => (previous.includes(id) ? previous : [...previous, id]));
}, []);
return ( return (
<BoardReadyContext.Provider <BoardReadyContext.Provider
value={{ value={{
isReady: board.sections.length === readySections.length,
markAsReady, markAsReady,
}} }}
> >
@@ -31,3 +54,13 @@ export const useMarkSectionAsReady = () => {
return context.markAsReady; return context.markAsReady;
}; };
export const useIsBoardReady = () => {
const context = useContext(BoardReadyContext);
if (!context) {
throw new Error("BoardReadyProvider is required");
}
return context.isReady;
};
@@ -8,14 +8,12 @@ import { getFirstEmptyPosition } from "./empty-position";
import { getSectionElements } from "./section-elements"; import { getSectionElements } from "./section-elements";
export interface CreateItemInput { export interface CreateItemInput {
id?: string;
kind: WidgetKind; kind: WidgetKind;
options?: Record<string, unknown>; options?: Record<string, unknown>;
integrationIds?: string[];
} }
export const createItemCallback = export const createItemCallback =
({ id, kind, options = {}, integrationIds = [] }: CreateItemInput) => ({ kind, options = {} }: CreateItemInput) =>
(previous: Board): Board => { (previous: Board): Board => {
const firstSection = previous.sections const firstSection = previous.sections
.filter((section): section is EmptySection => section.kind === "empty") .filter((section): section is EmptySection => section.kind === "empty")
@@ -25,11 +23,11 @@ export const createItemCallback =
if (!firstSection) return previous; if (!firstSection) return previous;
const widget = { const widget = {
id: id ?? createId(), id: createId(),
kind, kind,
options, options,
layouts: createItemLayouts(previous, firstSection), layouts: createItemLayouts(previous, firstSection),
integrationIds, integrationIds: [],
advancedOptions: { advancedOptions: {
title: null, title: null,
customCssClasses: [], customCssClasses: [],
@@ -2,26 +2,20 @@ import { useMemo, useState } from "react";
import { Avatar, Button, Card, Center, Grid, Group, Input, Stack, Text, Tooltip } from "@mantine/core"; import { Avatar, Button, Card, Center, Grid, Group, Input, Stack, Text, Tooltip } from "@mantine/core";
import { IconSearch } from "@tabler/icons-react"; import { IconSearch } from "@tabler/icons-react";
import { clientApi } from "@homarr/api/client"; import { objectEntries } from "@homarr/common";
import { createId, objectEntries } from "@homarr/common";
import { getIconUrl, getIntegrationName } from "@homarr/definitions"; import { getIconUrl, getIntegrationName } from "@homarr/definitions";
import type { IntegrationKind, WidgetKind } from "@homarr/definitions"; import type { IntegrationKind, WidgetKind } from "@homarr/definitions";
import { createModal, useModalAction } from "@homarr/modals"; import { createModal } from "@homarr/modals";
import { useSettings } from "@homarr/settings";
import { useI18n } from "@homarr/translation/client"; import { useI18n } from "@homarr/translation/client";
import type { TablerIcon } from "@homarr/ui"; import type { TablerIcon } from "@homarr/ui";
import { reduceWidgetOptionsWithDefaultValues, widgetImports } from "@homarr/widgets"; import { widgetImports } from "@homarr/widgets";
import { WidgetEditModal } from "@homarr/widgets/modals";
import { useItemActions } from "./item-actions"; import { useItemActions } from "./item-actions";
export const ItemSelectModal = createModal<void>(({ actions }) => { export const ItemSelectModal = createModal<void>(({ actions }) => {
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const t = useI18n(); const t = useI18n();
const { createItem, updateItemOptions, updateItemAdvancedOptions, updateItemIntegrations } = useItemActions(); const { createItem } = useItemActions();
const { openModal: openEditModal } = useModalAction(WidgetEditModal);
const { data: integrationData } = clientApi.integration.all.useQuery();
const settings = useSettings();
const items = useMemo( const items = useMemo(
() => () =>
@@ -46,43 +40,8 @@ export const ItemSelectModal = createModal<void>(({ actions }) => {
); );
const handleAdd = (kind: WidgetKind) => { const handleAdd = (kind: WidgetKind) => {
const definition = widgetImports[kind].definition; createItem({ kind });
const hasIntegrationSupport = "supportedIntegrations" in definition;
const matchingIntegrations = hasIntegrationSupport
? (integrationData ?? []).filter((integration) =>
(definition.supportedIntegrations as string[]).includes(integration.kind),
)
: [];
const integrationIds = matchingIntegrations.map((i) => i.id);
const itemId = createId();
const defaultOptions = reduceWidgetOptionsWithDefaultValues(kind, settings);
createItem({ id: itemId, kind, integrationIds });
actions.closeModal(); actions.closeModal();
openEditModal(
{
kind,
value: {
advancedOptions: { title: null, customCssClasses: [], borderColor: "" },
options: defaultOptions,
integrationIds,
},
onSuccessfulEdit: ({ options, integrationIds: newIntegrationIds, advancedOptions }) => {
updateItemOptions({ itemId, newOptions: options });
updateItemAdvancedOptions({ itemId, newAdvancedOptions: advancedOptions });
updateItemIntegrations({ itemId, newIntegrations: newIntegrationIds });
},
integrationData: matchingIntegrations,
integrationSupport: hasIntegrationSupport,
settings,
},
{
title: (titleT) => `${titleT("item.edit.title")} - ${titleT(`widget.${kind}.name`)}`,
},
);
}; };
return ( return (
@@ -3,7 +3,6 @@ import { useDisclosure } from "@mantine/hooks";
import { IconChevronDown, IconChevronUp } from "@tabler/icons-react"; import { IconChevronDown, IconChevronUp } from "@tabler/icons-react";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
import { useSession } from "@homarr/auth/client";
import { useRequiredBoard } from "@homarr/boards/context"; import { useRequiredBoard } from "@homarr/boards/context";
import type { CategorySection } from "~/app/[locale]/boards/_types"; import type { CategorySection } from "~/app/[locale]/boards/_types";
@@ -11,36 +10,19 @@ import { CategoryMenu } from "./category/category-menu";
import { GridStack } from "./gridstack/gridstack"; import { GridStack } from "./gridstack/gridstack";
import classes from "./item.module.css"; import classes from "./item.module.css";
const localStorageKey = (sectionId: string) => `homarr-section-collapsed-${sectionId}`;
interface Props { interface Props {
section: CategorySection; section: CategorySection;
} }
export const BoardCategorySection = ({ section }: Props) => { export const BoardCategorySection = ({ section }: Props) => {
const { status } = useSession();
const { mutate } = clientApi.section.changeCollapsed.useMutation(); const { mutate } = clientApi.section.changeCollapsed.useMutation();
const board = useRequiredBoard(); const board = useRequiredBoard();
const [opened, { toggle }] = useDisclosure(section.collapsed, {
const initialCollapsed =
typeof window !== "undefined"
? (localStorage.getItem(localStorageKey(section.id)) ?? String(section.collapsed)) === "true"
: section.collapsed;
const [opened, { toggle }] = useDisclosure(initialCollapsed, {
onOpen() { onOpen() {
if (status === "authenticated") { mutate({ sectionId: section.id, collapsed: true });
mutate({ sectionId: section.id, collapsed: true });
} else if (status === "unauthenticated") {
localStorage.setItem(localStorageKey(section.id), "true");
}
}, },
onClose() { onClose() {
if (status === "authenticated") { mutate({ sectionId: section.id, collapsed: false });
mutate({ sectionId: section.id, collapsed: false });
} else if (status === "unauthenticated") {
localStorage.setItem(localStorageKey(section.id), "false");
}
}, },
}); });
@@ -44,7 +44,6 @@ export const BoardBackgroundVideo = () => {
muted muted
loop loop
playsInline playsInline
aria-hidden="true"
style={{ style={{
position: "fixed", position: "fixed",
width: "100vw", width: "100vw",
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["tasks.cjs"],
},
...baseConfig,
];
+9 -4
View File
@@ -4,19 +4,20 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"main": "./src/main.ts",
"types": "./src/main.ts",
"exports": { "exports": {
".": "./src/main.ts" ".": "./src/main.ts"
}, },
"main": "./src/main.ts",
"types": "./src/main.ts",
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"dev": "pnpm with-env tsx ./src/main.ts", "dev": "pnpm with-env tsx ./src/main.ts",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --" "with-env": "dotenv -e ../../.env --"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/analytics": "workspace:^0.1.0", "@homarr/analytics": "workspace:^0.1.0",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -42,10 +43,14 @@
"undici": "catalog:" "undici": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/node": "catalog:", "@types/node": "catalog:",
"dotenv-cli": "catalog:", "dotenv-cli": "catalog:",
"esbuild": "catalog:", "esbuild": "catalog:",
"eslint": "catalog:",
"prettier": "catalog:",
"tsx": "catalog:", "tsx": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
+108
View File
@@ -0,0 +1,108 @@
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { handshakeAsync } from "@homarr/redis";
import { waitForRedisAsync } from "./main";
const { mockLogger } = vi.hoisted(() => ({
mockLogger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
},
}));
vi.mock("./overrides", () => ({}));
vi.mock("@homarr/core/infrastructure/logs", () => ({
createLogger: () => mockLogger,
}));
vi.mock("@homarr/redis", () => ({
handshakeAsync: vi.fn(),
}));
vi.mock("@homarr/cron-jobs", () => ({
jobGroup: {
initializeAsync: vi.fn().mockResolvedValue(undefined),
startAllAsync: vi.fn().mockResolvedValue(undefined),
},
}));
vi.mock("./on-start", () => ({
onStartAsync: vi.fn().mockResolvedValue(undefined),
}));
describe("waitForRedisAsync", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
test("succeeds on first attempt", async () => {
vi.mocked(handshakeAsync).mockResolvedValueOnce(undefined);
await waitForRedisAsync();
expect(handshakeAsync).toHaveBeenCalledOnce();
expect(mockLogger.info).toHaveBeenCalledWith("Redis connection established");
});
test("retries on failure then succeeds", async () => {
vi.mocked(handshakeAsync)
.mockRejectedValueOnce(new Error("ECONNREFUSED"))
.mockRejectedValueOnce(new Error("ECONNREFUSED"))
.mockResolvedValueOnce(undefined);
const promise = waitForRedisAsync();
await vi.advanceTimersByTimeAsync(500);
await vi.advanceTimersByTimeAsync(500);
await promise;
expect(handshakeAsync).toHaveBeenCalledTimes(3);
expect(mockLogger.warn).toHaveBeenCalledTimes(2);
expect(mockLogger.info).toHaveBeenCalledWith("Redis connection established");
});
test("logs error and proceeds after max retries exhausted", async () => {
vi.mocked(handshakeAsync).mockRejectedValue(new Error("ECONNREFUSED"));
const promise = waitForRedisAsync();
for (let index = 0; index < 10; index++) {
await vi.advanceTimersByTimeAsync(500);
}
await promise;
expect(handshakeAsync).toHaveBeenCalledTimes(10);
expect(mockLogger.error).toHaveBeenCalledWith("Redis did not become ready after retries, proceeding anyway");
expect(mockLogger.info).not.toHaveBeenCalled();
});
test("warns with attempt count on each retry", async () => {
vi.mocked(handshakeAsync).mockRejectedValueOnce(new Error("fail")).mockResolvedValueOnce(undefined);
const promise = waitForRedisAsync();
await vi.advanceTimersByTimeAsync(500);
await promise;
expect(mockLogger.warn).toHaveBeenCalledWith("Redis not ready, retrying (1/10)...");
});
test("does not retry after success", async () => {
vi.mocked(handshakeAsync).mockResolvedValueOnce(undefined);
await waitForRedisAsync();
expect(handshakeAsync).toHaveBeenCalledOnce();
expect(mockLogger.warn).not.toHaveBeenCalled();
expect(mockLogger.error).not.toHaveBeenCalled();
});
});
+22
View File
@@ -1,11 +1,33 @@
// This import has to be the first import in the file so that the agent is overridden before any other modules are imported. // This import has to be the first import in the file so that the agent is overridden before any other modules are imported.
import "./overrides"; import "./overrides";
import { createLogger } from "@homarr/core/infrastructure/logs";
import { jobGroup } from "@homarr/cron-jobs"; import { jobGroup } from "@homarr/cron-jobs";
import { handshakeAsync } from "@homarr/redis";
import { onStartAsync } from "./on-start"; import { onStartAsync } from "./on-start";
const logger = createLogger({ module: "tasks" });
const MAX_RETRIES = 10;
const RETRY_DELAY_MS = 500;
export const waitForRedisAsync = async () => {
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
try {
await handshakeAsync();
logger.info("Redis connection established");
return;
} catch {
logger.warn(`Redis not ready, retrying (${attempt}/${MAX_RETRIES})...`);
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
}
}
logger.error("Redis did not become ready after retries, proceeding anyway");
};
void (async () => { void (async () => {
await waitForRedisAsync();
await onStartAsync(); await onStartAsync();
await jobGroup.initializeAsync(); await jobGroup.initializeAsync();
await jobGroup.startAllAsync(); await jobGroup.startAllAsync();
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["wssServer.cjs"],
},
...baseConfig,
];
+9 -4
View File
@@ -4,19 +4,20 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"main": "./src/main.ts",
"types": "./src/main.ts",
"exports": { "exports": {
".": "./src/main.ts" ".": "./src/main.ts"
}, },
"main": "./src/main.ts",
"types": "./src/main.ts",
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"dev": "pnpm with-env tsx ./src/main.ts", "dev": "pnpm with-env tsx ./src/main.ts",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --" "with-env": "dotenv -e ../../.env --"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -31,9 +32,13 @@
"ws": "catalog:" "ws": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/ws": "catalog:", "@types/ws": "catalog:",
"esbuild": "catalog:", "esbuild": "catalog:",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+1 -1
View File
@@ -4,11 +4,11 @@
"dependencies": { "dependencies": {
"better-sqlite3": "^12.10.0" "better-sqlite3": "^12.10.0"
}, },
"packageManager": "pnpm@10.33.4",
"engines": { "engines": {
"node": ">=24.15.0", "node": ">=24.15.0",
"pnpm": ">=10.33.4" "pnpm": ">=10.33.4"
}, },
"packageManager": "pnpm@10.33.4",
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [
"better-sqlite3" "better-sqlite3"
+1 -1
View File
@@ -51,4 +51,4 @@ services:
volumes: volumes:
mysql_data: mysql_data:
postgresql_data: postgresql_data:
+12 -10
View File
@@ -1,6 +1,6 @@
{ {
"name": "homarr", "name": "homarr",
"version": "1.61.1", "version": "1.61.1-beta.1",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "cross-env CI=true turbo build", "build": "cross-env CI=true turbo build",
@@ -17,11 +17,12 @@
"db:studio": "pnpm -F db studio", "db:studio": "pnpm -F db studio",
"dev": "pnpm -F nextjs dev", "dev": "pnpm -F nextjs dev",
"docker:dev": "docker compose -f ./development/development.docker-compose.yml up", "docker:dev": "docker compose -f ./development/development.docker-compose.yml up",
"format": "turbo format --continue", "format": "turbo format --continue -- --cache --cache-location node_modules/.cache/.prettiercache",
"format:fix": "turbo format --continue -- --write", "format:fix": "turbo format --continue -- --write --cache --cache-location node_modules/.cache/.prettiercache",
"lint": "turbo lint --continue", "lint": "turbo lint --continue -- --cache --cache-location node_modules/.cache/.eslintcache",
"lint:fix": "turbo lint --continue -- --fix", "lint:fix": "turbo lint --continue -- --fix --cache --cache-location node_modules/.cache/.eslintcache",
"lint:ws": "pnpm dlx sherif@latest", "lint:ws": "pnpm dlx sherif@latest",
"package:new": "turbo gen init",
"release": "semantic-release", "release": "semantic-release",
"scripts:update-bug-report-template": "tsx ./scripts/update-bug-report-template.mts", "scripts:update-bug-report-template": "tsx ./scripts/update-bug-report-template.mts",
"scripts:update-readme-integrations": "tsx ./scripts/update-integration-list.mts", "scripts:update-readme-integrations": "tsx ./scripts/update-integration-list.mts",
@@ -32,7 +33,9 @@
"typecheck": "turbo typecheck", "typecheck": "turbo typecheck",
"with-env": "dotenv -e .env --" "with-env": "dotenv -e .env --"
}, },
"prettier": "@homarr/prettier-config",
"devDependencies": { "devDependencies": {
"@homarr/prettier-config": "workspace:^0.1.0",
"@playwright/test": "catalog:", "@playwright/test": "catalog:",
"@semantic-release/changelog": "catalog:", "@semantic-release/changelog": "catalog:",
"@semantic-release/commit-analyzer": "catalog:", "@semantic-release/commit-analyzer": "catalog:",
@@ -49,8 +52,7 @@
"cross-env": "catalog:", "cross-env": "catalog:",
"jsdom": "catalog:", "jsdom": "catalog:",
"json5": "catalog:", "json5": "catalog:",
"oxfmt": "catalog:", "prettier": "catalog:",
"oxlint": "catalog:",
"semantic-release": "catalog:", "semantic-release": "catalog:",
"testcontainers": "catalog:", "testcontainers": "catalog:",
"turbo": "catalog:", "turbo": "catalog:",
@@ -58,11 +60,11 @@
"vite-tsconfig-paths": "catalog:", "vite-tsconfig-paths": "catalog:",
"vitest": "catalog:" "vitest": "catalog:"
}, },
"packageManager": "pnpm@10.33.4",
"engines": { "engines": {
"node": ">=24.15.0", "node": ">=24.15.0",
"pnpm": ">=10.33.4" "pnpm": ">=10.33.4"
}, },
"packageManager": "pnpm@10.33.4",
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [
"@tree-sitter-grammars/tree-sitter-yaml", "@tree-sitter-grammars/tree-sitter-yaml",
@@ -83,7 +85,7 @@
"brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.6", "brace-expansion@>=1.0.0 <=1.1.11": ">=5.0.6",
"esbuild@<=0.24.2": ">=0.28.0", "esbuild@<=0.24.2": ">=0.28.0",
"form-data@>=4.0.0 <4.0.4": ">=4.0.5", "form-data@>=4.0.0 <4.0.4": ">=4.0.5",
"hono@<4.6.5": ">=4.12.21", "hono@<4.6.5": ">=4.12.19",
"linkifyjs@<4.3.2": ">=4.3.3", "linkifyjs@<4.3.2": ">=4.3.3",
"nanoid@>=4.0.0 <5.0.9": ">=5.1.11", "nanoid@>=4.0.0 <5.0.9": ">=5.1.11",
"prismjs@<1.30.0": ">=1.30.0", "prismjs@<1.30.0": ">=1.30.0",
@@ -94,7 +96,7 @@
"tar-fs@>=3.0.0 <3.0.9": ">=3.1.2", "tar-fs@>=3.0.0 <3.0.9": ">=3.1.2",
"tar-fs@>=2.0.0 <2.1.3": ">=3.1.2", "tar-fs@>=2.0.0 <2.1.3": ">=3.1.2",
"tmp@<=0.2.3": ">=0.2.5", "tmp@<=0.2.3": ">=0.2.5",
"vite@>=5.0.0 <=5.4.18": ">=8.0.14" "vite@>=5.0.0 <=5.4.18": ">=8.0.13"
}, },
"patchedDependencies": { "patchedDependencies": {
"@types/node-unifi": "patches/@types__node-unifi.patch", "@types/node-unifi": "patches/@types__node-unifi.patch",
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
@@ -31,7 +32,10 @@
"superjson": "catalog:" "superjson": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -4
View File
@@ -4,8 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": { "exports": {
".": "./src/index.ts", ".": "./src/index.ts",
"./client": "./src/client.ts", "./client": "./src/client.ts",
@@ -14,12 +12,15 @@
"./shared": "./src/shared.ts", "./shared": "./src/shared.ts",
"./open-api": "./src/open-api.ts" "./open-api": "./src/open-api.ts"
}, },
"main": "./index.ts",
"types": "./index.ts",
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
@@ -54,7 +55,11 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -4
View File
@@ -4,8 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"main": "./index.ts",
"types": "./index.ts",
"exports": { "exports": {
".": "./index.ts", ".": "./index.ts",
"./next": "./next.ts", "./next": "./next.ts",
@@ -16,12 +14,15 @@
"./shared": "./shared.ts", "./shared": "./shared.ts",
"./env": "./env.ts" "./env": "./env.ts"
}, },
"main": "./index.ts",
"types": "./index.ts",
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@auth/core": "catalog:", "@auth/core": "catalog:",
"@auth/drizzle-adapter": "catalog:", "@auth/drizzle-adapter": "catalog:",
@@ -40,9 +41,13 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/bcrypt": "catalog:", "@types/bcrypt": "catalog:",
"@types/cookies": "catalog:", "@types/cookies": "catalog:",
"eslint": "catalog:",
"prettier": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+11 -7
View File
@@ -4,6 +4,11 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
"./context": "./src/context.tsx",
"./updater": "./src/updater.ts",
"./edit-mode": "./src/edit-mode.tsx"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,24 +16,23 @@
] ]
} }
}, },
"exports": {
"./context": "./src/context.tsx",
"./updater": "./src/updater.ts",
"./edit-mode": "./src/edit-mode.tsx"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"react": "catalog:", "react": "catalog:",
"react-dom": "catalog:" "react-dom": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,18 +14,16 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --loader:.html=text --loader:.node=text", "build": "esbuild src/index.ts --bundle --platform=node --outfile=cli.cjs --external:bcrypt --external:cpu-features --loader:.html=text --loader:.node=text",
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"run": "pnpm with-env node cli.cjs", "run": "pnpm with-env node cli.cjs",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"with-env": "dotenv -e .env --" "with-env": "dotenv -e .env --"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@drizzle-team/brocli": "catalog:", "@drizzle-team/brocli": "catalog:",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -32,8 +33,11 @@
"dotenv": "catalog:" "dotenv": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"esbuild": "catalog:", "esbuild": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+13 -9
View File
@@ -4,13 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"exports": { "exports": {
".": "./index.ts", ".": "./index.ts",
"./types": "./src/types.ts", "./types": "./src/types.ts",
@@ -18,12 +11,20 @@
"./client": "./src/client.ts", "./client": "./src/client.ts",
"./env": "./env.ts" "./env": "./env.ts"
}, },
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/core": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0",
"@paralleldrive/cuid2": "catalog:", "@paralleldrive/cuid2": "catalog:",
@@ -38,7 +39,10 @@
"zod-validation-error": "catalog:" "zod-validation-error": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+13 -9
View File
@@ -4,13 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"exports": { "exports": {
"./infrastructure/redis": "./src/infrastructure/redis/client.ts", "./infrastructure/redis": "./src/infrastructure/redis/client.ts",
"./infrastructure/env": "./src/infrastructure/env/index.ts", "./infrastructure/env": "./src/infrastructure/env/index.ts",
@@ -29,12 +22,20 @@
"./infrastructure/http": "./src/infrastructure/http/index.ts", "./infrastructure/http": "./src/infrastructure/http/index.ts",
"./infrastructure/http/timeout": "./src/infrastructure/http/timeout.ts" "./infrastructure/http/timeout": "./src/infrastructure/http/timeout.ts"
}, },
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@t3-oss/env-nextjs": "catalog:", "@t3-oss/env-nextjs": "catalog:",
"better-sqlite3": "catalog:", "better-sqlite3": "catalog:",
@@ -48,9 +49,12 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/better-sqlite3": "catalog:", "@types/better-sqlite3": "catalog:",
"@types/pg": "catalog:", "@types/pg": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -5,6 +5,7 @@ import { redisEnv } from "./env";
const defaultRedisOptions = { const defaultRedisOptions = {
connectionName: "homarr", connectionName: "homarr",
lazyConnect: true,
} satisfies RedisOptions; } satisfies RedisOptions;
export type { Redis as RedisClient } from "ioredis"; export type { Redis as RedisClient } from "ioredis";
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./publisher": "./src/publisher.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,21 +15,21 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./publisher": "./src/publisher.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/redis": "workspace:^0.1.0" "@homarr/redis": "workspace:^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+11 -7
View File
@@ -4,6 +4,11 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./expressions": "./src/expressions.ts",
"./logger": "./src/logger.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,17 +16,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./expressions": "./src/expressions.ts",
"./logger": "./src/logger.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^", "@homarr/core": "workspace:^",
@@ -29,7 +30,10 @@
"croner": "catalog:" "croner": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./job-manager": "./src/job-manager.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,16 +15,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./job-manager": "./src/job-manager.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/analytics": "workspace:^0.1.0", "@homarr/analytics": "workspace:^0.1.0",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -42,7 +43,10 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -4
View File
@@ -4,8 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"main": "./index.ts",
"types": "./index.ts",
"exports": { "exports": {
".": "./index.ts", ".": "./index.ts",
"./collection": "./collection.ts", "./collection": "./collection.ts",
@@ -14,14 +12,16 @@
"./queries": "./queries/index.ts", "./queries": "./queries/index.ts",
"./validationSchemas": "./validationSchemas.ts" "./validationSchemas": "./validationSchemas.ts"
}, },
"main": "./index.ts",
"types": "./index.ts",
"scripts": { "scripts": {
"build": "pnpm run build:sqlite && pnpm run build:mysql && pnpm run build:postgresql", "build": "pnpm run build:sqlite && pnpm run build:mysql && pnpm run build:postgresql",
"build:mysql": "esbuild migrations/mysql/migrate.ts --bundle --platform=node --outfile=migrations/mysql/migrate.cjs", "build:mysql": "esbuild migrations/mysql/migrate.ts --bundle --platform=node --outfile=migrations/mysql/migrate.cjs",
"build:postgresql": "esbuild migrations/postgresql/migrate.ts --bundle --platform=node --outfile=migrations/postgresql/migrate.cjs", "build:postgresql": "esbuild migrations/postgresql/migrate.ts --bundle --platform=node --outfile=migrations/postgresql/migrate.cjs",
"build:sqlite": "esbuild migrations/sqlite/migrate.ts --bundle --platform=node --outfile=migrations/sqlite/migrate.cjs", "build:sqlite": "esbuild migrations/sqlite/migrate.ts --bundle --platform=node --outfile=migrations/sqlite/migrate.cjs",
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"migration:custom": "pnpm with-env tsx ./migrations/custom/run-custom.ts", "migration:custom": "pnpm with-env tsx ./migrations/custom/run-custom.ts",
"migration:mysql:drop": "pnpm with-env drizzle-kit drop --config ./configs/mysql.config.ts", "migration:mysql:drop": "pnpm with-env drizzle-kit drop --config ./configs/mysql.config.ts",
"migration:mysql:generate": "pnpm with-env drizzle-kit generate --config ./configs/mysql.config.ts", "migration:mysql:generate": "pnpm with-env drizzle-kit generate --config ./configs/mysql.config.ts",
@@ -42,6 +42,7 @@
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --" "with-env": "dotenv -e ../../.env --"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@auth/core": "catalog:", "@auth/core": "catalog:",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
@@ -62,11 +63,15 @@
"superjson": "catalog:" "superjson": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/better-sqlite3": "catalog:", "@types/better-sqlite3": "catalog:",
"@types/pg": "catalog:", "@types/pg": "catalog:",
"dotenv-cli": "catalog:", "dotenv-cli": "catalog:",
"esbuild": "catalog:", "esbuild": "catalog:",
"eslint": "catalog:",
"prettier": "catalog:",
"tsx": "catalog:", "tsx": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,23 +14,24 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"postinstall": "tsx ./src/docs/codegen.ts", "postinstall": "tsx ./src/docs/codegen.ts",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"fast-xml-parser": "catalog:", "fast-xml-parser": "catalog:",
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"tsx": "catalog:", "tsx": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+11 -7
View File
@@ -4,6 +4,11 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./shared": "./src/shared.ts",
"./env": "./src/env.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,25 +16,24 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./shared": "./src/shared.ts",
"./env": "./src/env.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0",
"dockerode": "catalog:" "dockerode": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/dockerode": "catalog:", "@types/dockerode": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./types": "./src/types.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,16 +15,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./types": "./src/types.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/translation": "workspace:^0.1.0", "@homarr/translation": "workspace:^0.1.0",
@@ -30,7 +31,10 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -34,7 +35,10 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./local": "./src/local.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,23 +15,23 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./local": "./src/local.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0",
"@homarr/db": "workspace:^0.1.0" "@homarr/db": "workspace:^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./src/index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./src/index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0",
@@ -27,8 +28,11 @@
"bcrypt": "catalog:" "bcrypt": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/bcrypt": "catalog:", "@types/bcrypt": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+12 -8
View File
@@ -4,6 +4,12 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./test-connection": "./src/base/test-connection/index.ts",
"./client": "./src/client.ts",
"./types": "./src/types.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,18 +17,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./test-connection": "./src/base/test-connection/index.ts",
"./client": "./src/client.ts",
"./types": "./src/types.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@ctrl/deluge": "catalog:", "@ctrl/deluge": "catalog:",
"@ctrl/qbittorrent": "catalog:", "@ctrl/qbittorrent": "catalog:",
@@ -51,9 +52,12 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/node-unifi": "catalog:", "@types/node-unifi": "catalog:",
"@types/xml2js": "catalog:", "@types/xml2js": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
@@ -41,7 +42,10 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+5
View File
@@ -0,0 +1,5 @@
import baseConfig from "@homarr/eslint-config/base";
import reactConfig from "@homarr/eslint-config/react";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig, ...reactConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/translation": "workspace:^0.1.0", "@homarr/translation": "workspace:^0.1.0",
"@homarr/ui": "workspace:^0.1.0", "@homarr/ui": "workspace:^0.1.0",
@@ -28,7 +29,10 @@
"react": "catalog:" "react": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,23 +15,23 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/ui": "workspace:^0.1.0", "@homarr/ui": "workspace:^0.1.0",
"@mantine/notifications": "catalog:", "@mantine/notifications": "catalog:",
"@tabler/icons-react": "catalog:" "@tabler/icons-react": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+13 -9
View File
@@ -4,13 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"exports": { "exports": {
".": "./index.ts", ".": "./index.ts",
"./analyse": "./src/analyse/index.ts", "./analyse": "./src/analyse/index.ts",
@@ -18,12 +11,20 @@
"./import": "./src/import/index.ts", "./import": "./src/import/index.ts",
"./shared": "./src/shared.ts" "./shared": "./src/shared.ts"
}, },
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0",
@@ -47,8 +48,11 @@
"zod-form-data": "catalog:" "zod-form-data": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/adm-zip": "catalog:", "@types/adm-zip": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,21 +14,22 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,21 +14,22 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/core": "workspace:^0.1.0" "@homarr/core": "workspace:^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^", "@homarr/common": "workspace:^",
"@homarr/core": "workspace:^", "@homarr/core": "workspace:^",
@@ -29,7 +30,10 @@
"superjson": "catalog:" "superjson": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -0,0 +1,102 @@
import { beforeEach, describe, expect, test, vi } from "vitest";
import { ChannelSubscriptionTracker } from "./channel-subscription-tracker";
import { createRedisConnection } from "./connection";
const mockRedisClient = {
subscribe: vi.fn().mockResolvedValue("OK"),
unsubscribe: vi.fn().mockResolvedValue("OK"),
on: vi.fn(),
};
vi.mock("@homarr/core/infrastructure/logs", () => ({
createLogger: () => ({ debug: vi.fn(), warn: vi.fn() }),
}));
vi.mock("./connection", () => ({
createRedisConnection: vi.fn(() => mockRedisClient),
}));
describe("ChannelSubscriptionTracker", () => {
beforeEach(() => {
vi.clearAllMocks();
// Reset static state between tests
// @ts-expect-error accessing private static for test reset
ChannelSubscriptionTracker.subscriptions = new Map();
// @ts-expect-error accessing private static for test reset
ChannelSubscriptionTracker._redis = undefined;
// @ts-expect-error accessing private static for test reset
ChannelSubscriptionTracker.listenerActive = false;
});
test("redis client is lazily created on first subscribe", () => {
vi.mocked(createRedisConnection).mockClear();
ChannelSubscriptionTracker.subscribe("channel-1", vi.fn());
expect(createRedisConnection).toHaveBeenCalledOnce();
});
test("redis client is reused across multiple subscribes", () => {
vi.mocked(createRedisConnection).mockClear();
ChannelSubscriptionTracker.subscribe("channel-1", vi.fn());
ChannelSubscriptionTracker.subscribe("channel-2", vi.fn());
expect(createRedisConnection).toHaveBeenCalledOnce();
});
test("subscribes to redis channel on first callback for a channel", () => {
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
expect(mockRedisClient.subscribe).toHaveBeenCalledWith("test-channel");
});
test("does not re-subscribe when adding second callback to same channel", () => {
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
mockRedisClient.subscribe.mockClear();
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
expect(mockRedisClient.subscribe).not.toHaveBeenCalled();
});
test("unsubscribe function removes the callback", () => {
const unsubscribe = ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
unsubscribe();
expect(mockRedisClient.unsubscribe).toHaveBeenCalledWith("test-channel");
});
test("does not unsubscribe from redis if other callbacks remain", () => {
ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
const unsubscribe = ChannelSubscriptionTracker.subscribe("test-channel", vi.fn());
unsubscribe();
expect(mockRedisClient.unsubscribe).not.toHaveBeenCalled();
});
test("activates message listener only once", () => {
ChannelSubscriptionTracker.subscribe("ch-1", vi.fn());
ChannelSubscriptionTracker.subscribe("ch-2", vi.fn());
expect(mockRedisClient.on).toHaveBeenCalledTimes(1);
expect(mockRedisClient.on).toHaveBeenCalledWith("message", expect.any(Function));
});
test("message listener dispatches to correct channel callbacks", () => {
const callback1 = vi.fn();
const callback2 = vi.fn();
ChannelSubscriptionTracker.subscribe("channel-a", callback1);
ChannelSubscriptionTracker.subscribe("channel-b", callback2);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const messageHandler = mockRedisClient.on.mock.calls[0]![1] as (channel: string, message: string) => void;
messageHandler("channel-a", "test-message");
expect(callback1).toHaveBeenCalledWith("test-message");
expect(callback2).not.toHaveBeenCalled();
});
});
@@ -2,6 +2,7 @@ import { randomUUID } from "crypto";
import type { MaybePromise } from "@homarr/common/types"; import type { MaybePromise } from "@homarr/common/types";
import { createLogger } from "@homarr/core/infrastructure/logs"; import { createLogger } from "@homarr/core/infrastructure/logs";
import type { RedisClient } from "@homarr/core/infrastructure/redis";
import { createRedisConnection } from "./connection"; import { createRedisConnection } from "./connection";
@@ -18,7 +19,10 @@ type SubscriptionCallback = (message: string) => MaybePromise<void>;
*/ */
export class ChannelSubscriptionTracker { export class ChannelSubscriptionTracker {
private static subscriptions = new Map<string, Map<string, SubscriptionCallback>>(); private static subscriptions = new Map<string, Map<string, SubscriptionCallback>>();
private static redis = createRedisConnection(); private static _redis: RedisClient | undefined;
private static get redis() {
return (this._redis ??= createRedisConnection());
}
private static listenerActive = false; private static listenerActive = false;
/** /**
+147
View File
@@ -0,0 +1,147 @@
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
createCacheChannel,
createGetSetChannel,
createListChannel,
createSubPubChannel,
handshakeAsync,
} from "./channel";
import { createRedisConnection } from "./connection";
const mockRedisClient = {
get: vi.fn().mockResolvedValue(null),
set: vi.fn().mockResolvedValue("OK"),
del: vi.fn().mockResolvedValue(1),
publish: vi.fn().mockResolvedValue(1),
lrange: vi.fn().mockResolvedValue([]),
lrem: vi.fn().mockResolvedValue(0),
lpush: vi.fn().mockResolvedValue(1),
ltrim: vi.fn().mockResolvedValue("OK"),
llen: vi.fn().mockResolvedValue(0),
hello: vi.fn().mockResolvedValue({}),
subscribe: vi.fn().mockResolvedValue("OK"),
on: vi.fn(),
};
vi.mock("@homarr/core/infrastructure/logs", () => ({
createLogger: () => ({ debug: vi.fn(), warn: vi.fn(), error: vi.fn(), info: vi.fn() }),
}));
vi.mock("./connection", () => ({
createRedisConnection: vi.fn(() => mockRedisClient),
}));
vi.mock("./channel-subscription-tracker", () => ({
ChannelSubscriptionTracker: {
subscribe: vi.fn(() => vi.fn()),
},
}));
describe("channel lazy initialization", () => {
beforeEach(() => {
vi.mocked(createRedisConnection).mockClear();
});
test("getSetClient is lazily created on first channel operation", async () => {
vi.mocked(createRedisConnection).mockClear();
const channel = createGetSetChannel<string>("test-lazy");
expect(createRedisConnection).not.toHaveBeenCalled();
await channel.getAsync();
expect(createRedisConnection).toHaveBeenCalled();
});
test("publisher is lazily created on first publish", async () => {
const channel = createSubPubChannel<string>("test-pub", { persist: false });
const callsBefore = vi.mocked(createRedisConnection).mock.calls.length;
await channel.publishAsync("hello");
expect(vi.mocked(createRedisConnection).mock.calls.length).toBeGreaterThan(callsBefore);
});
test("handshakeAsync creates a client and calls hello", async () => {
await handshakeAsync();
expect(mockRedisClient.hello).toHaveBeenCalledOnce();
});
});
describe("createSubPubChannel", () => {
beforeEach(() => {
vi.clearAllMocks();
});
test("publishAsync persists data and publishes", async () => {
const channel = createSubPubChannel<{ value: number }>("test-channel");
await channel.publishAsync({ value: 42 });
expect(mockRedisClient.set).toHaveBeenCalledOnce();
expect(mockRedisClient.publish).toHaveBeenCalledOnce();
});
test("publishAsync with persist:false skips set", async () => {
const channel = createSubPubChannel<string>("no-persist", { persist: false });
await channel.publishAsync("data");
expect(mockRedisClient.set).not.toHaveBeenCalled();
expect(mockRedisClient.publish).toHaveBeenCalledOnce();
});
test("getLastDataAsync returns null when no data", async () => {
const channel = createSubPubChannel<string>("empty");
const result = await channel.getLastDataAsync();
expect(result).toBeNull();
});
});
describe("createListChannel", () => {
beforeEach(() => {
vi.clearAllMocks();
});
test("addAsync pushes to list", async () => {
const channel = createListChannel<string>("test-list");
await channel.addAsync("item1");
expect(mockRedisClient.lpush).toHaveBeenCalledOnce();
});
test("clearAsync deletes the list", async () => {
const channel = createListChannel<string>("test-list");
await channel.clearAsync();
expect(mockRedisClient.del).toHaveBeenCalledOnce();
});
});
describe("createCacheChannel", () => {
beforeEach(() => {
vi.clearAllMocks();
});
test("invalidateAsync deletes the cache key", async () => {
const channel = createCacheChannel<string>("test-cache");
await channel.invalidateAsync();
expect(mockRedisClient.del).toHaveBeenCalledWith("cache:test-cache");
});
test("getAsync returns null when no cached data", async () => {
const channel = createCacheChannel<string>("test-cache");
const result = await channel.getAsync();
expect(result).toBeNull();
});
});
+58 -54
View File
@@ -2,6 +2,7 @@ import superjson from "superjson";
import { createId, hashObjectBase64 } from "@homarr/common"; import { createId, hashObjectBase64 } from "@homarr/common";
import { createLogger } from "@homarr/core/infrastructure/logs"; import { createLogger } from "@homarr/core/infrastructure/logs";
import type { RedisClient } from "@homarr/core/infrastructure/redis";
import type { WidgetKind } from "@homarr/definitions"; import type { WidgetKind } from "@homarr/definitions";
import { ChannelSubscriptionTracker } from "./channel-subscription-tracker"; import { ChannelSubscriptionTracker } from "./channel-subscription-tracker";
@@ -9,8 +10,11 @@ import { createRedisConnection } from "./connection";
const logger = createLogger({ module: "redisChannel" }); const logger = createLogger({ module: "redisChannel" });
const publisher = createRedisConnection(); let _publisher: RedisClient | undefined;
const lastDataClient = createRedisConnection(); const getPublisher = () => (_publisher ??= createRedisConnection());
let _lastDataClient: RedisClient | undefined;
const getLastDataClient = () => (_lastDataClient ??= createRedisConnection());
/** /**
* Creates a new pub/sub channel. * Creates a new pub/sub channel.
@@ -27,34 +31,33 @@ export const createSubPubChannel = <TData>(name: string, { persist }: { persist:
*/ */
subscribe: (callback: (data: TData) => void) => { subscribe: (callback: (data: TData) => void) => {
if (persist) { if (persist) {
void lastDataClient.get(lastChannelName).then((data) => { void getLastDataClient()
if (data) { .get(lastChannelName)
callback(superjson.parse(data)); .then((data) => {
} if (data) {
}); callback(superjson.parse(data));
}
});
} }
return ChannelSubscriptionTracker.subscribe(channelName, (message) => { return ChannelSubscriptionTracker.subscribe(channelName, (message) => {
callback(superjson.parse(message)); callback(superjson.parse(message));
}); });
}, },
/**
* Publish data to the channel with last data saved.
* @param data data to be published
*/
publishAsync: async (data: TData) => { publishAsync: async (data: TData) => {
if (persist) { if (persist) {
await lastDataClient.set(lastChannelName, superjson.stringify(data)); await getLastDataClient().set(lastChannelName, superjson.stringify(data));
} }
await publisher.publish(channelName, superjson.stringify(data)); await getPublisher().publish(channelName, superjson.stringify(data));
}, },
getLastDataAsync: async () => { getLastDataAsync: async () => {
const data = await lastDataClient.get(lastChannelName); const data = await getLastDataClient().get(lastChannelName);
return data ? superjson.parse<TData>(data) : null; return data ? superjson.parse<TData>(data) : null;
}, },
}; };
}; };
const getSetClient = createRedisConnection(); let _getSetClient: RedisClient | undefined;
const getSetClient = () => (_getSetClient ??= createRedisConnection());
/** /**
* Creates a new redis channel for a list * Creates a new redis channel for a list
@@ -69,7 +72,7 @@ export const createListChannel = <TItem>(name: string) => {
* @returns an array of all items * @returns an array of all items
*/ */
getAllAsync: async () => { getAllAsync: async () => {
const items = await getSetClient.lrange(listChannelName, 0, -1); const items = await getSetClient().lrange(listChannelName, 0, -1);
return items.map((item) => superjson.parse<TItem>(item)); return items.map((item) => superjson.parse<TItem>(item));
}, },
/** /**
@@ -77,20 +80,20 @@ export const createListChannel = <TItem>(name: string) => {
* @param item item to remove * @param item item to remove
*/ */
removeAsync: async (item: TItem) => { removeAsync: async (item: TItem) => {
await getSetClient.lrem(listChannelName, 0, superjson.stringify(item)); await getSetClient().lrem(listChannelName, 0, superjson.stringify(item));
}, },
/** /**
* Clear all items from the channels list * Clear all items from the channels list
*/ */
clearAsync: async () => { clearAsync: async () => {
await getSetClient.del(listChannelName); await getSetClient().del(listChannelName);
}, },
/** /**
* Add an item to the channels list * Add an item to the channels list
* @param item item to add * @param item item to add
*/ */
addAsync: async (item: TItem) => { addAsync: async (item: TItem) => {
await getSetClient.lpush(listChannelName, superjson.stringify(item)); await getSetClient().lpush(listChannelName, superjson.stringify(item));
}, },
}; };
}; };
@@ -106,7 +109,7 @@ export const createGetSetChannel = <TData>(name: string) => {
* @returns data or null if not found * @returns data or null if not found
*/ */
getAsync: async () => { getAsync: async () => {
const data = await getSetClient.get(name); const data = await getSetClient().get(name);
return data ? superjson.parse<TData>(data) : null; return data ? superjson.parse<TData>(data) : null;
}, },
/** /**
@@ -114,13 +117,13 @@ export const createGetSetChannel = <TData>(name: string) => {
* @param data data to be stored in the channel * @param data data to be stored in the channel
*/ */
setAsync: async (data: TData) => { setAsync: async (data: TData) => {
await getSetClient.set(name, superjson.stringify(data)); await getSetClient().set(name, superjson.stringify(data));
}, },
/** /**
* Remove data from the channel * Remove data from the channel
*/ */
removeAsync: async () => { removeAsync: async () => {
await getSetClient.del(name); await getSetClient().del(name);
}, },
}; };
}; };
@@ -140,7 +143,7 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
* @returns data or null if not found or expired * @returns data or null if not found or expired
*/ */
getAsync: async () => { getAsync: async () => {
const data = await getSetClient.get(cacheChannelName); const data = await getSetClient().get(cacheChannelName);
if (!data) return null; if (!data) return null;
const parsedData = superjson.parse<{ data: TData; timestamp: Date }>(data); const parsedData = superjson.parse<{ data: TData; timestamp: Date }>(data);
@@ -156,13 +159,13 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
* @returns data or new data if not present or expired * @returns data or new data if not present or expired
*/ */
consumeAsync: async (callback: () => Promise<TData>) => { consumeAsync: async (callback: () => Promise<TData>) => {
const data = await getSetClient.get(cacheChannelName); const data = await getSetClient().get(cacheChannelName);
const getNewDataAsync = async () => { const getNewDataAsync = async () => {
logger.debug(`Cache miss for channel '${cacheChannelName}'`); logger.debug(`Cache miss for channel '${cacheChannelName}'`);
const newData = await callback(); const newData = await callback();
const result = { data: newData, timestamp: new Date() }; const result = { data: newData, timestamp: new Date() };
await getSetClient.set(cacheChannelName, superjson.stringify(result)); await getSetClient().set(cacheChannelName, superjson.stringify(result));
logger.debug(`Cache updated for channel '${cacheChannelName}'`); logger.debug(`Cache updated for channel '${cacheChannelName}'`);
return result; return result;
}; };
@@ -187,14 +190,14 @@ export const createCacheChannel = <TData>(name: string, cacheDurationMs: number
* Invalidate the cache channels data. * Invalidate the cache channels data.
*/ */
invalidateAsync: async () => { invalidateAsync: async () => {
await getSetClient.del(cacheChannelName); await getSetClient().del(cacheChannelName);
}, },
/** /**
* Set the data in the cache channel. * Set the data in the cache channel.
* @param data data to be stored in the cache channel * @param data data to be stored in the cache channel
*/ */
setAsync: async (data: TData) => { setAsync: async (data: TData) => {
await getSetClient.set(cacheChannelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().set(cacheChannelName, superjson.stringify({ data, timestamp: new Date() }));
}, },
}; };
}; };
@@ -236,12 +239,12 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
}); });
}, },
pushAsync: async (data: TData, options = { publish: false }) => { pushAsync: async (data: TData, options = { publish: false }) => {
if (options.publish) await publisher.publish(channelName, superjson.stringify(data)); if (options.publish) await getPublisher().publish(channelName, superjson.stringify(data));
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
await getSetClient.ltrim(channelName, 0, maxElements); await getSetClient().ltrim(channelName, 0, maxElements);
}, },
clearAsync: async () => { clearAsync: async () => {
await getSetClient.del(channelName); await getSetClient().del(channelName);
}, },
/** /**
* Returns a slice of the available data in the channel. * Returns a slice of the available data in the channel.
@@ -250,17 +253,17 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
* @param endIndex End index of the slice, negative values are counted from the end, defaults at end of range. * @param endIndex End index of the slice, negative values are counted from the end, defaults at end of range.
*/ */
getSliceAsync: async (startIndex = 0, endIndex = -1) => { getSliceAsync: async (startIndex = 0, endIndex = -1) => {
const range = await getSetClient.lrange(channelName, startIndex, endIndex); const range = await getSetClient().lrange(channelName, startIndex, endIndex);
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item)); return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
}, },
getSliceUntilTimeAsync: async (time: Date) => { getSliceUntilTimeAsync: async (time: Date) => {
const itemsInCollection = await getSetClient.lrange(channelName, 0, -1); const itemsInCollection = await getSetClient().lrange(channelName, 0, -1);
return itemsInCollection return itemsInCollection
.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item)) .map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item))
.filter((item) => item.timestamp < time); .filter((item) => item.timestamp < time);
}, },
getLengthAsync: async () => { getLengthAsync: async () => {
return await getSetClient.llen(channelName); return await getSetClient().llen(channelName);
}, },
name: channelName, name: channelName,
}; };
@@ -271,11 +274,11 @@ export const createChannelEventHistory = <TData>(channelName: string, maxElement
*/ */
export const createChannelEventHistoryOld = <TData>(channelName: string, maxElements = 15) => { export const createChannelEventHistoryOld = <TData>(channelName: string, maxElements = 15) => {
const popElementsOverMaxAsync = async () => { const popElementsOverMaxAsync = async () => {
const length = await getSetClient.llen(channelName); const length = await getSetClient().llen(channelName);
if (length <= maxElements) { if (length <= maxElements) {
return; return;
} }
await getSetClient.ltrim(channelName, 0, maxElements - 1); await getSetClient().ltrim(channelName, 0, maxElements - 1);
}; };
return { return {
@@ -285,33 +288,33 @@ export const createChannelEventHistoryOld = <TData>(channelName: string, maxElem
}); });
}, },
publishAndPushAsync: async (data: TData) => { publishAndPushAsync: async (data: TData) => {
await publisher.publish(channelName, superjson.stringify(data)); await getPublisher().publish(channelName, superjson.stringify(data));
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
await popElementsOverMaxAsync(); await popElementsOverMaxAsync();
}, },
pushAsync: async (data: TData) => { pushAsync: async (data: TData) => {
await getSetClient.lpush(channelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().lpush(channelName, superjson.stringify({ data, timestamp: new Date() }));
await popElementsOverMaxAsync(); await popElementsOverMaxAsync();
}, },
clearAsync: async () => { clearAsync: async () => {
await getSetClient.del(channelName); await getSetClient().del(channelName);
}, },
getLastAsync: async () => { getLastAsync: async () => {
const length = await getSetClient.llen(channelName); const length = await getSetClient().llen(channelName);
const data = await getSetClient.lrange(channelName, length - 1, length); const data = await getSetClient().lrange(channelName, length - 1, length);
if (data.length !== 1) return null; if (data.length !== 1) return null;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return superjson.parse<{ data: TData; timestamp: Date }>(data[0]!); return superjson.parse<{ data: TData; timestamp: Date }>(data[0]!);
}, },
getSliceAsync: async (startIndex: number, endIndex: number) => { getSliceAsync: async (startIndex: number, endIndex: number) => {
const range = await getSetClient.lrange(channelName, startIndex, endIndex); const range = await getSetClient().lrange(channelName, startIndex, endIndex);
return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item)); return range.map((item) => superjson.parse<{ data: TData; timestamp: Date }>(item));
}, },
getSliceUntilTimeAsync: async (time: Date) => { getSliceUntilTimeAsync: async (time: Date) => {
const length = await getSetClient.llen(channelName); const length = await getSetClient().llen(channelName);
const items: TData[] = []; const items: TData[] = [];
const itemsInCollection = await getSetClient.lrange(channelName, 0, length - 1); const itemsInCollection = await getSetClient().lrange(channelName, 0, length - 1);
for (let i = 0; i < length - 1; i++) { for (let i = 0; i < length - 1; i++) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -324,7 +327,7 @@ export const createChannelEventHistoryOld = <TData>(channelName: string, maxElem
return items; return items;
}, },
getLengthAsync: async () => { getLengthAsync: async () => {
return await getSetClient.llen(channelName); return await getSetClient().llen(channelName);
}, },
name: channelName, name: channelName,
}; };
@@ -338,14 +341,14 @@ export const createChannelWithLatestAndEvents = <TData>(channelName: string) =>
}); });
}, },
publishAndUpdateLastStateAsync: async (data: TData) => { publishAndUpdateLastStateAsync: async (data: TData) => {
await publisher.publish(channelName, superjson.stringify(data)); await getPublisher().publish(channelName, superjson.stringify(data));
await getSetClient.set(channelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().set(channelName, superjson.stringify({ data, timestamp: new Date() }));
}, },
setAsync: async (data: TData) => { setAsync: async (data: TData) => {
await getSetClient.set(channelName, superjson.stringify({ data, timestamp: new Date() })); await getSetClient().set(channelName, superjson.stringify({ data, timestamp: new Date() }));
}, },
getAsync: async () => { getAsync: async () => {
const data = await getSetClient.get(channelName); const data = await getSetClient().get(channelName);
if (!data) return null; if (!data) return null;
return superjson.parse<{ data: TData; timestamp: Date }>(data); return superjson.parse<{ data: TData; timestamp: Date }>(data);
@@ -354,7 +357,8 @@ export const createChannelWithLatestAndEvents = <TData>(channelName: string) =>
}; };
}; };
const queueClient = createRedisConnection(); let _queueClient: RedisClient | undefined;
const getQueueClient = () => (_queueClient ??= createRedisConnection());
type WithId<TItem> = TItem & { _id: string }; type WithId<TItem> = TItem & { _id: string };
@@ -366,11 +370,11 @@ type WithId<TItem> = TItem & { _id: string };
export const createQueueChannel = <TItem>(name: string) => { export const createQueueChannel = <TItem>(name: string) => {
const queueChannelName = `queue:${name}`; const queueChannelName = `queue:${name}`;
const getDataAsync = async () => { const getDataAsync = async () => {
const data = await queueClient.get(queueChannelName); const data = await getQueueClient().get(queueChannelName);
return data ? superjson.parse<WithId<TItem>[]>(data) : []; return data ? superjson.parse<WithId<TItem>[]>(data) : [];
}; };
const setDataAsync = async (data: WithId<TItem>[]) => { const setDataAsync = async (data: WithId<TItem>[]) => {
await queueClient.set(queueChannelName, superjson.stringify(data)); await getQueueClient().set(queueChannelName, superjson.stringify(data));
}; };
return { return {
@@ -417,5 +421,5 @@ export const createQueueChannel = <TItem>(name: string) => {
}; };
export const handshakeAsync = async () => { export const handshakeAsync = async () => {
await getSetClient.hello(); await getSetClient().hello();
}; };
+45
View File
@@ -0,0 +1,45 @@
import { describe, expect, test, vi } from "vitest";
import { createRedisClient } from "@homarr/core/infrastructure/redis";
import { createRedisConnection } from "./connection";
const mockRedisInstance = { ping: vi.fn() };
vi.mock("@homarr/core/infrastructure/redis", () => ({
createRedisClient: vi.fn(() => mockRedisInstance),
}));
describe("createRedisConnection", () => {
test("returns a redis client regardless of CI env", () => {
const original = process.env.CI;
process.env.CI = "true";
const client = createRedisConnection();
expect(client).toBe(mockRedisInstance);
expect(client).not.toBeNull();
process.env.CI = original;
});
test("returns a redis client when DISABLE_REDIS_LOGS is set", () => {
const original = process.env.DISABLE_REDIS_LOGS;
process.env.DISABLE_REDIS_LOGS = "true";
const client = createRedisConnection();
expect(client).toBe(mockRedisInstance);
expect(client).not.toBeNull();
process.env.DISABLE_REDIS_LOGS = original;
});
test("always delegates to createRedisClient", () => {
vi.mocked(createRedisClient).mockClear();
createRedisConnection();
expect(createRedisClient).toHaveBeenCalledOnce();
});
});
+1 -13
View File
@@ -1,15 +1,3 @@
import type { RedisClient } from "@homarr/core/infrastructure/redis";
import { createRedisClient } from "@homarr/core/infrastructure/redis"; import { createRedisClient } from "@homarr/core/infrastructure/redis";
/** export const createRedisConnection = () => createRedisClient();
* Creates a new Redis connection
* @returns redis client
*/
export const createRedisConnection = () => {
if (Boolean(process.env.CI) || Boolean(process.env.DISABLE_REDIS_LOGS)) {
// Return null if we are in CI as we don't want to connect to Redis
return null as unknown as RedisClient;
}
return createRedisClient();
};
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
"./*": "./src/*.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
"./*": "./src/*.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@extractus/feed-extractor": "catalog:", "@extractus/feed-extractor": "catalog:",
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
@@ -36,7 +37,10 @@
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,21 +14,22 @@
] ]
} }
}, },
"exports": {
".": "./index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/definitions": "workspace:^0.1.0", "@homarr/definitions": "workspace:^0.1.0",
"@homarr/translation": "workspace:^0.1.0" "@homarr/translation": "workspace:^0.1.0"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+9
View File
@@ -0,0 +1,9 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: [],
},
...baseConfig,
];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./creator": "./src/creator.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,16 +15,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./creator": "./src/creator.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/db": "workspace:^0.1.0", "@homarr/db": "workspace:^0.1.0",
"@homarr/server-settings": "workspace:^0.1.0", "@homarr/server-settings": "workspace:^0.1.0",
@@ -30,7 +31,10 @@
"react-dom": "catalog:" "react-dom": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+5
View File
@@ -0,0 +1,5 @@
import baseConfig from "@homarr/eslint-config/base";
import reactConfig from "@homarr/eslint-config/react";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig, ...reactConfig];
+10 -6
View File
@@ -4,6 +4,10 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,16 +15,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/api": "workspace:^0.1.0", "@homarr/api": "workspace:^0.1.0",
"@homarr/auth": "workspace:^0.1.0", "@homarr/auth": "workspace:^0.1.0",
@@ -43,7 +44,10 @@
"use-deep-compare-effect": "catalog:" "use-deep-compare-effect": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+13 -9
View File
@@ -4,13 +4,6 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"exports": { "exports": {
".": "./index.ts", ".": "./index.ts",
"./client": "./src/client/index.ts", "./client": "./src/client/index.ts",
@@ -19,12 +12,20 @@
"./request": "./src/request.ts", "./request": "./src/request.ts",
"./dayjs": "./src/dayjs.ts" "./dayjs": "./src/dayjs.ts"
}, },
"typesVersions": {
"*": {
"*": [
"src/*"
]
}
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/definitions": "workspace:^0.1.0", "@homarr/definitions": "workspace:^0.1.0",
@@ -37,7 +38,10 @@
"react-dom": "catalog:" "react-dom": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+74 -74
View File
@@ -159,7 +159,7 @@
"label": "Abrir resultados da busca em uma nova guia" "label": "Abrir resultados da busca em uma nova guia"
}, },
"ddgBangs": { "ddgBangs": {
"label": "Ativar bangs do DuckDuckGo" "label": ""
} }
}, },
"error": { "error": {
@@ -252,10 +252,10 @@
"changeDdgBangs": { "changeDdgBangs": {
"notification": { "notification": {
"success": { "success": {
"message": "Bangs do DuckDuckGo alternados com sucesso" "message": ""
}, },
"error": { "error": {
"message": "Não foi possível alternar os bangs do DuckDuckGo" "message": ""
} }
} }
}, },
@@ -1093,7 +1093,7 @@
}, },
"colorScheme": { "colorScheme": {
"options": { "options": {
"auto": "Automático", "auto": "",
"light": "Claro", "light": "Claro",
"dark": "Escuro" "dark": "Escuro"
} }
@@ -2111,101 +2111,101 @@
} }
}, },
"umami": { "umami": {
"name": "Umami Analytics", "name": "",
"description": "Exibir estatísticas de visitantes da sua instância do Umami", "description": "",
"visitors": "visitantes", "visitors": "",
"active": "ativos", "active": "",
"pageviews": "visualizações de página", "pageviews": "",
"visits": "visitas", "visits": "",
"bounceRate": "rejeição", "bounceRate": "",
"avgDuration": "média", "avgDuration": "",
"option": { "option": {
"websiteId": { "websiteId": {
"label": "site", "label": "",
"description": "Selecione um site monitorado pela sua instância do Umami", "description": "",
"placeholder": "Selecionar um site", "placeholder": "",
"loading": "Carregando sites...", "loading": "",
"noWebsites": "Nenhum site encontrado", "noWebsites": "",
"configureIntegrationFirst": "Conecte uma integração do Umami primeiro" "configureIntegrationFirst": ""
}, },
"timeFrame": { "timeFrame": {
"label": "Período de tempo", "label": "",
"description": "O período de tempo para exibir os dados de visitantes", "description": "",
"option": { "option": {
"today": "Hoje", "today": "",
"24h": "Últimas 24 horas", "24h": "",
"7d": "Últimos 7 dias", "7d": "",
"30d": "Últimos 30 dias", "30d": "",
"month": "Este mês", "month": "",
"lastMonth": "Mês passado" "lastMonth": ""
} }
}, },
"eventName": { "eventName": {
"label": "Evento", "label": "",
"description": "Exibir total de ocorrências de um evento específico", "description": "",
"placeholder": "Selecionar um evento", "placeholder": "",
"loading": "Carregando eventos...", "loading": "",
"noEvents": "Nenhum evento encontrado", "noEvents": "",
"none": "Nenhum evento", "none": "",
"configureWebsiteFirst": "Selecione um site primeiro para carregar os eventos" "configureWebsiteFirst": ""
}, },
"chartType": { "chartType": {
"label": "Tipo de gráfico", "label": "",
"description": "Estilo de exibição do gráfico", "description": "",
"option": { "option": {
"bar": "Gráfico de barras", "bar": "",
"sparkline": "Sparkline" "sparkline": ""
} }
}, },
"chartStyle": { "chartStyle": {
"label": "Estilo do gráfico", "label": "",
"description": "Como exibir a série de eventos no gráfico", "description": "",
"option": { "option": {
"grouped": "Lado a lado", "grouped": "",
"overlay": "Sobreposição (subconjunto)" "overlay": ""
} }
}, },
"viewMode": { "viewMode": {
"label": "Visualização", "label": "",
"description": "O que exibir no corpo do widget", "description": "",
"option": { "option": {
"chart": "Gráfico", "chart": "",
"events": "Gráfico de eventos", "events": "",
"topPages": "Principais páginas", "topPages": "",
"topReferrers": "Principais referenciadores" "topReferrers": ""
} }
}, },
"eventNames": { "eventNames": {
"label": "Eventos", "label": "",
"description": "Selecione um ou mais eventos para o gráfico", "description": "",
"placeholder": "Selecionar eventos...", "placeholder": "",
"loading": "Carregando eventos...", "loading": "",
"noEvents": "Nenhum evento encontrado", "noEvents": "",
"configureWebsiteFirst": "Selecione um site primeiro para carregar os eventos" "configureWebsiteFirst": ""
}, },
"topCount": { "topCount": {
"label": "Itens para exibir", "label": "",
"description": "Número de itens principais para exibir (máx 500)" "description": ""
} }
}, },
"event": { "event": {
"occurrences": "Eventos", "occurrences": "",
"label": "Eventos" "label": ""
}, },
"topPages": { "topPages": {
"direct": "Direto" "direct": ""
}, },
"topReferrers": { "topReferrers": {
"direct": "Direto" "direct": ""
}, },
"events": { "events": {
"selectPrompt": "Selecionar eventos para o gráfico" "selectPrompt": ""
}, },
"error": { "error": {
"noIntegration": "Nenhuma integração Umami configurada", "noIntegration": "",
"noWebsite": "Nenhum site configurado", "noWebsite": "",
"noData": "Nenhum dado disponível", "noData": "",
"internalServerError": "Falha ao buscar dados do Umami" "internalServerError": ""
} }
}, },
"common": { "common": {
@@ -3680,7 +3680,7 @@
"defaultColorScheme": { "defaultColorScheme": {
"label": "Esquema de cores padrão", "label": "Esquema de cores padrão",
"options": { "options": {
"auto": "Automático", "auto": "",
"light": "Claro", "light": "Claro",
"dark": "Escuro" "dark": "Escuro"
} }
@@ -3783,7 +3783,7 @@
"label": "Tracearr" "label": "Tracearr"
}, },
"umamiActiveVisitors": { "umamiActiveVisitors": {
"label": "Visitantes Ativos do Umami" "label": ""
} }
}, },
"interval": { "interval": {
@@ -3972,7 +3972,7 @@
"label": "Portas" "label": "Portas"
}, },
"host": { "host": {
"label": "Host" "label": ""
} }
}, },
"action": { "action": {
@@ -4499,7 +4499,7 @@
"title": "Comandos globais", "title": "Comandos globais",
"option": { "option": {
"colorScheme": { "colorScheme": {
"auto": "Alternar modo de aparência", "auto": "",
"light": "Alternar para o modo claro", "light": "Alternar para o modo claro",
"dark": "Alternar para o modo escuro" "dark": "Alternar para o modo escuro"
}, },
@@ -4551,13 +4551,13 @@
"group": { "group": {
"searchEngine": { "searchEngine": {
"title": "Mecanismos de busca", "title": "Mecanismos de busca",
"tipDdgBangs": "Dica: Você também pode usar qualquer bang do DuckDuckGo aqui, ex: !something", "tipDdgBangs": "",
"bang": { "bang": {
"searchWithQuery": "Pesquisar \"{query}\" com {label}", "searchWithQuery": "",
"pressEnterToOpen": "Pressione Enter para abrir", "pressEnterToOpen": "",
"engineSelected": "{label} selecionado (!{bang})", "engineSelected": "",
"typeQueryToContinue": "Digite sua pesquisa para continuar", "typeQueryToContinue": "",
"emptyBangHint": "Digite um bang, ex: !yt, e pressione Espaço para selecionar" "emptyBangHint": ""
}, },
"children": { "children": {
"action": { "action": {
+5
View File
@@ -0,0 +1,5 @@
import baseConfig from "@homarr/eslint-config/base";
import reactConfig from "@homarr/eslint-config/react";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig, ...reactConfig];
+12 -8
View File
@@ -4,6 +4,12 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css",
"./hooks": "./src/hooks/index.ts",
"./icons": "./src/icons/index.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,18 +17,13 @@
] ]
} }
}, },
"exports": {
".": "./index.ts",
"./styles.css": "./src/styles.css",
"./hooks": "./src/hooks/index.ts",
"./icons": "./src/icons/index.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/common": "workspace:^0.1.0", "@homarr/common": "workspace:^0.1.0",
"@homarr/definitions": "workspace:^0.1.0", "@homarr/definitions": "workspace:^0.1.0",
@@ -41,9 +42,12 @@
"svgson": "catalog:" "svgson": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"@types/crypto-js": "catalog:", "@types/crypto-js": "catalog:",
"@types/css-modules": "catalog:", "@types/css-modules": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+4
View File
@@ -0,0 +1,4 @@
import baseConfig from "@homarr/eslint-config/base";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig];
+9 -5
View File
@@ -4,6 +4,9 @@
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"type": "module", "type": "module",
"exports": {
"./*": "./src/*.ts"
},
"typesVersions": { "typesVersions": {
"*": { "*": {
"*": [ "*": [
@@ -11,15 +14,13 @@
] ]
} }
}, },
"exports": {
"./*": "./src/*.ts"
},
"scripts": { "scripts": {
"clean": "rm -rf .turbo node_modules", "clean": "rm -rf .turbo node_modules",
"format": "oxfmt --check .", "format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "oxlint", "lint": "eslint",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit"
}, },
"prettier": "@homarr/prettier-config",
"dependencies": { "dependencies": {
"@homarr/definitions": "workspace:^0.1.0", "@homarr/definitions": "workspace:^0.1.0",
"@homarr/translation": "workspace:^0.1.0", "@homarr/translation": "workspace:^0.1.0",
@@ -27,7 +28,10 @@
"zod-form-data": "catalog:" "zod-form-data": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@homarr/eslint-config": "workspace:^0.2.0",
"@homarr/prettier-config": "workspace:^0.1.0",
"@homarr/tsconfig": "workspace:^0.1.0", "@homarr/tsconfig": "workspace:^0.1.0",
"eslint": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }
+5
View File
@@ -0,0 +1,5 @@
import baseConfig from "@homarr/eslint-config/base";
import reactConfig from "@homarr/eslint-config/react";
/** @type {import('typescript-eslint').Config} */
export default [...baseConfig, ...reactConfig];
Loaded 100 of 122 files, more files were not shown because too many files have changed in this diff. Show more