@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.
Files changed (53) hide show
  1. package/README.md +134 -0
  2. package/README.zh-CN.md +136 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +1 -0
  6. package/dist/client/index.js +1 -0
  7. package/dist/client/locale.d.ts +7 -0
  8. package/dist/client/pages/TableDetail.d.ts +1 -0
  9. package/dist/client/pages/TableList.d.ts +1 -0
  10. package/dist/client/plugin.d.ts +7 -0
  11. package/dist/externalVersion.js +11 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +39 -0
  14. package/dist/locale/en-US.json +65 -0
  15. package/dist/locale/zh-CN.json +65 -0
  16. package/dist/node_modules/archiver/LICENSE +22 -0
  17. package/dist/node_modules/archiver/index.js +73 -0
  18. package/dist/node_modules/archiver/lib/core.js +974 -0
  19. package/dist/node_modules/archiver/lib/error.js +40 -0
  20. package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
  21. package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
  22. package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
  23. package/dist/node_modules/archiver/package.json +1 -0
  24. package/dist/server/adapters/base-adapter.d.ts +63 -0
  25. package/dist/server/adapters/base-adapter.js +31 -0
  26. package/dist/server/adapters/index.d.ts +36 -0
  27. package/dist/server/adapters/index.js +86 -0
  28. package/dist/server/adapters/mysql-adapter.d.ts +13 -0
  29. package/dist/server/adapters/mysql-adapter.js +118 -0
  30. package/dist/server/adapters/postgres-adapter.d.ts +13 -0
  31. package/dist/server/adapters/postgres-adapter.js +115 -0
  32. package/dist/server/adapters/sqlite-adapter.d.ts +13 -0
  33. package/dist/server/adapters/sqlite-adapter.js +115 -0
  34. package/dist/server/collections/.gitkeep +0 -0
  35. package/dist/server/constants.d.ts +4 -0
  36. package/dist/server/constants.js +38 -0
  37. package/dist/server/index.d.ts +1 -0
  38. package/dist/server/index.js +33 -0
  39. package/dist/server/plugin.d.ts +11 -0
  40. package/dist/server/plugin.js +61 -0
  41. package/dist/server/resourcers/database-clean.d.ts +31 -0
  42. package/dist/server/resourcers/database-clean.js +303 -0
  43. package/dist/server/services/database-service.d.ts +46 -0
  44. package/dist/server/services/database-service.js +138 -0
  45. package/dist/server/services/filtered-backup-service.d.ts +40 -0
  46. package/dist/server/services/filtered-backup-service.js +269 -0
  47. package/dist/server/utils/lock.d.ts +23 -0
  48. package/dist/server/utils/lock.js +62 -0
  49. package/dist/server/utils.d.ts +2 -0
  50. package/dist/server/utils.js +43 -0
  51. package/package.json +26 -0
  52. package/server.d.ts +2 -0
  53. package/server.js +1 -0
