@futo-org/backups-orchestrator-api 1.12.1 → 1.13.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.
Files changed (216) hide show
  1. package/dist/const.d.ts +3 -0
  2. package/dist/const.js +3 -0
  3. package/dist/const.js.map +1 -1
  4. package/dist/controllers/job.controller.d.ts +5 -4
  5. package/dist/controllers/job.controller.js +13 -12
  6. package/dist/controllers/job.controller.js.map +1 -1
  7. package/dist/controllers/onboarding.controller.d.ts +2 -2
  8. package/dist/controllers/onboarding.controller.js +3 -3
  9. package/dist/controllers/onboarding.controller.js.map +1 -1
  10. package/dist/controllers/schedule.controller.d.ts +3 -2
  11. package/dist/controllers/schedule.controller.js +8 -6
  12. package/dist/controllers/schedule.controller.js.map +1 -1
  13. package/dist/dto/onboarding.dto.d.ts +5 -0
  14. package/dist/dto/onboarding.dto.js +5 -0
  15. package/dist/dto/onboarding.dto.js.map +1 -1
  16. package/dist/dto/param.dto.d.ts +7 -0
  17. package/dist/dto/param.dto.js +6 -0
  18. package/dist/dto/param.dto.js.map +1 -0
  19. package/dist/enum.d.ts +1 -5
  20. package/dist/enum.js +1 -6
  21. package/dist/enum.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/jobs/repositoryBackup.job.js +25 -26
  24. package/dist/jobs/repositoryBackup.job.js.map +1 -1
  25. package/dist/jobs/repositoryRestoreFromPoint.job.d.ts +1 -3
  26. package/dist/jobs/repositoryRestoreFromPoint.job.js +15 -9
  27. package/dist/jobs/repositoryRestoreFromPoint.job.js.map +1 -1
  28. package/dist/legacy-sqlite/legacySqlite.d.ts +3 -0
  29. package/dist/legacy-sqlite/legacySqlite.js +38 -0
  30. package/dist/legacy-sqlite/legacySqlite.js.map +1 -0
  31. package/dist/legacy-sqlite/legacyState.repository.d.ts +9 -0
  32. package/dist/legacy-sqlite/legacyState.repository.js +221 -0
  33. package/dist/legacy-sqlite/legacyState.repository.js.map +1 -0
  34. package/dist/legacy-sqlite/migrations/20260218105210-InitialMigration.js.map +1 -0
  35. package/dist/legacy-sqlite/migrations/20260218122600-AddRepositories.js.map +1 -0
  36. package/dist/legacy-sqlite/migrations/20260224112323-RepositoryPathTable.js.map +1 -0
  37. package/dist/legacy-sqlite/migrations/20260224123344-RunHistoryTable.js.map +1 -0
  38. package/dist/legacy-sqlite/migrations/20260224125102-RepositoryMetricsTable.js.map +1 -0
  39. package/dist/legacy-sqlite/migrations/20260304162353-ScheduleTable.js.map +1 -0
  40. package/dist/legacy-sqlite/migrations/20260313222211-AddMetricsColumns.js.map +1 -0
  41. package/dist/legacy-sqlite/migrations/20260330120000-RepositoryIntegrationImmichTable.js.map +1 -0
  42. package/dist/legacy-sqlite/migrations/20260330130000-AddScheduleIdToImmichIntegration.js.map +1 -0
  43. package/dist/legacy-sqlite/migrations/20260507120000-AddRunHistoryType.js.map +1 -0
  44. package/dist/legacy-sqlite/migrations/20260512120000-AddRepositoryRetentionPolicy.js.map +1 -0
  45. package/dist/legacy-sqlite/migrations/20260512130000-AllowForgetRunHistoryType.js.map +1 -0
  46. package/dist/legacy-sqlite/migrations/20260603120000-AddRepositoryRemoteId.js.map +1 -0
  47. package/dist/legacy-sqlite/migrations/20260729130000-AddRepositoryPlacement.js.map +1 -0
  48. package/dist/legacy-sqlite/migrations/20260814120000-AllowWarnRunHistoryStatus.js.map +1 -0
  49. package/dist/legacy-sqlite/migrations/20260814120100-AddLastBackupStatus.js.map +1 -0
  50. package/dist/legacy-sqlite/migrations/20260917120000-AllowCancelledStatus.js.map +1 -0
  51. package/dist/legacy-sqlite/migrations/20261013120000-AddJobs.js.map +1 -0
  52. package/dist/legacy-sqlite/migrations/20261015120000-MigrateRunHistoryToJobs.js.map +1 -0
  53. package/dist/legacy-sqlite/migrations/20261015120100-DropRunHistory.js.map +1 -0
  54. package/dist/legacy-sqlite/schema.d.ts +60 -0
  55. package/dist/legacy-sqlite/schema.js +2 -0
  56. package/dist/legacy-sqlite/schema.js.map +1 -0
  57. package/dist/middleware/session.guard.js +3 -0
  58. package/dist/middleware/session.guard.js.map +1 -1
  59. package/dist/moduleConfig.d.ts +10 -2
  60. package/dist/moduleConfig.js.map +1 -1
  61. package/dist/orchestrationApi.module.d.ts +6 -5
  62. package/dist/orchestrationApi.module.js +3 -18
  63. package/dist/orchestrationApi.module.js.map +1 -1
  64. package/dist/pglite.d.ts +5 -0
  65. package/dist/pglite.js +59 -0
  66. package/dist/pglite.js.map +1 -0
  67. package/dist/repositories/backend.repository.d.ts +2 -2
  68. package/dist/repositories/backend.repository.js +11 -22
  69. package/dist/repositories/backend.repository.js.map +1 -1
  70. package/dist/repositories/config.repository.d.ts +6 -3
  71. package/dist/repositories/config.repository.js +58 -57
  72. package/dist/repositories/config.repository.js.map +1 -1
  73. package/dist/repositories/database.repository.d.ts +4 -2
  74. package/dist/repositories/database.repository.js +30 -40
  75. package/dist/repositories/database.repository.js.map +1 -1
  76. package/dist/repositories/job.repository.d.ts +51 -11
  77. package/dist/repositories/job.repository.js +65 -60
  78. package/dist/repositories/job.repository.js.map +1 -1
  79. package/dist/repositories/repository.repository.d.ts +27 -15
  80. package/dist/repositories/repository.repository.js +11 -51
  81. package/dist/repositories/repository.repository.js.map +1 -1
  82. package/dist/repositories/repositoryIntegrationImmich.repository.d.ts +2 -6
  83. package/dist/repositories/repositoryIntegrationImmich.repository.js +16 -14
  84. package/dist/repositories/repositoryIntegrationImmich.repository.js.map +1 -1
  85. package/dist/repositories/repositoryLocalMetrics.repository.d.ts +8 -10
  86. package/dist/repositories/repositoryLocalMetrics.repository.js +23 -17
  87. package/dist/repositories/repositoryLocalMetrics.repository.js.map +1 -1
  88. package/dist/repositories/repositoryPath.repository.d.ts +4 -4
  89. package/dist/repositories/repositoryPath.repository.js +11 -7
  90. package/dist/repositories/repositoryPath.repository.js.map +1 -1
  91. package/dist/repositories/schedule.repository.d.ts +19 -18
  92. package/dist/repositories/schedule.repository.js +45 -44
  93. package/dist/repositories/schedule.repository.js.map +1 -1
  94. package/dist/schema/enums.d.ts +4 -0
  95. package/dist/schema/enums.js +19 -0
  96. package/dist/schema/enums.js.map +1 -0
  97. package/dist/schema/index.d.ts +14 -10
  98. package/dist/schema/index.js +35 -1
  99. package/dist/schema/index.js.map +1 -1
  100. package/dist/schema/migrations/1793295581871-InitialMigration.d.ts +3 -0
  101. package/dist/schema/migrations/1793295581871-InitialMigration.js +106 -0
  102. package/dist/schema/migrations/1793295581871-InitialMigration.js.map +1 -0
  103. package/dist/schema/tables/backend.table.d.ts +2 -2
  104. package/dist/schema/tables/backend.table.js +24 -2
  105. package/dist/schema/tables/backend.table.js.map +1 -1
  106. package/dist/schema/tables/config.table.d.ts +38 -3
  107. package/dist/schema/tables/config.table.js +26 -2
  108. package/dist/schema/tables/config.table.js.map +1 -1
  109. package/dist/schema/tables/job.table.d.ts +10 -6
  110. package/dist/schema/tables/job.table.js +75 -2
  111. package/dist/schema/tables/job.table.js.map +1 -1
  112. package/dist/schema/tables/repository.table.d.ts +4 -2
  113. package/dist/schema/tables/repository.table.js +41 -2
  114. package/dist/schema/tables/repository.table.js.map +1 -1
  115. package/dist/schema/tables/repositoryIntegrationImmich.table.d.ts +2 -2
  116. package/dist/schema/tables/repositoryIntegrationImmich.table.js +31 -3
  117. package/dist/schema/tables/repositoryIntegrationImmich.table.js.map +1 -1
  118. package/dist/schema/tables/repositoryLocalMetrics.table.d.ts +6 -5
  119. package/dist/schema/tables/repositoryLocalMetrics.table.js +39 -3
  120. package/dist/schema/tables/repositoryLocalMetrics.table.js.map +1 -1
  121. package/dist/schema/tables/repositoryPath.table.d.ts +1 -1
  122. package/dist/schema/tables/repositoryPath.table.js +26 -3
  123. package/dist/schema/tables/repositoryPath.table.js.map +1 -1
  124. package/dist/schema/tables/repositorySchedule.table.d.ts +2 -2
  125. package/dist/schema/tables/repositorySchedule.table.js +28 -4
  126. package/dist/schema/tables/repositorySchedule.table.js.map +1 -1
  127. package/dist/schema/tables/schedule.table.d.ts +6 -5
  128. package/dist/schema/tables/schedule.table.js +44 -2
  129. package/dist/schema/tables/schedule.table.js.map +1 -1
  130. package/dist/services/bootstrap.service.d.ts +5 -1
  131. package/dist/services/bootstrap.service.js +18 -2
  132. package/dist/services/bootstrap.service.js.map +1 -1
  133. package/dist/services/development.service.d.ts +3 -4
  134. package/dist/services/development.service.js +6 -18
  135. package/dist/services/development.service.js.map +1 -1
  136. package/dist/services/integrations.service.d.ts +5 -3
  137. package/dist/services/integrations.service.js +23 -12
  138. package/dist/services/integrations.service.js.map +1 -1
  139. package/dist/services/onboarding.service.d.ts +2 -2
  140. package/dist/services/onboarding.service.js +2 -0
  141. package/dist/services/onboarding.service.js.map +1 -1
  142. package/dist/services/repository.service.d.ts +1 -1
  143. package/dist/services/repository.service.js +4 -4
  144. package/dist/services/repository.service.js.map +1 -1
  145. package/dist/services/schedule.service.js +13 -14
  146. package/dist/services/schedule.service.js.map +1 -1
  147. package/dist/services/session.service.d.ts +1 -0
  148. package/dist/services/session.service.js +4 -1
  149. package/dist/services/session.service.js.map +1 -1
  150. package/dist/services/yucca.service.d.ts +26 -7
  151. package/dist/services/yucca.service.js +6 -7
  152. package/dist/services/yucca.service.js.map +1 -1
  153. package/dist/utils/restic.d.ts +2 -0
  154. package/dist/utils/restic.js +1 -0
  155. package/dist/utils/restic.js.map +1 -1
  156. package/package.json +28 -4
  157. package/dist/schema/migrations/20260218105210-InitialMigration.js.map +0 -1
  158. package/dist/schema/migrations/20260218122600-AddRepositories.js.map +0 -1
  159. package/dist/schema/migrations/20260224112323-RepositoryPathTable.js.map +0 -1
  160. package/dist/schema/migrations/20260224123344-RunHistoryTable.js.map +0 -1
  161. package/dist/schema/migrations/20260224125102-RepositoryMetricsTable.js.map +0 -1
  162. package/dist/schema/migrations/20260304162353-ScheduleTable.js.map +0 -1
  163. package/dist/schema/migrations/20260313222211-AddMetricsColumns.js.map +0 -1
  164. package/dist/schema/migrations/20260330120000-RepositoryIntegrationImmichTable.js.map +0 -1
  165. package/dist/schema/migrations/20260330130000-AddScheduleIdToImmichIntegration.js.map +0 -1
  166. package/dist/schema/migrations/20260507120000-AddRunHistoryType.js.map +0 -1
  167. package/dist/schema/migrations/20260512120000-AddRepositoryRetentionPolicy.js.map +0 -1
  168. package/dist/schema/migrations/20260512130000-AllowForgetRunHistoryType.js.map +0 -1
  169. package/dist/schema/migrations/20260603120000-AddRepositoryRemoteId.js.map +0 -1
  170. package/dist/schema/migrations/20260729130000-AddRepositoryPlacement.js.map +0 -1
  171. package/dist/schema/migrations/20260814120000-AllowWarnRunHistoryStatus.js.map +0 -1
  172. package/dist/schema/migrations/20260814120100-AddLastBackupStatus.js.map +0 -1
  173. package/dist/schema/migrations/20260917120000-AllowCancelledStatus.js.map +0 -1
  174. package/dist/schema/migrations/20261013120000-AddJobs.js.map +0 -1
  175. package/dist/schema/migrations/20261015120000-MigrateRunHistoryToJobs.js.map +0 -1
  176. package/dist/schema/migrations/20261015120100-DropRunHistory.js.map +0 -1
  177. /package/dist/{schema → legacy-sqlite}/migrations/20260218105210-InitialMigration.d.ts +0 -0
  178. /package/dist/{schema → legacy-sqlite}/migrations/20260218105210-InitialMigration.js +0 -0
  179. /package/dist/{schema → legacy-sqlite}/migrations/20260218122600-AddRepositories.d.ts +0 -0
  180. /package/dist/{schema → legacy-sqlite}/migrations/20260218122600-AddRepositories.js +0 -0
  181. /package/dist/{schema → legacy-sqlite}/migrations/20260224112323-RepositoryPathTable.d.ts +0 -0
  182. /package/dist/{schema → legacy-sqlite}/migrations/20260224112323-RepositoryPathTable.js +0 -0
  183. /package/dist/{schema → legacy-sqlite}/migrations/20260224123344-RunHistoryTable.d.ts +0 -0
  184. /package/dist/{schema → legacy-sqlite}/migrations/20260224123344-RunHistoryTable.js +0 -0
  185. /package/dist/{schema → legacy-sqlite}/migrations/20260224125102-RepositoryMetricsTable.d.ts +0 -0
  186. /package/dist/{schema → legacy-sqlite}/migrations/20260224125102-RepositoryMetricsTable.js +0 -0
  187. /package/dist/{schema → legacy-sqlite}/migrations/20260304162353-ScheduleTable.d.ts +0 -0
  188. /package/dist/{schema → legacy-sqlite}/migrations/20260304162353-ScheduleTable.js +0 -0
  189. /package/dist/{schema → legacy-sqlite}/migrations/20260313222211-AddMetricsColumns.d.ts +0 -0
  190. /package/dist/{schema → legacy-sqlite}/migrations/20260313222211-AddMetricsColumns.js +0 -0
  191. /package/dist/{schema → legacy-sqlite}/migrations/20260330120000-RepositoryIntegrationImmichTable.d.ts +0 -0
  192. /package/dist/{schema → legacy-sqlite}/migrations/20260330120000-RepositoryIntegrationImmichTable.js +0 -0
  193. /package/dist/{schema → legacy-sqlite}/migrations/20260330130000-AddScheduleIdToImmichIntegration.d.ts +0 -0
  194. /package/dist/{schema → legacy-sqlite}/migrations/20260330130000-AddScheduleIdToImmichIntegration.js +0 -0
  195. /package/dist/{schema → legacy-sqlite}/migrations/20260507120000-AddRunHistoryType.d.ts +0 -0
  196. /package/dist/{schema → legacy-sqlite}/migrations/20260507120000-AddRunHistoryType.js +0 -0
  197. /package/dist/{schema → legacy-sqlite}/migrations/20260512120000-AddRepositoryRetentionPolicy.d.ts +0 -0
  198. /package/dist/{schema → legacy-sqlite}/migrations/20260512120000-AddRepositoryRetentionPolicy.js +0 -0
  199. /package/dist/{schema → legacy-sqlite}/migrations/20260512130000-AllowForgetRunHistoryType.d.ts +0 -0
  200. /package/dist/{schema → legacy-sqlite}/migrations/20260512130000-AllowForgetRunHistoryType.js +0 -0
  201. /package/dist/{schema → legacy-sqlite}/migrations/20260603120000-AddRepositoryRemoteId.d.ts +0 -0
  202. /package/dist/{schema → legacy-sqlite}/migrations/20260603120000-AddRepositoryRemoteId.js +0 -0
  203. /package/dist/{schema → legacy-sqlite}/migrations/20260729130000-AddRepositoryPlacement.d.ts +0 -0
  204. /package/dist/{schema → legacy-sqlite}/migrations/20260729130000-AddRepositoryPlacement.js +0 -0
  205. /package/dist/{schema → legacy-sqlite}/migrations/20260814120000-AllowWarnRunHistoryStatus.d.ts +0 -0
  206. /package/dist/{schema → legacy-sqlite}/migrations/20260814120000-AllowWarnRunHistoryStatus.js +0 -0
  207. /package/dist/{schema → legacy-sqlite}/migrations/20260814120100-AddLastBackupStatus.d.ts +0 -0
  208. /package/dist/{schema → legacy-sqlite}/migrations/20260814120100-AddLastBackupStatus.js +0 -0
  209. /package/dist/{schema → legacy-sqlite}/migrations/20260917120000-AllowCancelledStatus.d.ts +0 -0
  210. /package/dist/{schema → legacy-sqlite}/migrations/20260917120000-AllowCancelledStatus.js +0 -0
  211. /package/dist/{schema → legacy-sqlite}/migrations/20261013120000-AddJobs.d.ts +0 -0
  212. /package/dist/{schema → legacy-sqlite}/migrations/20261013120000-AddJobs.js +0 -0
  213. /package/dist/{schema → legacy-sqlite}/migrations/20261015120000-MigrateRunHistoryToJobs.d.ts +0 -0
  214. /package/dist/{schema → legacy-sqlite}/migrations/20261015120000-MigrateRunHistoryToJobs.js +0 -0
  215. /package/dist/{schema → legacy-sqlite}/migrations/20261015120100-DropRunHistory.d.ts +0 -0
  216. /package/dist/{schema → legacy-sqlite}/migrations/20261015120100-DropRunHistory.js +0 -0
