refactor: move usages of create-id to common package (#3606)

This commit is contained in:
Meier Lukas
2025-07-17 10:42:11 +02:00
committed by GitHub
parent d4acb01efd
commit c00110e426
56 changed files with 69 additions and 64 deletions

View File

@@ -3,7 +3,7 @@
import { Button, Fieldset, Grid, Group, Input, NumberInput, Slider, Stack, Text, TextInput } from "@mantine/core";
import { clientApi } from "@homarr/api/client";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import { useZodForm } from "@homarr/form";
import { useI18n } from "@homarr/translation/client";
import { boardSaveLayoutsSchema } from "@homarr/validation/board";

View File

@@ -4,8 +4,7 @@ import { IconAlertTriangle, IconCheck, IconCopy, IconExclamationCircle, IconRepe
import { clientApi } from "@homarr/api/client";
import { useSession } from "@homarr/auth/client";
import { getMantineColor } from "@homarr/common";
import { createId } from "@homarr/db/client";
import { createId, getMantineColor } from "@homarr/common";
import { createDocumentationLink } from "@homarr/definitions";
import { createModal, useConfirmModal, useModalAction } from "@homarr/modals";
import { AddCertificateModal } from "@homarr/modals-collection";

View File

@@ -3,7 +3,7 @@
import { SimpleGrid, Skeleton, Stack, Title } from "@mantine/core";
import { clientApi } from "@homarr/api/client";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { KubernetesLabelResourceType } from "@homarr/definitions";
import { useI18n } from "@homarr/translation/client";

View File

@@ -10,7 +10,7 @@ import { MantineReactTable } from "mantine-react-table";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { KubernetesIngress } from "@homarr/definitions";
import type { ScopedTranslationFunction } from "@homarr/translation";
import { useScopedI18n } from "@homarr/translation/client";

View File

@@ -8,7 +8,7 @@ import { MantineReactTable } from "mantine-react-table";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { KubernetesService } from "@homarr/definitions";
import type { ScopedTranslationFunction } from "@homarr/translation";
import { useScopedI18n } from "@homarr/translation/client";

View File

@@ -1,6 +1,6 @@
import { getBoardLayouts } from "@homarr/boards/context";
import { createId } from "@homarr/common";
import type { Modify } from "@homarr/common/types";
import { createId } from "@homarr/db/client";
import type { WidgetKind } from "@homarr/definitions";
import type { Board, EmptySection, Item, ItemLayout } from "~/app/[locale]/boards/_types";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { Board, EmptySection, ItemLayout, Section } from "~/app/[locale]/boards/_types";
import { getFirstEmptyPosition } from "./empty-position";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { Board, DynamicSection, EmptySection, Item, Section } from "~/app/[locale]/boards/_types";
import { DynamicSectionMockBuilder } from "./dynamic-section-mock";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { CategorySection } from "~/app/[locale]/boards/_types";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { DynamicSection } from "~/app/[locale]/boards/_types";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { EmptySection } from "~/app/[locale]/boards/_types";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { Item } from "~/app/[locale]/boards/_types";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { Board } from "~/app/[locale]/boards/_types";

View File

@@ -1,7 +1,7 @@
import { useCallback } from "react";
import { useUpdateBoard } from "@homarr/boards/updater";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { CategorySection, EmptySection, Section } from "~/app/[locale]/boards/_types";
import type { MoveCategoryInput } from "./actions/move-category";

View File

@@ -2,7 +2,7 @@ import { useCallback } from "react";
import { fetchApi } from "@homarr/api/client";
import { getCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import { useConfirmModal, useModalAction } from "@homarr/modals";
import { useSettings } from "@homarr/settings";
import { useI18n } from "@homarr/translation/client";

View File

@@ -1,5 +1,5 @@
import { getBoardLayouts } from "@homarr/boards/context";
import { createId } from "@homarr/db/client";
import { createId } from "@homarr/common";
import type { Board, DynamicSection, DynamicSectionLayout, EmptySection } from "~/app/[locale]/boards/_types";
import { getFirstEmptyPosition } from "~/components/board/items/actions/empty-position";

View File

@@ -1,8 +1,9 @@
import { z } from "zod";
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
import { createId } from "@homarr/common";
import { generateSecureRandomToken } from "@homarr/common/server";
import { createId, db, eq } from "@homarr/db";
import { db, eq } from "@homarr/db";
import { apiKeys } from "@homarr/db/schema";
import { createTRPCRouter, permissionRequiredProcedure } from "../trpc";

View File

@@ -1,7 +1,8 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { asc, createId, eq, inArray, like } from "@homarr/db";
import { createId } from "@homarr/common";
import { asc, eq, inArray, like } from "@homarr/db";
import { apps } from "@homarr/db/schema";
import { selectAppSchema } from "@homarr/db/validationSchemas";
import { getIconForName } from "@homarr/icons";

View File

@@ -3,9 +3,10 @@ import superjson from "superjson";
import { z } from "zod";
import { constructBoardPermissions } from "@homarr/auth/shared";
import { createId } from "@homarr/common";
import type { DeviceType } from "@homarr/common/server";
import type { Database, InferInsertModel, InferSelectModel, SQL } from "@homarr/db";
import { and, asc, createId, eq, handleTransactionsAsync, inArray, isNull, like, not, or, sql } from "@homarr/db";
import { and, asc, eq, handleTransactionsAsync, inArray, isNull, like, not, or, sql } from "@homarr/db";
import { createDbInsertCollectionWithoutTransaction } from "@homarr/db/collection";
import { getServerSettingByKeyAsync } from "@homarr/db/queries";
import {

View File

@@ -1,8 +1,9 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { createId } from "@homarr/common";
import type { Database } from "@homarr/db";
import { and, createId, eq, handleTransactionsAsync, like, not } from "@homarr/db";
import { and, eq, handleTransactionsAsync, like, not } from "@homarr/db";
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
import { groupMembers, groupPermissions, groups } from "@homarr/db/schema";
import { everyoneGroup } from "@homarr/definitions";

View File

@@ -1,10 +1,10 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { objectEntries } from "@homarr/common";
import { createId, objectEntries } from "@homarr/common";
import { decryptSecret, encryptSecret } from "@homarr/common/server";
import type { Database } from "@homarr/db";
import { and, asc, createId, eq, handleTransactionsAsync, inArray, like } from "@homarr/db";
import { and, asc, eq, handleTransactionsAsync, inArray, like } from "@homarr/db";
import {
groupMembers,
groupPermissions,

View File

@@ -2,7 +2,8 @@ import { randomBytes } from "crypto";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { asc, createId, eq } from "@homarr/db";
import { createId } from "@homarr/common";
import { asc, eq } from "@homarr/db";
import { invites } from "@homarr/db/schema";
import { selectInviteSchema } from "@homarr/db/validationSchemas";

View File

@@ -1,8 +1,9 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { createId } from "@homarr/common";
import type { InferInsertModel } from "@homarr/db";
import { and, createId, desc, eq, like } from "@homarr/db";
import { and, desc, eq, like } from "@homarr/db";
import { iconRepositories, icons, medias } from "@homarr/db/schema";
import { createLocalImageUrl, LOCAL_ICON_REPOSITORY_SLUG, mapMediaToIcon } from "@homarr/icons/local";
import { byIdSchema, paginatedSchema } from "@homarr/validation/common";

View File

@@ -1,7 +1,8 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { asc, createId, eq, like } from "@homarr/db";
import { createId } from "@homarr/common";
import { asc, eq, like } from "@homarr/db";
import { getServerSettingByKeyAsync, updateServerSettingByKeyAsync } from "@homarr/db/queries";
import { searchEngines, users } from "@homarr/db/schema";
import { createIntegrationAsync } from "@homarr/integrations";

View File

@@ -2,7 +2,7 @@
import { describe, expect, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { apps } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import type { GroupPermissionKey } from "@homarr/definitions";

View File

@@ -2,8 +2,9 @@ import SuperJSON from "superjson";
import { describe, expect, it, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/common";
import type { Database, InferInsertModel } from "@homarr/db";
import { and, createId, eq, not } from "@homarr/db";
import { and, eq, not } from "@homarr/db";
import {
boardGroupPermissions,
boards,

View File

@@ -1,7 +1,8 @@
import { describe, expect, test, vi } from "vitest";
import * as authShared from "@homarr/auth/shared";
import { createId, eq } from "@homarr/db";
import { createId } from "@homarr/common";
import { eq } from "@homarr/db";
import { boards, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -2,7 +2,8 @@ import { describe, expect, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import * as env from "@homarr/auth/env";
import { createId, eq } from "@homarr/db";
import { createId } from "@homarr/common";
import { eq } from "@homarr/db";
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import type { GroupPermissionKey } from "@homarr/definitions";

View File

@@ -1,7 +1,8 @@
import { describe, expect, test, vi } from "vitest";
import * as authShared from "@homarr/auth/shared";
import { createId, eq } from "@homarr/db";
import { createId } from "@homarr/common";
import { eq } from "@homarr/db";
import { integrations, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -2,8 +2,8 @@
import { describe, expect, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/common";
import { encryptSecret } from "@homarr/common/server";
import { createId } from "@homarr/db";
import { integrations, integrationSecrets } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import type { GroupPermissionKey } from "@homarr/definitions";

View File

@@ -2,7 +2,7 @@
import { describe, expect, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { invites, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -2,7 +2,7 @@ import SuperJSON from "superjson";
import { describe, expect, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { serverSettings } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server-settings";

View File

@@ -1,8 +1,9 @@
import { describe, expect, it, test, vi } from "vitest";
import type { Session } from "@homarr/auth";
import { createId } from "@homarr/common";
import type { Database } from "@homarr/db";
import { createId, eq } from "@homarr/db";
import { eq } from "@homarr/db";
import { invites, onboarding, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import type { GroupPermissionKey, OnboardingStep } from "@homarr/definitions";

View File

@@ -2,8 +2,9 @@ import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
import { createId } from "@homarr/common";
import type { Database } from "@homarr/db";
import { and, createId, eq, like } from "@homarr/db";
import { and, eq, like } from "@homarr/db";
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
import { boards, groupMembers, groupPermissions, groups, invites, users } from "@homarr/db/schema";
import { selectUserSchema } from "@homarr/db/validationSchemas";

View File

@@ -1,8 +1,8 @@
import type { Session } from "next-auth";
import { describe, expect, test, vi } from "vitest";
import { createId } from "@homarr/common";
import type { InferInsertModel } from "@homarr/db";
import { createId } from "@homarr/db";
import { boardGroupPermissions, boards, boardUserPermissions, groupMembers, groups, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -1,9 +1,9 @@
import { CredentialsSignin } from "@auth/core/errors";
import { z } from "zod";
import { extractErrorMessage } from "@homarr/common";
import { createId, extractErrorMessage } from "@homarr/common";
import type { Database, InferInsertModel } from "@homarr/db";
import { and, createId, eq } from "@homarr/db";
import { and, eq } from "@homarr/db";
import { users } from "@homarr/db/schema";
import { logger } from "@homarr/log";
import type { userSignInSchema } from "@homarr/validation/user";

View File

@@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -1,8 +1,9 @@
import { CredentialsSignin } from "@auth/core/errors";
import { describe, expect, test, vi } from "vitest";
import { createId } from "@homarr/common";
import type { Database } from "@homarr/db";
import { and, createId, eq } from "@homarr/db";
import { and, eq } from "@homarr/db";
import { groups, users } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";

View File

@@ -1,8 +1,9 @@
import { command, string } from "@drizzle-team/brocli";
import { createSaltAsync, hashPasswordAsync } from "@homarr/auth";
import { createId } from "@homarr/common";
import { generateSecureRandomToken } from "@homarr/common/server";
import { and, count, createId, db, eq } from "@homarr/db";
import { and, count, db, eq } from "@homarr/db";
import { getMaxGroupPositionAsync } from "@homarr/db/queries";
import { groupMembers, groupPermissions, groups, users } from "@homarr/db/schema";
import { usernameSchema } from "@homarr/validation/user";

View File

@@ -1,8 +1,7 @@
import { splitToNChunks, Stopwatch } from "@homarr/common";
import { createId, splitToNChunks, Stopwatch } from "@homarr/common";
import { EVERY_WEEK } from "@homarr/cron-jobs-core/expressions";
import type { InferInsertModel } from "@homarr/db";
import { db, handleTransactionsAsync, inArray, sql } from "@homarr/db";
import { createId } from "@homarr/db/client";
import { iconRepositories, icons } from "@homarr/db/schema";
import { fetchIconsAsync } from "@homarr/icons";
import { logger } from "@homarr/log";

View File

@@ -1 +0,0 @@
export { createId } from "@paralleldrive/cuid2";

View File

@@ -9,5 +9,4 @@ export const db = database;
export type Database = typeof db;
export type { HomarrDatabaseMysql } from "./driver";
export { createId } from "@paralleldrive/cuid2";
export { handleDiffrentDbDriverOperationsAsync as handleTransactionsAsync } from "./transactions";

View File

@@ -1,4 +1,4 @@
import { objectKeys } from "@homarr/common";
import { createId, objectKeys } from "@homarr/common";
import {
createDocumentationLink,
everyoneGroup,
@@ -9,7 +9,7 @@ import {
import { defaultServerSettings, defaultServerSettingsKeys } from "@homarr/server-settings";
import type { Database } from "..";
import { createId, eq } from "..";
import { eq } from "..";
import {
getServerSettingByKeyAsync,
insertServerSettingByKeyAsync,

View File

@@ -6,7 +6,6 @@
"type": "module",
"exports": {
".": "./index.ts",
"./client": "./client.ts",
"./collection": "./collection.ts",
"./schema": "./schema/index.ts",
"./test": "./test/index.ts",

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { logger } from "@homarr/log";
import type { OldmarrConfig } from "@homarr/old-schema";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import type { Database } from "@homarr/db";
import { sections } from "@homarr/db/schema";
import { logger } from "@homarr/log";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
import { logger } from "@homarr/log";
import type { BoardSize, OldmarrConfig } from "@homarr/old-schema";

View File

@@ -1,4 +1,4 @@
import { createId } from "@homarr/db";
import { createId } from "@homarr/common";
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
import { credentialsAdminGroup } from "@homarr/definitions";
import { logger } from "@homarr/log";

View File

@@ -1,5 +1,5 @@
import { createId } from "@homarr/common";
import type { InferInsertModel } from "@homarr/db";
import { createId } from "@homarr/db";
import type { boards } from "@homarr/db/schema";
import type { prepareMultipleImports } from "../prepare/prepare-multiple";

View File

@@ -1,5 +1,5 @@
import { createId } from "@homarr/common";
import { decryptSecretWithKey } from "@homarr/common/server";
import { createId } from "@homarr/db";
import type { IntegrationKind } from "@homarr/definitions";
import type { OldmarrIntegrationType } from "@homarr/old-schema";

View File

@@ -1,7 +1,7 @@
import SuperJSON from "superjson";
import { createId } from "@homarr/common";
import type { InferInsertModel } from "@homarr/db";
import { createId } from "@homarr/db";
import type { itemLayouts, items } from "@homarr/db/schema";
import { logger } from "@homarr/log";
import type { BoardSize, OldmarrApp, OldmarrWidget } from "@homarr/old-schema";

View File

@@ -1,5 +1,5 @@
import { createId } from "@homarr/common";
import type { InferInsertModel } from "@homarr/db";
import { createId } from "@homarr/db";
import type { sections } from "@homarr/db/schema";
import type { OldmarrCategorySection, OldmarrEmptySection } from "@homarr/old-schema";

View File

@@ -1,6 +1,6 @@
import { createId } from "@homarr/common";
import { decryptSecretWithKey } from "@homarr/common/server";
import type { InferInsertModel } from "@homarr/db";
import { createId } from "@homarr/db";
import type { users } from "@homarr/db/schema";
import type { OldmarrImportUser } from "../user-schema";

View File

@@ -23,7 +23,6 @@
"prettier": "@homarr/prettier-config",
"dependencies": {
"@homarr/common": "workspace:^",
"@homarr/db": "workspace:^",
"@homarr/definitions": "workspace:^",
"@homarr/log": "workspace:^",
"ioredis": "5.6.1",

View File

@@ -1,7 +1,6 @@
import superjson from "superjson";
import { hashObjectBase64 } from "@homarr/common";
import { createId } from "@homarr/db";
import { createId, hashObjectBase64 } from "@homarr/common";
import type { WidgetKind } from "@homarr/definitions";
import { logger } from "@homarr/log";

3
pnpm-lock.yaml generated
View File

@@ -1697,9 +1697,6 @@ importers:
'@homarr/common':
specifier: workspace:^
version: link:../common
'@homarr/db':
specifier: workspace:^
version: link:../db
'@homarr/definitions':
specifier: workspace:^
version: link:../definitions