feat: local backup enhancements (#714)

This commit is contained in:
Daniel Lautzenheiser
2023-04-19 13:30:21 -04:00
committed by GitHub
parent 39bb9647b2
commit 804c09415b
49 changed files with 348 additions and 140 deletions

View File

@ -27,6 +27,7 @@ import {
getPathDepth,
localForage,
} from './lib/util';
import { getEntryBackupKey } from './lib/util/backup.util';
import {
selectAllowDeletion,
selectAllowNewEntries,
@ -47,6 +48,7 @@ import createEntry from './valueObjects/createEntry';
import type {
BackendClass,
BackendInitializer,
BackupEntry,
BaseField,
Collection,
CollectionFile,
@ -104,15 +106,6 @@ export class LocalStorageAuthStore {
}
}
function getEntryBackupKey(collectionName?: string, slug?: string) {
const baseKey = 'backup';
if (!collectionName) {
return baseKey;
}
const suffix = slug ? `.${slug}` : '';
return `${baseKey}.${collectionName}${suffix}`;
}
export function getEntryField(field: string, entry: Entry): string {
const value = get(entry.data, field);
if (value) {
@ -254,13 +247,6 @@ export interface MediaFile {
isDirectory?: boolean;
}
interface BackupEntry {
raw: string;
path: string;
mediaFiles: MediaFile[];
i18n?: Record<string, { raw: string }>;
}
function collectionDepth<EF extends BaseField>(collection: Collection<EF>) {
let depth;
depth =