From a0c34ee48deb9a5bf8305893209b0a8aec4b1af8 Mon Sep 17 00:00:00 2001 From: Nico <47644445+nicotsx@users.noreply.github.com> Date: Wed, 22 Apr 2026 21:14:37 +0200 Subject: [PATCH] chore: cleanup un-used exports (#823) --- .fallowrc.json | 3 ++ .gitignore | 1 + app/client/components/theme-provider.tsx | 2 +- app/client/lib/datetime.ts | 2 +- app/client/lib/errors.tsx | 4 +- app/client/lib/utils.ts | 23 ---------- app/client/modules/auth/routes/onboarding.tsx | 3 -- .../components/create-notification-form.tsx | 2 +- .../repositories/routes/snapshot-details.tsx | 2 +- app/lib/request-client.ts | 1 + app/router.tsx | 1 + app/routes/__root.tsx | 2 +- app/routes/api.$.ts | 2 +- app/schemas/events-dto.ts | 28 ++++++------ app/schemas/notifications.ts | 4 +- app/schemas/server-events.ts | 2 +- app/schemas/volumes.ts | 2 +- app/server/app.ts | 4 +- app/server/core/request-context.ts | 2 +- .../lib/auth/helpers/create-default-org.ts | 2 +- app/server/modules/agents/agents-manager.ts | 1 + app/server/modules/auth/auth.dto.ts | 6 +-- app/server/modules/auth/auth.service.ts | 2 +- .../modules/backends/utils/backend-utils.ts | 22 ---------- app/server/modules/backups/backups.dto.ts | 26 +++++------ .../00005-split-backup-include-paths.ts | 2 +- .../notifications/notifications.dto.ts | 20 ++++----- .../modules/repositories/repositories.dto.ts | 44 +++++++++---------- app/server/modules/sso/sso.dto.ts | 4 +- app/server/modules/sso/sso.service.ts | 2 +- app/server/modules/sso/utils/sso-context.ts | 8 ---- .../modules/sso/utils/sso-provider-id.ts | 2 +- app/server/modules/system/system.dto.ts | 12 ++--- app/server/modules/volumes/volume.dto.ts | 20 ++++----- app/server/utils/backend-compatibility.ts | 7 +-- app/server/utils/branded.ts | 2 - app/server/utils/cache.ts | 4 +- app/test/helpers/auth.ts | 2 +- app/test/test-utils.tsx | 26 +---------- apps/docs/source.config.ts | 1 + apps/docs/src/lib/metadata.ts | 2 +- apps/docs/src/router.tsx | 1 + 42 files changed, 117 insertions(+), 191 deletions(-) create mode 100644 .fallowrc.json diff --git a/.fallowrc.json b/.fallowrc.json new file mode 100644 index 00000000..16d48ead --- /dev/null +++ b/.fallowrc.json @@ -0,0 +1,3 @@ +{ + "ignorePatterns": ["node_modules/**", ".output/**", "**/api-client/**", "**/components/ui/**", "**/routeTree.gen.ts"] +} diff --git a/.gitignore b/.gitignore index e0067a38..d3b47d61 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ qa-output .worktrees/ .turbo .superset +.fallow diff --git a/app/client/components/theme-provider.tsx b/app/client/components/theme-provider.tsx index 9ab506f8..70cdc058 100644 --- a/app/client/components/theme-provider.tsx +++ b/app/client/components/theme-provider.tsx @@ -10,7 +10,7 @@ type ThemeContextValue = { const ThemeContext = createContext(null); export const THEME_COOKIE_NAME = "theme"; -export const THEME_COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year +const THEME_COOKIE_MAX_AGE = 60 * 60 * 24 * 365; // 1 year const DEFAULT_THEME: Theme = "dark"; export function ThemeProvider({ children, initialTheme }: { children: React.ReactNode; initialTheme?: Theme }) { diff --git a/app/client/lib/datetime.ts b/app/client/lib/datetime.ts index 75b07ad6..e879e213 100644 --- a/app/client/lib/datetime.ts +++ b/app/client/lib/datetime.ts @@ -6,7 +6,7 @@ export type DateInput = Date | string | number | null | undefined; export const DATE_FORMATS = ["MM/DD/YYYY", "DD/MM/YYYY", "YYYY/MM/DD"] as const; export type DateFormatPreference = (typeof DATE_FORMATS)[number]; -export const DEFAULT_DATE_FORMAT: DateFormatPreference = "MM/DD/YYYY"; +const DEFAULT_DATE_FORMAT: DateFormatPreference = "MM/DD/YYYY"; export const TIME_FORMATS = ["12h", "24h"] as const; export type TimeFormatPreference = (typeof TIME_FORMATS)[number]; diff --git a/app/client/lib/errors.tsx b/app/client/lib/errors.tsx index 0631298a..bf6fea21 100644 --- a/app/client/lib/errors.tsx +++ b/app/client/lib/errors.tsx @@ -3,7 +3,7 @@ import { unlockRepository } from "~/client/api-client/sdk.gen"; import { Button } from "~/client/components/ui/button"; import { Unlock } from "lucide-react"; -export const isLockError = (error: unknown): boolean => { +const isLockError = (error: unknown): boolean => { const errorMessage = parseError(error)?.message || ""; return ( @@ -25,7 +25,7 @@ export const parseError = (error?: unknown) => { return undefined; }; -export const showLockErrorToast = (repositoryId: string, title: string) => { +const showLockErrorToast = (repositoryId: string, title: string) => { toast.error(title, { description: "The repository is currently locked by another operation. This can happen when a previous operation didn't complete properly.", diff --git a/app/client/lib/utils.ts b/app/client/lib/utils.ts index f3cb121c..80511197 100644 --- a/app/client/lib/utils.ts +++ b/app/client/lib/utils.ts @@ -6,29 +6,6 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -/** - * Converts an arbitrary string into a URL-safe slug: - * - lowercase - * - trims whitespace - * - replaces non-alphanumeric runs with "-" - * - collapses multiple hyphens - * - trims leading/trailing hyphens - */ -/** - * Live slugify for UI: lowercases, normalizes dashes, replaces invalid runs with "-", - * collapses repeats, but DOES NOT trim leading/trailing hyphens so the user can type - * spaces/dashes progressively while editing. - */ -export function slugify(input: string): string { - return input - .toLowerCase() - .replace(/[ ]/g, "-") - .replace(/[^a-z0-9_-]+/g, "") - .replace(/[-]{2,}/g, "-") - .replace(/[_]{2,}/g, "_") - .trim(); -} - export function safeJsonParse(input: string): T | null { try { return JSON.parse(input) as T; diff --git a/app/client/modules/auth/routes/onboarding.tsx b/app/client/modules/auth/routes/onboarding.tsx index ffe10f1f..ab0db91c 100644 --- a/app/client/modules/auth/routes/onboarding.tsx +++ b/app/client/modules/auth/routes/onboarding.tsx @@ -10,7 +10,6 @@ import { FormLabel, FormMessage, } from "~/client/components/ui/form"; -import { authMiddleware } from "~/middleware/auth"; import { AuthLayout } from "~/client/components/auth-layout"; import { Input } from "~/client/components/ui/input"; import { Button } from "~/client/components/ui/button"; @@ -22,8 +21,6 @@ import { normalizeUsername } from "~/lib/username"; import { z } from "zod"; import { inferDateTimePreferences } from "~/client/lib/datetime"; -export const clientMiddleware = [authMiddleware]; - const onboardingSchema = z.object({ username: z.string().min(2).max(30).transform(normalizeUsername), email: z diff --git a/app/client/modules/notifications/components/create-notification-form.tsx b/app/client/modules/notifications/components/create-notification-form.tsx index 6b8c1cdf..4fedadde 100644 --- a/app/client/modules/notifications/components/create-notification-form.tsx +++ b/app/client/modules/notifications/components/create-notification-form.tsx @@ -39,7 +39,7 @@ import { const baseFields = { name: z.string().min(2).max(32) }; -export const formSchema = z.discriminatedUnion("type", [ +const formSchema = z.discriminatedUnion("type", [ emailNotificationConfigSchema.extend(baseFields), slackNotificationConfigSchema.extend(baseFields), discordNotificationConfigSchema.extend(baseFields), diff --git a/app/client/modules/repositories/routes/snapshot-details.tsx b/app/client/modules/repositories/routes/snapshot-details.tsx index 832a3db4..cb895d3d 100644 --- a/app/client/modules/repositories/routes/snapshot-details.tsx +++ b/app/client/modules/repositories/routes/snapshot-details.tsx @@ -15,7 +15,7 @@ import { Database } from "lucide-react"; import { Link, useParams } from "@tanstack/react-router"; import { getVolumeMountPath } from "~/client/lib/volume-path"; -export const SnapshotError = () => { +const SnapshotError = () => { const { repositoryId } = useParams({ from: "/(dashboard)/repositories/$repositoryId/$snapshotId/" }); return ( diff --git a/app/lib/request-client.ts b/app/lib/request-client.ts index 305c488b..c8613f55 100644 --- a/app/lib/request-client.ts +++ b/app/lib/request-client.ts @@ -36,6 +36,7 @@ const loadRequestClientStore = async (): Promise return requestClientStorePromise; }; +// fallow-ignore-next-line unused-export export function getRequestClient(): RequestClient { const client = requestClientStore?.getStore(); diff --git a/app/router.tsx b/app/router.tsx index b70c2340..3ca536a2 100644 --- a/app/router.tsx +++ b/app/router.tsx @@ -11,6 +11,7 @@ client.setConfig({ credentials: "include", }); +// fallow-ignore-next-line unused-export export function getRouter() { const queryClient = new QueryClient({ defaultOptions: { diff --git a/app/routes/__root.tsx b/app/routes/__root.tsx index 5b74b319..e40379cd 100644 --- a/app/routes/__root.tsx +++ b/app/routes/__root.tsx @@ -38,7 +38,7 @@ export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()( errorComponent: (e) =>
{e.error.message}
, }); -export function RootLayout() { +function RootLayout() { const { theme } = Route.useLoaderData(); const pathname = useRouterState({ select: (state) => state.location.pathname }); useServerEvents({ enabled: !isAuthRoute(pathname) }); diff --git a/app/routes/api.$.ts b/app/routes/api.$.ts index f36dfa84..682e56b5 100644 --- a/app/routes/api.$.ts +++ b/app/routes/api.$.ts @@ -17,7 +17,7 @@ type RequestInitWithDuplex = RequestInit & { duplex?: "half"; }; -export const prepareApiRequest = (request: NodeRuntimeRequest, timeoutMs: number) => { +const prepareApiRequest = (request: NodeRuntimeRequest, timeoutMs: number) => { request.runtime?.node?.res?.setTimeout(timeoutMs); if (config.trustProxy && request.headers.has("x-forwarded-for")) { diff --git a/app/schemas/events-dto.ts b/app/schemas/events-dto.ts index 9acb7ab8..e964b440 100644 --- a/app/schemas/events-dto.ts +++ b/app/schemas/events-dto.ts @@ -1,8 +1,8 @@ import { z } from "zod"; import { resticBackupProgressMetricsSchema, resticBackupRunSummarySchema } from "@zerobyte/core/restic"; -export const backupEventStatusSchema = z.enum(["success", "error", "stopped", "warning"]); -export const restoreEventStatusSchema = z.enum(["success", "error"]); +const backupEventStatusSchema = z.enum(["success", "error", "stopped", "warning"]); +const restoreEventStatusSchema = z.enum(["success", "error"]); const backupEventBaseSchema = z.object({ scheduleId: z.string(), @@ -35,37 +35,37 @@ const restoreProgressMetricsSchema = z.object({ bytes_restored: z.number().default(0), }); -export const backupStartedEventSchema = backupEventBaseSchema; +const backupStartedEventSchema = backupEventBaseSchema; export const backupProgressEventSchema = backupEventBaseSchema.extend(resticBackupProgressMetricsSchema.shape); -export const backupCompletedEventSchema = backupEventBaseSchema.extend({ +const backupCompletedEventSchema = backupEventBaseSchema.extend({ status: backupEventStatusSchema, summary: resticBackupRunSummarySchema.optional(), }); -export const restoreStartedEventSchema = restoreEventBaseSchema; +const restoreStartedEventSchema = restoreEventBaseSchema; -export const restoreProgressEventSchema = restoreEventBaseSchema.extend(restoreProgressMetricsSchema.shape); +const restoreProgressEventSchema = restoreEventBaseSchema.extend(restoreProgressMetricsSchema.shape); -export const restoreCompletedEventSchema = restoreEventBaseSchema.extend({ +const restoreCompletedEventSchema = restoreEventBaseSchema.extend({ status: restoreEventStatusSchema, error: z.string().optional(), }); -export const serverBackupStartedEventSchema = organizationScopedSchema.extend(backupStartedEventSchema.shape); +const serverBackupStartedEventSchema = organizationScopedSchema.extend(backupStartedEventSchema.shape); -export const serverBackupProgressEventSchema = organizationScopedSchema.extend(backupProgressEventSchema.shape); +const serverBackupProgressEventSchema = organizationScopedSchema.extend(backupProgressEventSchema.shape); -export const serverBackupCompletedEventSchema = organizationScopedSchema.extend(backupCompletedEventSchema.shape); +const serverBackupCompletedEventSchema = organizationScopedSchema.extend(backupCompletedEventSchema.shape); -export const serverRestoreStartedEventSchema = organizationScopedSchema.extend(restoreStartedEventSchema.shape); +const serverRestoreStartedEventSchema = organizationScopedSchema.extend(restoreStartedEventSchema.shape); -export const serverRestoreProgressEventSchema = organizationScopedSchema.extend(restoreProgressEventSchema.shape); +const serverRestoreProgressEventSchema = organizationScopedSchema.extend(restoreProgressEventSchema.shape); -export const serverRestoreCompletedEventSchema = organizationScopedSchema.extend(restoreCompletedEventSchema.shape); +const serverRestoreCompletedEventSchema = organizationScopedSchema.extend(restoreCompletedEventSchema.shape); -export const serverDumpStartedEventSchema = organizationScopedSchema.extend(dumpStartedEventSchema.shape); +const serverDumpStartedEventSchema = organizationScopedSchema.extend(dumpStartedEventSchema.shape); export type BackupEventStatusDto = z.infer; export type BackupStartedEventDto = z.infer; diff --git a/app/schemas/notifications.ts b/app/schemas/notifications.ts index 62d90287..4ff14fb0 100644 --- a/app/schemas/notifications.ts +++ b/app/schemas/notifications.ts @@ -90,7 +90,7 @@ export const customNotificationConfigSchema = z.object({ shoutrrrUrl: z.string().min(1), }); -export const notificationConfigSchemaBase = z.discriminatedUnion("type", [ +const notificationConfigSchemaBase = z.discriminatedUnion("type", [ emailNotificationConfigSchema, slackNotificationConfigSchema, discordNotificationConfigSchema, @@ -106,7 +106,7 @@ export const notificationConfigSchema = notificationConfigSchemaBase; export type NotificationConfig = z.infer; -export const NOTIFICATION_EVENTS = { +const NOTIFICATION_EVENTS = { start: "start", success: "success", failure: "failure", diff --git a/app/schemas/server-events.ts b/app/schemas/server-events.ts index 7ec54f22..d84a9048 100644 --- a/app/schemas/server-events.ts +++ b/app/schemas/server-events.ts @@ -15,7 +15,7 @@ const payload = () => undefined as unknown as T; * Single runtime registry for all broadcastable server events. * Used as source-of-truth for both event names and payload typing. */ -export const serverEventPayloads = { +const serverEventPayloads = { "backup:started": payload(), "backup:progress": payload(), "backup:completed": payload(), diff --git a/app/schemas/volumes.ts b/app/schemas/volumes.ts index 60946f63..3e829f98 100644 --- a/app/schemas/volumes.ts +++ b/app/schemas/volumes.ts @@ -86,7 +86,7 @@ export const sftpConfigSchema = z.object({ knownHosts: z.string().optional(), }); -export const volumeConfigSchemaBase = z.discriminatedUnion("backend", [ +const volumeConfigSchemaBase = z.discriminatedUnion("backend", [ nfsConfigSchema, smbConfigSchema, webdavConfigSchema, diff --git a/app/server/app.ts b/app/server/app.ts index 042f9d6c..76bffbba 100644 --- a/app/server/app.ts +++ b/app/server/app.ts @@ -21,7 +21,7 @@ import { config } from "./core/config"; import { auth } from "~/server/lib/auth"; import { db } from "./db/db"; -export const generalDescriptor = (app: Hono) => +const generalDescriptor = (app: Hono) => openAPIRouteHandler(app, { documentation: { info: { @@ -33,7 +33,7 @@ export const generalDescriptor = (app: Hono) => }, }); -export const scalarDescriptor = Scalar({ +const scalarDescriptor = Scalar({ title: "Zerobyte API Docs", pageTitle: "Zerobyte API Docs", url: "/api/v1/openapi.json", diff --git a/app/server/core/request-context.ts b/app/server/core/request-context.ts index 112d4a31..eed3bcc5 100644 --- a/app/server/core/request-context.ts +++ b/app/server/core/request-context.ts @@ -11,7 +11,7 @@ export const withContext = (context: RequestContext, fn: () => T): T => { return requestContextStorage.run(context, fn); }; -export const getRequestContext = (): RequestContext => { +const getRequestContext = (): RequestContext => { const context = requestContextStorage.getStore(); if (!context?.organizationId) { diff --git a/app/server/lib/auth/helpers/create-default-org.ts b/app/server/lib/auth/helpers/create-default-org.ts index 3ca4ebf7..e3bd8deb 100644 --- a/app/server/lib/auth/helpers/create-default-org.ts +++ b/app/server/lib/auth/helpers/create-default-org.ts @@ -15,7 +15,7 @@ export async function findMembershipWithOrganization(userId: string, organizatio return membership ?? null; } -export function buildOrgSlug(email: string) { +function buildOrgSlug(email: string) { const [emailPrefix] = email.split("@"); const sanitized = emailPrefix .toLowerCase() diff --git a/app/server/modules/agents/agents-manager.ts b/app/server/modules/agents/agents-manager.ts index 6782dcad..7830f349 100644 --- a/app/server/modules/agents/agents-manager.ts +++ b/app/server/modules/agents/agents-manager.ts @@ -217,6 +217,7 @@ export const spawnLocalAgent = async () => { await spawnLocalAgentProcess(getAgentRuntimeState()); }; +// fallow-ignore-next-line unused-export export const stopLocalAgent = async () => { await stopLocalAgentProcess(getAgentRuntimeState()); }; diff --git a/app/server/modules/auth/auth.dto.ts b/app/server/modules/auth/auth.dto.ts index 942d1ffb..5c194013 100644 --- a/app/server/modules/auth/auth.dto.ts +++ b/app/server/modules/auth/auth.dto.ts @@ -5,7 +5,7 @@ const statusResponseSchema = z.object({ hasUsers: z.boolean(), }); -export const adminUsersResponse = z.object({ +const adminUsersResponse = z.object({ users: z .object({ id: z.string(), @@ -60,7 +60,7 @@ export const getStatusDto = describeRoute({ export type GetStatusDto = z.infer; -export const userDeletionImpactDto = z.object({ +const userDeletionImpactDto = z.object({ organizations: z .object({ id: z.string(), @@ -109,7 +109,7 @@ export const deleteUserAccountDto = describeRoute({ }, }); -export const orgMembersResponse = z.object({ +const orgMembersResponse = z.object({ members: z .object({ id: z.string(), diff --git a/app/server/modules/auth/auth.service.ts b/app/server/modules/auth/auth.service.ts index 7b8e29fd..e1f9f98c 100644 --- a/app/server/modules/auth/auth.service.ts +++ b/app/server/modules/auth/auth.service.ts @@ -12,7 +12,7 @@ import { import { eq, ne, and, count, inArray } from "drizzle-orm"; import type { UserDeletionImpactDto } from "./auth.dto"; -export class AuthService { +class AuthService { /** * Check if any users exist in the system */ diff --git a/app/server/modules/backends/utils/backend-utils.ts b/app/server/modules/backends/utils/backend-utils.ts index 751a055b..a9e9d2b6 100644 --- a/app/server/modules/backends/utils/backend-utils.ts +++ b/app/server/modules/backends/utils/backend-utils.ts @@ -1,6 +1,4 @@ import * as fs from "node:fs/promises"; -import * as npath from "node:path"; -import { toMessage } from "../../../utils/errors"; import { logger } from "@zerobyte/core/node"; import { safeExec } from "@zerobyte/core/node"; import { getMountForPath } from "../../../utils/mountinfo"; @@ -62,23 +60,3 @@ export const assertMounted = async (path: string, isExpectedFilesystem: (fstype: throw new Error(`Path ${path} is not mounted as correct fstype (found ${mount.fstype}).`); } }; - -export const createTestFile = async (path: string): Promise => { - const testFilePath = npath.join(path, `.healthcheck-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`); - - await fs.writeFile(testFilePath, "healthcheck"); - - const files = await fs.readdir(path); - await Promise.all( - files.map(async (file) => { - if (file.startsWith(".healthcheck-")) { - const filePath = npath.join(path, file); - try { - await fs.unlink(filePath); - } catch (err) { - logger.warn(`Failed to stat or unlink file ${filePath}: ${toMessage(err)}`); - } - } - }), - ); -}; diff --git a/app/server/modules/backups/backups.dto.ts b/app/server/modules/backups/backups.dto.ts index 555c3e48..facf490a 100644 --- a/app/server/modules/backups/backups.dto.ts +++ b/app/server/modules/backups/backups.dto.ts @@ -96,7 +96,7 @@ export const getBackupScheduleDto = describeRoute({ }, }); -export const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable(); +const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable(); export type GetBackupScheduleForVolumeResponseDto = z.infer; @@ -142,7 +142,7 @@ export const createBackupScheduleBody = z.object({ export type CreateBackupScheduleBody = z.infer; -export const createBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); +const createBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); export type CreateBackupScheduleDto = z.infer; @@ -187,7 +187,7 @@ export const updateBackupScheduleBody = z.object({ export type UpdateBackupScheduleBody = z.infer; -export const updateBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); +const updateBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); export type UpdateBackupScheduleDto = z.infer; @@ -207,7 +207,7 @@ export const updateBackupScheduleDto = describeRoute({ }, }); -export const deleteBackupScheduleResponse = z.object({ +const deleteBackupScheduleResponse = z.object({ success: z.boolean(), }); @@ -229,7 +229,7 @@ export const deleteBackupScheduleDto = describeRoute({ }, }); -export const runBackupNowResponse = z.object({ +const runBackupNowResponse = z.object({ success: z.boolean(), }); @@ -251,7 +251,7 @@ export const runBackupNowDto = describeRoute({ }, }); -export const stopBackupResponse = z.object({ +const stopBackupResponse = z.object({ success: z.boolean(), }); @@ -276,7 +276,7 @@ export const stopBackupDto = describeRoute({ }, }); -export const runForgetResponse = z.object({ +const runForgetResponse = z.object({ success: z.boolean(), }); @@ -298,7 +298,7 @@ export const runForgetDto = describeRoute({ }, }); -export const getScheduleMirrorsResponse = scheduleMirrorSchema.array(); +const getScheduleMirrorsResponse = scheduleMirrorSchema.array(); export type GetScheduleMirrorsDto = z.infer; export const getScheduleMirrorsDto = describeRoute({ @@ -328,7 +328,7 @@ export const updateScheduleMirrorsBody = z.object({ export type UpdateScheduleMirrorsBody = z.infer; -export const updateScheduleMirrorsResponse = scheduleMirrorSchema.array(); +const updateScheduleMirrorsResponse = scheduleMirrorSchema.array(); export type UpdateScheduleMirrorsDto = z.infer; export const updateScheduleMirrorsDto = describeRoute({ @@ -353,7 +353,7 @@ const mirrorCompatibilitySchema = z.object({ reason: z.string().nullable(), }); -export const getMirrorCompatibilityResponse = mirrorCompatibilitySchema.array(); +const getMirrorCompatibilityResponse = mirrorCompatibilitySchema.array(); export type GetMirrorCompatibilityDto = z.infer; export const getMirrorCompatibilityDto = describeRoute({ @@ -378,7 +378,7 @@ export const reorderBackupSchedulesBody = z.object({ export type ReorderBackupSchedulesBody = z.infer; -export const reorderBackupSchedulesResponse = z.object({ +const reorderBackupSchedulesResponse = z.object({ success: z.boolean(), }); @@ -406,7 +406,7 @@ const missingSnapshotSchema = z.object({ size: z.number(), }); -export const getMirrorSyncStatusResponse = z.object({ +const getMirrorSyncStatusResponse = z.object({ sourceCount: z.number(), mirrorCount: z.number(), missingSnapshots: missingSnapshotSchema.array(), @@ -435,7 +435,7 @@ export const syncMirrorBody = z.object({ export type SyncMirrorBody = z.infer; -export const syncMirrorResponse = z.object({ +const syncMirrorResponse = z.object({ success: z.boolean(), }); export type SyncMirrorDto = z.infer; diff --git a/app/server/modules/lifecycle/migrations/00005-split-backup-include-paths.ts b/app/server/modules/lifecycle/migrations/00005-split-backup-include-paths.ts index 39874b67..8ac5e053 100644 --- a/app/server/modules/lifecycle/migrations/00005-split-backup-include-paths.ts +++ b/app/server/modules/lifecycle/migrations/00005-split-backup-include-paths.ts @@ -4,7 +4,7 @@ import { db } from "../../../db/db"; import { backupSchedulesTable } from "../../../db/schema"; import { toMessage } from "~/server/utils/errors"; -export const isIncludePatternEntry = (value: string) => value.startsWith("!") || /[*?[\]]/.test(value); +const isIncludePatternEntry = (value: string) => value.startsWith("!") || /[*?[\]]/.test(value); const execute = async () => { const errors: Array<{ name: string; error: string }> = []; diff --git a/app/server/modules/notifications/notifications.dto.ts b/app/server/modules/notifications/notifications.dto.ts index 6acac0ed..b227d28a 100644 --- a/app/server/modules/notifications/notifications.dto.ts +++ b/app/server/modules/notifications/notifications.dto.ts @@ -2,7 +2,7 @@ import { z } from "zod"; import { describeRoute, resolver } from "hono-openapi"; import { NOTIFICATION_TYPES, notificationConfigSchema } from "~/schemas/notifications"; -export const notificationDestinationSchema = z.object({ +const notificationDestinationSchema = z.object({ id: z.number(), name: z.string(), enabled: z.boolean(), @@ -14,7 +14,7 @@ export const notificationDestinationSchema = z.object({ export type NotificationDestinationDto = z.infer; -export const listDestinationsResponse = notificationDestinationSchema.array(); +const listDestinationsResponse = notificationDestinationSchema.array(); export type ListDestinationsDto = z.infer; export const listDestinationsDto = describeRoute({ @@ -38,7 +38,7 @@ export const createDestinationBody = z.object({ config: notificationConfigSchema, }); -export const createDestinationResponse = notificationDestinationSchema; +const createDestinationResponse = notificationDestinationSchema; export type CreateDestinationDto = z.infer; export const createDestinationDto = describeRoute({ @@ -57,7 +57,7 @@ export const createDestinationDto = describeRoute({ }, }); -export const getDestinationResponse = notificationDestinationSchema; +const getDestinationResponse = notificationDestinationSchema; export type GetDestinationDto = z.infer; export const getDestinationDto = describeRoute({ @@ -85,7 +85,7 @@ export const updateDestinationBody = z.object({ config: notificationConfigSchema.optional(), }); -export const updateDestinationResponse = notificationDestinationSchema; +const updateDestinationResponse = notificationDestinationSchema; export type UpdateDestinationDto = z.infer; export const updateDestinationDto = describeRoute({ @@ -107,7 +107,7 @@ export const updateDestinationDto = describeRoute({ }, }); -export const deleteDestinationResponse = z.object({ +const deleteDestinationResponse = z.object({ message: z.string(), }); export type DeleteDestinationDto = z.infer; @@ -131,7 +131,7 @@ export const deleteDestinationDto = describeRoute({ }, }); -export const testDestinationResponse = z.object({ +const testDestinationResponse = z.object({ success: z.boolean(), }); export type TestDestinationDto = z.infer; @@ -161,7 +161,7 @@ export const testDestinationDto = describeRoute({ }, }); -export const scheduleNotificationAssignmentSchema = z.object({ +const scheduleNotificationAssignmentSchema = z.object({ scheduleId: z.number(), destinationId: z.number(), notifyOnStart: z.boolean(), @@ -174,7 +174,7 @@ export const scheduleNotificationAssignmentSchema = z.object({ export type ScheduleNotificationAssignmentDto = z.infer; -export const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); +const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); export type GetScheduleNotificationsDto = z.infer; export const getScheduleNotificationsDto = describeRoute({ @@ -205,7 +205,7 @@ export const updateScheduleNotificationsBody = z.object({ .array(), }); -export const updateScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); +const updateScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); export type UpdateScheduleNotificationsDto = z.infer; export const updateScheduleNotificationsDto = describeRoute({ diff --git a/app/server/modules/repositories/repositories.dto.ts b/app/server/modules/repositories/repositories.dto.ts index f066f6ad..ec01918a 100644 --- a/app/server/modules/repositories/repositories.dto.ts +++ b/app/server/modules/repositories/repositories.dto.ts @@ -29,7 +29,7 @@ export const repositorySchema = z.object({ export type RepositoryDto = z.infer; -export const listRepositoriesResponse = repositorySchema.array(); +const listRepositoriesResponse = repositorySchema.array(); export type ListRepositoriesDto = z.infer; export const listRepositoriesDto = describeRoute({ @@ -56,7 +56,7 @@ export const createRepositoryBody = z.object({ export type CreateRepositoryBody = z.infer; -export const createRepositoryResponse = z.object({ +const createRepositoryResponse = z.object({ message: z.string(), repository: z.object({ id: z.string(), @@ -83,7 +83,7 @@ export const createRepositoryDto = describeRoute({ }, }); -export const getRepositoryResponse = repositorySchema; +const getRepositoryResponse = repositorySchema; export type GetRepositoryDto = z.infer; export const getRepositoryDto = describeRoute({ @@ -102,8 +102,8 @@ export const getRepositoryDto = describeRoute({ }, }); -export const repositoryStatsSchema = resticStatsSchema; -export const getRepositoryStatsResponse = repositoryStatsSchema; +const repositoryStatsSchema = resticStatsSchema; +const getRepositoryStatsResponse = repositoryStatsSchema; export type GetRepositoryStatsDto = z.infer; export const getRepositoryStatsDto = describeRoute({ @@ -122,7 +122,7 @@ export const getRepositoryStatsDto = describeRoute({ }, }); -export const refreshRepositoryStatsResponse = repositoryStatsSchema; +const refreshRepositoryStatsResponse = repositoryStatsSchema; export type RefreshRepositoryStatsDto = z.infer; export const refreshRepositoryStatsDto = describeRoute({ @@ -141,7 +141,7 @@ export const refreshRepositoryStatsDto = describeRoute({ }, }); -export const deleteRepositoryResponse = z.object({ +const deleteRepositoryResponse = z.object({ message: z.string(), }); @@ -171,7 +171,7 @@ export const updateRepositoryBody = z.object({ export type UpdateRepositoryBody = z.infer; -export const updateRepositoryResponse = repositorySchema; +const updateRepositoryResponse = repositorySchema; export type UpdateRepositoryDto = z.infer; export const updateRepositoryDto = describeRoute({ @@ -199,7 +199,7 @@ export const updateRepositoryDto = describeRoute({ }, }); -export const snapshotSchema = z.object({ +const snapshotSchema = z.object({ short_id: z.string(), time: z.number(), paths: z.array(z.string()), @@ -235,7 +235,7 @@ export const listSnapshotsDto = describeRoute({ }, }); -export const getSnapshotDetailsResponse = snapshotSchema; +const getSnapshotDetailsResponse = snapshotSchema; export type GetSnapshotDetailsDto = z.infer; @@ -255,7 +255,7 @@ export const getSnapshotDetailsDto = describeRoute({ }, }); -export const snapshotFileNodeSchema = z.object({ +const snapshotFileNodeSchema = z.object({ name: z.string(), type: z.string(), path: z.string(), @@ -268,7 +268,7 @@ export const snapshotFileNodeSchema = z.object({ ctime: z.string().optional(), }); -export const listSnapshotFilesResponse = z.object({ +const listSnapshotFilesResponse = z.object({ snapshot: z.object({ id: z.string(), short_id: z.string(), @@ -312,7 +312,7 @@ const DUMP_PATH_KINDS = { dir: "dir", } as const; -export const dumpPathKindSchema = z.enum(DUMP_PATH_KINDS); +const dumpPathKindSchema = z.enum(DUMP_PATH_KINDS); export type DumpPathKind = z.infer; export const dumpSnapshotQuery = z.object({ @@ -339,7 +339,7 @@ export const dumpSnapshotDto = describeRoute({ }, }); -export const overwriteModeSchema = z.enum(OVERWRITE_MODES); +const overwriteModeSchema = z.enum(OVERWRITE_MODES); export const restoreSnapshotBody = z.object({ snapshotId: z.string(), @@ -354,7 +354,7 @@ export const restoreSnapshotBody = z.object({ export type RestoreSnapshotBody = z.infer; -export const restoreSnapshotResponse = z.object({ +const restoreSnapshotResponse = z.object({ success: z.boolean(), message: z.string(), filesRestored: z.number(), @@ -379,7 +379,7 @@ export const restoreSnapshotDto = describeRoute({ }, }); -export const startDoctorResponse = z.object({ +const startDoctorResponse = z.object({ message: z.string(), repositoryId: z.string(), }); @@ -406,7 +406,7 @@ export const startDoctorDto = describeRoute({ }, }); -export const cancelDoctorResponse = z.object({ +const cancelDoctorResponse = z.object({ message: z.string(), }); @@ -454,7 +454,7 @@ export const listRcloneRemotesDto = describeRoute({ }, }); -export const deleteSnapshotResponse = z.object({ +const deleteSnapshotResponse = z.object({ message: z.string(), }); @@ -480,7 +480,7 @@ export const deleteSnapshotsBody = z.object({ snapshotIds: z.array(z.string()).min(1), }); -export const deleteSnapshotsResponse = z.object({ +const deleteSnapshotsResponse = z.object({ message: z.string(), }); @@ -509,7 +509,7 @@ export const tagSnapshotsBody = z.object({ set: z.array(z.string()).optional(), }); -export const tagSnapshotsResponse = z.object({ +const tagSnapshotsResponse = z.object({ message: z.string(), }); @@ -531,7 +531,7 @@ export const tagSnapshotsDto = describeRoute({ }, }); -export const refreshSnapshotsResponse = z.object({ +const refreshSnapshotsResponse = z.object({ message: z.string(), count: z.number(), }); @@ -580,7 +580,7 @@ export const devPanelExecDto = describeRoute({ }, }); -export const unlockRepositoryResponse = z.object({ +const unlockRepositoryResponse = z.object({ success: z.boolean(), message: z.string(), }); diff --git a/app/server/modules/sso/sso.dto.ts b/app/server/modules/sso/sso.dto.ts index 5b764d07..64082768 100644 --- a/app/server/modules/sso/sso.dto.ts +++ b/app/server/modules/sso/sso.dto.ts @@ -1,7 +1,7 @@ import { z } from "zod"; import { describeRoute, resolver } from "hono-openapi"; -export const publicSsoProvidersDto = z.object({ +const publicSsoProvidersDto = z.object({ providers: z .object({ providerId: z.string(), @@ -28,7 +28,7 @@ export const getPublicSsoProvidersDto = describeRoute({ }, }); -export const ssoSettingsResponse = z.object({ +const ssoSettingsResponse = z.object({ providers: z .object({ providerId: z.string(), diff --git a/app/server/modules/sso/sso.service.ts b/app/server/modules/sso/sso.service.ts index ec56f678..8aeb5aaf 100644 --- a/app/server/modules/sso/sso.service.ts +++ b/app/server/modules/sso/sso.service.ts @@ -4,7 +4,7 @@ import { eq, and, inArray } from "drizzle-orm"; import { isReservedSsoProviderId } from "./utils/sso-provider-id"; import { normalizeEmail } from "./utils/sso-context"; -export class SsoService { +class SsoService { /** * Get public SSO providers for the instance */ diff --git a/app/server/modules/sso/utils/sso-context.ts b/app/server/modules/sso/utils/sso-context.ts index 9c649956..d3f956f4 100644 --- a/app/server/modules/sso/utils/sso-context.ts +++ b/app/server/modules/sso/utils/sso-context.ts @@ -20,14 +20,6 @@ export function extractProviderIdFromUrl(url: string): string | null { } } -export function isSsoCallbackPath(path?: string | null): boolean { - if (!path) { - return false; - } - - return extractProviderIdFromPath(path) !== null; -} - export function isSsoCallbackRequest(ctx?: GenericEndpointContext | null): boolean { if (!ctx?.request?.url) { return false; diff --git a/app/server/modules/sso/utils/sso-provider-id.ts b/app/server/modules/sso/utils/sso-provider-id.ts index b76f8903..96f171e5 100644 --- a/app/server/modules/sso/utils/sso-provider-id.ts +++ b/app/server/modules/sso/utils/sso-provider-id.ts @@ -1,6 +1,6 @@ const RESERVED_SSO_PROVIDER_IDS = new Set(["credential"]); -export function normalizeSsoProviderId(providerId: string): string { +function normalizeSsoProviderId(providerId: string): string { return providerId.trim().toLowerCase(); } diff --git a/app/server/modules/system/system.dto.ts b/app/server/modules/system/system.dto.ts index 705ada28..10da861d 100644 --- a/app/server/modules/system/system.dto.ts +++ b/app/server/modules/system/system.dto.ts @@ -1,25 +1,25 @@ import { z } from "zod"; import { describeRoute, resolver } from "hono-openapi"; -export const capabilitiesSchema = z.object({ +const capabilitiesSchema = z.object({ rclone: z.boolean(), sysAdmin: z.boolean(), }); -export const systemInfoResponse = z.object({ +const systemInfoResponse = z.object({ capabilities: capabilitiesSchema, }); export type SystemInfoDto = z.infer; -export const releaseInfoSchema = z.object({ +const releaseInfoSchema = z.object({ version: z.string(), url: z.string(), publishedAt: z.string(), body: z.string(), }); -export const updateInfoResponse = z.object({ +const updateInfoResponse = z.object({ currentVersion: z.string(), latestVersion: z.string(), hasUpdate: z.boolean(), @@ -81,7 +81,7 @@ export const downloadResticPasswordDto = describeRoute({ }, }); -export const registrationStatusResponse = z.object({ +const registrationStatusResponse = z.object({ enabled: z.boolean(), }); @@ -123,7 +123,7 @@ export const setRegistrationStatusDto = describeRoute({ }, }); -export const devPanelResponse = z.object({ +const devPanelResponse = z.object({ enabled: z.boolean(), }); diff --git a/app/server/modules/volumes/volume.dto.ts b/app/server/modules/volumes/volume.dto.ts index 6bab8bf4..3aa187fc 100644 --- a/app/server/modules/volumes/volume.dto.ts +++ b/app/server/modules/volumes/volume.dto.ts @@ -19,7 +19,7 @@ export const volumeSchema = z.object({ export type VolumeDto = z.infer; -export const listVolumesResponse = volumeSchema.array(); +const listVolumesResponse = volumeSchema.array(); export type ListVolumesDto = z.infer; export const listVolumesDto = describeRoute({ @@ -43,7 +43,7 @@ export const createVolumeBody = z.object({ config: volumeConfigSchema, }); -export const createVolumeResponse = volumeSchema; +const createVolumeResponse = volumeSchema; export type CreateVolumeDto = z.infer; export const createVolumeDto = describeRoute({ @@ -62,7 +62,7 @@ export const createVolumeDto = describeRoute({ }, }); -export const deleteVolumeResponse = z.object({ +const deleteVolumeResponse = z.object({ message: z.string(), }); export type DeleteVolumeDto = z.infer; @@ -123,7 +123,7 @@ export const updateVolumeBody = z.object({ export type UpdateVolumeBody = z.infer; -export const updateVolumeResponse = volumeSchema; +const updateVolumeResponse = volumeSchema; export type UpdateVolumeDto = z.infer; export const updateVolumeDto = describeRoute({ @@ -149,7 +149,7 @@ export const testConnectionBody = z.object({ config: volumeConfigSchema, }); -export const testConnectionResponse = z.object({ +const testConnectionResponse = z.object({ success: z.boolean(), message: z.string(), }); @@ -171,7 +171,7 @@ export const testConnectionDto = describeRoute({ }, }); -export const mountVolumeResponse = z.object({ +const mountVolumeResponse = z.object({ error: z.string().optional(), status: z.enum(BACKEND_STATUS), }); @@ -193,7 +193,7 @@ export const mountVolumeDto = describeRoute({ }, }); -export const unmountVolumeResponse = z.object({ +const unmountVolumeResponse = z.object({ error: z.string().optional(), status: z.enum(BACKEND_STATUS), }); @@ -215,7 +215,7 @@ export const unmountVolumeDto = describeRoute({ }, }); -export const healthCheckResponse = z.object({ +const healthCheckResponse = z.object({ error: z.string().optional(), status: z.enum(BACKEND_STATUS), }); @@ -248,7 +248,7 @@ const fileEntrySchema = z.object({ modifiedAt: z.number().optional(), }); -export const listFilesResponse = z.object({ +const listFilesResponse = z.object({ files: fileEntrySchema.array(), path: z.string(), offset: z.number(), @@ -280,7 +280,7 @@ export const listFilesDto = describeRoute({ }, }); -export const browseFilesystemResponse = z.object({ +const browseFilesystemResponse = z.object({ directories: fileEntrySchema.array(), path: z.string(), }); diff --git a/app/server/utils/backend-compatibility.ts b/app/server/utils/backend-compatibility.ts index e406076f..c07f463d 100644 --- a/app/server/utils/backend-compatibility.ts +++ b/app/server/utils/backend-compatibility.ts @@ -3,7 +3,7 @@ import { cryptoUtils } from "./crypto"; type BackendConflictGroup = "s3" | "gcs" | "azure" | "rest" | "sftp" | null; -export const getBackendConflictGroup = (backend: string): BackendConflictGroup => { +const getBackendConflictGroup = (backend: string): BackendConflictGroup => { switch (backend) { case "s3": case "r2": @@ -24,10 +24,7 @@ export const getBackendConflictGroup = (backend: string): BackendConflictGroup = } }; -export const hasCompatibleCredentials = async ( - config1: RepositoryConfig, - config2: RepositoryConfig, -): Promise => { +const hasCompatibleCredentials = async (config1: RepositoryConfig, config2: RepositoryConfig): Promise => { const group1 = getBackendConflictGroup(config1.backend); const group2 = getBackendConflictGroup(config2.backend); diff --git a/app/server/utils/branded.ts b/app/server/utils/branded.ts index 84802d93..f0221b72 100644 --- a/app/server/utils/branded.ts +++ b/app/server/utils/branded.ts @@ -5,5 +5,3 @@ export type Branded = T & { [brand]: B }; export type ShortId = Branded; export const asShortId = (value: string): ShortId => value as ShortId; - -export const isShortId = (value: string): value is ShortId => /^[A-Za-z0-9_-]+$/.test(value); diff --git a/app/server/utils/cache.ts b/app/server/utils/cache.ts index c628878e..5a0a152e 100644 --- a/app/server/utils/cache.ts +++ b/app/server/utils/cache.ts @@ -3,13 +3,13 @@ import path from "node:path"; import fs from "node:fs"; import { DATABASE_URL } from "../core/constants"; -export const ONE_DAY_IN_SECONDS = 60 * 60 * 24; +const ONE_DAY_IN_SECONDS = 60 * 60 * 24; export interface CacheOptions { dbPath?: string; } -export const createCache = (options: CacheOptions = {}) => { +const createCache = (options: CacheOptions = {}) => { const defaultPath = path.join(path.dirname(DATABASE_URL), "cache.db"); const dbPath = options.dbPath || defaultPath; diff --git a/app/test/helpers/auth.ts b/app/test/helpers/auth.ts index aa380da4..78351459 100644 --- a/app/test/helpers/auth.ts +++ b/app/test/helpers/auth.ts @@ -3,7 +3,7 @@ import { db } from "~/server/db/db"; import { member, organization, sessionsTable, usersTable } from "~/server/db/schema"; import { eq } from "drizzle-orm"; -export const COOKIE_PREFIX = "zerobyte"; +const COOKIE_PREFIX = "zerobyte"; export function getAuthHeaders(token: string): { Cookie: string } { return { diff --git a/app/test/test-utils.tsx b/app/test/test-utils.tsx index 63e0537b..60a60f42 100644 --- a/app/test/test-utils.tsx +++ b/app/test/test-utils.tsx @@ -1,10 +1,5 @@ import { MutationCache, QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import { - render as testingLibraryRender, - renderHook as testingLibraryRenderHook, - type RenderHookOptions, - type RenderOptions, -} from "@testing-library/react"; +import { render as testingLibraryRender, type RenderOptions } from "@testing-library/react"; import testingLibraryUserEvent from "@testing-library/user-event"; import { Suspense, type ReactElement, type ReactNode } from "react"; import { logger } from "~/client/lib/logger"; @@ -16,7 +11,6 @@ type TestProviderOptions = { }; type TestRenderOptions = Omit & TestProviderOptions; -type TestRenderHookOptions = Omit, "wrapper"> & TestProviderOptions; export const createTestQueryClient = () => { let queryClient: QueryClient; @@ -72,23 +66,7 @@ const customRender = (ui: ReactElement, options: TestRenderOptions = {}) => { }; }; -const customRenderHook = ( - callback: (initialProps: Props) => Result, - options: TestRenderHookOptions = {}, -) => { - const { queryClient, withSuspense, suspenseFallback, ...renderOptions } = options; - const wrapper = createWrapper({ queryClient, withSuspense, suspenseFallback }); - - return { - queryClient: wrapper.queryClient, - ...testingLibraryRenderHook(callback, { - wrapper: wrapper.Wrapper, - ...renderOptions, - }), - }; -}; - export * from "@testing-library/react"; export const userEvent = testingLibraryUserEvent.setup(); -export { customRender as render, customRenderHook as renderHook }; +export { customRender as render }; diff --git a/apps/docs/source.config.ts b/apps/docs/source.config.ts index fe40bd31..ec32dee0 100644 --- a/apps/docs/source.config.ts +++ b/apps/docs/source.config.ts @@ -1,5 +1,6 @@ import { defineDocs } from "fumadocs-mdx/config"; +// fallow-ignore-next-line unused-export export const docs = defineDocs({ dir: "content/docs", }); diff --git a/apps/docs/src/lib/metadata.ts b/apps/docs/src/lib/metadata.ts index d13536f7..08432398 100644 --- a/apps/docs/src/lib/metadata.ts +++ b/apps/docs/src/lib/metadata.ts @@ -6,7 +6,7 @@ export const siteDescription = "Zerobyte is a web control plane for Restic backups with scheduling, encrypted repositories, monitoring, and restore workflows."; export const ogImageUrl = new URL(ogImageAssetUrl, siteUrl).toString(); -export function getCanonicalUrl(path: string) { +function getCanonicalUrl(path: string) { return new URL(path, siteUrl).toString(); } diff --git a/apps/docs/src/router.tsx b/apps/docs/src/router.tsx index 0b1d0fbe..0571ecaa 100644 --- a/apps/docs/src/router.tsx +++ b/apps/docs/src/router.tsx @@ -1,6 +1,7 @@ import { createRouter as createTanStackRouter } from "@tanstack/react-router"; import { routeTree } from "./routeTree.gen"; +// fallow-ignore-next-line unused-export export function getRouter() { const router = createTanStackRouter({ routeTree,