@nocobase/plugin-backup-restore 1.2.12-alpha → 1.3.0-alpha.20240710084543
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/client/Configuration.d.ts +0 -10
- package/dist/client/DuplicatorProvider.d.ts +0 -10
- package/dist/client/index.d.ts +0 -13
- package/dist/client/index.js +0 -10
- package/dist/client/locale/index.d.ts +0 -12
- package/dist/externalVersion.js +0 -23
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -44
- package/dist/locale/ja-JP.d.ts +0 -33
- package/dist/locale/ja-JP.js +0 -55
- package/dist/locale/ko_KR.json +0 -50
- package/dist/locale/pt-BR.d.ts +0 -34
- package/dist/locale/pt-BR.js +0 -57
- package/dist/locale/zh-CN.json +0 -50
- package/dist/node_modules/@hapi/topo/lib/index.d.ts +0 -60
- package/dist/node_modules/@hapi/topo/lib/index.js +0 -1
- package/dist/node_modules/@hapi/topo/package.json +0 -1
- package/dist/node_modules/archiver/LICENSE +0 -22
- package/dist/node_modules/archiver/index.js +0 -68
- package/dist/node_modules/archiver/lib/core.js +0 -974
- package/dist/node_modules/archiver/lib/error.js +0 -40
- package/dist/node_modules/archiver/lib/plugins/json.js +0 -110
- package/dist/node_modules/archiver/lib/plugins/tar.js +0 -167
- package/dist/node_modules/archiver/lib/plugins/zip.js +0 -120
- package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +0 -127
- package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +0 -116
- package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +0 -17
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +0 -126
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +0 -37
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +0 -1027
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +0 -190
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +0 -641
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -180
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -183
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -96
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -86
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -3
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +0 -52
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -86
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +0 -22
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/dist/node_modules/archiver/node_modules/readable-stream/package.json +0 -68
- package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +0 -9
- package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +0 -16
- package/dist/node_modules/archiver/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/dist/node_modules/archiver/node_modules/string_decoder/package.json +0 -34
- package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +0 -257
- package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +0 -295
- package/dist/node_modules/archiver/node_modules/tar-stream/index.js +0 -2
- package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +0 -255
- package/dist/node_modules/archiver/node_modules/tar-stream/package.json +0 -58
- package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +0 -11
- package/dist/node_modules/archiver/package.json +0 -1
- package/dist/node_modules/decompress/index.js +0 -16
- package/dist/node_modules/decompress/license +0 -9
- package/dist/node_modules/decompress/node_modules/make-dir/index.js +0 -85
- package/dist/node_modules/decompress/node_modules/make-dir/license +0 -9
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/index.js +0 -84
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/license +0 -9
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/package.json +0 -51
- package/dist/node_modules/decompress/node_modules/make-dir/package.json +0 -54
- package/dist/node_modules/decompress/package.json +0 -1
- package/dist/node_modules/mkdirp/LICENSE +0 -21
- package/dist/node_modules/mkdirp/bin/cmd.js +0 -68
- package/dist/node_modules/mkdirp/index.js +0 -1
- package/dist/node_modules/mkdirp/lib/find-made.js +0 -29
- package/dist/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
- package/dist/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
- package/dist/node_modules/mkdirp/lib/opts-arg.js +0 -23
- package/dist/node_modules/mkdirp/lib/path-arg.js +0 -29
- package/dist/node_modules/mkdirp/lib/use-native.js +0 -10
- package/dist/node_modules/mkdirp/package.json +0 -1
- package/dist/node_modules/mkdirp/readme.markdown +0 -266
- package/dist/node_modules/semver/LICENSE +0 -15
- package/dist/node_modules/semver/bin/semver.js +0 -197
- package/dist/node_modules/semver/classes/comparator.js +0 -141
- package/dist/node_modules/semver/classes/index.js +0 -5
- package/dist/node_modules/semver/classes/range.js +0 -539
- package/dist/node_modules/semver/classes/semver.js +0 -302
- package/dist/node_modules/semver/functions/clean.js +0 -6
- package/dist/node_modules/semver/functions/cmp.js +0 -52
- package/dist/node_modules/semver/functions/coerce.js +0 -52
- package/dist/node_modules/semver/functions/compare-build.js +0 -7
- package/dist/node_modules/semver/functions/compare-loose.js +0 -3
- package/dist/node_modules/semver/functions/compare.js +0 -5
- package/dist/node_modules/semver/functions/diff.js +0 -65
- package/dist/node_modules/semver/functions/eq.js +0 -3
- package/dist/node_modules/semver/functions/gt.js +0 -3
- package/dist/node_modules/semver/functions/gte.js +0 -3
- package/dist/node_modules/semver/functions/inc.js +0 -19
- package/dist/node_modules/semver/functions/lt.js +0 -3
- package/dist/node_modules/semver/functions/lte.js +0 -3
- package/dist/node_modules/semver/functions/major.js +0 -3
- package/dist/node_modules/semver/functions/minor.js +0 -3
- package/dist/node_modules/semver/functions/neq.js +0 -3
- package/dist/node_modules/semver/functions/parse.js +0 -16
- package/dist/node_modules/semver/functions/patch.js +0 -3
- package/dist/node_modules/semver/functions/prerelease.js +0 -6
- package/dist/node_modules/semver/functions/rcompare.js +0 -3
- package/dist/node_modules/semver/functions/rsort.js +0 -3
- package/dist/node_modules/semver/functions/satisfies.js +0 -10
- package/dist/node_modules/semver/functions/sort.js +0 -3
- package/dist/node_modules/semver/functions/valid.js +0 -6
- package/dist/node_modules/semver/index.js +0 -1
- package/dist/node_modules/semver/internal/constants.js +0 -35
- package/dist/node_modules/semver/internal/debug.js +0 -9
- package/dist/node_modules/semver/internal/identifiers.js +0 -23
- package/dist/node_modules/semver/internal/parse-options.js +0 -15
- package/dist/node_modules/semver/internal/re.js +0 -212
- package/dist/node_modules/semver/package.json +0 -1
- package/dist/node_modules/semver/preload.js +0 -2
- package/dist/node_modules/semver/range.bnf +0 -16
- package/dist/node_modules/semver/ranges/gtr.js +0 -4
- package/dist/node_modules/semver/ranges/intersects.js +0 -7
- package/dist/node_modules/semver/ranges/ltr.js +0 -4
- package/dist/node_modules/semver/ranges/max-satisfying.js +0 -25
- package/dist/node_modules/semver/ranges/min-satisfying.js +0 -24
- package/dist/node_modules/semver/ranges/min-version.js +0 -61
- package/dist/node_modules/semver/ranges/outside.js +0 -80
- package/dist/node_modules/semver/ranges/simplify.js +0 -47
- package/dist/node_modules/semver/ranges/subset.js +0 -247
- package/dist/node_modules/semver/ranges/to-comparators.js +0 -8
- package/dist/node_modules/semver/ranges/valid.js +0 -11
- package/dist/server/app-migrator.d.ts +0 -25
- package/dist/server/app-migrator.js +0 -70
- package/dist/server/commands/restore-command.d.ts +0 -10
- package/dist/server/commands/restore-command.js +0 -77
- package/dist/server/dumper.d.ts +0 -79
- package/dist/server/dumper.js +0 -420
- package/dist/server/errors/restore-check-error.d.ts +0 -11
- package/dist/server/errors/restore-check-error.js +0 -41
- package/dist/server/field-value-writer.d.ts +0 -17
- package/dist/server/field-value-writer.js +0 -110
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.js +0 -42
- package/dist/server/locale/zh-CN.d.ts +0 -17
- package/dist/server/locale/zh-CN.js +0 -39
- package/dist/server/migrations/20240618103927-update-snippet-name.d.ts +0 -14
- package/dist/server/migrations/20240618103927-update-snippet-name.js +0 -60
- package/dist/server/resourcers/backup-files.d.ts +0 -33
- package/dist/server/resourcers/backup-files.js +0 -202
- package/dist/server/restorer.d.ts +0 -43
- package/dist/server/restorer.js +0 -363
- package/dist/server/server.d.ts +0 -13
- package/dist/server/server.js +0 -54
- package/dist/server/utils.d.ts +0 -13
- package/dist/server/utils.js +0 -87
- package/dist/swagger/index.d.ts +0 -400
- package/dist/swagger/index.js +0 -456
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var zh_CN_exports = {};
|
|
28
|
-
__export(zh_CN_exports, {
|
|
29
|
-
default: () => zh_CN_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(zh_CN_exports);
|
|
32
|
-
var zh_CN_default = {
|
|
33
|
-
"Select Import data": "\u8BF7\u9009\u62E9\u5BFC\u5165\u6570\u636E",
|
|
34
|
-
"Select Import Plugins": "\u8BF7\u9009\u62E9\u5BFC\u5165\u63D2\u4EF6",
|
|
35
|
-
"Select User Collections": "\u8BF7\u9009\u62E9\u7528\u6237\u6570\u636E",
|
|
36
|
-
"Basic Data": "\u57FA\u7840\u6570\u636E",
|
|
37
|
-
"Optional Data": "\u53EF\u9009\u6570\u636E",
|
|
38
|
-
"User Data": "\u7528\u6237\u6570\u636E"
|
|
39
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Migration } from '@nocobase/server';
|
|
10
|
-
export default class extends Migration {
|
|
11
|
-
on: string;
|
|
12
|
-
appVersion: string;
|
|
13
|
-
up(): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var update_snippet_name_exports = {};
|
|
28
|
-
__export(update_snippet_name_exports, {
|
|
29
|
-
default: () => update_snippet_name_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(update_snippet_name_exports);
|
|
32
|
-
var import_server = require("@nocobase/server");
|
|
33
|
-
class update_snippet_name_default extends import_server.Migration {
|
|
34
|
-
on = "afterLoad";
|
|
35
|
-
// 'beforeLoad' or 'afterLoad'
|
|
36
|
-
appVersion = "<1.2.4-alpha";
|
|
37
|
-
async up() {
|
|
38
|
-
const roles = await this.db.getRepository("roles").find();
|
|
39
|
-
for (const role of roles) {
|
|
40
|
-
const snippets = await role.get("snippets");
|
|
41
|
-
let roleNeedsUpdate = false;
|
|
42
|
-
for (let i = 0; i < snippets.length; i++) {
|
|
43
|
-
if (snippets[i].includes("pm.backup.restore")) {
|
|
44
|
-
snippets[i] = snippets[i].replace("pm.backup.restore", "pm.backup-restore");
|
|
45
|
-
roleNeedsUpdate = true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (roleNeedsUpdate) {
|
|
49
|
-
await this.db.getRepository("roles").update({
|
|
50
|
-
filter: {
|
|
51
|
-
name: role.get("name")
|
|
52
|
-
},
|
|
53
|
-
values: {
|
|
54
|
-
snippets: JSON.parse(JSON.stringify(snippets))
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
name: string;
|
|
11
|
-
middleware: (ctx: any, next: any) => Promise<any>;
|
|
12
|
-
actions: {
|
|
13
|
-
list(ctx: any, next: any): Promise<void>;
|
|
14
|
-
get(ctx: any, next: any): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* create dump task
|
|
17
|
-
* @param ctx
|
|
18
|
-
* @param next
|
|
19
|
-
*/
|
|
20
|
-
create(ctx: any, next: any): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* download backup file
|
|
23
|
-
* @param ctx
|
|
24
|
-
* @param next
|
|
25
|
-
*/
|
|
26
|
-
download(ctx: any, next: any): Promise<void>;
|
|
27
|
-
restore(ctx: any, next: any): Promise<void>;
|
|
28
|
-
destroy(ctx: any, next: any): Promise<void>;
|
|
29
|
-
upload(ctx: any, next: any): Promise<void>;
|
|
30
|
-
dumpableCollections(ctx: any, next: any): Promise<void>;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export default _default;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var backup_files_exports = {};
|
|
38
|
-
__export(backup_files_exports, {
|
|
39
|
-
default: () => backup_files_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(backup_files_exports);
|
|
42
|
-
var import_dumper = require("../dumper");
|
|
43
|
-
var import_fs = __toESM(require("fs"));
|
|
44
|
-
var import_utils = require("@nocobase/utils");
|
|
45
|
-
var import_os = __toESM(require("os"));
|
|
46
|
-
var import_path = __toESM(require("path"));
|
|
47
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
48
|
-
var import_restorer = require("../restorer");
|
|
49
|
-
var import_actions = require("@nocobase/actions");
|
|
50
|
-
var backup_files_default = {
|
|
51
|
-
name: "backupFiles",
|
|
52
|
-
middleware: async (ctx, next) => {
|
|
53
|
-
if (ctx.action.actionName !== "upload") {
|
|
54
|
-
return next();
|
|
55
|
-
}
|
|
56
|
-
const storage = import_utils.koaMulter.diskStorage({
|
|
57
|
-
destination: import_os.default.tmpdir(),
|
|
58
|
-
filename: function(req, file, cb) {
|
|
59
|
-
const randomName = Date.now().toString() + Math.random().toString().slice(2);
|
|
60
|
-
cb(null, randomName);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const upload = (0, import_utils.koaMulter)({ storage }).single("file");
|
|
64
|
-
return upload(ctx, next);
|
|
65
|
-
},
|
|
66
|
-
actions: {
|
|
67
|
-
async list(ctx, next) {
|
|
68
|
-
const { page = import_actions.DEFAULT_PAGE, pageSize = import_actions.DEFAULT_PER_PAGE } = ctx.action.params;
|
|
69
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
70
|
-
const backupFiles = await dumper.allBackUpFilePaths({
|
|
71
|
-
includeInProgress: true
|
|
72
|
-
});
|
|
73
|
-
const count = backupFiles.length;
|
|
74
|
-
const rows = await Promise.all(
|
|
75
|
-
backupFiles.slice((page - 1) * pageSize, page * pageSize).map(async (file) => {
|
|
76
|
-
return await import_dumper.Dumper.getFileStatus(file.endsWith(".lock") ? file.replace(".lock", "") : file);
|
|
77
|
-
})
|
|
78
|
-
);
|
|
79
|
-
ctx.body = {
|
|
80
|
-
count,
|
|
81
|
-
rows,
|
|
82
|
-
page: Number(page),
|
|
83
|
-
pageSize: Number(pageSize),
|
|
84
|
-
totalPage: Math.ceil(count / pageSize)
|
|
85
|
-
};
|
|
86
|
-
await next();
|
|
87
|
-
},
|
|
88
|
-
async get(ctx, next) {
|
|
89
|
-
const { filterByTk } = ctx.action.params;
|
|
90
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
91
|
-
const filePath = dumper.backUpFilePath(filterByTk);
|
|
92
|
-
async function sendError(message, status = 404) {
|
|
93
|
-
ctx.body = { status: "error", message };
|
|
94
|
-
ctx.status = status;
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
const fileState = await import_dumper.Dumper.getFileStatus(filePath);
|
|
98
|
-
if (fileState.status !== "ok") {
|
|
99
|
-
await sendError(`Backup file ${filterByTk} not found`);
|
|
100
|
-
} else {
|
|
101
|
-
const restorer = new import_restorer.Restorer(ctx.app, {
|
|
102
|
-
backUpFilePath: filePath
|
|
103
|
-
});
|
|
104
|
-
const restoreMeta = await restorer.parseBackupFile();
|
|
105
|
-
ctx.body = {
|
|
106
|
-
...fileState,
|
|
107
|
-
meta: restoreMeta
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
} catch (e) {
|
|
111
|
-
if (e.code === "ENOENT") {
|
|
112
|
-
await sendError(`Backup file ${filterByTk} not found`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
await next();
|
|
116
|
-
},
|
|
117
|
-
/**
|
|
118
|
-
* create dump task
|
|
119
|
-
* @param ctx
|
|
120
|
-
* @param next
|
|
121
|
-
*/
|
|
122
|
-
async create(ctx, next) {
|
|
123
|
-
const data = ctx.request.body;
|
|
124
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
125
|
-
const taskId = await dumper.runDumpTask({
|
|
126
|
-
groups: new Set(data.dataTypes)
|
|
127
|
-
});
|
|
128
|
-
ctx.body = {
|
|
129
|
-
key: taskId
|
|
130
|
-
};
|
|
131
|
-
await next();
|
|
132
|
-
},
|
|
133
|
-
/**
|
|
134
|
-
* download backup file
|
|
135
|
-
* @param ctx
|
|
136
|
-
* @param next
|
|
137
|
-
*/
|
|
138
|
-
async download(ctx, next) {
|
|
139
|
-
const { filterByTk } = ctx.action.params;
|
|
140
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
141
|
-
const filePath = dumper.backUpFilePath(filterByTk);
|
|
142
|
-
const fileState = await import_dumper.Dumper.getFileStatus(filePath);
|
|
143
|
-
if (fileState.status !== "ok") {
|
|
144
|
-
throw new Error(`Backup file ${filterByTk} not found`);
|
|
145
|
-
}
|
|
146
|
-
ctx.attachment(filePath);
|
|
147
|
-
ctx.body = import_fs.default.createReadStream(filePath);
|
|
148
|
-
await next();
|
|
149
|
-
},
|
|
150
|
-
async restore(ctx, next) {
|
|
151
|
-
const { dataTypes, filterByTk, key } = ctx.action.params.values;
|
|
152
|
-
const filePath = (() => {
|
|
153
|
-
if (key) {
|
|
154
|
-
const tmpDir = import_os.default.tmpdir();
|
|
155
|
-
return import_path.default.resolve(tmpDir, key);
|
|
156
|
-
}
|
|
157
|
-
if (filterByTk) {
|
|
158
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
159
|
-
return dumper.backUpFilePath(filterByTk);
|
|
160
|
-
}
|
|
161
|
-
})();
|
|
162
|
-
if (!filePath) {
|
|
163
|
-
throw new Error(`Backup file ${filterByTk} not found`);
|
|
164
|
-
}
|
|
165
|
-
const args = ["restore", "-f", filePath];
|
|
166
|
-
for (const dataType of dataTypes) {
|
|
167
|
-
args.push("-g", dataType);
|
|
168
|
-
}
|
|
169
|
-
await ctx.app.runCommand(...args);
|
|
170
|
-
await next();
|
|
171
|
-
},
|
|
172
|
-
async destroy(ctx, next) {
|
|
173
|
-
const { filterByTk } = ctx.action.params;
|
|
174
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
175
|
-
const filePath = dumper.backUpFilePath(filterByTk);
|
|
176
|
-
await import_promises.default.unlink(filePath);
|
|
177
|
-
ctx.body = {
|
|
178
|
-
status: "ok"
|
|
179
|
-
};
|
|
180
|
-
await next();
|
|
181
|
-
},
|
|
182
|
-
async upload(ctx, next) {
|
|
183
|
-
const file = ctx.file;
|
|
184
|
-
const fileName = file.filename;
|
|
185
|
-
const restorer = new import_restorer.Restorer(ctx.app, {
|
|
186
|
-
backUpFilePath: file.path
|
|
187
|
-
});
|
|
188
|
-
const restoreMeta = await restorer.parseBackupFile();
|
|
189
|
-
ctx.body = {
|
|
190
|
-
key: fileName,
|
|
191
|
-
meta: restoreMeta
|
|
192
|
-
};
|
|
193
|
-
await next();
|
|
194
|
-
},
|
|
195
|
-
async dumpableCollections(ctx, next) {
|
|
196
|
-
ctx.withoutDataWrapping = true;
|
|
197
|
-
const dumper = new import_dumper.Dumper(ctx.app);
|
|
198
|
-
ctx.body = await dumper.dumpableCollectionsGroupByGroup();
|
|
199
|
-
await next();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { AppMigrator, AppMigratorOptions } from './app-migrator';
|
|
10
|
-
import { Application } from '@nocobase/server';
|
|
11
|
-
import { DumpRulesGroupType } from '@nocobase/database';
|
|
12
|
-
type RestoreOptions = {
|
|
13
|
-
groups: Set<DumpRulesGroupType>;
|
|
14
|
-
};
|
|
15
|
-
export declare class Restorer extends AppMigrator {
|
|
16
|
-
direction: "restore";
|
|
17
|
-
backUpFilePath: string;
|
|
18
|
-
decompressed: boolean;
|
|
19
|
-
importedCollections: string[];
|
|
20
|
-
constructor(app: Application, options: AppMigratorOptions & {
|
|
21
|
-
backUpFilePath?: string;
|
|
22
|
-
});
|
|
23
|
-
static sortCollectionsByInherits(collections: Array<{
|
|
24
|
-
name: string;
|
|
25
|
-
inherits: string[];
|
|
26
|
-
}>): any;
|
|
27
|
-
setBackUpFilePath(backUpFilePath: string): void;
|
|
28
|
-
parseBackupFile(): Promise<any>;
|
|
29
|
-
restore(options: RestoreOptions): Promise<void>;
|
|
30
|
-
getImportMeta(): Promise<any>;
|
|
31
|
-
checkMeta(): Promise<void>;
|
|
32
|
-
importCollections(options: RestoreOptions): Promise<void>;
|
|
33
|
-
decompressBackup(backupFilePath: string): Promise<void>;
|
|
34
|
-
readCollectionMeta(collectionName: string): Promise<any>;
|
|
35
|
-
importCollection(options: {
|
|
36
|
-
name: string;
|
|
37
|
-
insert?: boolean;
|
|
38
|
-
clear?: boolean;
|
|
39
|
-
rowCondition?: (row: any) => boolean;
|
|
40
|
-
}): Promise<any>;
|
|
41
|
-
importDb(options: RestoreOptions): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
export {};
|