@datatruck/cli 0.32.1 → 0.32.3

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 (189) hide show
  1. package/config.schema.json +1224 -1271
  2. package/{Action → lib/Action}/BackupAction.d.ts +9 -9
  3. package/{Action → lib/Action}/BackupAction.js +27 -8
  4. package/{Action → lib/Action}/ConfigAction.d.ts +9 -9
  5. package/{Action → lib/Action}/ConfigAction.js +4 -2
  6. package/{Action → lib/Action}/CopyAction.d.ts +5 -5
  7. package/{Action → lib/Action}/InitAction.d.ts +3 -3
  8. package/{Action → lib/Action}/PruneAction.d.ts +5 -5
  9. package/{Action → lib/Action}/RestoreAction.d.ts +5 -5
  10. package/{Action → lib/Action}/SnapshotsAction.d.ts +5 -5
  11. package/{Command → lib/Command}/BackupCommand.d.ts +2 -2
  12. package/{Command → lib/Command}/CommandAbstract.d.ts +4 -4
  13. package/{Command → lib/Command}/ConfigCommand.d.ts +2 -2
  14. package/{Command → lib/Command}/InitCommand.d.ts +2 -2
  15. package/{Command → lib/Command}/PruneCommand.d.ts +2 -2
  16. package/{Command → lib/Command}/RestoreCommand.d.ts +2 -2
  17. package/{Command → lib/Command}/SnapshotsCommand.d.ts +2 -2
  18. package/lib/Config/Config.d.ts +28 -0
  19. package/lib/Config/PackageConfig.d.ts +24 -0
  20. package/lib/Config/PackageConfig.js +2 -0
  21. package/lib/Config/PackageRepositoryConfig.d.ts +15 -0
  22. package/lib/Config/PackageRepositoryConfig.js +2 -0
  23. package/lib/Config/PrunePolicyConfig.d.ts +2 -0
  24. package/lib/Config/PrunePolicyConfig.js +2 -0
  25. package/lib/Config/RepositoryConfig.d.ts +27 -0
  26. package/lib/Config/RepositoryConfig.js +2 -0
  27. package/lib/Config/TaskConfig.d.ts +31 -0
  28. package/lib/Config/TaskConfig.js +2 -0
  29. package/{Factory → lib/Factory}/CommandFactory.d.ts +5 -5
  30. package/lib/Factory/RepositoryFactory.d.ts +3 -0
  31. package/lib/Factory/TaskFactory.d.ts +3 -0
  32. package/{Repository → lib/Repository}/DatatruckRepository.d.ts +9 -12
  33. package/{Repository → lib/Repository}/DatatruckRepository.js +1 -38
  34. package/lib/Repository/GitRepository.d.ts +28 -0
  35. package/{Repository → lib/Repository}/GitRepository.js +1 -15
  36. package/{Repository → lib/Repository}/RepositoryAbstract.d.ts +8 -8
  37. package/{Repository → lib/Repository}/ResticRepository.d.ts +11 -14
  38. package/{Repository → lib/Repository}/ResticRepository.js +1 -63
  39. package/{Task → lib/Task}/GitTask.d.ts +2 -4
  40. package/{Task → lib/Task}/GitTask.js +1 -42
  41. package/{Task → lib/Task}/MariadbTask.d.ts +2 -4
  42. package/{Task → lib/Task}/MariadbTask.js +1 -54
  43. package/{Task → lib/Task}/MssqlTask.d.ts +2 -4
  44. package/{Task → lib/Task}/MssqlTask.js +1 -14
  45. package/{Task → lib/Task}/MysqlDumpTask.d.ts +4 -5
  46. package/{Task → lib/Task}/MysqlDumpTask.js +1 -11
  47. package/{Task → lib/Task}/PostgresqlDumpTask.d.ts +5 -7
  48. package/{Task → lib/Task}/PostgresqlDumpTask.js +1 -5
  49. package/lib/Task/ScriptTask.d.ts +30 -0
  50. package/lib/Task/ScriptTask.js +55 -0
  51. package/{Task → lib/Task}/SqlDumpTaskAbstract.d.ts +5 -7
  52. package/{Task → lib/Task}/SqlDumpTaskAbstract.js +1 -43
  53. package/{Task → lib/Task}/TaskAbstract.d.ts +2 -2
  54. package/lib/cli.d.ts +4 -0
  55. package/lib/config.schema.d.ts +2 -0
  56. package/lib/config.schema.js +10 -0
  57. package/lib/index.d.ts +24 -0
  58. package/lib/index.js +21 -0
  59. package/{utils → lib/utils}/DataFormat.d.ts +4 -4
  60. package/{utils → lib/utils}/Git.d.ts +6 -6
  61. package/{utils → lib/utils}/Restic.d.ts +14 -14
  62. package/{utils → lib/utils}/datatruck/config.d.ts +20 -20
  63. package/lib/utils/datatruck/paths.d.ts +17 -0
  64. package/{utils → lib/utils}/datatruck/paths.js +3 -3
  65. package/{utils → lib/utils}/datatruck/repository-server.d.ts +1 -1
  66. package/{utils → lib/utils}/datatruck/snapshot.d.ts +2 -2
  67. package/{utils → lib/utils}/date.d.ts +3 -3
  68. package/{utils → lib/utils}/exit.d.ts +3 -3
  69. package/{utils → lib/utils}/mysql.d.ts +5 -4
  70. package/{utils → lib/utils}/mysql.js +2 -2
  71. package/{utils → lib/utils}/process.d.ts +8 -5
  72. package/lib/utils/reportSteps.d.ts +26 -0
  73. package/lib/utils/reportSteps.js +41 -0
  74. package/lib/utils/spawnSteps.d.ts +36 -0
  75. package/lib/utils/spawnSteps.js +74 -0
  76. package/{utils → lib/utils}/string.d.ts +3 -3
  77. package/{utils → lib/utils}/string.js +3 -3
  78. package/{utils → lib/utils}/tar.d.ts +0 -8
  79. package/{utils → lib/utils}/tar.js +1 -18
  80. package/package.json +39 -25
  81. package/CHANGELOG.md +0 -569
  82. package/Config/Config.d.ts +0 -28
  83. package/Config/Config.js +0 -140
  84. package/Config/PackageConfig.d.ts +0 -23
  85. package/Config/PackageConfig.js +0 -51
  86. package/Config/PackageRepositoryConfig.d.ts +0 -17
  87. package/Config/PackageRepositoryConfig.js +0 -37
  88. package/Config/PrunePolicyConfig.d.ts +0 -4
  89. package/Config/PrunePolicyConfig.js +0 -28
  90. package/Config/RepositoryConfig.d.ts +0 -24
  91. package/Config/RepositoryConfig.js +0 -62
  92. package/Config/TaskConfig.d.ts +0 -27
  93. package/Config/TaskConfig.js +0 -41
  94. package/Factory/RepositoryFactory.d.ts +0 -3
  95. package/Factory/TaskFactory.d.ts +0 -3
  96. package/JsonSchema/DefinitionEnum.d.ts +0 -26
  97. package/JsonSchema/DefinitionEnum.js +0 -33
  98. package/JsonSchema/JsonSchema.d.ts +0 -4
  99. package/JsonSchema/JsonSchema.js +0 -65
  100. package/JsonSchema/backup-def.d.ts +0 -30
  101. package/JsonSchema/backup-def.js +0 -18
  102. package/JsonSchema/copy-def.d.ts +0 -24
  103. package/JsonSchema/copy-def.js +0 -15
  104. package/Repository/GitRepository.d.ts +0 -31
  105. package/Task/ScriptTask.d.ts +0 -38
  106. package/Task/ScriptTask.js +0 -163
  107. package/cli.d.ts +0 -4
  108. package/index.d.ts +0 -1
  109. package/utils/datatruck/paths.d.ts +0 -17
  110. package/utils/path.d.ts +0 -1
  111. package/utils/path.js +0 -8
  112. package/utils/schema.d.ts +0 -34
  113. package/utils/schema.js +0 -36
  114. package/utils/steps.d.ts +0 -43
  115. package/utils/steps.js +0 -97
  116. /package/{Action → lib/Action}/CleanCacheAction.d.ts +0 -0
  117. /package/{Action → lib/Action}/CleanCacheAction.js +0 -0
  118. /package/{Action → lib/Action}/CopyAction.js +0 -0
  119. /package/{Action → lib/Action}/InitAction.js +0 -0
  120. /package/{Action → lib/Action}/PruneAction.js +0 -0
  121. /package/{Action → lib/Action}/RestoreAction.js +0 -0
  122. /package/{Action → lib/Action}/SnapshotsAction.js +0 -0
  123. /package/{Command → lib/Command}/BackupCommand.js +0 -0
  124. /package/{Command → lib/Command}/CleanCacheCommand.d.ts +0 -0
  125. /package/{Command → lib/Command}/CleanCacheCommand.js +0 -0
  126. /package/{Command → lib/Command}/CommandAbstract.js +0 -0
  127. /package/{Command → lib/Command}/ConfigCommand.js +0 -0
  128. /package/{Command → lib/Command}/CopyCommand.d.ts +0 -0
  129. /package/{Command → lib/Command}/CopyCommand.js +0 -0
  130. /package/{Command → lib/Command}/InitCommand.js +0 -0
  131. /package/{Command → lib/Command}/PruneCommand.js +0 -0
  132. /package/{Command → lib/Command}/RestoreCommand.js +0 -0
  133. /package/{Command → lib/Command}/SnapshotsCommand.js +0 -0
  134. /package/{Command → lib/Command}/StartServerCommand.d.ts +0 -0
  135. /package/{Command → lib/Command}/StartServerCommand.js +0 -0
  136. /package/{index.js → lib/Config/Config.js} +0 -0
  137. /package/{Error → lib/Error}/AppError.d.ts +0 -0
  138. /package/{Error → lib/Error}/AppError.js +0 -0
  139. /package/{Factory → lib/Factory}/CommandFactory.js +0 -0
  140. /package/{Factory → lib/Factory}/RepositoryFactory.js +0 -0
  141. /package/{Factory → lib/Factory}/TaskFactory.js +0 -0
  142. /package/{Repository → lib/Repository}/RepositoryAbstract.js +0 -0
  143. /package/{Task → lib/Task}/TaskAbstract.js +0 -0
  144. /package/{bin.d.ts → lib/bin.d.ts} +0 -0
  145. /package/{bin.js → lib/bin.js} +0 -0
  146. /package/{cli.js → lib/cli.js} +0 -0
  147. /package/{globalData.d.ts → lib/globalData.d.ts} +0 -0
  148. /package/{globalData.js → lib/globalData.js} +0 -0
  149. /package/{pkg.d.ts → lib/pkg.d.ts} +0 -0
  150. /package/{pkg.js → lib/pkg.js} +0 -0
  151. /package/{utils → lib/utils}/DataFormat.js +0 -0
  152. /package/{utils → lib/utils}/Git.js +0 -0
  153. /package/{utils → lib/utils}/Restic.js +0 -0
  154. /package/{utils → lib/utils}/async.d.ts +0 -0
  155. /package/{utils → lib/utils}/async.js +0 -0
  156. /package/{utils → lib/utils}/bytes.d.ts +0 -0
  157. /package/{utils → lib/utils}/bytes.js +0 -0
  158. /package/{utils → lib/utils}/cli.d.ts +0 -0
  159. /package/{utils → lib/utils}/cli.js +0 -0
  160. /package/{utils → lib/utils}/crypto.d.ts +0 -0
  161. /package/{utils → lib/utils}/crypto.js +0 -0
  162. /package/{utils → lib/utils}/datatruck/client.d.ts +0 -0
  163. /package/{utils → lib/utils}/datatruck/client.js +0 -0
  164. /package/{utils → lib/utils}/datatruck/config.js +0 -0
  165. /package/{utils → lib/utils}/datatruck/cron-server.d.ts +0 -0
  166. /package/{utils → lib/utils}/datatruck/cron-server.js +0 -0
  167. /package/{utils → lib/utils}/datatruck/repository-server.js +0 -0
  168. /package/{utils → lib/utils}/datatruck/snapshot.js +0 -0
  169. /package/{utils → lib/utils}/date.js +0 -0
  170. /package/{utils → lib/utils}/exit.js +0 -0
  171. /package/{utils → lib/utils}/fs.d.ts +0 -0
  172. /package/{utils → lib/utils}/fs.js +0 -0
  173. /package/{utils → lib/utils}/http.d.ts +0 -0
  174. /package/{utils → lib/utils}/http.js +0 -0
  175. /package/{utils → lib/utils}/list.d.ts +0 -0
  176. /package/{utils → lib/utils}/list.js +0 -0
  177. /package/{utils → lib/utils}/math.d.ts +0 -0
  178. /package/{utils → lib/utils}/math.js +0 -0
  179. /package/{utils → lib/utils}/object.d.ts +0 -0
  180. /package/{utils → lib/utils}/object.js +0 -0
  181. /package/{utils → lib/utils}/process.js +0 -0
  182. /package/{utils → lib/utils}/progress.d.ts +0 -0
  183. /package/{utils → lib/utils}/progress.js +0 -0
  184. /package/{utils → lib/utils}/stream.d.ts +0 -0
  185. /package/{utils → lib/utils}/stream.js +0 -0
  186. /package/{utils → lib/utils}/temp.d.ts +0 -0
  187. /package/{utils → lib/utils}/temp.js +0 -0
  188. /package/{utils → lib/utils}/virtual-fs.d.ts +0 -0
  189. /package/{utils → lib/utils}/virtual-fs.js +0 -0
