kourou 1.4.0-dev.3 → 1.4.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.
- package/README.md +1 -1
- package/lib/commands/app/doctor.js +2 -2
- package/lib/commands/app/scaffold.js +1 -1
- package/lib/commands/app/start-services.js +3 -3
- package/lib/commands/es/migrate.js +3 -3
- package/lib/commands/instance/kill.js +4 -4
- package/lib/commands/instance/spawn.js +5 -6
- package/lib/commands/paas/login.js +5 -3
- package/lib/commands/realtime/subscribe.js +0 -1
- package/lib/commands/sdk/execute.js +0 -1
- package/lib/commands/vault/add.js +1 -1
- package/lib/common.js +5 -5
- package/lib/index.js +0 -1
- package/lib/support/docker/checkPrerequisites.js +1 -2
- package/lib/support/dump-collection.js +2 -6
- package/lib/support/emoji.d.ts +17 -0
- package/lib/support/emoji.js +20 -0
- package/lib/support/execute.d.ts +0 -1
- package/lib/support/execute.js +2 -2
- package/lib/support/kuzzle.d.ts +0 -1
- package/lib/support/migrate/providers/bulk.js +2 -3
- package/lib/support/migrate/providers/file.js +3 -3
- package/lib/support/migrate/providers/index.js +1 -2
- package/lib/support/restore-collection.js +2 -3
- package/lib/support/restore-securities.js +30 -11
- package/package.json +13 -22
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ class AppDoctor extends common_1.Kommand {
|
|
|
144
144
|
count_docs: i["docs.count"],
|
|
145
145
|
})));
|
|
146
146
|
}
|
|
147
|
-
catch (
|
|
147
|
+
catch (_a) {
|
|
148
148
|
this.logKo("=> Cannot show more information about ElasticSearch (cluster name, nodes, indices) because it's not accessible");
|
|
149
149
|
}
|
|
150
150
|
let librairies = [];
|
|
@@ -164,7 +164,7 @@ class AppDoctor extends common_1.Kommand {
|
|
|
164
164
|
this.logOk(` ${lib} is installed`);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
catch (
|
|
167
|
+
catch (_b) {
|
|
168
168
|
this.logKo(` => ${lib} is not installed`);
|
|
169
169
|
notInstalled.push(lib);
|
|
170
170
|
}
|
|
@@ -87,7 +87,7 @@ class AppScaffold extends common_1.Kommand {
|
|
|
87
87
|
const { stdout } = await (0, execute_1.execute)("gh", "auth", "token");
|
|
88
88
|
return stdout.trim() || undefined;
|
|
89
89
|
}
|
|
90
|
-
catch (
|
|
90
|
+
catch (_a) {
|
|
91
91
|
// GitHub CLI is not installed or not authenticated
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
@@ -5,7 +5,7 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const emoji_1 = require("../../support/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");
|
|
@@ -31,10 +31,10 @@ class AppStartServices extends common_1.Kommand {
|
|
|
31
31
|
? await (0, checkPrerequisites_1.checkPrerequisites)(this)
|
|
32
32
|
: true;
|
|
33
33
|
if (this.flags.check && successfullCheck) {
|
|
34
|
-
this.log(`\n${
|
|
34
|
+
this.log(`\n${emoji_1.emoji.okHand} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
|
|
35
35
|
}
|
|
36
36
|
else if (this.flags.check && !successfullCheck) {
|
|
37
|
-
throw new Error(`${
|
|
37
|
+
throw new Error(`${emoji_1.emoji.shrug} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle services.`);
|
|
38
38
|
}
|
|
39
39
|
this.log(chalk_1.default.grey(`\nWriting the Docker Compose file to ${docoFilename}...\n`));
|
|
40
40
|
(0, fs_1.writeFileSync)(docoFilename, kuzzleServicesFile);
|
|
@@ -5,7 +5,7 @@ const command_1 = require("@oclif/command");
|
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const emoji_1 = require("../../support/emoji");
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const common_1 = require("../../common");
|
|
11
11
|
const providers_1 = require("../../support/migrate/providers");
|
|
@@ -87,8 +87,8 @@ class EsMigrate extends common_1.Kommand {
|
|
|
87
87
|
this.dest = await this.detectProviderType(this.flags.dest);
|
|
88
88
|
if (this.flags.reset) {
|
|
89
89
|
if (!this.flags["no-interactive"]) {
|
|
90
|
-
this.log(chalk_1.default.red(`${
|
|
91
|
-
await cli_ux_1.default.confirm(chalk_1.default.redBright(` ${
|
|
90
|
+
this.log(chalk_1.default.red(`${emoji_1.emoji.fire} Are you sure you want to reset ${chalk_1.default.bold(this.flags.dest)}?`));
|
|
91
|
+
await cli_ux_1.default.confirm(chalk_1.default.redBright(` ${emoji_1.emoji.fire} You will lose all the data stored in it (Type "yes" to confirm)`));
|
|
92
92
|
}
|
|
93
93
|
await this.dest.clear();
|
|
94
94
|
}
|
|
@@ -8,7 +8,7 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
|
8
8
|
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
11
|
-
const
|
|
11
|
+
const emoji_1 = require("../../support/emoji");
|
|
12
12
|
const common_1 = require("../../common");
|
|
13
13
|
const execute_1 = require("../../support/execute");
|
|
14
14
|
class InstanceLogs extends common_1.Kommand {
|
|
@@ -47,7 +47,7 @@ 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(`${
|
|
50
|
+
cli_ux_1.default.action.start(`${emoji_1.emoji.boom} Killing Kuzzle instance ${instanceName}`, undefined, {
|
|
51
51
|
stdout: true,
|
|
52
52
|
});
|
|
53
53
|
const instanceKill = (0, child_process_1.spawn)("docker", [
|
|
@@ -60,10 +60,10 @@ class InstanceLogs extends common_1.Kommand {
|
|
|
60
60
|
]);
|
|
61
61
|
return new Promise((resolve) => instanceKill.on("close", (code) => {
|
|
62
62
|
if (code === 0) {
|
|
63
|
-
cli_ux_1.default.action.stop(chalk_1.default.green(`\n${
|
|
63
|
+
cli_ux_1.default.action.stop(chalk_1.default.green(`\n${emoji_1.emoji.thumbsUp} Instance ${instanceName} successfully killed.`));
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
cli_ux_1.default.action.stop(chalk_1.default.red(`\n${
|
|
66
|
+
cli_ux_1.default.action.stop(chalk_1.default.red(`\n${emoji_1.emoji.thumbsDown} Something went wrong whilde killing instance ${instanceName}.`));
|
|
67
67
|
}
|
|
68
68
|
resolve(undefined);
|
|
69
69
|
}));
|
|
@@ -8,7 +8,7 @@ const command_1 = require("@oclif/command");
|
|
|
8
8
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
11
|
-
const
|
|
11
|
+
const emoji_1 = require("../../support/emoji");
|
|
12
12
|
const common_1 = require("../../common");
|
|
13
13
|
const execute_1 = require("../../support/execute");
|
|
14
14
|
const checkPrerequisites_1 = require("../../support/docker/checkPrerequisites");
|
|
@@ -86,10 +86,10 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
86
86
|
? await (0, checkPrerequisites_1.checkPrerequisites)(this)
|
|
87
87
|
: true;
|
|
88
88
|
if (this.flags.check && successfullCheck) {
|
|
89
|
-
this.log(`\n${
|
|
89
|
+
this.log(`\n${emoji_1.emoji.okHand} Prerequisites are ${chalk_1.default.green.bold("OK")}!`);
|
|
90
90
|
}
|
|
91
91
|
else if (this.flags.check && !successfullCheck) {
|
|
92
|
-
throw new Error(`${
|
|
92
|
+
throw new Error(`${emoji_1.emoji.shrug} Your system doesn't satisfy all the prerequisites. Cannot run Kuzzle.`);
|
|
93
93
|
}
|
|
94
94
|
this.log(chalk_1.default.grey(`\nWriting docker compose file to ${docoFilename}...`));
|
|
95
95
|
(0, fs_1.writeFileSync)(docoFilename, this.generateDocoFile(this.flags.version, portIndex));
|
|
@@ -104,13 +104,13 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
104
104
|
"up",
|
|
105
105
|
"-d",
|
|
106
106
|
]);
|
|
107
|
-
cli_ux_1.default.action.start(` ${
|
|
107
|
+
cli_ux_1.default.action.start(` ${emoji_1.emoji.rocket} Kuzzle version ${this.flags.version} is launching`, undefined, {
|
|
108
108
|
stdout: true,
|
|
109
109
|
});
|
|
110
110
|
doco.on("close", (docoCode) => {
|
|
111
111
|
if (docoCode === 0) {
|
|
112
112
|
cli_ux_1.default.action.stop("done");
|
|
113
|
-
this.log(`\n${
|
|
113
|
+
this.log(`\n${emoji_1.emoji.thumbsUp} ${chalk_1.default.bold("Kuzzle is booting")} in the background right now.`);
|
|
114
114
|
this.log(chalk_1.default.grey("To watch the logs, run"));
|
|
115
115
|
this.log(chalk_1.default.grey(` docker compose -f ${docoFilename} -p stack-${portIndex} logs -f\n`));
|
|
116
116
|
this.log(` Kuzzle port: ${7512 + portIndex}`);
|
|
@@ -150,7 +150,6 @@ class InstanceSpawn extends common_1.Kommand {
|
|
|
150
150
|
}
|
|
151
151
|
async findAvailablePort() {
|
|
152
152
|
let i = 0;
|
|
153
|
-
// eslint-disable-next-line
|
|
154
153
|
while (true) {
|
|
155
154
|
if (await this.isPortAvailable(7512 + i)) {
|
|
156
155
|
return i;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
6
5
|
const command_1 = require("@oclif/command");
|
|
7
6
|
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
8
7
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
@@ -50,12 +49,15 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
50
49
|
}),
|
|
51
50
|
};
|
|
52
51
|
const targetUrl = `https://${this.packagesHost}/-/user/org.couchdb.user:${username}`;
|
|
53
|
-
const response = await (
|
|
54
|
-
const json = await response.json();
|
|
52
|
+
const response = await fetch(targetUrl, options);
|
|
53
|
+
const json = (await response.json());
|
|
55
54
|
if (response.status !== 201) {
|
|
56
55
|
throw new Error(json.error);
|
|
57
56
|
}
|
|
58
57
|
const { token } = json;
|
|
58
|
+
if (!token) {
|
|
59
|
+
throw new Error("The registry accepted the credentials but returned no authentication token");
|
|
60
|
+
}
|
|
59
61
|
(0, child_process_1.spawnSync)("npm", ["config", "set", "@kuzzleio:registry", `https://${this.packagesHost}`], { stdio: "inherit" });
|
|
60
62
|
(0, child_process_1.spawnSync)("npm", ["set", `//${this.packagesHost}/:_authToken`, token], {
|
|
61
63
|
stdio: "inherit",
|
|
@@ -29,7 +29,6 @@ class RealtimeSubscribe extends common_1.Kommand {
|
|
|
29
29
|
volatile: this.parseJs(this.flags.volatile),
|
|
30
30
|
});
|
|
31
31
|
this.logInfo(`Waiting for realtime notifications on "${this.args.index}":"${this.args.collection}" ...`);
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
33
32
|
await new Promise(() => { });
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -83,7 +83,6 @@ ${this.getVariables()}
|
|
|
83
83
|
}
|
|
84
84
|
if (!userError && (this.haveSubscription || this.flags["keep-alive"])) {
|
|
85
85
|
this.logInfo("Keep alive for realtime notifications ...");
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
87
86
|
await new Promise(() => { });
|
|
88
87
|
}
|
|
89
88
|
}
|
package/lib/common.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Kommand = void 0;
|
|
4
|
+
exports.pickValues = pickValues;
|
|
5
|
+
exports.formatValueForCSV = formatValueForCSV;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
8
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
9
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
10
|
const command_1 = require("@oclif/command");
|
|
9
11
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
|
-
const
|
|
12
|
+
const emoji_1 = require("./support/emoji");
|
|
11
13
|
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
12
14
|
const isObject_1 = tslib_1.__importDefault(require("lodash/isObject"));
|
|
13
15
|
const kepler_companion_1 = tslib_1.__importDefault(require("kepler-companion"));
|
|
@@ -41,7 +43,7 @@ class Kommand extends command_1.Command {
|
|
|
41
43
|
.split("\n")
|
|
42
44
|
.filter((line) => line.length > 0)[0];
|
|
43
45
|
this.log("");
|
|
44
|
-
this.log(`${chalk_1.default.blue.bold(`${
|
|
46
|
+
this.log(`${chalk_1.default.blue.bold(`${emoji_1.emoji.rocket} Kourou`)} - ${shortDescription}`);
|
|
45
47
|
this.log("");
|
|
46
48
|
}
|
|
47
49
|
log(message) {
|
|
@@ -188,7 +190,6 @@ Kommand.keepAuth = false;
|
|
|
188
190
|
function pickValues(object, fields) {
|
|
189
191
|
return fields.map((f) => formatValueForCSV((0, get_1.default)(object, f)));
|
|
190
192
|
}
|
|
191
|
-
exports.pickValues = pickValues;
|
|
192
193
|
/**
|
|
193
194
|
* Formats the value for correct CSV output, avoiding to return
|
|
194
195
|
* values that would badly serialize in CSV.
|
|
@@ -202,4 +203,3 @@ function formatValueForCSV(value) {
|
|
|
202
203
|
}
|
|
203
204
|
return value;
|
|
204
205
|
}
|
|
205
|
-
exports.formatValueForCSV = formatValueForCSV;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkPrerequisites =
|
|
3
|
+
exports.checkPrerequisites = checkPrerequisites;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const listr_1 = tslib_1.__importDefault(require("listr"));
|
|
6
6
|
const execute_1 = require("../execute");
|
|
@@ -28,4 +28,3 @@ async function checkPrerequisites(ctx) {
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
exports.checkPrerequisites = checkPrerequisites;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.dumpCollectionData = dumpCollectionData;
|
|
4
|
+
exports.dumpCollectionMappings = dumpCollectionMappings;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -64,15 +65,12 @@ class AbstractDumper {
|
|
|
64
65
|
*
|
|
65
66
|
* @returns void
|
|
66
67
|
*/
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
68
68
|
async setup() { }
|
|
69
69
|
/**
|
|
70
70
|
* One-shot call before iterating over the data. Can be
|
|
71
71
|
* used to write the header of the dumped output.
|
|
72
72
|
*/
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
74
73
|
async writeHeader() { }
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
76
74
|
async tearDown() { }
|
|
77
75
|
/**
|
|
78
76
|
* The loop that iterates over the documents of the collection and
|
|
@@ -235,7 +233,6 @@ async function dumpCollectionData(sdk, index, collection, batchSize, destPath, q
|
|
|
235
233
|
return dumper.dump();
|
|
236
234
|
}
|
|
237
235
|
}
|
|
238
|
-
exports.dumpCollectionData = dumpCollectionData;
|
|
239
236
|
async function dumpCollectionMappings(sdk, index, collection, destPath, format = "jsonl") {
|
|
240
237
|
const collectionDir = path_1.default.join(destPath, collection);
|
|
241
238
|
const filename = path_1.default.join(collectionDir, "mappings.json");
|
|
@@ -256,4 +253,3 @@ async function dumpCollectionMappings(sdk, index, collection, destPath, format =
|
|
|
256
253
|
};
|
|
257
254
|
fs_1.default.writeFileSync(filename, JSON.stringify(format.toLowerCase() === "jsonl" ? dump : mappings, null, 2));
|
|
258
255
|
}
|
|
259
|
-
exports.dumpCollectionMappings = dumpCollectionMappings;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The glyphs kourou prints.
|
|
3
|
+
*
|
|
4
|
+
* These used to come from `node-emoji`, but every call site passed a string
|
|
5
|
+
* literal, so the lookup resolved to a constant anyway: the package shipped a
|
|
6
|
+
* full emoji database, and a `string | undefined` return type, for these seven
|
|
7
|
+
* characters.
|
|
8
|
+
*/
|
|
9
|
+
export declare const emoji: {
|
|
10
|
+
readonly boom: "💥";
|
|
11
|
+
readonly fire: "🔥";
|
|
12
|
+
readonly okHand: "👌";
|
|
13
|
+
readonly rocket: "🚀";
|
|
14
|
+
readonly shrug: "🤷";
|
|
15
|
+
readonly thumbsDown: "👎";
|
|
16
|
+
readonly thumbsUp: "👍";
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emoji = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The glyphs kourou prints.
|
|
6
|
+
*
|
|
7
|
+
* These used to come from `node-emoji`, but every call site passed a string
|
|
8
|
+
* literal, so the lookup resolved to a constant anyway: the package shipped a
|
|
9
|
+
* full emoji database, and a `string | undefined` return type, for these seven
|
|
10
|
+
* characters.
|
|
11
|
+
*/
|
|
12
|
+
exports.emoji = {
|
|
13
|
+
boom: "💥",
|
|
14
|
+
fire: "🔥",
|
|
15
|
+
okHand: "👌",
|
|
16
|
+
rocket: "🚀",
|
|
17
|
+
shrug: "🤷",
|
|
18
|
+
thumbsDown: "👎",
|
|
19
|
+
thumbsUp: "👍",
|
|
20
|
+
};
|
package/lib/support/execute.d.ts
CHANGED
package/lib/support/execute.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ExecutionError = void 0;
|
|
4
|
+
exports.execute = execute;
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
5
6
|
class ExecutionError extends Error {
|
|
6
7
|
constructor(stderr, stdout, code, command) {
|
|
@@ -48,4 +49,3 @@ function execute(...args) {
|
|
|
48
49
|
executor.process = process;
|
|
49
50
|
return executor;
|
|
50
51
|
}
|
|
51
|
-
exports.execute = execute;
|
package/lib/support/kuzzle.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.chunkDocuments = chunkDocuments;
|
|
4
|
+
exports.throwOnBulkErrors = throwOnBulkErrors;
|
|
4
5
|
const DEFAULT_CHUNK_SIZE = 1000;
|
|
5
6
|
/**
|
|
6
7
|
* Splits documents into chunks so a bulk request never exceeds the
|
|
@@ -12,7 +13,6 @@ function* chunkDocuments(docs, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
|
12
13
|
yield docs.slice(i, i + size);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
exports.chunkDocuments = chunkDocuments;
|
|
16
16
|
/**
|
|
17
17
|
* A bulk request answers with a 200 even when some documents were rejected,
|
|
18
18
|
* so the per-item errors have to be checked explicitly.
|
|
@@ -35,4 +35,3 @@ function throwOnBulkErrors(response) {
|
|
|
35
35
|
}));
|
|
36
36
|
throw error;
|
|
37
37
|
}
|
|
38
|
-
exports.throwOnBulkErrors = throwOnBulkErrors;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.File = void 0;
|
|
4
|
+
exports.fileExists = fileExists;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const fs_1 = require("fs");
|
|
6
7
|
const fs_2 = tslib_1.__importDefault(require("fs"));
|
|
@@ -66,8 +67,7 @@ function fileExists(filePath) {
|
|
|
66
67
|
fs_2.default.accessSync(filePath, fs_1.constants.F_OK);
|
|
67
68
|
return true;
|
|
68
69
|
}
|
|
69
|
-
catch (
|
|
70
|
+
catch (_a) {
|
|
70
71
|
return false;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
|
-
exports.fileExists = fileExists;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isURL =
|
|
3
|
+
exports.isURL = isURL;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./bulk"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./elasticsearch7"), exports);
|
|
@@ -9,4 +9,3 @@ tslib_1.__exportStar(require("./file"), exports);
|
|
|
9
9
|
function isURL(str) {
|
|
10
10
|
return URL.canParse(str);
|
|
11
11
|
}
|
|
12
|
-
exports.isURL = isURL;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.restoreCollectionData = restoreCollectionData;
|
|
4
|
+
exports.restoreCollectionMappings = restoreCollectionMappings;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
@@ -116,7 +117,6 @@ async function restoreCollectionData(sdk, log, batchSize, dumpFile, index, colle
|
|
|
116
117
|
index: mWriteRequest.index,
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
exports.restoreCollectionData = restoreCollectionData;
|
|
120
120
|
/**
|
|
121
121
|
* Imports mappings from a collection mappings dump
|
|
122
122
|
* Expected format:
|
|
@@ -154,4 +154,3 @@ async function restoreCollectionMappings(sdk, dump, index, collection) {
|
|
|
154
154
|
collection: dstCollection,
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
exports.restoreCollectionMappings = restoreCollectionMappings;
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.restoreRoles = restoreRoles;
|
|
4
|
+
exports.restoreProfiles = restoreProfiles;
|
|
5
|
+
exports.restoreUsers = restoreUsers;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
-
const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
|
|
7
8
|
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
9
|
+
/**
|
|
10
|
+
* Applies `fn` to every item, `concurrency` at a time, and returns the results
|
|
11
|
+
* in input order. Rejects on the first failure, like `Promise.all`, and stops
|
|
12
|
+
* feeding the workers once that happens.
|
|
13
|
+
*/
|
|
14
|
+
async function mapWithConcurrency(items, fn, concurrency) {
|
|
15
|
+
const results = new Array(items.length);
|
|
16
|
+
let next = 0;
|
|
17
|
+
const worker = async () => {
|
|
18
|
+
while (next < items.length) {
|
|
19
|
+
const index = next;
|
|
20
|
+
next += 1;
|
|
21
|
+
results[index] = await fn(items[index]);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, worker));
|
|
25
|
+
return results;
|
|
26
|
+
}
|
|
8
27
|
async function restoreRoles(kommand, dump, preserveAnonymous = false) {
|
|
9
28
|
if (dump.type !== "roles") {
|
|
10
29
|
throw new Error("Dump file does not contain roles definition");
|
|
@@ -27,30 +46,30 @@ async function restoreRoles(kommand, dump, preserveAnonymous = false) {
|
|
|
27
46
|
kommand.logInfo("Anonymous user rights has been preserved.");
|
|
28
47
|
delete dump.content.anonymous;
|
|
29
48
|
}
|
|
30
|
-
const results = await
|
|
49
|
+
const results = await mapWithConcurrency(Object.entries(dump.content), ([roleId, role]) => kommand.sdk.security.createOrReplaceRole(roleId, role, { force: true }), 10);
|
|
31
50
|
return results.length;
|
|
32
51
|
}
|
|
33
|
-
exports.restoreRoles = restoreRoles;
|
|
34
52
|
async function restoreProfiles(kommand, dump) {
|
|
35
53
|
if (dump.type !== "profiles") {
|
|
36
54
|
throw new Error("Dump file does not contain profiles definition");
|
|
37
55
|
}
|
|
38
|
-
const results = await
|
|
56
|
+
const results = await mapWithConcurrency(Object.entries(dump.content), ([profileId, profile]) => kommand.sdk.security.createOrReplaceProfile(profileId, profile, {
|
|
39
57
|
force: true,
|
|
40
|
-
}),
|
|
58
|
+
}), 10);
|
|
41
59
|
return results.length;
|
|
42
60
|
}
|
|
43
|
-
exports.restoreProfiles = restoreProfiles;
|
|
44
61
|
async function restoreUsers(kommand, dump) {
|
|
45
62
|
if (dump.type !== "users") {
|
|
46
63
|
throw new Error("Dump file does not contain users definition");
|
|
47
64
|
}
|
|
48
|
-
const results = await
|
|
65
|
+
const results = await mapWithConcurrency(Object.entries(dump.content), ([userId, userBody]) => {
|
|
49
66
|
return kommand.sdk.security
|
|
50
67
|
.createUser(userId, userBody)
|
|
51
68
|
.then(() => true)
|
|
52
|
-
.catch((error) =>
|
|
53
|
-
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
kommand.logKo(`Error importing user ${userId}: ${error.message}`);
|
|
71
|
+
return false;
|
|
72
|
+
});
|
|
73
|
+
}, 10);
|
|
54
74
|
return results.filter((success) => success).length;
|
|
55
75
|
}
|
|
56
|
-
exports.restoreUsers = restoreUsers;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kourou",
|
|
3
3
|
"description": "The CLI that helps you manage your Kuzzle instances",
|
|
4
|
-
"version": "1.4.0
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kourou": "./bin/run"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dev": "./bin/run",
|
|
13
13
|
"postpack": "rm -f oclif.manifest.json",
|
|
14
14
|
"version": "oclif-dev readme && git add README.md",
|
|
15
|
-
"test:lint": "eslint src/ test/
|
|
16
|
-
"test:lint:fix": "eslint src/ test/ --
|
|
15
|
+
"test:lint": "eslint src/ test/",
|
|
16
|
+
"test:lint:fix": "eslint src/ test/ --fix",
|
|
17
17
|
"test:functional": "npm run build && npm run test:functional:stdout && npm run test:functional:cucumber",
|
|
18
18
|
"test:functional:stdout": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
19
19
|
"test:functional:cucumber": "./node_modules/.bin/cucumber-js --fail-fast"
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@oclif/config": "1.18.*",
|
|
26
26
|
"@oclif/plugin-autocomplete": "1.3.*",
|
|
27
27
|
"@oclif/plugin-help": "3.2.2",
|
|
28
|
-
"bluebird": "3.7.2",
|
|
29
28
|
"chalk": "4.1.2",
|
|
30
29
|
"cli-ux": "5.5.1",
|
|
31
30
|
"inquirer": "8.2.7",
|
|
@@ -35,39 +34,31 @@
|
|
|
35
34
|
"listr": "0.14.3",
|
|
36
35
|
"lodash": "4.18.1",
|
|
37
36
|
"ndjson": "2.0.0",
|
|
38
|
-
"node-emoji": "1.11.0",
|
|
39
|
-
"node-fetch": "2.7.0",
|
|
40
37
|
"strip-json-comments": "3.1.1",
|
|
41
38
|
"tmp": "0.2.7",
|
|
42
39
|
"tslib": "2.8.1",
|
|
43
|
-
"ws": "8.21.
|
|
44
|
-
"typescript": "5.
|
|
40
|
+
"ws": "8.21.3",
|
|
41
|
+
"typescript": "5.9.*"
|
|
45
42
|
},
|
|
46
43
|
"devDependencies": {
|
|
44
|
+
"@cucumber/cucumber": "13.2.1",
|
|
47
45
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
48
46
|
"@oclif/dev-cli": "1.26.10",
|
|
49
47
|
"@oclif/test": "1.2.8",
|
|
50
|
-
"@types/bluebird": "3.5.42",
|
|
51
48
|
"@types/chai": "4.3.20",
|
|
52
49
|
"@types/compare-version": "0.1.34",
|
|
53
50
|
"@types/inquirer": "8.2.13",
|
|
54
51
|
"@types/listr": "0.14.10",
|
|
55
|
-
"@types/mocha": "
|
|
52
|
+
"@types/mocha": "10.0.10",
|
|
56
53
|
"@types/ndjson": "2.0.4",
|
|
57
|
-
"@types/node": "20.
|
|
58
|
-
"@types/node-emoji": "1.8.2",
|
|
59
|
-
"@types/node-fetch": "2.6.13",
|
|
54
|
+
"@types/node": "22.20.1",
|
|
60
55
|
"@types/tmp": "0.2.6",
|
|
61
56
|
"@types/ws": "8.18.1",
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
63
|
-
"@typescript-eslint/parser": "7.18.0",
|
|
64
57
|
"chai": "4.5.0",
|
|
65
|
-
"
|
|
66
|
-
"eslint": "
|
|
67
|
-
"eslint-plugin-kuzzle": "0.0.15",
|
|
68
|
-
"eslint-plugin-prettier": "5.1.3",
|
|
58
|
+
"eslint": "9.32.0",
|
|
59
|
+
"eslint-plugin-kuzzle": "1.0.0",
|
|
69
60
|
"globby": "11.1.0",
|
|
70
|
-
"mocha": "
|
|
61
|
+
"mocha": "12.0.0",
|
|
71
62
|
"nyc": "15.1.0",
|
|
72
63
|
"semantic-release": "25.0.8",
|
|
73
64
|
"semantic-release-config-kuzzle": "1.7.0",
|
|
@@ -76,7 +67,7 @@
|
|
|
76
67
|
"ts-node": "10.9.*"
|
|
77
68
|
},
|
|
78
69
|
"engines": {
|
|
79
|
-
"node": ">=
|
|
70
|
+
"node": ">=22.0.0"
|
|
80
71
|
},
|
|
81
72
|
"files": [
|
|
82
73
|
"/bin",
|
|
@@ -141,7 +132,7 @@
|
|
|
141
132
|
"repository": "kuzzleio/kourou",
|
|
142
133
|
"types": "lib/index.d.ts",
|
|
143
134
|
"overrides": {
|
|
144
|
-
"ws@8": "8.21.
|
|
135
|
+
"ws@8": "8.21.3",
|
|
145
136
|
"cross-spawn@6": "6.0.6",
|
|
146
137
|
"semver@5": "5.7.2",
|
|
147
138
|
"picomatch@2": "2.3.2",
|