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.
- package/README.md +98 -12
- package/lib/commands/api-key/check.d.ts +3 -3
- package/lib/commands/api-key/check.js +5 -7
- package/lib/commands/api-key/create.d.ts +3 -3
- package/lib/commands/api-key/create.js +8 -10
- package/lib/commands/api-key/delete.d.ts +3 -3
- package/lib/commands/api-key/delete.js +4 -6
- package/lib/commands/api-key/search.d.ts +3 -3
- package/lib/commands/api-key/search.js +5 -7
- package/lib/commands/app/debug-proxy.d.ts +3 -3
- package/lib/commands/app/debug-proxy.js +57 -55
- package/lib/commands/app/doctor.d.ts +24 -0
- package/lib/commands/app/doctor.js +201 -0
- package/lib/commands/app/scaffold.d.ts +2 -2
- package/lib/commands/app/scaffold.js +20 -15
- package/lib/commands/app/start-services.d.ts +1 -1
- package/lib/commands/app/start-services.js +26 -26
- package/lib/commands/collection/create.d.ts +3 -3
- package/lib/commands/collection/create.js +9 -6
- package/lib/commands/collection/export.d.ts +5 -5
- package/lib/commands/collection/export.js +25 -26
- package/lib/commands/collection/import.d.ts +5 -5
- package/lib/commands/collection/import.js +17 -17
- package/lib/commands/collection/migrate.d.ts +27 -0
- package/lib/commands/collection/migrate.js +43 -0
- package/lib/commands/config/diff.d.ts +1 -1
- package/lib/commands/config/diff.js +27 -21
- package/lib/commands/document/search.d.ts +3 -3
- package/lib/commands/document/search.js +20 -20
- package/lib/commands/es/aliases/cat.d.ts +12 -0
- package/lib/commands/es/aliases/cat.js +36 -0
- package/lib/commands/es/indices/cat.d.ts +2 -2
- package/lib/commands/es/indices/cat.js +8 -8
- package/lib/commands/es/indices/get.d.ts +2 -2
- package/lib/commands/es/indices/get.js +7 -7
- package/lib/commands/es/indices/insert.d.ts +2 -2
- package/lib/commands/es/indices/insert.js +9 -9
- package/lib/commands/es/migrate.d.ts +10 -8
- package/lib/commands/es/migrate.js +86 -82
- package/lib/commands/es/snapshot/create-repository.d.ts +2 -2
- package/lib/commands/es/snapshot/create-repository.js +16 -12
- package/lib/commands/es/snapshot/create.d.ts +2 -2
- package/lib/commands/es/snapshot/create.js +7 -7
- package/lib/commands/es/snapshot/list.d.ts +2 -2
- package/lib/commands/es/snapshot/list.js +12 -8
- package/lib/commands/file/decrypt.d.ts +4 -4
- package/lib/commands/file/decrypt.js +21 -21
- package/lib/commands/file/encrypt.d.ts +4 -4
- package/lib/commands/file/encrypt.js +20 -22
- package/lib/commands/file/test.d.ts +3 -3
- package/lib/commands/file/test.js +13 -13
- package/lib/commands/import.d.ts +5 -5
- package/lib/commands/import.js +39 -28
- package/lib/commands/index/export.d.ts +5 -4
- package/lib/commands/index/export.js +21 -19
- package/lib/commands/index/import.d.ts +5 -5
- package/lib/commands/index/import.js +21 -19
- package/lib/commands/instance/kill.d.ts +2 -2
- package/lib/commands/instance/kill.js +34 -34
- package/lib/commands/instance/list.d.ts +1 -1
- package/lib/commands/instance/list.js +33 -30
- package/lib/commands/instance/logs.d.ts +2 -2
- package/lib/commands/instance/logs.js +26 -22
- package/lib/commands/instance/spawn.d.ts +2 -2
- package/lib/commands/instance/spawn.js +46 -40
- package/lib/commands/paas/deploy.d.ts +2 -2
- package/lib/commands/paas/deploy.js +33 -21
- package/lib/commands/paas/init.d.ts +1 -1
- package/lib/commands/paas/init.js +10 -6
- package/lib/commands/paas/login.d.ts +3 -3
- package/lib/commands/paas/login.js +30 -19
- package/lib/commands/paas/logs.d.ts +27 -0
- package/lib/commands/paas/logs.js +137 -18
- package/lib/commands/profile/export.d.ts +3 -3
- package/lib/commands/profile/export.js +12 -12
- package/lib/commands/profile/import.d.ts +3 -3
- package/lib/commands/profile/import.js +6 -8
- package/lib/commands/realtime/subscribe.d.ts +3 -3
- package/lib/commands/realtime/subscribe.js +25 -25
- package/lib/commands/redis/list-keys.d.ts +3 -3
- package/lib/commands/redis/list-keys.js +15 -11
- package/lib/commands/role/export.d.ts +3 -3
- package/lib/commands/role/export.js +11 -11
- package/lib/commands/role/import.d.ts +4 -4
- package/lib/commands/role/import.js +10 -12
- package/lib/commands/sdk/execute.d.ts +5 -5
- package/lib/commands/sdk/execute.js +23 -19
- package/lib/commands/sdk/query.d.ts +5 -4
- package/lib/commands/sdk/query.js +30 -24
- package/lib/commands/user/export-mappings.d.ts +3 -3
- package/lib/commands/user/export-mappings.js +11 -11
- package/lib/commands/user/export.d.ts +6 -6
- package/lib/commands/user/export.js +34 -33
- package/lib/commands/user/import-mappings.d.ts +3 -3
- package/lib/commands/user/import-mappings.js +7 -7
- package/lib/commands/user/import.d.ts +3 -3
- package/lib/commands/user/import.js +6 -8
- package/lib/commands/vault/add.d.ts +3 -3
- package/lib/commands/vault/add.js +27 -19
- package/lib/commands/vault/decrypt.d.ts +4 -4
- package/lib/commands/vault/decrypt.js +24 -20
- package/lib/commands/vault/encrypt.d.ts +4 -4
- package/lib/commands/vault/encrypt.js +24 -20
- package/lib/commands/vault/show.d.ts +3 -3
- package/lib/commands/vault/show.js +24 -20
- package/lib/commands/vault/test.d.ts +3 -3
- package/lib/commands/vault/test.js +16 -12
- package/lib/common.d.ts +3 -3
- package/lib/common.js +28 -29
- package/lib/hooks/command_not_found/api-action.d.ts +2 -2
- package/lib/hooks/command_not_found/api-action.js +20 -22
- package/lib/index.d.ts +1 -1
- package/lib/support/PaasKommand.d.ts +2 -2
- package/lib/support/PaasKommand.js +9 -9
- package/lib/support/dump-collection.js +50 -41
- package/lib/support/editor.js +12 -10
- package/lib/support/execute.d.ts +6 -1
- package/lib/support/execute.js +9 -8
- package/lib/support/kuzzle.d.ts +12 -4
- package/lib/support/kuzzle.js +65 -31
- package/lib/support/migrate/providers/elasticsearch.d.ts +16 -0
- package/lib/support/migrate/providers/elasticsearch.js +74 -0
- package/lib/support/migrate/providers/file.d.ts +15 -0
- package/lib/support/migrate/providers/file.js +74 -0
- package/lib/support/migrate/providers/index.d.ts +12 -0
- package/lib/support/migrate/providers/index.js +16 -0
- package/lib/support/migrate/types.d.ts +8 -0
- package/lib/support/migrate/types.js +2 -0
- package/lib/support/restore-collection.d.ts +2 -1
- package/lib/support/restore-collection.js +37 -26
- package/lib/support/restore-securities.js +22 -19
- package/package.json +16 -15
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
|
-
const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
|
|
7
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
8
8
|
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
@@ -15,13 +15,17 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
15
15
|
: await cli_ux_1.default.prompt(` Username`);
|
|
16
16
|
const password = process.env.KUZZLE_PAAS_PASSWORD
|
|
17
17
|
? process.env.KUZZLE_PAAS_PASSWORD
|
|
18
|
-
: await cli_ux_1.default.prompt(` Password`, { type:
|
|
18
|
+
: await cli_ux_1.default.prompt(` Password`, { type: "hide" });
|
|
19
|
+
if (this.flags.only_npm) {
|
|
20
|
+
await this.authenticateNPM(username, password);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
if (this.flags.only_npm) {
|
|
20
24
|
await this.authenticateNPM(username, password);
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
await this.initPaasClient({ username, password });
|
|
24
|
-
const apiKey = await this.paas.auth.createApiKey(
|
|
28
|
+
const apiKey = await this.paas.auth.createApiKey("Kourou PaaS API Key");
|
|
25
29
|
this.createProjectCredentials(apiKey);
|
|
26
30
|
await this.authenticateNPM(username, password);
|
|
27
31
|
this.logOk(`Successfully logged in as ${username}. Your Kuzzle Enterprise license is now enabled on this host.`);
|
|
@@ -38,37 +42,44 @@ class PaasLogin extends PaasKommand_1.PaasKommand {
|
|
|
38
42
|
}
|
|
39
43
|
async authenticateNPM(username, password) {
|
|
40
44
|
const options = {
|
|
41
|
-
method:
|
|
45
|
+
method: "PUT",
|
|
42
46
|
headers: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
Accept: "application/json",
|
|
49
|
+
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`,
|
|
46
50
|
},
|
|
47
51
|
body: JSON.stringify({
|
|
48
52
|
name: username,
|
|
49
53
|
password,
|
|
50
|
-
})
|
|
54
|
+
}),
|
|
51
55
|
};
|
|
52
56
|
const response = await (0, node_fetch_1.default)(`https://packages.paas.kuzzle.io/-/user/org.couchdb.user:${username}`, options);
|
|
53
57
|
const { token } = await response.json();
|
|
54
|
-
(0, child_process_1.spawnSync)(
|
|
55
|
-
|
|
58
|
+
(0, child_process_1.spawnSync)("npm", [
|
|
59
|
+
"config",
|
|
60
|
+
"set",
|
|
61
|
+
"@kuzzleio:registry",
|
|
62
|
+
"https://packages.paas.kuzzle.io",
|
|
63
|
+
], { stdio: "inherit" });
|
|
64
|
+
(0, child_process_1.spawnSync)("npm", ["set", "//packages.paas.kuzzle.io/:_authToken", token], {
|
|
65
|
+
stdio: "inherit",
|
|
66
|
+
});
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
|
-
PaasLogin.description =
|
|
69
|
+
PaasLogin.description = "Login for a PaaS project";
|
|
59
70
|
PaasLogin.flags = {
|
|
60
71
|
help: command_1.flags.help(),
|
|
61
72
|
project: command_1.flags.string({
|
|
62
|
-
description:
|
|
63
|
-
required: false
|
|
73
|
+
description: "Current PaaS project",
|
|
74
|
+
required: false,
|
|
64
75
|
}),
|
|
65
76
|
username: command_1.flags.string({
|
|
66
|
-
description:
|
|
77
|
+
description: "PaaS username",
|
|
67
78
|
}),
|
|
68
79
|
only_npm: command_1.flags.boolean({
|
|
69
|
-
description:
|
|
80
|
+
description: "Only perform the login on the private NPM registry",
|
|
70
81
|
required: false,
|
|
71
|
-
default: false
|
|
72
|
-
})
|
|
82
|
+
default: false,
|
|
83
|
+
}),
|
|
73
84
|
};
|
|
74
85
|
exports.default = PaasLogin;
|
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import { flags } from "@oclif/command";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { PaasKommand } from "../../support/PaasKommand";
|
|
3
4
|
declare class PaasLogs extends PaasKommand {
|
|
4
5
|
static description: string;
|
|
5
6
|
static flags: {
|
|
7
|
+
follow: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
|
+
timestamp: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
6
9
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
7
10
|
project: flags.IOptionFlag<string | undefined>;
|
|
11
|
+
tail: import("@oclif/parser/lib/flags").IOptionFlag<number | undefined>;
|
|
12
|
+
podName: flags.IOptionFlag<string | undefined>;
|
|
13
|
+
since: flags.IOptionFlag<string | undefined>;
|
|
14
|
+
until: flags.IOptionFlag<string | undefined>;
|
|
8
15
|
};
|
|
9
16
|
static args: {
|
|
10
17
|
name: string;
|
|
11
18
|
description: string;
|
|
12
19
|
required: boolean;
|
|
13
20
|
}[];
|
|
21
|
+
/**
|
|
22
|
+
* Allowed colors for pod names.
|
|
23
|
+
*/
|
|
24
|
+
private readonly allColors;
|
|
25
|
+
/**
|
|
26
|
+
* Available colors for pod names.
|
|
27
|
+
*/
|
|
28
|
+
private availableColors;
|
|
29
|
+
/**
|
|
30
|
+
* The color to use for pod names.
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
private podsColor;
|
|
14
34
|
runSafe(): Promise<void>;
|
|
15
35
|
getCredentials(): Promise<any>;
|
|
36
|
+
getNumberOfSpaces(names: string[], currentName: string): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the color to use for a pod name.
|
|
39
|
+
* @param podName Name of the pod.
|
|
40
|
+
* @returns The color to use.
|
|
41
|
+
*/
|
|
42
|
+
getPodColor(podName: string): chalk.Chalk;
|
|
16
43
|
}
|
|
17
44
|
export default PaasLogs;
|
|
@@ -1,54 +1,173 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const readline = (0, tslib_1.__importStar)(require("readline"));
|
|
4
6
|
const command_1 = require("@oclif/command");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const login_1 = tslib_1.__importDefault(require("./login"));
|
|
7
|
+
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
|
+
const chrono = (0, tslib_1.__importStar)(require("chrono-node"));
|
|
8
9
|
const cli_ux_1 = require("cli-ux");
|
|
10
|
+
const login_1 = (0, tslib_1.__importDefault)(require("./login"));
|
|
11
|
+
const PaasKommand_1 = require("../../support/PaasKommand");
|
|
9
12
|
class PaasLogs extends PaasKommand_1.PaasKommand {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
/**
|
|
16
|
+
* Allowed colors for pod names.
|
|
17
|
+
*/
|
|
18
|
+
this.allColors = [chalk_1.default.red, chalk_1.default.green, chalk_1.default.yellow, chalk_1.default.blue, chalk_1.default.magenta, chalk_1.default.cyan, chalk_1.default.gray];
|
|
19
|
+
/**
|
|
20
|
+
* Available colors for pod names.
|
|
21
|
+
*/
|
|
22
|
+
this.availableColors = [...this.allColors];
|
|
23
|
+
/**
|
|
24
|
+
* The color to use for pod names.
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
this.podsColor = new Map();
|
|
28
|
+
}
|
|
10
29
|
async runSafe() {
|
|
30
|
+
var e_1, _a;
|
|
11
31
|
const apiKey = await this.getCredentials();
|
|
12
32
|
await this.initPaasClient({ apiKey });
|
|
13
33
|
const user = await this.paas.auth.getCurrentUser();
|
|
14
34
|
this.logInfo(`Logged as "${user._id}" for project "${this.flags.project || this.getProject()}"`);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
const separator = "\t";
|
|
36
|
+
// Parse the time arguments
|
|
37
|
+
const since = this.flags.since ? chrono.parseDate(this.flags.since).toISOString() : undefined;
|
|
38
|
+
const until = this.flags.until ? chrono.parseDate(this.flags.until).toISOString() : undefined;
|
|
39
|
+
// Perform the streamed request
|
|
40
|
+
const incomingMessage = await this.paas.queryHttpStream({
|
|
41
|
+
controller: "application",
|
|
42
|
+
action: "logs",
|
|
18
43
|
environmentId: this.args.environment,
|
|
19
44
|
projectId: this.flags.project || this.getProject(),
|
|
20
45
|
applicationId: this.args.application,
|
|
46
|
+
follow: this.flags.follow,
|
|
47
|
+
tailLines: this.flags.tail,
|
|
48
|
+
podName: this.flags.podName,
|
|
49
|
+
since,
|
|
50
|
+
until,
|
|
21
51
|
});
|
|
22
|
-
|
|
52
|
+
// Read the response line by line
|
|
53
|
+
const lineStream = readline.createInterface({
|
|
54
|
+
input: incomingMessage,
|
|
55
|
+
crlfDelay: Infinity,
|
|
56
|
+
terminal: false,
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
// Display the response
|
|
60
|
+
for (var lineStream_1 = (0, tslib_1.__asyncValues)(lineStream), lineStream_1_1; lineStream_1_1 = await lineStream_1.next(), !lineStream_1_1.done;) {
|
|
61
|
+
const line = lineStream_1_1.value;
|
|
62
|
+
// Parse the data
|
|
63
|
+
const data = JSON.parse(line);
|
|
64
|
+
// Exclude logs that are empty or that are not from a pod
|
|
65
|
+
if (!data.content || !data.podName) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Get the pod color
|
|
69
|
+
const podColor = this.getPodColor(data.podName);
|
|
70
|
+
// Display the log
|
|
71
|
+
const timestamp = this.flags.timestamp ? `[${new Date(data.timeStamp).toLocaleString()}] ` : "";
|
|
72
|
+
const name = podColor(`${data.podName}${separator}`);
|
|
73
|
+
this.log(`${timestamp}${name}| ${data.content}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
77
|
+
finally {
|
|
78
|
+
try {
|
|
79
|
+
if (lineStream_1_1 && !lineStream_1_1.done && (_a = lineStream_1.return)) await _a.call(lineStream_1);
|
|
80
|
+
}
|
|
81
|
+
finally { if (e_1) throw e_1.error; }
|
|
82
|
+
}
|
|
23
83
|
}
|
|
24
84
|
async getCredentials() {
|
|
25
85
|
const project = this.getProject();
|
|
26
86
|
const projectFile = this.fileProjectCredentials(project);
|
|
27
87
|
if (!fs_1.default.existsSync(projectFile)) {
|
|
28
|
-
this.log(
|
|
29
|
-
const nextStep = await cli_ux_1.cli.prompt(
|
|
30
|
-
this.log(
|
|
31
|
-
if (nextStep.toLowerCase().startsWith(
|
|
32
|
-
await login_1.default.run([
|
|
88
|
+
this.log("");
|
|
89
|
+
const nextStep = await cli_ux_1.cli.prompt("Cannot find credentials for this project. Do you want to login first? [Y/N]", { type: "single" });
|
|
90
|
+
this.log("");
|
|
91
|
+
if (nextStep.toLowerCase().startsWith("y")) {
|
|
92
|
+
await login_1.default.run(["--project", project]);
|
|
33
93
|
}
|
|
34
94
|
else {
|
|
35
|
-
this.logKo(
|
|
95
|
+
this.logKo("Aborting.");
|
|
36
96
|
process.exit(1);
|
|
37
97
|
}
|
|
38
98
|
}
|
|
39
|
-
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile,
|
|
99
|
+
const credentials = JSON.parse(fs_1.default.readFileSync(projectFile, "utf8"));
|
|
40
100
|
return credentials.apiKey;
|
|
41
101
|
}
|
|
102
|
+
getNumberOfSpaces(names, currentName) {
|
|
103
|
+
const end = 10;
|
|
104
|
+
let max = { name: '', length: 0 };
|
|
105
|
+
for (const name of names) {
|
|
106
|
+
if (max.length < name.length) {
|
|
107
|
+
max = { name: name, length: name.length };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return currentName === max.name ? end : end + (max.length - currentName.length);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns the color to use for a pod name.
|
|
114
|
+
* @param podName Name of the pod.
|
|
115
|
+
* @returns The color to use.
|
|
116
|
+
*/
|
|
117
|
+
getPodColor(podName) {
|
|
118
|
+
// Attempt to get the color from the list
|
|
119
|
+
let podColor = this.podsColor.get(podName);
|
|
120
|
+
if (!podColor) {
|
|
121
|
+
// Get a random color
|
|
122
|
+
const index = Math.floor(Math.random() * this.availableColors.length);
|
|
123
|
+
[podColor] = this.availableColors.splice(index, 1);
|
|
124
|
+
this.podsColor.set(podName, podColor);
|
|
125
|
+
// If all colors are used, reset the available colors
|
|
126
|
+
if (this.availableColors.length === 0) {
|
|
127
|
+
this.availableColors = [...this.allColors];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return podColor;
|
|
131
|
+
}
|
|
42
132
|
}
|
|
43
|
-
PaasLogs.description =
|
|
133
|
+
PaasLogs.description = "Show logs of the targeted application";
|
|
44
134
|
PaasLogs.flags = {
|
|
135
|
+
follow: command_1.flags.boolean({
|
|
136
|
+
char: "f",
|
|
137
|
+
description: "Follow log output",
|
|
138
|
+
}),
|
|
139
|
+
timestamp: command_1.flags.boolean({
|
|
140
|
+
char: "t",
|
|
141
|
+
description: "Show timestamp",
|
|
142
|
+
}),
|
|
45
143
|
help: command_1.flags.help(),
|
|
46
144
|
project: command_1.flags.string({
|
|
47
|
-
description:
|
|
145
|
+
description: "Current PaaS project",
|
|
146
|
+
}),
|
|
147
|
+
tail: command_1.flags.integer({
|
|
148
|
+
char: "n",
|
|
149
|
+
description: "Number of lines to show from the end of the logs",
|
|
150
|
+
}),
|
|
151
|
+
podName: command_1.flags.string({
|
|
152
|
+
description: "Name of the pod to show logs from",
|
|
153
|
+
}),
|
|
154
|
+
since: command_1.flags.string({
|
|
155
|
+
description: "Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time",
|
|
156
|
+
}),
|
|
157
|
+
until: command_1.flags.string({
|
|
158
|
+
description: "Display logs until a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time",
|
|
48
159
|
}),
|
|
49
160
|
};
|
|
50
161
|
PaasLogs.args = [
|
|
51
|
-
{
|
|
52
|
-
|
|
162
|
+
{
|
|
163
|
+
name: "environment",
|
|
164
|
+
description: "Kuzzle PaaS environment",
|
|
165
|
+
required: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "application",
|
|
169
|
+
description: "Kuzzle PaaS application",
|
|
170
|
+
required: true,
|
|
171
|
+
},
|
|
53
172
|
];
|
|
54
173
|
exports.default = PaasLogs;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class ProfileExport extends Kommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
@@ -10,7 +10,7 @@ export default class ProfileExport extends Kommand {
|
|
|
10
10
|
username: flags.IOptionFlag<string>;
|
|
11
11
|
password: flags.IOptionFlag<string | undefined>;
|
|
12
12
|
as: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
|
|
13
|
+
"api-key": flags.IOptionFlag<string | undefined>;
|
|
14
14
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
15
15
|
path: flags.IOptionFlag<string>;
|
|
16
16
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
5
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
7
|
const common_1 = require("../../common");
|
|
8
8
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
9
9
|
class ProfileExport extends common_1.Kommand {
|
|
10
10
|
async runSafe() {
|
|
11
|
-
const filename = path_1.default.join(this.flags.path,
|
|
11
|
+
const filename = path_1.default.join(this.flags.path, "profiles.json");
|
|
12
12
|
this.logInfo(`Exporting profiles in ${filename} ...`);
|
|
13
13
|
fs_1.default.mkdirSync(this.flags.path, { recursive: true });
|
|
14
14
|
const profiles = await this._dumpProfiles();
|
|
15
15
|
const dump = {
|
|
16
|
-
type:
|
|
17
|
-
content: profiles
|
|
16
|
+
type: "profiles",
|
|
17
|
+
content: profiles,
|
|
18
18
|
};
|
|
19
19
|
fs_1.default.writeFileSync(filename, JSON.stringify(dump, null, 2));
|
|
20
20
|
this.logOk(`${Object.keys(profiles).length} profiles dumped`);
|
|
21
21
|
}
|
|
22
22
|
async _dumpProfiles() {
|
|
23
23
|
const options = {
|
|
24
|
-
scroll:
|
|
25
|
-
size: 100
|
|
24
|
+
scroll: "3s",
|
|
25
|
+
size: 100,
|
|
26
26
|
};
|
|
27
27
|
let result = await this.sdk.security.searchProfiles({}, options);
|
|
28
28
|
const profiles = {};
|
|
@@ -36,11 +36,11 @@ class ProfileExport extends common_1.Kommand {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
exports.default = ProfileExport;
|
|
39
|
-
ProfileExport.description =
|
|
39
|
+
ProfileExport.description = "Exports profiles";
|
|
40
40
|
ProfileExport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}), path: command_1.flags.string({
|
|
41
|
-
description:
|
|
42
|
-
default:
|
|
41
|
+
description: "Dump directory",
|
|
42
|
+
default: "profiles",
|
|
43
43
|
}) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
|
|
44
|
-
description:
|
|
45
|
-
default:
|
|
44
|
+
description: "Kuzzle protocol (http or websocket)",
|
|
45
|
+
default: "ws",
|
|
46
46
|
}) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class ProfileImport extends Kommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
@@ -10,7 +10,7 @@ export default class ProfileImport extends Kommand {
|
|
|
10
10
|
username: flags.IOptionFlag<string>;
|
|
11
11
|
password: flags.IOptionFlag<string | undefined>;
|
|
12
12
|
as: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
|
|
13
|
+
"api-key": flags.IOptionFlag<string | undefined>;
|
|
14
14
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
15
15
|
};
|
|
16
16
|
static args: {
|
|
@@ -2,24 +2,22 @@
|
|
|
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"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
const restore_securities_1 = require("../../support/restore-securities");
|
|
9
9
|
class ProfileImport extends common_1.Kommand {
|
|
10
10
|
async runSafe() {
|
|
11
11
|
this.logInfo(`Importing profiles from ${this.args.path} ...`);
|
|
12
|
-
const dump = JSON.parse(fs_1.default.readFileSync(this.args.path,
|
|
12
|
+
const dump = JSON.parse(fs_1.default.readFileSync(this.args.path, "utf-8"));
|
|
13
13
|
const count = await (0, restore_securities_1.restoreProfiles)(this, dump);
|
|
14
14
|
this.logOk(`${count} profiles restored`);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.default = ProfileImport;
|
|
18
|
-
ProfileImport.description =
|
|
18
|
+
ProfileImport.description = "Imports profiles";
|
|
19
19
|
ProfileImport.flags = Object.assign(Object.assign({ help: command_1.flags.help({}) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
|
|
20
|
-
description:
|
|
21
|
-
default:
|
|
20
|
+
description: "Kuzzle protocol (http or websocket)",
|
|
21
|
+
default: "ws",
|
|
22
22
|
}) });
|
|
23
|
-
ProfileImport.args = [
|
|
24
|
-
{ name: 'path', description: 'Dump file', required: true },
|
|
25
|
-
];
|
|
23
|
+
ProfileImport.args = [{ name: "path", description: "Dump file", required: true }];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class RealtimeSubscribe extends Kommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
@@ -11,7 +11,7 @@ export default class RealtimeSubscribe extends Kommand {
|
|
|
11
11
|
username: flags.IOptionFlag<string>;
|
|
12
12
|
password: flags.IOptionFlag<string | undefined>;
|
|
13
13
|
as: flags.IOptionFlag<string | undefined>;
|
|
14
|
-
|
|
14
|
+
"api-key": flags.IOptionFlag<string | undefined>;
|
|
15
15
|
scope: flags.IOptionFlag<string>;
|
|
16
16
|
users: flags.IOptionFlag<string>;
|
|
17
17
|
volatile: flags.IOptionFlag<string>;
|
|
@@ -2,24 +2,24 @@
|
|
|
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 lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
5
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const kuzzle_1 = require("../../support/kuzzle");
|
|
8
8
|
class RealtimeSubscribe extends common_1.Kommand {
|
|
9
9
|
async beforeConnect() {
|
|
10
|
-
if (this.flags.protocol ===
|
|
11
|
-
throw new Error(
|
|
10
|
+
if (this.flags.protocol === "http") {
|
|
11
|
+
throw new Error("Realtime notification does not work with the Http protocol");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
async runSafe() {
|
|
15
|
-
let filters = this.stdin ? this.stdin : this.args.filters ||
|
|
15
|
+
let filters = this.stdin ? this.stdin : this.args.filters || "{}";
|
|
16
16
|
// content from user editor
|
|
17
17
|
if (this.flags.editor) {
|
|
18
18
|
filters = this.fromEditor(filters, { json: true });
|
|
19
19
|
}
|
|
20
20
|
await this.sdk.realtime.subscribe(this.args.index, this.args.collection, this.parseJs(filters), (notification) => {
|
|
21
21
|
this.logInfo(`New notification triggered by API action "${notification.controller}:${notification.action}"`);
|
|
22
|
-
const display = this.flags.display ===
|
|
22
|
+
const display = this.flags.display === ""
|
|
23
23
|
? notification
|
|
24
24
|
: lodash_1.default.get(notification, this.flags.display);
|
|
25
25
|
this.log(JSON.stringify(display, null, 2));
|
|
@@ -34,35 +34,35 @@ class RealtimeSubscribe extends common_1.Kommand {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.default = RealtimeSubscribe;
|
|
37
|
-
RealtimeSubscribe.description =
|
|
37
|
+
RealtimeSubscribe.description = "Subscribes to realtime notifications";
|
|
38
38
|
RealtimeSubscribe.examples = [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
"kourou realtime:subscribe iot-data sensors",
|
|
40
|
+
"kourou realtime:subscribe iot-data sensors '{ range: { temperature: { gt: 0 } } }'",
|
|
41
|
+
"kourou realtime:subscribe iot-data sensors '{ exists: \"position\" }' --scope out",
|
|
42
|
+
"kourou realtime:subscribe iot-data sensors --users all --volatile '{ clientId: \"citizen-kane\" }'",
|
|
43
|
+
"kourou realtime:subscribe iot-data sensors --display result._source.temperature",
|
|
44
44
|
];
|
|
45
45
|
RealtimeSubscribe.flags = Object.assign(Object.assign({ scope: command_1.flags.string({
|
|
46
|
-
description:
|
|
47
|
-
default:
|
|
46
|
+
description: "Subscribe to document entering or leaving the scope (all, in, out, none)",
|
|
47
|
+
default: "all",
|
|
48
48
|
}), users: command_1.flags.string({
|
|
49
|
-
description:
|
|
50
|
-
default:
|
|
49
|
+
description: "Subscribe to users entering or leaving the room (all, in, out, none)",
|
|
50
|
+
default: "all",
|
|
51
51
|
}), volatile: command_1.flags.string({
|
|
52
|
-
description:
|
|
53
|
-
default:
|
|
52
|
+
description: "Additional subscription information used in user join/leave notifications",
|
|
53
|
+
default: "{}",
|
|
54
54
|
}), display: command_1.flags.string({
|
|
55
|
-
description:
|
|
56
|
-
default:
|
|
55
|
+
description: "Path of the property to display from the notification (empty string to display everything)",
|
|
56
|
+
default: "result",
|
|
57
57
|
}), editor: command_1.flags.boolean({
|
|
58
|
-
description:
|
|
58
|
+
description: "Open an editor (EDITOR env variable) to edit the filters before subscribing.",
|
|
59
59
|
}), help: command_1.flags.help() }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
|
|
60
|
-
description:
|
|
61
|
-
default:
|
|
60
|
+
description: "Kuzzle protocol (only websocket for realtime)",
|
|
61
|
+
default: "websocket",
|
|
62
62
|
}) });
|
|
63
63
|
RealtimeSubscribe.args = [
|
|
64
|
-
{ name:
|
|
65
|
-
{ name:
|
|
66
|
-
{ name:
|
|
64
|
+
{ name: "index", description: "Index name", required: true },
|
|
65
|
+
{ name: "collection", description: "Collection name", required: true },
|
|
66
|
+
{ name: "filters", description: "Set of Koncorde filters" },
|
|
67
67
|
];
|
|
68
68
|
RealtimeSubscribe.readStdin = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class RedisListKeys extends Kommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
@@ -10,7 +10,7 @@ export default class RedisListKeys extends Kommand {
|
|
|
10
10
|
password: flags.IOptionFlag<string | undefined>;
|
|
11
11
|
protocol: flags.IOptionFlag<string>;
|
|
12
12
|
as: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
|
|
13
|
+
"api-key": flags.IOptionFlag<string | undefined>;
|
|
14
14
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
15
15
|
remove: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
16
16
|
size: flags.IOptionFlag<string>;
|
|
@@ -10,7 +10,7 @@ class RedisListKeys extends common_1.Kommand {
|
|
|
10
10
|
const maxPages = parseInt(this.flags.max, 10);
|
|
11
11
|
this.logInfo(`Start searching for keys matching "${match}...`);
|
|
12
12
|
let keys = [];
|
|
13
|
-
let cursor =
|
|
13
|
+
let cursor = "0";
|
|
14
14
|
let pages = 0;
|
|
15
15
|
do {
|
|
16
16
|
const result = await this.sdk.ms.scan(cursor, { count, match });
|
|
@@ -20,11 +20,11 @@ class RedisListKeys extends common_1.Kommand {
|
|
|
20
20
|
}
|
|
21
21
|
pages++;
|
|
22
22
|
process.stdout.write(`Iterate on page ${pages}. ${keys.length} keys found so far.`);
|
|
23
|
-
process.stdout.write(
|
|
23
|
+
process.stdout.write("\r");
|
|
24
24
|
if (maxPages !== -1 && pages >= maxPages) {
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
|
-
} while (cursor !==
|
|
27
|
+
} while (cursor !== "0");
|
|
28
28
|
keys = keys.sort();
|
|
29
29
|
const values = await this.sdk.ms.mget(keys);
|
|
30
30
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -40,19 +40,23 @@ class RedisListKeys extends common_1.Kommand {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.default = RedisListKeys;
|
|
43
|
-
RedisListKeys.description =
|
|
43
|
+
RedisListKeys.description = "Lists keys stored in Redis";
|
|
44
44
|
RedisListKeys.flags = Object.assign({ help: command_1.flags.help(), remove: command_1.flags.boolean({
|
|
45
|
-
description:
|
|
46
|
-
default: false
|
|
45
|
+
description: "Remove matching keys",
|
|
46
|
+
default: false,
|
|
47
47
|
}), size: command_1.flags.string({
|
|
48
|
-
description:
|
|
49
|
-
default:
|
|
48
|
+
description: "Page size",
|
|
49
|
+
default: "100",
|
|
50
50
|
}), max: command_1.flags.string({
|
|
51
|
-
description:
|
|
52
|
-
default:
|
|
51
|
+
description: "Maximum number of page to retrieve (-1 to retrieve everything)",
|
|
52
|
+
default: "-1",
|
|
53
53
|
}) }, kuzzle_1.kuzzleFlags);
|
|
54
54
|
RedisListKeys.args = [
|
|
55
|
-
{
|
|
55
|
+
{
|
|
56
|
+
name: "match",
|
|
57
|
+
description: "Match Redis keys with a pattern",
|
|
58
|
+
default: "*",
|
|
59
|
+
},
|
|
56
60
|
];
|
|
57
61
|
RedisListKeys.examples = [
|
|
58
62
|
'kourou redis:list-keys "*cluster*"',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flags } from
|
|
2
|
-
import { Kommand } from
|
|
1
|
+
import { flags } from "@oclif/command";
|
|
2
|
+
import { Kommand } from "../../common";
|
|
3
3
|
export default class RoleDump extends Kommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
@@ -10,7 +10,7 @@ export default class RoleDump extends Kommand {
|
|
|
10
10
|
username: flags.IOptionFlag<string>;
|
|
11
11
|
password: flags.IOptionFlag<string | undefined>;
|
|
12
12
|
as: flags.IOptionFlag<string | undefined>;
|
|
13
|
-
|
|
13
|
+
"api-key": flags.IOptionFlag<string | undefined>;
|
|
14
14
|
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
15
15
|
path: flags.IOptionFlag<string>;
|
|
16
16
|
};
|