kourou 0.24.2 → 0.25.0

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 (132) hide show
  1. package/README.md +98 -12
  2. package/lib/commands/api-key/check.d.ts +3 -3
  3. package/lib/commands/api-key/check.js +5 -7
  4. package/lib/commands/api-key/create.d.ts +3 -3
  5. package/lib/commands/api-key/create.js +8 -10
  6. package/lib/commands/api-key/delete.d.ts +3 -3
  7. package/lib/commands/api-key/delete.js +4 -6
  8. package/lib/commands/api-key/search.d.ts +3 -3
  9. package/lib/commands/api-key/search.js +5 -7
  10. package/lib/commands/app/debug-proxy.d.ts +3 -3
  11. package/lib/commands/app/debug-proxy.js +57 -55
  12. package/lib/commands/app/doctor.d.ts +24 -0
  13. package/lib/commands/app/doctor.js +201 -0
  14. package/lib/commands/app/scaffold.d.ts +2 -2
  15. package/lib/commands/app/scaffold.js +20 -15
  16. package/lib/commands/app/start-services.d.ts +1 -1
  17. package/lib/commands/app/start-services.js +26 -26
  18. package/lib/commands/collection/create.d.ts +3 -3
  19. package/lib/commands/collection/create.js +9 -6
  20. package/lib/commands/collection/export.d.ts +5 -5
  21. package/lib/commands/collection/export.js +25 -26
  22. package/lib/commands/collection/import.d.ts +5 -5
  23. package/lib/commands/collection/import.js +17 -17
  24. package/lib/commands/collection/migrate.d.ts +27 -0
  25. package/lib/commands/collection/migrate.js +43 -0
  26. package/lib/commands/config/diff.d.ts +1 -1
  27. package/lib/commands/config/diff.js +27 -21
  28. package/lib/commands/document/search.d.ts +3 -3
  29. package/lib/commands/document/search.js +20 -20
  30. package/lib/commands/es/aliases/cat.d.ts +12 -0
  31. package/lib/commands/es/aliases/cat.js +36 -0
  32. package/lib/commands/es/indices/cat.d.ts +2 -2
  33. package/lib/commands/es/indices/cat.js +8 -8
  34. package/lib/commands/es/indices/get.d.ts +2 -2
  35. package/lib/commands/es/indices/get.js +7 -7
  36. package/lib/commands/es/indices/insert.d.ts +2 -2
  37. package/lib/commands/es/indices/insert.js +9 -9
  38. package/lib/commands/es/migrate.d.ts +10 -8
  39. package/lib/commands/es/migrate.js +86 -82
  40. package/lib/commands/es/snapshot/create-repository.d.ts +2 -2
  41. package/lib/commands/es/snapshot/create-repository.js +16 -12
  42. package/lib/commands/es/snapshot/create.d.ts +2 -2
  43. package/lib/commands/es/snapshot/create.js +7 -7
  44. package/lib/commands/es/snapshot/list.d.ts +2 -2
  45. package/lib/commands/es/snapshot/list.js +12 -8
  46. package/lib/commands/file/decrypt.d.ts +4 -4
  47. package/lib/commands/file/decrypt.js +21 -21
  48. package/lib/commands/file/encrypt.d.ts +4 -4
  49. package/lib/commands/file/encrypt.js +20 -22
  50. package/lib/commands/file/test.d.ts +3 -3
  51. package/lib/commands/file/test.js +13 -13
  52. package/lib/commands/import.d.ts +5 -5
  53. package/lib/commands/import.js +39 -28
  54. package/lib/commands/index/export.d.ts +5 -4
  55. package/lib/commands/index/export.js +21 -19
  56. package/lib/commands/index/import.d.ts +5 -5
  57. package/lib/commands/index/import.js +21 -19
  58. package/lib/commands/instance/kill.d.ts +2 -2
  59. package/lib/commands/instance/kill.js +34 -34
  60. package/lib/commands/instance/list.d.ts +1 -1
  61. package/lib/commands/instance/list.js +33 -30
  62. package/lib/commands/instance/logs.d.ts +2 -2
  63. package/lib/commands/instance/logs.js +26 -22
  64. package/lib/commands/instance/spawn.d.ts +2 -2
  65. package/lib/commands/instance/spawn.js +46 -40
  66. package/lib/commands/paas/deploy.d.ts +2 -2
  67. package/lib/commands/paas/deploy.js +33 -21
  68. package/lib/commands/paas/init.d.ts +1 -1
  69. package/lib/commands/paas/init.js +10 -6
  70. package/lib/commands/paas/login.d.ts +3 -3
  71. package/lib/commands/paas/login.js +30 -19
  72. package/lib/commands/paas/logs.d.ts +27 -0
  73. package/lib/commands/paas/logs.js +137 -18
  74. package/lib/commands/profile/export.d.ts +3 -3
  75. package/lib/commands/profile/export.js +12 -12
  76. package/lib/commands/profile/import.d.ts +3 -3
  77. package/lib/commands/profile/import.js +6 -8
  78. package/lib/commands/realtime/subscribe.d.ts +3 -3
  79. package/lib/commands/realtime/subscribe.js +25 -25
  80. package/lib/commands/redis/list-keys.d.ts +3 -3
  81. package/lib/commands/redis/list-keys.js +15 -11
  82. package/lib/commands/role/export.d.ts +3 -3
  83. package/lib/commands/role/export.js +11 -11
  84. package/lib/commands/role/import.d.ts +4 -4
  85. package/lib/commands/role/import.js +10 -12
  86. package/lib/commands/sdk/execute.d.ts +5 -5
  87. package/lib/commands/sdk/execute.js +23 -19
  88. package/lib/commands/sdk/query.d.ts +5 -4
  89. package/lib/commands/sdk/query.js +30 -24
  90. package/lib/commands/user/export-mappings.d.ts +3 -3
  91. package/lib/commands/user/export-mappings.js +11 -11
  92. package/lib/commands/user/export.d.ts +6 -6
  93. package/lib/commands/user/export.js +34 -33
  94. package/lib/commands/user/import-mappings.d.ts +3 -3
  95. package/lib/commands/user/import-mappings.js +7 -7
  96. package/lib/commands/user/import.d.ts +3 -3
  97. package/lib/commands/user/import.js +6 -8
  98. package/lib/commands/vault/add.d.ts +3 -3
  99. package/lib/commands/vault/add.js +27 -19
  100. package/lib/commands/vault/decrypt.d.ts +4 -4
  101. package/lib/commands/vault/decrypt.js +24 -20
  102. package/lib/commands/vault/encrypt.d.ts +4 -4
  103. package/lib/commands/vault/encrypt.js +24 -20
  104. package/lib/commands/vault/show.d.ts +3 -3
  105. package/lib/commands/vault/show.js +24 -20
  106. package/lib/commands/vault/test.d.ts +3 -3
  107. package/lib/commands/vault/test.js +16 -12
  108. package/lib/common.d.ts +3 -3
  109. package/lib/common.js +28 -29
  110. package/lib/hooks/command_not_found/api-action.d.ts +2 -2
  111. package/lib/hooks/command_not_found/api-action.js +20 -22
  112. package/lib/index.d.ts +1 -1
  113. package/lib/support/PaasKommand.d.ts +2 -2
  114. package/lib/support/PaasKommand.js +9 -9
  115. package/lib/support/dump-collection.js +50 -41
  116. package/lib/support/editor.js +12 -10
  117. package/lib/support/execute.d.ts +6 -1
  118. package/lib/support/execute.js +9 -8
  119. package/lib/support/kuzzle.d.ts +12 -4
  120. package/lib/support/kuzzle.js +65 -31
  121. package/lib/support/migrate/providers/elasticsearch.d.ts +16 -0
  122. package/lib/support/migrate/providers/elasticsearch.js +74 -0
  123. package/lib/support/migrate/providers/file.d.ts +15 -0
  124. package/lib/support/migrate/providers/file.js +74 -0
  125. package/lib/support/migrate/providers/index.d.ts +12 -0
  126. package/lib/support/migrate/providers/index.js +16 -0
  127. package/lib/support/migrate/types.d.ts +8 -0
  128. package/lib/support/migrate/types.js +2 -0
  129. package/lib/support/restore-collection.d.ts +2 -1
  130. package/lib/support/restore-collection.js +37 -26
  131. package/lib/support/restore-securities.js +22 -19
  132. package/package.json +16 -15
