chore: cleanup un-used exports (#823)

This commit is contained in:
Nico 2026-04-22 21:14:37 +02:00 committed by GitHub
parent 3f92dace6c
commit a0c34ee48d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 117 additions and 191 deletions

3
.fallowrc.json Normal file
View file

@ -0,0 +1,3 @@
{
"ignorePatterns": ["node_modules/**", ".output/**", "**/api-client/**", "**/components/ui/**", "**/routeTree.gen.ts"]
}

1
.gitignore vendored
View file

@ -46,3 +46,4 @@ qa-output
.worktrees/ .worktrees/
.turbo .turbo
.superset .superset
.fallow

View file

@ -10,7 +10,7 @@ type ThemeContextValue = {
const ThemeContext = createContext<ThemeContextValue | null>(null); const ThemeContext = createContext<ThemeContextValue | null>(null);
export const THEME_COOKIE_NAME = "theme"; 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"; const DEFAULT_THEME: Theme = "dark";
export function ThemeProvider({ children, initialTheme }: { children: React.ReactNode; initialTheme?: Theme }) { export function ThemeProvider({ children, initialTheme }: { children: React.ReactNode; initialTheme?: Theme }) {

View file

@ -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 const DATE_FORMATS = ["MM/DD/YYYY", "DD/MM/YYYY", "YYYY/MM/DD"] as const;
export type DateFormatPreference = (typeof DATE_FORMATS)[number]; 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 const TIME_FORMATS = ["12h", "24h"] as const;
export type TimeFormatPreference = (typeof TIME_FORMATS)[number]; export type TimeFormatPreference = (typeof TIME_FORMATS)[number];

View file

@ -3,7 +3,7 @@ import { unlockRepository } from "~/client/api-client/sdk.gen";
import { Button } from "~/client/components/ui/button"; import { Button } from "~/client/components/ui/button";
import { Unlock } from "lucide-react"; import { Unlock } from "lucide-react";
export const isLockError = (error: unknown): boolean => { const isLockError = (error: unknown): boolean => {
const errorMessage = parseError(error)?.message || ""; const errorMessage = parseError(error)?.message || "";
return ( return (
@ -25,7 +25,7 @@ export const parseError = (error?: unknown) => {
return undefined; return undefined;
}; };
export const showLockErrorToast = (repositoryId: string, title: string) => { const showLockErrorToast = (repositoryId: string, title: string) => {
toast.error(title, { toast.error(title, {
description: description:
"The repository is currently locked by another operation. This can happen when a previous operation didn't complete properly.", "The repository is currently locked by another operation. This can happen when a previous operation didn't complete properly.",

View file

@ -6,29 +6,6 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs)); 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<T>(input: string): T | null { export function safeJsonParse<T>(input: string): T | null {
try { try {
return JSON.parse(input) as T; return JSON.parse(input) as T;

View file

@ -10,7 +10,6 @@ import {
FormLabel, FormLabel,
FormMessage, FormMessage,
} from "~/client/components/ui/form"; } from "~/client/components/ui/form";
import { authMiddleware } from "~/middleware/auth";
import { AuthLayout } from "~/client/components/auth-layout"; import { AuthLayout } from "~/client/components/auth-layout";
import { Input } from "~/client/components/ui/input"; import { Input } from "~/client/components/ui/input";
import { Button } from "~/client/components/ui/button"; import { Button } from "~/client/components/ui/button";
@ -22,8 +21,6 @@ import { normalizeUsername } from "~/lib/username";
import { z } from "zod"; import { z } from "zod";
import { inferDateTimePreferences } from "~/client/lib/datetime"; import { inferDateTimePreferences } from "~/client/lib/datetime";
export const clientMiddleware = [authMiddleware];
const onboardingSchema = z.object({ const onboardingSchema = z.object({
username: z.string().min(2).max(30).transform(normalizeUsername), username: z.string().min(2).max(30).transform(normalizeUsername),
email: z email: z

View file

@ -39,7 +39,7 @@ import {
const baseFields = { name: z.string().min(2).max(32) }; const baseFields = { name: z.string().min(2).max(32) };
export const formSchema = z.discriminatedUnion("type", [ const formSchema = z.discriminatedUnion("type", [
emailNotificationConfigSchema.extend(baseFields), emailNotificationConfigSchema.extend(baseFields),
slackNotificationConfigSchema.extend(baseFields), slackNotificationConfigSchema.extend(baseFields),
discordNotificationConfigSchema.extend(baseFields), discordNotificationConfigSchema.extend(baseFields),

View file

@ -15,7 +15,7 @@ import { Database } from "lucide-react";
import { Link, useParams } from "@tanstack/react-router"; import { Link, useParams } from "@tanstack/react-router";
import { getVolumeMountPath } from "~/client/lib/volume-path"; import { getVolumeMountPath } from "~/client/lib/volume-path";
export const SnapshotError = () => { const SnapshotError = () => {
const { repositoryId } = useParams({ from: "/(dashboard)/repositories/$repositoryId/$snapshotId/" }); const { repositoryId } = useParams({ from: "/(dashboard)/repositories/$repositoryId/$snapshotId/" });
return ( return (

View file

@ -36,6 +36,7 @@ const loadRequestClientStore = async (): Promise<RequestClientStore | undefined>
return requestClientStorePromise; return requestClientStorePromise;
}; };
// fallow-ignore-next-line unused-export
export function getRequestClient(): RequestClient { export function getRequestClient(): RequestClient {
const client = requestClientStore?.getStore(); const client = requestClientStore?.getStore();

View file

@ -11,6 +11,7 @@ client.setConfig({
credentials: "include", credentials: "include",
}); });
// fallow-ignore-next-line unused-export
export function getRouter() { export function getRouter() {
const queryClient = new QueryClient({ const queryClient = new QueryClient({
defaultOptions: { defaultOptions: {

View file

@ -38,7 +38,7 @@ export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
errorComponent: (e) => <div>{e.error.message}</div>, errorComponent: (e) => <div>{e.error.message}</div>,
}); });
export function RootLayout() { function RootLayout() {
const { theme } = Route.useLoaderData(); const { theme } = Route.useLoaderData();
const pathname = useRouterState({ select: (state) => state.location.pathname }); const pathname = useRouterState({ select: (state) => state.location.pathname });
useServerEvents({ enabled: !isAuthRoute(pathname) }); useServerEvents({ enabled: !isAuthRoute(pathname) });

View file

@ -17,7 +17,7 @@ type RequestInitWithDuplex = RequestInit & {
duplex?: "half"; duplex?: "half";
}; };
export const prepareApiRequest = (request: NodeRuntimeRequest, timeoutMs: number) => { const prepareApiRequest = (request: NodeRuntimeRequest, timeoutMs: number) => {
request.runtime?.node?.res?.setTimeout(timeoutMs); request.runtime?.node?.res?.setTimeout(timeoutMs);
if (config.trustProxy && request.headers.has("x-forwarded-for")) { if (config.trustProxy && request.headers.has("x-forwarded-for")) {

View file

@ -1,8 +1,8 @@
import { z } from "zod"; import { z } from "zod";
import { resticBackupProgressMetricsSchema, resticBackupRunSummarySchema } from "@zerobyte/core/restic"; import { resticBackupProgressMetricsSchema, resticBackupRunSummarySchema } from "@zerobyte/core/restic";
export const backupEventStatusSchema = z.enum(["success", "error", "stopped", "warning"]); const backupEventStatusSchema = z.enum(["success", "error", "stopped", "warning"]);
export const restoreEventStatusSchema = z.enum(["success", "error"]); const restoreEventStatusSchema = z.enum(["success", "error"]);
const backupEventBaseSchema = z.object({ const backupEventBaseSchema = z.object({
scheduleId: z.string(), scheduleId: z.string(),
@ -35,37 +35,37 @@ const restoreProgressMetricsSchema = z.object({
bytes_restored: z.number().default(0), bytes_restored: z.number().default(0),
}); });
export const backupStartedEventSchema = backupEventBaseSchema; const backupStartedEventSchema = backupEventBaseSchema;
export const backupProgressEventSchema = backupEventBaseSchema.extend(resticBackupProgressMetricsSchema.shape); export const backupProgressEventSchema = backupEventBaseSchema.extend(resticBackupProgressMetricsSchema.shape);
export const backupCompletedEventSchema = backupEventBaseSchema.extend({ const backupCompletedEventSchema = backupEventBaseSchema.extend({
status: backupEventStatusSchema, status: backupEventStatusSchema,
summary: resticBackupRunSummarySchema.optional(), 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, status: restoreEventStatusSchema,
error: z.string().optional(), 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<typeof backupEventStatusSchema>; export type BackupEventStatusDto = z.infer<typeof backupEventStatusSchema>;
export type BackupStartedEventDto = z.infer<typeof backupStartedEventSchema>; export type BackupStartedEventDto = z.infer<typeof backupStartedEventSchema>;

View file

@ -90,7 +90,7 @@ export const customNotificationConfigSchema = z.object({
shoutrrrUrl: z.string().min(1), shoutrrrUrl: z.string().min(1),
}); });
export const notificationConfigSchemaBase = z.discriminatedUnion("type", [ const notificationConfigSchemaBase = z.discriminatedUnion("type", [
emailNotificationConfigSchema, emailNotificationConfigSchema,
slackNotificationConfigSchema, slackNotificationConfigSchema,
discordNotificationConfigSchema, discordNotificationConfigSchema,
@ -106,7 +106,7 @@ export const notificationConfigSchema = notificationConfigSchemaBase;
export type NotificationConfig = z.infer<typeof notificationConfigSchema>; export type NotificationConfig = z.infer<typeof notificationConfigSchema>;
export const NOTIFICATION_EVENTS = { const NOTIFICATION_EVENTS = {
start: "start", start: "start",
success: "success", success: "success",
failure: "failure", failure: "failure",

View file

@ -15,7 +15,7 @@ const payload = <T>() => undefined as unknown as T;
* Single runtime registry for all broadcastable server events. * Single runtime registry for all broadcastable server events.
* Used as source-of-truth for both event names and payload typing. * Used as source-of-truth for both event names and payload typing.
*/ */
export const serverEventPayloads = { const serverEventPayloads = {
"backup:started": payload<ServerBackupStartedEventDto>(), "backup:started": payload<ServerBackupStartedEventDto>(),
"backup:progress": payload<ServerBackupProgressEventDto>(), "backup:progress": payload<ServerBackupProgressEventDto>(),
"backup:completed": payload<ServerBackupCompletedEventDto>(), "backup:completed": payload<ServerBackupCompletedEventDto>(),

View file

@ -86,7 +86,7 @@ export const sftpConfigSchema = z.object({
knownHosts: z.string().optional(), knownHosts: z.string().optional(),
}); });
export const volumeConfigSchemaBase = z.discriminatedUnion("backend", [ const volumeConfigSchemaBase = z.discriminatedUnion("backend", [
nfsConfigSchema, nfsConfigSchema,
smbConfigSchema, smbConfigSchema,
webdavConfigSchema, webdavConfigSchema,

View file

@ -21,7 +21,7 @@ import { config } from "./core/config";
import { auth } from "~/server/lib/auth"; import { auth } from "~/server/lib/auth";
import { db } from "./db/db"; import { db } from "./db/db";
export const generalDescriptor = (app: Hono) => const generalDescriptor = (app: Hono) =>
openAPIRouteHandler(app, { openAPIRouteHandler(app, {
documentation: { documentation: {
info: { info: {
@ -33,7 +33,7 @@ export const generalDescriptor = (app: Hono) =>
}, },
}); });
export const scalarDescriptor = Scalar({ const scalarDescriptor = Scalar({
title: "Zerobyte API Docs", title: "Zerobyte API Docs",
pageTitle: "Zerobyte API Docs", pageTitle: "Zerobyte API Docs",
url: "/api/v1/openapi.json", url: "/api/v1/openapi.json",

View file

@ -11,7 +11,7 @@ export const withContext = <T>(context: RequestContext, fn: () => T): T => {
return requestContextStorage.run(context, fn); return requestContextStorage.run(context, fn);
}; };
export const getRequestContext = (): RequestContext => { const getRequestContext = (): RequestContext => {
const context = requestContextStorage.getStore(); const context = requestContextStorage.getStore();
if (!context?.organizationId) { if (!context?.organizationId) {

View file

@ -15,7 +15,7 @@ export async function findMembershipWithOrganization(userId: string, organizatio
return membership ?? null; return membership ?? null;
} }
export function buildOrgSlug(email: string) { function buildOrgSlug(email: string) {
const [emailPrefix] = email.split("@"); const [emailPrefix] = email.split("@");
const sanitized = emailPrefix const sanitized = emailPrefix
.toLowerCase() .toLowerCase()

View file

@ -217,6 +217,7 @@ export const spawnLocalAgent = async () => {
await spawnLocalAgentProcess(getAgentRuntimeState()); await spawnLocalAgentProcess(getAgentRuntimeState());
}; };
// fallow-ignore-next-line unused-export
export const stopLocalAgent = async () => { export const stopLocalAgent = async () => {
await stopLocalAgentProcess(getAgentRuntimeState()); await stopLocalAgentProcess(getAgentRuntimeState());
}; };

View file

@ -5,7 +5,7 @@ const statusResponseSchema = z.object({
hasUsers: z.boolean(), hasUsers: z.boolean(),
}); });
export const adminUsersResponse = z.object({ const adminUsersResponse = z.object({
users: z users: z
.object({ .object({
id: z.string(), id: z.string(),
@ -60,7 +60,7 @@ export const getStatusDto = describeRoute({
export type GetStatusDto = z.infer<typeof statusResponseSchema>; export type GetStatusDto = z.infer<typeof statusResponseSchema>;
export const userDeletionImpactDto = z.object({ const userDeletionImpactDto = z.object({
organizations: z organizations: z
.object({ .object({
id: z.string(), id: z.string(),
@ -109,7 +109,7 @@ export const deleteUserAccountDto = describeRoute({
}, },
}); });
export const orgMembersResponse = z.object({ const orgMembersResponse = z.object({
members: z members: z
.object({ .object({
id: z.string(), id: z.string(),

View file

@ -12,7 +12,7 @@ import {
import { eq, ne, and, count, inArray } from "drizzle-orm"; import { eq, ne, and, count, inArray } from "drizzle-orm";
import type { UserDeletionImpactDto } from "./auth.dto"; import type { UserDeletionImpactDto } from "./auth.dto";
export class AuthService { class AuthService {
/** /**
* Check if any users exist in the system * Check if any users exist in the system
*/ */

View file

@ -1,6 +1,4 @@
import * as fs from "node:fs/promises"; 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 { logger } from "@zerobyte/core/node";
import { safeExec } from "@zerobyte/core/node"; import { safeExec } from "@zerobyte/core/node";
import { getMountForPath } from "../../../utils/mountinfo"; 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}).`); throw new Error(`Path ${path} is not mounted as correct fstype (found ${mount.fstype}).`);
} }
}; };
export const createTestFile = async (path: string): Promise<void> => {
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)}`);
}
}
}),
);
};

View file

@ -96,7 +96,7 @@ export const getBackupScheduleDto = describeRoute({
}, },
}); });
export const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable(); const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable();
export type GetBackupScheduleForVolumeResponseDto = z.infer<typeof getBackupScheduleForVolumeResponse>; export type GetBackupScheduleForVolumeResponseDto = z.infer<typeof getBackupScheduleForVolumeResponse>;
@ -142,7 +142,7 @@ export const createBackupScheduleBody = z.object({
export type CreateBackupScheduleBody = z.infer<typeof createBackupScheduleBody>; export type CreateBackupScheduleBody = z.infer<typeof createBackupScheduleBody>;
export const createBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); const createBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true });
export type CreateBackupScheduleDto = z.infer<typeof createBackupScheduleResponse>; export type CreateBackupScheduleDto = z.infer<typeof createBackupScheduleResponse>;
@ -187,7 +187,7 @@ export const updateBackupScheduleBody = z.object({
export type UpdateBackupScheduleBody = z.infer<typeof updateBackupScheduleBody>; export type UpdateBackupScheduleBody = z.infer<typeof updateBackupScheduleBody>;
export const updateBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true }); const updateBackupScheduleResponse = backupScheduleSchema.omit({ volume: true, repository: true });
export type UpdateBackupScheduleDto = z.infer<typeof updateBackupScheduleResponse>; export type UpdateBackupScheduleDto = z.infer<typeof updateBackupScheduleResponse>;
@ -207,7 +207,7 @@ export const updateBackupScheduleDto = describeRoute({
}, },
}); });
export const deleteBackupScheduleResponse = z.object({ const deleteBackupScheduleResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
@ -229,7 +229,7 @@ export const deleteBackupScheduleDto = describeRoute({
}, },
}); });
export const runBackupNowResponse = z.object({ const runBackupNowResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
@ -251,7 +251,7 @@ export const runBackupNowDto = describeRoute({
}, },
}); });
export const stopBackupResponse = z.object({ const stopBackupResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
@ -276,7 +276,7 @@ export const stopBackupDto = describeRoute({
}, },
}); });
export const runForgetResponse = z.object({ const runForgetResponse = z.object({
success: z.boolean(), 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<typeof getScheduleMirrorsResponse>; export type GetScheduleMirrorsDto = z.infer<typeof getScheduleMirrorsResponse>;
export const getScheduleMirrorsDto = describeRoute({ export const getScheduleMirrorsDto = describeRoute({
@ -328,7 +328,7 @@ export const updateScheduleMirrorsBody = z.object({
export type UpdateScheduleMirrorsBody = z.infer<typeof updateScheduleMirrorsBody>; export type UpdateScheduleMirrorsBody = z.infer<typeof updateScheduleMirrorsBody>;
export const updateScheduleMirrorsResponse = scheduleMirrorSchema.array(); const updateScheduleMirrorsResponse = scheduleMirrorSchema.array();
export type UpdateScheduleMirrorsDto = z.infer<typeof updateScheduleMirrorsResponse>; export type UpdateScheduleMirrorsDto = z.infer<typeof updateScheduleMirrorsResponse>;
export const updateScheduleMirrorsDto = describeRoute({ export const updateScheduleMirrorsDto = describeRoute({
@ -353,7 +353,7 @@ const mirrorCompatibilitySchema = z.object({
reason: z.string().nullable(), reason: z.string().nullable(),
}); });
export const getMirrorCompatibilityResponse = mirrorCompatibilitySchema.array(); const getMirrorCompatibilityResponse = mirrorCompatibilitySchema.array();
export type GetMirrorCompatibilityDto = z.infer<typeof getMirrorCompatibilityResponse>; export type GetMirrorCompatibilityDto = z.infer<typeof getMirrorCompatibilityResponse>;
export const getMirrorCompatibilityDto = describeRoute({ export const getMirrorCompatibilityDto = describeRoute({
@ -378,7 +378,7 @@ export const reorderBackupSchedulesBody = z.object({
export type ReorderBackupSchedulesBody = z.infer<typeof reorderBackupSchedulesBody>; export type ReorderBackupSchedulesBody = z.infer<typeof reorderBackupSchedulesBody>;
export const reorderBackupSchedulesResponse = z.object({ const reorderBackupSchedulesResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
@ -406,7 +406,7 @@ const missingSnapshotSchema = z.object({
size: z.number(), size: z.number(),
}); });
export const getMirrorSyncStatusResponse = z.object({ const getMirrorSyncStatusResponse = z.object({
sourceCount: z.number(), sourceCount: z.number(),
mirrorCount: z.number(), mirrorCount: z.number(),
missingSnapshots: missingSnapshotSchema.array(), missingSnapshots: missingSnapshotSchema.array(),
@ -435,7 +435,7 @@ export const syncMirrorBody = z.object({
export type SyncMirrorBody = z.infer<typeof syncMirrorBody>; export type SyncMirrorBody = z.infer<typeof syncMirrorBody>;
export const syncMirrorResponse = z.object({ const syncMirrorResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
export type SyncMirrorDto = z.infer<typeof syncMirrorResponse>; export type SyncMirrorDto = z.infer<typeof syncMirrorResponse>;

View file

@ -4,7 +4,7 @@ import { db } from "../../../db/db";
import { backupSchedulesTable } from "../../../db/schema"; import { backupSchedulesTable } from "../../../db/schema";
import { toMessage } from "~/server/utils/errors"; 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 execute = async () => {
const errors: Array<{ name: string; error: string }> = []; const errors: Array<{ name: string; error: string }> = [];

View file

@ -2,7 +2,7 @@ import { z } from "zod";
import { describeRoute, resolver } from "hono-openapi"; import { describeRoute, resolver } from "hono-openapi";
import { NOTIFICATION_TYPES, notificationConfigSchema } from "~/schemas/notifications"; import { NOTIFICATION_TYPES, notificationConfigSchema } from "~/schemas/notifications";
export const notificationDestinationSchema = z.object({ const notificationDestinationSchema = z.object({
id: z.number(), id: z.number(),
name: z.string(), name: z.string(),
enabled: z.boolean(), enabled: z.boolean(),
@ -14,7 +14,7 @@ export const notificationDestinationSchema = z.object({
export type NotificationDestinationDto = z.infer<typeof notificationDestinationSchema>; export type NotificationDestinationDto = z.infer<typeof notificationDestinationSchema>;
export const listDestinationsResponse = notificationDestinationSchema.array(); const listDestinationsResponse = notificationDestinationSchema.array();
export type ListDestinationsDto = z.infer<typeof listDestinationsResponse>; export type ListDestinationsDto = z.infer<typeof listDestinationsResponse>;
export const listDestinationsDto = describeRoute({ export const listDestinationsDto = describeRoute({
@ -38,7 +38,7 @@ export const createDestinationBody = z.object({
config: notificationConfigSchema, config: notificationConfigSchema,
}); });
export const createDestinationResponse = notificationDestinationSchema; const createDestinationResponse = notificationDestinationSchema;
export type CreateDestinationDto = z.infer<typeof createDestinationResponse>; export type CreateDestinationDto = z.infer<typeof createDestinationResponse>;
export const createDestinationDto = describeRoute({ export const createDestinationDto = describeRoute({
@ -57,7 +57,7 @@ export const createDestinationDto = describeRoute({
}, },
}); });
export const getDestinationResponse = notificationDestinationSchema; const getDestinationResponse = notificationDestinationSchema;
export type GetDestinationDto = z.infer<typeof getDestinationResponse>; export type GetDestinationDto = z.infer<typeof getDestinationResponse>;
export const getDestinationDto = describeRoute({ export const getDestinationDto = describeRoute({
@ -85,7 +85,7 @@ export const updateDestinationBody = z.object({
config: notificationConfigSchema.optional(), config: notificationConfigSchema.optional(),
}); });
export const updateDestinationResponse = notificationDestinationSchema; const updateDestinationResponse = notificationDestinationSchema;
export type UpdateDestinationDto = z.infer<typeof updateDestinationResponse>; export type UpdateDestinationDto = z.infer<typeof updateDestinationResponse>;
export const updateDestinationDto = describeRoute({ export const updateDestinationDto = describeRoute({
@ -107,7 +107,7 @@ export const updateDestinationDto = describeRoute({
}, },
}); });
export const deleteDestinationResponse = z.object({ const deleteDestinationResponse = z.object({
message: z.string(), message: z.string(),
}); });
export type DeleteDestinationDto = z.infer<typeof deleteDestinationResponse>; export type DeleteDestinationDto = z.infer<typeof deleteDestinationResponse>;
@ -131,7 +131,7 @@ export const deleteDestinationDto = describeRoute({
}, },
}); });
export const testDestinationResponse = z.object({ const testDestinationResponse = z.object({
success: z.boolean(), success: z.boolean(),
}); });
export type TestDestinationDto = z.infer<typeof testDestinationResponse>; export type TestDestinationDto = z.infer<typeof testDestinationResponse>;
@ -161,7 +161,7 @@ export const testDestinationDto = describeRoute({
}, },
}); });
export const scheduleNotificationAssignmentSchema = z.object({ const scheduleNotificationAssignmentSchema = z.object({
scheduleId: z.number(), scheduleId: z.number(),
destinationId: z.number(), destinationId: z.number(),
notifyOnStart: z.boolean(), notifyOnStart: z.boolean(),
@ -174,7 +174,7 @@ export const scheduleNotificationAssignmentSchema = z.object({
export type ScheduleNotificationAssignmentDto = z.infer<typeof scheduleNotificationAssignmentSchema>; export type ScheduleNotificationAssignmentDto = z.infer<typeof scheduleNotificationAssignmentSchema>;
export const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array();
export type GetScheduleNotificationsDto = z.infer<typeof getScheduleNotificationsResponse>; export type GetScheduleNotificationsDto = z.infer<typeof getScheduleNotificationsResponse>;
export const getScheduleNotificationsDto = describeRoute({ export const getScheduleNotificationsDto = describeRoute({
@ -205,7 +205,7 @@ export const updateScheduleNotificationsBody = z.object({
.array(), .array(),
}); });
export const updateScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array(); const updateScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array();
export type UpdateScheduleNotificationsDto = z.infer<typeof updateScheduleNotificationsResponse>; export type UpdateScheduleNotificationsDto = z.infer<typeof updateScheduleNotificationsResponse>;
export const updateScheduleNotificationsDto = describeRoute({ export const updateScheduleNotificationsDto = describeRoute({

View file

@ -29,7 +29,7 @@ export const repositorySchema = z.object({
export type RepositoryDto = z.infer<typeof repositorySchema>; export type RepositoryDto = z.infer<typeof repositorySchema>;
export const listRepositoriesResponse = repositorySchema.array(); const listRepositoriesResponse = repositorySchema.array();
export type ListRepositoriesDto = z.infer<typeof listRepositoriesResponse>; export type ListRepositoriesDto = z.infer<typeof listRepositoriesResponse>;
export const listRepositoriesDto = describeRoute({ export const listRepositoriesDto = describeRoute({
@ -56,7 +56,7 @@ export const createRepositoryBody = z.object({
export type CreateRepositoryBody = z.infer<typeof createRepositoryBody>; export type CreateRepositoryBody = z.infer<typeof createRepositoryBody>;
export const createRepositoryResponse = z.object({ const createRepositoryResponse = z.object({
message: z.string(), message: z.string(),
repository: z.object({ repository: z.object({
id: z.string(), id: z.string(),
@ -83,7 +83,7 @@ export const createRepositoryDto = describeRoute({
}, },
}); });
export const getRepositoryResponse = repositorySchema; const getRepositoryResponse = repositorySchema;
export type GetRepositoryDto = z.infer<typeof getRepositoryResponse>; export type GetRepositoryDto = z.infer<typeof getRepositoryResponse>;
export const getRepositoryDto = describeRoute({ export const getRepositoryDto = describeRoute({
@ -102,8 +102,8 @@ export const getRepositoryDto = describeRoute({
}, },
}); });
export const repositoryStatsSchema = resticStatsSchema; const repositoryStatsSchema = resticStatsSchema;
export const getRepositoryStatsResponse = repositoryStatsSchema; const getRepositoryStatsResponse = repositoryStatsSchema;
export type GetRepositoryStatsDto = z.infer<typeof getRepositoryStatsResponse>; export type GetRepositoryStatsDto = z.infer<typeof getRepositoryStatsResponse>;
export const getRepositoryStatsDto = describeRoute({ export const getRepositoryStatsDto = describeRoute({
@ -122,7 +122,7 @@ export const getRepositoryStatsDto = describeRoute({
}, },
}); });
export const refreshRepositoryStatsResponse = repositoryStatsSchema; const refreshRepositoryStatsResponse = repositoryStatsSchema;
export type RefreshRepositoryStatsDto = z.infer<typeof refreshRepositoryStatsResponse>; export type RefreshRepositoryStatsDto = z.infer<typeof refreshRepositoryStatsResponse>;
export const refreshRepositoryStatsDto = describeRoute({ export const refreshRepositoryStatsDto = describeRoute({
@ -141,7 +141,7 @@ export const refreshRepositoryStatsDto = describeRoute({
}, },
}); });
export const deleteRepositoryResponse = z.object({ const deleteRepositoryResponse = z.object({
message: z.string(), message: z.string(),
}); });
@ -171,7 +171,7 @@ export const updateRepositoryBody = z.object({
export type UpdateRepositoryBody = z.infer<typeof updateRepositoryBody>; export type UpdateRepositoryBody = z.infer<typeof updateRepositoryBody>;
export const updateRepositoryResponse = repositorySchema; const updateRepositoryResponse = repositorySchema;
export type UpdateRepositoryDto = z.infer<typeof updateRepositoryResponse>; export type UpdateRepositoryDto = z.infer<typeof updateRepositoryResponse>;
export const updateRepositoryDto = describeRoute({ 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(), short_id: z.string(),
time: z.number(), time: z.number(),
paths: z.array(z.string()), 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<typeof getSnapshotDetailsResponse>; export type GetSnapshotDetailsDto = z.infer<typeof getSnapshotDetailsResponse>;
@ -255,7 +255,7 @@ export const getSnapshotDetailsDto = describeRoute({
}, },
}); });
export const snapshotFileNodeSchema = z.object({ const snapshotFileNodeSchema = z.object({
name: z.string(), name: z.string(),
type: z.string(), type: z.string(),
path: z.string(), path: z.string(),
@ -268,7 +268,7 @@ export const snapshotFileNodeSchema = z.object({
ctime: z.string().optional(), ctime: z.string().optional(),
}); });
export const listSnapshotFilesResponse = z.object({ const listSnapshotFilesResponse = z.object({
snapshot: z.object({ snapshot: z.object({
id: z.string(), id: z.string(),
short_id: z.string(), short_id: z.string(),
@ -312,7 +312,7 @@ const DUMP_PATH_KINDS = {
dir: "dir", dir: "dir",
} as const; } as const;
export const dumpPathKindSchema = z.enum(DUMP_PATH_KINDS); const dumpPathKindSchema = z.enum(DUMP_PATH_KINDS);
export type DumpPathKind = z.infer<typeof dumpPathKindSchema>; export type DumpPathKind = z.infer<typeof dumpPathKindSchema>;
export const dumpSnapshotQuery = z.object({ 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({ export const restoreSnapshotBody = z.object({
snapshotId: z.string(), snapshotId: z.string(),
@ -354,7 +354,7 @@ export const restoreSnapshotBody = z.object({
export type RestoreSnapshotBody = z.infer<typeof restoreSnapshotBody>; export type RestoreSnapshotBody = z.infer<typeof restoreSnapshotBody>;
export const restoreSnapshotResponse = z.object({ const restoreSnapshotResponse = z.object({
success: z.boolean(), success: z.boolean(),
message: z.string(), message: z.string(),
filesRestored: z.number(), filesRestored: z.number(),
@ -379,7 +379,7 @@ export const restoreSnapshotDto = describeRoute({
}, },
}); });
export const startDoctorResponse = z.object({ const startDoctorResponse = z.object({
message: z.string(), message: z.string(),
repositoryId: 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(), message: z.string(),
}); });
@ -454,7 +454,7 @@ export const listRcloneRemotesDto = describeRoute({
}, },
}); });
export const deleteSnapshotResponse = z.object({ const deleteSnapshotResponse = z.object({
message: z.string(), message: z.string(),
}); });
@ -480,7 +480,7 @@ export const deleteSnapshotsBody = z.object({
snapshotIds: z.array(z.string()).min(1), snapshotIds: z.array(z.string()).min(1),
}); });
export const deleteSnapshotsResponse = z.object({ const deleteSnapshotsResponse = z.object({
message: z.string(), message: z.string(),
}); });
@ -509,7 +509,7 @@ export const tagSnapshotsBody = z.object({
set: z.array(z.string()).optional(), set: z.array(z.string()).optional(),
}); });
export const tagSnapshotsResponse = z.object({ const tagSnapshotsResponse = z.object({
message: z.string(), message: z.string(),
}); });
@ -531,7 +531,7 @@ export const tagSnapshotsDto = describeRoute({
}, },
}); });
export const refreshSnapshotsResponse = z.object({ const refreshSnapshotsResponse = z.object({
message: z.string(), message: z.string(),
count: z.number(), count: z.number(),
}); });
@ -580,7 +580,7 @@ export const devPanelExecDto = describeRoute({
}, },
}); });
export const unlockRepositoryResponse = z.object({ const unlockRepositoryResponse = z.object({
success: z.boolean(), success: z.boolean(),
message: z.string(), message: z.string(),
}); });

View file

@ -1,7 +1,7 @@
import { z } from "zod"; import { z } from "zod";
import { describeRoute, resolver } from "hono-openapi"; import { describeRoute, resolver } from "hono-openapi";
export const publicSsoProvidersDto = z.object({ const publicSsoProvidersDto = z.object({
providers: z providers: z
.object({ .object({
providerId: z.string(), providerId: z.string(),
@ -28,7 +28,7 @@ export const getPublicSsoProvidersDto = describeRoute({
}, },
}); });
export const ssoSettingsResponse = z.object({ const ssoSettingsResponse = z.object({
providers: z providers: z
.object({ .object({
providerId: z.string(), providerId: z.string(),

View file

@ -4,7 +4,7 @@ import { eq, and, inArray } from "drizzle-orm";
import { isReservedSsoProviderId } from "./utils/sso-provider-id"; import { isReservedSsoProviderId } from "./utils/sso-provider-id";
import { normalizeEmail } from "./utils/sso-context"; import { normalizeEmail } from "./utils/sso-context";
export class SsoService { class SsoService {
/** /**
* Get public SSO providers for the instance * Get public SSO providers for the instance
*/ */

View file

@ -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 { export function isSsoCallbackRequest(ctx?: GenericEndpointContext | null): boolean {
if (!ctx?.request?.url) { if (!ctx?.request?.url) {
return false; return false;

View file

@ -1,6 +1,6 @@
const RESERVED_SSO_PROVIDER_IDS = new Set(["credential"]); const RESERVED_SSO_PROVIDER_IDS = new Set(["credential"]);
export function normalizeSsoProviderId(providerId: string): string { function normalizeSsoProviderId(providerId: string): string {
return providerId.trim().toLowerCase(); return providerId.trim().toLowerCase();
} }

View file

@ -1,25 +1,25 @@
import { z } from "zod"; import { z } from "zod";
import { describeRoute, resolver } from "hono-openapi"; import { describeRoute, resolver } from "hono-openapi";
export const capabilitiesSchema = z.object({ const capabilitiesSchema = z.object({
rclone: z.boolean(), rclone: z.boolean(),
sysAdmin: z.boolean(), sysAdmin: z.boolean(),
}); });
export const systemInfoResponse = z.object({ const systemInfoResponse = z.object({
capabilities: capabilitiesSchema, capabilities: capabilitiesSchema,
}); });
export type SystemInfoDto = z.infer<typeof systemInfoResponse>; export type SystemInfoDto = z.infer<typeof systemInfoResponse>;
export const releaseInfoSchema = z.object({ const releaseInfoSchema = z.object({
version: z.string(), version: z.string(),
url: z.string(), url: z.string(),
publishedAt: z.string(), publishedAt: z.string(),
body: z.string(), body: z.string(),
}); });
export const updateInfoResponse = z.object({ const updateInfoResponse = z.object({
currentVersion: z.string(), currentVersion: z.string(),
latestVersion: z.string(), latestVersion: z.string(),
hasUpdate: z.boolean(), hasUpdate: z.boolean(),
@ -81,7 +81,7 @@ export const downloadResticPasswordDto = describeRoute({
}, },
}); });
export const registrationStatusResponse = z.object({ const registrationStatusResponse = z.object({
enabled: z.boolean(), enabled: z.boolean(),
}); });
@ -123,7 +123,7 @@ export const setRegistrationStatusDto = describeRoute({
}, },
}); });
export const devPanelResponse = z.object({ const devPanelResponse = z.object({
enabled: z.boolean(), enabled: z.boolean(),
}); });

View file

@ -19,7 +19,7 @@ export const volumeSchema = z.object({
export type VolumeDto = z.infer<typeof volumeSchema>; export type VolumeDto = z.infer<typeof volumeSchema>;
export const listVolumesResponse = volumeSchema.array(); const listVolumesResponse = volumeSchema.array();
export type ListVolumesDto = z.infer<typeof listVolumesResponse>; export type ListVolumesDto = z.infer<typeof listVolumesResponse>;
export const listVolumesDto = describeRoute({ export const listVolumesDto = describeRoute({
@ -43,7 +43,7 @@ export const createVolumeBody = z.object({
config: volumeConfigSchema, config: volumeConfigSchema,
}); });
export const createVolumeResponse = volumeSchema; const createVolumeResponse = volumeSchema;
export type CreateVolumeDto = z.infer<typeof createVolumeResponse>; export type CreateVolumeDto = z.infer<typeof createVolumeResponse>;
export const createVolumeDto = describeRoute({ export const createVolumeDto = describeRoute({
@ -62,7 +62,7 @@ export const createVolumeDto = describeRoute({
}, },
}); });
export const deleteVolumeResponse = z.object({ const deleteVolumeResponse = z.object({
message: z.string(), message: z.string(),
}); });
export type DeleteVolumeDto = z.infer<typeof deleteVolumeResponse>; export type DeleteVolumeDto = z.infer<typeof deleteVolumeResponse>;
@ -123,7 +123,7 @@ export const updateVolumeBody = z.object({
export type UpdateVolumeBody = z.infer<typeof updateVolumeBody>; export type UpdateVolumeBody = z.infer<typeof updateVolumeBody>;
export const updateVolumeResponse = volumeSchema; const updateVolumeResponse = volumeSchema;
export type UpdateVolumeDto = z.infer<typeof updateVolumeResponse>; export type UpdateVolumeDto = z.infer<typeof updateVolumeResponse>;
export const updateVolumeDto = describeRoute({ export const updateVolumeDto = describeRoute({
@ -149,7 +149,7 @@ export const testConnectionBody = z.object({
config: volumeConfigSchema, config: volumeConfigSchema,
}); });
export const testConnectionResponse = z.object({ const testConnectionResponse = z.object({
success: z.boolean(), success: z.boolean(),
message: z.string(), message: z.string(),
}); });
@ -171,7 +171,7 @@ export const testConnectionDto = describeRoute({
}, },
}); });
export const mountVolumeResponse = z.object({ const mountVolumeResponse = z.object({
error: z.string().optional(), error: z.string().optional(),
status: z.enum(BACKEND_STATUS), 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(), error: z.string().optional(),
status: z.enum(BACKEND_STATUS), 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(), error: z.string().optional(),
status: z.enum(BACKEND_STATUS), status: z.enum(BACKEND_STATUS),
}); });
@ -248,7 +248,7 @@ const fileEntrySchema = z.object({
modifiedAt: z.number().optional(), modifiedAt: z.number().optional(),
}); });
export const listFilesResponse = z.object({ const listFilesResponse = z.object({
files: fileEntrySchema.array(), files: fileEntrySchema.array(),
path: z.string(), path: z.string(),
offset: z.number(), offset: z.number(),
@ -280,7 +280,7 @@ export const listFilesDto = describeRoute({
}, },
}); });
export const browseFilesystemResponse = z.object({ const browseFilesystemResponse = z.object({
directories: fileEntrySchema.array(), directories: fileEntrySchema.array(),
path: z.string(), path: z.string(),
}); });

View file

@ -3,7 +3,7 @@ import { cryptoUtils } from "./crypto";
type BackendConflictGroup = "s3" | "gcs" | "azure" | "rest" | "sftp" | null; type BackendConflictGroup = "s3" | "gcs" | "azure" | "rest" | "sftp" | null;
export const getBackendConflictGroup = (backend: string): BackendConflictGroup => { const getBackendConflictGroup = (backend: string): BackendConflictGroup => {
switch (backend) { switch (backend) {
case "s3": case "s3":
case "r2": case "r2":
@ -24,10 +24,7 @@ export const getBackendConflictGroup = (backend: string): BackendConflictGroup =
} }
}; };
export const hasCompatibleCredentials = async ( const hasCompatibleCredentials = async (config1: RepositoryConfig, config2: RepositoryConfig): Promise<boolean> => {
config1: RepositoryConfig,
config2: RepositoryConfig,
): Promise<boolean> => {
const group1 = getBackendConflictGroup(config1.backend); const group1 = getBackendConflictGroup(config1.backend);
const group2 = getBackendConflictGroup(config2.backend); const group2 = getBackendConflictGroup(config2.backend);

View file

@ -5,5 +5,3 @@ export type Branded<T, B> = T & { [brand]: B };
export type ShortId = Branded<string, "ShortId">; export type ShortId = Branded<string, "ShortId">;
export const asShortId = (value: string): ShortId => value as ShortId; export const asShortId = (value: string): ShortId => value as ShortId;
export const isShortId = (value: string): value is ShortId => /^[A-Za-z0-9_-]+$/.test(value);

View file

@ -3,13 +3,13 @@ import path from "node:path";
import fs from "node:fs"; import fs from "node:fs";
import { DATABASE_URL } from "../core/constants"; 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 { export interface CacheOptions {
dbPath?: string; dbPath?: string;
} }
export const createCache = (options: CacheOptions = {}) => { const createCache = (options: CacheOptions = {}) => {
const defaultPath = path.join(path.dirname(DATABASE_URL), "cache.db"); const defaultPath = path.join(path.dirname(DATABASE_URL), "cache.db");
const dbPath = options.dbPath || defaultPath; const dbPath = options.dbPath || defaultPath;

View file

@ -3,7 +3,7 @@ import { db } from "~/server/db/db";
import { member, organization, sessionsTable, usersTable } from "~/server/db/schema"; import { member, organization, sessionsTable, usersTable } from "~/server/db/schema";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
export const COOKIE_PREFIX = "zerobyte"; const COOKIE_PREFIX = "zerobyte";
export function getAuthHeaders(token: string): { Cookie: string } { export function getAuthHeaders(token: string): { Cookie: string } {
return { return {

View file

@ -1,10 +1,5 @@
import { MutationCache, QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { MutationCache, QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { import { render as testingLibraryRender, type RenderOptions } from "@testing-library/react";
render as testingLibraryRender,
renderHook as testingLibraryRenderHook,
type RenderHookOptions,
type RenderOptions,
} from "@testing-library/react";
import testingLibraryUserEvent from "@testing-library/user-event"; import testingLibraryUserEvent from "@testing-library/user-event";
import { Suspense, type ReactElement, type ReactNode } from "react"; import { Suspense, type ReactElement, type ReactNode } from "react";
import { logger } from "~/client/lib/logger"; import { logger } from "~/client/lib/logger";
@ -16,7 +11,6 @@ type TestProviderOptions = {
}; };
type TestRenderOptions = Omit<RenderOptions, "wrapper"> & TestProviderOptions; type TestRenderOptions = Omit<RenderOptions, "wrapper"> & TestProviderOptions;
type TestRenderHookOptions<Props> = Omit<RenderHookOptions<Props>, "wrapper"> & TestProviderOptions;
export const createTestQueryClient = () => { export const createTestQueryClient = () => {
let queryClient: QueryClient; let queryClient: QueryClient;
@ -72,23 +66,7 @@ const customRender = (ui: ReactElement, options: TestRenderOptions = {}) => {
}; };
}; };
const customRenderHook = <Result, Props>(
callback: (initialProps: Props) => Result,
options: TestRenderHookOptions<Props> = {},
) => {
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 * from "@testing-library/react";
export const userEvent = testingLibraryUserEvent.setup(); export const userEvent = testingLibraryUserEvent.setup();
export { customRender as render, customRenderHook as renderHook }; export { customRender as render };

View file

@ -1,5 +1,6 @@
import { defineDocs } from "fumadocs-mdx/config"; import { defineDocs } from "fumadocs-mdx/config";
// fallow-ignore-next-line unused-export
export const docs = defineDocs({ export const docs = defineDocs({
dir: "content/docs", dir: "content/docs",
}); });

View file

@ -6,7 +6,7 @@ export const siteDescription =
"Zerobyte is a web control plane for Restic backups with scheduling, encrypted repositories, monitoring, and restore workflows."; "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 const ogImageUrl = new URL(ogImageAssetUrl, siteUrl).toString();
export function getCanonicalUrl(path: string) { function getCanonicalUrl(path: string) {
return new URL(path, siteUrl).toString(); return new URL(path, siteUrl).toString();
} }

View file

@ -1,6 +1,7 @@
import { createRouter as createTanStackRouter } from "@tanstack/react-router"; import { createRouter as createTanStackRouter } from "@tanstack/react-router";
import { routeTree } from "./routeTree.gen"; import { routeTree } from "./routeTree.gen";
// fallow-ignore-next-line unused-export
export function getRouter() { export function getRouter() {
const router = createTanStackRouter({ const router = createTanStackRouter({
routeTree, routeTree,