@@ -1,6 +1,6 @@
1
- import type { ConfigType } from "../Config/Config";
2
- import { PackageConfigType } from "../Config/PackageConfig";
3
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
1
+ import type { Config } from "../Config/Config";
2
+ import { PackageConfig } from "../Config/PackageConfig";
3
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
4
4
  import { PreSnapshot } from "../Repository/RepositoryAbstract";
5
5
  import { DataFormat } from "../utils/DataFormat";
6
6
  import { Listr3TaskResultEnd } from "../utils/list";
@@ -9,7 +9,7 @@ import { Streams } from "../utils/stream";
9
9
  import { IfRequireKeys } from "../utils/ts";
10
10
  export type BackupActionOptions = {
11
11
  repositoryNames?: string[];
12
- repositoryTypes?: RepositoryConfigType["type"][];
12
+ repositoryTypes?: RepositoryConfig["type"][];
13
13
  packageNames?: string[];
14
14
  packageTaskNames?: string[];
15
15
  tags?: string[];
@@ -49,11 +49,11 @@ type Context = {
49
49
  };
50
50
  };
51
51
  export declare class BackupAction<TRequired extends boolean = true> {
52
- readonly config: ConfigType;
52
+ readonly config: Config;
53
53
  readonly options: IfRequireKeys<TRequired, BackupActionOptions>;
54
- constructor(config: ConfigType, options?: IfRequireKeys<TRequired, BackupActionOptions>);
54
+ constructor(config: Config, options?: IfRequireKeys<TRequired, BackupActionOptions>);
55
55
  protected prepareSnapshot(): PreSnapshot;
56
- protected getPackages(snapshot: PreSnapshot): PackageConfigType[];
56
+ protected getPackages(snapshot: PreSnapshot): PackageConfig[];
57
57
  protected getRepositoryNames(repositoryNames: string[]): {
58
58
  name: string;
59
59
  mirrors: string[];
@@ -62,14 +62,14 @@ export declare class BackupAction<TRequired extends boolean = true> {
62
62
  repositoryName: string;
63
63
  snapshot: PreSnapshot;
64
64
  snapshotPath: string | undefined;
65
- pkg: PackageConfigType;
65
+ pkg: PackageConfig;
66
66
  onProgress: (data: Progress) => void;
67
67
  }): Promise<void>;
68
68
  protected copy(data: {
69
69
  repositoryName: string;
70
70
  mirrorRepositoryName: string;
71
71
  snapshot: PreSnapshot;
72
- pkg: PackageConfigType;
72
+ pkg: PackageConfig;
73
73
  onProgress: (data: Progress) => void;
74
74
  }): Promise<void>;
75
75
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
@@ -13,7 +13,8 @@ const date_1 = require("../utils/date");
13
13
  const fs_1 = require("../utils/fs");
14
14
  const list_1 = require("../utils/list");
15
15
  const progress_1 = require("../utils/progress");
16
- const steps_1 = require("../utils/steps");
16
+ const reportSteps_1 = require("../utils/reportSteps");
17
+ const spawnSteps_1 = require("../utils/spawnSteps");
17
18
  const temp_1 = require("../utils/temp");
18
19
  const PruneAction_1 = require("./PruneAction");
19
20
  const assert_1 = require("assert");
@@ -345,13 +346,31 @@ class BackupAction {
345
346
  (report.when === "error" && !success);
346
347
  if (!enabled)
347
348
  return task.skip(`Report send skipped: ${reportIndex}`);
348
- const text = this.dataFormat(result).format(report.format ?? "list");
349
- await (0, steps_1.runSteps)(report.run, {
350
- vars: {
351
- dtt: { title: "DTT Backup", text, result, success },
352
- },
353
- verbose: this.options.verbose,
354
- });
349
+ const message = this.dataFormat(result).format(report.format ?? "list");
350
+ if ((0, spawnSteps_1.isSpawnStep)(report.run)) {
351
+ await (0, spawnSteps_1.runSpawnSteps)(report.run, {
352
+ data: {
353
+ dtt: {
354
+ message,
355
+ result,
356
+ success,
357
+ },
358
+ },
359
+ verbose: this.options.verbose,
360
+ });
361
+ }
362
+ else if ((0, reportSteps_1.isReportStep)(report.run)) {
363
+ await (0, reportSteps_1.runReportSteps)(report.run, {
364
+ data: {
365
+ title: "DTT Backup",
366
+ message,
367
+ success,
368
+ },
369
+ });
370
+ }
371
+ else {
372
+ throw new Error(`Invalid step type: ${report.run.type}`);
373
+ }
355
374
  },
356
375
  });
