kourou 1.4.0-dev.1 → 1.4.0-dev.3

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 (70) hide show
  1. package/README.md +7 -1
  2. package/lib/commands/app/debug-proxy.js +3 -3
  3. package/lib/commands/app/doctor.js +8 -5
  4. package/lib/commands/app/scaffold.js +3 -3
  5. package/lib/commands/app/start-services.js +4 -4
  6. package/lib/commands/collection/create.js +1 -1
  7. package/lib/commands/collection/export.js +3 -3
  8. package/lib/commands/collection/import.js +3 -3
  9. package/lib/commands/collection/migrate.js +7 -8
  10. package/lib/commands/config/diff.js +5 -4
  11. package/lib/commands/document/search.js +1 -1
  12. package/lib/commands/es/aliases/cat.d.ts +2 -2
  13. package/lib/commands/es/aliases/cat.js +10 -10
  14. package/lib/commands/es/indices/cat.js +2 -2
  15. package/lib/commands/es/indices/get.js +1 -1
  16. package/lib/commands/es/indices/insert.js +1 -1
  17. package/lib/commands/es/migrate.js +6 -8
  18. package/lib/commands/es/snapshot/create-repository.js +1 -1
  19. package/lib/commands/es/snapshot/create.d.ts +1 -0
  20. package/lib/commands/es/snapshot/create.js +14 -2
  21. package/lib/commands/es/snapshot/list.js +1 -1
  22. package/lib/commands/es/snapshot/restore.d.ts +1 -0
  23. package/lib/commands/es/snapshot/restore.js +14 -2
  24. package/lib/commands/file/decrypt.js +2 -2
  25. package/lib/commands/file/encrypt.js +2 -2
  26. package/lib/commands/file/test.js +2 -2
  27. package/lib/commands/import.js +3 -3
  28. package/lib/commands/index/export.js +4 -4
  29. package/lib/commands/index/import.js +3 -3
  30. package/lib/commands/instance/kill.js +5 -5
  31. package/lib/commands/instance/list.js +6 -1
  32. package/lib/commands/instance/logs.js +1 -1
  33. package/lib/commands/instance/spawn.js +6 -6
  34. package/lib/commands/paas/login.js +4 -9
  35. package/lib/commands/profile/export.js +3 -3
  36. package/lib/commands/profile/import.js +2 -2
  37. package/lib/commands/realtime/subscribe.js +2 -2
  38. package/lib/commands/redis/list-keys.js +1 -1
  39. package/lib/commands/role/export.js +3 -3
  40. package/lib/commands/role/import.js +2 -2
  41. package/lib/commands/sdk/execute.js +5 -3
  42. package/lib/commands/sdk/query.js +2 -2
  43. package/lib/commands/user/export-mappings.js +3 -3
  44. package/lib/commands/user/export.js +5 -5
  45. package/lib/commands/user/import-mappings.js +2 -2
  46. package/lib/commands/user/import.js +2 -2
  47. package/lib/commands/vault/add.js +2 -2
  48. package/lib/commands/vault/decrypt.js +2 -2
  49. package/lib/commands/vault/encrypt.js +3 -3
  50. package/lib/commands/vault/show.js +3 -3
  51. package/lib/commands/vault/test.js +1 -1
  52. package/lib/common.js +8 -8
  53. package/lib/hooks/command_not_found/api-action.js +5 -3
  54. package/lib/support/PaasKommand.d.ts +1 -1
  55. package/lib/support/PaasKommand.js +2 -2
  56. package/lib/support/docker/checkPrerequisites.js +1 -1
  57. package/lib/support/dump-collection.js +5 -5
  58. package/lib/support/editor.js +2 -2
  59. package/lib/support/execute.d.ts +1 -1
  60. package/lib/support/kuzzle.d.ts +1 -1
  61. package/lib/support/kuzzle.js +2 -2
  62. package/lib/support/migrate/providers/elasticsearch7.js +6 -8
  63. package/lib/support/migrate/providers/elasticsearch8.js +6 -8
  64. package/lib/support/migrate/providers/elasticsearchTypes.d.ts +1 -1
  65. package/lib/support/migrate/providers/file.js +4 -5
  66. package/lib/support/migrate/providers/index.js +5 -11
  67. package/lib/support/migrate/types.d.ts +1 -1
  68. package/lib/support/restore-collection.js +4 -4
  69. package/lib/support/restore-securities.js +2 -2
  70. package/package.json +49 -44