@@ -0,0 +1,118 @@
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 mysql_adapter_exports = {};
19
+ __export(mysql_adapter_exports, {
20
+ MysqlAdapter: () => MysqlAdapter
21
+ });
22
+ module.exports = __toCommonJS(mysql_adapter_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var import_base_adapter = require("./base-adapter");
25
+ class MysqlAdapter extends import_base_adapter.BaseDatabaseAdapter {
26
+ get dialect() {
27
+ return "mysql";
28
+ }
29
+ async getTableSize(collection) {
30
+ const tableName = collection.model.tableName;
31
+ const database = this.app.db.sequelize.getDatabaseName();
32
+ const results = await this.app.db.sequelize.query(
33
+ `SELECT (data_length + index_length) as total_size
34
+ FROM information_schema.tables
35
+ WHERE table_schema = :database AND table_name = :tableName`,
36
+ {
37
+ type: import_sequelize.QueryTypes.SELECT,
38
+ replacements: { database, tableName }
39
+ }
40
+ );
41
+ if (!results || results.length === 0 || !results[0]) {
42
+ throw new Error(`Failed to get table size for ${tableName}`);
43
+ }
44
+ return {
45
+ totalSize: parseInt(String(results[0].total_size || 0), 10) || 0
46
+ };
47
+ }
48
+ async getRowCount(collection) {
49
+ const tableName = collection.model.tableName;
50
+ const results = await this.app.db.sequelize.query(`SELECT COUNT(*) as count FROM \`${tableName}\``, {
51
+ type: import_sequelize.QueryTypes.SELECT
52
+ });
53
+ if (!results || results.length === 0 || !results[0]) {
54
+ throw new Error(`Failed to get row count for ${collection.name}`);
55
+ }
56
+ return parseInt(String(results[0].count), 10) || 0;
57
+ }
58
+ async getTimeRange(collection, hasCreatedAt, hasUpdatedAt) {
59
+ var _a, _b, _c;
60
+ const result = {
61
+ minCreatedAt: null,
62
+ maxCreatedAt: null,
63
+ maxUpdatedAt: null
64
+ };
65
+ const tableName = collection.model.tableName;
66
+ if (hasCreatedAt) {
67
+ const minResults = await this.app.db.sequelize.query(
68
+ `SELECT MIN(\`createdAt\`) as min_val FROM \`${tableName}\``,
69
+ { type: import_sequelize.QueryTypes.SELECT }
70
+ );
71
+ if ((_a = minResults == null ? void 0 : minResults[0]) == null ? void 0 : _a.min_val) {
72
+ result.minCreatedAt = minResults[0].min_val;
73
+ }
74
+ const maxResults = await this.app.db.sequelize.query(
75
+ `SELECT MAX(\`createdAt\`) as max_val FROM \`${tableName}\``,
76
+ { type: import_sequelize.QueryTypes.SELECT }
77
+ );
78
+ if ((_b = maxResults == null ? void 0 : maxResults[0]) == null ? void 0 : _b.max_val) {
79
+ result.maxCreatedAt = maxResults[0].max_val;
80
+ }
81
+ }
82
+ if (hasUpdatedAt) {
83
+ const results = await this.app.db.sequelize.query(`SELECT MAX(\`updatedAt\`) as max_val FROM \`${tableName}\``, {
84
+ type: import_sequelize.QueryTypes.SELECT
85
+ });
86
+ if ((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.max_val) {
87
+ result.maxUpdatedAt = results[0].max_val;
88
+ }
89
+ }
90
+ return result;
91
+ }
92
+ async getIdRange(collection) {
93
+ const primaryKey = collection.model.primaryKeyAttribute || "id";
94
+ const tableName = collection.model.tableName;
95
+ try {
96
+ const results = await this.app.db.sequelize.query(
97
+ `SELECT MIN(\`${primaryKey}\`) as min_id, MAX(\`${primaryKey}\`) as max_id FROM \`${tableName}\``,
98
+ { type: import_sequelize.QueryTypes.SELECT }
99
+ );
100
+ if (results == null ? void 0 : results[0]) {
101
+ return {
102
+ minId: results[0].min_id,
103
+ maxId: results[0].max_id
104
+ };
105
+ }
106
+ } catch (e) {
107
+ }
108
+ return { minId: null, maxId: null };
109
+ }
110
+ async vacuum(collection, full = false) {
111
+ const tableName = collection.model.tableName;
112
+ await this.app.db.sequelize.query(`OPTIMIZE TABLE \`${tableName}\``);
113
+ }
114
+ }
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ MysqlAdapter
118
+ });
@@ -0,0 +1,13 @@
1
+ import { Collection } from '@tego/server';
2
+ import { BaseDatabaseAdapter, IdRangeInfo, TableSizeInfo, TimeRangeInfo } from './base-adapter';
3
+ /**
4
+ * PostgreSQL 数据库适配器
5
+ */
6
+ export declare class PostgresAdapter 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
+ }
@@ -0,0 +1,115 @@
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 postgres_adapter_exports = {};
19
+ __export(postgres_adapter_exports, {
20
+ PostgresAdapter: () => PostgresAdapter
21
+ });
22
+ module.exports = __toCommonJS(postgres_adapter_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var import_base_adapter = require("./base-adapter");
25
+ class PostgresAdapter extends import_base_adapter.BaseDatabaseAdapter {
26
+ get dialect() {
27
+ return "postgres";
28
+ }
29
+ async getTableSize(collection) {
30
+ const schema = collection.collectionSchema() || "public";
31
+ const tableName = collection.model.tableName;
32
+ const results = await this.app.db.sequelize.query(
33
+ `SELECT pg_total_relation_size('${schema}."${tableName}"') as total_size`,
34
+ { type: import_sequelize.QueryTypes.SELECT }
35
+ );
36
+ if (!results || results.length === 0 || !results[0]) {
37
+ throw new Error(`Failed to get table size for ${tableName}`);
38
+ }
39
+ return {
40
+ totalSize: parseInt(String(results[0].total_size), 10) || 0
41
+ };
42
+ }
43
+ async getRowCount(collection) {
44
+ const results = await this.app.db.sequelize.query(
45
+ `SELECT COUNT(*) as count FROM ${collection.isParent() ? "ONLY" : ""} ${collection.quotedTableName()}`,
46
+ { type: import_sequelize.QueryTypes.SELECT }
47
+ );
48
+ if (!results || results.length === 0 || !results[0]) {
49
+ throw new Error(`Failed to get row count for ${collection.name}`);
50
+ }
51
+ return parseInt(String(results[0].count), 10) || 0;
52
+ }
53
+ async getTimeRange(collection, hasCreatedAt, hasUpdatedAt) {
54
+ var _a, _b, _c;
55
+ const result = {
56
+ minCreatedAt: null,
57
+ maxCreatedAt: null,
58
+ maxUpdatedAt: null
59
+ };
60
+ const tableName = `${collection.isParent() ? "ONLY" : ""} ${collection.quotedTableName()}`;
61
+ if (hasCreatedAt) {
62
+ const minResults = await this.app.db.sequelize.query(`SELECT MIN("createdAt") as min_val FROM ${tableName}`, {
63
+ type: import_sequelize.QueryTypes.SELECT
64
+ });
65
+ if ((_a = minResults == null ? void 0 : minResults[0]) == null ? void 0 : _a.min_val) {
66
+ result.minCreatedAt = minResults[0].min_val;
67
+ }
68
+ const maxResults = await this.app.db.sequelize.query(`SELECT MAX("createdAt") as max_val FROM ${tableName}`, {
69
+ type: import_sequelize.QueryTypes.SELECT
70
+ });
71
+ if ((_b = maxResults == null ? void 0 : maxResults[0]) == null ? void 0 : _b.max_val) {
72
+ result.maxCreatedAt = maxResults[0].max_val;
73
+ }
74
+ }
75
+ if (hasUpdatedAt) {
76
+ const results = await this.app.db.sequelize.query(`SELECT MAX("updatedAt") as max_val FROM ${tableName}`, {
77
+ type: import_sequelize.QueryTypes.SELECT
78
+ });
79
+ if ((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.max_val) {
80
+ result.maxUpdatedAt = results[0].max_val;
81
+ }
82
+ }
83
+ return result;
84
+ }
85
+ async getIdRange(collection) {
86
+ const primaryKey = collection.model.primaryKeyAttribute || "id";
87
+ const tableName = `${collection.isParent() ? "ONLY" : ""} ${collection.quotedTableName()}`;
88
+ try {
89
+ const results = await this.app.db.sequelize.query(
90
+ `SELECT MIN("${primaryKey}") as min_id, MAX("${primaryKey}") as max_id FROM ${tableName}`,
91
+ { type: import_sequelize.QueryTypes.SELECT }
92
+ );
93
+ if (results == null ? void 0 : results[0]) {
94
+ return {
95
+ minId: results[0].min_id,
96
+ maxId: results[0].max_id
97
+ };
98
+ }
99
+ } catch (e) {
100
+ }
101
+ return { minId: null, maxId: null };
102
+ }
103
+ async vacuum(collection, full = false) {
104
+ const tableName = collection.quotedTableName();
105
+ if (full) {
106
+ await this.app.db.sequelize.query(`VACUUM FULL ANALYZE ${tableName}`);
107
+ } else {
108
+ await this.app.db.sequelize.query(`VACUUM ANALYZE ${tableName}`);
109
+ }
110
+ }
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ PostgresAdapter
115
+ });
@@ -0,0 +1,13 @@
1
+ import { Collection } from '@tego/server';
2
+ import { BaseDatabaseAdapter, IdRangeInfo, TableSizeInfo, TimeRangeInfo } from './base-adapter';
3
+ /**
4
+ * SQLite 数据库适配器
5
+ */
6
+ export declare class SqliteAdapter 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
+ }
@@ -0,0 +1,115 @@
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 sqlite_adapter_exports = {};
19
+ __export(sqlite_adapter_exports, {
20
+ SqliteAdapter: () => SqliteAdapter
21
+ });
22
+ module.exports = __toCommonJS(sqlite_adapter_exports);
23
+ var import_sequelize = require("sequelize");
24
+ var import_base_adapter = require("./base-adapter");
25
+ class SqliteAdapter extends import_base_adapter.BaseDatabaseAdapter {
26
+ get dialect() {
27
+ return "sqlite";
28
+ }
29
+ async getTableSize(collection) {
30
+ var _a;
31
+ const tableName = collection.model.tableName;
32
+ try {
33
+ const results = await this.app.db.sequelize.query(
34
+ `SELECT SUM(pgsize) as total_size FROM dbstat WHERE name = :tableName`,
35
+ {
36
+ type: import_sequelize.QueryTypes.SELECT,
37
+ replacements: { tableName }
38
+ }
39
+ );
40
+ if ((_a = results == null ? void 0 : results[0]) == null ? void 0 : _a.total_size) {
41
+ return { totalSize: results[0].total_size };
42
+ }
43
+ } catch (e) {
44
+ }
45
+ const rowCount = await this.getRowCount(collection);
46
+ return { totalSize: rowCount * 1024 };
47
+ }
48
+ async getRowCount(collection) {
49
+ const tableName = collection.model.tableName;
50
+ const results = await this.app.db.sequelize.query(`SELECT COUNT(*) as count FROM "${tableName}"`, {
51
+ type: import_sequelize.QueryTypes.SELECT
52
+ });
53
+ if (!results || results.length === 0 || !results[0]) {
54
+ throw new Error(`Failed to get row count for ${collection.name}`);
55
+ }
56
+ return parseInt(String(results[0].count), 10) || 0;
57
+ }
58
+ async getTimeRange(collection, hasCreatedAt, hasUpdatedAt) {
59
+ var _a, _b, _c;
60
+ const result = {
61
+ minCreatedAt: null,
62
+ maxCreatedAt: null,
63
+ maxUpdatedAt: null
64
+ };
65
+ const tableName = collection.model.tableName;
66
+ if (hasCreatedAt) {
67
+ const minResults = await this.app.db.sequelize.query(`SELECT MIN("createdAt") as min_val FROM "${tableName}"`, {
68
+ type: import_sequelize.QueryTypes.SELECT
69
+ });
70
+ if ((_a = minResults == null ? void 0 : minResults[0]) == null ? void 0 : _a.min_val) {
71
+ result.minCreatedAt = new Date(minResults[0].min_val);
72
+ }
73
+ const maxResults = await this.app.db.sequelize.query(`SELECT MAX("createdAt") as max_val FROM "${tableName}"`, {
74
+ type: import_sequelize.QueryTypes.SELECT
75
+ });
76
+ if ((_b = maxResults == null ? void 0 : maxResults[0]) == null ? void 0 : _b.max_val) {
77
+ result.maxCreatedAt = new Date(maxResults[0].max_val);
78
+ }
79
+ }
80
+ if (hasUpdatedAt) {
81
+ const results = await this.app.db.sequelize.query(`SELECT MAX("updatedAt") as max_val FROM "${tableName}"`, {
82
+ type: import_sequelize.QueryTypes.SELECT
83
+ });
84
+ if ((_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.max_val) {
85
+ result.maxUpdatedAt = new Date(results[0].max_val);
86
+ }
87
+ }
88
+ return result;
89
+ }
90
+ async getIdRange(collection) {
91
+ const primaryKey = collection.model.primaryKeyAttribute || "id";
92
+ const tableName = collection.model.tableName;
93
+ try {
94
+ const results = await this.app.db.sequelize.query(
95
+ `SELECT MIN("${primaryKey}") as min_id, MAX("${primaryKey}") as max_id FROM "${tableName}"`,
96
+ { type: import_sequelize.QueryTypes.SELECT }
97
+ );
98
+ if (results == null ? void 0 : results[0]) {
99
+ return {
100
+ minId: results[0].min_id,
101
+ maxId: results[0].max_id
102
+ };
103
+ }
104
+ } catch (e) {
105
+ }
106
+ return { minId: null, maxId: null };
107
+ }
108
+ async vacuum(collection, full = false) {
109
+ await this.app.db.sequelize.query("VACUUM");
110
+ }
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ SqliteAdapter
115
+ });
File without changes
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 白名单表列表 - 只有这些表可以被分析和清理
3
+ */
4
+ export declare const WHITELIST_TABLES: string[];
@@ -0,0 +1,38 @@
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 constants_exports = {};
19
+ __export(constants_exports, {
20
+ WHITELIST_TABLES: () => WHITELIST_TABLES
21
+ });
22
+ module.exports = __toCommonJS(constants_exports);
23
+ const WHITELIST_TABLES = [
24
+ "auditChanges",
25
+ // 审计日志变动值
26
+ "jobs",
27
+ // 工作流任务日志
28
+ "executions",
29
+ // 工作流执行记录
30
+ "apiLogsChanges",
31
+ // API 日志变动值
32
+ "auditLogs"
33
+ // 审计日志
34
+ ];
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ WHITELIST_TABLES
38
+ });
@@ -0,0 +1 @@
1
+ export { default } from './plugin';
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var server_exports = {};
29
+ __export(server_exports, {
30
+ default: () => import_plugin.default
31
+ });
32
+ module.exports = __toCommonJS(server_exports);
33
+ var import_plugin = __toESM(require("./plugin"));
@@ -0,0 +1,11 @@
1
+ import { Plugin } from '@tego/server';
2
+ export declare class PluginPluginDatabaseClean extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ install(): Promise<void>;
7
+ afterEnable(): Promise<void>;
8
+ afterDisable(): Promise<void>;
9
+ remove(): Promise<void>;
10
+ }
11
+ export default PluginPluginDatabaseClean;
@@ -0,0 +1,61 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var plugin_exports = {};
29
+ __export(plugin_exports, {
30
+ PluginPluginDatabaseClean: () => PluginPluginDatabaseClean,
31
+ default: () => plugin_default
32
+ });
33
+ module.exports = __toCommonJS(plugin_exports);
34
+ var import_server = require("@tego/server");
35
+ var import_database_clean = __toESM(require("./resourcers/database-clean"));
36
+ class PluginPluginDatabaseClean extends import_server.Plugin {
37
+ async afterAdd() {
38
+ }
39
+ async beforeLoad() {
40
+ this.app.acl.registerSnippet({
41
+ name: "pm.database-clean.*",
42
+ actions: ["databaseClean:*"]
43
+ });
44
+ }
45
+ async load() {
46
+ this.app.resourcer.define(import_database_clean.default);
47
+ }
48
+ async install() {
49
+ }
50
+ async afterEnable() {
51
+ }
52
+ async afterDisable() {
53
+ }
54
+ async remove() {
55
+ }
56
+ }
57
+ var plugin_default = PluginPluginDatabaseClean;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ PluginPluginDatabaseClean
61
+ });
@@ -0,0 +1,31 @@
1
+ import { Context, Next } from '@tego/server';
2
+ declare const _default: {
3
+ name: string;
4
+ actions: {
5
+ /**
6
+ * 获取表列表
7
+ */
8
+ list(ctx: Context, next: Next): Promise<void>;
9
+ /**
10
+ * 获取表信息
11
+ */
12
+ get(ctx: Context, next: Next): Promise<void>;
13
+ /**
14
+ * 获取表数据
15
+ */
16
+ data(ctx: Context, next: Next): Promise<void>;
17
+ /**
18
+ * 备份数据
19
+ */
20
+ backup(ctx: Context, next: Next): Promise<void>;
21
+ /**
22
+ * 清理数据
23
+ */
24
+ clean(ctx: Context, next: Next): Promise<void>;
25
+ /**
26
+ * 下载备份文件
27
+ */
28
+ download(ctx: Context, next: Next): Promise<void>;
29
+ };
30
+ };
31
+ export default _default;