UNPKG

@nocobase/plugin-file-manager

Version:

Provides files storage services with files collection template and attachment field.

56 lines (55 loc) 1.92 kB
/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ import { Application } from '@nocobase/server'; import { AttachmentModel, StorageClassType, StorageModel } from '../storages'; export type RepairFilenameStatus = 'pending' | 'repaired' | 'skipped' | 'failed'; export interface RepairFilenameItem { collectionName: string; id: number | string; storageId: number | string; storageType: string; oldPath: string; oldFilename: string; newPath: string; newFilename: string; oldKey: string; newKey: string; sourceExists?: boolean; targetExists?: boolean; status: RepairFilenameStatus; reason?: string; } export interface RepairFilenamesOptions { apply?: boolean; batchSize?: number; limit?: number; } export interface RepairFilenamesResult { dryRun: boolean; scanned: number; candidates: RepairFilenameItem[]; repaired: RepairFilenameItem[]; skipped: RepairFilenameItem[]; failed: RepairFilenameItem[]; } interface FileManagerLike { storageTypes: { get(type: string): StorageClassType | undefined; }; loadStorages(): Promise<void>; storagesCache: Map<number | string, StorageModel>; } export declare function replaceInvisibleChars(value?: string | null): string; export declare function getRepairedAttachmentValues(record: Pick<AttachmentModel, 'path' | 'filename'>): { path: string; filename: string; }; export declare function repairAttachmentFilenames(app: Application, fileManager: FileManagerLike, options?: RepairFilenamesOptions): Promise<RepairFilenamesResult>; export declare function registerRepairFilenamesCommand(app: Application): void; export {};