@@ -1,3 +1,4 @@
1
+ import type { Dialect } from 'kysely';
1
2
  import type { Socket } from 'socket.io';
2
3
  import { GatewayEvent } from './events/events.gateway.js';
3
4
  import type { ResticProxyThrottle } from './proxy/resticProxy.js';
@@ -12,6 +13,13 @@ export type ImmichDatabaseDumpConfig = {
12
13
  enabled: boolean;
13
14
  keepLastAmount: number;
14
15
  };
16
+ export type DatabaseDumpTagName = 'yucca.v1.immichBackupFileName' | 'yucca.v1.stateDumpFileName';
17
+ export type DatabaseHooks = {
18
+ tagName: DatabaseDumpTagName;
19
+ dump(signal: AbortSignal): Promise<string>;
20
+ cleanup?(): Promise<void>;
21
+ restore(fileName: string): Promise<void>;
22
+ };
15
23
  export type ImmichIntegration = {
16
24
  dataPath: string;
17
25
  dataFolders: string[];
@@ -22,8 +30,6 @@ export type ImmichIntegration = {
22
30
  exclusionPatterns: string[];
23
31
  }[];
24
32
  hooks: {
25
- createDatabaseBackup(signal: AbortSignal): Promise<string>;
26
- cleanupDatabaseBackups(): Promise<void>;
27
33
  getImmichDatabaseDumpConfig(): Promise<ImmichDatabaseDumpConfig>;
28
34
  configureImmichDatabaseDump(config: Partial<ImmichDatabaseDumpConfig>): Promise<void>;
29
35
  enterMaintenanceRollback(repositoryId: string, snapshotId: string, backupFileName?: string): Promise<{
@@ -32,6 +38,7 @@ export type ImmichIntegration = {
32
38
  };
33
39
  };
34
40
  export type ModuleConfig = {
41
+ dialect: Dialect;
35
42
  statePath: string;
36
43
  cachePath?: string;
37
44
  resticWalkConcurrency?: number;
@@ -44,5 +51,6 @@ export type ModuleConfig = {
44
51
  throttle?: ResticProxyThrottle;
45
52
  authenticate?: AuthenticateFn;
46
53
  onInternalEvent?: (event: GatewayEvent) => void;
54
+ databaseHooks?: DatabaseHooks;
47
55
  immichIntegration?: ImmichIntegration;
48
56
  };
@@ -1 +1 @@
1
- {"version":3,"file":"moduleConfig.js","sourceRoot":"","sources":["../src/moduleConfig.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"moduleConfig.js","sourceRoot":"","sources":["../src/moduleConfig.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { DynamicModule, FactoryProvider, ModuleMetadata } from '@nestjs/common';
2
- import { type SqliteDatabase } from 'kysely';
3
2
  import { AuthController } from './controllers/auth.controller.js';
4
3
  import { BackendController } from './controllers/backend.controller.js';
5
4
  import { ConfigController } from './controllers/config.controller.js';
@@ -17,6 +16,7 @@ import { RepositoryRestoreJob } from './jobs/repositoryRestore.job.js';
17
16
  import { RepositoryRestoreFromPointJob } from './jobs/repositoryRestoreFromPoint.job.js';
18
17
  import { RepositorySnapshotForgetJob } from './jobs/repositorySnapshotForget.job.js';
19
18
  import { RepositorySyncMetricsJob } from './jobs/repositorySyncMetrics.job.js';
19
+ import { LegacyStateRepository } from './legacy-sqlite/legacyState.repository.js';
20
20
  import { type ModuleConfig } from './moduleConfig.js';
21
21
  import { BackendRepository } from './repositories/backend.repository.js';
22
22
  import { BootstrapRepository } from './repositories/bootstrap.repository.js';
@@ -50,14 +50,15 @@ import { SupportModeService } from './services/supportMode.service.js';
50
50
  import { TelemetryService } from './services/telemetry.service.js';
51
51
  import { YuccaService } from './services/yucca.service.js';
52
52
  export declare const controllers: (typeof AuthController | typeof BackendController | typeof ConfigController | typeof DevelopmentController | typeof FilesystemController | typeof IntegrationsController | typeof JobController | typeof OnboardingController | typeof RepositoryController | typeof ScheduleController | typeof SupportModeController)[];
53
- export declare const repositories: (typeof ModuleConfigRepository | typeof LoggingRepository | typeof BackendRepository | typeof ConfigRepository | typeof RepositoryRepository | typeof BootstrapRepository | typeof StorageRepository | typeof DatabaseRepository | typeof RepositoryIntegrationImmichRepository | typeof RepositoryPathRepository | typeof SupportContextRepository | typeof ResticRepository | typeof RepositoryLocalMetricsRepository | typeof JobRepository | typeof ScheduleRepository | typeof LockRepository)[];
54
- export declare const services: (typeof SessionService | typeof TelemetryService | typeof AuthService | typeof BackendService | typeof ConfigService | typeof SupportModeService | typeof RepositoryService | typeof BootstrapService | typeof JobService | typeof ScheduleService | typeof DevelopmentService | typeof FilesystemService | typeof IntegrationsService | typeof OnboardingService | typeof YuccaService)[];
53
+ export declare const repositories: (typeof ModuleConfigRepository | typeof LoggingRepository | typeof ConfigRepository | typeof StorageRepository | typeof BackendRepository | typeof DatabaseRepository | typeof SupportContextRepository | typeof JobRepository | typeof RepositoryRepository | typeof RepositoryIntegrationImmichRepository | typeof RepositoryPathRepository | typeof ResticRepository | typeof RepositoryLocalMetricsRepository | typeof LegacyStateRepository | typeof BootstrapRepository | typeof LockRepository | typeof ScheduleRepository)[];
54
+ export declare const services: (typeof SupportModeService | typeof TelemetryService | typeof RepositoryService | typeof ConfigService | typeof BackendService | typeof ScheduleService | typeof IntegrationsService | typeof JobService | typeof BootstrapService | typeof SessionService | typeof AuthService | typeof DevelopmentService | typeof FilesystemService | typeof OnboardingService | typeof YuccaService)[];
55
55
  export declare const jobs: (typeof RepositoryBackupJob | typeof RepositoryPruneJob | typeof RepositoryRestoreJob | typeof RepositoryRestoreFromPointJob | typeof RepositorySnapshotForgetJob | typeof RepositorySyncMetricsJob)[];
56
- export declare function openStateDatabase(config: Pick<ModuleConfig, 'statePath'>, logger?: LoggingRepository): SqliteDatabase;
56
+ type OrchestrationApiModuleConfig = Pick<ModuleConfig, 'dialect'> & Partial<Omit<ModuleConfig, 'dialect'>>;
57
57
  export interface OrchestrationApiModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
58
58
  inject?: FactoryProvider['inject'];
59
- useFactory: (...args: any[]) => Promise<Partial<ModuleConfig>> | Partial<ModuleConfig>;
59
+ useFactory: (...args: any[]) => Promise<OrchestrationApiModuleConfig> | OrchestrationApiModuleConfig;
60
60
  }
61
61
  export declare class OrchestrationApiModule {
62
62
  static forRootAsync(options: OrchestrationApiModuleAsyncOptions): DynamicModule;
63
63
  }
64
+ export {};
@@ -10,10 +10,7 @@ import { APP_GUARD, APP_INTERCEPTOR, DiscoveryModule } from '@nestjs/core';
10
10
  import { EventEmitterModule } from '@nestjs/event-emitter';
11
11
  import { JwtModule } from '@nestjs/jwt';
12
12
  import { ScheduleModule } from '@nestjs/schedule';
13
- import Database from 'better-sqlite3';
14
- import { SqliteDialect } from 'kysely';
15
13
  import { KyselyModule } from 'nestjs-kysely';
16
- import { existsSync, mkdirSync } from 'node:fs';
17
14
  import { homedir } from 'node:os';
18
15
  import { resolve } from 'node:path';
19
16
  import { AuthController } from './controllers/auth.controller.js';
@@ -35,6 +32,7 @@ import { RepositoryRestoreJob } from './jobs/repositoryRestore.job.js';
35
32
  import { RepositoryRestoreFromPointJob } from './jobs/repositoryRestoreFromPoint.job.js';
36
33
  import { RepositorySnapshotForgetJob } from './jobs/repositorySnapshotForget.job.js';
37
34
  import { RepositorySyncMetricsJob } from './jobs/repositorySyncMetrics.job.js';
35
+ import { LegacyStateRepository } from './legacy-sqlite/legacyState.repository.js';
38
36
  import { SessionGuard } from './middleware/session.guard.js';
39
37
  import { ModuleConfigProvider } from './moduleConfig.js';
40
38
  import { ResticProxyPool } from './proxy/resticProxyPool.js';
@@ -89,6 +87,7 @@ export const repositories = [
89
87
  ConfigRepository,
90
88
  DatabaseRepository,
91
89
  JobRepository,
90
+ LegacyStateRepository,
92
91
  LockRepository,
93
92
  LoggingRepository,
94
93
  ModuleConfigRepository,
@@ -126,20 +125,6 @@ export const jobs = [
126
125
  RepositorySnapshotForgetJob,
127
126
  RepositorySyncMetricsJob,
128
127
  ];
129
- export function openStateDatabase(config, logger = LoggingRepository.create('State')) {
130
- mkdirSync(config.statePath, { recursive: true });
131
- const databasePath = resolve(config.statePath, 'state.sqlite3');
132
- if (existsSync(databasePath)) {
133
- logger.log(`Opened existing state database at ${databasePath}`);
134
- }
135
- else {
136
- logger.warn(`No state database at ${databasePath}, creating a new one`);
137
- }
138
- const database = new Database(databasePath);
139
- database.pragma('journal_mode = WAL');
140
- database.pragma('wal_autocheckpoint = 1');
141
- return database;
142
- }
143
128
  let OrchestrationConfigModule = OrchestrationConfigModule_1 = class OrchestrationConfigModule {
144
129
  static forRootAsync(options) {
145
130
  return {
@@ -176,7 +161,7 @@ let OrchestrationApiModule = OrchestrationApiModule_1 = class OrchestrationApiMo
176
161
  imports: [configModule],
177
162
  inject: [ModuleConfigProvider],
178
163
  useFactory: (config) => ({
179
- dialect: new SqliteDialect({ database: openStateDatabase(config) }),
164
+ dialect: config.dialect,
180
165
  }),
181
166
  }),
182
167
  EventEmitterModule.forRoot(),
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrationApi.module.js","sourceRoot":"","sources":["../src/orchestrationApi.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAkC,MAAM,EAAk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aAChB;YACD,WAAW;YACX,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,yBAAyB,EAAE;gBACjE,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE;gBAC9C,aAAa;gBACb,eAAe;gBACf,GAAG,YAAY;gBACf,GAAG,QAAQ;gBACX,GAAG,IAAI;aACR;YACD,OAAO,EAAE,CAAC,YAAY,CAAC;SACxB,CAAC;IACJ,CAAC;CACF,CAAA;AAlCY,sBAAsB;IADlC,MAAM,CAAC,EAAE,CAAC;GACE,sBAAsB,CAkClC"}
@@ -0,0 +1,5 @@
1
+ import type { DatabaseHooks } from './moduleConfig.js';
2
+ export declare function createPGliteDatabase(databasePath: string, statePath: string): Promise<{
3
+ dialect: import("kysely-pglite-dialect").PGliteDialect;
4
+ databaseHooks: DatabaseHooks;
5
+ }>;
package/dist/pglite.js ADDED
@@ -0,0 +1,59 @@
1
+ import { existsSync, openAsBlob } from 'node:fs';
2
+ import { rename, rm, writeFile } from 'node:fs/promises';
3
+ import { resolve } from 'node:path';
4
+ const CACHEDIR_TAG_FILE_NAME = 'CACHEDIR.TAG';
5
+ const CACHEDIR_TAG_CONTENTS = 'Signature: 8a477f597d28d172789f06886806bc55\n';
6
+ const STATE_DUMP_FILE_NAME = 'state.dump';
7
+ export async function createPGliteDatabase(databasePath, statePath) {
8
+ const { PGlite } = await import('@electric-sql/pglite');
9
+ const { PGliteDialect } = await import('kysely-pglite-dialect');
10
+ const nextDatabasePath = `${databasePath}.next`;
11
+ const previousDatabasePath = `${databasePath}.previous`;
12
+ if (!existsSync(databasePath) && existsSync(previousDatabasePath)) {
13
+ await rename(previousDatabasePath, databasePath);
14
+ }
15
+ let loadDataDir;
16
+ if (!existsSync(resolve(databasePath, 'PG_VERSION'))) {
17
+ const { dataDir } = await import('@electric-sql/pglite-prepopulatedfs');
18
+ loadDataDir = await dataDir();
19
+ }
20
+ let database = await PGlite.create({ dataDir: databasePath, loadDataDir });
21
+ await writeFile(resolve(databasePath, CACHEDIR_TAG_FILE_NAME), CACHEDIR_TAG_CONTENTS);
22
+ const client = {
23
+ query: (...args) => database.query(...args),
24
+ close: () => database.close(),
25
+ };
26
+ const databaseHooks = {
27
+ tagName: 'yucca.v1.stateDumpFileName',
28
+ async dump() {
29
+ const dump = await database.dumpDataDir('gzip');
30
+ await writeFile(resolve(statePath, STATE_DUMP_FILE_NAME), Buffer.from(await dump.arrayBuffer()));
31
+ return STATE_DUMP_FILE_NAME;
32
+ },
33
+ async cleanup() {
34
+ await rm(resolve(statePath, STATE_DUMP_FILE_NAME), { force: true });
35
+ },
36
+ async restore(fileName) {
37
+ await rm(nextDatabasePath, { recursive: true, force: true });
38
+ await rm(previousDatabasePath, { recursive: true, force: true });
39
+ const dump = await openAsBlob(resolve(statePath, fileName));
40
+ const next = await PGlite.create({ dataDir: nextDatabasePath, loadDataDir: dump });
41
+ await next.close();
42
+ await database.close();
43
+ try {
44
+ await rename(databasePath, previousDatabasePath);
45
+ await rename(nextDatabasePath, databasePath);
46
+ }
47
+ finally {
48
+ if (!existsSync(databasePath)) {
49
+ await rename(previousDatabasePath, databasePath);
50
+ }
51
+ database = await PGlite.create({ dataDir: databasePath });
52
+ }
53
+ await writeFile(resolve(databasePath, CACHEDIR_TAG_FILE_NAME), CACHEDIR_TAG_CONTENTS);
54
+ await rm(resolve(statePath, fileName), { force: true });
55
+ },
56
+ };
57
+ return { dialect: new PGliteDialect(client), databaseHooks };
58
+ }
59
+ //# sourceMappingURL=pglite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pglite.js","sourceRoot":"","sources":["../src/pglite.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,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AM,MAAM,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;gBACnD,CAAC;gBAED,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;YAC5D,CAAC;YAED,MAAM,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAAE,qBAAqB,CAAC,CAAC;YACtF,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;AAC/D,CAAC"}
@@ -6,7 +6,7 @@ export declare class BackendRepository {
6
6
  constructor(db: Kysely<DB>);
7
7
  updateBackend(id: string, configuration: BackendConfiguration): Promise<{
8
8
  id: string;
9
- configuration: string;
9
+ configuration: BackendConfiguration;
10
10
  }>;
11
11
  getBackends(): Promise<{
12
12
  id: string;
@@ -14,8 +14,8 @@ export declare class BackendRepository {
14
14
  backend: import("../backends/local.backend.js").LocalBackend | import("../backends/s3.backend.js").S3Backend | import("../backends/yucca.backend.js").YuccaBackend;
15
15
  }[]>;
16
16
  getBackend(id: string): Promise<{
17
+ backend: import("../backends/local.backend.js").LocalBackend | import("../backends/s3.backend.js").S3Backend | import("../backends/yucca.backend.js").YuccaBackend;
17
18
  id: string;
18
19
  configuration: BackendConfiguration;
19
- backend: import("../backends/local.backend.js").LocalBackend | import("../backends/s3.backend.js").S3Backend | import("../backends/yucca.backend.js").YuccaBackend;
20
20
  } | undefined>;
21
21
  }
@@ -21,34 +21,23 @@ let BackendRepository = class BackendRepository {
21
21
  }
22
22
  async updateBackend(id, configuration) {
23
23
  return await this.db
24
- .insertInto('backends')
25
- .values({
26
- id,
27
- configuration: JSON.stringify(configuration),
28
- })
29
- .onConflict((oc) => oc.doUpdateSet({ configuration: JSON.stringify(configuration) }))
24
+ .insertInto('futo_backups_backends')
25
+ .values({ id, configuration })
26
+ .onConflict((oc) => oc.column('id').doUpdateSet({ configuration }))
30
27
  .returningAll()
31
28
  .executeTakeFirstOrThrow();
32
29
  }
33
30
  async getBackends() {
34
- const backends = await this.db.selectFrom('backends').selectAll('backends').execute();
35
- return backends
36
- .map(({ id, configuration }) => ({
37
- id,
38
- configuration: JSON.parse(configuration),
39
- }))
40
- .map(({ id, configuration }) => ({ id, configuration, backend: createBackend(configuration) }));
31
+ const backends = await this.db.selectFrom('futo_backups_backends').selectAll().execute();
32
+ return backends.map(({ id, configuration }) => ({ id, configuration, backend: createBackend(configuration) }));
41
33
  }
42
34
  async getBackend(id) {
43
- const backend = await this.db.selectFrom('backends').selectAll('backends').where('id', '=', id).executeTakeFirst();
44
- if (backend) {
45
- const configuration = JSON.parse(backend.configuration);
46
- return {
47
- id: backend.id,
48
- configuration,
49
- backend: createBackend(configuration),
50
- };
51
- }
35
+ const backend = await this.db
36
+ .selectFrom('futo_backups_backends')
37
+ .selectAll()
38
+ .where('id', '=', id)
39
+ .executeTakeFirst();
40
+ return backend && { ...backend, backend: createBackend(backend.configuration) };
52
41
  }
53
42
  };
54
43
  BackendRepository = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"backend.repository.js","sourceRoot":"","sources":["../../src/repositories/backend.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKtD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACsB;IAAlD,YAAkD,EAAc;QAAd,OAAE,GAAF,EAAE,CAAY;IAAG,CAAC;IAEpE,KAAK,CAAC,aAAa,CAAC,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EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IACjH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE;aAC1B,UAAU,CAAC,uBAAuB,CAAC;aACnC,SAAS,EAAE;aACX,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;aACpB,gBAAgB,EAAE,CAAC;QAEtB,OAAO,OAAO,IAAI,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;IAClF,CAAC;CACF,CAAA;AA1BY,iBAAiB;IAD7B,UAAU,EAAE;IAEE,WAAA,YAAY,CAAC,cAAc,CAAC,CAAA;qCAAa,MAAM;GADjD,iBAAiB,CA0B7B"}
@@ -26,7 +26,6 @@ export declare class ConfigRepository {
26
26
  private assertStateIsEmpty;
27
27
  private recordStatePath;
28
28
  private set;
29
- private setAll;
30
29
  private get;
31
30
  private getOptional;
32
31
  private has;
@@ -43,12 +42,16 @@ export declare class ConfigRepository {
43
42
  hasIgnoredImmichDatabaseDumpWarning(): Promise<boolean>;
44
43
  ignoreImmichDatabaseDumpWarning(): Promise<void>;
45
44
  hasRestoreAwaitingContinue(): Promise<boolean>;
46
- setRestoreAwaitingContinue(): Promise<void>;
45
+ getRestoreAwaitingContinue(): Promise<{
46
+ isAwaiting: boolean;
47
+ databaseRestored?: boolean;
48
+ } | undefined>;
49
+ setRestoreAwaitingContinue(databaseRestored: boolean): Promise<void>;
47
50
  clearRestoreAwaitingContinue(): Promise<void>;
48
51
  hasSessionSecret(): Promise<boolean>;
49
52
  getSessionSecret(): Promise<Buffer>;
50
53
  getThrottle(): Promise<ResticProxyThrottle | undefined>;
51
- setThrottle({ bytesPerSec, quietHours }: ResticProxyThrottle): Promise<void>;
54
+ setThrottle(throttle: ResticProxyThrottle): Promise<void>;
52
55
  getSupportMode(): Promise<SupportModeSettings>;
53
56
  setSupportMode(settings: SupportModeSettings): Promise<void>;
54
57
  consumeSupportModeRun(): Promise<SupportModeSettings | undefined>;
@@ -17,12 +17,12 @@ import { InjectKysely } from 'nestjs-kysely';
17
17
  import { randomBytes } from 'node:crypto';
18
18
  import { availableParallelism } from 'node:os';
19
19
  import { resolve } from 'node:path';
20
- import { ConfigurationKey } from '../enum.js';
20
+ import { ConfigurationKey, TelemetryLevel } from '../enum.js';
21
21
  import { ModuleConfigProvider } from '../moduleConfig.js';
22
22
  import { yuccaWellKnown } from '../wellKnown.js';
23
23
  import { LoggingRepository } from './logging.repository.js';
24
24
  const SUPPORT_MODE_OFF = { remainingRuns: 0, streamToFuto: false, includePaths: false };
25
- const parseSupportMode = (value) => value ? { ...SUPPORT_MODE_OFF, ...JSON.parse(value) } : SUPPORT_MODE_OFF;
25
+ const parseSupportMode = (value) => value ? { ...SUPPORT_MODE_OFF, ...value } : SUPPORT_MODE_OFF;
26
26
  let ConfigRepository = ConfigRepository_1 = class ConfigRepository {
27
27
  db;
28
28
  moduleConfig;
@@ -39,26 +39,26 @@ let ConfigRepository = ConfigRepository_1 = class ConfigRepository {
39
39
  if (!hasKey) {
40
40
  await this.assertStateIsEmpty(statePath);
41
41
  this.logger.warn(`Generating a new master encryption key for the state in ${statePath}. Backups written with a previous key cannot be decrypted with this one.`);
42
- await this.set(ConfigurationKey.EncryptionKey, randomBytes(32).toString('hex'));
42
+ await this.set(ConfigurationKey.EncryptionKey, { key: randomBytes(32).toString('hex') });
43
43
  }
44
44
  await this.recordStatePath(statePath);
45
45
  const hasSecret = await this.hasSessionSecret();
46
46
  if (!hasSecret) {
47
- await this.set(ConfigurationKey.SessionSecret, randomBytes(32).toString('hex'));
47
+ await this.set(ConfigurationKey.SessionSecret, { secret: randomBytes(32).toString('hex') });
48
48
  }
49
49
  }
50
50
  async getStateSummary() {
51
51
  const [{ backends }] = await this.db
52
- .selectFrom('backends')
52
+ .selectFrom('futo_backups_backends')
53
53
  .select((eb) => eb.fn.countAll().as('backends'))
54
54
  .execute();
55
55
  const [{ repositories }] = await this.db
56
- .selectFrom('repositories')
56
+ .selectFrom('futo_backups_repositories')
57
57
  .select((eb) => eb.fn.countAll().as('repositories'))
58
58
  .execute();
59
59
  const [{ activeSchedules }] = await this.db
60
- .selectFrom('schedules')
61
- .where('paused', '!=', 1)
60
+ .selectFrom('futo_backups_schedule')
61
+ .where('paused', '=', false)
62
62
  .select((eb) => eb.fn.countAll().as('activeSchedules'))
63
63
  .execute();
64
64
  return { backends, repositories, activeSchedules };
@@ -71,53 +71,52 @@ let ConfigRepository = ConfigRepository_1 = class ConfigRepository {
71
71
  throw new Error(`The state in ${statePath} has ${backends} backend(s) and ${repositories} repository(ies) but no master encryption key. Refusing to generate one, as that would make those backups undecryptable. Restore the original state database.`);
72
72
  }
73
73
  async recordStatePath(statePath) {
74
- const previous = await this.getOptional(ConfigurationKey.StatePath);
74
+ const recorded = await this.getOptional(ConfigurationKey.StatePath);
75
+ const previous = recorded?.path;
75
76
  if (previous === statePath) {
76
77
  return;
77
78
  }
78
79
  if (previous) {
79
80
  this.logger.warn(`The state database was created in ${previous} but is being opened from ${statePath}. If the original directory is still populated, two installations are now diverging.`);
80
81
  }
81
- await this.set(ConfigurationKey.StatePath, statePath);
82
+ await this.set(ConfigurationKey.StatePath, { path: statePath });
82
83
  }
83
84
  async set(key, value) {
84
- await this.setAll({ [key]: value });
85
- }
86
- async setAll(values) {
87
85
  await this.db
88
- .insertInto('config')
89
- .values(Object.entries(values).map(([key, value]) => ({ key, value })))
90
- .onConflict((oc) => oc.column('key').doUpdateSet((eb) => ({ value: eb.ref('excluded.value') })))
86
+ .insertInto('futo_backups_config')
87
+ .values({ key, value })
88
+ .onConflict((oc) => oc.column('key').doUpdateSet({ value }))
91
89
  .execute();
92
90
  }
93
91
  async get(key) {
94
92
  const { value } = await this.db
95
- .selectFrom('config')
96
- .where('config.key', '=', key)
97
- .select('config.value')
93
+ .selectFrom('futo_backups_config')
94
+ .where('key', '=', key)
95
+ .select('value')
98
96
  .executeTakeFirstOrThrow();
99
97
  return value;
100
98
  }
101
99
  async getOptional(key) {
102
100
  const row = await this.db
103
- .selectFrom('config')
104
- .where('config.key', '=', key)
105
- .select('config.value')
101
+ .selectFrom('futo_backups_config')
102
+ .where('key', '=', key)
103
+ .select('value')
106
104
  .executeTakeFirst();
107
105
  return row?.value;
108
106
  }
109
107
  async has(key) {
110
- const results = await this.db.selectFrom('config').where('config.key', '=', key).selectAll().execute();
111
- return results.length > 0;
108
+ const row = await this.db.selectFrom('futo_backups_config').where('key', '=', key).select('key').executeTakeFirst();
109
+ return !!row;
112
110
  }
113
111
  async hasEncryptionKey() {
114
112
  return this.has(ConfigurationKey.EncryptionKey);
115
113
  }
116
114
  async getMasterEncryptionKey() {
117
- return await this.get(ConfigurationKey.EncryptionKey);
115
+ const { key } = await this.get(ConfigurationKey.EncryptionKey);
116
+ return key;
118
117
  }
119
118
  async deriveEncryptionKey(info) {
120
- const encryptionKey = await this.get(ConfigurationKey.EncryptionKey);
119
+ const encryptionKey = await this.getMasterEncryptionKey();
121
120
  const masterKey = Buffer.from(encryptionKey, 'hex');
122
121
  const key = new Uint8Array(await crypto.subtle.deriveBits({
123
122
  name: 'HKDF',
@@ -128,82 +127,82 @@ let ConfigRepository = ConfigRepository_1 = class ConfigRepository {
128
127
  return key;
129
128
  }
130
129
  async importEncryptionKey(key) {
131
- await this.set(ConfigurationKey.EncryptionKey, key);
130
+ await this.set(ConfigurationKey.EncryptionKey, { key });
132
131
  }
133
132
  async hasOnboardedKey() {
134
133
  return this.has(ConfigurationKey.OnboardedKey);
135
134
  }
136
135
  async confirmKeyOnboarded() {
137
- return this.set(ConfigurationKey.OnboardedKey, '1');
136
+ return this.set(ConfigurationKey.OnboardedKey, { isOnboarded: true });
138
137
  }
139
138
  async hasTelemetry() {
140
139
  return this.has(ConfigurationKey.Telemetry);
141
140
  }
142
141
  async enableTelemetry() {
143
- return this.set(ConfigurationKey.Telemetry, 'full');
142
+ return this.set(ConfigurationKey.Telemetry, { level: TelemetryLevel.Full });
144
143
  }
145
144
  async hasSkippedExtraConfig() {
146
145
  return this.has(ConfigurationKey.SkippedOnboardingExtraConfig);
147
146
  }
148
147
  async skipExtraConfig() {
149
- return this.set(ConfigurationKey.SkippedOnboardingExtraConfig, '1');
148
+ return this.set(ConfigurationKey.SkippedOnboardingExtraConfig, { isSkipped: true });
150
149
  }
151
150
  async hasIgnoredImmichDatabaseDumpWarning() {
152
151
  return this.has(ConfigurationKey.IgnoredImmichDatabaseDumpWarning);
153
152
  }
154
153
  async ignoreImmichDatabaseDumpWarning() {
155
- return this.set(ConfigurationKey.IgnoredImmichDatabaseDumpWarning, '1');
154
+ return this.set(ConfigurationKey.IgnoredImmichDatabaseDumpWarning, { isIgnored: true });
156
155
  }
157
156
  async hasRestoreAwaitingContinue() {
158
157
  return this.has(ConfigurationKey.RestoreAwaitingContinue);
159
158
  }
160
- async setRestoreAwaitingContinue() {
161
- return this.set(ConfigurationKey.RestoreAwaitingContinue, '1');
159
+ async getRestoreAwaitingContinue() {
160
+ return this.getOptional(ConfigurationKey.RestoreAwaitingContinue);
161
+ }
162
+ async setRestoreAwaitingContinue(databaseRestored) {
163
+ return this.set(ConfigurationKey.RestoreAwaitingContinue, { isAwaiting: true, databaseRestored });
162
164
  }
163
165
  async clearRestoreAwaitingContinue() {
164
- await this.db.deleteFrom('config').where('config.key', '=', ConfigurationKey.RestoreAwaitingContinue).execute();
166
+ await this.db
167
+ .deleteFrom('futo_backups_config')
168
+ .where('key', '=', ConfigurationKey.RestoreAwaitingContinue)
169
+ .execute();
165
170
  }
166
171
  async hasSessionSecret() {
167
172
  return this.has(ConfigurationKey.SessionSecret);
168
173
  }
169
174
  async getSessionSecret() {
170
- return Buffer.from(await this.get(ConfigurationKey.SessionSecret), 'hex');
175
+ const { secret } = await this.get(ConfigurationKey.SessionSecret);
176
+ return Buffer.from(secret, 'hex');
171
177
  }
172
- async getThrottle() {
173
- const bytesPerSec = await this.getOptional(ConfigurationKey.ThrottleBytesPerSec);
174
- if (bytesPerSec === undefined) {
175
- return;
176
- }
177
- const quietHours = await this.getOptional(ConfigurationKey.ThrottleQuietHours);
178
- return { bytesPerSec: Number.parseInt(bytesPerSec), quietHours: quietHours || undefined };
178
+ getThrottle() {
179
+ return this.getOptional(ConfigurationKey.Throttle);
179
180
  }
180
- async setThrottle({ bytesPerSec, quietHours }) {
181
- await this.setAll({
182
- [ConfigurationKey.ThrottleBytesPerSec]: String(bytesPerSec),
183
- [ConfigurationKey.ThrottleQuietHours]: quietHours ?? '',
184
- });
181
+ async setThrottle(throttle) {
182
+ await this.set(ConfigurationKey.Throttle, throttle);
185
183
  }
186
184
  async getSupportMode() {
187
185
  return parseSupportMode(await this.getOptional(ConfigurationKey.SupportMode));
188
186
  }
189
187
  async setSupportMode(settings) {
190
- await this.set(ConfigurationKey.SupportMode, JSON.stringify(settings));
188
+ await this.set(ConfigurationKey.SupportMode, settings);
191
189
  }
192
190
  async consumeSupportModeRun() {
193
191
  return this.db.transaction().execute(async (trx) => {
194
192
  const row = await trx
195
- .selectFrom('config')
196
- .where('config.key', '=', ConfigurationKey.SupportMode)
197
- .select('config.value')
193
+ .selectFrom('futo_backups_config')
194
+ .where('key', '=', ConfigurationKey.SupportMode)
195
+ .select('value')
196
+ .forUpdate()
198
197
  .executeTakeFirst();
199
198
  const settings = parseSupportMode(row?.value);
200
199
  if (settings.remainingRuns <= 0) {
201
200
  return;
202
201
  }
203
202
  await trx
204
- .updateTable('config')
205
- .set({ value: JSON.stringify({ ...settings, remainingRuns: settings.remainingRuns - 1 }) })
206
- .where('config.key', '=', ConfigurationKey.SupportMode)
203
+ .updateTable('futo_backups_config')
204
+ .set({ value: { ...settings, remainingRuns: settings.remainingRuns - 1 } })
205
+ .where('key', '=', ConfigurationKey.SupportMode)
207
206
  .execute();
208
207
  return settings;
209
208
  });
@@ -213,9 +212,11 @@ let ConfigRepository = ConfigRepository_1 = class ConfigRepository {
213
212
  const clusterCode = placement.storageClusterCode ?? undefined;
214
213
  const cores = availableParallelism();
215
214
  const override = await this.getOptional(ConfigurationKey.ResticOptionRestConnections);
216
- const connections = override
217
- ? Number.parseInt(override)
218
- : ((await yuccaWellKnown.getConnections(cores, siteCode, clusterCode)) ?? cores);
215
+ let connections = override?.connections;
216
+ if (!connections) {
217
+ const wellKnownConnections = await yuccaWellKnown.getConnections(cores, siteCode, clusterCode);
218
+ connections = wellKnownConnections ?? cores;
219
+ }
219
220
  return { connections, packSizeMib: await yuccaWellKnown.getPackSizeMib(siteCode, clusterCode) };
220
221
  }
221
222
  };