mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
refactor(storages): reorganize into types/utils
This commit is contained in:
@@ -7,8 +7,8 @@ import { db, db as dbClient } from "@/db";
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import { dbmsEnumSchema, EDbmsSchema } from "@/db/schema/types";
|
||||
import { withUpdatedAt } from "@/db/utils";
|
||||
import type { StorageInput } from "@/features/storages/storages.types";
|
||||
import { dispatchStorage } from "@/features/storages/storages.dispatch";
|
||||
import type { StorageInput } from "@/features/storages/types";
|
||||
import { dispatchStorage } from "@/features/storages/utils/storages.dispatch";
|
||||
import { Setting } from "@/db/schema/01_setting";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { isUUID } from "@/utils/text";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {NextResponse} from "next/server";
|
||||
import path from "path";
|
||||
import type {StorageInput} from "@/features/storages/storages.types";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import type {StorageInput} from "@/features/storages/types";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import {Readable} from "node:stream";
|
||||
import {logger} from "@/lib/logger";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {NextResponse} from "next/server";
|
||||
import {auth} from "@/lib/auth/auth";
|
||||
import {headers} from "next/headers";
|
||||
import {StorageInput} from "@/features/storages/storages.types";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import {StorageInput} from "@/features/storages/types";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import {Readable} from "node:stream";
|
||||
import {logger} from "@/lib/logger";
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import {useIsMobile} from "@/hooks/use-mobile";
|
||||
import {cn} from "@/lib/utils";
|
||||
import {StorageChannel} from "@/db/schema/12_storage-channel";
|
||||
import {ChannelKind} from "@/features/channel/components/channels-helpers";
|
||||
import type {StorageInput} from "@/features/storages/storages.types";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import type {StorageInput} from "@/features/storages/types";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
|
||||
|
||||
type NotifierTestChannelButtonProps = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
StorageMetaData,
|
||||
StorageResult,
|
||||
StorageUploadInput
|
||||
} from '@/features/storages/storages.types';
|
||||
} from '@/features/storages/types';
|
||||
import {Readable} from "node:stream";
|
||||
|
||||
type BlobConfig = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
StorageMetaData,
|
||||
StorageResult,
|
||||
StorageUploadInput
|
||||
} from '@/features/storages/storages.types';
|
||||
} from '@/features/storages/types';
|
||||
import {GoogleDriveConfig} from "@/features/channel/components/storages/google-drive/types";
|
||||
import {
|
||||
ensureFolderPath,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
getGoogleDriveClient, resolveFilePath
|
||||
} from "@/features/channel/components/storages/google-drive/helpers";
|
||||
import {Readable} from "node:stream";
|
||||
import {generateFileUrl} from "@/features/storages/storages.helpers";
|
||||
import {generateFileUrl} from "@/features/storages/utils/storages.helpers";
|
||||
|
||||
export async function uploadGoogleDrive(
|
||||
config: GoogleDriveConfig,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
StorageProviderKind,
|
||||
StorageInput,
|
||||
StorageResult,
|
||||
} from '@/features/storages/storages.types';
|
||||
} from '@/features/storages/types';
|
||||
|
||||
import {uploadLocal, getLocal, deleteLocal, pingLocal, copyLocal} from './local';
|
||||
import {copyS3, deleteS3, getS3, pingS3, uploadS3} from "@/features/channel/components/storages/s3";
|
||||
|
||||
@@ -8,9 +8,9 @@ import {
|
||||
StorageMetaData,
|
||||
StorageResult,
|
||||
StorageUploadInput,
|
||||
} from '@/features/storages/storages.types';
|
||||
} from '@/features/storages/types';
|
||||
import fs from "node:fs";
|
||||
import { generateFileUrl } from "@/features/storages/storages.helpers";
|
||||
import { generateFileUrl } from "@/features/storages/utils/storages.helpers";
|
||||
import { Readable } from "node:stream";
|
||||
import { env } from "@/env.mjs";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
StorageMetaData,
|
||||
StorageResult,
|
||||
StorageUploadInput
|
||||
} from '@/features/storages/storages.types';
|
||||
} from '@/features/storages/types';
|
||||
import {Readable} from "node:stream";
|
||||
|
||||
type S3Config = {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {z} from "zod";
|
||||
import type {StorageInput} from "@/features/storages/storages.types";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import type {StorageInput} from "@/features/storages/types";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import {db} from "@/db";
|
||||
import {and, eq, isNull, ne, sql} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
|
||||
@@ -7,7 +7,7 @@ import {Backup} from "@/db/schema/07_database";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {z} from "zod";
|
||||
import {storeBackupFiles} from "@/features/storages/storages.helpers";
|
||||
import {storeBackupFiles} from "@/features/storages/utils/storages.helpers";
|
||||
import {getFileExtension} from "@/utils/common";
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import {z} from "zod";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {eq, inArray} from "drizzle-orm";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {getTodayISODate} from "@/utils/date-formatting";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {Json} from "drizzle-zod";
|
||||
|
||||
import * as drizzleDb from '@/db';
|
||||
import {db} from '@/db';
|
||||
import type {StorageInput, StorageProviderKind, StorageResult,} from '@/features/storages/storages.types';
|
||||
import type {StorageInput, StorageProviderKind, StorageResult,} from '@/features/storages/types';
|
||||
import {dispatchViaProvider} from "@/features/channel/storages";
|
||||
import {StorageChannel} from "@/db/schema/12_storage-channel";
|
||||
import {
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
import {Backup, DatabaseWith} from "@/db/schema/07_database";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import type {
|
||||
StorageGetInput,
|
||||
StorageInput,
|
||||
StorageMetaData,
|
||||
StorageResult,
|
||||
StorageUploadInput
|
||||
} from "@/features/storages/storages.types";
|
||||
} from "@/features/storages/types";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
import {eq} from "drizzle-orm";
|
||||
@@ -7,8 +7,8 @@ import {db} from "@/db";
|
||||
import {eq} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {dispatchStorage} from "@/features/storages/storages.dispatch";
|
||||
import {StorageInput} from "@/features/storages/storages.types";
|
||||
import {dispatchStorage} from "@/features/storages/utils/storages.dispatch";
|
||||
import {StorageInput} from "@/features/storages/types";
|
||||
import sharp from "sharp";
|
||||
|
||||
const log = logger.child({module: "features/upload/upload.action"});
|
||||
|
||||
@@ -7,8 +7,8 @@ import { db } from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { withUpdatedAt } from "@/db/utils";
|
||||
import type { StorageInput } from "@/features/storages/storages.types";
|
||||
import { dispatchStorage } from "@/features/storages/storages.dispatch";
|
||||
import type { StorageInput } from "@/features/storages/types";
|
||||
import { dispatchStorage } from "@/features/storages/utils/storages.dispatch";
|
||||
|
||||
export const deleteBackupCronAction = action
|
||||
.schema(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { db } from "@/db";
|
||||
import { env } from "@/env.mjs";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { StorageProviderKind } from "@/features/storages/storages.types";
|
||||
import { StorageProviderKind } from "@/features/storages/types";
|
||||
import { withUpdatedAt } from "@/db/utils";
|
||||
|
||||
export async function createSettingsIfNotExist() {
|
||||
|
||||
Reference in New Issue
Block a user