@datatruck/cli 0.0.1
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/lib/Action/BackupAction.d.ts +32 -0
- package/lib/Action/BackupAction.js +201 -0
- package/lib/Action/BackupSessionsAction.d.ts +13 -0
- package/lib/Action/BackupSessionsAction.js +16 -0
- package/lib/Action/CleanCacheAction.d.ts +9 -0
- package/lib/Action/CleanCacheAction.js +18 -0
- package/lib/Action/ConfigAction.d.ts +14 -0
- package/lib/Action/ConfigAction.js +64 -0
- package/lib/Action/InitAction.d.ts +18 -0
- package/lib/Action/InitAction.js +39 -0
- package/lib/Action/PruneAction.d.ts +37 -0
- package/lib/Action/PruneAction.js +80 -0
- package/lib/Action/RestoreAction.d.ts +36 -0
- package/lib/Action/RestoreAction.js +246 -0
- package/lib/Action/RestoreSessionsAction.d.ts +13 -0
- package/lib/Action/RestoreSessionsAction.js +16 -0
- package/lib/Action/SnapshotsAction.d.ts +30 -0
- package/lib/Action/SnapshotsAction.js +35 -0
- package/lib/Command/BackupCommand.d.ts +15 -0
- package/lib/Command/BackupCommand.js +83 -0
- package/lib/Command/BackupSessionsCommand.d.ts +12 -0
- package/lib/Command/BackupSessionsCommand.js +88 -0
- package/lib/Command/CleanCacheCommand.d.ts +6 -0
- package/lib/Command/CleanCacheCommand.js +20 -0
- package/lib/Command/CommandAbstract.d.ts +19 -0
- package/lib/Command/CommandAbstract.js +14 -0
- package/lib/Command/ConfigCommand.d.ts +17 -0
- package/lib/Command/ConfigCommand.js +61 -0
- package/lib/Command/InitCommand.d.ts +13 -0
- package/lib/Command/InitCommand.js +67 -0
- package/lib/Command/PruneCommand.d.ts +27 -0
- package/lib/Command/PruneCommand.js +160 -0
- package/lib/Command/RestoreCommand.d.ts +14 -0
- package/lib/Command/RestoreCommand.js +71 -0
- package/lib/Command/RestoreSessionsCommand.d.ts +12 -0
- package/lib/Command/RestoreSessionsCommand.js +87 -0
- package/lib/Command/SnapshotsCommand.d.ts +25 -0
- package/lib/Command/SnapshotsCommand.js +128 -0
- package/lib/Config/Config.d.ts +8 -0
- package/lib/Config/Config.js +19 -0
- package/lib/Config/PackageConfig.d.ts +27 -0
- package/lib/Config/PackageConfig.js +69 -0
- package/lib/Config/PackageRepositoryConfig.d.ts +17 -0
- package/lib/Config/PackageRepositoryConfig.js +37 -0
- package/lib/Config/PrunePolicyConfig.d.ts +4 -0
- package/lib/Config/PrunePolicyConfig.js +28 -0
- package/lib/Config/RepositoryConfig.d.ts +18 -0
- package/lib/Config/RepositoryConfig.js +37 -0
- package/lib/Config/TaskConfig.d.ts +23 -0
- package/lib/Config/TaskConfig.js +39 -0
- package/lib/Decorator/EntityDecorator.d.ts +11 -0
- package/lib/Decorator/EntityDecorator.js +17 -0
- package/lib/Entity/BackupSessionEntity.d.ts +6 -0
- package/lib/Entity/BackupSessionEntity.js +22 -0
- package/lib/Entity/BackupSessionRepositoryEntity.d.ts +6 -0
- package/lib/Entity/BackupSessionRepositoryEntity.js +22 -0
- package/lib/Entity/BackupSessionTaskEntity.d.ts +5 -0
- package/lib/Entity/BackupSessionTaskEntity.js +22 -0
- package/lib/Entity/CrudEntityAbstract.d.ts +5 -0
- package/lib/Entity/CrudEntityAbstract.js +6 -0
- package/lib/Entity/RestoreSessionEntity.d.ts +5 -0
- package/lib/Entity/RestoreSessionEntity.js +22 -0
- package/lib/Entity/RestoreSessionRepositoryEntity.d.ts +6 -0
- package/lib/Entity/RestoreSessionRepositoryEntity.js +22 -0
- package/lib/Entity/RestoreSessionTaskEntity.d.ts +5 -0
- package/lib/Entity/RestoreSessionTaskEntity.js +22 -0
- package/lib/Entity/StateEntityAbstract.d.ts +12 -0
- package/lib/Entity/StateEntityAbstract.js +7 -0
- package/lib/Error/AppError.d.ts +2 -0
- package/lib/Error/AppError.js +6 -0
- package/lib/Factory/CommandFactory.d.ts +42 -0
- package/lib/Factory/CommandFactory.js +79 -0
- package/lib/Factory/EntityFactory.d.ts +6 -0
- package/lib/Factory/EntityFactory.js +40 -0
- package/lib/Factory/RepositoryFactory.d.ts +3 -0
- package/lib/Factory/RepositoryFactory.js +23 -0
- package/lib/Factory/TaskFactory.d.ts +3 -0
- package/lib/Factory/TaskFactory.js +30 -0
- package/lib/JsonSchema/DefinitionEnum.d.ts +25 -0
- package/lib/JsonSchema/DefinitionEnum.js +32 -0
- package/lib/JsonSchema/JsonSchema.d.ts +4 -0
- package/lib/JsonSchema/JsonSchema.js +50 -0
- package/lib/Repository/GitRepository.d.ts +29 -0
- package/lib/Repository/GitRepository.js +237 -0
- package/lib/Repository/LocalRepository.d.ts +51 -0
- package/lib/Repository/LocalRepository.js +358 -0
- package/lib/Repository/RepositoryAbstract.d.ts +77 -0
- package/lib/Repository/RepositoryAbstract.js +19 -0
- package/lib/Repository/ResticRepository.d.ts +36 -0
- package/lib/Repository/ResticRepository.js +230 -0
- package/lib/SessionDriver/ConsoleSessionDriver.d.ts +37 -0
- package/lib/SessionDriver/ConsoleSessionDriver.js +178 -0
- package/lib/SessionDriver/SessionDriverAbstract.d.ts +78 -0
- package/lib/SessionDriver/SessionDriverAbstract.js +27 -0
- package/lib/SessionDriver/SqliteSessionDriver.d.ts +20 -0
- package/lib/SessionDriver/SqliteSessionDriver.js +169 -0
- package/lib/SessionManager/BackupSessionManager.d.ts +44 -0
- package/lib/SessionManager/BackupSessionManager.js +206 -0
- package/lib/SessionManager/RestoreSessionManager.d.ts +44 -0
- package/lib/SessionManager/RestoreSessionManager.js +206 -0
- package/lib/Task/GitTask.d.ts +35 -0
- package/lib/Task/GitTask.js +248 -0
- package/lib/Task/MariadbTask.d.ts +25 -0
- package/lib/Task/MariadbTask.js +139 -0
- package/lib/Task/MssqlTask.d.ts +22 -0
- package/lib/Task/MssqlTask.js +109 -0
- package/lib/Task/MysqlDumpTask.d.ts +14 -0
- package/lib/Task/MysqlDumpTask.js +129 -0
- package/lib/Task/PostgresqlDumpTask.d.ts +14 -0
- package/lib/Task/PostgresqlDumpTask.js +101 -0
- package/lib/Task/SqlDumpTaskAbstract.d.ts +36 -0
- package/lib/Task/SqlDumpTaskAbstract.js +146 -0
- package/lib/Task/TaskAbstract.d.ts +37 -0
- package/lib/Task/TaskAbstract.js +17 -0
- package/lib/bin.d.ts +2 -0
- package/lib/bin.js +5 -0
- package/lib/cli.d.ts +4 -0
- package/lib/cli.js +110 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +1 -0
- package/lib/util/DataFormat.d.ts +24 -0
- package/lib/util/DataFormat.js +50 -0
- package/lib/util/GitUtil.d.ts +38 -0
- package/lib/util/GitUtil.js +105 -0
- package/lib/util/ObjectVault.d.ts +13 -0
- package/lib/util/ObjectVault.js +31 -0
- package/lib/util/ResticUtil.d.ts +92 -0
- package/lib/util/ResticUtil.js +144 -0
- package/lib/util/cli-util.d.ts +27 -0
- package/lib/util/cli-util.js +118 -0
- package/lib/util/datatruck/config-util.d.ts +55 -0
- package/lib/util/datatruck/config-util.js +93 -0
- package/lib/util/datatruck/paths-util.d.ts +5 -0
- package/lib/util/datatruck/paths-util.js +22 -0
- package/lib/util/datatruck/snapshot-util.d.ts +4 -0
- package/lib/util/datatruck/snapshot-util.js +31 -0
- package/lib/util/date-util.d.ts +12 -0
- package/lib/util/date-util.js +74 -0
- package/lib/util/entity-util.d.ts +4 -0
- package/lib/util/entity-util.js +10 -0
- package/lib/util/fs-util.d.ts +43 -0
- package/lib/util/fs-util.js +278 -0
- package/lib/util/math-util.d.ts +1 -0
- package/lib/util/math-util.js +7 -0
- package/lib/util/object-util.d.ts +7 -0
- package/lib/util/object-util.js +58 -0
- package/lib/util/process-util.d.ts +50 -0
- package/lib/util/process-util.js +181 -0
- package/lib/util/string-util.d.ts +17 -0
- package/lib/util/string-util.js +77 -0
- package/lib/util/zip-util.d.ts +52 -0
- package/lib/util/zip-util.js +135 -0
- package/migrations/001-initial.sql +122 -0
- package/package.json +62 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SqliteSessionDriver = void 0;
|
|
7
|
+
const EntityDecorator_1 = require("../Decorator/EntityDecorator");
|
|
8
|
+
const BackupSessionEntity_1 = require("../Entity/BackupSessionEntity");
|
|
9
|
+
const BackupSessionRepositoryEntity_1 = require("../Entity/BackupSessionRepositoryEntity");
|
|
10
|
+
const RestoreSessionEntity_1 = require("../Entity/RestoreSessionEntity");
|
|
11
|
+
const RestoreSessionRepositoryEntity_1 = require("../Entity/RestoreSessionRepositoryEntity");
|
|
12
|
+
const cli_util_1 = require("../util/cli-util");
|
|
13
|
+
const entity_util_1 = require("../util/entity-util");
|
|
14
|
+
const process_util_1 = require("../util/process-util");
|
|
15
|
+
const SessionDriverAbstract_1 = require("./SessionDriverAbstract");
|
|
16
|
+
const assert_1 = require("assert");
|
|
17
|
+
const os_1 = require("os");
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const sqlite_1 = require("sqlite");
|
|
20
|
+
const sqlite3_1 = __importDefault(require("sqlite3"));
|
|
21
|
+
class SqliteSessionDriver extends SessionDriverAbstract_1.SessionDriverAbstract {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.idMap = {};
|
|
25
|
+
}
|
|
26
|
+
async onInit() {
|
|
27
|
+
this.db = await (0, sqlite_1.open)({
|
|
28
|
+
filename: process.env["DATATRUCK_SQLITE_DB"] ??
|
|
29
|
+
(0, path_1.join)((0, os_1.homedir)(), "datatruck.sqlite"),
|
|
30
|
+
driver: sqlite3_1.default.Database,
|
|
31
|
+
});
|
|
32
|
+
await this.db.migrate({
|
|
33
|
+
migrationsPath: __dirname + "/../../migrations",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
buildInsertStm(tableName, values) {
|
|
37
|
+
const keys = Object.keys(values);
|
|
38
|
+
const columnNames = keys.map((v) => `\`${v}\``).join(", ");
|
|
39
|
+
const paramNames = keys.map((v) => `:${v}`).join(", ");
|
|
40
|
+
return `INSERT INTO ${tableName} (${columnNames}) VALUES (${paramNames})`;
|
|
41
|
+
}
|
|
42
|
+
buildUpdateStm(tableName, values, pkColumnName = "id") {
|
|
43
|
+
const set = Object.keys(values)
|
|
44
|
+
.filter((v) => v !== pkColumnName)
|
|
45
|
+
.map((v) => `\`${v}\` = :${v}`)
|
|
46
|
+
.join(", ");
|
|
47
|
+
return `UPDATE ${tableName} SET ${set} WHERE ${pkColumnName} = :${pkColumnName}`;
|
|
48
|
+
}
|
|
49
|
+
async exec(query, cb) {
|
|
50
|
+
if (this.options.verbose) {
|
|
51
|
+
(0, cli_util_1.logExec)("query");
|
|
52
|
+
(0, process_util_1.logExecStdout)({ data: query, lineSalt: true });
|
|
53
|
+
}
|
|
54
|
+
const result = await cb();
|
|
55
|
+
if (this.options.verbose)
|
|
56
|
+
(0, process_util_1.logExecStdout)({ data: JSON.stringify(result, null, 2), lineSalt: true });
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
async onRead(data, type) {
|
|
60
|
+
const sessionMeta = (0, EntityDecorator_1.EntityDecoratorHandler)(type === SessionDriverAbstract_1.EntityEnum.BackupSession
|
|
61
|
+
? BackupSessionEntity_1.BackupSessionEntity
|
|
62
|
+
: RestoreSessionEntity_1.RestoreSessionEntity);
|
|
63
|
+
const sessionRepositoryMeta = (0, EntityDecorator_1.EntityDecoratorHandler)(type === SessionDriverAbstract_1.EntityEnum.BackupSession
|
|
64
|
+
? BackupSessionRepositoryEntity_1.BackupSessionRepositoryEntity
|
|
65
|
+
: RestoreSessionRepositoryEntity_1.RestoreSessionRepositoryEntity);
|
|
66
|
+
const sessionTable = (0, entity_util_1.makeTableSelector)(sessionMeta.get().tableName);
|
|
67
|
+
const repoTable = (0, entity_util_1.makeTableSelector)(sessionRepositoryMeta.get().tableName);
|
|
68
|
+
const where = {};
|
|
69
|
+
if (data.packageNames)
|
|
70
|
+
where[sessionTable("packageName")] = data.packageNames;
|
|
71
|
+
if (data.repositoryNames)
|
|
72
|
+
where[repoTable("repositoryName")] = data.repositoryNames;
|
|
73
|
+
if (data.packageNames)
|
|
74
|
+
where[sessionTable("packageName")] = data.packageNames;
|
|
75
|
+
if (type === SessionDriverAbstract_1.EntityEnum.BackupSession && data.tags)
|
|
76
|
+
data.tags.map((tag) => `(',' || ${sessionTable("tags")} || ',') LIKE '%,${tag},%' `);
|
|
77
|
+
let query = `
|
|
78
|
+
SELECT
|
|
79
|
+
${sessionTable("id")},
|
|
80
|
+
${sessionTable("snapshotId")},
|
|
81
|
+
${sessionTable("creationDate")},
|
|
82
|
+
${sessionTable("state")},
|
|
83
|
+
${sessionTable("packageName")},
|
|
84
|
+
${repoTable("repositoryName")},
|
|
85
|
+
${repoTable("repositoryType")},
|
|
86
|
+
COALESCE(${repoTable("error")}, ${sessionTable("error")}) AS error
|
|
87
|
+
FROM
|
|
88
|
+
${sessionTable}
|
|
89
|
+
LEFT JOIN ${repoTable} ON
|
|
90
|
+
${repoTable("sessionId")} = ${sessionTable("id")}
|
|
91
|
+
ORDER BY
|
|
92
|
+
${sessionTable("id")} DESC
|
|
93
|
+
`;
|
|
94
|
+
if (data.limit)
|
|
95
|
+
query += `LIMIT ${data.limit}`;
|
|
96
|
+
return await this.exec(query, async () => await this.db.all(query));
|
|
97
|
+
}
|
|
98
|
+
setMapId(entity, id, value) {
|
|
99
|
+
if (!this.idMap[entity])
|
|
100
|
+
this.idMap[entity] = {};
|
|
101
|
+
const map = this.idMap[entity];
|
|
102
|
+
(0, assert_1.ok)(map);
|
|
103
|
+
map[id] = value;
|
|
104
|
+
}
|
|
105
|
+
getMapId(entity, id) {
|
|
106
|
+
const result = this.idMap[entity]?.[id];
|
|
107
|
+
if (!result)
|
|
108
|
+
throw new Error(`Entity id not found: ${entity}-${id}`);
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
static getEntityTable(entity) {
|
|
112
|
+
return {
|
|
113
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSession]: "backup_session",
|
|
114
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSessionRepository]: "backup_session_repository",
|
|
115
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSessionTask]: "backup_session_task",
|
|
116
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSession]: "restore_session",
|
|
117
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository]: "restore_session_repository",
|
|
118
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSessionTask]: "restore_session_task",
|
|
119
|
+
}[entity];
|
|
120
|
+
}
|
|
121
|
+
static getParentEntity(entity) {
|
|
122
|
+
return {
|
|
123
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSession]: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
124
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSessionRepository]: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
125
|
+
[SessionDriverAbstract_1.EntityEnum.BackupSessionTask]: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
126
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSession]: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
127
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository]: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
128
|
+
[SessionDriverAbstract_1.EntityEnum.RestoreSessionTask]: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
129
|
+
}[entity];
|
|
130
|
+
}
|
|
131
|
+
async onWrite(data) {
|
|
132
|
+
const tableName = SqliteSessionDriver.getEntityTable(data.entity);
|
|
133
|
+
let stm;
|
|
134
|
+
let object = data.data;
|
|
135
|
+
const id = object.id;
|
|
136
|
+
if (data.action === SessionDriverAbstract_1.ActionEnum.Init) {
|
|
137
|
+
// @ts-expect-error
|
|
138
|
+
object = { ...object, id: null };
|
|
139
|
+
stm = this.buildInsertStm(tableName, object);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
object = { ...object, id: this.getMapId(data.entity, id) };
|
|
143
|
+
if ("sessionId" in object) {
|
|
144
|
+
const parentEntity = SqliteSessionDriver.getParentEntity(data.entity);
|
|
145
|
+
object.sessionId = this.getMapId(parentEntity, object.sessionId);
|
|
146
|
+
}
|
|
147
|
+
stm = this.buildUpdateStm(tableName, object);
|
|
148
|
+
}
|
|
149
|
+
const params = Object.keys(object).reduce((result, name) => {
|
|
150
|
+
result[`:${name}`] = object[name];
|
|
151
|
+
return result;
|
|
152
|
+
}, {});
|
|
153
|
+
try {
|
|
154
|
+
const result = await this.exec(stm, async () => await this.db.run(stm, params));
|
|
155
|
+
if (data.action === SessionDriverAbstract_1.ActionEnum.Init &&
|
|
156
|
+
typeof result.lastID === "number") {
|
|
157
|
+
this.setMapId(data.entity, id, result.lastID);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error({
|
|
162
|
+
query: stm,
|
|
163
|
+
params: params,
|
|
164
|
+
});
|
|
165
|
+
throw new Error(error.message);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.SqliteSessionDriver = SqliteSessionDriver;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BackupSessionsActionOptionsType } from "../Action/BackupSessionsAction";
|
|
2
|
+
import { BackupSessionEntity } from "../Entity/BackupSessionEntity";
|
|
3
|
+
import { BackupSessionRepositoryEntity } from "../Entity/BackupSessionRepositoryEntity";
|
|
4
|
+
import { BackupSessionTaskEntity } from "../Entity/BackupSessionTaskEntity";
|
|
5
|
+
import { WriteDataType, SessionDriverAbstract } from "../SessionDriver/SessionDriverAbstract";
|
|
6
|
+
import { ObjectVault } from "../util/ObjectVault";
|
|
7
|
+
export declare type OptionsType = {
|
|
8
|
+
driver: SessionDriverAbstract;
|
|
9
|
+
altDrivers?: SessionDriverAbstract[];
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class BackupSessionManager {
|
|
13
|
+
readonly options: OptionsType;
|
|
14
|
+
sessionVault: ObjectVault<BackupSessionEntity>;
|
|
15
|
+
taskVault: ObjectVault<BackupSessionTaskEntity>;
|
|
16
|
+
repositoryVault: ObjectVault<BackupSessionRepositoryEntity>;
|
|
17
|
+
constructor(options: OptionsType);
|
|
18
|
+
findId(data: {
|
|
19
|
+
packageName: string;
|
|
20
|
+
}): number;
|
|
21
|
+
findTaskId(data: {
|
|
22
|
+
packageName: string;
|
|
23
|
+
taskName: string;
|
|
24
|
+
}): number;
|
|
25
|
+
findRepositoryId(data: {
|
|
26
|
+
packageName: string;
|
|
27
|
+
repositoryName: string;
|
|
28
|
+
}): number;
|
|
29
|
+
initDrivers(): Promise<void>;
|
|
30
|
+
endDrivers(): Promise<void>;
|
|
31
|
+
protected alter(data: WriteDataType): Promise<number>;
|
|
32
|
+
readAll(options: BackupSessionsActionOptionsType): Promise<import("../SessionDriver/SessionDriverAbstract").ReadResultType[]>;
|
|
33
|
+
init(input: Pick<BackupSessionEntity, "packageName" | "snapshotId" | "tags">): Promise<number>;
|
|
34
|
+
initTask(input: Pick<BackupSessionTaskEntity, "sessionId" | "taskName">): Promise<number>;
|
|
35
|
+
initRepository(input: Pick<BackupSessionRepositoryEntity, "repositoryName" | "sessionId" | "repositoryType">): Promise<number>;
|
|
36
|
+
start(input: Pick<BackupSessionEntity, "id">): Promise<number>;
|
|
37
|
+
end(input: Pick<BackupSessionEntity, "id" | "error">): Promise<number>;
|
|
38
|
+
startTask(input: Pick<BackupSessionTaskEntity, "id">): Promise<number>;
|
|
39
|
+
progressTask(input: Pick<BackupSessionTaskEntity, "id" | "progressTotal" | "progressCurrent" | "progressPercent" | "progressStep" | "progressStepPercent">): Promise<number>;
|
|
40
|
+
endTask(input: Pick<BackupSessionTaskEntity, "id" | "error">): Promise<number>;
|
|
41
|
+
startRepository(input: Pick<BackupSessionRepositoryEntity, "id">): Promise<number>;
|
|
42
|
+
progressRepository(input: Pick<BackupSessionTaskEntity, "id" | "progressTotal" | "progressCurrent" | "progressPercent" | "progressStep" | "progressStepPercent">): Promise<number>;
|
|
43
|
+
endRepository(input: Pick<BackupSessionRepositoryEntity, "id" | "error">): Promise<number>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackupSessionManager = void 0;
|
|
4
|
+
const SessionDriverAbstract_1 = require("../SessionDriver/SessionDriverAbstract");
|
|
5
|
+
const ObjectVault_1 = require("../util/ObjectVault");
|
|
6
|
+
class BackupSessionManager {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.sessionVault = new ObjectVault_1.ObjectVault();
|
|
10
|
+
this.taskVault = new ObjectVault_1.ObjectVault();
|
|
11
|
+
this.repositoryVault = new ObjectVault_1.ObjectVault();
|
|
12
|
+
}
|
|
13
|
+
findId(data) {
|
|
14
|
+
return this.sessionVault.getId([data.packageName]);
|
|
15
|
+
}
|
|
16
|
+
findTaskId(data) {
|
|
17
|
+
const sessionId = this.findId(data);
|
|
18
|
+
return this.taskVault.getId([sessionId, data.taskName]);
|
|
19
|
+
}
|
|
20
|
+
findRepositoryId(data) {
|
|
21
|
+
const sessionId = this.findId(data);
|
|
22
|
+
return this.repositoryVault.getId([sessionId, data.repositoryName]);
|
|
23
|
+
}
|
|
24
|
+
async initDrivers() {
|
|
25
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
26
|
+
for (const driver of drivers) {
|
|
27
|
+
await driver.onInit();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async endDrivers() {
|
|
31
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
32
|
+
for (const driver of drivers) {
|
|
33
|
+
await driver.onEnd();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async alter(data) {
|
|
37
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
38
|
+
for (const driver of drivers) {
|
|
39
|
+
await driver.onWrite(data);
|
|
40
|
+
}
|
|
41
|
+
return data.data.id;
|
|
42
|
+
}
|
|
43
|
+
async readAll(options) {
|
|
44
|
+
return this.options.driver?.onRead(options, SessionDriverAbstract_1.EntityEnum.BackupSession);
|
|
45
|
+
}
|
|
46
|
+
async init(input) {
|
|
47
|
+
return await this.alter({
|
|
48
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
49
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
50
|
+
data: this.sessionVault.add({
|
|
51
|
+
keys: [input.packageName],
|
|
52
|
+
handler: (id) => ({
|
|
53
|
+
...input,
|
|
54
|
+
id: id,
|
|
55
|
+
creationDate: new Date().toISOString(),
|
|
56
|
+
state: null,
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async initTask(input) {
|
|
62
|
+
return await this.alter({
|
|
63
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
64
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionTask,
|
|
65
|
+
sessionData: this.sessionVault.get(input.sessionId),
|
|
66
|
+
data: this.taskVault.add({
|
|
67
|
+
keys: [input.sessionId, input.taskName],
|
|
68
|
+
handler: (id) => ({
|
|
69
|
+
...input,
|
|
70
|
+
id: id,
|
|
71
|
+
creationDate: new Date().toISOString(),
|
|
72
|
+
state: null,
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async initRepository(input) {
|
|
78
|
+
return await this.alter({
|
|
79
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
80
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionRepository,
|
|
81
|
+
sessionData: this.sessionVault.get(input.sessionId),
|
|
82
|
+
data: this.repositoryVault.add({
|
|
83
|
+
keys: [input.sessionId, input.repositoryName],
|
|
84
|
+
handler: (id) => ({
|
|
85
|
+
...input,
|
|
86
|
+
id: id,
|
|
87
|
+
creationDate: new Date().toISOString(),
|
|
88
|
+
state: null,
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async start(input) {
|
|
94
|
+
return await this.alter({
|
|
95
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
96
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
97
|
+
data: {
|
|
98
|
+
...this.sessionVault.get(input.id),
|
|
99
|
+
...input,
|
|
100
|
+
startDate: new Date().toISOString(),
|
|
101
|
+
updatingDate: new Date().toISOString(),
|
|
102
|
+
state: "started",
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async end(input) {
|
|
107
|
+
return await this.alter({
|
|
108
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
109
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSession,
|
|
110
|
+
data: {
|
|
111
|
+
...this.sessionVault.get(input.id),
|
|
112
|
+
...input,
|
|
113
|
+
endDate: new Date().toISOString(),
|
|
114
|
+
updatingDate: new Date().toISOString(),
|
|
115
|
+
state: "ended",
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async startTask(input) {
|
|
120
|
+
const object = this.taskVault.get(input.id);
|
|
121
|
+
return await this.alter({
|
|
122
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
123
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionTask,
|
|
124
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
125
|
+
data: {
|
|
126
|
+
...object,
|
|
127
|
+
...input,
|
|
128
|
+
state: "started",
|
|
129
|
+
startDate: new Date().toISOString(),
|
|
130
|
+
updatingDate: new Date().toISOString(),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async progressTask(input) {
|
|
135
|
+
const object = this.taskVault.get(input.id);
|
|
136
|
+
return await this.alter({
|
|
137
|
+
action: SessionDriverAbstract_1.ActionEnum.Progress,
|
|
138
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionTask,
|
|
139
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
140
|
+
data: {
|
|
141
|
+
...object,
|
|
142
|
+
...input,
|
|
143
|
+
updatingDate: new Date().toISOString(),
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async endTask(input) {
|
|
148
|
+
const object = this.taskVault.get(input.id);
|
|
149
|
+
return await this.alter({
|
|
150
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
151
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionTask,
|
|
152
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
153
|
+
data: {
|
|
154
|
+
...object,
|
|
155
|
+
...input,
|
|
156
|
+
endDate: new Date().toISOString(),
|
|
157
|
+
updatingDate: new Date().toISOString(),
|
|
158
|
+
state: "ended",
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async startRepository(input) {
|
|
163
|
+
const object = this.repositoryVault.get(input.id);
|
|
164
|
+
return await this.alter({
|
|
165
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
166
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionRepository,
|
|
167
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
168
|
+
data: {
|
|
169
|
+
...object,
|
|
170
|
+
...input,
|
|
171
|
+
startDate: new Date().toISOString(),
|
|
172
|
+
updatingDate: new Date().toISOString(),
|
|
173
|
+
state: "started",
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async progressRepository(input) {
|
|
178
|
+
const object = this.repositoryVault.get(input.id);
|
|
179
|
+
return await this.alter({
|
|
180
|
+
action: SessionDriverAbstract_1.ActionEnum.Progress,
|
|
181
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionRepository,
|
|
182
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
183
|
+
data: {
|
|
184
|
+
...object,
|
|
185
|
+
...input,
|
|
186
|
+
updatingDate: new Date().toISOString(),
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async endRepository(input) {
|
|
191
|
+
const object = this.repositoryVault.get(input.id);
|
|
192
|
+
return await this.alter({
|
|
193
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
194
|
+
entity: SessionDriverAbstract_1.EntityEnum.BackupSessionRepository,
|
|
195
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
196
|
+
data: {
|
|
197
|
+
...object,
|
|
198
|
+
...input,
|
|
199
|
+
endDate: new Date().toISOString(),
|
|
200
|
+
updatingDate: new Date().toISOString(),
|
|
201
|
+
state: "ended",
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.BackupSessionManager = BackupSessionManager;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BackupSessionsActionOptionsType } from "../Action/BackupSessionsAction";
|
|
2
|
+
import { RestoreSessionEntity } from "../Entity/RestoreSessionEntity";
|
|
3
|
+
import { RestoreSessionRepositoryEntity } from "../Entity/RestoreSessionRepositoryEntity";
|
|
4
|
+
import { RestoreSessionTaskEntity } from "../Entity/RestoreSessionTaskEntity";
|
|
5
|
+
import { WriteDataType, SessionDriverAbstract } from "../SessionDriver/SessionDriverAbstract";
|
|
6
|
+
import { ObjectVault } from "../util/ObjectVault";
|
|
7
|
+
export declare type OptionsType = {
|
|
8
|
+
driver: SessionDriverAbstract;
|
|
9
|
+
altDrivers?: SessionDriverAbstract[];
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class RestoreSessionManager {
|
|
13
|
+
readonly options: OptionsType;
|
|
14
|
+
sessionVault: ObjectVault<RestoreSessionEntity>;
|
|
15
|
+
repositoryVault: ObjectVault<RestoreSessionRepositoryEntity>;
|
|
16
|
+
taskVault: ObjectVault<RestoreSessionTaskEntity>;
|
|
17
|
+
constructor(options: OptionsType);
|
|
18
|
+
findId(data: {
|
|
19
|
+
packageName: string;
|
|
20
|
+
}): number;
|
|
21
|
+
findTaskId(data: {
|
|
22
|
+
packageName: string;
|
|
23
|
+
taskName: string;
|
|
24
|
+
}): number;
|
|
25
|
+
findRepositoryId(data: {
|
|
26
|
+
packageName: string;
|
|
27
|
+
repositoryName: string;
|
|
28
|
+
}): number;
|
|
29
|
+
initDrivers(): Promise<void>;
|
|
30
|
+
endDrivers(): Promise<void>;
|
|
31
|
+
protected alter(data: WriteDataType): Promise<number>;
|
|
32
|
+
readAll(options: BackupSessionsActionOptionsType): Promise<import("../SessionDriver/SessionDriverAbstract").ReadResultType[]>;
|
|
33
|
+
init(input: Pick<RestoreSessionEntity, "packageName" | "snapshotId">): Promise<number>;
|
|
34
|
+
initTask(input: Pick<RestoreSessionTaskEntity, "sessionId" | "taskName">): Promise<number>;
|
|
35
|
+
initRepository(input: Pick<RestoreSessionRepositoryEntity, "sessionId" | "repositoryName" | "repositoryType">): Promise<number>;
|
|
36
|
+
start(input: Pick<RestoreSessionEntity, "id">): Promise<number>;
|
|
37
|
+
end(input: Pick<RestoreSessionEntity, "id" | "error">): Promise<number>;
|
|
38
|
+
startTask(input: Pick<RestoreSessionTaskEntity, "id">): Promise<number>;
|
|
39
|
+
startRepository(input: Pick<RestoreSessionRepositoryEntity, "id">): Promise<number>;
|
|
40
|
+
progressTask(input: Pick<RestoreSessionTaskEntity, "id" | "progressTotal" | "progressCurrent" | "progressPercent" | "progressStep" | "progressStepPercent">): Promise<number>;
|
|
41
|
+
endTask(input: Pick<RestoreSessionTaskEntity, "id" | "error">): Promise<number>;
|
|
42
|
+
progressRepository(input: Pick<RestoreSessionRepositoryEntity, "id" | "progressTotal" | "progressCurrent" | "progressPercent" | "progressStep" | "progressStepPercent">): Promise<number>;
|
|
43
|
+
endRepository(input: Pick<RestoreSessionRepositoryEntity, "id" | "error">): Promise<number>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestoreSessionManager = void 0;
|
|
4
|
+
const SessionDriverAbstract_1 = require("../SessionDriver/SessionDriverAbstract");
|
|
5
|
+
const ObjectVault_1 = require("../util/ObjectVault");
|
|
6
|
+
class RestoreSessionManager {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.sessionVault = new ObjectVault_1.ObjectVault();
|
|
10
|
+
this.repositoryVault = new ObjectVault_1.ObjectVault();
|
|
11
|
+
this.taskVault = new ObjectVault_1.ObjectVault();
|
|
12
|
+
}
|
|
13
|
+
findId(data) {
|
|
14
|
+
return this.sessionVault.getId([data.packageName]);
|
|
15
|
+
}
|
|
16
|
+
findTaskId(data) {
|
|
17
|
+
const sessionId = this.findId(data);
|
|
18
|
+
return this.taskVault.getId([sessionId, data.taskName]);
|
|
19
|
+
}
|
|
20
|
+
findRepositoryId(data) {
|
|
21
|
+
const sessionId = this.findId(data);
|
|
22
|
+
return this.repositoryVault.getId([sessionId, data.repositoryName]);
|
|
23
|
+
}
|
|
24
|
+
async initDrivers() {
|
|
25
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
26
|
+
for (const driver of drivers) {
|
|
27
|
+
await driver.onInit();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async endDrivers() {
|
|
31
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
32
|
+
for (const driver of drivers) {
|
|
33
|
+
await driver.onEnd();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async alter(data) {
|
|
37
|
+
const drivers = [this.options.driver, ...(this.options.altDrivers ?? [])];
|
|
38
|
+
for (const driver of drivers) {
|
|
39
|
+
await driver.onWrite(data);
|
|
40
|
+
}
|
|
41
|
+
return data.data.id;
|
|
42
|
+
}
|
|
43
|
+
async readAll(options) {
|
|
44
|
+
return this.options.driver.onRead(options, SessionDriverAbstract_1.EntityEnum.RestoreSession);
|
|
45
|
+
}
|
|
46
|
+
async init(input) {
|
|
47
|
+
return await this.alter({
|
|
48
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
49
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
50
|
+
data: this.sessionVault.add({
|
|
51
|
+
keys: [input.packageName],
|
|
52
|
+
handler: (id) => ({
|
|
53
|
+
...input,
|
|
54
|
+
id: id,
|
|
55
|
+
creationDate: new Date().toISOString(),
|
|
56
|
+
state: null,
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async initTask(input) {
|
|
62
|
+
return await this.alter({
|
|
63
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
64
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionTask,
|
|
65
|
+
sessionData: this.sessionVault.get(input.sessionId),
|
|
66
|
+
data: this.taskVault.add({
|
|
67
|
+
keys: [input.sessionId, input.taskName],
|
|
68
|
+
handler: (id) => ({
|
|
69
|
+
...input,
|
|
70
|
+
id: id,
|
|
71
|
+
taskName: input.taskName,
|
|
72
|
+
creationDate: new Date().toISOString(),
|
|
73
|
+
state: null,
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async initRepository(input) {
|
|
79
|
+
return await this.alter({
|
|
80
|
+
action: SessionDriverAbstract_1.ActionEnum.Init,
|
|
81
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository,
|
|
82
|
+
sessionData: this.sessionVault.get(input.sessionId),
|
|
83
|
+
data: this.repositoryVault.add({
|
|
84
|
+
keys: [input.sessionId, input.repositoryName],
|
|
85
|
+
handler: (id) => ({
|
|
86
|
+
...input,
|
|
87
|
+
id: id,
|
|
88
|
+
creationDate: new Date().toISOString(),
|
|
89
|
+
state: null,
|
|
90
|
+
}),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async start(input) {
|
|
95
|
+
return await this.alter({
|
|
96
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
97
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
98
|
+
data: {
|
|
99
|
+
...this.sessionVault.get(input.id),
|
|
100
|
+
...input,
|
|
101
|
+
startDate: new Date().toISOString(),
|
|
102
|
+
state: "started",
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async end(input) {
|
|
107
|
+
return await this.alter({
|
|
108
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
109
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSession,
|
|
110
|
+
data: {
|
|
111
|
+
...this.sessionVault.get(input.id),
|
|
112
|
+
...input,
|
|
113
|
+
endDate: new Date().toISOString(),
|
|
114
|
+
updatingDate: new Date().toISOString(),
|
|
115
|
+
state: "ended",
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async startTask(input) {
|
|
120
|
+
const object = this.taskVault.get(input.id);
|
|
121
|
+
return await this.alter({
|
|
122
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
123
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionTask,
|
|
124
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
125
|
+
data: {
|
|
126
|
+
...object,
|
|
127
|
+
...input,
|
|
128
|
+
state: "started",
|
|
129
|
+
startDate: new Date().toISOString(),
|
|
130
|
+
updatingDate: new Date().toISOString(),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async startRepository(input) {
|
|
135
|
+
const object = this.repositoryVault.get(input.id);
|
|
136
|
+
return await this.alter({
|
|
137
|
+
action: SessionDriverAbstract_1.ActionEnum.Start,
|
|
138
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository,
|
|
139
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
140
|
+
data: {
|
|
141
|
+
...object,
|
|
142
|
+
...input,
|
|
143
|
+
state: "started",
|
|
144
|
+
startDate: new Date().toISOString(),
|
|
145
|
+
updatingDate: new Date().toISOString(),
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async progressTask(input) {
|
|
150
|
+
const object = this.taskVault.get(input.id);
|
|
151
|
+
return await this.alter({
|
|
152
|
+
action: SessionDriverAbstract_1.ActionEnum.Progress,
|
|
153
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionTask,
|
|
154
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
155
|
+
data: {
|
|
156
|
+
...object,
|
|
157
|
+
...input,
|
|
158
|
+
updatingDate: new Date().toISOString(),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async endTask(input) {
|
|
163
|
+
const object = this.taskVault.get(input.id);
|
|
164
|
+
return await this.alter({
|
|
165
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
166
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionTask,
|
|
167
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
168
|
+
data: {
|
|
169
|
+
...object,
|
|
170
|
+
...input,
|
|
171
|
+
endDate: new Date().toISOString(),
|
|
172
|
+
updatingDate: new Date().toISOString(),
|
|
173
|
+
state: "ended",
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async progressRepository(input) {
|
|
178
|
+
const object = this.repositoryVault.get(input.id);
|
|
179
|
+
return await this.alter({
|
|
180
|
+
action: SessionDriverAbstract_1.ActionEnum.Progress,
|
|
181
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository,
|
|
182
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
183
|
+
data: {
|
|
184
|
+
...object,
|
|
185
|
+
...input,
|
|
186
|
+
updatingDate: new Date().toISOString(),
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async endRepository(input) {
|
|
191
|
+
const object = this.repositoryVault.get(input.id);
|
|
192
|
+
return await this.alter({
|
|
193
|
+
action: SessionDriverAbstract_1.ActionEnum.End,
|
|
194
|
+
entity: SessionDriverAbstract_1.EntityEnum.RestoreSessionRepository,
|
|
195
|
+
sessionData: this.sessionVault.get(object.sessionId),
|
|
196
|
+
data: {
|
|
197
|
+
...object,
|
|
198
|
+
...input,
|
|
199
|
+
endDate: new Date().toISOString(),
|
|
200
|
+
updatingDate: new Date().toISOString(),
|
|
201
|
+
state: "ended",
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.RestoreSessionManager = RestoreSessionManager;
|