357
376
  }),
@@ -1,5 +1,5 @@
1
1
  import { GlobalOptions } from "../Command/CommandAbstract";
2
- import type { ConfigType } from "../Config/Config";
2
+ import type { Config } from "../Config/Config";
3
3
  import { IfRequireKeys } from "../utils/ts";
4
4
  export type ConfigActionOptions = {
5
5
  path: string;
@@ -8,20 +8,20 @@ export type ConfigActionOptions = {
8
8
  export declare class ConfigAction<TRequired extends boolean = true> {
9
9
  readonly options: IfRequireKeys<TRequired, ConfigActionOptions>;
10
10
  constructor(options: IfRequireKeys<TRequired, ConfigActionOptions>);
11
- static validate(config: ConfigType): void;
12
- static check(config: ConfigType): void;
13
- static normalize(config: ConfigType): ConfigType;
14
- static parseFile(path: string): Promise<ConfigType>;
11
+ static validate(config: Config): void;
12
+ static check(config: Config): void;
13
+ static normalize(config: Config): Config;
14
+ static parseFile(path: string): Promise<Config>;
15
15
  static fromGlobalOptionsWithPath(globalOptions: GlobalOptions<true>): Promise<{
16
16
  path: string;
17
- data: ConfigType;
17
+ data: Config;
18
18
  } | {
19
19
  path: null;
20
- data: ConfigType;
20
+ data: Config;
21
21
  }>;
22
- static fromGlobalOptions(globalOptions: GlobalOptions<true>): Promise<ConfigType>;
22
+ static fromGlobalOptions(globalOptions: GlobalOptions<true>): Promise<Config>;
23
23
  exec(): Promise<{
24
24
  path: string;
25
- data: ConfigType;
25
+ data: Config;
26
26
  }>;
27
27
  }
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigAction = void 0;
7
7
  const AppError_1 = require("../Error/AppError");
8
- const JsonSchema_1 = require("../JsonSchema/JsonSchema");
8
+ const config_schema_1 = require("../config.schema");
9
9
  const config_1 = require("../utils/datatruck/config");
10
10
  const fs_1 = require("../utils/fs");
11
11
  const ajv_1 = __importDefault(require("ajv"));
@@ -16,7 +16,9 @@ class ConfigAction {
16
16
  this.options = options;
17
17
  }
18
18
  static validate(config) {
19
- const validate = new ajv_1.default().compile(JsonSchema_1.schema);
19
+ const validate = new ajv_1.default({
20
+ allowUnionTypes: true,
21
+ }).compile(config_schema_1.configSchema);
20
22
  if (!validate(config))
21
23
  throw new AppError_1.AppError("Json schema error: " + JSON.stringify(validate.errors, null, 2));
22
24
  }
@@ -1,11 +1,11 @@
1
- import type { ConfigType } from "../Config/Config";
1
+ import type { Config } from "../Config/Config";
2
2
  import { Snapshot } from "../Repository/RepositoryAbstract";
3
3
  import { DataFormat } from "../utils/DataFormat";
4
4
  import { Listr3TaskResultEnd } from "../utils/list";
5
5
  import { ProgressMode } from "../utils/progress";
6
6
  import { Streams } from "../utils/stream";
7
7
  import { IfRequireKeys } from "../utils/ts";
8
- export type CopyActionOptionsType = {
8
+ export type CopyActionOptions = {
9
9
  ids?: string[];
10
10
  last?: number;
11
11
  repositoryName: string;
@@ -32,9 +32,9 @@ export type Context = {
32
32
  };
33
33
  };
34
34
  export declare class CopyAction<TRequired extends boolean = true> {
35
- readonly config: ConfigType;
36
- readonly options: IfRequireKeys<TRequired, CopyActionOptionsType>;
37
- constructor(config: ConfigType, options: IfRequireKeys<TRequired, CopyActionOptionsType>);
35
+ readonly config: Config;
36
+ readonly options: IfRequireKeys<TRequired, CopyActionOptions>;
37
+ constructor(config: Config, options: IfRequireKeys<TRequired, CopyActionOptions>);
38
38
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
39
39
  streams?: Streams;
40
40
  verbose?: number;
@@ -1,4 +1,4 @@
1
- import type { ConfigType } from "../Config/Config";
1
+ import type { Config } from "../Config/Config";
2
2
  import { IfRequireKeys } from "../utils/ts";
3
3
  export type InitActionOptions = {
4
4
  repositoryNames?: string[];
@@ -6,9 +6,9 @@ export type InitActionOptions = {
6
6
  verbose?: boolean;
7
7
  };
8
8
  export declare class InitAction<TRequired extends boolean = true> {
9
- readonly config: ConfigType;
9
+ readonly config: Config;
10
10
  readonly options: IfRequireKeys<TRequired, InitActionOptions>;
11
- constructor(config: ConfigType, options: IfRequireKeys<TRequired, InitActionOptions>);
11
+ constructor(config: Config, options: IfRequireKeys<TRequired, InitActionOptions>);
12
12
  exec(): Promise<{
13
13
  repositoryName: string;
14
14
  repositoryType: string;
@@ -1,5 +1,5 @@
1
- import type { ConfigType } from "../Config/Config";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
1
+ import type { Config } from "../Config/Config";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { KeepObject } from "../utils/date";
4
4
  import { IfRequireKeys } from "../utils/ts";
5
5
  import { ExtendedSnapshot, SnapshotsActionOptions } from "./SnapshotsAction";
@@ -7,7 +7,7 @@ export type PruneActionsOptions = KeepObject & {
7
7
  ids?: string[];
8
8
  packageNames?: string[];
9
9
  repositoryNames?: string[];
10
- repositoryTypes?: RepositoryConfigType["type"][];
10
+ repositoryTypes?: RepositoryConfig["type"][];
11
11
  tags?: string[];
12
12
  verbose?: boolean;
13
13
  groupBy?: SnapshotsActionOptions["groupBy"];
@@ -23,9 +23,9 @@ export type PruneResult = {
23
23
  })[];
24
24
  };
25
25
  export declare class PruneAction<TRequired extends boolean = true> {
26
- readonly config: ConfigType;
26
+ readonly config: Config;
27
27
  readonly options: IfRequireKeys<TRequired, PruneActionsOptions>;
28
- constructor(config: ConfigType, options: IfRequireKeys<TRequired, PruneActionsOptions>);
28
+ constructor(config: Config, options: IfRequireKeys<TRequired, PruneActionsOptions>);
29
29
  confirm(snapshots: PruneResult["snapshots"]): Promise<void>;
30
30
  exec(): Promise<PruneResult>;
31
31
  }
@@ -1,5 +1,5 @@
1
- import type { ConfigType } from "../Config/Config";
2
- import { PackageConfigType } from "../Config/PackageConfig";
1
+ import type { Config } from "../Config/Config";
2
+ import { PackageConfig } from "../Config/PackageConfig";
3
3
  import { Snapshot } from "../Repository/RepositoryAbstract";
4
4
  import { TaskAbstract } from "../Task/TaskAbstract";
5
5
  import { DataFormat } from "../utils/DataFormat";
@@ -37,15 +37,15 @@ type Context = {
37
37
  restore: RestoreSnapshot;
38
38
  };
39
39
  export declare class RestoreAction<TRequired extends boolean = true> {
40
- readonly config: ConfigType;
40
+ readonly config: Config;
41
41
  readonly options: IfRequireKeys<TRequired, RestoreActionOptions>;
42
42
  protected taskErrors: Record<string, Error[]>;
43
43
  protected repoErrors: Record<string, Error[]>;
44
- constructor(config: ConfigType, options: IfRequireKeys<TRequired, RestoreActionOptions>);
44
+ constructor(config: Config, options: IfRequireKeys<TRequired, RestoreActionOptions>);
45
45
  protected findSnapshots(): Promise<RestoreSnapshot[]>;
46
46
  protected groupSnapshots(snapshots: RestoreSnapshot[]): RestoreSnapshot[];
47
47
  protected restore(data: {
48
- pkg: PackageConfigType;
48
+ pkg: PackageConfig;
49
49
  task: TaskAbstract | undefined;
50
50
  snapshot: RestoreSnapshot;
51
51
  gc: GargabeCollector;
@@ -1,5 +1,5 @@
1
- import type { ConfigType } from "../Config/Config";
2
- import { RepositoryConfigEnabledActionType } from "../Config/RepositoryConfig";
1
+ import type { Config } from "../Config/Config";
2
+ import { RepositoryConfigEnabledAction } from "../Config/RepositoryConfig";
3
3
  import { Snapshot } from "../Repository/RepositoryAbstract";
4
4
  import { IfRequireKeys } from "../utils/ts";
5
5
  export type SnapshotGroupByType = keyof Pick<ExtendedSnapshot, "packageName" | "repositoryName" | "repositoryType">;
@@ -27,8 +27,8 @@ export type ExtendedSnapshot = {
27
27
  repositoryType: string;
28
28
  } & Snapshot;
29
29
  export declare class SnapshotsAction<TRequired extends boolean = true> {
30
- readonly config: ConfigType;
30
+ readonly config: Config;
31
31
  readonly options: IfRequireKeys<TRequired, SnapshotsActionOptions>;
32
- constructor(config: ConfigType, options: IfRequireKeys<TRequired, SnapshotsActionOptions>);
33
- exec(sourceAction?: RepositoryConfigEnabledActionType): Promise<ExtendedSnapshot[]>;
32
+ constructor(config: Config, options: IfRequireKeys<TRequired, SnapshotsActionOptions>);
33
+ exec(sourceAction?: RepositoryConfigEnabledAction): Promise<ExtendedSnapshot[]>;
34
34
  }
@@ -1,12 +1,12 @@
1
1
  import { BackupAction } from "../Action/BackupAction";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { If, Unwrap } from "../utils/ts";
4
4
  import { CommandAbstract } from "./CommandAbstract";
5
5
  export type BackupCommandOptions<TResolved = false> = {
6
6
  package?: If<TResolved, string[]>;
7
7
  packageTask?: If<TResolved, string[]>;
8
8
  repository?: If<TResolved, string[]>;
9
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
9
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
10
10
  tag?: If<TResolved, string[]>;
11
11
  dryRun?: boolean;
12
12
  date?: string;
@@ -1,12 +1,12 @@
1
- import { ConfigType } from "../Config/Config";
2
- import { FormatType } from "../utils/DataFormat";
1
+ import { Config } from "../Config/Config";
2
+ import { DataFormatType } from "../utils/DataFormat";
3
3
  import { OptionsType } from "../utils/cli";
4
4
  import { ProgressMode } from "../utils/progress";
5
5
  import { Streams } from "../utils/stream";
6
6
  import { If, SimilarObject } from "../utils/ts";
7
7
  export type GlobalOptions<TResolved = false> = {
8
- config: string | ConfigType;
9
- outputFormat?: FormatType;
8
+ config: string | Config;
9
+ outputFormat?: DataFormatType;
10
10
  verbose?: number;
11
11
  tty?: If<TResolved, "auto" | boolean, "auto" | "true" | "false">;
12
12
  progress?: If<TResolved, ProgressMode, Exclude<ProgressMode, boolean> | "true" | "false">;
@@ -1,12 +1,12 @@
1
1
  import { ConfigAction } from "../Action/ConfigAction";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { If, Unwrap } from "../utils/ts";
4
4
  import { CommandAbstract } from "./CommandAbstract";
5
5
  export type ConfigCommandOptions<TResolved = false> = {
6
6
  package?: If<TResolved, string[]>;
7
7
  packageTask?: If<TResolved, string[]>;
8
8
  repository?: If<TResolved, string[]>;
9
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
9
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
10
10
  };
11
11
  export type ConfigCommandResult = Unwrap<ConfigAction["exec"]>;
12
12
  export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptions<false>, ConfigCommandOptions<true>> {
@@ -1,10 +1,10 @@
1
1
  import { InitAction } from "../Action/InitAction";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { If, Unwrap } from "../utils/ts";
4
4
  import { CommandAbstract } from "./CommandAbstract";
5
5
  export type InitCommandOptions<TResolved = false> = {
6
6
  repository?: If<TResolved, string[]>;
7
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
7
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
8
8
  };
9
9
  export type InitCommandResult = Unwrap<InitAction["exec"]>;
10
10
  export declare class InitCommand extends CommandAbstract<InitCommandOptions<false>, InitCommandOptions<true>> {
@@ -1,5 +1,5 @@
1
1
  import { SnapshotGroupByType } from "../Action/SnapshotsAction";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { KeepObject } from "../utils/date";
4
4
  import { If } from "../utils/ts";
5
5
  import { CommandAbstract } from "./CommandAbstract";
@@ -8,7 +8,7 @@ export type PruneCommandOptions<TResolved = false> = KeepObject & {
8
8
  longId?: boolean;
9
9
  package?: If<TResolved, string[]>;
10
10
  repository?: If<TResolved, string[]>;
11
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
11
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
12
12
  tag?: If<TResolved, string[]>;
13
13
  groupBy?: If<TResolved, SnapshotGroupByType[]>;
14
14
  dryRun?: boolean;
@@ -1,4 +1,4 @@
1
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
1
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
2
2
  import { If } from "../utils/ts";
3
3
  import { CommandAbstract } from "./CommandAbstract";
4
4
  export type RestoreCommandOptionsType<TResolved = false> = {
@@ -7,7 +7,7 @@ export type RestoreCommandOptionsType<TResolved = false> = {
7
7
  packageTask?: If<TResolved, string[]>;
8
8
  packageConfig?: boolean;
9
9
  repository?: If<TResolved, string[]>;
10
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
10
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
11
11
  tag?: If<TResolved, string[]>;
12
12
  initial?: boolean;
13
13
  };
@@ -1,5 +1,5 @@
1
1
  import { SnapshotsAction } from "../Action/SnapshotsAction";
2
- import { RepositoryConfigType } from "../Config/RepositoryConfig";
2
+ import { RepositoryConfig } from "../Config/RepositoryConfig";
3
3
  import { If, Unwrap } from "../utils/ts";
4
4
  import { CommandAbstract } from "./CommandAbstract";
5
5
  export type SnapshotsCommandOptions<TResolved = false> = {
@@ -8,7 +8,7 @@ export type SnapshotsCommandOptions<TResolved = false> = {
8
8
  packageTask?: If<TResolved, string[]>;
9
9
  packageConfig?: boolean;
10
10
  repository?: If<TResolved, string[]>;
11
- repositoryType?: If<TResolved, RepositoryConfigType["type"][]>;
11
+ repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
12
12
  longId?: boolean;
13
13
  last?: If<TResolved, number>;
14
14
  lastMinutely?: If<TResolved, number>;
@@ -0,0 +1,28 @@
1
+ import { DataFormatType } from "../utils/DataFormat";
2
+ import { DatatruckCronServerOptions } from "../utils/datatruck/cron-server";
3
+ import { DatatruckRepositoryServerOptions } from "../utils/datatruck/repository-server";
4
+ import { ReportStep } from "../utils/reportSteps";
5
+ import { SpawnStep } from "../utils/spawnSteps";
6
+ import { PackageConfig } from "./PackageConfig";
7
+ import { PrunePolicyConfig } from "./PrunePolicyConfig";
8
+ import { RepositoryConfig } from "./RepositoryConfig";
9
+ export type Config = {
10
+ $schema?: string;
11
+ tempDir?: string;
12
+ minFreeDiskSpace?: string | number;
13
+ repositories: RepositoryConfig[];
14
+ packages: PackageConfig[];
15
+ server?: DatatruckServerOptions;
16
+ reports?: ReportConfig[];
17
+ prunePolicy?: PrunePolicyConfig;
18
+ };
19
+ export type DatatruckServerOptions = {
20
+ log?: boolean;
21
+ repository?: DatatruckRepositoryServerOptions;
22
+ cron?: DatatruckCronServerOptions;
23
+ };
24
+ export type ReportConfig = {
25
+ when?: "success" | "error";
26
+ format?: Exclude<DataFormatType, "custom" | "tpl">;
27
+ run: SpawnStep | ReportStep;
28
+ };
@@ -0,0 +1,24 @@
1
+ import { SpawnStep } from "../utils/spawnSteps";
2
+ import { PackageRepositoryConfig } from "./PackageRepositoryConfig";
3
+ import { PrunePolicyConfig } from "./PrunePolicyConfig";
4
+ import type { TaskConfig } from "./TaskConfig";
5
+ export type Meta = {
6
+ [name: string]: any;
7
+ };
8
+ export type PackageConfig = {
9
+ name: string;
10
+ enabled?: boolean;
11
+ task?: TaskConfig;
12
+ path?: string;
13
+ restorePath?: string;
14
+ meta?: Meta;
15
+ restorePermissions?: {
16
+ uid: string | number;
17
+ gid: string | number;
18
+ };
19
+ include?: (string | SpawnStep)[];
20
+ exclude?: (string | SpawnStep)[];
21
+ repositoryNames?: string[];
22
+ prunePolicy?: PrunePolicyConfig;
23
+ repositoryConfigs?: PackageRepositoryConfig[];
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { DatatruckPackageRepositoryConfig, datatruckRepositoryName } from "../Repository/DatatruckRepository";
2
+ import { GitPackageRepositoryConfig, gitRepositoryName } from "../Repository/GitRepository";
3
+ import { ResticPackageRepositoryConfig, resticRepositoryName } from "../Repository/ResticRepository";
4
+ export type PackageRepositoryConfig = {
5
+ names?: string[];
6
+ } & ({
7
+ type: typeof resticRepositoryName;
8
+ config: ResticPackageRepositoryConfig;
9
+ } | {
10
+ type: typeof datatruckRepositoryName;
11
+ config: DatatruckPackageRepositoryConfig;
12
+ } | {
13
+ type: typeof gitRepositoryName;
14
+ config: GitPackageRepositoryConfig;
15
+ });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { PruneActionsOptions } from "../Action/PruneAction";
2
+ export type PrunePolicyConfig = Pick<PruneActionsOptions, "keepDaily" | "keepHourly" | "keepMinutely" | "keepLast" | "keepMonthly" | "keepWeekly" | "keepYearly" | "groupBy" | "tags">;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { DatatruckRepositoryConfig, datatruckRepositoryName } from "../Repository/DatatruckRepository";
2
+ import { GitRepositoryConfig, gitRepositoryName } from "../Repository/GitRepository";
3
+ import { ResticRepositoryConfig, resticRepositoryName } from "../Repository/ResticRepository";
4
+ export type RepositoryConfigType = RepositoryConfig["type"];
5
+ export type RepositoryConfigEnabledAction = "backup" | "init" | "prune" | "restore" | "snapshots";
6
+ export type RepositoryEnabledObject = {
7
+ [K in "defaults" | RepositoryConfigEnabledAction]?: boolean;
8
+ };
9
+ export type ResticRepositoryConfigItem = {
10
+ type: typeof resticRepositoryName;
11
+ config: ResticRepositoryConfig;
12
+ };
13
+ export type DatatruckRepositoryConfigItem = {
14
+ type: typeof datatruckRepositoryName;
15
+ config: DatatruckRepositoryConfig;
16
+ };
17
+ export type GitRepositoryConfigItem = {
18
+ type: typeof gitRepositoryName;
19
+ config: GitRepositoryConfig;
20
+ };
21
+ type CommonRepositoryConfig = {
22
+ name: string;
23
+ mirrorRepoNames?: string[];
24
+ enabled?: boolean | RepositoryEnabledObject;
25
+ };
26
+ export type RepositoryConfig = CommonRepositoryConfig & (ResticRepositoryConfigItem | DatatruckRepositoryConfigItem | GitRepositoryConfigItem);
27
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,31 @@
1
+ import { GitTaskConfig, gitTaskName } from "../Task/GitTask";
2
+ import { MariadbTaskConfig, mariadbTaskName } from "../Task/MariadbTask";
3
+ import { MssqlTaskConfig, mssqlTaskName } from "../Task/MssqlTask";
4
+ import { MysqlDumpTaskConfig, mysqlDumpTaskName } from "../Task/MysqlDumpTask";
5
+ import { PostgresqlDumpTaskConfig, postgresqlDumpTaskName } from "../Task/PostgresqlDumpTask";
6
+ import { ScriptTaskConfig, scriptTaskName } from "../Task/ScriptTask";
7
+ export type GitTaskConfigItem = {
8
+ name: typeof gitTaskName;
9
+ config: GitTaskConfig;
10
+ };
11
+ export type MariadbTaskConfigItem = {
12
+ name: typeof mariadbTaskName;
13
+ config: MariadbTaskConfig;
14
+ };
15
+ export type MssqlTaskConfigItem = {
16
+ name: typeof mssqlTaskName;
17
+ config: MssqlTaskConfig;
18
+ };
19
+ export type MysqlDumpTaskConfigItem = {
20
+ name: typeof mysqlDumpTaskName;
21
+ config: MysqlDumpTaskConfig;
22
+ };
23
+ export type PostgresqlDumpTaskConfigItem = {
24
+ name: typeof postgresqlDumpTaskName;
25
+ config: PostgresqlDumpTaskConfig;
26
+ };
27
+ export type ScriptTaskConfigItem = {
28
+ name: typeof scriptTaskName;
29
+ config: ScriptTaskConfig;
30
+ };
31
+ export type TaskConfig = GitTaskConfigItem | MariadbTaskConfigItem | MssqlTaskConfigItem | MysqlDumpTaskConfigItem | PostgresqlDumpTaskConfigItem | ScriptTaskConfigItem;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -20,7 +20,7 @@ export declare enum CommandEnum {
20
20
  cleanCache = "clean-cache",
21
21
  startServer = "start-server"
22
22
  }
23
- export type OptionsMapType = {
23
+ export type OptionsMap = {
24
24
  [CommandEnum.config]: ConfigCommandOptions;
25
25
  [CommandEnum.init]: InitCommandOptions;
26
26
  [CommandEnum.snapshots]: SnapshotsCommandOptions;
@@ -31,15 +31,15 @@ export type OptionsMapType = {
31
31
  [CommandEnum.cleanCache]: CleanCacheActionOptions;
32
32
  [CommandEnum.startServer]: StartServerCommandOptions;
33
33
  };
34
- export type LogMapType = {
34
+ export type LogMap = {
35
35
  [CommandEnum.config]: ConfigCommandResult;
36
36
  [CommandEnum.init]: InitCommandResult;
37
37
  [CommandEnum.snapshots]: SnapshotsCommandResult;
38
38
  [CommandEnum.backup]: BackupCommandResult;
39
39
  };
40
- export declare function CommandFactory<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>, configPath?: string): StartServerCommand;
41
- export declare function exec<TCommand extends keyof OptionsMapType>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMapType[TCommand], streams?: Partial<Streams>): Promise<number>;
40
+ export declare function CommandFactory<TCommand extends keyof OptionsMap>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMap[TCommand], streams?: Partial<Streams>, configPath?: string): StartServerCommand;
41
+ export declare function exec<TCommand extends keyof OptionsMap>(type: TCommand, globalOptions: GlobalOptions<true>, options: OptionsMap[TCommand], streams?: Partial<Streams>): Promise<number>;
42
42
  export declare function createActionInterface(globalOptions: GlobalOptions<true>): {
43
- [K in keyof OptionsMapType as `${K}`]: (options: OptionsMapType[K]) => Promise<K extends keyof LogMapType ? LogMapType[K] : never>;
43
+ [K in keyof OptionsMap as `${K}`]: (options: OptionsMap[K]) => Promise<K extends keyof LogMap ? LogMap[K] : never>;
44
44
  };
45
45
  export declare function CommandConstructorFactory(type: CommandEnum): typeof StartServerCommand;
@@ -0,0 +1,3 @@
1
+ import type { RepositoryConfig } from "../Config/RepositoryConfig";
2
+ import type { RepositoryAbstract } from "../Repository/RepositoryAbstract";
3
+ export declare function createRepo(repository: RepositoryConfig): RepositoryAbstract<any>;
@@ -0,0 +1,3 @@
1
+ import { TaskConfig } from "../Config/TaskConfig";
2
+ import type { TaskAbstract } from "../Task/TaskAbstract";
3
+ export declare function createTask(task: TaskConfig): TaskAbstract;