package/README.md CHANGED
@@ -27,7 +27,7 @@ $ npm install -g kourou
27
27
  $ kourou COMMAND
28
28
  running command...
29
29
  $ kourou (-v|--version|version)
30
- kourou/1.4.0-dev.1 linux-x64 node-v24.18.0
30
+ kourou/1.4.0-dev.3 linux-x64 node-v24.18.0
31
31
  $ kourou --help [COMMAND]
32
32
  USAGE
33
33
  $ kourou COMMAND
@@ -759,6 +759,9 @@ ARGUMENTS
759
759
  OPTIONS
760
760
  -n, --node=node [default: http://localhost:9200] Elasticsearch server URL
761
761
  --help show CLI help
762
+
763
+ --[no-]wait Wait for the snapshot to complete before returning. Use --no-wait to return as soon as Elasticsearch
764
+ has accepted the request
762
765
  ```
763
766
 
764
767
  _See code: [lib/commands/es/snapshot/create.js](lib/commands/es/snapshot/create.js)_
@@ -816,6 +819,9 @@ ARGUMENTS
816
819
  OPTIONS
817
820
  -n, --node=node [default: http://localhost:9200] Elasticsearch server URL
818
821
  --help show CLI help
822
+
823
+ --[no-]wait Wait for the restore to complete before returning. Use --no-wait to return as soon as Elasticsearch
824
+ has accepted the request
819
825
  ```
820
826
 
821
827
  _See code: [lib/commands/es/snapshot/restore.js](lib/commands/es/snapshot/restore.js)_
@@ -4,8 +4,8 @@ const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
5
  const common_1 = require("../../common");
6
6
  const kuzzle_1 = require("../../support/kuzzle");
7
- const http_1 = (0, tslib_1.__importDefault)(require("http"));
8
- const ws_1 = (0, tslib_1.__importDefault)(require("ws"));
7
+ const http_1 = tslib_1.__importDefault(require("http"));
8
+ const ws_1 = tslib_1.__importDefault(require("ws"));
9
9
  // Add the proper headers and send the body in the response
10
10
  function sendResponse(response, bodyObject) {
11
11
  response.setHeader("Content-Type", "application/json; charset=UTF-8");
@@ -159,7 +159,6 @@ class DebugProxy extends common_1.Kommand {
159
159
  await promise;
160
160
  }
161
161
  }
162
- exports.default = DebugProxy;
163
162
  DebugProxy.description = "Create a Proxy Server that allows Chrome to debug Kuzzle remotely using the DebugController";
164
163
  DebugProxy.flags = Object.assign({ help: command_1.flags.help(), forwardPort: command_1.flags.integer({
165
164
  description: "Port of the forwarding server",
@@ -184,3 +183,4 @@ DebugProxy.flags = Object.assign({ help: command_1.flags.help(), forwardPort: co
184
183
  DebugProxy.sdkOptions = {
185
184
  protocol: "ws",
186
185
  };
186
+ exports.default = DebugProxy;
@@ -6,7 +6,7 @@ const common_1 = require("../../common");
6
6
  const kuzzle_1 = require("../../support/kuzzle");
7
7
  const sdk_es7_1 = require("sdk-es7");
8
8
  const execute_1 = require("../../support/execute");
9
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
9
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
10
10
  const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
11
11
  class AppDoctor extends common_1.Kommand {
12
12
  constructor() {
@@ -36,9 +36,9 @@ class AppDoctor extends common_1.Kommand {
36
36
  async runSafe() {
37
37
  const suggestions = [];
38
38
  const [nodeVersion, adminExists, anonymous] = await Promise.all([
39
- this.sdk.query({ controller: "debug", action: "nodeVersion", }),
39
+ this.sdk.query({ controller: "debug", action: "nodeVersion" }),
40
40
  this.sdk.server.adminExists({}),
41
- this.sdk.security.getRole("anonymous")
41
+ this.sdk.security.getRole("anonymous"),
42
42
  ]);
43
43
  this.log(`----------------- DoKtor begin his job ! -----------------`);
44
44
  this.log(`General checks`);
@@ -96,7 +96,7 @@ class AppDoctor extends common_1.Kommand {
96
96
  this.logInfo("No config found for the server");
97
97
  }
98
98
  // Redis
99
- if ("PONG" === (await this.sdk.ms.ping())) {
99
+ if ((await this.sdk.ms.ping()) === "PONG") {
100
100
  this.logOk("Redis Memory Storage is running");
101
101
  }
102
102
  else {
@@ -131,9 +131,12 @@ class AppDoctor extends common_1.Kommand {
131
131
  this.logOk(`ElasticSearch Status: ${info.meta.connection.status}`);
132
132
  const nodes = await client.cat.nodes({ format: "json" });
133
133
  this.log(`ElasticSearch nodes`);
134
+ // oclif has no tabular output helper, console.table is the only option
135
+ // eslint-disable-next-line no-console
134
136
  console.table(nodes.body.map((i) => ({ node_name: i.name, ip: i.ip })));
135
137
  const indices = await client.cat.indices({ format: "json" });
136
138
  this.log(`ElasticSearch indices`);
139
+ // eslint-disable-next-line no-console
137
140
  console.table(indices.body.map((i) => ({
138
141
  indice_name: i.index,
139
142
  health: i.health,
@@ -182,7 +185,6 @@ class AppDoctor extends common_1.Kommand {
182
185
  this.log(`-------------------------------------------------------------`);
183
186
  }
184
187
  }
185
- exports.default = AppDoctor;
186
188
  AppDoctor.description = "Analyze a Kuzzle application";
187
189
  AppDoctor.flags = Object.assign({ help: command_1.flags.help(), elasticsearch: command_1.flags.string({
188
190
  description: "Elasticsearch server URL",
@@ -190,3 +192,4 @@ AppDoctor.flags = Object.assign({ help: command_1.flags.help(), elasticsearch: c
190
192
  }) }, kuzzle_1.kuzzleFlags);
191
193
  AppDoctor.args = [];
192
194
  AppDoctor.readStdin = true;
195
+ exports.default = AppDoctor;
@@ -2,8 +2,8 @@
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 chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
6
- const listr_1 = (0, tslib_1.__importDefault)(require("listr"));
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const listr_1 = tslib_1.__importDefault(require("listr"));
7
7
  const common_1 = require("../../common");
8
8
  const execute_1 = require("../../support/execute");
9
9
  class AppScaffold extends common_1.Kommand {
@@ -152,7 +152,6 @@ class AppScaffold extends common_1.Kommand {
152
152
  await (0, execute_1.execute)("rm", "-rf", `${destination}/.git`);
153
153
  }
154
154
  }
155
- exports.default = AppScaffold;
156
155
  AppScaffold.initSdk = false;
157
156
  AppScaffold.description = "Scaffolds a new Kuzzle application";
158
157
  AppScaffold.flags = {
@@ -173,3 +172,4 @@ AppScaffold.args = [
173
172
  required: true,
174
173
  },
175
174
  ];
175
+ exports.default = AppScaffold;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const fs_1 = require("fs");
5
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
6
  const command_1 = require("@oclif/command");
7
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
8
- const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
9
9
  const common_1 = require("../../common");
10
10
  const execute_1 = require("../../support/execute");
11
11
  const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
@@ -55,7 +55,6 @@ class AppStartServices extends common_1.Kommand {
55
55
  }
56
56
  }
57
57
  }
58
- exports.default = AppStartServices;
59
58
  AppStartServices.initSdk = false;
60
59
  AppStartServices.description = "Starts Kuzzle services (Elasticsearch and Redis)";
61
60
  AppStartServices.flags = {
@@ -65,3 +64,4 @@ AppStartServices.flags = {
65
64
  default: false,
66
65
  }),
67
66
  };
67
+ exports.default = AppStartServices;
@@ -14,7 +14,6 @@ class CollectionCreate extends common_1.Kommand {
14
14
  this.logOk(`Collection "${this.args.index}":"${this.args.collection}" created`);
15
15
  }
16
16
  }
17
- exports.default = CollectionCreate;
18
17
  CollectionCreate.description = "Creates a collection";
19
18
  CollectionCreate.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags);
20
19
  CollectionCreate.args = [
@@ -26,3 +25,4 @@ CollectionCreate.args = [
26
25
  },
27
26
  ];
28
27
  CollectionCreate.readStdin = true;
28
+ exports.default = CollectionCreate;
@@ -2,8 +2,8 @@
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 fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
7
  const common_1 = require("../../common");
8
8
  const kuzzle_1 = require("../../support/kuzzle");
9
9
  const dump_collection_1 = require("../../support/dump-collection");
@@ -35,7 +35,6 @@ class CollectionExport extends common_1.Kommand {
35
35
  this.logOk(`Collection ${this.args.index}:${this.args.collection} dumped`);
36
36
  }
37
37
  }
38
- exports.default = CollectionExport;
39
38
  CollectionExport.keepAuth = true;
40
39
  CollectionExport.description = "Exports a collection (JSONL format)";
41
40
  CollectionExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({
@@ -81,3 +80,4 @@ CollectionExport.examples = [
81
80
  "kourou collection:export nyc-open-data yellow-taxi",
82
81
  "kourou collection:export nyc-open-data yellow-taxi --query '{ term: { city: \"Saigon\" } }'",
83
82
  ];
83
+ exports.default = CollectionExport;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
- const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
4
+ const path_1 = tslib_1.__importDefault(require("path"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
6
  const command_1 = require("@oclif/command");
7
7
  const common_1 = require("../../common");
8
8
  const kuzzle_1 = require("../../support/kuzzle");
@@ -19,7 +19,6 @@ class CollectionImport extends common_1.Kommand {
19
19
  this.logOk(`Successfully imported ${total} documents from "${this.args.path}" in "${index}:${collection}"`);
20
20
  }
21
21
  }
22
- exports.default = CollectionImport;
23
22
  CollectionImport.keepAuth = true;
24
23
  CollectionImport.description = "Imports a collection";
25
24
  CollectionImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), "batch-size": command_1.flags.string({
@@ -38,3 +37,4 @@ CollectionImport.flags = Object.assign(Object.assign({ help: command_1.flags.hel
38
37
  CollectionImport.args = [
39
38
  { name: "path", description: "Dump directory path", required: true },
40
39
  ];
40
+ exports.default = CollectionImport;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
- const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
4
+ const path_1 = tslib_1.__importDefault(require("path"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
6
  const command_1 = require("@oclif/command");
7
7
  const common_1 = require("../../common");
8
8
  const kuzzle_1 = require("../../support/kuzzle");
@@ -16,14 +16,12 @@ class CollectionMigrate extends common_1.Kommand {
16
16
  }
17
17
  getMigrationFunction() {
18
18
  const migrationScript = fs_1.default.readFileSync(this.args.script, "utf8");
19
- let migrationFunction;
20
- {
21
- migrationFunction = eval(`var f = ${migrationScript}; f`);
22
- }
23
- return migrationFunction;
19
+ // Evaluating user-supplied code is the whole point of the command: the
20
+ // script argument is the migration function itself.
21
+ // eslint-disable-next-line no-eval
22
+ return eval(`var f = ${migrationScript}; f`);
24
23
  }
25
24
  }
26
- exports.default = CollectionMigrate;
27
25
  CollectionMigrate.keepAuth = true;
28
26
  CollectionMigrate.description = "Migrate a collection by transforming documents from a dump file and importing them into Kuzzle";
29
27
  CollectionMigrate.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), "batch-size": command_1.flags.string({
@@ -41,3 +39,4 @@ CollectionMigrate.args = [
41
39
  { name: "script", description: "Migration script path", required: true },
42
40
  { name: "path", description: "Collection dump path", required: true },
43
41
  ];
42
+ exports.default = CollectionMigrate;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigKeyDiff = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const command_1 = require("@oclif/command");
6
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
7
- const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
8
- const strip_json_comments_1 = (0, tslib_1.__importDefault)(require("strip-json-comments"));
6
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
+ const fs_1 = tslib_1.__importDefault(require("fs"));
8
+ const strip_json_comments_1 = tslib_1.__importDefault(require("strip-json-comments"));
9
9
  const common_1 = require("../../common");
10
10
  class ConfigKeyDiff extends common_1.Kommand {
11
11
  async runSafe() {
@@ -52,7 +52,8 @@ class ConfigKeyDiff extends common_1.Kommand {
52
52
  walkObject(_base[key], _object[key], [...path, key]);
53
53
  }
54
54
  else if (this.flags.values && _base[key] !== _object[key]) {
55
- changes[[...path, key].join(".")] = `value is "${_object[key]}" and was "${_base[key]}"`;
55
+ changes[[...path, key].join(".")] =
56
+ `value is "${_object[key]}" and was "${_base[key]}"`;
56
57
  }
57
58
  }
58
59
  };
@@ -31,7 +31,6 @@ class DocumentSearch extends common_1.Kommand {
31
31
  this.logOk(`${result === null || result === void 0 ? void 0 : result.hits.length} documents fetched on a total of ${result === null || result === void 0 ? void 0 : result.total}`);
32
32
  }
33
33
  }
34
- exports.default = DocumentSearch;
35
34
  DocumentSearch.description = "Searches for documents";
36
35
  DocumentSearch.examples = [
37
36
  "kourou document:search iot sensors '{ equals: { name: \"corona\" } }'",
@@ -58,3 +57,4 @@ DocumentSearch.args = [
58
57
  { name: "collection", description: "Collection name", required: true },
59
58
  { name: "query", description: "Search query in JS or JSON format." },
60
59
  ];
60
+ exports.default = DocumentSearch;
@@ -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 EsListAliases extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
@@ -7,30 +7,30 @@ class EsListAliases extends common_1.Kommand {
7
7
  async runSafe() {
8
8
  const esClient = new sdk_es7_1.Client({ node: this.flags.node });
9
9
  try {
10
- const { body } = await esClient.cat.aliases({ format: 'json' });
10
+ const { body } = await esClient.cat.aliases({ format: "json" });
11
11
  const elements = body
12
12
  .map((e) => ({ index: e.index, alias: e.alias }))
13
- .filter((e) => (this.flags.grep ? e.alias.match(new RegExp(this.flags.grep)) : true))
13
+ .filter((e) => this.flags.grep ? e.alias.match(new RegExp(this.flags.grep)) : true)
14
14
  .sort();
15
15
  this.log(JSON.stringify(elements, null, 2));
16
16
  }
17
17
  catch (error) {
18
- console.log(error);
18
+ this.logKo(error.message);
19
19
  }
20
20
  }
21
21
  }
22
- exports.default = EsListAliases;
23
22
  EsListAliases.initSdk = false;
24
- EsListAliases.description = 'Lists available ES aliases';
23
+ EsListAliases.description = "Lists available ES aliases";
25
24
  EsListAliases.flags = {
26
25
  help: command_1.flags.help(),
27
26
  node: command_1.flags.string({
28
- char: 'n',
29
- description: 'Elasticsearch server URL',
30
- default: 'http://localhost:9200',
27
+ char: "n",
28
+ description: "Elasticsearch server URL",
29
+ default: "http://localhost:9200",
31
30
  }),
32
31
  grep: command_1.flags.string({
33
- char: 'g',
34
- description: 'Match output with pattern',
32
+ char: "g",
33
+ description: "Match output with pattern",
35
34
  }),
36
35
  };
36
+ exports.default = EsListAliases;
@@ -16,11 +16,10 @@ class EsListIndex extends common_1.Kommand {
16
16
  this.log(JSON.stringify(indexes, null, 2));
17
17
  }
18
18
  catch (error) {
19
- console.log(error);
19
+ this.logKo(error.message);
20
20
  }
21
21
  }
22
22
  }
23
- exports.default = EsListIndex;
24
23
  EsListIndex.initSdk = false;
25
24
  EsListIndex.description = "Lists available ES indexes";
26
25
  EsListIndex.flags = {
@@ -35,3 +34,4 @@ EsListIndex.flags = {
35
34
  description: "Match output with pattern",
36
35
  }),
37
36
  };
37
+ exports.default = EsListIndex;
@@ -14,7 +14,6 @@ class EsGet extends common_1.Kommand {
14
14
  this.log(JSON.stringify(body, null, 2));
15
15
  }
16
16
  }
17
- exports.default = EsGet;
18
17
  EsGet.initSdk = false;
19
18
  EsGet.description = "Gets a document from ES";
20
19
  EsGet.flags = {
@@ -29,3 +28,4 @@ EsGet.args = [
29
28
  { name: "index", description: "ES Index name", required: true },
30
29
  { name: "id", description: "Document ID", required: true },
31
30
  ];
31
+ exports.default = EsGet;
@@ -15,7 +15,6 @@ class EsInsert extends common_1.Kommand {
15
15
  this.logOk("Document successfully inserted.");
16
16
  }
17
17
  }
18
- exports.default = EsInsert;
19
18
  EsInsert.initSdk = false;
20
19
  EsInsert.description = "Inserts a document directly into ES (will replace if exists)";
21
20
  EsInsert.flags = {
@@ -36,3 +35,4 @@ EsInsert.flags = {
36
35
  EsInsert.args = [
37
36
  { name: "index", description: "ES Index name", required: true },
38
37
  ];
38
+ exports.default = EsInsert;
@@ -2,10 +2,10 @@
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 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"));
5
+ const path_1 = tslib_1.__importDefault(require("path"));
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"));
9
9
  const fs_1 = require("fs");
10
10
  const common_1 = require("../../common");
11
11
  const providers_1 = require("../../support/migrate/providers");
@@ -34,9 +34,7 @@ class EsMigrate extends common_1.Kommand {
34
34
  }
35
35
  return new providers_1.File(provider);
36
36
  }
37
- else {
38
- throw new Error(`Unknown provider type: ${provider}. You should provide either an Elasticsearch URL or a file path.`);
39
- }
37
+ throw new Error(`Unknown provider type: ${provider}. You should provide either an Elasticsearch URL or a file path.`);
40
38
  }
41
39
  async migrateIndex(index) {
42
40
  const indexDefinition = await this.src.getIndex(index);
@@ -107,7 +105,6 @@ class EsMigrate extends common_1.Kommand {
107
105
  }
108
106
  }
109
107
  }
110
- exports.default = EsMigrate;
111
108
  EsMigrate.initSdk = false;
112
109
  EsMigrate.description = "Migrate all the index from an Elasticsearch (or a file) to another Elasticsearch";
113
110
  EsMigrate.flags = {
@@ -164,3 +161,4 @@ EsMigrate.examples = [
164
161
  "kourou es:migrate --src ./my-backup --dest http://elasticsearch:9200 --reset --batch-size 2000 --no-interactive",
165
162
  "kourou es:migrate --src ./my-backup --dest http://elasticsearch:9200 --reset --batch-size 2000 --no-interactive --esVersion 8",
166
163
  ];
164
+ exports.default = EsMigrate;
@@ -21,7 +21,6 @@ class EsSnapshotsCreateRepository extends common_1.Kommand {
21
21
  this.logOk(`Success ${JSON.stringify(response.body)}`);
22
22
  }
23
23
  }
24
- exports.default = EsSnapshotsCreateRepository;
25
24
  EsSnapshotsCreateRepository.initSdk = false;
26
25
  EsSnapshotsCreateRepository.description = "Create a FS snapshot repository inside an ES instance";
27
26
  EsSnapshotsCreateRepository.flags = {
@@ -44,3 +43,4 @@ EsSnapshotsCreateRepository.args = [
44
43
  required: true,
45
44
  },
46
45
  ];
46
+ exports.default = EsSnapshotsCreateRepository;
@@ -5,6 +5,7 @@ export default class EsSnapshotsCreate extends Kommand {
5
5
  static description: string;
6
6
  static flags: {
7
7
  node: flags.IOptionFlag<string>;
8
+ wait: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
9
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
9
10
  };
10
11
  static args: {
@@ -3,12 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@oclif/command");
4
4
  const sdk_es7_1 = require("sdk-es7");
5
5
  const common_1 = require("../../../common");
6
+ const SNAPSHOT_TIMEOUT = 30 * 60 * 1000;
6
7
  class EsSnapshotsCreate extends common_1.Kommand {
7
8
  async runSafe() {
8
- const esClient = new sdk_es7_1.Client({ node: this.flags.node });
9
+ const esClient = new sdk_es7_1.Client({
10
+ node: this.flags.node,
11
+ // Waiting holds the HTTP request open for as long as the snapshot takes,
12
+ // which the 30s default would cut short on any real dataset.
13
+ requestTimeout: this.flags.wait ? SNAPSHOT_TIMEOUT : undefined,
14
+ });
9
15
  const esRequest = {
10
16
  repository: this.args.repository,
11
17
  snapshot: this.args.name,
18
+ wait_for_completion: this.flags.wait,
12
19
  body: {
13
20
  indices: "*",
14
21
  include_global_state: false,
@@ -19,7 +26,6 @@ class EsSnapshotsCreate extends common_1.Kommand {
19
26
  this.logOk(`Success ${JSON.stringify(response.body)}`);
20
27
  }
21
28
  }
22
- exports.default = EsSnapshotsCreate;
23
29
  EsSnapshotsCreate.initSdk = false;
24
30
  EsSnapshotsCreate.description = "Create a snapshot repository inside an ES instance";
25
31
  EsSnapshotsCreate.flags = {
@@ -28,9 +34,15 @@ EsSnapshotsCreate.flags = {
28
34
  description: "Elasticsearch server URL",
29
35
  default: "http://localhost:9200",
30
36
  }),
37
+ wait: command_1.flags.boolean({
38
+ description: "Wait for the snapshot to complete before returning. Use --no-wait to return as soon as Elasticsearch has accepted the request",
39
+ default: true,
40
+ allowNo: true,
41
+ }),
31
42
  help: command_1.flags.help(),
32
43
  };
33
44
  EsSnapshotsCreate.args = [
34
45
  { name: "repository", description: "ES repository name", required: true },
35
46
  { name: "name", description: "ES snapshot name", required: true },
36
47
  ];
48
+ exports.default = EsSnapshotsCreate;
@@ -28,7 +28,6 @@ class EsSnapshotsList extends common_1.Kommand {
28
28
  this.logOk(`Success: ${JSON.stringify(result, null, 2)}`);
29
29
  }
30
30
  }
31
- exports.default = EsSnapshotsList;
32
31
  EsSnapshotsList.initSdk = false;
33
32
  EsSnapshotsList.description = "List all snapshot from a repository acknowledge by an ES instance";
34
33
  EsSnapshotsList.flags = {
@@ -46,3 +45,4 @@ EsSnapshotsList.args = [
46
45
  required: true,
47
46
  },
48
47
  ];
48
+ exports.default = EsSnapshotsList;
@@ -5,6 +5,7 @@ export default class EsSnapshotsRestore extends Kommand {
5
5
  static description: string;
6
6
  static flags: {
7
7
  node: flags.IOptionFlag<string>;
8
+ wait: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
9
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
9
10
  };
10
11
  static args: {
@@ -3,9 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@oclif/command");
4
4
  const sdk_es7_1 = require("sdk-es7");
5
5
  const common_1 = require("../../../common");
6
+ const RESTORE_TIMEOUT = 30 * 60 * 1000;
6
7
  class EsSnapshotsRestore extends common_1.Kommand {
7
8
  async runSafe() {
8
- const esClient = new sdk_es7_1.Client({ node: this.flags.node });
9
+ const esClient = new sdk_es7_1.Client({
10
+ node: this.flags.node,
11
+ // Waiting holds the HTTP request open for as long as the restore takes,
12
+ // which the 30s default would cut short on any real dataset.
13
+ requestTimeout: this.flags.wait ? RESTORE_TIMEOUT : undefined,
14
+ });
9
15
  await esClient.indices.close({
10
16
  index: "*",
11
17
  expand_wildcards: "all",
@@ -13,6 +19,7 @@ class EsSnapshotsRestore extends common_1.Kommand {
13
19
  const esRequest = {
14
20
  repository: this.args.repository,
15
21
  snapshot: this.args.name,
22
+ wait_for_completion: this.flags.wait,
16
23
  body: {
17
24
  feature_states: ["none"],
18
25
  include_global_state: false,
@@ -23,7 +30,6 @@ class EsSnapshotsRestore extends common_1.Kommand {
23
30
  this.logOk(`Success ${JSON.stringify(response.body)}`);
24
31
  }
25
32
  }
26
- exports.default = EsSnapshotsRestore;
27
33
  EsSnapshotsRestore.initSdk = false;
28
34
  EsSnapshotsRestore.description = "Restore a snapshot repository inside an ES instance";
29
35
  EsSnapshotsRestore.flags = {
@@ -32,9 +38,15 @@ EsSnapshotsRestore.flags = {
32
38
  description: "Elasticsearch server URL",
33
39
  default: "http://localhost:9200",
34
40
  }),
41
+ wait: command_1.flags.boolean({
42
+ description: "Wait for the restore to complete before returning. Use --no-wait to return as soon as Elasticsearch has accepted the request",
43
+ default: true,
44
+ allowNo: true,
45
+ }),
35
46
  help: command_1.flags.help(),
36
47
  };
37
48
  EsSnapshotsRestore.args = [
38
49
  { name: "repository", description: "ES repository name", required: true },
39
50
  { name: "name", description: "ES snapshot name", required: true },
40
51
  ];
52
+ exports.default = EsSnapshotsRestore;
@@ -2,8 +2,8 @@
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 = (0, tslib_1.__importDefault)(require("fs"));
6
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const lodash_1 = 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");
@@ -2,8 +2,8 @@
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 = (0, tslib_1.__importDefault)(require("fs"));
6
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const lodash_1 = 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");
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FileTest = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const lodash_1 = 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");
@@ -2,8 +2,8 @@
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 fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const path_1 = tslib_1.__importDefault(require("path"));
7
7
  const common_1 = require("../common");
8
8
  const kuzzle_1 = require("../support/kuzzle");
9
9
  const restore_collection_1 = require("../support/restore-collection");
@@ -122,7 +122,6 @@ class Import extends common_1.Kommand {
122
122
  }
123
123
  }
124
124
  }
125
- exports.default = Import;
126
125
  Import.keepAuth = true;
127
126
  Import.description = "Recursively imports dump files from a root directory";
128
127
  Import.flags = Object.assign(Object.assign({ "preserve-anonymous": command_1.flags.boolean({
@@ -142,3 +141,4 @@ Import.args = [
142
141
  required: true,
143
142
  },
144
143
  ];
144
+ exports.default = Import;