• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger-identus / sdk-ts / 15879559936

25 Jun 2025 02:45PM UTC coverage: 72.405% (-3.8%) from 76.16%
15879559936

push

github

web-flow
fix: db improvements and inference (#442)

Signed-off-by: Francisco Javier Ribo Labrador <elribonazo@gmail.com>

1320 of 2008 branches covered (65.74%)

Branch coverage included in aggregate %.

13 of 14 new or added lines in 4 files covered. (92.86%)

162 existing lines in 12 files now uncovered.

3054 of 4033 relevant lines covered (75.73%)

44.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.65
/src/pluto/backup/BackupManager.ts
1
import * as Domain from "../../domain";
2
import * as Versions from "./versions";
3
import { Pluto } from "../Pluto";
4
import { PlutoRepositories } from "../repositories";
5
import { isEmpty } from "../../utils";
6
import { IBackupTask, IRestoreTask } from "./versions/interfaces";
7
import { Version } from "../../domain/backup";
8

9
/**
10
 * BackupManager
11
 * handle the different versions of backup and restore
12
 */
13
export class BackupManager {
14
  constructor(
15
    private readonly Pluto: Pluto,
99✔
16
    private readonly Repositories: PlutoRepositories
99✔
17
  ) {}
18

19
  /**
20
   * convert stored data to JSON
21
   * 
22
   * @param version - backup schema version
23
   * @returns {Promise<Domain.Backup.Schema>}
24
   */
25
  backup(version?: Version) {
UNCOV
26
    const task = this.getBackupTask(version);
×
UNCOV
27
    return task.run();
×
28
  }
29

30
  /**
31
   * convert JSON to stored data
32
   * 
33
   * @param backup 
34
   */
35
  async restore(backup: Domain.Backup.Schema) {
36
    await this.assertStoreIsEmpty();
6✔
37
    const task = this.getRestoreTask(backup);
6✔
38
    await task.run();
6✔
39
  }
40

41
  private getBackupTask(version: Version = Domain.Backup.defaultVersion): IBackupTask {
×
UNCOV
42
    switch (version) {
×
43
      case "0.0.1":
UNCOV
44
        return new Versions.v0_0_1.BackupTask(this.Pluto, this.Repositories);
×
45
    }
46

47
    throw new Domain.PlutoError.BackupNotFoundError();
×
48
  }
49

50
  private getRestoreTask(backup: Domain.Backup.Schema): IRestoreTask {
51
    const version = backup.version ?? Domain.Backup.defaultVersion;
6!
52
    switch (version) {
6✔
53
      case "0.0.1":
54
        return new Versions.v0_0_1.RestoreTask(this.Pluto, backup);
6✔
55
    }
56

57
    throw new Domain.PlutoError.RestoreNotFoundError();
×
58
  }
59

60
  private async assertStoreIsEmpty() {
61
    const credentials = await this.Repositories.Credentials.getModels();
6✔
62
    const dids = await this.Repositories.DIDs.getModels();
6✔
63
    const keys = await this.Repositories.Keys.getModels();
6✔
64
    const link_secret = await this.Repositories.LinkSecrets.getModels();
6✔
65
    const messages = await this.Repositories.Messages.getModels();
6✔
66

67
    if (
6!
68
      isEmpty(credentials) &&
30✔
69
      isEmpty(dids) &&
70
      isEmpty(keys) &&
71
      isEmpty(link_secret) &&
72
      isEmpty(messages)
73
    ) {
74
      return true;
6✔
75
    }
76

UNCOV
77
    throw new Domain.PlutoError.StoreNotEmptyError();
×
78
  }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc