@nocobase/plugin-backup-restore 2.1.0-alpha.2 → 2.1.0-alpha.20
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/LICENSE +201 -661
- package/README.md +79 -10
- package/dist/client/370.f951dd2ebca3bb32.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/node_modules/@hapi/topo/package.json +1 -1
- package/dist/node_modules/archiver/package.json +1 -1
- package/dist/node_modules/decompress/index.js +3 -3
- package/dist/node_modules/decompress/node_modules/make-dir/index.js +85 -0
- package/dist/node_modules/decompress/node_modules/make-dir/license +9 -0
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/index.js +84 -0
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/license +9 -0
- package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/package.json +51 -0
- package/dist/node_modules/decompress/node_modules/make-dir/package.json +54 -0
- package/dist/node_modules/decompress/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/moment/package.json +1 -1
- package/dist/node_modules/semver/package.json +1 -1
- package/dist/server/dumper.js +9 -9
- package/dist/server/restorer.js +4 -3
- package/package.json +3 -3
- package/dist/client/e4f348aa71db3614.js +0 -10
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const pify = require('pify');
|
|
5
|
+
|
|
6
|
+
const defaults = {
|
|
7
|
+
mode: 0o777 & (~process.umask()),
|
|
8
|
+
fs
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// https://github.com/nodejs/node/issues/8987
|
|
12
|
+
// https://github.com/libuv/libuv/pull/1088
|
|
13
|
+
const checkPath = pth => {
|
|
14
|
+
if (process.platform === 'win32') {
|
|
15
|
+
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
|
|
16
|
+
|
|
17
|
+
if (pathHasInvalidWinCharacters) {
|
|
18
|
+
const err = new Error(`Path contains invalid characters: ${pth}`);
|
|
19
|
+
err.code = 'EINVAL';
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = (input, opts) => Promise.resolve().then(() => {
|
|
26
|
+
checkPath(input);
|
|
27
|
+
opts = Object.assign({}, defaults, opts);
|
|
28
|
+
|
|
29
|
+
const mkdir = pify(opts.fs.mkdir);
|
|
30
|
+
const stat = pify(opts.fs.stat);
|
|
31
|
+
|
|
32
|
+
const make = pth => {
|
|
33
|
+
return mkdir(pth, opts.mode)
|
|
34
|
+
.then(() => pth)
|
|
35
|
+
.catch(err => {
|
|
36
|
+
if (err.code === 'ENOENT') {
|
|
37
|
+
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return make(path.dirname(pth)).then(() => make(pth));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return stat(pth)
|
|
45
|
+
.then(stats => stats.isDirectory() ? pth : Promise.reject())
|
|
46
|
+
.catch(() => {
|
|
47
|
+
throw err;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return make(path.resolve(input));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
module.exports.sync = (input, opts) => {
|
|
56
|
+
checkPath(input);
|
|
57
|
+
opts = Object.assign({}, defaults, opts);
|
|
58
|
+
|
|
59
|
+
const make = pth => {
|
|
60
|
+
try {
|
|
61
|
+
opts.fs.mkdirSync(pth, opts.mode);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (err.code === 'ENOENT') {
|
|
64
|
+
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
make(path.dirname(pth));
|
|
69
|
+
return make(pth);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
if (!opts.fs.statSync(pth).isDirectory()) {
|
|
74
|
+
throw new Error('The path is not a directory');
|
|
75
|
+
}
|
|
76
|
+
} catch (_) {
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return pth;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return make(path.resolve(input));
|
|
85
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const processFn = (fn, opts) => function () {
|
|
4
|
+
const P = opts.promiseModule;
|
|
5
|
+
const args = new Array(arguments.length);
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
8
|
+
args[i] = arguments[i];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return new P((resolve, reject) => {
|
|
12
|
+
if (opts.errorFirst) {
|
|
13
|
+
args.push(function (err, result) {
|
|
14
|
+
if (opts.multiArgs) {
|
|
15
|
+
const results = new Array(arguments.length - 1);
|
|
16
|
+
|
|
17
|
+
for (let i = 1; i < arguments.length; i++) {
|
|
18
|
+
results[i - 1] = arguments[i];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (err) {
|
|
22
|
+
results.unshift(err);
|
|
23
|
+
reject(results);
|
|
24
|
+
} else {
|
|
25
|
+
resolve(results);
|
|
26
|
+
}
|
|
27
|
+
} else if (err) {
|
|
28
|
+
reject(err);
|
|
29
|
+
} else {
|
|
30
|
+
resolve(result);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
args.push(function (result) {
|
|
35
|
+
if (opts.multiArgs) {
|
|
36
|
+
const results = new Array(arguments.length - 1);
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
39
|
+
results[i] = arguments[i];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
resolve(results);
|
|
43
|
+
} else {
|
|
44
|
+
resolve(result);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fn.apply(this, args);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = (obj, opts) => {
|
|
54
|
+
opts = Object.assign({
|
|
55
|
+
exclude: [/.+(Sync|Stream)$/],
|
|
56
|
+
errorFirst: true,
|
|
57
|
+
promiseModule: Promise
|
|
58
|
+
}, opts);
|
|
59
|
+
|
|
60
|
+
const filter = key => {
|
|
61
|
+
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
62
|
+
return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
let ret;
|
|
66
|
+
if (typeof obj === 'function') {
|
|
67
|
+
ret = function () {
|
|
68
|
+
if (opts.excludeMain) {
|
|
69
|
+
return obj.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return processFn(obj, opts).apply(this, arguments);
|
|
73
|
+
};
|
|
74
|
+
} else {
|
|
75
|
+
ret = Object.create(Object.getPrototypeOf(obj));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (const key in obj) { // eslint-disable-line guard-for-in
|
|
79
|
+
const x = obj[key];
|
|
80
|
+
ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return ret;
|
|
84
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pify",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Promisify a callback-style function",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/pify",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Sindre Sorhus",
|
|
9
|
+
"email": "sindresorhus@gmail.com",
|
|
10
|
+
"url": "sindresorhus.com"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=4"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "xo && ava && npm run optimization-test",
|
|
17
|
+
"optimization-test": "node --allow-natives-syntax optimization-test.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"index.js"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"promise",
|
|
24
|
+
"promises",
|
|
25
|
+
"promisify",
|
|
26
|
+
"all",
|
|
27
|
+
"denodify",
|
|
28
|
+
"denodeify",
|
|
29
|
+
"callback",
|
|
30
|
+
"cb",
|
|
31
|
+
"node",
|
|
32
|
+
"then",
|
|
33
|
+
"thenify",
|
|
34
|
+
"convert",
|
|
35
|
+
"transform",
|
|
36
|
+
"wrap",
|
|
37
|
+
"wrapper",
|
|
38
|
+
"bind",
|
|
39
|
+
"to",
|
|
40
|
+
"async",
|
|
41
|
+
"await",
|
|
42
|
+
"es2015",
|
|
43
|
+
"bluebird"
|
|
44
|
+
],
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"ava": "*",
|
|
47
|
+
"pinkie-promise": "^2.0.0",
|
|
48
|
+
"v8-natives": "^1.0.0",
|
|
49
|
+
"xo": "*"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "make-dir",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Make a directory and its parents if needed - Think `mkdir -p`",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/make-dir",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Sindre Sorhus",
|
|
9
|
+
"email": "sindresorhus@gmail.com",
|
|
10
|
+
"url": "sindresorhus.com"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=4"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "xo && nyc ava"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"index.js"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"mkdir",
|
|
23
|
+
"mkdirp",
|
|
24
|
+
"make",
|
|
25
|
+
"directories",
|
|
26
|
+
"dir",
|
|
27
|
+
"dirs",
|
|
28
|
+
"folders",
|
|
29
|
+
"directory",
|
|
30
|
+
"folder",
|
|
31
|
+
"path",
|
|
32
|
+
"parent",
|
|
33
|
+
"parents",
|
|
34
|
+
"intermediate",
|
|
35
|
+
"recursively",
|
|
36
|
+
"recursive",
|
|
37
|
+
"create",
|
|
38
|
+
"fs",
|
|
39
|
+
"filesystem",
|
|
40
|
+
"file-system"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"pify": "^3.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"ava": "*",
|
|
47
|
+
"codecov": "^3.0.0",
|
|
48
|
+
"graceful-fs": "^4.1.11",
|
|
49
|
+
"nyc": "^11.3.0",
|
|
50
|
+
"path-type": "^3.0.0",
|
|
51
|
+
"tempy": "^0.2.1",
|
|
52
|
+
"xo": "^0.20.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"decompress","version":"4.2.1","description":"Extracting archives made easy","license":"MIT","repository":"kevva/decompress","author":{"name":"Kevin Mårtensson","email":"kevinmartensson@gmail.com","url":"github.com/kevva"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["bz2","bzip2","decompress","extract","tar","tar.bz","tar.gz","zip","unzip"],"dependencies":{"decompress-tar":"^4.0.0","decompress-tarbz2":"^4.0.0","decompress-targz":"^4.0.0","decompress-unzip":"^4.0.1","graceful-fs":"^4.1.10","make-dir":"^1.0.0","pify":"^2.3.0","strip-dirs":"^2.0.0"},"devDependencies":{"ava":"*","esm":"^3.2.25","is-jpg":"^1.0.0","path-exists":"^3.0.0","pify":"^2.3.0","rimraf":"^3.0.2","xo":"*"},"ava":{"require":["esm"]},"xo":{"rules":{"promise/prefer-await-to-then":"off"}},"_lastModified":"2026-
|
|
1
|
+
{"name":"decompress","version":"4.2.1","description":"Extracting archives made easy","license":"MIT","repository":"kevva/decompress","author":{"name":"Kevin Mårtensson","email":"kevinmartensson@gmail.com","url":"github.com/kevva"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["bz2","bzip2","decompress","extract","tar","tar.bz","tar.gz","zip","unzip"],"dependencies":{"decompress-tar":"^4.0.0","decompress-tarbz2":"^4.0.0","decompress-targz":"^4.0.0","decompress-unzip":"^4.0.1","graceful-fs":"^4.1.10","make-dir":"^1.0.0","pify":"^2.3.0","strip-dirs":"^2.0.0"},"devDependencies":{"ava":"*","esm":"^3.2.25","is-jpg":"^1.0.0","path-exists":"^3.0.0","pify":"^2.3.0","rimraf":"^3.0.2","xo":"*"},"ava":{"require":["esm"]},"xo":{"rules":{"promise/prefer-await-to-then":"off"}},"_lastModified":"2026-04-20T10:42:42.667Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"fs-extra","version":"9.1.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=10"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"at-least-node":"^1.0.0","graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"coveralls":"^3.0.0","klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^5.0.5","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^14.1.0"},"main":"./lib/index.js","files":["lib/","!lib/**/__tests__/"],"scripts":{"full-ci":"npm run lint && npm run coverage","coverage":"nyc -r lcovonly npm run unit","coveralls":"coveralls < coverage/lcov.info","lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit","unit":"node test.js"},"_lastModified":"2026-
|
|
1
|
+
{"name":"fs-extra","version":"9.1.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=10"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"at-least-node":"^1.0.0","graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"coveralls":"^3.0.0","klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^5.0.5","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^14.1.0"},"main":"./lib/index.js","files":["lib/","!lib/**/__tests__/"],"scripts":{"full-ci":"npm run lint && npm run coverage","coverage":"nyc -r lcovonly npm run unit","coveralls":"coveralls < coverage/lcov.info","lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit","unit":"node test.js"},"_lastModified":"2026-04-20T10:42:41.381Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"moment","version":"2.29.4","description":"Parse, validate, manipulate, and display dates","homepage":"https://momentjs.com","author":"Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)","contributors":["Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)","Rocky Meza (http://rockymeza.com)","Matt Johnson <mj1856@hotmail.com> (http://codeofmatt.com)","Isaac Cambron <isaac@isaaccambron.com> (http://isaaccambron.com)","Andre Polykanine <andre@oire.org> (https://github.com/oire)"],"keywords":["moment","date","time","parse","format","validate","i18n","l10n","ender"],"main":"./moment.js","jsnext:main":"./dist/moment.js","typings":"./moment.d.ts","typesVersions":{">=3.1":{"*":["ts3.1-typings/*"]}},"engines":{"node":"*"},"repository":{"type":"git","url":"https://github.com/moment/moment.git"},"bugs":{"url":"https://github.com/moment/moment/issues"},"license":"MIT","devDependencies":{"benchmark":"latest","coveralls":"latest","cross-env":"^6.0.3","es6-promise":"latest","eslint":"~6","grunt":"latest","grunt-benchmark":"latest","grunt-cli":"latest","grunt-contrib-clean":"latest","grunt-contrib-concat":"latest","grunt-contrib-copy":"latest","grunt-contrib-uglify":"latest","grunt-contrib-watch":"latest","grunt-env":"latest","grunt-exec":"latest","grunt-karma":"latest","grunt-nuget":"latest","grunt-string-replace":"latest","karma":"latest","karma-chrome-launcher":"latest","karma-firefox-launcher":"latest","karma-qunit":"latest","karma-sauce-launcher":"4.1.4","load-grunt-tasks":"latest","lodash":">=4.17.19","node-qunit":"latest","nyc":"latest","prettier":"latest","qunit":"^2.10.0","rollup":"2.17.1","typescript":"^1.8.10","typescript3":"npm:typescript@^3.1.6","uglify-js":"latest"},"ender":"./ender.js","dojoBuild":"package.js","jspm":{"files":["moment.js","moment.d.ts","locale"],"map":{"moment":"./moment"},"buildConfig":{"uglify":true}},"scripts":{"ts3.1-typescript-test":"cross-env node_modules/typescript3/bin/tsc --project ts3.1-typing-tests","typescript-test":"cross-env node_modules/typescript/bin/tsc --project typing-tests","test":"grunt test","eslint":"eslint Gruntfile.js tasks src","prettier-check":"prettier --check Gruntfile.js tasks src","prettier-fmt":"prettier --write Gruntfile.js tasks src","coverage":"nyc npm test && nyc report","coveralls":"nyc npm test && nyc report --reporter=text-lcov | coveralls"},"spm":{"main":"moment.js","output":["locale/*.js"]},"_lastModified":"2026-
|
|
1
|
+
{"name":"moment","version":"2.29.4","description":"Parse, validate, manipulate, and display dates","homepage":"https://momentjs.com","author":"Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)","contributors":["Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)","Rocky Meza (http://rockymeza.com)","Matt Johnson <mj1856@hotmail.com> (http://codeofmatt.com)","Isaac Cambron <isaac@isaaccambron.com> (http://isaaccambron.com)","Andre Polykanine <andre@oire.org> (https://github.com/oire)"],"keywords":["moment","date","time","parse","format","validate","i18n","l10n","ender"],"main":"./moment.js","jsnext:main":"./dist/moment.js","typings":"./moment.d.ts","typesVersions":{">=3.1":{"*":["ts3.1-typings/*"]}},"engines":{"node":"*"},"repository":{"type":"git","url":"https://github.com/moment/moment.git"},"bugs":{"url":"https://github.com/moment/moment/issues"},"license":"MIT","devDependencies":{"benchmark":"latest","coveralls":"latest","cross-env":"^6.0.3","es6-promise":"latest","eslint":"~6","grunt":"latest","grunt-benchmark":"latest","grunt-cli":"latest","grunt-contrib-clean":"latest","grunt-contrib-concat":"latest","grunt-contrib-copy":"latest","grunt-contrib-uglify":"latest","grunt-contrib-watch":"latest","grunt-env":"latest","grunt-exec":"latest","grunt-karma":"latest","grunt-nuget":"latest","grunt-string-replace":"latest","karma":"latest","karma-chrome-launcher":"latest","karma-firefox-launcher":"latest","karma-qunit":"latest","karma-sauce-launcher":"4.1.4","load-grunt-tasks":"latest","lodash":">=4.17.19","node-qunit":"latest","nyc":"latest","prettier":"latest","qunit":"^2.10.0","rollup":"2.17.1","typescript":"^1.8.10","typescript3":"npm:typescript@^3.1.6","uglify-js":"latest"},"ender":"./ender.js","dojoBuild":"package.js","jspm":{"files":["moment.js","moment.d.ts","locale"],"map":{"moment":"./moment"},"buildConfig":{"uglify":true}},"scripts":{"ts3.1-typescript-test":"cross-env node_modules/typescript3/bin/tsc --project ts3.1-typing-tests","typescript-test":"cross-env node_modules/typescript/bin/tsc --project typing-tests","test":"grunt test","eslint":"eslint Gruntfile.js tasks src","prettier-check":"prettier --check Gruntfile.js tasks src","prettier-fmt":"prettier --write Gruntfile.js tasks src","coverage":"nyc npm test && nyc report","coveralls":"nyc npm test && nyc report --reporter=text-lcov | coveralls"},"spm":{"main":"moment.js","output":["locale/*.js"]},"_lastModified":"2026-04-20T10:42:41.921Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"semver","version":"7.7.1","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"npm run eslint","postlint":"template-oss-check","lintfix":"npm run eslint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""},"devDependencies":{"@npmcli/eslint-config":"^5.0.0","@npmcli/template-oss":"4.23.4","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.23.4","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2026-
|
|
1
|
+
{"name":"semver","version":"7.7.1","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"npm run eslint","postlint":"template-oss-check","lintfix":"npm run eslint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""},"devDependencies":{"@npmcli/eslint-config":"^5.0.0","@npmcli/template-oss":"4.23.4","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.23.4","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2026-04-20T10:42:43.179Z"}
|
package/dist/server/dumper.js
CHANGED
|
@@ -47,12 +47,13 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
47
47
|
var import_promises = __toESM(require("fs/promises"));
|
|
48
48
|
var import_lodash = __toESM(require("lodash"));
|
|
49
49
|
var import_path = __toESM(require("path"));
|
|
50
|
+
var import_utils = require("@nocobase/utils");
|
|
50
51
|
var process = __toESM(require("process"));
|
|
51
52
|
var import_stream = __toESM(require("stream"));
|
|
52
53
|
var import_util = __toESM(require("util"));
|
|
53
54
|
var import_app_migrator = require("./app-migrator");
|
|
54
55
|
var import_field_value_writer = require("./field-value-writer");
|
|
55
|
-
var
|
|
56
|
+
var import_utils2 = require("./utils");
|
|
56
57
|
const finished = import_util.default.promisify(import_stream.default.finished);
|
|
57
58
|
class Dumper extends import_app_migrator.AppMigrator {
|
|
58
59
|
static dumpTasks = /* @__PURE__ */ new Map();
|
|
@@ -81,7 +82,7 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
81
82
|
return {
|
|
82
83
|
name: fileName,
|
|
83
84
|
createdAt: backupFileStat.ctime,
|
|
84
|
-
fileSize: (0,
|
|
85
|
+
fileSize: (0, import_utils2.humanFileSize)(backupFileStat.size),
|
|
85
86
|
status: "ok"
|
|
86
87
|
};
|
|
87
88
|
} else {
|
|
@@ -93,7 +94,7 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
static generateFileName() {
|
|
96
|
-
return `backup_${(0, import_dayjs.default)().format(`YYYYMMDD_HHmmss_${Math.floor(1e3 + Math.random() * 9e3)}`)}.${
|
|
97
|
+
return `backup_${(0, import_dayjs.default)().format(`YYYYMMDD_HHmmss_${Math.floor(1e3 + Math.random() * 9e3)}`)}.${import_utils2.DUMPED_EXTENSION}`;
|
|
97
98
|
}
|
|
98
99
|
writeSQLContent(key, data) {
|
|
99
100
|
this.sqlContent[key] = data;
|
|
@@ -141,11 +142,10 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
141
142
|
return Object.fromEntries(Object.entries(grouped).map(([key, value]) => [key, value.map((item) => item.name)]));
|
|
142
143
|
}
|
|
143
144
|
backUpStorageDir() {
|
|
144
|
-
const paths = [process.cwd(), "storage", "backups"];
|
|
145
145
|
if (this.app.name !== "main") {
|
|
146
|
-
|
|
146
|
+
return (0, import_utils.storagePathJoin)("backups", this.app.name);
|
|
147
147
|
}
|
|
148
|
-
return
|
|
148
|
+
return (0, import_utils.storagePathJoin)("backups");
|
|
149
149
|
}
|
|
150
150
|
async allBackUpFilePaths(options) {
|
|
151
151
|
const dirname = (options == null ? void 0 : options.dir) || this.backUpStorageDir();
|
|
@@ -158,7 +158,7 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
158
158
|
const filteredFiles = files.filter((file) => {
|
|
159
159
|
const baseName = import_path.default.basename(file);
|
|
160
160
|
const isLockFile = import_path.default.extname(file) === ".lock";
|
|
161
|
-
const isDumpFile = import_path.default.extname(file) === `.${
|
|
161
|
+
const isDumpFile = import_path.default.extname(file) === `.${import_utils2.DUMPED_EXTENSION}`;
|
|
162
162
|
return includeInProgress && isLockFile || isDumpFile && !lockFilesSet.has(baseName);
|
|
163
163
|
}).map(async (file) => {
|
|
164
164
|
const filePath = import_path.default.resolve(dirname, file);
|
|
@@ -309,7 +309,7 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
309
309
|
const dataFilePath = import_path.default.resolve(collectionDataDir, "data");
|
|
310
310
|
const dataStream = import_fs.default.createWriteStream(dataFilePath);
|
|
311
311
|
const rows = await app.db.sequelize.query(
|
|
312
|
-
(0,
|
|
312
|
+
(0, import_utils2.sqlAdapter)(
|
|
313
313
|
app.db,
|
|
314
314
|
`SELECT *
|
|
315
315
|
FROM ${collection.isParent() ? "ONLY" : ""} ${collection.quotedTableName()}`
|
|
@@ -392,7 +392,7 @@ class Dumper extends import_app_migrator.AppMigrator {
|
|
|
392
392
|
});
|
|
393
393
|
const onClose = new Promise((resolve, reject) => {
|
|
394
394
|
output.on("close", function() {
|
|
395
|
-
console.log("dumped file size: " + (0,
|
|
395
|
+
console.log("dumped file size: " + (0, import_utils2.humanFileSize)(archive.pointer(), true));
|
|
396
396
|
resolve(true);
|
|
397
397
|
});
|
|
398
398
|
output.on("end", function() {
|
package/dist/server/restorer.js
CHANGED
|
@@ -43,8 +43,9 @@ var import_decompress = __toESM(require("decompress"));
|
|
|
43
43
|
var import_fs = __toESM(require("fs"));
|
|
44
44
|
var import_promises = __toESM(require("fs/promises"));
|
|
45
45
|
var import_path = __toESM(require("path"));
|
|
46
|
+
var import_utils = require("@nocobase/utils");
|
|
46
47
|
var import_app_migrator = require("./app-migrator");
|
|
47
|
-
var
|
|
48
|
+
var import_utils2 = require("./utils");
|
|
48
49
|
var import_database = require("@nocobase/database");
|
|
49
50
|
var import_lodash = __toESM(require("lodash"));
|
|
50
51
|
var import_field_value_writer = require("./field-value-writer");
|
|
@@ -109,7 +110,7 @@ class Restorer extends import_app_migrator.AppMigrator {
|
|
|
109
110
|
if (import_path.default.isAbsolute(backUpFilePath)) {
|
|
110
111
|
this.backUpFilePath = backUpFilePath;
|
|
111
112
|
} else if (import_path.default.basename(backUpFilePath) === backUpFilePath) {
|
|
112
|
-
const dirname =
|
|
113
|
+
const dirname = (0, import_utils.storagePathJoin)("duplicator");
|
|
113
114
|
this.backUpFilePath = import_path.default.resolve(dirname, backUpFilePath);
|
|
114
115
|
} else {
|
|
115
116
|
this.backUpFilePath = import_path.default.resolve(process.cwd(), backUpFilePath);
|
|
@@ -273,7 +274,7 @@ class Restorer extends import_app_migrator.AppMigrator {
|
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
const rows = await (0,
|
|
277
|
+
const rows = await (0, import_utils2.readLines)(collectionDataPath);
|
|
277
278
|
if (rows.length == 0) {
|
|
278
279
|
app.logger.info(`${collectionName} has no data to import`);
|
|
279
280
|
this.importedCollections.push(collectionName);
|
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"description": "Backup and restore applications for scenarios such as application replication, migration, and upgrades.",
|
|
7
7
|
"description.ru-RU": "Резервное копирование и восстановление приложений для задач репликации, миграции и обновления.",
|
|
8
8
|
"description.zh-CN": "备份和还原应用,可用于应用的复制、迁移、升级等场景。",
|
|
9
|
-
"version": "2.1.0-alpha.
|
|
10
|
-
"license": "
|
|
9
|
+
"version": "2.1.0-alpha.20",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/backup-restore",
|
|
13
13
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/backup-restore",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"keywords": [
|
|
48
48
|
"System management"
|
|
49
49
|
],
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3d1535db6bf93ca23257faf474afee0d565f54c6"
|
|
51
51
|
}
|
|
@@ -1,10 +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
|
-
"use strict";(self.webpackChunk_nocobase_plugin_backup_restore=self.webpackChunk_nocobase_plugin_backup_restore||[]).push([["611"],{95:function(e,t,n){n.r(t),n.d(t,{BackupAndRestoreList:function(){return C}});var r=n(482),l=n(632),a=n(772),o=n(721),i=n(346),u=n(156),c=n.n(u),s=n(551);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t,n,r,l,a,o){try{var i=e[a](o),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,l)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,l){var a=e.apply(t,n);function o(e){p(a,r,l,o,i,"next",e)}function i(e){p(a,r,l,o,i,"throw",e)}o(void 0)})}}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var a=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){var n,r,l,a,o={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var u=[a,i];if(n)throw TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(l=2&u[0]?r.return:u[0]?r.throw||((l=r.return)&&l.call(r),0):r.next)&&!(l=l.call(r,u[1])).done)return l;switch(r=0,l&&(u=[2&u[0],l.value]),u[0]){case 0:case 1:l=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(l=(l=o.trys).length>0&&l[l.length-1])&&(6===u[0]||2===u[0])){o=0;continue}if(3===u[0]&&(!l||u[1]>l[0]&&u[1]<l[3])){o.label=u[1];break}if(6===u[0]&&o.label<l[1]){o.label=l[1],l=u;break}if(l&&o.label<l[2]){o.label=l[2],o.ops.push(u);break}l[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=l=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var g=o.Upload.Dragger,v=function(e){var t,n=e.collectionsData,r=(0,s.lV)().t,l=y((0,u.useState)(!1),2),i=l[0],f=l[1],p=y((0,u.useState)(n),2),m=p[0],b=p[1];(0,u.useEffect)(function(){b(n)},[n]);var g=(0,a.useAPIClient)(),v=(0,a.useCompile)(),k=(0,u.useMemo)(function(){return g.resource("backupFiles")},[g]),E=(t=d(function(){var t;return h(this,function(n){switch(n.label){case 0:if(!e.isBackup)return[3,2];return[4,k.dumpableCollections()];case 1:b(null==(t=n.sent())?void 0:t.data),f(!0),n.label=2;case 2:return f(!0),[2]}})}),function(){return t.apply(this,arguments)}),w=[{title:r("Collection"),dataIndex:"collection",key:"collection",render:function(e,t){var n=v(t.title);return t.name===n?n:c().createElement("div",null,t.name," ",c().createElement("span",{style:{color:"rgba(0, 0, 0, 0.3)",fontSize:"0.9em"}},"(",v(t.title),")"))}},{title:r("Origin"),dataIndex:"origin",key:"origin",width:"50%"}],C=Object.keys(m||{}).map(function(e){return{key:e,label:r("".concat(e,".title")),children:c().createElement(c().Fragment,null,c().createElement(o.Alert,{style:{marginBottom:16},message:r("".concat(e,".description"))}),c().createElement(o.Table,{pagination:{pageSize:100},bordered:!0,size:"small",dataSource:m[e],columns:w,scroll:{y:400}}))}});return c().createElement(c().Fragment,null,c().createElement("a",{onClick:E},r("Learn more")),c().createElement(o.Modal,{title:r("Backup instructions"),width:"80vw",open:i,footer:null,onOk:function(){f(!1)},onCancel:function(){f(!1)}},c().createElement(o.Tabs,{defaultActiveKey:"required",items:C})))},k=function(e){var t,n=e.ButtonComponent,r=void 0===n?o.Button:n,i=e.title,f=e.upload,p=void 0!==f&&f,m=e.fileData,b=(0,s.lV)().t,g=y((0,u.useState)(["required"]),2),k=g[0],E=g[1],C=y((0,u.useState)(!1),2),S=C[0],O=C[1],P=y((0,u.useState)(null),2),B=P[0],x=P[1],j=y((0,u.useState)(!1),2),D=j[0],A=j[1],F=(0,a.useAPIClient)(),I=(0,u.useMemo)(function(){return F.resource("backupFiles")},[F]),T=y((0,u.useState)([]),2),q=T[0],R=T[1];(0,u.useEffect)(function(){R(Object.keys((null==B?void 0:B.dumpableCollectionsGroupByGroup)||[]).map(function(e){return{value:e,label:b("".concat(e,".title")),disabled:["required","skipped"].includes(e)}}))},[B]);var G=(t=d(function(){var e,t,n,r;return h(this,function(l){switch(l.label){case 0:if(O(!0),p)return[3,2];return A(!0),[4,I.get({filterByTk:m.name})];case 1:R(Object.keys((null==(r=l.sent().data)||null==(t=r.data)||null==(e=t.meta)?void 0:e.dumpableCollectionsGroupByGroup)||[]).map(function(e){return{value:e,label:b("".concat(e,".title")),disabled:["required","skipped"].includes(e)}})),x(null==r||null==(n=r.data)?void 0:n.meta),A(!1),l.label=2;case 2:return[2]}})}),function(){return t.apply(this,arguments)});return c().createElement(c().Fragment,null,c().createElement(r,{onClick:G},i),c().createElement(o.Modal,{title:b("Restore"),width:800,footer:p&&!B?null:void 0,open:S,onOk:function(){I.restore({values:{dataTypes:k,filterByTk:null==m?void 0:m.name,key:null==B?void 0:B.key}}),O(!1)},onCancel:function(){O(!1),x(null),E(["required"])}},c().createElement(o.Spin,{spinning:D},p&&!B&&c().createElement(w,{setRestoreData:x}),(!p||B)&&[c().createElement("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"},key:"info"},b("Select the data to be restored")," (",c().createElement(v,{collectionsData:null==B?void 0:B.dumpableCollectionsGroupByGroup}),"):"),c().createElement("div",{style:{lineHeight:2,marginBottom:8},key:"dataType"},c().createElement(l.FormItem,null,c().createElement(a.Checkbox.Group,{options:q,style:{flexDirection:"column"},value:k,onChange:function(e){return E(e)}})))])))},E=function(e){var t,n=e.ButtonComponent,l=void 0===n?o.Button:n,i=e.refresh,f=(0,s.lV)().t,p=y((0,u.useState)(!1),2),m=p[0],b=p[1],g=y((0,u.useState)(["required"]),2),k=g[0],E=g[1],w=(0,a.useAPIClient)(),C=y((0,u.useState)([]),2),S=C[0],O=C[1],P=(t=d(function(){return h(this,function(e){switch(e.label){case 0:return[4,w.resource("backupFiles").dumpableCollections()];case 1:return O(Object.keys(e.sent().data||[]).map(function(e){return{value:e,label:f("".concat(e,".title")),disabled:["required","skipped"].includes(e)}})),b(!0),[2]}})}),function(){return t.apply(this,arguments)});return c().createElement(c().Fragment,null,c().createElement(l,{icon:c().createElement(r.PlusOutlined,null),type:"primary",onClick:P},f("New backup")),c().createElement(o.Modal,{title:f("New backup"),width:800,open:m,onOk:function(){w.request({url:"backupFiles:create",method:"post",data:{dataTypes:k}}),b(!1),E(["required"]),setTimeout(function(){i()},500)},onCancel:function(){b(!1),E(["required"])}},c().createElement("strong",{style:{fontWeight:600,display:"block",margin:"16px 0 8px"}},f("Select the data to be backed up")," (",c().createElement(v,{isBackup:!0}),"):"),c().createElement("div",{style:{lineHeight:2,marginBottom:8}},c().createElement(a.Checkbox.Group,{options:S,style:{flexDirection:"column"},onChange:function(e){return E(e)},value:k}))))},w=function(e){var t,n,l=(0,s.lV)().t;return c().createElement(g,(t={multiple:!1,action:"/backupFiles:upload",onChange:function(t){t.fileList.length>1&&t.fileList.splice(0,t.fileList.length-1);var n,r,a,i=t.file.status;"done"===i?(o.message.success("".concat(t.file.name," ")+l("file uploaded successfully")),e.setRestoreData(b(m({},null==(r=t.file.response)||null==(n=r.data)?void 0:n.meta),{key:null==(a=t.file.response)?void 0:a.data.key}))):"error"===i&&o.message.error("".concat(t.file.name," ")+l("file upload failed"))},onDrop:function(e){console.log("Dropped files",e.dataTransfer.files)}},n=(0,a.useAPIClient)(),b(m({},t),{customRequest:function(e){var t=e.action,r=e.data,l=e.file,a=e.filename,o=e.headers,i=e.onError,u=e.onProgress,c=e.onSuccess,s=e.withCredentials,f=new FormData;return r&&Object.keys(r).forEach(function(e){f.append(e,r[e])}),f.append(a,l),n.axios.post(t,f,{withCredentials:s,headers:o,onUploadProgress:function(e){var t=e.total;u({percent:Math.round(e.loaded/t*100).toFixed(2)},l)}}).then(function(e){c(e.data,l)}).catch(i).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}},onChange:function(e){var n;null==(n=t.onChange)||n.call(t,e)}})),c().createElement("p",{className:"ant-upload-drag-icon"},c().createElement(r.InboxOutlined,null)),c().createElement("p",{className:"ant-upload-text"}," ",l("Click or drag file to this area to upload")))},C=function(){var e,t,n,l=(0,s.lV)().t,f=(0,a.useAPIClient)(),p=y((0,u.useState)([]),2),m=p[0],b=p[1],g=y((0,u.useState)(!1),2),v=g[0],w=g[1],C=y((0,u.useState)(!1),2),S=(C[0],C[1]),O=o.App.useApp().modal,P=(0,u.useMemo)(function(){return f.resource("backupFiles")},[f]);(0,u.useEffect)(function(){B()},[]);var B=(e=d(function(){return h(this,function(e){switch(e.label){case 0:return w(!0),[4,P.list()];case 1:return b(e.sent().data.data),w(!1),[2]}})}),function(){return e.apply(this,arguments)}),x=(t=d(function(e){var t,n;return h(this,function(r){switch(r.label){case 0:return S(e.name),[4,f.request({url:"backupFiles:download",method:"get",params:{filterByTk:e.name},responseType:"blob"})];case 1:return t=r.sent(),S(!1),n=new Blob([t.data]),(0,i.saveAs)(n,e.name),[2]}})}),function(e){return t.apply(this,arguments)}),j=(n=d(function(){return h(this,function(e){switch(e.label){case 0:return[4,B()];case 1:return e.sent(),[2]}})}),function(){return n.apply(this,arguments)}),D=function(e){O.confirm({title:l("Delete record",{ns:"client"}),content:l("Are you sure you want to delete it?",{ns:"client"}),onOk:d(function(){return h(this,function(t){switch(t.label){case 0:return[4,P.destroy({filterByTk:e.name})];case 1:return t.sent(),[4,B()];case 2:return t.sent(),o.message.success(l("Deleted successfully")),[2]}})})})};return c().createElement("div",null,c().createElement(o.Card,{bordered:!1},c().createElement(o.Space,{style:{float:"right",marginBottom:16}},c().createElement(o.Button,{onClick:j,icon:c().createElement(r.ReloadOutlined,null)},l("Refresh")),c().createElement(k,{upload:!0,title:c().createElement(c().Fragment,null,c().createElement(r.UploadOutlined,null)," ",l("Restore backup from local"))}),c().createElement(E,{refresh:j})),c().createElement(o.Table,{dataSource:m,loading:v,columns:[{title:l("Backup file"),dataIndex:"name",width:400,onCell:function(e){return e.inProgress?{colSpan:4}:{}},render:function(e,t){return t.inProgress?c().createElement("div",{style:{color:"rgba(0, 0, 0, 0.88)"}},e,"(",l("Backing up"),"...)"):c().createElement("div",null,e)}},{title:l("File size"),dataIndex:"fileSize",onCell:function(e){return e.inProgress?{colSpan:0}:{}}},{title:l("Created at",{ns:"client"}),dataIndex:"createdAt",onCell:function(e){return e.inProgress?{colSpan:0}:{}},render:function(e){return c().createElement(a.DatePicker.ReadPretty,{value:e,showTime:!0})}},{title:l("Actions",{ns:"client"}),dataIndex:"actions",onCell:function(e){return e.inProgress?{colSpan:0}:{}},render:function(e,t){return c().createElement(o.Space,{split:c().createElement(o.Divider,{type:"vertical"})},c().createElement(k,{ButtonComponent:"a",title:l("Restore"),fileData:t}),c().createElement("a",{type:"link",onClick:function(){return x(t)}},l("Download")),c().createElement("a",{onClick:function(){return D(t)}},l("Delete")))}}]})))}}}]);
|