@tachybase/plugin-database-clean 1.6.2
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/README.md +134 -0
- package/README.zh-CN.md +136 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/client/locale.d.ts +7 -0
- package/dist/client/pages/TableDetail.d.ts +1 -0
- package/dist/client/pages/TableList.d.ts +1 -0
- package/dist/client/plugin.d.ts +7 -0
- package/dist/externalVersion.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +65 -0
- package/dist/locale/zh-CN.json +65 -0
- package/dist/node_modules/archiver/LICENSE +22 -0
- package/dist/node_modules/archiver/index.js +73 -0
- package/dist/node_modules/archiver/lib/core.js +974 -0
- package/dist/node_modules/archiver/lib/error.js +40 -0
- package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
- package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
- package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
- package/dist/node_modules/archiver/package.json +1 -0
- package/dist/server/adapters/base-adapter.d.ts +63 -0
- package/dist/server/adapters/base-adapter.js +31 -0
- package/dist/server/adapters/index.d.ts +36 -0
- package/dist/server/adapters/index.js +86 -0
- package/dist/server/adapters/mysql-adapter.d.ts +13 -0
- package/dist/server/adapters/mysql-adapter.js +118 -0
- package/dist/server/adapters/postgres-adapter.d.ts +13 -0
- package/dist/server/adapters/postgres-adapter.js +115 -0
- package/dist/server/adapters/sqlite-adapter.d.ts +13 -0
- package/dist/server/adapters/sqlite-adapter.js +115 -0
- package/dist/server/collections/.gitkeep +0 -0
- package/dist/server/constants.d.ts +4 -0
- package/dist/server/constants.js +38 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/plugin.d.ts +11 -0
- package/dist/server/plugin.js +61 -0
- package/dist/server/resourcers/database-clean.d.ts +31 -0
- package/dist/server/resourcers/database-clean.js +303 -0
- package/dist/server/services/database-service.d.ts +46 -0
- package/dist/server/services/database-service.js +138 -0
- package/dist/server/services/filtered-backup-service.d.ts +40 -0
- package/dist/server/services/filtered-backup-service.js +269 -0
- package/dist/server/utils/lock.d.ts +23 -0
- package/dist/server/utils/lock.js +62 -0
- package/dist/server/utils.d.ts +2 -0
- package/dist/server/utils.js +43 -0
- package/package.json +26 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Archiver Core
|
|
3
|
+
*
|
|
4
|
+
* @ignore
|
|
5
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
6
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var util = require('util');
|
|
10
|
+
|
|
11
|
+
const ERROR_CODES = {
|
|
12
|
+
'ABORTED': 'archive was aborted',
|
|
13
|
+
'DIRECTORYDIRPATHREQUIRED': 'diretory dirpath argument must be a non-empty string value',
|
|
14
|
+
'DIRECTORYFUNCTIONINVALIDDATA': 'invalid data returned by directory custom data function',
|
|
15
|
+
'ENTRYNAMEREQUIRED': 'entry name must be a non-empty string value',
|
|
16
|
+
'FILEFILEPATHREQUIRED': 'file filepath argument must be a non-empty string value',
|
|
17
|
+
'FINALIZING': 'archive already finalizing',
|
|
18
|
+
'QUEUECLOSED': 'queue closed',
|
|
19
|
+
'NOENDMETHOD': 'no suitable finalize/end method defined by module',
|
|
20
|
+
'DIRECTORYNOTSUPPORTED': 'support for directory entries not defined by module',
|
|
21
|
+
'FORMATSET': 'archive format already set',
|
|
22
|
+
'INPUTSTEAMBUFFERREQUIRED': 'input source must be valid Stream or Buffer instance',
|
|
23
|
+
'MODULESET': 'module already set',
|
|
24
|
+
'SYMLINKNOTSUPPORTED': 'support for symlink entries not defined by module',
|
|
25
|
+
'SYMLINKFILEPATHREQUIRED': 'symlink filepath argument must be a non-empty string value',
|
|
26
|
+
'SYMLINKTARGETREQUIRED': 'symlink target argument must be a non-empty string value',
|
|
27
|
+
'ENTRYNOTSUPPORTED': 'entry not supported'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function ArchiverError(code, data) {
|
|
31
|
+
Error.captureStackTrace(this, this.constructor);
|
|
32
|
+
//this.name = this.constructor.name;
|
|
33
|
+
this.message = ERROR_CODES[code] || code;
|
|
34
|
+
this.code = code;
|
|
35
|
+
this.data = data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
util.inherits(ArchiverError, Error);
|
|
39
|
+
|
|
40
|
+
exports = module.exports = ArchiverError;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Format Plugin
|
|
3
|
+
*
|
|
4
|
+
* @module plugins/json
|
|
5
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
6
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
7
|
+
*/
|
|
8
|
+
var inherits = require('util').inherits;
|
|
9
|
+
var Transform = require('readable-stream').Transform;
|
|
10
|
+
|
|
11
|
+
var crc32 = require('buffer-crc32');
|
|
12
|
+
var util = require('archiver-utils');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {(JsonOptions|TransformOptions)} options
|
|
17
|
+
*/
|
|
18
|
+
var Json = function(options) {
|
|
19
|
+
if (!(this instanceof Json)) {
|
|
20
|
+
return new Json(options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
options = this.options = util.defaults(options, {});
|
|
24
|
+
|
|
25
|
+
Transform.call(this, options);
|
|
26
|
+
|
|
27
|
+
this.supports = {
|
|
28
|
+
directory: true,
|
|
29
|
+
symlink: true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
this.files = [];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
inherits(Json, Transform);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* [_transform description]
|
|
39
|
+
*
|
|
40
|
+
* @private
|
|
41
|
+
* @param {Buffer} chunk
|
|
42
|
+
* @param {String} encoding
|
|
43
|
+
* @param {Function} callback
|
|
44
|
+
* @return void
|
|
45
|
+
*/
|
|
46
|
+
Json.prototype._transform = function(chunk, encoding, callback) {
|
|
47
|
+
callback(null, chunk);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* [_writeStringified description]
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
* @return void
|
|
55
|
+
*/
|
|
56
|
+
Json.prototype._writeStringified = function() {
|
|
57
|
+
var fileString = JSON.stringify(this.files);
|
|
58
|
+
this.write(fileString);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* [append description]
|
|
63
|
+
*
|
|
64
|
+
* @param {(Buffer|Stream)} source
|
|
65
|
+
* @param {EntryData} data
|
|
66
|
+
* @param {Function} callback
|
|
67
|
+
* @return void
|
|
68
|
+
*/
|
|
69
|
+
Json.prototype.append = function(source, data, callback) {
|
|
70
|
+
var self = this;
|
|
71
|
+
|
|
72
|
+
data.crc32 = 0;
|
|
73
|
+
|
|
74
|
+
function onend(err, sourceBuffer) {
|
|
75
|
+
if (err) {
|
|
76
|
+
callback(err);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
data.size = sourceBuffer.length || 0;
|
|
81
|
+
data.crc32 = crc32.unsigned(sourceBuffer);
|
|
82
|
+
|
|
83
|
+
self.files.push(data);
|
|
84
|
+
|
|
85
|
+
callback(null, data);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (data.sourceType === 'buffer') {
|
|
89
|
+
onend(null, source);
|
|
90
|
+
} else if (data.sourceType === 'stream') {
|
|
91
|
+
util.collectStream(source, onend);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* [finalize description]
|
|
97
|
+
*
|
|
98
|
+
* @return void
|
|
99
|
+
*/
|
|
100
|
+
Json.prototype.finalize = function() {
|
|
101
|
+
this._writeStringified();
|
|
102
|
+
this.end();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = Json;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {Object} JsonOptions
|
|
109
|
+
* @global
|
|
110
|
+
*/
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TAR Format Plugin
|
|
3
|
+
*
|
|
4
|
+
* @module plugins/tar
|
|
5
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
6
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
7
|
+
*/
|
|
8
|
+
var zlib = require('zlib');
|
|
9
|
+
|
|
10
|
+
var engine = require('tar-stream');
|
|
11
|
+
var util = require('archiver-utils');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {TarOptions} options
|
|
16
|
+
*/
|
|
17
|
+
var Tar = function(options) {
|
|
18
|
+
if (!(this instanceof Tar)) {
|
|
19
|
+
return new Tar(options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
options = this.options = util.defaults(options, {
|
|
23
|
+
gzip: false
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (typeof options.gzipOptions !== 'object') {
|
|
27
|
+
options.gzipOptions = {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.supports = {
|
|
31
|
+
directory: true,
|
|
32
|
+
symlink: true
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.engine = engine.pack(options);
|
|
36
|
+
this.compressor = false;
|
|
37
|
+
|
|
38
|
+
if (options.gzip) {
|
|
39
|
+
this.compressor = zlib.createGzip(options.gzipOptions);
|
|
40
|
+
this.compressor.on('error', this._onCompressorError.bind(this));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* [_onCompressorError description]
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
* @param {Error} err
|
|
49
|
+
* @return void
|
|
50
|
+
*/
|
|
51
|
+
Tar.prototype._onCompressorError = function(err) {
|
|
52
|
+
this.engine.emit('error', err);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* [append description]
|
|
57
|
+
*
|
|
58
|
+
* @param {(Buffer|Stream)} source
|
|
59
|
+
* @param {TarEntryData} data
|
|
60
|
+
* @param {Function} callback
|
|
61
|
+
* @return void
|
|
62
|
+
*/
|
|
63
|
+
Tar.prototype.append = function(source, data, callback) {
|
|
64
|
+
var self = this;
|
|
65
|
+
|
|
66
|
+
data.mtime = data.date;
|
|
67
|
+
|
|
68
|
+
function append(err, sourceBuffer) {
|
|
69
|
+
if (err) {
|
|
70
|
+
callback(err);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
self.engine.entry(data, sourceBuffer, function(err) {
|
|
75
|
+
callback(err, data);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (data.sourceType === 'buffer') {
|
|
80
|
+
append(null, source);
|
|
81
|
+
} else if (data.sourceType === 'stream' && data.stats) {
|
|
82
|
+
data.size = data.stats.size;
|
|
83
|
+
|
|
84
|
+
var entry = self.engine.entry(data, function(err) {
|
|
85
|
+
callback(err, data);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
source.pipe(entry);
|
|
89
|
+
} else if (data.sourceType === 'stream') {
|
|
90
|
+
util.collectStream(source, append);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* [finalize description]
|
|
96
|
+
*
|
|
97
|
+
* @return void
|
|
98
|
+
*/
|
|
99
|
+
Tar.prototype.finalize = function() {
|
|
100
|
+
this.engine.finalize();
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* [on description]
|
|
105
|
+
*
|
|
106
|
+
* @return this.engine
|
|
107
|
+
*/
|
|
108
|
+
Tar.prototype.on = function() {
|
|
109
|
+
return this.engine.on.apply(this.engine, arguments);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* [pipe description]
|
|
114
|
+
*
|
|
115
|
+
* @param {String} destination
|
|
116
|
+
* @param {Object} options
|
|
117
|
+
* @return this.engine
|
|
118
|
+
*/
|
|
119
|
+
Tar.prototype.pipe = function(destination, options) {
|
|
120
|
+
if (this.compressor) {
|
|
121
|
+
return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
|
|
122
|
+
} else {
|
|
123
|
+
return this.engine.pipe.apply(this.engine, arguments);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* [unpipe description]
|
|
129
|
+
*
|
|
130
|
+
* @return this.engine
|
|
131
|
+
*/
|
|
132
|
+
Tar.prototype.unpipe = function() {
|
|
133
|
+
if (this.compressor) {
|
|
134
|
+
return this.compressor.unpipe.apply(this.compressor, arguments);
|
|
135
|
+
} else {
|
|
136
|
+
return this.engine.unpipe.apply(this.engine, arguments);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
module.exports = Tar;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @typedef {Object} TarOptions
|
|
144
|
+
* @global
|
|
145
|
+
* @property {Boolean} [gzip=false] Compress the tar archive using gzip.
|
|
146
|
+
* @property {Object} [gzipOptions] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
|
|
147
|
+
* to control compression.
|
|
148
|
+
* @property {*} [*] See [tar-stream]{@link https://github.com/mafintosh/tar-stream} documentation for additional properties.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @typedef {Object} TarEntryData
|
|
153
|
+
* @global
|
|
154
|
+
* @property {String} name Sets the entry name including internal path.
|
|
155
|
+
* @property {(String|Date)} [date=NOW()] Sets the entry date.
|
|
156
|
+
* @property {Number} [mode=D:0755/F:0644] Sets the entry permissions.
|
|
157
|
+
* @property {String} [prefix] Sets a path prefix for the entry name. Useful
|
|
158
|
+
* when working with methods like `directory` or `glob`.
|
|
159
|
+
* @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
|
|
160
|
+
* for reduction of fs stat calls when stat data is already known.
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* TarStream Module
|
|
165
|
+
* @external TarStream
|
|
166
|
+
* @see {@link https://github.com/mafintosh/tar-stream}
|
|
167
|
+
*/
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP Format Plugin
|
|
3
|
+
*
|
|
4
|
+
* @module plugins/zip
|
|
5
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
6
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
7
|
+
*/
|
|
8
|
+
var engine = require('zip-stream');
|
|
9
|
+
var util = require('archiver-utils');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @constructor
|
|
13
|
+
* @param {ZipOptions} [options]
|
|
14
|
+
* @param {String} [options.comment] Sets the zip archive comment.
|
|
15
|
+
* @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
|
|
16
|
+
* @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
|
|
17
|
+
* @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
|
|
18
|
+
* @param {Boolean} [options.store=false] Sets the compression method to STORE.
|
|
19
|
+
* @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
|
|
20
|
+
*/
|
|
21
|
+
var Zip = function(options) {
|
|
22
|
+
if (!(this instanceof Zip)) {
|
|
23
|
+
return new Zip(options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
options = this.options = util.defaults(options, {
|
|
27
|
+
comment: '',
|
|
28
|
+
forceUTC: false,
|
|
29
|
+
namePrependSlash: false,
|
|
30
|
+
store: false
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.supports = {
|
|
34
|
+
directory: true,
|
|
35
|
+
symlink: true
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
this.engine = new engine(options);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {(Buffer|Stream)} source
|
|
43
|
+
* @param {ZipEntryData} data
|
|
44
|
+
* @param {String} data.name Sets the entry name including internal path.
|
|
45
|
+
* @param {(String|Date)} [data.date=NOW()] Sets the entry date.
|
|
46
|
+
* @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
|
|
47
|
+
* @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
|
|
48
|
+
* when working with methods like `directory` or `glob`.
|
|
49
|
+
* @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
|
|
50
|
+
* for reduction of fs stat calls when stat data is already known.
|
|
51
|
+
* @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
|
|
52
|
+
* @param {Function} callback
|
|
53
|
+
* @return void
|
|
54
|
+
*/
|
|
55
|
+
Zip.prototype.append = function(source, data, callback) {
|
|
56
|
+
this.engine.entry(source, data, callback);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @return void
|
|
61
|
+
*/
|
|
62
|
+
Zip.prototype.finalize = function() {
|
|
63
|
+
this.engine.finalize();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @return this.engine
|
|
68
|
+
*/
|
|
69
|
+
Zip.prototype.on = function() {
|
|
70
|
+
return this.engine.on.apply(this.engine, arguments);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @return this.engine
|
|
75
|
+
*/
|
|
76
|
+
Zip.prototype.pipe = function() {
|
|
77
|
+
return this.engine.pipe.apply(this.engine, arguments);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @return this.engine
|
|
82
|
+
*/
|
|
83
|
+
Zip.prototype.unpipe = function() {
|
|
84
|
+
return this.engine.unpipe.apply(this.engine, arguments);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
module.exports = Zip;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {Object} ZipOptions
|
|
91
|
+
* @global
|
|
92
|
+
* @property {String} [comment] Sets the zip archive comment.
|
|
93
|
+
* @property {Boolean} [forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
|
|
94
|
+
* @property {Boolean} [forceZip64=false] Forces the archive to contain ZIP64 headers.
|
|
95
|
+
* @prpperty {Boolean} [namePrependSlash=false] Prepends a forward slash to archive file paths.
|
|
96
|
+
* @property {Boolean} [store=false] Sets the compression method to STORE.
|
|
97
|
+
* @property {Object} [zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
|
|
98
|
+
* to control compression.
|
|
99
|
+
* @property {*} [*] See [zip-stream]{@link https://archiverjs.com/zip-stream/ZipStream.html} documentation for current list of properties.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @typedef {Object} ZipEntryData
|
|
104
|
+
* @global
|
|
105
|
+
* @property {String} name Sets the entry name including internal path.
|
|
106
|
+
* @property {(String|Date)} [date=NOW()] Sets the entry date.
|
|
107
|
+
* @property {Number} [mode=D:0755/F:0644] Sets the entry permissions.
|
|
108
|
+
* @property {Boolean} [namePrependSlash=ZipOptions.namePrependSlash] Prepends a forward slash to archive file paths.
|
|
109
|
+
* @property {String} [prefix] Sets a path prefix for the entry name. Useful
|
|
110
|
+
* when working with methods like `directory` or `glob`.
|
|
111
|
+
* @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
|
|
112
|
+
* for reduction of fs stat calls when stat data is already known.
|
|
113
|
+
* @property {Boolean} [store=ZipOptions.store] Sets the compression method to STORE.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* ZipStream Module
|
|
118
|
+
* @external ZipStream
|
|
119
|
+
* @see {@link https://www.archiverjs.com/zip-stream/ZipStream.html}
|
|
120
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"archiver","version":"7.0.1","description":"a streaming interface for archive generation","homepage":"https://github.com/archiverjs/node-archiver","author":{"name":"Chris Talkington","url":"http://christalkington.com/"},"repository":{"type":"git","url":"https://github.com/archiverjs/node-archiver.git"},"bugs":{"url":"https://github.com/archiverjs/node-archiver/issues"},"license":"MIT","main":"index.js","files":["index.js","lib"],"engines":{"node":">= 14"},"scripts":{"test":"mocha --reporter dot","bench":"node benchmark/simple/pack-zip.js"},"dependencies":{"archiver-utils":"^5.0.2","async":"^3.2.4","buffer-crc32":"^1.0.0","readable-stream":"^4.0.0","readdir-glob":"^1.1.2","tar-stream":"^3.0.0","zip-stream":"^6.0.1"},"devDependencies":{"archiver-jsdoc-theme":"1.1.3","chai":"4.4.1","jsdoc":"4.0.2","mkdirp":"3.0.1","mocha":"10.3.0","rimraf":"5.0.5","stream-bench":"0.1.2","tar":"6.2.0","yauzl":"3.1.2"},"keywords":["archive","archiver","stream","zip","tar"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_lastModified":"2025-12-22T11:13:58.232Z"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Application, Collection } from '@tego/server';
|
|
2
|
+
/**
|
|
3
|
+
* 表大小信息
|
|
4
|
+
*/
|
|
5
|
+
export interface TableSizeInfo {
|
|
6
|
+
/** 表+索引的总大小(字节) */
|
|
7
|
+
totalSize: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 时间范围信息
|
|
11
|
+
*/
|
|
12
|
+
export interface TimeRangeInfo {
|
|
13
|
+
minCreatedAt: Date | null;
|
|
14
|
+
maxCreatedAt: Date | null;
|
|
15
|
+
maxUpdatedAt: Date | null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ID 范围信息
|
|
19
|
+
*/
|
|
20
|
+
export interface IdRangeInfo {
|
|
21
|
+
minId: number | null;
|
|
22
|
+
maxId: number | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 数据库适配器基类
|
|
26
|
+
* 定义了数据库清理插件需要的所有数据库特定操作
|
|
27
|
+
*/
|
|
28
|
+
export declare abstract class BaseDatabaseAdapter {
|
|
29
|
+
protected app: Application;
|
|
30
|
+
constructor(app: Application);
|
|
31
|
+
/**
|
|
32
|
+
* 获取适配器支持的数据库方言
|
|
33
|
+
*/
|
|
34
|
+
abstract get dialect(): string;
|
|
35
|
+
/**
|
|
36
|
+
* 获取表的总大小(包括索引)
|
|
37
|
+
* @param collection 集合对象
|
|
38
|
+
*/
|
|
39
|
+
abstract getTableSize(collection: Collection): Promise<TableSizeInfo>;
|
|
40
|
+
/**
|
|
41
|
+
* 获取表的行数
|
|
42
|
+
* @param collection 集合对象
|
|
43
|
+
*/
|
|
44
|
+
abstract getRowCount(collection: Collection): Promise<number>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取表的时间范围
|
|
47
|
+
* @param collection 集合对象
|
|
48
|
+
* @param hasCreatedAt 是否有 createdAt 字段
|
|
49
|
+
* @param hasUpdatedAt 是否有 updatedAt 字段
|
|
50
|
+
*/
|
|
51
|
+
abstract getTimeRange(collection: Collection, hasCreatedAt: boolean, hasUpdatedAt: boolean): Promise<TimeRangeInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* 获取表的 ID 范围
|
|
54
|
+
* @param collection 集合对象
|
|
55
|
+
*/
|
|
56
|
+
abstract getIdRange(collection: Collection): Promise<IdRangeInfo>;
|
|
57
|
+
/**
|
|
58
|
+
* 执行 VACUUM 操作以释放磁盘空间
|
|
59
|
+
* @param collection 集合对象
|
|
60
|
+
* @param full 是否使用 VACUUM FULL(会锁表但真正释放空间)
|
|
61
|
+
*/
|
|
62
|
+
abstract vacuum(collection: Collection, full?: boolean): Promise<void>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var base_adapter_exports = {};
|
|
19
|
+
__export(base_adapter_exports, {
|
|
20
|
+
BaseDatabaseAdapter: () => BaseDatabaseAdapter
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(base_adapter_exports);
|
|
23
|
+
class BaseDatabaseAdapter {
|
|
24
|
+
constructor(app) {
|
|
25
|
+
this.app = app;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
BaseDatabaseAdapter
|
|
31
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Application } from '@tego/server';
|
|
2
|
+
import { BaseDatabaseAdapter } from './base-adapter';
|
|
3
|
+
/**
|
|
4
|
+
* 数据库适配器工厂
|
|
5
|
+
* 根据数据库类型返回对应的适配器实例
|
|
6
|
+
*/
|
|
7
|
+
export declare class DatabaseAdapterFactory {
|
|
8
|
+
private static adapters;
|
|
9
|
+
/**
|
|
10
|
+
* 获取当前数据库对应的适配器
|
|
11
|
+
* @param app Application 实例
|
|
12
|
+
* @returns 数据库适配器实例
|
|
13
|
+
* @throws 如果数据库类型不支持
|
|
14
|
+
*/
|
|
15
|
+
static getAdapter(app: Application): BaseDatabaseAdapter;
|
|
16
|
+
/**
|
|
17
|
+
* 检查当前数据库是否支持
|
|
18
|
+
* @param app Application 实例
|
|
19
|
+
* @returns 是否支持
|
|
20
|
+
*/
|
|
21
|
+
static isSupported(app: Application): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 获取支持的数据库类型列表
|
|
24
|
+
*/
|
|
25
|
+
static getSupportedDialects(): string[];
|
|
26
|
+
/**
|
|
27
|
+
* 注册自定义适配器(用于扩展)
|
|
28
|
+
* @param dialect 数据库方言
|
|
29
|
+
* @param adapterClass 适配器类
|
|
30
|
+
*/
|
|
31
|
+
static registerAdapter(dialect: string, adapterClass: new (app: Application) => BaseDatabaseAdapter): void;
|
|
32
|
+
}
|
|
33
|
+
export * from './base-adapter';
|
|
34
|
+
export * from './mysql-adapter';
|
|
35
|
+
export * from './postgres-adapter';
|
|
36
|
+
export * from './sqlite-adapter';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var adapters_exports = {};
|
|
20
|
+
__export(adapters_exports, {
|
|
21
|
+
DatabaseAdapterFactory: () => DatabaseAdapterFactory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(adapters_exports);
|
|
24
|
+
var import_mysql_adapter = require("./mysql-adapter");
|
|
25
|
+
var import_postgres_adapter = require("./postgres-adapter");
|
|
26
|
+
var import_sqlite_adapter = require("./sqlite-adapter");
|
|
27
|
+
__reExport(adapters_exports, require("./base-adapter"), module.exports);
|
|
28
|
+
__reExport(adapters_exports, require("./mysql-adapter"), module.exports);
|
|
29
|
+
__reExport(adapters_exports, require("./postgres-adapter"), module.exports);
|
|
30
|
+
__reExport(adapters_exports, require("./sqlite-adapter"), module.exports);
|
|
31
|
+
const SUPPORTED_DIALECTS = ["postgres", "mysql", "sqlite"];
|
|
32
|
+
class DatabaseAdapterFactory {
|
|
33
|
+
/**
|
|
34
|
+
* 获取当前数据库对应的适配器
|
|
35
|
+
* @param app Application 实例
|
|
36
|
+
* @returns 数据库适配器实例
|
|
37
|
+
* @throws 如果数据库类型不支持
|
|
38
|
+
*/
|
|
39
|
+
static getAdapter(app) {
|
|
40
|
+
const dialect = app.db.sequelize.getDialect();
|
|
41
|
+
const AdapterClass = this.adapters.get(dialect);
|
|
42
|
+
if (!AdapterClass) {
|
|
43
|
+
const supported = Array.from(this.adapters.keys()).join(", ");
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Database dialect "${dialect}" is not supported by database-clean plugin. Currently supported: ${supported}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return new AdapterClass(app);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 检查当前数据库是否支持
|
|
52
|
+
* @param app Application 实例
|
|
53
|
+
* @returns 是否支持
|
|
54
|
+
*/
|
|
55
|
+
static isSupported(app) {
|
|
56
|
+
const dialect = app.db.sequelize.getDialect();
|
|
57
|
+
return this.adapters.has(dialect);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 获取支持的数据库类型列表
|
|
61
|
+
*/
|
|
62
|
+
static getSupportedDialects() {
|
|
63
|
+
return Array.from(this.adapters.keys());
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 注册自定义适配器(用于扩展)
|
|
67
|
+
* @param dialect 数据库方言
|
|
68
|
+
* @param adapterClass 适配器类
|
|
69
|
+
*/
|
|
70
|
+
static registerAdapter(dialect, adapterClass) {
|
|
71
|
+
this.adapters.set(dialect, adapterClass);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
DatabaseAdapterFactory.adapters = /* @__PURE__ */ new Map([
|
|
75
|
+
["postgres", import_postgres_adapter.PostgresAdapter],
|
|
76
|
+
["mysql", import_mysql_adapter.MysqlAdapter],
|
|
77
|
+
["sqlite", import_sqlite_adapter.SqliteAdapter]
|
|
78
|
+
]);
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
DatabaseAdapterFactory,
|
|
82
|
+
...require("./base-adapter"),
|
|
83
|
+
...require("./mysql-adapter"),
|
|
84
|
+
...require("./postgres-adapter"),
|
|
85
|
+
...require("./sqlite-adapter")
|
|
86
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Collection } from '@tego/server';
|
|
2
|
+
import { BaseDatabaseAdapter, IdRangeInfo, TableSizeInfo, TimeRangeInfo } from './base-adapter';
|
|
3
|
+
/**
|
|
4
|
+
* MySQL 数据库适配器
|
|
5
|
+
*/
|
|
6
|
+
export declare class MysqlAdapter extends BaseDatabaseAdapter {
|
|
7
|
+
get dialect(): string;
|
|
8
|
+
getTableSize(collection: Collection): Promise<TableSizeInfo>;
|
|
9
|
+
getRowCount(collection: Collection): Promise<number>;
|
|
10
|
+
getTimeRange(collection: Collection, hasCreatedAt: boolean, hasUpdatedAt: boolean): Promise<TimeRangeInfo>;
|
|
11
|
+
getIdRange(collection: Collection): Promise<IdRangeInfo>;
|
|
12
|
+
vacuum(collection: Collection, full?: boolean): Promise<void>;
|
|
13
|
+
}
|