//
// Copyright 2023 DXOS.org
//
import { importSpace } from '@dxos/client/echo';
import { Serializer } from '@dxos/echo-db';
import { log } from '@dxos/log';
export const exportData = async (space) => {
    const backup = await new Serializer().export(space.internal.db);
    return new Blob([JSON.stringify(backup, null, 2)], { type: 'application/json' });
};
export const importData = async (space, backup) => {
    try {
        const backupString = await backup.text();
        await importSpace(space.internal.db, JSON.parse(backupString));
    }
    catch (err) {
        log.catch(err);
    }
};
//# sourceMappingURL=backup.js.map