@futo-org/backups-orchestrator-api 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +41 -0
- package/dist/backends/backend.d.ts +23 -0
- package/dist/backends/backend.js +31 -0
- package/dist/backends/backend.js.map +1 -0
- package/dist/backends/local.backend.d.ts +24 -0
- package/dist/backends/local.backend.js +92 -0
- package/dist/backends/local.backend.js.map +1 -0
- package/dist/backends/s3.backend.d.ts +24 -0
- package/dist/backends/s3.backend.js +47 -0
- package/dist/backends/s3.backend.js.map +1 -0
- package/dist/backends/yucca.backend.d.ts +27 -0
- package/dist/backends/yucca.backend.js +63 -0
- package/dist/backends/yucca.backend.js.map +1 -0
- package/dist/const.d.ts +2 -0
- package/dist/const.js +6 -0
- package/dist/const.js.map +1 -0
- package/dist/controllers/auth.controller.d.ts +7 -0
- package/dist/controllers/auth.controller.js +38 -0
- package/dist/controllers/auth.controller.js.map +1 -0
- package/dist/controllers/backend.controller.d.ts +8 -0
- package/dist/controllers/backend.controller.js +52 -0
- package/dist/controllers/backend.controller.js.map +1 -0
- package/dist/controllers/development.controller.d.ts +6 -0
- package/dist/controllers/development.controller.js +35 -0
- package/dist/controllers/development.controller.js.map +1 -0
- package/dist/controllers/filesystem.controller.d.ts +7 -0
- package/dist/controllers/filesystem.controller.js +43 -0
- package/dist/controllers/filesystem.controller.js.map +1 -0
- package/dist/controllers/integrations.controller.d.ts +8 -0
- package/dist/controllers/integrations.controller.js +51 -0
- package/dist/controllers/integrations.controller.js.map +1 -0
- package/dist/controllers/onboarding.controller.d.ts +11 -0
- package/dist/controllers/onboarding.controller.js +80 -0
- package/dist/controllers/onboarding.controller.js.map +1 -0
- package/dist/controllers/repository.controller.d.ts +22 -0
- package/dist/controllers/repository.controller.js +227 -0
- package/dist/controllers/repository.controller.js.map +1 -0
- package/dist/controllers/runHistory.controller.d.ts +9 -0
- package/dist/controllers/runHistory.controller.js +55 -0
- package/dist/controllers/runHistory.controller.js.map +1 -0
- package/dist/controllers/runningTasks.controller.d.ts +8 -0
- package/dist/controllers/runningTasks.controller.js +52 -0
- package/dist/controllers/runningTasks.controller.js.map +1 -0
- package/dist/controllers/schedule.controller.d.ts +10 -0
- package/dist/controllers/schedule.controller.js +76 -0
- package/dist/controllers/schedule.controller.js.map +1 -0
- package/dist/dto/auth.dto.d.ts +4 -0
- package/dist/dto/auth.dto.js +27 -0
- package/dist/dto/auth.dto.js.map +1 -0
- package/dist/dto/backend.dto.d.ts +16 -0
- package/dist/dto/backend.dto.js +64 -0
- package/dist/dto/backend.dto.js.map +1 -0
- package/dist/dto/filesystem.dto.d.ts +12 -0
- package/dist/dto/filesystem.dto.js +56 -0
- package/dist/dto/filesystem.dto.js.map +1 -0
- package/dist/dto/integrations.dto.d.ts +35 -0
- package/dist/dto/integrations.dto.js +163 -0
- package/dist/dto/integrations.dto.js.map +1 -0
- package/dist/dto/onboarding.dto.d.ts +13 -0
- package/dist/dto/onboarding.dto.js +60 -0
- package/dist/dto/onboarding.dto.js.map +1 -0
- package/dist/dto/repository.dto.d.ts +113 -0
- package/dist/dto/repository.dto.js +421 -0
- package/dist/dto/repository.dto.js.map +1 -0
- package/dist/dto/runningTasks.dto.d.ts +14 -0
- package/dist/dto/runningTasks.dto.js +59 -0
- package/dist/dto/runningTasks.dto.js.map +1 -0
- package/dist/dto/schedule.dto.d.ts +29 -0
- package/dist/dto/schedule.dto.js +149 -0
- package/dist/dto/schedule.dto.js.map +1 -0
- package/dist/enum.d.ts +32 -0
- package/dist/enum.js +42 -0
- package/dist/enum.js.map +1 -0
- package/dist/events/events.gateway.d.ts +73 -0
- package/dist/events/events.gateway.js +79 -0
- package/dist/events/events.gateway.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/moduleConfig.d.ts +20 -0
- package/dist/moduleConfig.js +5 -0
- package/dist/moduleConfig.js.map +1 -0
- package/dist/orchestrationApi.module.d.ts +5 -0
- package/dist/orchestrationApi.module.js +134 -0
- package/dist/orchestrationApi.module.js.map +1 -0
- package/dist/repositories/backend.repository.d.ts +19 -0
- package/dist/repositories/backend.repository.js +60 -0
- package/dist/repositories/backend.repository.js.map +1 -0
- package/dist/repositories/config.repository.d.ts +18 -0
- package/dist/repositories/config.repository.js +93 -0
- package/dist/repositories/config.repository.js.map +1 -0
- package/dist/repositories/database.repository.d.ts +11 -0
- package/dist/repositories/database.repository.js +85 -0
- package/dist/repositories/database.repository.js.map +1 -0
- package/dist/repositories/moduleConfig.repository.d.ts +12 -0
- package/dist/repositories/moduleConfig.repository.js +48 -0
- package/dist/repositories/moduleConfig.repository.js.map +1 -0
- package/dist/repositories/repository.repository.d.ts +18 -0
- package/dist/repositories/repository.repository.js +81 -0
- package/dist/repositories/repository.repository.js.map +1 -0
- package/dist/repositories/repositoryIntegrationImmich.repository.d.ts +14 -0
- package/dist/repositories/repositoryIntegrationImmich.repository.js +57 -0
- package/dist/repositories/repositoryIntegrationImmich.repository.js.map +1 -0
- package/dist/repositories/repositoryLocalMetrics.repository.d.ts +23 -0
- package/dist/repositories/repositoryLocalMetrics.repository.js +55 -0
- package/dist/repositories/repositoryLocalMetrics.repository.js.map +1 -0
- package/dist/repositories/repositoryPath.repository.d.ts +17 -0
- package/dist/repositories/repositoryPath.repository.js +48 -0
- package/dist/repositories/repositoryPath.repository.js.map +1 -0
- package/dist/repositories/restic.repository.d.ts +207 -0
- package/dist/repositories/restic.repository.js +96 -0
- package/dist/repositories/restic.repository.js.map +1 -0
- package/dist/repositories/runHistory.repository.d.ts +44 -0
- package/dist/repositories/runHistory.repository.js +191 -0
- package/dist/repositories/runHistory.repository.js.map +1 -0
- package/dist/repositories/runningTasks.repository.d.ts +14 -0
- package/dist/repositories/runningTasks.repository.js +77 -0
- package/dist/repositories/runningTasks.repository.js.map +1 -0
- package/dist/repositories/schedule.repository.d.ts +47 -0
- package/dist/repositories/schedule.repository.js +99 -0
- package/dist/repositories/schedule.repository.js.map +1 -0
- package/dist/repositories/storage.repository.d.ts +9 -0
- package/dist/repositories/storage.repository.js +39 -0
- package/dist/repositories/storage.repository.js.map +1 -0
- package/dist/schema/index.d.ts +20 -0
- package/dist/schema/index.js +3 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/migrations/20260218105210-InitialMigration.d.ts +3 -0
- package/dist/schema/migrations/20260218105210-InitialMigration.js +15 -0
- package/dist/schema/migrations/20260218105210-InitialMigration.js.map +1 -0
- package/dist/schema/migrations/20260218122600-AddRepositories.d.ts +3 -0
- package/dist/schema/migrations/20260218122600-AddRepositories.js +21 -0
- package/dist/schema/migrations/20260218122600-AddRepositories.js.map +1 -0
- package/dist/schema/migrations/20260224112323-RepositoryPathTable.d.ts +3 -0
- package/dist/schema/migrations/20260224112323-RepositoryPathTable.js +16 -0
- package/dist/schema/migrations/20260224112323-RepositoryPathTable.js.map +1 -0
- package/dist/schema/migrations/20260224123344-RunHistoryTable.d.ts +3 -0
- package/dist/schema/migrations/20260224123344-RunHistoryTable.js +20 -0
- package/dist/schema/migrations/20260224123344-RunHistoryTable.js.map +1 -0
- package/dist/schema/migrations/20260224125102-RepositoryMetricsTable.d.ts +3 -0
- package/dist/schema/migrations/20260224125102-RepositoryMetricsTable.js +16 -0
- package/dist/schema/migrations/20260224125102-RepositoryMetricsTable.js.map +1 -0
- package/dist/schema/migrations/20260304162353-ScheduleTable.d.ts +3 -0
- package/dist/schema/migrations/20260304162353-ScheduleTable.js +27 -0
- package/dist/schema/migrations/20260304162353-ScheduleTable.js.map +1 -0
- package/dist/schema/migrations/20260313222211-AddMetricsColumns.d.ts +3 -0
- package/dist/schema/migrations/20260313222211-AddMetricsColumns.js +13 -0
- package/dist/schema/migrations/20260313222211-AddMetricsColumns.js.map +1 -0
- package/dist/schema/migrations/20260330120000-RepositoryIntegrationImmichTable.d.ts +3 -0
- package/dist/schema/migrations/20260330120000-RepositoryIntegrationImmichTable.js +15 -0
- package/dist/schema/migrations/20260330120000-RepositoryIntegrationImmichTable.js.map +1 -0
- package/dist/schema/migrations/20260330130000-AddScheduleIdToImmichIntegration.d.ts +3 -0
- package/dist/schema/migrations/20260330130000-AddScheduleIdToImmichIntegration.js +14 -0
- package/dist/schema/migrations/20260330130000-AddScheduleIdToImmichIntegration.js.map +1 -0
- package/dist/schema/migrations/20260507120000-AddRunHistoryType.d.ts +3 -0
- package/dist/schema/migrations/20260507120000-AddRunHistoryType.js +18 -0
- package/dist/schema/migrations/20260507120000-AddRunHistoryType.js.map +1 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPolicy.d.ts +3 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPolicy.js +11 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPolicy.js.map +1 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPreset.d.ts +3 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPreset.js +18 -0
- package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPreset.js.map +1 -0
- package/dist/schema/migrations/20260512130000-AllowForgetRunHistoryType.d.ts +3 -0
- package/dist/schema/migrations/20260512130000-AllowForgetRunHistoryType.js +47 -0
- package/dist/schema/migrations/20260512130000-AllowForgetRunHistoryType.js.map +1 -0
- package/dist/schema/tables/backend.table.d.ts +20 -0
- package/dist/schema/tables/backend.table.js +9 -0
- package/dist/schema/tables/backend.table.js.map +1 -0
- package/dist/schema/tables/config.table.d.ts +4 -0
- package/dist/schema/tables/config.table.js +9 -0
- package/dist/schema/tables/config.table.js.map +1 -0
- package/dist/schema/tables/repository.table.d.ts +5 -0
- package/dist/schema/tables/repository.table.js +10 -0
- package/dist/schema/tables/repository.table.js.map +1 -0
- package/dist/schema/tables/repositoryIntegrationImmich.table.d.ts +10 -0
- package/dist/schema/tables/repositoryIntegrationImmich.table.js +10 -0
- package/dist/schema/tables/repositoryIntegrationImmich.table.js.map +1 -0
- package/dist/schema/tables/repositoryLocalMetrics.table.d.ts +7 -0
- package/dist/schema/tables/repositoryLocalMetrics.table.js +12 -0
- package/dist/schema/tables/repositoryLocalMetrics.table.js.map +1 -0
- package/dist/schema/tables/repositoryPath.table.d.ts +4 -0
- package/dist/schema/tables/repositoryPath.table.js +9 -0
- package/dist/schema/tables/repositoryPath.table.js.map +1 -0
- package/dist/schema/tables/repositorySchedule.table.d.ts +4 -0
- package/dist/schema/tables/repositorySchedule.table.js +9 -0
- package/dist/schema/tables/repositorySchedule.table.js.map +1 -0
- package/dist/schema/tables/runHistory.table.d.ts +11 -0
- package/dist/schema/tables/runHistory.table.js +14 -0
- package/dist/schema/tables/runHistory.table.js.map +1 -0
- package/dist/schema/tables/schedule.table.d.ts +9 -0
- package/dist/schema/tables/schedule.table.js +14 -0
- package/dist/schema/tables/schedule.table.js.map +1 -0
- package/dist/services/auth.service.d.ts +16 -0
- package/dist/services/auth.service.js +85 -0
- package/dist/services/auth.service.js.map +1 -0
- package/dist/services/backend.service.d.ts +12 -0
- package/dist/services/backend.service.js +68 -0
- package/dist/services/backend.service.js.map +1 -0
- package/dist/services/bootstrap.service.d.ts +13 -0
- package/dist/services/bootstrap.service.js +44 -0
- package/dist/services/bootstrap.service.js.map +1 -0
- package/dist/services/database.service.d.ts +11 -0
- package/dist/services/database.service.js +39 -0
- package/dist/services/database.service.js.map +1 -0
- package/dist/services/development.service.d.ts +11 -0
- package/dist/services/development.service.js +59 -0
- package/dist/services/development.service.js.map +1 -0
- package/dist/services/filesystem.service.d.ts +7 -0
- package/dist/services/filesystem.service.js +43 -0
- package/dist/services/filesystem.service.js.map +1 -0
- package/dist/services/integrations.service.d.ts +22 -0
- package/dist/services/integrations.service.js +158 -0
- package/dist/services/integrations.service.js.map +1 -0
- package/dist/services/onboarding.service.d.ts +17 -0
- package/dist/services/onboarding.service.js +65 -0
- package/dist/services/onboarding.service.js.map +1 -0
- package/dist/services/repository.service.d.ts +65 -0
- package/dist/services/repository.service.js +623 -0
- package/dist/services/repository.service.js.map +1 -0
- package/dist/services/runHistory.service.d.ts +7 -0
- package/dist/services/runHistory.service.js +29 -0
- package/dist/services/runHistory.service.js.map +1 -0
- package/dist/services/runningTasks.service.d.ts +8 -0
- package/dist/services/runningTasks.service.js +34 -0
- package/dist/services/runningTasks.service.js.map +1 -0
- package/dist/services/schedule.service.d.ts +27 -0
- package/dist/services/schedule.service.js +197 -0
- package/dist/services/schedule.service.js.map +1 -0
- package/dist/utils/restic.d.ts +17 -0
- package/dist/utils/restic.js +26 -0
- package/dist/utils/restic.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BackendRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
let BackendRepository = class BackendRepository {
|
|
20
|
+
db;
|
|
21
|
+
constructor(db) {
|
|
22
|
+
this.db = db;
|
|
23
|
+
}
|
|
24
|
+
async updateBackend(id, configuration) {
|
|
25
|
+
return await this.db
|
|
26
|
+
.insertInto('backends')
|
|
27
|
+
.values({
|
|
28
|
+
id,
|
|
29
|
+
configuration: JSON.stringify(configuration),
|
|
30
|
+
})
|
|
31
|
+
.onConflict((oc) => oc.doUpdateSet({ configuration: JSON.stringify(configuration) }))
|
|
32
|
+
.returningAll()
|
|
33
|
+
.executeTakeFirstOrThrow();
|
|
34
|
+
}
|
|
35
|
+
async getBackends() {
|
|
36
|
+
const backends = await this.db.selectFrom('backends').selectAll('backends').execute();
|
|
37
|
+
return backends.map(({ id, configuration }) => ({
|
|
38
|
+
id,
|
|
39
|
+
configuration: JSON.parse(configuration),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
async getBackend(id) {
|
|
43
|
+
const backend = await this.db
|
|
44
|
+
.selectFrom('backends')
|
|
45
|
+
.selectAll('backends')
|
|
46
|
+
.where('id', '=', id)
|
|
47
|
+
.executeTakeFirstOrThrow();
|
|
48
|
+
return {
|
|
49
|
+
id: backend.id,
|
|
50
|
+
configuration: JSON.parse(backend.configuration),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.BackendRepository = BackendRepository;
|
|
55
|
+
exports.BackendRepository = BackendRepository = __decorate([
|
|
56
|
+
(0, common_1.Injectable)(),
|
|
57
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
58
|
+
__metadata("design:paramtypes", [kysely_1.Kysely])
|
|
59
|
+
], BackendRepository);
|
|
60
|
+
//# sourceMappingURL=backend.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.repository.js","sourceRoot":"","sources":["../../src/repositories/backend.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAgC;AAChC,iDAA6C;AAKtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACsB;I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B;IAD7B,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAA;qCAAa,eAAM;GADjD,iBAAiB,CAmC7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
2
|
+
import { DB } from '../schema';
|
|
3
|
+
export declare class ConfigRepository {
|
|
4
|
+
private db;
|
|
5
|
+
constructor(db: Kysely<DB>);
|
|
6
|
+
bootstrap(): Promise<void>;
|
|
7
|
+
private set;
|
|
8
|
+
private get;
|
|
9
|
+
private has;
|
|
10
|
+
hasEncryptionKey(): Promise<boolean>;
|
|
11
|
+
getMasterEncryptionKey(): Promise<string>;
|
|
12
|
+
deriveEncryptionKey(info: `repository-${string}`): Promise<Uint8Array>;
|
|
13
|
+
importEncryptionKey(key: string): Promise<void>;
|
|
14
|
+
hasOnboardedKey(): Promise<boolean>;
|
|
15
|
+
confirmKeyOnboarded(): Promise<void>;
|
|
16
|
+
hasSkippedExtraConfig(): Promise<boolean>;
|
|
17
|
+
skipExtraConfig(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ConfigRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
const node_crypto_1 = require("node:crypto");
|
|
20
|
+
const enum_1 = require("../enum");
|
|
21
|
+
let ConfigRepository = class ConfigRepository {
|
|
22
|
+
db;
|
|
23
|
+
constructor(db) {
|
|
24
|
+
this.db = db;
|
|
25
|
+
}
|
|
26
|
+
async bootstrap() {
|
|
27
|
+
const hasKey = await this.hasEncryptionKey();
|
|
28
|
+
if (!hasKey) {
|
|
29
|
+
await this.set(enum_1.ConfigurationKey.EncryptionKey, (0, node_crypto_1.randomBytes)(32).toString('hex'));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async set(key, value) {
|
|
33
|
+
await this.db
|
|
34
|
+
.insertInto('config')
|
|
35
|
+
.values({
|
|
36
|
+
key,
|
|
37
|
+
value,
|
|
38
|
+
})
|
|
39
|
+
.onConflict((oc) => oc.doUpdateSet({ value }))
|
|
40
|
+
.executeTakeFirstOrThrow();
|
|
41
|
+
}
|
|
42
|
+
async get(key) {
|
|
43
|
+
const { value } = await this.db
|
|
44
|
+
.selectFrom('config')
|
|
45
|
+
.where('config.key', '=', key)
|
|
46
|
+
.select('config.value')
|
|
47
|
+
.executeTakeFirstOrThrow();
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
async has(key) {
|
|
51
|
+
const results = await this.db.selectFrom('config').where('config.key', '=', key).selectAll().execute();
|
|
52
|
+
return results.length > 0;
|
|
53
|
+
}
|
|
54
|
+
async hasEncryptionKey() {
|
|
55
|
+
return this.has(enum_1.ConfigurationKey.EncryptionKey);
|
|
56
|
+
}
|
|
57
|
+
async getMasterEncryptionKey() {
|
|
58
|
+
return await this.get(enum_1.ConfigurationKey.EncryptionKey);
|
|
59
|
+
}
|
|
60
|
+
async deriveEncryptionKey(info) {
|
|
61
|
+
const encryptionKey = await this.get(enum_1.ConfigurationKey.EncryptionKey);
|
|
62
|
+
const masterKey = Buffer.from(encryptionKey, 'hex');
|
|
63
|
+
const key = new Uint8Array(await crypto.subtle.deriveBits({
|
|
64
|
+
name: 'HKDF',
|
|
65
|
+
hash: 'SHA-256',
|
|
66
|
+
info: Buffer.from(info),
|
|
67
|
+
salt: Buffer.from(Array.from({ length: 32 }).fill(0)),
|
|
68
|
+
}, await crypto.subtle.importKey('raw', masterKey, 'HKDF', false, ['deriveBits']), 256));
|
|
69
|
+
return key;
|
|
70
|
+
}
|
|
71
|
+
async importEncryptionKey(key) {
|
|
72
|
+
await this.set(enum_1.ConfigurationKey.EncryptionKey, key);
|
|
73
|
+
}
|
|
74
|
+
async hasOnboardedKey() {
|
|
75
|
+
return this.has(enum_1.ConfigurationKey.OnboardedKey);
|
|
76
|
+
}
|
|
77
|
+
async confirmKeyOnboarded() {
|
|
78
|
+
return this.set(enum_1.ConfigurationKey.OnboardedKey, '1');
|
|
79
|
+
}
|
|
80
|
+
async hasSkippedExtraConfig() {
|
|
81
|
+
return this.has(enum_1.ConfigurationKey.SkippedOnboardingExtraConfig);
|
|
82
|
+
}
|
|
83
|
+
async skipExtraConfig() {
|
|
84
|
+
return this.set(enum_1.ConfigurationKey.SkippedOnboardingExtraConfig, '1');
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.ConfigRepository = ConfigRepository;
|
|
88
|
+
exports.ConfigRepository = ConfigRepository = __decorate([
|
|
89
|
+
(0, common_1.Injectable)(),
|
|
90
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
91
|
+
__metadata("design:paramtypes", [kysely_1.Kysely])
|
|
92
|
+
], ConfigRepository);
|
|
93
|
+
//# sourceMappingURL=config.repository.js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uBAAgB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAgB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAgB,CAAC,4BAA4B,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAgB,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;IACtE,CAAC;CACF,CAAA;AArFY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAA;qCAAa,eAAM;GADjD,gBAAgB,CAqF5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
2
|
+
import { DB } from '../schema';
|
|
3
|
+
import { StorageRepository } from './storage.repository';
|
|
4
|
+
export declare class DatabaseRepository {
|
|
5
|
+
private db;
|
|
6
|
+
private readonly storage;
|
|
7
|
+
constructor(db: Kysely<DB>, storage: StorageRepository);
|
|
8
|
+
runMigrations(): Promise<void>;
|
|
9
|
+
restoreFrom(path: string): Promise<void>;
|
|
10
|
+
private createMigrator;
|
|
11
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DatabaseRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const storage_repository_1 = require("./storage.repository");
|
|
21
|
+
let DatabaseRepository = class DatabaseRepository {
|
|
22
|
+
db;
|
|
23
|
+
storage;
|
|
24
|
+
constructor(db, storage) {
|
|
25
|
+
this.db = db;
|
|
26
|
+
this.storage = storage;
|
|
27
|
+
}
|
|
28
|
+
async runMigrations() {
|
|
29
|
+
const migrator = this.createMigrator();
|
|
30
|
+
const { error, results } = await migrator.migrateToLatest();
|
|
31
|
+
for (const result of results ?? []) {
|
|
32
|
+
if (result.status === 'Success') {
|
|
33
|
+
console.debug(`Migration "${result.migrationName}" succeeded`);
|
|
34
|
+
}
|
|
35
|
+
if (result.status === 'Error') {
|
|
36
|
+
console.error(`Migration "${result.migrationName}" failed`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (error) {
|
|
40
|
+
console.error(`Migrations failed: ${error}`);
|
|
41
|
+
throw new Error('Migrations failed.');
|
|
42
|
+
}
|
|
43
|
+
console.info('Finished running migrations');
|
|
44
|
+
}
|
|
45
|
+
async restoreFrom(path) {
|
|
46
|
+
await (0, kysely_1.sql) `PRAGMA foreign_keys = OFF`.execute(this.db);
|
|
47
|
+
try {
|
|
48
|
+
await (0, kysely_1.sql) `ATTACH DATABASE ${path} AS restored`.execute(this.db);
|
|
49
|
+
const tables = await (0, kysely_1.sql) `
|
|
50
|
+
SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
|
|
51
|
+
`.execute(this.db);
|
|
52
|
+
for (const { name } of tables.rows) {
|
|
53
|
+
await (0, kysely_1.sql) `DELETE FROM ${kysely_1.sql.table(name)}`.execute(this.db);
|
|
54
|
+
await (0, kysely_1.sql) `INSERT INTO ${kysely_1.sql.table(name)} SELECT * FROM ${kysely_1.sql.table(`restored.${name}`)}`.execute(this.db);
|
|
55
|
+
}
|
|
56
|
+
await (0, kysely_1.sql) `DETACH DATABASE restored`.execute(this.db);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await (0, kysely_1.sql) `PRAGMA foreign_keys = ON`.execute(this.db);
|
|
60
|
+
}
|
|
61
|
+
await this.runMigrations();
|
|
62
|
+
}
|
|
63
|
+
createMigrator() {
|
|
64
|
+
return new kysely_1.Migrator({
|
|
65
|
+
db: this.db,
|
|
66
|
+
migrationLockTableName: 'kysely_migrations_lock',
|
|
67
|
+
migrationTableName: 'kysely_migrations',
|
|
68
|
+
provider: new kysely_1.FileMigrationProvider({
|
|
69
|
+
fs: {
|
|
70
|
+
readdir: this.storage.readdir,
|
|
71
|
+
},
|
|
72
|
+
path: { join: node_path_1.join },
|
|
73
|
+
migrationFolder: (0, node_path_1.join)(__dirname, '..', 'schema/migrations'),
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
exports.DatabaseRepository = DatabaseRepository;
|
|
79
|
+
exports.DatabaseRepository = DatabaseRepository = __decorate([
|
|
80
|
+
(0, common_1.Injectable)(),
|
|
81
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
82
|
+
__metadata("design:paramtypes", [kysely_1.Kysely,
|
|
83
|
+
storage_repository_1.StorageRepository])
|
|
84
|
+
], DatabaseRepository);
|
|
85
|
+
//# sourceMappingURL=database.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.repository.js","sourceRoot":"","sources":["../../src/repositories/database.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAsE;AACtE,iDAA6C;AAC7C,yCAAiC;AAEjC,6DAAyD;AAGlD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEW;IACrB;IAFnB,YACwC,EAAc,EACnC,OAA0B;QADL,OAAE,GAAF,EAAE,CAAY;QACnC,YAAO,GAAP,OAAO,CAAmB;IAC1C,CAAC;IAEJ,KAAK,CAAC,aAAa;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACvC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;QAE5D,KAAK,MAAM,MAAM,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;YACnC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChC,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,aAAa,aAAa,CAAC,CAAC;YACjE,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC9B,OAAO,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,aAAa,UAAU,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,6BAA6B,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ACF,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;iBAC9B;gBACD,IAAI,EAAE,EAAE,IAAI,EAAJ,gBAAI,EAAE;gBACd,eAAe,EAAE,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,mBAAmB,CAAC;aAC5D,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjEY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAA;qCAAa,eAAM;QACtB,sCAAiB;GAHlC,kBAAkB,CAiE9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
2
|
+
import { type ModuleConfig } from '../moduleConfig';
|
|
3
|
+
export declare class ModuleConfigRepository {
|
|
4
|
+
private readonly eventEmitter;
|
|
5
|
+
private lock;
|
|
6
|
+
private config;
|
|
7
|
+
constructor(initial: ModuleConfig, eventEmitter: EventEmitter2);
|
|
8
|
+
get(): ModuleConfig;
|
|
9
|
+
update(partial: Partial<ModuleConfig>): void;
|
|
10
|
+
acquireLock(): void;
|
|
11
|
+
hasLock(): boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ModuleConfigRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
18
|
+
const enum_1 = require("../enum");
|
|
19
|
+
const moduleConfig_1 = require("../moduleConfig");
|
|
20
|
+
let ModuleConfigRepository = class ModuleConfigRepository {
|
|
21
|
+
eventEmitter;
|
|
22
|
+
lock = false;
|
|
23
|
+
config;
|
|
24
|
+
constructor(initial, eventEmitter) {
|
|
25
|
+
this.eventEmitter = eventEmitter;
|
|
26
|
+
this.config = { ...initial };
|
|
27
|
+
}
|
|
28
|
+
get() {
|
|
29
|
+
return this.config;
|
|
30
|
+
}
|
|
31
|
+
update(partial) {
|
|
32
|
+
this.config = { ...this.config, ...partial };
|
|
33
|
+
this.eventEmitter.emit(enum_1.InternalEvent.ModuleConfigUpdated, this.config);
|
|
34
|
+
}
|
|
35
|
+
acquireLock() {
|
|
36
|
+
this.lock = true;
|
|
37
|
+
}
|
|
38
|
+
hasLock() {
|
|
39
|
+
return this.lock || !this.config.requireLock;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.ModuleConfigRepository = ModuleConfigRepository;
|
|
43
|
+
exports.ModuleConfigRepository = ModuleConfigRepository = __decorate([
|
|
44
|
+
(0, common_1.Injectable)(),
|
|
45
|
+
__param(0, (0, common_1.Inject)(moduleConfig_1.ModuleConfigProvider)),
|
|
46
|
+
__metadata("design:paramtypes", [Object, event_emitter_1.EventEmitter2])
|
|
47
|
+
], ModuleConfigRepository);
|
|
48
|
+
//# sourceMappingURL=moduleConfig.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleConfig.repository.js","sourceRoot":"","sources":["../../src/repositories/moduleConfig.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yDAAsD;AACtD,kCAAwC;AACxC,kDAA0E;AAGnE,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAMd;IALX,IAAI,GAAG,KAAK,CAAC;IACb,MAAM,CAAe;IAE7B,YACgC,OAAqB,EAClC,YAA2B;QAA3B,iBAAY,GAAZ,YAAY,CAAe;QAE5C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,OAA8B;QACnC,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,oBAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzE,CAAC;IAED,WAAW;QACT,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;IAC/C,CAAC;CACF,CAAA;AA3BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,mCAAoB,CAAC,CAAA;6CACE,6BAAa;GANnC,sBAAsB,CA2BlC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
2
|
+
import { DB } from '../schema';
|
|
3
|
+
import { RetentionPolicy } from '../utils/restic';
|
|
4
|
+
type RepositoryRow = {
|
|
5
|
+
id: string;
|
|
6
|
+
backendId: string;
|
|
7
|
+
retentionPolicy: RetentionPolicy | null;
|
|
8
|
+
};
|
|
9
|
+
export declare class RepositoryRepository {
|
|
10
|
+
private db;
|
|
11
|
+
constructor(db: Kysely<DB>);
|
|
12
|
+
create(repository: RepositoryRow): Promise<RepositoryRow>;
|
|
13
|
+
update(id: string, patch: Partial<Pick<RepositoryRow, 'retentionPolicy'>>): Promise<void>;
|
|
14
|
+
get(id: string): Promise<RepositoryRow>;
|
|
15
|
+
getAll(): Promise<RepositoryRow[]>;
|
|
16
|
+
delete(id: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RepositoryRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
let RepositoryRepository = class RepositoryRepository {
|
|
20
|
+
db;
|
|
21
|
+
constructor(db) {
|
|
22
|
+
this.db = db;
|
|
23
|
+
}
|
|
24
|
+
async create(repository) {
|
|
25
|
+
await this.db
|
|
26
|
+
.insertInto('repositories')
|
|
27
|
+
.values({
|
|
28
|
+
id: repository.id,
|
|
29
|
+
backendId: repository.backendId,
|
|
30
|
+
retentionPolicy: repository.retentionPolicy === null ? null : JSON.stringify(repository.retentionPolicy),
|
|
31
|
+
})
|
|
32
|
+
.returningAll()
|
|
33
|
+
.executeTakeFirstOrThrow();
|
|
34
|
+
return repository;
|
|
35
|
+
}
|
|
36
|
+
async update(id, patch) {
|
|
37
|
+
await this.db
|
|
38
|
+
.updateTable('repositories')
|
|
39
|
+
.set({
|
|
40
|
+
...('retentionPolicy' in patch && {
|
|
41
|
+
retentionPolicy: patch.retentionPolicy === null ? null : JSON.stringify(patch.retentionPolicy),
|
|
42
|
+
}),
|
|
43
|
+
})
|
|
44
|
+
.where('id', '=', id)
|
|
45
|
+
.execute();
|
|
46
|
+
}
|
|
47
|
+
async get(id) {
|
|
48
|
+
const row = await this.db
|
|
49
|
+
.selectFrom('repositories')
|
|
50
|
+
.selectAll('repositories')
|
|
51
|
+
.where('id', '=', id)
|
|
52
|
+
.executeTakeFirstOrThrow();
|
|
53
|
+
return {
|
|
54
|
+
id: row.id,
|
|
55
|
+
backendId: row.backendId,
|
|
56
|
+
retentionPolicy: row.retentionPolicy === null ? null : JSON.parse(row.retentionPolicy),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async getAll() {
|
|
60
|
+
const rows = await this.db.selectFrom('repositories').selectAll('repositories').execute();
|
|
61
|
+
return rows.map((row) => ({
|
|
62
|
+
id: row.id,
|
|
63
|
+
backendId: row.backendId,
|
|
64
|
+
retentionPolicy: row.retentionPolicy === null ? null : JSON.parse(row.retentionPolicy),
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
async delete(id) {
|
|
68
|
+
await this.db.deleteFrom('repositoryLocalMetrics').where('id', '=', id).execute();
|
|
69
|
+
await this.db.deleteFrom('repositoryPaths').where('id', '=', id).execute();
|
|
70
|
+
await this.db.deleteFrom('repositorySchedules').where('repository', '=', id).execute();
|
|
71
|
+
await this.db.deleteFrom('runHistory').where('repositoryId', '=', id).execute();
|
|
72
|
+
await this.db.deleteFrom('repositories').where('id', '=', id).execute();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.RepositoryRepository = RepositoryRepository;
|
|
76
|
+
exports.RepositoryRepository = RepositoryRepository = __decorate([
|
|
77
|
+
(0, common_1.Injectable)(),
|
|
78
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
79
|
+
__metadata("design:paramtypes", [kysely_1.Kysely])
|
|
80
|
+
], RepositoryRepository);
|
|
81
|
+
//# sourceMappingURL=repository.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.repository.js","sourceRoot":"","sources":["../../src/repositories/repository.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAgC;AAChC,iDAA6C;AAWtC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACmB;IAAlD,YAAkD,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;IAAG,CAAC;IAEpE,KAAK,CAAC,MAAM,CAAC,UAAyB;QACpC,MAAM,IAAI,CAAC,EAAE;aACV,UAAU,CAAC,cAAc,CAAC;aAC1B,MAAM,CAAC;YACN,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,eAAe,EAAE,UAAU,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC;SACzG,CAAC;aACD,YAAY,EAAE;aACd,uBAAuB,EAAE,CAAC;QAE7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EA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C,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAqB;SAC5G,CAAC,CAAC,CAAC;IACN,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAClF,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3E,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACvF,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAChF,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1E,CAAC;CACF,CAAA;AA3DY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAA;qCAAa,eAAM;GADjD,oBAAoB,CA2DhC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
2
|
+
import { DB } from '../schema';
|
|
3
|
+
import { ImmichRepositoryConfig } from '../schema/tables/repositoryIntegrationImmich.table';
|
|
4
|
+
export declare class RepositoryIntegrationImmichRepository {
|
|
5
|
+
private db;
|
|
6
|
+
constructor(db: Kysely<DB>);
|
|
7
|
+
get(): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
scheduleId: string;
|
|
10
|
+
configuration: ImmichRepositoryConfig;
|
|
11
|
+
} | undefined>;
|
|
12
|
+
upsert(id: string, scheduleId: string, configuration: ImmichRepositoryConfig): Promise<void>;
|
|
13
|
+
delete(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RepositoryIntegrationImmichRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
let RepositoryIntegrationImmichRepository = class RepositoryIntegrationImmichRepository {
|
|
20
|
+
db;
|
|
21
|
+
constructor(db) {
|
|
22
|
+
this.db = db;
|
|
23
|
+
}
|
|
24
|
+
async get() {
|
|
25
|
+
const integration = await this.db.selectFrom('repositoryIntegrationImmich').selectAll().executeTakeFirst();
|
|
26
|
+
if (!integration) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
id: integration.id,
|
|
31
|
+
scheduleId: integration.scheduleId,
|
|
32
|
+
configuration: JSON.parse(integration.configuration),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async upsert(id, scheduleId, configuration) {
|
|
36
|
+
await this.db
|
|
37
|
+
.insertInto('repositoryIntegrationImmich')
|
|
38
|
+
.values({
|
|
39
|
+
id,
|
|
40
|
+
scheduleId,
|
|
41
|
+
configuration: JSON.stringify(configuration),
|
|
42
|
+
})
|
|
43
|
+
.onConflict((oc) => oc.column('id').doUpdateSet({ configuration: JSON.stringify(configuration), scheduleId }))
|
|
44
|
+
.returningAll()
|
|
45
|
+
.executeTakeFirstOrThrow();
|
|
46
|
+
}
|
|
47
|
+
async delete() {
|
|
48
|
+
await this.db.deleteFrom('repositoryIntegrationImmich').execute();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.RepositoryIntegrationImmichRepository = RepositoryIntegrationImmichRepository;
|
|
52
|
+
exports.RepositoryIntegrationImmichRepository = RepositoryIntegrationImmichRepository = __decorate([
|
|
53
|
+
(0, common_1.Injectable)(),
|
|
54
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
55
|
+
__metadata("design:paramtypes", [kysely_1.Kysely])
|
|
56
|
+
], RepositoryIntegrationImmichRepository);
|
|
57
|
+
//# sourceMappingURL=repositoryIntegrationImmich.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositoryIntegrationImmich.repository.js","sourceRoot":"","sources":["../../src/repositories/repositoryIntegrationImmich.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAgC;AAChC,iDAA6C;AAKtC,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IACE;IAAlD,YAAkD,EAAc;QAAd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
|
2
|
+
import { RepositoryMetricsDto } from '../dto/repository.dto';
|
|
3
|
+
import { DB } from '../schema';
|
|
4
|
+
import { RepositoryLocalMetricsTable } from '../schema/tables/repositoryLocalMetrics.table';
|
|
5
|
+
export declare class RepositoryLocalMetricsRepository {
|
|
6
|
+
private db;
|
|
7
|
+
constructor(db: Kysely<DB>);
|
|
8
|
+
save(id: string, metrics: Updateable<RepositoryLocalMetricsTable>): Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
lastBackup: string | undefined;
|
|
11
|
+
lastSuccessfulBackup: string | undefined;
|
|
12
|
+
lastBackupDuration: number | undefined;
|
|
13
|
+
sizeBytes: number;
|
|
14
|
+
}>;
|
|
15
|
+
get(id: string): Promise<RepositoryMetricsDto>;
|
|
16
|
+
getAll(): Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
lastBackup: string | undefined;
|
|
19
|
+
lastSuccessfulBackup: string | undefined;
|
|
20
|
+
lastBackupDuration: number | undefined;
|
|
21
|
+
sizeBytes: number;
|
|
22
|
+
}[]>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RepositoryLocalMetricsRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const kysely_1 = require("kysely");
|
|
18
|
+
const nestjs_kysely_1 = require("nestjs-kysely");
|
|
19
|
+
let RepositoryLocalMetricsRepository = class RepositoryLocalMetricsRepository {
|
|
20
|
+
db;
|
|
21
|
+
constructor(db) {
|
|
22
|
+
this.db = db;
|
|
23
|
+
}
|
|
24
|
+
async save(id, metrics) {
|
|
25
|
+
return await this.db
|
|
26
|
+
.insertInto('repositoryLocalMetrics')
|
|
27
|
+
.values({
|
|
28
|
+
id,
|
|
29
|
+
sizeBytes: 0,
|
|
30
|
+
...metrics,
|
|
31
|
+
})
|
|
32
|
+
.onConflict((oc) => oc.doUpdateSet(metrics))
|
|
33
|
+
.returningAll()
|
|
34
|
+
.executeTakeFirstOrThrow();
|
|
35
|
+
}
|
|
36
|
+
async get(id) {
|
|
37
|
+
return ((await this.db
|
|
38
|
+
.selectFrom('repositoryLocalMetrics')
|
|
39
|
+
.selectAll('repositoryLocalMetrics')
|
|
40
|
+
.where('id', '=', id)
|
|
41
|
+
.executeTakeFirst()) ?? {
|
|
42
|
+
sizeBytes: 0,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getAll() {
|
|
46
|
+
return this.db.selectFrom('repositoryLocalMetrics').selectAll('repositoryLocalMetrics').execute();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.RepositoryLocalMetricsRepository = RepositoryLocalMetricsRepository;
|
|
50
|
+
exports.RepositoryLocalMetricsRepository = RepositoryLocalMetricsRepository = __decorate([
|
|
51
|
+
(0, common_1.Injectable)(),
|
|
52
|
+
__param(0, (0, nestjs_kysely_1.InjectKysely)('orchestrator')),
|
|
53
|
+
__metadata("design:paramtypes", [kysely_1.Kysely])
|
|
54
|
+
], RepositoryLocalMetricsRepository);
|
|
55
|
+
//# sourceMappingURL=repositoryLocalMetrics.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositoryLocalMetrics.repository.js","sourceRoot":"","sources":["../../src/repositories/repositoryLocalMetrics.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mCAA4C;AAC5C,iDAA6C;AAMtC,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IACO;IAAlD,YAAkD,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;IAAG,CAAC;IAEpE,KAAK,CAAC,IAAI,CAAC,EAAU,EAAE,OAAgD;QACrE,OAAO,MAAM,IAAI,CAAC,EAAE;aACjB,UAAU,CAAC,wBAAwB,CAAC;aACpC,MAAM,CAAC;YACN,EAAE;YACF,SAAS,EAAE,CAAC;YACZ,GAAG,OAAO;SACX,CAAC;aACD,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;aAC3C,YAAY,EAAE;aACd,uBAAuB,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,CACL,CAAC,MAAM,IAAI,CAAC,EAAE;aACX,UAAU,CAAC,wBAAwB,CAAC;aACpC,SAAS,CAAC,wBAAwB,CAAC;aACnC,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;aACpB,gBAAgB,EAAE,CAAC,IAAI;YACxB,SAAS,EAAE,CAAC;SACb,CACF,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,OAAO,EAAE,CAAC;IACpG,CAAC;CACF,CAAA;AA/BY,4EAAgC;2CAAhC,gCAAgC;IAD5C,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAA;qCAAa,eAAM;GADjD,gCAAgC,CA+B5C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Insertable, Kysely } from 'kysely';
|
|
2
|
+
import { DB } from '../schema';
|
|
3
|
+
import { RepositoryPathTable } from '../schema/tables/repositoryPath.table';
|
|
4
|
+
export declare class RepositoryPathRepository {
|
|
5
|
+
private db;
|
|
6
|
+
constructor(db: Kysely<DB>);
|
|
7
|
+
create(entry: Insertable<RepositoryPathTable>): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}>;
|
|
11
|
+
get(id: string): Promise<string[]>;
|
|
12
|
+
getAll(): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}[]>;
|
|
16
|
+
delete(id: string, path: string): Promise<import("kysely").DeleteResult>;
|
|
17
|
+
}
|