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,33 +2,33 @@
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 = 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 FileTest 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
18
  if (!fs_1.default.existsSync(this.args.file)) {
19
19
  throw new Error(`Encrypted file "${this.args.file} does not exists`);
20
20
  }
21
- const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags['vault-key']);
21
+ const cryptonomicon = new kuzzle_vault_1.Cryptonomicon(this.flags["vault-key"]);
22
22
  let encryptedContent;
23
23
  try {
24
- encryptedContent = fs_1.default.readFileSync(this.args.file, 'utf8');
24
+ encryptedContent = fs_1.default.readFileSync(this.args.file, "utf8");
25
25
  }
26
26
  catch (error) {
27
27
  throw new Error(`Cannot read encrypted content from file "${this.args.file}": ${error.message}`);
28
28
  }
29
29
  try {
30
30
  cryptonomicon.decryptString(encryptedContent);
31
- this.logOk('Encrypted file can be decrypted');
31
+ this.logOk("Encrypted file can be decrypted");
32
32
  }
33
33
  catch (error) {
34
34
  this.logKo(`Encrypted file cannot be decrypted: ${error.message}`);
@@ -37,16 +37,16 @@ class FileTest extends common_1.Kommand {
37
37
  }
38
38
  exports.FileTest = FileTest;
39
39
  FileTest.initSdk = false;
40
- FileTest.description = 'Tests if an encrypted file can be decrypted.';
40
+ FileTest.description = "Tests if an encrypted file can be decrypted.";
41
41
  FileTest.examples = [
42
- 'kourou file:test books/cryptonomicon.txt.enc --vault-key <vault-key>'
42
+ "kourou file:test books/cryptonomicon.txt.enc --vault-key <vault-key>",
43
43
  ];
44
44
  FileTest.flags = {
45
- 'vault-key': command_1.flags.string({
46
- description: 'Kuzzle Vault Key (or KUZZLE_VAULT_KEY)',
45
+ "vault-key": command_1.flags.string({
46
+ description: "Kuzzle Vault Key (or KUZZLE_VAULT_KEY)",
47
47
  default: process.env.KUZZLE_VAULT_KEY,
48
48
  }),
49
49
  };
50
50
  FileTest.args = [
51
- { name: 'file', description: 'Encrypted file', required: true }
51
+ { name: "file", description: "Encrypted file", required: true },
52
52
  ];
@@ -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 Import extends Kommand {
4
4
  static keepAuth: boolean;
5
5
  static description: string;
@@ -11,10 +11,10 @@ export default class Import extends Kommand {
11
11
  username: flags.IOptionFlag<string>;
12
12
  password: flags.IOptionFlag<string | undefined>;
13
13
  as: flags.IOptionFlag<string | undefined>;
14
- 'api-key': flags.IOptionFlag<string | undefined>;
15
- 'preserve-anonymous': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
14
+ "api-key": flags.IOptionFlag<string | undefined>;
15
+ "preserve-anonymous": import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
16
16
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
17
- 'batch-size': flags.IOptionFlag<string>;
17
+ "batch-size": flags.IOptionFlag<string>;
18
18
  };
19
19
  static args: {
20
20
  name: string;
@@ -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 = tslib_1.__importDefault(require("fs"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const path_1 = (0, 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");
@@ -14,7 +14,7 @@ class Import extends common_1.Kommand {
14
14
  for (const file of files.mappings) {
15
15
  try {
16
16
  this.logInfo(`[collection] Start importing mappings in ${file}`);
17
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
17
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
18
18
  const { index, collection } = await (0, restore_collection_1.restoreCollectionMappings)(this.sdk, dump);
19
19
  this.logOk(`[collection] Imported mappings for "${index}":"${collection}"`);
20
20
  }
@@ -25,7 +25,7 @@ class Import extends common_1.Kommand {
25
25
  for (const file of files.documents) {
26
26
  try {
27
27
  this.logInfo(`[collection] Start importing documents in ${file}`);
28
- const { total, index, collection } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), file);
28
+ const { total, index, collection } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags["batch-size"]), file);
29
29
  this.logOk(`[collection] Imported ${total} documents in "${index}":"${collection}"`);
30
30
  }
31
31
  catch (error) {
@@ -35,8 +35,8 @@ class Import extends common_1.Kommand {
35
35
  for (const file of files.roles) {
36
36
  try {
37
37
  this.logInfo(`[roles] Start importing roles in ${file}`);
38
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
39
- const total = await (0, restore_securities_1.restoreRoles)(this, dump, this.flags['preserve-anonymous']);
38
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
39
+ const total = await (0, restore_securities_1.restoreRoles)(this, dump, this.flags["preserve-anonymous"]);
40
40
  this.logOk(`[roles] Imported ${total} roles`);
41
41
  }
42
42
  catch (error) {
@@ -46,7 +46,7 @@ class Import extends common_1.Kommand {
46
46
  for (const file of files.profiles) {
47
47
  try {
48
48
  this.logInfo(`[profiles] Start importing profiles in ${file}`);
49
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
49
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
50
50
  const total = await (0, restore_securities_1.restoreProfiles)(this, dump);
51
51
  this.logOk(`[profiles] Imported ${total} profiles`);
52
52
  }
@@ -57,10 +57,10 @@ class Import extends common_1.Kommand {
57
57
  for (const file of files.usersMappings) {
58
58
  try {
59
59
  this.logInfo(`[users] Start importing users collection mappings in ${file}`);
60
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
60
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
61
61
  const mapping = dump.content.mapping;
62
62
  await this.sdk.security.updateUserMapping({ properties: mapping });
63
- this.logOk('[users] collection mappings imported');
63
+ this.logOk("[users] collection mappings imported");
64
64
  }
65
65
  catch (error) {
66
66
  this.logKo(`Error during import of ${file}: ${error.message}. Skipped.`);
@@ -69,7 +69,7 @@ class Import extends common_1.Kommand {
69
69
  for (const file of files.users) {
70
70
  try {
71
71
  this.logInfo(`[users] Start importing users in ${file}`);
72
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
72
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
73
73
  const total = await (0, restore_securities_1.restoreUsers)(this, dump);
74
74
  this.logOk(`[users] Imported ${total} users`);
75
75
  }
@@ -81,16 +81,23 @@ class Import extends common_1.Kommand {
81
81
  async walkDirectories(directory) {
82
82
  const entries = fs_1.default.readdirSync(directory);
83
83
  const directories = entries
84
- .map(entry => path_1.default.join(directory, entry))
85
- .filter(dirName => fs_1.default.lstatSync(dirName).isDirectory());
84
+ .map((entry) => path_1.default.join(directory, entry))
85
+ .filter((dirName) => fs_1.default.lstatSync(dirName).isDirectory());
86
86
  const files = entries
87
- .map(entry => path_1.default.join(directory, entry))
88
- .filter(fileName => fs_1.default.lstatSync(fileName).isFile())
87
+ .map((entry) => path_1.default.join(directory, entry))
88
+ .filter((fileName) => fs_1.default.lstatSync(fileName).isFile())
89
89
  .reduce((memo, file) => {
90
90
  const fileType = this.getFileType(file);
91
91
  memo[fileType].push(file);
92
92
  return memo;
93
- }, { documents: [], mappings: [], roles: [], profiles: [], usersMappings: [], users: [] });
93
+ }, {
94
+ documents: [],
95
+ mappings: [],
96
+ roles: [],
97
+ profiles: [],
98
+ usersMappings: [],
99
+ users: [],
100
+ });
94
101
  for (const dir of directories) {
95
102
  const { documents, mappings, roles, profiles, usersMappings, users } = await this.walkDirectories(dir);
96
103
  files.documents = files.documents.concat(documents);
@@ -103,11 +110,11 @@ class Import extends common_1.Kommand {
103
110
  return files;
104
111
  }
105
112
  getFileType(file) {
106
- if (file.endsWith('.jsonl')) {
107
- return 'documents';
113
+ if (file.endsWith(".jsonl")) {
114
+ return "documents";
108
115
  }
109
116
  try {
110
- const dump = JSON.parse(fs_1.default.readFileSync(file, 'utf8'));
117
+ const dump = JSON.parse(fs_1.default.readFileSync(file, "utf8"));
111
118
  return dump.type;
112
119
  }
113
120
  catch (error) {
@@ -117,17 +124,21 @@ class Import extends common_1.Kommand {
117
124
  }
118
125
  exports.default = Import;
119
126
  Import.keepAuth = true;
120
- Import.description = 'Recursively imports dump files from a root directory';
121
- Import.flags = Object.assign(Object.assign({ 'preserve-anonymous': command_1.flags.boolean({
122
- description: 'Preserve anonymous rights',
123
- default: false
124
- }), help: command_1.flags.help({}), 'batch-size': command_1.flags.string({
125
- description: 'Maximum batch size (see limits.documentsWriteCount config)',
126
- default: '200'
127
+ Import.description = "Recursively imports dump files from a root directory";
128
+ Import.flags = Object.assign(Object.assign({ "preserve-anonymous": command_1.flags.boolean({
129
+ description: "Preserve anonymous rights",
130
+ default: false,
131
+ }), help: command_1.flags.help({}), "batch-size": command_1.flags.string({
132
+ description: "Maximum batch size (see limits.documentsWriteCount config)",
133
+ default: "200",
127
134
  }) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
128
- description: 'Kuzzle protocol (http or websocket)',
129
- default: 'ws',
135
+ description: "Kuzzle protocol (http or websocket)",
136
+ default: "ws",
130
137
  }) });
131
138
  Import.args = [
132
- { name: 'path', description: 'Root directory containing dumps', required: true },
139
+ {
140
+ name: "path",
141
+ description: "Root directory containing dumps",
142
+ required: true,
143
+ },
133
144
  ];
@@ -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 IndexExport extends Kommand {
4
4
  static keepAuth: boolean;
5
5
  static description: string;
@@ -11,12 +11,13 @@ export default class IndexExport extends Kommand {
11
11
  username: flags.IOptionFlag<string>;
12
12
  password: flags.IOptionFlag<string | undefined>;
13
13
  as: flags.IOptionFlag<string | undefined>;
14
- 'api-key': flags.IOptionFlag<string | undefined>;
14
+ "api-key": flags.IOptionFlag<string | undefined>;
15
15
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
16
16
  path: flags.IOptionFlag<string | undefined>;
17
- 'batch-size': flags.IOptionFlag<string>;
17
+ "batch-size": flags.IOptionFlag<string>;
18
18
  query: flags.IOptionFlag<string>;
19
19
  format: flags.IOptionFlag<string>;
20
+ scrollTTL: flags.IOptionFlag<string>;
20
21
  };
21
22
  static args: {
22
23
  name: string;
@@ -2,9 +2,9 @@
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 = tslib_1.__importDefault(require("fs"));
6
- const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
7
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
8
8
  const common_1 = require("../../common");
9
9
  const kuzzle_1 = require("../../support/kuzzle");
10
10
  const dump_collection_1 = require("../../support/dump-collection");
@@ -19,9 +19,9 @@ class IndexExport extends common_1.Kommand {
19
19
  const { collections } = await this.sdk.collection.list(this.args.index);
20
20
  for (const collection of collections) {
21
21
  try {
22
- if (collection.type !== 'realtime') {
22
+ if (collection.type !== "realtime") {
23
23
  await (0, dump_collection_1.dumpCollectionMappings)(this.sdk, this.args.index, collection.name, exportPath, this.flags.format);
24
- await (0, dump_collection_1.dumpCollectionData)(this.sdk, this.args.index, collection.name, Number(this.flags['batch-size']), exportPath, query, this.flags.format);
24
+ await (0, dump_collection_1.dumpCollectionData)(this.sdk, this.args.index, collection.name, Number(this.flags["batch-size"]), exportPath, query, this.flags.format, this.flags.scrollTTL);
25
25
  cli_ux_1.default.action.stop();
26
26
  }
27
27
  }
@@ -34,26 +34,28 @@ class IndexExport extends common_1.Kommand {
34
34
  }
35
35
  exports.default = IndexExport;
36
36
  IndexExport.keepAuth = true;
37
- IndexExport.description = 'Exports an index (JSONL or Kuzzle format)';
37
+ IndexExport.description = "Exports an index (JSONL or Kuzzle format)";
38
38
  IndexExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({
39
- description: 'Dump root directory',
40
- }), 'batch-size': command_1.flags.string({
41
- description: 'Maximum batch size (see limits.documentsFetchCount config)',
42
- default: '2000'
39
+ description: "Dump root directory",
40
+ }), "batch-size": command_1.flags.string({
41
+ description: "Maximum batch size (see limits.documentsFetchCount config)",
42
+ default: "2000",
43
43
  }), query: command_1.flags.string({
44
- description: 'Only dump documents in collections matching the query (JS or JSON format)',
45
- default: '{}'
44
+ description: "Only dump documents in collections matching the query (JS or JSON format)",
45
+ default: "{}",
46
46
  }), format: command_1.flags.string({
47
47
  description: '"jsonl or kuzzle - kuzzle will export in Kuzzle format usable for internal fixtures and jsonl allows to import that data back with kourou',
48
- default: 'jsonl'
48
+ default: "jsonl",
49
+ }), scrollTTL: command_1.flags.string({
50
+ description: `The scroll TTL option to pass to the dump operation (which performs a document.search under the hood),
51
+ expressed in ms format, e.g. '2s', '1m', '3h'.`,
52
+ default: "20s",
49
53
  }) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
50
- description: 'Kuzzle protocol (http or websocket)',
51
- default: 'ws',
54
+ description: "Kuzzle protocol (http or websocket)",
55
+ default: "ws",
52
56
  }) });
53
- IndexExport.args = [
54
- { name: 'index', description: 'Index name', required: true },
55
- ];
57
+ IndexExport.args = [{ name: "index", description: "Index name", required: true }];
56
58
  IndexExport.examples = [
57
- 'kourou index:export nyc-open-data',
59
+ "kourou index:export nyc-open-data",
58
60
  'kourou index:export nyc-open-data --query \'{"range":{"_kuzzle_info.createdAt":{"gt":1632935638866}}}\'',
59
61
  ];
@@ -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 IndexImport extends Kommand {
4
4
  static keepAuth: boolean;
5
5
  static description: string;
@@ -12,11 +12,11 @@ export default class IndexImport extends Kommand {
12
12
  username: flags.IOptionFlag<string>;
13
13
  password: flags.IOptionFlag<string | undefined>;
14
14
  as: flags.IOptionFlag<string | undefined>;
15
- 'api-key': flags.IOptionFlag<string | undefined>;
15
+ "api-key": flags.IOptionFlag<string | undefined>;
16
16
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
17
- 'batch-size': flags.IOptionFlag<string>;
17
+ "batch-size": flags.IOptionFlag<string>;
18
18
  index: flags.IOptionFlag<string | undefined>;
19
- 'no-mappings': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
19
+ "no-mappings": import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
20
20
  };
21
21
  static args: {
22
22
  name: string;
@@ -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 = tslib_1.__importDefault(require("path"));
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
4
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
5
+ const fs_1 = (0, 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");
@@ -15,15 +15,17 @@ class IndexImport extends common_1.Kommand {
15
15
  else {
16
16
  this.logInfo(`Start importing dump from ${this.args.path} in same index`);
17
17
  }
18
- const dumpDirs = fs_1.default.readdirSync(this.args.path).map(f => path_1.default.join(this.args.path, f));
18
+ const dumpDirs = fs_1.default
19
+ .readdirSync(this.args.path)
20
+ .map((f) => path_1.default.join(this.args.path, f));
19
21
  for (const dumpDir of dumpDirs) {
20
22
  try {
21
- if (!this.flags['no-mappings']) {
22
- const mappingsPath = path_1.default.join(dumpDir, 'mappings.json');
23
- const dump = JSON.parse(fs_1.default.readFileSync(mappingsPath, 'utf8'));
23
+ if (!this.flags["no-mappings"]) {
24
+ const mappingsPath = path_1.default.join(dumpDir, "mappings.json");
25
+ const dump = JSON.parse(fs_1.default.readFileSync(mappingsPath, "utf8"));
24
26
  await (0, restore_collection_1.restoreCollectionMappings)(this.sdk, dump, this.flags.index);
25
27
  }
26
- const { total, collection, index: dstIndex } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags['batch-size']), path_1.default.join(dumpDir, 'documents.jsonl'), this.flags.index);
28
+ const { total, collection, index: dstIndex, } = await (0, restore_collection_1.restoreCollectionData)(this.sdk, this.log.bind(this), Number(this.flags["batch-size"]), path_1.default.join(dumpDir, "documents.jsonl"), this.flags.index);
27
29
  this.logOk(`Successfully imported ${total} documents in "${dstIndex}:${collection}"`);
28
30
  }
29
31
  catch (error) {
@@ -34,22 +36,22 @@ class IndexImport extends common_1.Kommand {
34
36
  }
35
37
  exports.default = IndexImport;
36
38
  IndexImport.keepAuth = true;
37
- IndexImport.description = 'Imports an index (JSONL format)';
39
+ IndexImport.description = "Imports an index (JSONL format)";
38
40
  IndexImport.examples = [
39
- 'kourou index:import ./dump/iot-data',
40
- 'kourou index:import ./dump/iot-data --index iot-data-production --no-mappings'
41
+ "kourou index:import ./dump/iot-data",
42
+ "kourou index:import ./dump/iot-data --index iot-data-production --no-mappings",
41
43
  ];
42
- IndexImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), 'batch-size': command_1.flags.string({
43
- description: 'Maximum batch size (see limits.documentsWriteCount config)',
44
- default: '200'
44
+ IndexImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), "batch-size": command_1.flags.string({
45
+ description: "Maximum batch size (see limits.documentsWriteCount config)",
46
+ default: "200",
45
47
  }), index: command_1.flags.string({
46
- description: 'If set, override the index destination name',
47
- }), 'no-mappings': command_1.flags.boolean({
48
- description: 'Skip collections mappings'
48
+ description: "If set, override the index destination name",
49
+ }), "no-mappings": command_1.flags.boolean({
50
+ description: "Skip collections mappings",
49
51
  }) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
50
- description: 'Kuzzle protocol (http or websocket)',
51
- default: 'ws',
52
+ description: "Kuzzle protocol (http or websocket)",
53
+ default: "ws",
52
54
  }) });
53
55
  IndexImport.args = [
54
- { name: 'path', description: 'Dump directory or file', required: true },
56
+ { name: "path", description: "Dump directory or file", required: true },
55
57
  ];
@@ -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 declare class InstanceLogs extends Kommand {
4
4
  static initSdk: boolean;
5
5
  static description: string;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InstanceLogs = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
5
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
6
  const command_1 = require("@oclif/command");
7
- const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
8
- const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
7
+ const inquirer_1 = (0, tslib_1.__importDefault)(require("inquirer"));
8
+ const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
9
9
  const child_process_1 = require("child_process");
10
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
11
- const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
10
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
11
+ const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
12
12
  const common_1 = require("../../common");
13
13
  const execute_1 = require("../../support/execute");
14
14
  class InstanceLogs extends common_1.Kommand {
@@ -18,7 +18,7 @@ class InstanceLogs extends common_1.Kommand {
18
18
  const all = this.flags.all;
19
19
  const instancesList = await this.getInstancesList();
20
20
  if (instancesList.length === 0) {
21
- throw new Error('There are no Kuzzle running instances');
21
+ throw new Error("There are no Kuzzle running instances");
22
22
  }
23
23
  if (all) {
24
24
  for (const i of instancesList) {
@@ -29,14 +29,14 @@ class InstanceLogs extends common_1.Kommand {
29
29
  if (!instance) {
30
30
  const responses = await inquirer_1.default.prompt([
31
31
  {
32
- name: 'instance',
33
- message: 'Which kuzzle instance do you want to kill',
34
- type: 'list',
35
- choices: instancesList
36
- }
32
+ name: "instance",
33
+ message: "Which kuzzle instance do you want to kill",
34
+ type: "list",
35
+ choices: instancesList,
36
+ },
37
37
  ]);
38
38
  if (!responses.instance) {
39
- throw new Error('A running instance must be selected');
39
+ throw new Error("A running instance must be selected");
40
40
  }
41
41
  instance = responses.instance;
42
42
  }
@@ -47,22 +47,22 @@ class InstanceLogs extends common_1.Kommand {
47
47
  }
48
48
  async killInstance(instanceName) {
49
49
  const docoFilename = path_1.default.join(this.kourouDir, `kuzzle-${instanceName}.yml`);
50
- cli_ux_1.default.action.start(`${node_emoji_1.default.get('boom')} Killing Kuzzle instance ${instanceName}`, undefined, {
51
- stdout: true
50
+ cli_ux_1.default.action.start(`${node_emoji_1.default.get("boom")} Killing Kuzzle instance ${instanceName}`, undefined, {
51
+ stdout: true,
52
52
  });
53
- const instanceKill = (0, child_process_1.spawn)('docker-compose', [
54
- '-f',
53
+ const instanceKill = (0, child_process_1.spawn)("docker-compose", [
54
+ "-f",
55
55
  docoFilename,
56
- '-p',
56
+ "-p",
57
57
  instanceName,
58
- 'down'
58
+ "down",
59
59
  ]);
60
- return new Promise(resolve => instanceKill.on('close', code => {
60
+ return new Promise((resolve) => instanceKill.on("close", (code) => {
61
61
  if (code === 0) {
62
- cli_ux_1.default.action.stop(chalk_1.default.green(`\n${node_emoji_1.default.get('thumbsup')} Instance ${instanceName} successfully killed.`));
62
+ cli_ux_1.default.action.stop(chalk_1.default.green(`\n${node_emoji_1.default.get("thumbsup")} Instance ${instanceName} successfully killed.`));
63
63
  }
64
64
  else {
65
- cli_ux_1.default.action.stop(chalk_1.default.red(`\n${node_emoji_1.default.get('thumbsdown')} Something went wrong whilde killing instance ${instanceName}.`));
65
+ cli_ux_1.default.action.stop(chalk_1.default.red(`\n${node_emoji_1.default.get("thumbsdown")} Something went wrong whilde killing instance ${instanceName}.`));
66
66
  }
67
67
  resolve(undefined);
68
68
  }));
@@ -70,32 +70,32 @@ class InstanceLogs extends common_1.Kommand {
70
70
  async getInstancesList() {
71
71
  let containersListProcess;
72
72
  try {
73
- containersListProcess = await (0, execute_1.execute)('docker', 'ps', '--format', '"{{.Names}}"');
73
+ containersListProcess = await (0, execute_1.execute)("docker", "ps", "--format", '"{{.Names}}"');
74
74
  }
75
75
  catch (error) {
76
76
  this.warn(`Something went wrong while getting kuzzle running instances list: ${error.message}`);
77
77
  return [];
78
78
  }
79
79
  const containersList = containersListProcess.stdout
80
- .replace(/"/g, '')
81
- .split('\n');
80
+ .replace(/"/g, "")
81
+ .split("\n");
82
82
  return containersList
83
- .filter(containerName => containerName.includes('kuzzle') &&
84
- !containerName.includes('redis') &&
85
- !containerName.includes('elasticsearch'))
86
- .map(containerName => containerName.split('_')[0]);
83
+ .filter((containerName) => containerName.includes("kuzzle") &&
84
+ !containerName.includes("redis") &&
85
+ !containerName.includes("elasticsearch"))
86
+ .map((containerName) => containerName.split("_")[0]);
87
87
  }
88
88
  }
89
89
  exports.InstanceLogs = InstanceLogs;
90
90
  InstanceLogs.initSdk = false;
91
- InstanceLogs.description = 'Stop and remove all the containers of a running kuzzle instance';
91
+ InstanceLogs.description = "Stop and remove all the containers of a running kuzzle instance";
92
92
  InstanceLogs.flags = {
93
93
  instance: command_1.flags.string({
94
- char: 'i',
95
- description: 'Kuzzle instance name [ex: stack-0]'
94
+ char: "i",
95
+ description: "Kuzzle instance name [ex: stack-0]",
96
96
  }),
97
97
  all: command_1.flags.boolean({
98
- char: 'a',
99
- description: 'Kill all instances'
100
- })
98
+ char: "a",
99
+ description: "Kill all instances",
100
+ }),
101
101
  };
@@ -1,4 +1,4 @@
1
- import { Kommand } from '../../common';
1
+ import { Kommand } from "../../common";
2
2
  export declare class InstanceList extends Kommand {
3
3
  static initSdk: boolean;
4
4
  static description: string;