@@ -2,136 +2,140 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
- const elasticsearch_1 = require("@elastic/elasticsearch");
6
- const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
7
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
+ const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
7
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
8
+ const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
9
+ const fs_1 = require("fs");
9
10
  const common_1 = require("../../common");
11
+ const providers_1 = require("../../support/migrate/providers");
10
12
  class EsMigrate extends common_1.Kommand {
11
- async migrateMappings(index, src, dest) {
12
- const { body } = await src.indices.getMapping({ index });
13
- const mappings = body[index];
14
- await dest.indices.create({ index, body: { mappings: mappings.mappings } });
13
+ constructor() {
14
+ super(...arguments);
15
+ this.src = undefined;
16
+ this.dest = undefined;
15
17
  }
16
- async migrateData(index, batch_size, src, dest) {
17
- const queue = [];
18
- const { body } = await src.search({
19
- index,
20
- scroll: this.flags.scroll,
21
- size: batch_size,
22
- body: {
23
- query: {
24
- match_all: {}
25
- }
18
+ async detectProviderType(provider) {
19
+ if ((0, providers_1.isURL)(provider)) {
20
+ return new providers_1.Elasticsearch(provider, {
21
+ batchSize: this.flags["batch-size"],
22
+ scrollDuration: this.flags.scroll,
23
+ });
24
+ }
25
+ else if (path_1.default.basename(provider)) {
26
+ if (!(0, providers_1.fileExists)(provider)) {
27
+ await fs_1.promises.mkdir(provider, { recursive: true });
26
28
  }
29
+ return new providers_1.File(provider);
30
+ }
31
+ else {
32
+ throw new Error(`Unknown provider type: ${provider}. You should provide either an Elasticsearch URL or a file path.`);
33
+ }
34
+ }
35
+ async migrateIndex(index) {
36
+ const indexDefinition = await this.src.getIndex(index);
37
+ await this.dest.createIndex(index, indexDefinition);
38
+ return;
39
+ }
40
+ async migrateData(index) {
41
+ const queue = [];
42
+ let documents;
43
+ const data = await this.src.readData(index);
44
+ const scrollId = data.scrollId;
45
+ const total = data.total;
46
+ documents = data.documents;
47
+ const progressBar = cli_ux_1.default.progress({
48
+ format: chalk_1.default.blue(" [*] Importing |{bar}| {percentage}% || {value}/{total} documents"),
27
49
  });
28
- const scrollId = body._scroll_id;
29
- const total = body.hits.total.value;
30
- if (total === 0) {
31
- return 0;
50
+ if (total) {
51
+ progressBar.start(total, 0);
32
52
  }
33
- const progressBar = cli_ux_1.default.progress({ format: chalk_1.default.blue(' [*] Importing |{bar}| {percentage}% || {value}/{total} documents') });
34
- progressBar.start(total, 0);
53
+ queue.push(documents);
35
54
  let count = 0;
36
- queue.push(body.hits);
37
55
  while (queue.length && total !== count) {
38
- const { hits: docs } = queue.pop();
39
- const bulk = [];
40
- for (const doc of docs) {
41
- bulk.push({ index: { _index: index, _id: doc._id } });
42
- bulk.push(doc._source);
43
- count++;
44
- }
45
- await dest.bulk({ body: bulk });
56
+ documents = queue.pop();
57
+ count += await this.dest.writeData(index, documents);
46
58
  progressBar.update(count);
47
- const { body: { hits } } = await src.scroll({
48
- scroll_id: scrollId,
49
- scroll: this.flags.scroll
50
- });
51
- queue.push(hits);
59
+ queue.push(await this.src.readData(index, { scrollId }));
52
60
  }
53
61
  progressBar.stop();
54
62
  return total;
55
63
  }
56
- async runMigrate(index, src, dest) {
64
+ async runMigrate(index) {
57
65
  this.logInfo(`Importing ${chalk_1.default.bold(index)} to ${chalk_1.default.bold(this.flags.dest)}`);
58
- await this.migrateMappings(index, src, dest);
59
- this.logOk('Mappings successfully imported!');
60
- const count = await this.migrateData(index, this.flags['batch-size'], src, dest);
66
+ await this.migrateIndex(index);
67
+ this.logOk("Mappings successfully imported!");
68
+ const count = await this.migrateData(index);
61
69
  if (count === 0) {
62
- this.logInfo('No documents to import\n');
70
+ this.logInfo("No documents to import\n");
63
71
  }
64
72
  else {
65
73
  this.logOk(`${chalk_1.default.bold(count)} document(s) imported!\n`);
66
74
  }
67
75
  }
68
76
  async runSafe() {
69
- const src = new elasticsearch_1.Client({ node: this.flags.src });
70
- const dest = new elasticsearch_1.Client({ node: this.flags.dest });
71
- if (this.flags.reset && !this.flags['no-interactive']) {
72
- this.log(chalk_1.default.red(`${node_emoji_1.default.get('fire')} Are you sure you want to reset ${chalk_1.default.bold(this.flags.dest)}?`));
73
- await cli_ux_1.default.confirm(chalk_1.default.redBright(` ${node_emoji_1.default.get('fire')} You will lose all the data stored in it (Type "yes" to confirm)`));
74
- await dest.indices.delete({ index: '_all' });
77
+ this.src = await this.detectProviderType(this.flags.src);
78
+ this.dest = await this.detectProviderType(this.flags.dest);
79
+ if (this.flags.reset) {
80
+ if (!this.flags["no-interactive"]) {
81
+ this.log(chalk_1.default.red(`${node_emoji_1.default.get("fire")} Are you sure you want to reset ${chalk_1.default.bold(this.flags.dest)}?`));
82
+ await cli_ux_1.default.confirm(chalk_1.default.redBright(` ${node_emoji_1.default.get("fire")} You will lose all the data stored in it (Type "yes" to confirm)`));
83
+ }
84
+ await this.dest.clear();
75
85
  }
76
86
  this.logInfo(`Fetching indices list from ${chalk_1.default.bold(this.flags.src)}`);
77
- const srcBody = await src.cat.indices({ format: 'json' });
78
- const srcIndices = srcBody.body
79
- .map(({ index }) => index)
80
- .filter((index) => index.match(this.flags.pattern))
81
- .sort();
82
- this.logOk(`Found ${chalk_1.default.bold(srcIndices.length)} indices in the source Elasticsearch server\n`);
83
- if (this.flags['dry-run']) {
87
+ const srcIndices = await this.src.listIndices(this.flags.pattern);
88
+ if (this.flags["dry-run"]) {
84
89
  this.log(`${chalk_1.default.bold(srcIndices)}`);
85
90
  this.logInfo(`${chalk_1.default.bold(srcIndices.length)} indices will be migrated`);
91
+ return;
86
92
  }
87
- else {
88
- this.logInfo(`Starting indices migration from ${chalk_1.default.bold(this.flags.src)} to ${chalk_1.default.bold(this.flags.dest)}`);
89
- for (const index of srcIndices) {
90
- await this.runMigrate(index, src, dest);
91
- }
93
+ this.logInfo(`Starting indices migration from ${chalk_1.default.bold(this.flags.src)} to ${chalk_1.default.bold(this.flags.dest)}`);
94
+ for (const index of srcIndices) {
95
+ await this.runMigrate(index);
92
96
  }
93
97
  }
94
98
  }
95
99
  exports.default = EsMigrate;
96
100
  EsMigrate.initSdk = false;
97
- EsMigrate.description = 'Migrate all the index from one Elasticsearch server to another';
101
+ EsMigrate.description = "Migrate all the index from an Elasticsearch (or a file) to another Elasticsearch";
98
102
  EsMigrate.flags = {
99
103
  help: command_1.flags.help(),
100
104
  src: command_1.flags.string({
101
- description: 'Source Elasticsearch server URL',
102
- env: 'KUZZLE_ES_SRC',
103
- required: true
105
+ description: "Migration source provider",
106
+ env: "KUZZLE_MIGRATION_SRC",
107
+ required: true,
104
108
  }),
105
109
  dest: command_1.flags.string({
106
- description: 'Destination Elasticsearch server URL',
107
- env: 'KUZZLE_ES_DEST',
108
- required: true
110
+ description: "Migration destination provider",
111
+ env: "KUZZLE_MIGRATION_DEST",
112
+ required: true,
109
113
  }),
110
114
  reset: command_1.flags.boolean({
111
- description: 'Reset destination Elasticsearch server',
115
+ description: "Reset destination Elasticsearch server",
112
116
  default: false,
113
117
  }),
114
- 'batch-size': command_1.flags.integer({
115
- description: 'How many documents to move in batch per operation',
118
+ "batch-size": command_1.flags.integer({
119
+ description: "How many documents to move in batch per operation",
116
120
  default: 1000,
117
121
  }),
118
- 'no-interactive': command_1.flags.boolean({
119
- description: 'Skip confirmation interactive prompts (perfect for scripting)',
122
+ "no-interactive": command_1.flags.boolean({
123
+ description: "Skip confirmation interactive prompts (perfect for scripting)",
120
124
  default: false,
121
125
  }),
122
- 'dry-run': command_1.flags.boolean({
123
- description: 'Print witch collections will be migrated',
126
+ "dry-run": command_1.flags.boolean({
127
+ description: "Print witch collections will be migrated",
124
128
  default: false,
125
129
  }),
126
- 'pattern': command_1.flags.string({
127
- description: 'Pattern to match indices to migrate'
130
+ pattern: command_1.flags.string({
131
+ description: "Pattern to match indices to migrate",
128
132
  }),
129
- 'scroll': command_1.flags.string({
130
- description: 'Scroll duration for Elasticsearch scrolling',
131
- default: '30s'
133
+ scroll: command_1.flags.string({
134
+ description: "Scroll duration for Elasticsearch scrolling",
135
+ default: "30s",
132
136
  }),
133
137
  };
134
138
  EsMigrate.examples = [
135
- 'kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000',
136
- 'kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000 --no-interactive'
139
+ "kourou es:migrate --src http://elasticsearch:9200 --dest ./my-backup --batch-size 2000 --pattern '&myindexes.collection-*'",
140
+ "kourou es:migrate --src ./my-backup --dest http://elasticsearch:9200 --reset --batch-size 2000 --no-interactive",
137
141
  ];
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../../common";
3
3
  export default class EsSnapshotsCreateRepository extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
@@ -10,12 +10,12 @@ class EsSnapshotsCreateRepository extends common_1.Kommand {
10
10
  repository: this.args.repository,
11
11
  verify: true,
12
12
  body: {
13
- type: 'fs',
13
+ type: "fs",
14
14
  settings: {
15
15
  location: this.args.location,
16
- compress: this.flags.compress
17
- }
18
- }
16
+ compress: this.flags.compress,
17
+ },
18
+ },
19
19
  };
20
20
  const response = await esClient.snapshot.createRepository(esRequest);
21
21
  this.logOk(`Success ${JSON.stringify(response.body)}`);
@@ -23,20 +23,24 @@ class EsSnapshotsCreateRepository extends common_1.Kommand {
23
23
  }
24
24
  exports.default = EsSnapshotsCreateRepository;
25
25
  EsSnapshotsCreateRepository.initSdk = false;
26
- EsSnapshotsCreateRepository.description = 'Create a FS snapshot repository inside an ES instance';
26
+ EsSnapshotsCreateRepository.description = "Create a FS snapshot repository inside an ES instance";
27
27
  EsSnapshotsCreateRepository.flags = {
28
28
  compress: command_1.flags.boolean({
29
- description: 'Compress data when storing them',
30
- default: false
29
+ description: "Compress data when storing them",
30
+ default: false,
31
31
  }),
32
32
  node: command_1.flags.string({
33
- char: 'n',
34
- description: 'Elasticsearch server URL',
35
- default: 'http://localhost:9200',
33
+ char: "n",
34
+ description: "Elasticsearch server URL",
35
+ default: "http://localhost:9200",
36
36
  }),
37
37
  help: command_1.flags.help(),
38
38
  };
39
39
  EsSnapshotsCreateRepository.args = [
40
- { name: 'repository', description: 'ES repository name', required: true },
41
- { name: 'location', description: 'ES snapshot repository location', required: true },
40
+ { name: "repository", description: "ES repository name", required: true },
41
+ {
42
+ name: "location",
43
+ description: "ES snapshot repository location",
44
+ required: true,
45
+ },
42
46
  ];
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../../common";
3
3
  export default class EsSnapshotsCreate extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
@@ -9,7 +9,7 @@ class EsSnapshotsCreate extends common_1.Kommand {
9
9
  const esRequest = {
10
10
  repository: this.args.repository,
11
11
  snapshot: this.args.name,
12
- body: {}
12
+ body: {},
13
13
  };
14
14
  const response = await esClient.snapshot.create(esRequest);
15
15
  this.logOk(`Success ${JSON.stringify(response.body)}`);
@@ -17,16 +17,16 @@ class EsSnapshotsCreate extends common_1.Kommand {
17
17
  }
18
18
  exports.default = EsSnapshotsCreate;
19
19
  EsSnapshotsCreate.initSdk = false;
20
- EsSnapshotsCreate.description = 'Create a snapshot repository inside an ES instance';
20
+ EsSnapshotsCreate.description = "Create a snapshot repository inside an ES instance";
21
21
  EsSnapshotsCreate.flags = {
22
22
  node: command_1.flags.string({
23
- char: 'n',
24
- description: 'Elasticsearch server URL',
25
- default: 'http://localhost:9200',
23
+ char: "n",
24
+ description: "Elasticsearch server URL",
25
+ default: "http://localhost:9200",
26
26
  }),
27
27
  help: command_1.flags.help(),
28
28
  };
29
29
  EsSnapshotsCreate.args = [
30
- { name: 'repository', description: 'ES repository name', required: true },
31
- { name: 'name', description: 'ES snapshot name', required: true },
30
+ { name: "repository", description: "ES repository name", required: true },
31
+ { name: "name", description: "ES snapshot name", required: true },
32
32
  ];
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../../common";
3
3
  export default class EsSnapshotsList extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
@@ -11,10 +11,10 @@ class EsSnapshotsList extends common_1.Kommand {
11
11
  ignore_unavailable: true,
12
12
  };
13
13
  const response = await esClient.cat.snapshots(esRequest);
14
- const snapshots = response.body.split('\n').filter(Boolean);
14
+ const snapshots = response.body.split("\n").filter(Boolean);
15
15
  const result = [];
16
16
  for (const snapshot of snapshots) {
17
- const snap = snapshot.split(' ').filter(Boolean);
17
+ const snap = snapshot.split(" ").filter(Boolean);
18
18
  result.push({
19
19
  name: snap[0],
20
20
  status: snap[1],
@@ -22,7 +22,7 @@ class EsSnapshotsList extends common_1.Kommand {
22
22
  hourStart: snap[3],
23
23
  timeStampEnd: snap[4],
24
24
  hourEnd: snap[5],
25
- duration: snap[6]
25
+ duration: snap[6],
26
26
  });
27
27
  }
28
28
  this.logOk(`Success: ${JSON.stringify(result, null, 2)}`);
@@ -30,15 +30,19 @@ class EsSnapshotsList extends common_1.Kommand {
30
30
  }
31
31
  exports.default = EsSnapshotsList;
32
32
  EsSnapshotsList.initSdk = false;
33
- EsSnapshotsList.description = 'List all snapshot from a repository acknowledge by an ES instance';
33
+ EsSnapshotsList.description = "List all snapshot from a repository acknowledge by an ES instance";
34
34
  EsSnapshotsList.flags = {
35
35
  node: command_1.flags.string({
36
- char: 'n',
37
- description: 'Elasticsearch server URL',
38
- default: 'http://localhost:9200',
36
+ char: "n",
37
+ description: "Elasticsearch server URL",
38
+ default: "http://localhost:9200",
39
39
  }),
40
40
  help: command_1.flags.help(),
41
41
  };
42
42
  EsSnapshotsList.args = [
43
- { name: 'repository', description: 'Name of repository from which to fetch the snapshot information', required: true },
43
+ {
44
+ name: "repository",
45
+ description: "Name of repository from which to fetch the snapshot information",
46
+ required: true,
47
+ },
44
48
  ];
@@ -1,13 +1,13 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class FileDecrypt extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
8
  force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- 'output-file': flags.IOptionFlag<string | undefined>;
10
- 'vault-key': flags.IOptionFlag<string | undefined>;
9
+ "output-file": flags.IOptionFlag<string | undefined>;
10
+ "vault-key": flags.IOptionFlag<string | undefined>;
11
11
  };
12
12
  static args: {
13
13
  name: string;
@@ -2,33 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileDecrypt = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
7
  const command_1 = require("@oclif/command");
8
8
  const kuzzle_vault_1 = require("kuzzle-vault");
9
9
  const common_1 = require("../../common");
10
10
  class FileDecrypt extends common_1.Kommand {
11
11
  async runSafe() {
12
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
13
- throw new Error('A vault key must be provided');
12
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
13
+ throw new Error("A vault key must be provided");
14
14
  }
15
15
  if (lodash_1.default.isEmpty(this.args.file)) {
16
- throw new Error('An encrypted file must be provided');
16
+ throw new Error("An encrypted file must be provided");
17
17
  }
18
- let outputFile = `${this.args.file.replace('.enc', '')}`;
19
- if (this.flags['output-file']) {
20
- outputFile = this.flags['output-file'];
18
+ let outputFile = `${this.args.file.replace(".enc", "")}`;
19
+ if (this.flags["output-file"]) {
20
+ outputFile = this.flags["output-file"];
21
21
  }
22
22
  if (fs_1.default.existsSync(outputFile) && !this.flags.force) {
23
23
  throw new Error(`Output file "${outputFile}" already exists. Use -f flag to overwrite it.`);
24
24
  }
25
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
25
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
26
26
  if (!fs_1.default.existsSync(this.args.file)) {
27
27
  throw new Error(`File "${this.args.file}" does not exist`);
28
28
  }
29
29
  let encryptedContent;
30
30
  try {
31
- encryptedContent = fs_1.default.readFileSync(this.args.file, 'utf8');
31
+ encryptedContent = fs_1.default.readFileSync(this.args.file, "utf8");
32
32
  }
33
33
  catch (error) {
34
34
  throw new Error(`Cannot read encrypted content from file "${this.args.file}": ${error.message}`);
@@ -40,25 +40,25 @@ class FileDecrypt extends common_1.Kommand {
40
40
  }
41
41
  exports.FileDecrypt = FileDecrypt;
42
42
  FileDecrypt.initSdk = false;
43
- FileDecrypt.description = 'Decrypts an encrypted file.';
43
+ FileDecrypt.description = "Decrypts an encrypted file.";
44
44
  FileDecrypt.examples = [
45
- 'kourou file:decrypt books/cryptonomicon.txt.enc --vault-key <vault-key>',
46
- 'kourou file:decrypt books/cryptonomicon.txt.enc -o books/cryptonomicon.txt --vault-key <vault-key>'
45
+ "kourou file:decrypt books/cryptonomicon.txt.enc --vault-key <vault-key>",
46
+ "kourou file:decrypt books/cryptonomicon.txt.enc -o books/cryptonomicon.txt --vault-key <vault-key>",
47
47
  ];
48
48
  FileDecrypt.flags = {
49
49
  force: command_1.flags.boolean({
50
- char: 'f',
51
- description: 'Overwrite the output file if it already exists'
50
+ char: "f",
51
+ description: "Overwrite the output file if it already exists",
52
52
  }),
53
- 'output-file': command_1.flags.string({
54
- char: 'o',
55
- description: 'Output file (default: remove ".enc")'
53
+ "output-file": command_1.flags.string({
54
+ char: "o",
55
+ description: 'Output file (default: remove ".enc")',
56
56
  }),
57
- 'vault-key': command_1.flags.string({
58
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
57
+ "vault-key": command_1.flags.string({
58
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
59
59
  default: process.env.KUZZLE_VAULT_KEY,
60
60
  }),
61
61
  };
62
62
  FileDecrypt.args = [
63
- { name: 'file', description: 'Encrypted file', required: true }
63
+ { name: "file", description: "Encrypted file", required: true },
64
64
  ];
@@ -1,13 +1,13 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class VaultEncrypt extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
8
  force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
- 'output-file': flags.IOptionFlag<string | undefined>;
10
- 'vault-key': flags.IOptionFlag<string | undefined>;
9
+ "output-file": flags.IOptionFlag<string | undefined>;
10
+ "vault-key": flags.IOptionFlag<string | undefined>;
11
11
  };
12
12
  static args: {
13
13
  name: string;
@@ -2,33 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VaultEncrypt = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
7
  const command_1 = require("@oclif/command");
8
8
  const kuzzle_vault_1 = require("kuzzle-vault");
9
9
  const common_1 = require("../../common");
10
10
  class VaultEncrypt extends common_1.Kommand {
11
11
  async runSafe() {
12
- if (lodash_1.default.isEmpty(this.flags['vault-key'])) {
13
- throw new Error('A vault key must be provided');
12
+ if (lodash_1.default.isEmpty(this.flags["vault-key"])) {
13
+ throw new Error("A vault key must be provided");
14
14
  }
15
15
  if (lodash_1.default.isEmpty(this.args.file)) {
16
- throw new Error('A file must be provided');
16
+ throw new Error("A file must be provided");
17
17
  }
18
18
  let outputFile = `${this.args.file}.enc`;
19
- if (this.flags['output-file']) {
20
- outputFile = this.flags['output-file'];
19
+ if (this.flags["output-file"]) {
20
+ outputFile = this.flags["output-file"];
21
21
  }
22
22
  if (fs_1.default.existsSync(outputFile) && !this.flags.force) {
23
23
  throw new Error(`Output file "${outputFile}" already exists. Use -f flag to overwrite it.`);
24
24
  }
25
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
25
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
26
26
  if (!fs_1.default.existsSync(this.args.file)) {
27
27
  throw new Error(`File "${this.args.file}" does not exists`);
28
28
  }
29
29
  let content;
30
30
  try {
31
- content = fs_1.default.readFileSync(this.args.file, 'utf8');
31
+ content = fs_1.default.readFileSync(this.args.file, "utf8");
32
32
  }
33
33
  catch (error) {
34
34
  throw new Error(`Cannot read file "${this.args.file}": ${error.message}`);
@@ -40,25 +40,23 @@ class VaultEncrypt extends common_1.Kommand {
40
40
  }
41
41
  exports.VaultEncrypt = VaultEncrypt;
42
42
  VaultEncrypt.initSdk = false;
43
- VaultEncrypt.description = 'Encrypts an entire file.';
43
+ VaultEncrypt.description = "Encrypts an entire file.";
44
44
  VaultEncrypt.examples = [
45
- 'kourou file:encrypt books/cryptonomicon.txt --vault-key <vault-key>',
46
- 'kourou file:encrypt books/cryptonomicon.txt -o books/cryptonomicon.txt.enc --vault-key <vault-key>'
45
+ "kourou file:encrypt books/cryptonomicon.txt --vault-key <vault-key>",
46
+ "kourou file:encrypt books/cryptonomicon.txt -o books/cryptonomicon.txt.enc --vault-key <vault-key>",
47
47
  ];
48
48
  VaultEncrypt.flags = {
49
49
  force: command_1.flags.boolean({
50
- char: 'f',
51
- description: 'Overwrite the output file if it already exists'
50
+ char: "f",
51
+ description: "Overwrite the output file if it already exists",
52
52
  }),
53
- 'output-file': command_1.flags.string({
54
- char: 'o',
55
- description: 'Output file (default: <filename>.enc)'
53
+ "output-file": command_1.flags.string({
54
+ char: "o",
55
+ description: "Output file (default: <filename>.enc)",
56
56
  }),
57
- 'vault-key': command_1.flags.string({
58
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
57
+ "vault-key": command_1.flags.string({
58
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
59
59
  default: process.env.KUZZLE_VAULT_KEY,
60
60
  }),
61
61
  };
62
- VaultEncrypt.args = [
63
- { name: 'file', description: 'Filename', required: true }
64
- ];
62
+ VaultEncrypt.args = [{ name: "file", description: "Filename", required: true }];
@@ -1,11 +1,11 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export declare class FileTest extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
6
6
  static examples: string[];
7
7
  static flags: {
8
- 'vault-key': flags.IOptionFlag<string | undefined>;
8
+ "vault-key": flags.IOptionFlag<string | undefined>;
9
9
  };
10
10
  static args: {
11
11
  name: string;