chore: cleanup un-used exports (#823)
This commit is contained in:
parent
3f92dace6c
commit
a0c34ee48d
42 changed files with 117 additions and 191 deletions
3
.fallowrc.json
Normal file
3
.fallowrc.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"ignorePatterns": ["node_modules/**", ".output/**", "**/api-client/**", "**/components/ui/**", "**/routeTree.gen.ts"]
|
||||
}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -46,3 +46,4 @@ qa-output
|
|||
.worktrees/
|
||||
.turbo
|
||||
.superset
|
||||
.fallow
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ type ThemeContextValue = {
|
|||
const ThemeContext = createContext<ThemeContextValue | null>(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 }) {
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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.",
|
||||
|
|
|
|||
|
|
@ -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<T>(input: string): T | null {
|
||||
try {
|
||||
return JSON.parse(input) as T;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ const loadRequestClientStore = async (): Promise<RequestClientStore | undefined>
|
|||
return requestClientStorePromise;
|
||||
};
|
||||
|
||||
// fallow-ignore-next-line unused-export
|
||||
export function getRequestClient(): RequestClient {
|
||||
const client = requestClientStore?.getStore();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ client.setConfig({
|
|||
credentials: "include",
|
||||
});
|
||||
|
||||
// fallow-ignore-next-line unused-export
|
||||
export function getRouter() {
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
|
|||
errorComponent: (e) => <div>{e.error.message}</div>,
|
||||
});
|
||||
|
||||
export function RootLayout() {
|
||||
function RootLayout() {
|
||||
const { theme } = Route.useLoaderData();
|
||||
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
||||
useServerEvents({ enabled: !isAuthRoute(pathname) });
|
||||
|
|
|
|||
|
|
@ -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")) {
|
||||
|
|
|
|||
|
|
@ -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<typeof backupEventStatusSchema>;
|
||||
export type BackupStartedEventDto = z.infer<typeof backupStartedEventSchema>;
|
||||
|
|
|
|||
|
|
@ -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<typeof notificationConfigSchema>;
|
||||
|
||||
export const NOTIFICATION_EVENTS = {
|
||||
const NOTIFICATION_EVENTS = {
|
||||
start: "start",
|
||||
success: "success",
|
||||
failure: "failure",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const payload = <T>() => 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<ServerBackupStartedEventDto>(),
|
||||
"backup:progress": payload<ServerBackupProgressEventDto>(),
|
||||
"backup:completed": payload<ServerBackupCompletedEventDto>(),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const withContext = <T>(context: RequestContext, fn: () => T): T => {
|
|||
return requestContextStorage.run(context, fn);
|
||||
};
|
||||
|
||||
export const getRequestContext = (): RequestContext => {
|
||||
const getRequestContext = (): RequestContext => {
|
||||
const context = requestContextStorage.getStore();
|
||||
|
||||
if (!context?.organizationId) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ export const spawnLocalAgent = async () => {
|
|||
await spawnLocalAgentProcess(getAgentRuntimeState());
|
||||
};
|
||||
|
||||
// fallow-ignore-next-line unused-export
|
||||
export const stopLocalAgent = async () => {
|
||||
await stopLocalAgentProcess(getAgentRuntimeState());
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<typeof statusResponseSchema>;
|
||||
|
||||
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(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<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)}`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ export const getBackupScheduleDto = describeRoute({
|
|||
},
|
||||
});
|
||||
|
||||
export const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable();
|
||||
const getBackupScheduleForVolumeResponse = backupScheduleSchema.nullable();
|
||||
|
||||
export type GetBackupScheduleForVolumeResponseDto = z.infer<typeof getBackupScheduleForVolumeResponse>;
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ export const createBackupScheduleBody = z.object({
|
|||
|
||||
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>;
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ export const updateBackupScheduleBody = z.object({
|
|||
|
||||
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>;
|
||||
|
||||
|
|
@ -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<typeof getScheduleMirrorsResponse>;
|
||||
|
||||
export const getScheduleMirrorsDto = describeRoute({
|
||||
|
|
@ -328,7 +328,7 @@ export const updateScheduleMirrorsBody = z.object({
|
|||
|
||||
export type UpdateScheduleMirrorsBody = z.infer<typeof updateScheduleMirrorsBody>;
|
||||
|
||||
export const updateScheduleMirrorsResponse = scheduleMirrorSchema.array();
|
||||
const updateScheduleMirrorsResponse = scheduleMirrorSchema.array();
|
||||
export type UpdateScheduleMirrorsDto = z.infer<typeof updateScheduleMirrorsResponse>;
|
||||
|
||||
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<typeof getMirrorCompatibilityResponse>;
|
||||
|
||||
export const getMirrorCompatibilityDto = describeRoute({
|
||||
|
|
@ -378,7 +378,7 @@ export const reorderBackupSchedulesBody = z.object({
|
|||
|
||||
export type ReorderBackupSchedulesBody = z.infer<typeof reorderBackupSchedulesBody>;
|
||||
|
||||
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<typeof syncMirrorBody>;
|
||||
|
||||
export const syncMirrorResponse = z.object({
|
||||
const syncMirrorResponse = z.object({
|
||||
success: z.boolean(),
|
||||
});
|
||||
export type SyncMirrorDto = z.infer<typeof syncMirrorResponse>;
|
||||
|
|
|
|||
|
|
@ -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 }> = [];
|
||||
|
|
|
|||
|
|
@ -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<typeof notificationDestinationSchema>;
|
||||
|
||||
export const listDestinationsResponse = notificationDestinationSchema.array();
|
||||
const listDestinationsResponse = notificationDestinationSchema.array();
|
||||
export type ListDestinationsDto = z.infer<typeof listDestinationsResponse>;
|
||||
|
||||
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<typeof createDestinationResponse>;
|
||||
|
||||
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 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<typeof updateDestinationResponse>;
|
||||
|
||||
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<typeof deleteDestinationResponse>;
|
||||
|
|
@ -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<typeof testDestinationResponse>;
|
||||
|
|
@ -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<typeof scheduleNotificationAssignmentSchema>;
|
||||
|
||||
export const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array();
|
||||
const getScheduleNotificationsResponse = scheduleNotificationAssignmentSchema.array();
|
||||
export type GetScheduleNotificationsDto = z.infer<typeof getScheduleNotificationsResponse>;
|
||||
|
||||
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<typeof updateScheduleNotificationsResponse>;
|
||||
|
||||
export const updateScheduleNotificationsDto = describeRoute({
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export const repositorySchema = z.object({
|
|||
|
||||
export type RepositoryDto = z.infer<typeof repositorySchema>;
|
||||
|
||||
export const listRepositoriesResponse = repositorySchema.array();
|
||||
const listRepositoriesResponse = repositorySchema.array();
|
||||
export type ListRepositoriesDto = z.infer<typeof listRepositoriesResponse>;
|
||||
|
||||
export const listRepositoriesDto = describeRoute({
|
||||
|
|
@ -56,7 +56,7 @@ export const createRepositoryBody = z.object({
|
|||
|
||||
export type CreateRepositoryBody = z.infer<typeof createRepositoryBody>;
|
||||
|
||||
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<typeof getRepositoryResponse>;
|
||||
|
||||
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<typeof getRepositoryStatsResponse>;
|
||||
|
||||
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 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<typeof updateRepositoryBody>;
|
||||
|
||||
export const updateRepositoryResponse = repositorySchema;
|
||||
const updateRepositoryResponse = repositorySchema;
|
||||
export type UpdateRepositoryDto = z.infer<typeof updateRepositoryResponse>;
|
||||
|
||||
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<typeof getSnapshotDetailsResponse>;
|
||||
|
||||
|
|
@ -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<typeof dumpPathKindSchema>;
|
||||
|
||||
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<typeof restoreSnapshotBody>;
|
||||
|
||||
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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<typeof systemInfoResponse>;
|
||||
|
||||
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(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export const volumeSchema = z.object({
|
|||
|
||||
export type VolumeDto = z.infer<typeof volumeSchema>;
|
||||
|
||||
export const listVolumesResponse = volumeSchema.array();
|
||||
const listVolumesResponse = volumeSchema.array();
|
||||
export type ListVolumesDto = z.infer<typeof listVolumesResponse>;
|
||||
|
||||
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<typeof createVolumeResponse>;
|
||||
|
||||
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<typeof deleteVolumeResponse>;
|
||||
|
|
@ -123,7 +123,7 @@ export const updateVolumeBody = z.object({
|
|||
|
||||
export type UpdateVolumeBody = z.infer<typeof updateVolumeBody>;
|
||||
|
||||
export const updateVolumeResponse = volumeSchema;
|
||||
const updateVolumeResponse = volumeSchema;
|
||||
export type UpdateVolumeDto = z.infer<typeof updateVolumeResponse>;
|
||||
|
||||
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(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<boolean> => {
|
||||
const hasCompatibleCredentials = async (config1: RepositoryConfig, config2: RepositoryConfig): Promise<boolean> => {
|
||||
const group1 = getBackendConflictGroup(config1.backend);
|
||||
const group2 = getBackendConflictGroup(config2.backend);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,5 +5,3 @@ export type Branded<T, B> = T & { [brand]: B };
|
|||
export type ShortId = Branded<string, "ShortId">;
|
||||
|
||||
export const asShortId = (value: string): ShortId => value as ShortId;
|
||||
|
||||
export const isShortId = (value: string): value is ShortId => /^[A-Za-z0-9_-]+$/.test(value);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<RenderOptions, "wrapper"> & TestProviderOptions;
|
||||
type TestRenderHookOptions<Props> = Omit<RenderHookOptions<Props>, "wrapper"> & TestProviderOptions;
|
||||
|
||||
export const createTestQueryClient = () => {
|
||||
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 const userEvent = testingLibraryUserEvent.setup();
|
||||
export { customRender as render, customRenderHook as renderHook };
|
||||
export { customRender as render };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { defineDocs } from "fumadocs-mdx/config";
|
||||
|
||||
// fallow-ignore-next-line unused-export
|
||||
export const docs = defineDocs({
|
||||
dir: "content/docs",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue