kourou 0.19.4 → 0.19.5
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 +111 -104
- package/lib/commands/collection/export.d.ts +1 -0
- package/lib/commands/collection/export.js +21 -4
- package/lib/common.d.ts +17 -0
- package/lib/common.js +29 -1
- package/lib/support/dump-collection.d.ts +1 -1
- package/lib/support/dump-collection.js +207 -57
- package/oclif.manifest.json +1 -1
- package/package.json +15 -15
- package/templates.tgz +0 -0
- package/lib/commands/es/snapshot/restore.d.ts +0 -18
- package/lib/commands/es/snapshot/restore.js +0 -52
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ $ npm install -g kourou
|
|
|
25
25
|
$ kourou COMMAND
|
|
26
26
|
running command...
|
|
27
27
|
$ kourou (-v|--version|version)
|
|
28
|
-
kourou/0.19.
|
|
28
|
+
kourou/0.19.5 linux-x64 node-v12.22.8
|
|
29
29
|
$ kourou --help [COMMAND]
|
|
30
30
|
USAGE
|
|
31
31
|
$ kourou COMMAND
|
|
@@ -143,7 +143,6 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
|
|
|
143
143
|
* [`kourou es:snapshot:create REPOSITORY NAME`](#kourou-essnapshotcreate-repository-name)
|
|
144
144
|
* [`kourou es:snapshot:create-repository REPOSITORY LOCATION`](#kourou-essnapshotcreate-repository-repository-location)
|
|
145
145
|
* [`kourou es:snapshot:list REPOSITORY`](#kourou-essnapshotlist-repository)
|
|
146
|
-
* [`kourou es:snapshot:restore REPOSITORY NAME`](#kourou-essnapshotrestore-repository-name)
|
|
147
146
|
* [`kourou file:decrypt FILE`](#kourou-filedecrypt-file)
|
|
148
147
|
* [`kourou file:encrypt FILE`](#kourou-fileencrypt-file)
|
|
149
148
|
* [`kourou file:test FILE`](#kourou-filetest-file)
|
|
@@ -379,31 +378,58 @@ ARGUMENTS
|
|
|
379
378
|
COLLECTION Collection name
|
|
380
379
|
|
|
381
380
|
OPTIONS
|
|
382
|
-
--api-key=api-key
|
|
383
|
-
|
|
384
|
-
--batch-size=batch-size [default: 2000] Maximum batch size (see limits.documentsFetchCount config)
|
|
385
|
-
--editor Open an editor (EDITOR env variable) to edit the query before sending
|
|
381
|
+
--api-key=api-key
|
|
382
|
+
Kuzzle user api-key
|
|
386
383
|
|
|
387
|
-
--
|
|
388
|
-
|
|
384
|
+
--as=as
|
|
385
|
+
Impersonate a user
|
|
389
386
|
|
|
390
|
-
--
|
|
387
|
+
--batch-size=batch-size
|
|
388
|
+
[default: 2000] Maximum batch size (see limits.documentsFetchCount config)
|
|
391
389
|
|
|
392
|
-
--
|
|
390
|
+
--editor
|
|
391
|
+
Open an editor (EDITOR env variable) to edit the query before sending
|
|
393
392
|
|
|
394
|
-
--
|
|
393
|
+
--fields=fields
|
|
394
|
+
[CSV format only] The list of fields to be included in the CSV export in dot-path format.
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
Example:
|
|
397
|
+
--fields oneField,anotherField,yetAnotherOne.nested.moarNested
|
|
397
398
|
|
|
398
|
-
|
|
399
|
+
Note that the '_id' field is always included in the CSV export. Leaving this option empty implies that all
|
|
400
|
+
exportable fields in the mapping will be exported.
|
|
399
401
|
|
|
400
|
-
--
|
|
402
|
+
--format=jsonl|kuzzle|csv
|
|
403
|
+
[default: jsonl] "kuzzle" will export in Kuzzle format usable for internal fixtures,
|
|
404
|
+
"jsonl" allows to import that data back with kourou,
|
|
405
|
+
"csv" allows to import data into Excel (please, specify the fields to export using the --fields option).
|
|
401
406
|
|
|
402
|
-
--
|
|
407
|
+
--help
|
|
408
|
+
show CLI help
|
|
403
409
|
|
|
404
|
-
--
|
|
410
|
+
--host=host
|
|
411
|
+
[default: localhost] Kuzzle server host
|
|
405
412
|
|
|
406
|
-
--
|
|
413
|
+
--password=password
|
|
414
|
+
Kuzzle user password
|
|
415
|
+
|
|
416
|
+
--path=path
|
|
417
|
+
Dump root directory
|
|
418
|
+
|
|
419
|
+
--port=port
|
|
420
|
+
[default: 7512] Kuzzle server port
|
|
421
|
+
|
|
422
|
+
--protocol=protocol
|
|
423
|
+
[default: ws] Kuzzle protocol (http or websocket)
|
|
424
|
+
|
|
425
|
+
--query=query
|
|
426
|
+
[default: {}] Only dump documents matching the query (JS or JSON format)
|
|
427
|
+
|
|
428
|
+
--ssl
|
|
429
|
+
Use SSL to connect to Kuzzle
|
|
430
|
+
|
|
431
|
+
--username=username
|
|
432
|
+
[default: anonymous] Kuzzle username (local strategy)
|
|
407
433
|
|
|
408
434
|
EXAMPLES
|
|
409
435
|
kourou collection:export nyc-open-data yellow-taxi
|
|
@@ -637,25 +663,6 @@ OPTIONS
|
|
|
637
663
|
|
|
638
664
|
_See code: [src/commands/es/snapshot/list.ts](src/commands/es/snapshot/list.ts)_
|
|
639
665
|
|
|
640
|
-
## `kourou es:snapshot:restore REPOSITORY NAME`
|
|
641
|
-
|
|
642
|
-
Restore a snapshot into an ES instance
|
|
643
|
-
|
|
644
|
-
```
|
|
645
|
-
USAGE
|
|
646
|
-
$ kourou es:snapshot:restore REPOSITORY NAME
|
|
647
|
-
|
|
648
|
-
ARGUMENTS
|
|
649
|
-
REPOSITORY ES repository name
|
|
650
|
-
NAME ES snapshot name
|
|
651
|
-
|
|
652
|
-
OPTIONS
|
|
653
|
-
-n, --node=node [default: http://localhost:9200] Elasticsearch server URL
|
|
654
|
-
--help show CLI help
|
|
655
|
-
```
|
|
656
|
-
|
|
657
|
-
_See code: [src/commands/es/snapshot/restore.ts](src/commands/es/snapshot/restore.ts)_
|
|
658
|
-
|
|
659
666
|
## `kourou file:decrypt FILE`
|
|
660
667
|
|
|
661
668
|
Decrypts an encrypted file.
|
|
@@ -737,7 +744,7 @@ OPTIONS
|
|
|
737
744
|
--all see all commands in CLI
|
|
738
745
|
```
|
|
739
746
|
|
|
740
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.
|
|
747
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2/src/commands/help.ts)_
|
|
741
748
|
|
|
742
749
|
## `kourou import PATH`
|
|
743
750
|
|
|
@@ -1111,29 +1118,29 @@ DESCRIPTION
|
|
|
1111
1118
|
|
|
1112
1119
|
Code Execution
|
|
1113
1120
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1121
|
+
Provided code will be executed in an async method.
|
|
1122
|
+
You can access a connected and authenticated SDK with the "sdk" variable.
|
|
1123
|
+
Templated variable passed as the command arguments are also accessible within the same name.
|
|
1124
|
+
Returned value will be printed on the standard output (e.g. 'return await sdk.server.now();').
|
|
1125
|
+
Errors will be caught and printed on the error output (e.g. 'throw new Error("failure");').
|
|
1119
1126
|
|
|
1120
1127
|
Provide code
|
|
1121
1128
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1129
|
+
code can be passed as an argument
|
|
1130
|
+
code will be read from STDIN if available
|
|
1124
1131
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1132
|
+
Examples:
|
|
1133
|
+
- kourou sdk:execute 'return await sdk.server.now()'
|
|
1134
|
+
- kourou sdk:execute 'return await sdk.index.exists(index)' --var 'index="iot-data"'
|
|
1135
|
+
- kourou sdk:execute < snippet.js
|
|
1136
|
+
- echo 'return await sdk.server.now()' | kourou sdk:execute
|
|
1130
1137
|
|
|
1131
1138
|
Other
|
|
1132
1139
|
|
|
1133
|
-
|
|
1140
|
+
use the --editor flag to modify the code before executing it
|
|
1134
1141
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1142
|
+
Examples:
|
|
1143
|
+
- kourou sdk:execute 'return await sdk.server.now()' --editor
|
|
1137
1144
|
```
|
|
1138
1145
|
|
|
1139
1146
|
_See code: [src/commands/sdk/execute.ts](src/commands/sdk/execute.ts)_
|
|
@@ -1184,55 +1191,55 @@ DESCRIPTION
|
|
|
1184
1191
|
|
|
1185
1192
|
Query arguments
|
|
1186
1193
|
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1194
|
+
Arguments can be passed and repeated using the --arg or -a flag.
|
|
1195
|
+
Index and collection names can be passed with --index (-i) and --collection (-c) flags
|
|
1196
|
+
ID can be passed with the --id flag.
|
|
1190
1197
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1198
|
+
Examples:
|
|
1199
|
+
- kourou sdk:query document:delete -i iot -c sensors -a refresh=wait_for
|
|
1193
1200
|
|
|
1194
1201
|
Query body
|
|
1195
1202
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1203
|
+
Body can be passed with the --body flag with either a JSON or JS string.
|
|
1204
|
+
Body will be read from STDIN if available
|
|
1198
1205
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1206
|
+
Examples:
|
|
1207
|
+
- kourou sdk:query document:create -i iot -c sensors --body '{creation: Date.now())}'
|
|
1208
|
+
- kourou sdk:query admin:loadMappings < mappings.json
|
|
1209
|
+
- echo '{dynamic: "strict"}' | kourou sdk:query collection:create -i iot -c sensors
|
|
1203
1210
|
|
|
1204
1211
|
Other
|
|
1205
1212
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1213
|
+
Use the --editor flag to modify the query before sending it to Kuzzle
|
|
1214
|
+
Use the --display flag to display a specific property of the response
|
|
1208
1215
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1216
|
+
Examples:
|
|
1217
|
+
- kourou sdk:query document:create -i iot -c sensors --editor
|
|
1218
|
+
- kourou sdk:query server:now --display 'result.now'
|
|
1212
1219
|
|
|
1213
1220
|
Default fallback to API action
|
|
1214
1221
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1222
|
+
It's possible to use the "sdk:query" command by only specifying the corresponding controller
|
|
1223
|
+
and action as first argument.
|
|
1217
1224
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
+
Kourou will try to infer the first arguments to one the following pattern:
|
|
1226
|
+
- <command> <index>
|
|
1227
|
+
- <command> <body>
|
|
1228
|
+
- <command> <index> <collection>
|
|
1229
|
+
- <command> <index> <collection> <id>
|
|
1230
|
+
- <command> <index> <collection> <body>
|
|
1231
|
+
- <command> <index> <collection> <id> <body>
|
|
1225
1232
|
|
|
1226
|
-
|
|
1227
|
-
|
|
1233
|
+
If a flag is given (-i, -c, --body or --id), then the flag value has priority over
|
|
1234
|
+
argument infering.
|
|
1228
1235
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
+
Examples:
|
|
1237
|
+
- kourou collection:list iot
|
|
1238
|
+
- kourou security:createUser '{ "content": { "profileIds": ["default"] } }' --id yagmur
|
|
1239
|
+
- kourou collection:delete iot sensors
|
|
1240
|
+
- kourou document:createOrReplace iot sensors sigfox-1 '{}'
|
|
1241
|
+
- kourou bulk:import iot sensors '{ bulkData: [...] }'
|
|
1242
|
+
- kourou admin:loadMappings < mappings.json
|
|
1236
1243
|
```
|
|
1237
1244
|
|
|
1238
1245
|
_See code: [src/commands/sdk/query.ts](src/commands/sdk/query.ts)_
|
|
@@ -1267,24 +1274,24 @@ DESCRIPTION
|
|
|
1267
1274
|
The users will be exported WITHOUT their credentials since Kuzzzle can't access them.
|
|
1268
1275
|
|
|
1269
1276
|
You can either:
|
|
1270
|
-
|
|
1271
|
-
|
|
1277
|
+
- Manually re-create credentials for your users
|
|
1278
|
+
- Use the "mustChangePasswordIfSetByAdmin" option Kuzzle password policies (see
|
|
1272
1279
|
https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local/#optional-properties)
|
|
1273
|
-
|
|
1280
|
+
- Use the "--generate-credentials" flag to auto-generate credentials for your users
|
|
1274
1281
|
|
|
1275
1282
|
Auto-generation of credentials
|
|
1276
1283
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1284
|
+
With the "--generate-credentials" flag, Kourou will add credentials for the "local" strategy.
|
|
1285
|
+
By default, the username will be the user ID.
|
|
1286
|
+
Use the "generated-username" flag to use an other property than the user ID for the generated username
|
|
1287
|
+
The password will be a strong random 40 characters string
|
|
1281
1288
|
|
|
1282
1289
|
Examples:
|
|
1283
1290
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1291
|
+
- kourou user:export
|
|
1292
|
+
- kourou user:export --exclude '.*admin.*' --exclude 'supervisor.*'
|
|
1293
|
+
- kourou user:export --generate-credentials
|
|
1294
|
+
- kourou user:export --generate-credentials --generated-username content.email
|
|
1288
1295
|
```
|
|
1289
1296
|
|
|
1290
1297
|
_See code: [src/commands/user/export.ts](src/commands/user/export.ts)_
|
|
@@ -1446,11 +1453,11 @@ DESCRIPTION
|
|
|
1446
1453
|
|
|
1447
1454
|
Example:
|
|
1448
1455
|
{
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1456
|
+
aws: {
|
|
1457
|
+
s3: {
|
|
1458
|
+
keyId: 'b61e267676660c314b006b06'
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1454
1461
|
}
|
|
1455
1462
|
|
|
1456
1463
|
Encrypted secrets are meant to be loaded inside an application with Kuzzle Vault.
|
|
@@ -1483,8 +1490,8 @@ DESCRIPTION
|
|
|
1483
1490
|
Prints an encrypted secrets file content.
|
|
1484
1491
|
|
|
1485
1492
|
This method can display either:
|
|
1486
|
-
|
|
1487
|
-
|
|
1493
|
+
- the entire content of the secrets file
|
|
1494
|
+
- a single key value
|
|
1488
1495
|
|
|
1489
1496
|
See https://github.com/kuzzleio/kuzzle-vault/ for more information.
|
|
1490
1497
|
|
|
@@ -17,6 +17,7 @@ export default class CollectionExport extends Kommand {
|
|
|
17
17
|
query: flags.IOptionFlag<string>;
|
|
18
18
|
editor: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
19
19
|
format: flags.IOptionFlag<string>;
|
|
20
|
+
fields: flags.IOptionFlag<string | undefined>;
|
|
20
21
|
};
|
|
21
22
|
static args: {
|
|
22
23
|
name: string;
|
|
@@ -12,16 +12,22 @@ class CollectionExport extends common_1.Kommand {
|
|
|
12
12
|
const exportPath = this.flags.path
|
|
13
13
|
? path_1.default.join(this.flags.path, this.args.index)
|
|
14
14
|
: this.args.index;
|
|
15
|
+
const fields = this.flags.fields
|
|
16
|
+
? this.flags.fields.split(',')
|
|
17
|
+
: [];
|
|
18
|
+
if (this.flags.format === 'csv' && fields.length === 0) {
|
|
19
|
+
this.logInfo('It looks like you are exporting to CSV but you did not select any field. All exportable fields in the mapping will be exported.');
|
|
20
|
+
}
|
|
15
21
|
let query = this.parseJs(this.flags.query);
|
|
16
22
|
if (this.flags.editor) {
|
|
17
23
|
query = this.fromEditor(query, { json: true });
|
|
18
24
|
}
|
|
19
25
|
const countAll = await this.sdk.document.count(this.args.index, this.args.collection);
|
|
20
26
|
const count = await this.sdk.document.count(this.args.index, this.args.collection, { query });
|
|
21
|
-
this.logInfo(`Dumping ${count} of ${countAll} documents from collection "${this.args.index}:${this.args.collection}" in ${
|
|
27
|
+
this.logInfo(`Dumping ${count} of ${countAll} documents from collection "${this.args.index}:${this.args.collection}" in ${exportPath} ...`);
|
|
22
28
|
fs_1.default.mkdirSync(exportPath, { recursive: true });
|
|
23
29
|
await (0, dump_collection_1.dumpCollectionMappings)(this.sdk, this.args.index, this.args.collection, exportPath, this.flags.format);
|
|
24
|
-
await (0, dump_collection_1.dumpCollectionData)(this.sdk, this.args.index, this.args.collection, Number(this.flags['batch-size']), exportPath, query, this.flags.format);
|
|
30
|
+
await (0, dump_collection_1.dumpCollectionData)(this.sdk, this.args.index, this.args.collection, Number(this.flags['batch-size']), exportPath, query, this.flags.format, fields);
|
|
25
31
|
this.logOk(`Collection ${this.args.index}:${this.args.collection} dumped`);
|
|
26
32
|
}
|
|
27
33
|
}
|
|
@@ -38,8 +44,19 @@ CollectionExport.flags = Object.assign(Object.assign({ help: command_1.flags.hel
|
|
|
38
44
|
}), editor: command_1.flags.boolean({
|
|
39
45
|
description: 'Open an editor (EDITOR env variable) to edit the query before sending'
|
|
40
46
|
}), format: command_1.flags.string({
|
|
41
|
-
description:
|
|
42
|
-
|
|
47
|
+
description: `"kuzzle" will export in Kuzzle format usable for internal fixtures,
|
|
48
|
+
"jsonl" allows to import that data back with kourou,
|
|
49
|
+
"csv" allows to import data into Excel (please, specify the fields to export using the --fields option).`,
|
|
50
|
+
options: ['jsonl', 'kuzzle', 'csv'],
|
|
51
|
+
default: 'jsonl'
|
|
52
|
+
}), fields: command_1.flags.string({
|
|
53
|
+
description: `[CSV format only] The list of fields to be included in the CSV export in dot-path format.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
--fields oneField,anotherField,yetAnotherOne.nested.moarNested
|
|
57
|
+
|
|
58
|
+
Note that the '_id' field is always included in the CSV export. Leaving this option empty implies that all
|
|
59
|
+
exportable fields in the mapping will be exported.`
|
|
43
60
|
}) }, kuzzle_1.kuzzleFlags), { protocol: command_1.flags.string({
|
|
44
61
|
description: 'Kuzzle protocol (http or websocket)',
|
|
45
62
|
default: 'ws',
|
package/lib/common.d.ts
CHANGED
|
@@ -27,3 +27,20 @@ export declare abstract class Kommand extends Command {
|
|
|
27
27
|
fromEditor(defaultContent: Record<string, unknown> | string, options?: EditorParams): Record<string, unknown>;
|
|
28
28
|
parseJs(input?: string): any;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* An iteration-order-safe version of lodash.values
|
|
32
|
+
*
|
|
33
|
+
* @param object The object containing the values
|
|
34
|
+
* @param fields The field names to pick in the right order
|
|
35
|
+
* @returns The values in the same order as the fields
|
|
36
|
+
* @see https://lodash.com/docs/4.17.15#values
|
|
37
|
+
*/
|
|
38
|
+
export declare function pickValues(object: any, fields: string[]): any[];
|
|
39
|
+
/**
|
|
40
|
+
* Formats the value for correct CSV output, avoiding to return
|
|
41
|
+
* values that would badly serialize in CSV.
|
|
42
|
+
*
|
|
43
|
+
* @param value The value to format
|
|
44
|
+
* @returns The value or a string telling the value is not scalar
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatValueForCSV(value: any): any;
|
package/lib/common.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Kommand = void 0;
|
|
3
|
+
exports.formatValueForCSV = exports.pickValues = exports.Kommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
7
7
|
const node_emoji_1 = (0, tslib_1.__importDefault)(require("node-emoji"));
|
|
8
8
|
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
9
|
+
const get_1 = (0, tslib_1.__importDefault)(require("lodash/get"));
|
|
10
|
+
const isObject_1 = (0, tslib_1.__importDefault)(require("lodash/isObject"));
|
|
9
11
|
const kuzzle_1 = require("./support/kuzzle");
|
|
10
12
|
const editor_1 = require("./support/editor");
|
|
11
13
|
class Kommand extends command_1.Command {
|
|
@@ -131,3 +133,29 @@ class Kommand extends command_1.Command {
|
|
|
131
133
|
exports.Kommand = Kommand;
|
|
132
134
|
Kommand.initSdk = true;
|
|
133
135
|
Kommand.readStdin = false;
|
|
136
|
+
/**
|
|
137
|
+
* An iteration-order-safe version of lodash.values
|
|
138
|
+
*
|
|
139
|
+
* @param object The object containing the values
|
|
140
|
+
* @param fields The field names to pick in the right order
|
|
141
|
+
* @returns The values in the same order as the fields
|
|
142
|
+
* @see https://lodash.com/docs/4.17.15#values
|
|
143
|
+
*/
|
|
144
|
+
function pickValues(object, fields) {
|
|
145
|
+
return fields.map(f => formatValueForCSV((0, get_1.default)(object, f)));
|
|
146
|
+
}
|
|
147
|
+
exports.pickValues = pickValues;
|
|
148
|
+
/**
|
|
149
|
+
* Formats the value for correct CSV output, avoiding to return
|
|
150
|
+
* values that would badly serialize in CSV.
|
|
151
|
+
*
|
|
152
|
+
* @param value The value to format
|
|
153
|
+
* @returns The value or a string telling the value is not scalar
|
|
154
|
+
*/
|
|
155
|
+
function formatValueForCSV(value) {
|
|
156
|
+
if ((0, isObject_1.default)(value)) {
|
|
157
|
+
return '[NOT_SCALAR]';
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
exports.formatValueForCSV = formatValueForCSV;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function dumpCollectionData(sdk: any, index: string, collection: string, batchSize: number, destPath: string, query?: any, format?: string): Promise<
|
|
1
|
+
export declare function dumpCollectionData(sdk: any, index: string, collection: string, batchSize: number, destPath: string, query?: any, format?: string, fields?: string[]): Promise<void>;
|
|
2
2
|
export declare function dumpCollectionMappings(sdk: any, index: string, collection: string, destPath: string, format?: string): Promise<void>;
|
|
@@ -6,72 +6,222 @@ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
|
6
6
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
7
7
|
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
8
8
|
const ndjson_1 = (0, tslib_1.__importDefault)(require("ndjson"));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const common_1 = require("../common");
|
|
10
|
+
/**
|
|
11
|
+
* Flatten an object transform:
|
|
12
|
+
* {
|
|
13
|
+
* title: "kuzzle",
|
|
14
|
+
* info : {
|
|
15
|
+
* tag: "news"
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* Into an object like:
|
|
20
|
+
* {
|
|
21
|
+
* title: "kuzzle",
|
|
22
|
+
* info.tag: news
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} target the object we have to flatten
|
|
26
|
+
* @returns {Object} the flattened object
|
|
27
|
+
*/
|
|
28
|
+
function flattenObject(target) {
|
|
29
|
+
const output = {};
|
|
30
|
+
flattenStep(output, target);
|
|
31
|
+
return output;
|
|
32
|
+
}
|
|
33
|
+
function flattenStep(output, object, prev = null) {
|
|
34
|
+
const keys = Object.keys(object);
|
|
35
|
+
for (let i = 0; i < keys.length; i++) {
|
|
36
|
+
const key = keys[i];
|
|
37
|
+
const value = object[key];
|
|
38
|
+
const newKey = prev ? prev + '.' + key : key;
|
|
39
|
+
if (Object.prototype.toString.call(value) === '[object Object]') {
|
|
40
|
+
output[newKey] = value;
|
|
41
|
+
flattenStep(output, value, newKey);
|
|
42
|
+
}
|
|
43
|
+
output[newKey] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class AbstractDumper {
|
|
47
|
+
constructor(sdk, index, collection, batchSize, destPath, query = {}) {
|
|
48
|
+
this.sdk = sdk;
|
|
49
|
+
this.index = index;
|
|
50
|
+
this.collection = collection;
|
|
51
|
+
this.batchSize = batchSize;
|
|
52
|
+
this.destPath = destPath;
|
|
53
|
+
this.query = query;
|
|
54
|
+
this.collectionDir = path_1.default.join(this.destPath, this.collection);
|
|
55
|
+
this.options = {
|
|
56
|
+
scroll: '2s',
|
|
57
|
+
size: batchSize
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One-shot call before the dump. Can be used to
|
|
62
|
+
* perform setup operations before dumping.
|
|
63
|
+
*
|
|
64
|
+
* @returns void
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
67
|
+
async setup() { }
|
|
68
|
+
/**
|
|
69
|
+
* One-shot call before iterating over the data. Can be
|
|
70
|
+
* used to write the header of the dumped output.
|
|
71
|
+
*/
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
73
|
+
async writeHeader() { }
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
75
|
+
async tearDown() { }
|
|
76
|
+
/**
|
|
77
|
+
* The loop that iterates over the documents of the collection and
|
|
78
|
+
* calls all the other hooks.
|
|
79
|
+
*
|
|
80
|
+
* @returns a promise resolving when the dump is finished.
|
|
81
|
+
*/
|
|
82
|
+
async dump() {
|
|
83
|
+
this.filename = path_1.default.join(this.collectionDir, `documents.${this.fileExtension}`);
|
|
84
|
+
this.writeStream = fs_1.default.createWriteStream(this.filename);
|
|
85
|
+
const waitWrite = new Promise((resolve, reject) => this.writeStream ? this.writeStream.on('finish', resolve) : reject());
|
|
86
|
+
this.writeStream.on('error', error => {
|
|
87
|
+
throw error;
|
|
88
|
+
});
|
|
89
|
+
await this.setup();
|
|
90
|
+
await this.writeHeader();
|
|
91
|
+
let results = await this.sdk.document.search(this.index, this.collection, { query: this.query }, this.options);
|
|
92
|
+
const progressBar = cli_ux_1.default.progress({
|
|
93
|
+
format: `Dumping ${this.collection} |{bar}| {percentage}% || {value}/{total} documents`
|
|
94
|
+
});
|
|
95
|
+
progressBar.start(results.total, 0);
|
|
96
|
+
do {
|
|
97
|
+
progressBar.update(results.fetched);
|
|
98
|
+
for (const hit of results.hits) {
|
|
99
|
+
await this.onResult({
|
|
100
|
+
_id: hit._id,
|
|
101
|
+
_source: hit._source
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
} while ((results = await results.next()));
|
|
105
|
+
await this.tearDown();
|
|
106
|
+
progressBar.stop();
|
|
107
|
+
this.writeStream.end();
|
|
108
|
+
return waitWrite;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class JSONLDumper extends AbstractDumper {
|
|
112
|
+
constructor() {
|
|
113
|
+
super(...arguments);
|
|
114
|
+
this.ndjsonStream = ndjson_1.default.stringify();
|
|
115
|
+
}
|
|
116
|
+
async setup() {
|
|
117
|
+
this.ndjsonStream.on('data', (line) => {
|
|
118
|
+
if (!this.writeStream) {
|
|
119
|
+
throw new Error('Cannot write data: WriteStream is not initialized.');
|
|
120
|
+
}
|
|
121
|
+
this.writeStream.write(line);
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
async writeHeader() {
|
|
126
|
+
await this.writeLine({ type: 'collection', index: this.index, collection: this.collection });
|
|
127
|
+
}
|
|
128
|
+
writeLine(content) {
|
|
20
129
|
return new Promise(resolve => {
|
|
21
|
-
if (ndjsonStream.write(content)) {
|
|
130
|
+
if (this.ndjsonStream.write(content)) {
|
|
22
131
|
resolve(undefined);
|
|
23
132
|
}
|
|
24
133
|
else {
|
|
25
|
-
ndjsonStream.once('drain', resolve);
|
|
134
|
+
this.ndjsonStream.once('drain', resolve);
|
|
26
135
|
}
|
|
27
136
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const rawDocuments = {
|
|
43
|
-
[index]: {
|
|
44
|
-
[collection]: []
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
do {
|
|
48
|
-
progressBar.update(results.fetched);
|
|
49
|
-
for (const hit of results.hits) {
|
|
50
|
-
let document = null;
|
|
51
|
-
if (format.toLocaleLowerCase() === 'jsonl') {
|
|
52
|
-
document = {
|
|
53
|
-
_id: hit._id,
|
|
54
|
-
body: hit._source
|
|
55
|
-
};
|
|
56
|
-
await writeLine(document);
|
|
137
|
+
}
|
|
138
|
+
onResult(document) {
|
|
139
|
+
return this.writeLine({ _id: document._id, body: document._source });
|
|
140
|
+
}
|
|
141
|
+
get fileExtension() {
|
|
142
|
+
return 'jsonl';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class KuzzleDumper extends JSONLDumper {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
this.rawDocuments = {
|
|
149
|
+
[this.index]: {
|
|
150
|
+
[this.collection]: []
|
|
57
151
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
get fileExtension() {
|
|
155
|
+
return 'json';
|
|
156
|
+
}
|
|
157
|
+
async onResult(document) {
|
|
158
|
+
this.rawDocuments[this.index][this.collection].push({
|
|
159
|
+
index: {
|
|
160
|
+
_id: document._id
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
this.rawDocuments[this.index][this.collection].push(document._source);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
tearDown() {
|
|
167
|
+
return this.writeLine(this.rawDocuments);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
class CSVDumper extends AbstractDumper {
|
|
171
|
+
constructor(sdk, index, collection, batchSize, destPath, query = {}, fields, separator = ',') {
|
|
172
|
+
super(sdk, index, collection, batchSize, destPath, query);
|
|
173
|
+
this.fields = fields;
|
|
174
|
+
this.separator = separator;
|
|
175
|
+
}
|
|
176
|
+
get fileExtension() {
|
|
177
|
+
return 'csv';
|
|
178
|
+
}
|
|
179
|
+
async setup() {
|
|
180
|
+
if (!this.fields.length) {
|
|
181
|
+
// If no field has been selected, then all fields are selected.
|
|
182
|
+
const mappings = await this.sdk.collection.getMapping(this.index, this.collection);
|
|
183
|
+
if (!mappings.properties) {
|
|
184
|
+
return;
|
|
65
185
|
}
|
|
186
|
+
this.fields = Object.keys(flattenObject(mappings.properties));
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// Delete '_id' from the selected fields, since IDs are
|
|
190
|
+
// _always_ exported.
|
|
191
|
+
if (this.fields.includes('_id')) {
|
|
192
|
+
this.fields.splice(this.fields.indexOf('_id'), 1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
writeHeader() {
|
|
197
|
+
return this.writeLine(['_id', ...this.fields].join(this.separator));
|
|
198
|
+
}
|
|
199
|
+
async writeLine(line) {
|
|
200
|
+
if (!this.writeStream) {
|
|
201
|
+
throw new Error('Cannot write data: WriteStream is not initialized.');
|
|
66
202
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
203
|
+
this.writeStream.write(line);
|
|
204
|
+
this.writeStream.write('\n');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
onResult(document) {
|
|
208
|
+
const values = [document._id, ...(0, common_1.pickValues)(document._source, this.fields)];
|
|
209
|
+
return this.writeLine(values.join(this.separator));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function dumpCollectionData(sdk, index, collection, batchSize, destPath, query = {}, format = 'jsonl', fields = []) {
|
|
213
|
+
let dumper;
|
|
214
|
+
switch (format.toLowerCase()) {
|
|
215
|
+
case 'jsonl':
|
|
216
|
+
dumper = new JSONLDumper(sdk, index, collection, batchSize, destPath, query);
|
|
217
|
+
return dumper.dump();
|
|
218
|
+
case 'csv':
|
|
219
|
+
dumper = new CSVDumper(sdk, index, collection, batchSize, destPath, query, fields);
|
|
220
|
+
return dumper.dump();
|
|
221
|
+
default:
|
|
222
|
+
dumper = new KuzzleDumper(sdk, index, collection, batchSize, destPath, query);
|
|
223
|
+
return dumper.dump();
|
|
224
|
+
}
|
|
75
225
|
}
|
|
76
226
|
exports.dumpCollectionData = dumpCollectionData;
|
|
77
227
|
async function dumpCollectionMappings(sdk, index, collection, destPath, format = 'jsonl') {
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.19.4","commands":{"import":{"id":"import","description":"Recursively imports dump files from a root directory","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"preserve-anonymous":{"name":"preserve-anonymous","type":"boolean","description":"Preserve anonymous rights","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Root directory containing dumps","required":true}]},"api-key:check":{"id":"api-key:check","description":"Checks an API key validity","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou api-key:check eyJhbG...QxfQrc"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"token","description":"API key token","required":true}]},"api-key:create":{"id":"api-key:create","description":"Creates a new API Key for a user","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"description":{"name":"description","type":"option","char":"d","description":"API Key description","required":true},"id":{"name":"id","type":"option","description":"API Key unique ID"},"expire":{"name":"expire","type":"option","description":"API Key validity","default":"-1"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:delete":{"id":"api-key:delete","description":"Deletes an API key.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:delete sigfox-gateway 1k-BF3EBjsXdvA2PR8x"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true},{"name":"id","description":"API Key unique ID","required":true}]},"api-key:search":{"id":"api-key:search","description":"Lists a user's API Keys.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"filter":{"name":"filter","type":"option","description":"Filter to match the API Key descriptions"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true}]},"app:scaffold":{"id":"app:scaffold","description":"Scaffolds a new Kuzzle application","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"name","description":"Application name","required":true}]},"app:start-services":{"id":"app:start-services","description":"Starts Kuzzle services (Elasticsearch and Redis)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running services","allowNo":false}},"args":[]},"collection:create":{"id":"collection:create","description":"Creates a collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"body","description":"Collection mappings and settings in JS or JSON format. Will be read from STDIN if available"}]},"collection:export":{"id":"collection:export","description":"Exports a collection (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou collection:export nyc-open-data yellow-taxi","kourou collection:export nyc-open-data yellow-taxi --query '{ term: { city: \"Saigon\" } }'"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump root directory"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"query":{"name":"query","type":"option","description":"Only dump documents matching the query (JS or JSON format)","default":"{}"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the query before sending","allowNo":false},"format":{"name":"format","type":"option","description":"\"jsonl or kuzzle - kuzzle will export in Kuzzle format usable for internal fixtures and jsonl allows to import that data back with kourou","default":"JSONL"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true}]},"collection:import":{"id":"collection:import","description":"Imports a collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"collection":{"name":"collection","type":"option","description":"If set, override the collection destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collection mappings","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump directory path","required":true}]},"config:diff":{"id":"config:diff","description":"Returns differences between two Kuzzle configuration files (kuzzlerc)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou config:diff config/local/kuzzlerc config/production/kuzzlerc"],"flags":{"strict":{"name":"strict","type":"boolean","description":"Exit with an error if differences are found","allowNo":false},"values":{"name":"values","type":"boolean","description":"Also displays value changes","allowNo":false}},"args":[{"name":"first","description":"First configuration file","required":true},{"name":"second","description":"Second configuration file","required":true}]},"document:search":{"id":"document:search","description":"Searches for documents","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou document:search iot sensors '{ equals: { name: \"corona\" } }'","kourou document:search iot sensors '{ match: { name: \"cOrOnna\" } }' -a lang=elasticsearch","kourou document:search iot sensors --editor"],"flags":{"sort":{"name":"sort","type":"option","description":"Sort in JS or JSON format.","default":"{}"},"from":{"name":"from","type":"option","description":"Optional offset"},"size":{"name":"size","type":"option","description":"Optional page size"},"scroll":{"name":"scroll","type":"option","description":"Optional scroll TTL"},"lang":{"name":"lang","type":"option","description":"Specify the query language to use","default":"koncorde"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the request before sending","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"query","description":"Search query in JS or JSON format."}]},"es:migrate":{"id":"es:migrate","description":"Migrate all the index from one Elasticsearch server to another","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000","kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000 --no-interactive"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"src":{"name":"src","type":"option","description":"Source Elasticsearch server URL","required":true},"dest":{"name":"dest","type":"option","description":"Destination Elasticsearch server URL","required":true},"reset":{"name":"reset","type":"boolean","description":"Reset destination Elasticsearch server","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"How many documents to move in batch per operation","default":1000},"no-interactive":{"name":"no-interactive","type":"boolean","description":"Skip confirmation interactive prompts (perfect for scripting)","allowNo":false}},"args":[]},"file:decrypt":{"id":"file:decrypt","description":"Decrypts an encrypted file.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:decrypt books/cryptonomicon.txt.enc --vault-key <vault-key>","kourou file:decrypt books/cryptonomicon.txt.enc -o books/cryptonomicon.txt --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: remove \".enc\")"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Encrypted file","required":true}]},"file:encrypt":{"id":"file:encrypt","description":"Encrypts an entire file.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:encrypt books/cryptonomicon.txt --vault-key <vault-key>","kourou file:encrypt books/cryptonomicon.txt -o books/cryptonomicon.txt.enc --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <filename>.enc)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Filename","required":true}]},"file:test":{"id":"file:test","description":"Tests if an encrypted file can be decrypted.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:test books/cryptonomicon.txt.enc --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Encrypted file","required":true}]},"index:export":{"id":"index:export","description":"Exports an index (JSONL or Kuzzle format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou index:export nyc-open-data","kourou index:export nyc-open-data --query '{\"range\":{\"_kuzzle_info.createdAt\":{\"gt\":1632935638866}}}'"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump root directory"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"query":{"name":"query","type":"option","description":"Only dump documents in collections matching the query (JS or JSON format)","default":"{}"},"format":{"name":"format","type":"option","description":"\"jsonl or kuzzle - kuzzle will export in Kuzzle format usable for internal fixtures and jsonl allows to import that data back with kourou","default":"jsonl"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true}]},"index:import":{"id":"index:import","description":"Imports an index (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou index:import ./dump/iot-data","kourou index:import ./dump/iot-data --index iot-data-production --no-mappings"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collections mappings","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump directory or file","required":true}]},"instance:kill":{"id":"instance:kill","description":"Stop and remove all the containers of a running kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name [ex: stack-0]"},"all":{"name":"all","type":"boolean","char":"a","description":"Kill all instances","allowNo":false}},"args":[]},"instance:list":{"id":"instance:list","description":"Lists the Kuzzle running instances","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{},"args":[]},"instance:logs":{"id":"instance:logs","description":"Displays the logs of a running Kuzzle","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name"},"follow":{"name":"follow","type":"boolean","char":"f","description":"Follow log output","allowNo":false}},"args":[]},"instance:spawn":{"id":"instance:spawn","description":"Spawn a new Kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running Kuzzle","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"Core-version of the instance to spawn","default":"2"}},"args":[]},"profile:export":{"id":"profile:export","description":"Exports profiles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"profiles"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"profile:import":{"id":"profile:import","description":"Imports profiles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"realtime:subscribe":{"id":"realtime:subscribe","description":"Subscribes to realtime notifications","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou realtime:subscribe iot-data sensors","kourou realtime:subscribe iot-data sensors '{ range: { temperature: { gt: 0 } } }'","kourou realtime:subscribe iot-data sensors '{ exists: \"position\" }' --scope out","kourou realtime:subscribe iot-data sensors --users all --volatile '{ clientId: \"citizen-kane\" }'","kourou realtime:subscribe iot-data sensors --display result._source.temperature"],"flags":{"scope":{"name":"scope","type":"option","description":"Subscribe to document entering or leaving the scope (all, in, out, none)","default":"all"},"users":{"name":"users","type":"option","description":"Subscribe to users entering or leaving the room (all, in, out, none)","default":"all"},"volatile":{"name":"volatile","type":"option","description":"Additional subscription information used in user join/leave notifications","default":"{}"},"display":{"name":"display","type":"option","description":"Path of the property to display from the notification (empty string to display everything)","default":"result"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the filters before subscribing.","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (only websocket for realtime)","default":"websocket"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"filters","description":"Set of Koncorde filters"}]},"redis:list-keys":{"id":"redis:list-keys","description":"Lists keys stored in Redis","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou redis:list-keys \"*cluster*\"","kourou redis:list-keys \"counters/*\" --remove"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"remove":{"name":"remove","type":"boolean","description":"Remove matching keys","allowNo":false},"size":{"name":"size","type":"option","description":"Page size","default":"100"},"max":{"name":"max","type":"option","description":"Maximum number of page to retrieve (-1 to retrieve everything)","default":"-1"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"match","description":"Match Redis keys with a pattern","default":"*"}]},"role:export":{"id":"role:export","description":"Exports roles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"roles"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"role:import":{"id":"role:import","description":"Import roles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"preserve-anonymous":{"name":"preserve-anonymous","type":"boolean","description":"Preserve anonymous rights","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"sdk:execute":{"id":"sdk:execute","description":"\nExecutes arbitrary code.\n\nCode Execution\n\n Provided code will be executed in an async method.\n You can access a connected and authenticated SDK with the \"sdk\" variable.\n Templated variable passed as the command arguments are also accessible within the same name.\n Returned value will be printed on the standard output (e.g. 'return await sdk.server.now();').\n Errors will be caught and printed on the error output (e.g. 'throw new Error(\"failure\");').\n\nProvide code\n\n code can be passed as an argument\n code will be read from STDIN if available\n\n Examples:\n - kourou sdk:execute 'return await sdk.server.now()'\n - kourou sdk:execute 'return await sdk.index.exists(index)' --var 'index=\"iot-data\"'\n - kourou sdk:execute < snippet.js\n - echo 'return await sdk.server.now()' | kourou sdk:execute\n\nOther\n\n use the --editor flag to modify the code before executing it\n\n Examples:\n - kourou sdk:execute 'return await sdk.server.now()' --editor\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"var":{"name":"var","type":"option","char":"v","description":"Additional arguments injected into the code. (eg: --var 'index=\"iot-data\"'"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the code before executing it.","allowNo":false},"keep-alive":{"name":"keep-alive","type":"boolean","description":"Keep the connection running (websocket only)","allowNo":false},"print-raw":{"name":"print-raw","type":"boolean","description":"Print only the script result to stdout","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"code","description":"Code to execute. Will be read from STDIN if available.","required":false}]},"sdk:query":{"id":"sdk:query","description":"\nExecutes an API query.\n\nQuery arguments\n\n Arguments can be passed and repeated using the --arg or -a flag.\n Index and collection names can be passed with --index (-i) and --collection (-c) flags\n ID can be passed with the --id flag.\n\n Examples:\n - kourou sdk:query document:delete -i iot -c sensors -a refresh=wait_for\n\nQuery body\n\n Body can be passed with the --body flag with either a JSON or JS string.\n Body will be read from STDIN if available\n\n Examples:\n - kourou sdk:query document:create -i iot -c sensors --body '{creation: Date.now())}'\n - kourou sdk:query admin:loadMappings < mappings.json\n - echo '{dynamic: \"strict\"}' | kourou sdk:query collection:create -i iot -c sensors\n\nOther\n\n Use the --editor flag to modify the query before sending it to Kuzzle\n Use the --display flag to display a specific property of the response\n\n Examples:\n - kourou sdk:query document:create -i iot -c sensors --editor\n - kourou sdk:query server:now --display 'result.now'\n\nDefault fallback to API action\n\n It's possible to use the \"sdk:query\" command by only specifying the corresponding controller\n and action as first argument.\n\n Kourou will try to infer the first arguments to one the following pattern:\n - <command> <index>\n - <command> <body>\n - <command> <index> <collection>\n - <command> <index> <collection> <id>\n - <command> <index> <collection> <body>\n - <command> <index> <collection> <id> <body>\n\n If a flag is given (-i, -c, --body or --id), then the flag value has priority over\n argument infering.\n\n Examples:\n - kourou collection:list iot\n - kourou security:createUser '{ \"content\": { \"profileIds\": [\"default\"] } }' --id yagmur\n - kourou collection:delete iot sensors\n - kourou document:createOrReplace iot sensors sigfox-1 '{}'\n - kourou bulk:import iot sensors '{ bulkData: [...] }'\n - kourou admin:loadMappings < mappings.json\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"arg":{"name":"arg","type":"option","char":"a","description":"Additional argument. Repeatable. (e.g. \"-a refresh=wait_for\")"},"body":{"name":"body","type":"option","description":"Request body in JS or JSON format. Will be read from STDIN if available.","default":"{}"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the request before sending.","allowNo":false},"body-editor":{"name":"body-editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the body before sending.","allowNo":false},"index":{"name":"index","type":"option","char":"i","description":"Index argument"},"collection":{"name":"collection","type":"option","char":"c","description":"Collection argument"},"id":{"name":"id","type":"option","description":"ID argument (_id)"},"display":{"name":"display","type":"option","description":"Path of the property to display from the response (empty string to display the result)","default":"result"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"controller:action","description":"Controller and action (eg: \"server:now\")","required":true}]},"user:export-mappings":{"id":"user:export-mappings","description":"Exports users collection mappings to JSON.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"users"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"user:export":{"id":"user:export","description":"\nExports users to JSON.\n\nThe users will be exported WITHOUT their credentials since Kuzzzle can't access them.\n\nYou can either:\n - Manually re-create credentials for your users\n - Use the \"mustChangePasswordIfSetByAdmin\" option Kuzzle password policies (see https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local/#optional-properties)\n - Use the \"--generate-credentials\" flag to auto-generate credentials for your users\n\nAuto-generation of credentials\n\n With the \"--generate-credentials\" flag, Kourou will add credentials for the \"local\" strategy.\n By default, the username will be the user ID.\n Use the \"generated-username\" flag to use an other property than the user ID for the generated username\n The password will be a strong random 40 characters string\n\nExamples:\n\n - kourou user:export\n - kourou user:export --exclude '.*admin.*' --exclude 'supervisor.*'\n - kourou user:export --generate-credentials\n - kourou user:export --generate-credentials --generated-username content.email\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"users"},"exclude":{"name":"exclude","type":"option","description":"Exclude users by matching their IDs with a regexp"},"generate-credentials":{"name":"generate-credentials","type":"boolean","description":"Generate credentials with a random password for users","allowNo":false},"generated-username":{"name":"generated-username","type":"option","description":"User content property used as a username for local credentials","default":"_id"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"user:import-mappings":{"id":"user:import-mappings","description":"Imports users collection mappings","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"user:import":{"id":"user:import","description":"Imports users","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"vault:add":{"id":"vault:add","description":"\nAdds an encrypted key to an encrypted secrets file.\n\nA new secrets file is created if it does not yet exist.\n\nEncrypted secrets are meant to be loaded inside an application with Kuzzle Vault.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:add config/secrets.enc.json aws.s3.keyId b61e267676660c314b006b06 --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true},{"name":"value","description":"Value to encrypt","required":true}]},"vault:decrypt":{"id":"vault:decrypt","description":"\nDecrypts an entire secrets file.\n\nDecrypted secrets file must NEVER be committed into the repository.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:decrypt config/secrets.enc.json --vault-key <vault-key>","kourou vault:decrypt config/secrets.enc.json -o config/secrets.json --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: remove \".enc\")"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing encrypted secrets","required":true}]},"vault:encrypt":{"id":"vault:encrypt","description":"\nEncrypts an entire secrets file.\n\nThe secrets file must be in JSON format and it must contain only strings or objects.\n\nExample:\n{\n aws: {\n s3: {\n keyId: 'b61e267676660c314b006b06'\n }\n }\n}\n\nEncrypted secrets are meant to be loaded inside an application with Kuzzle Vault.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:encrypt config/secrets.json --vault-key <vault-key>","kourou vault:encrypt config/secrets.json -o config/secrets_prod.enc.json --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <file>.enc.json)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing unencrypted secrets","required":true}]},"vault:show":{"id":"vault:show","description":"\nPrints an encrypted secrets file content.\n\nThis method can display either:\n - the entire content of the secrets file\n - a single key value\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:show config/secrets.enc.json --vault-key <vault-key>","kourou vault:show config/secrets.enc.json aws.s3.secretKey --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to a key (lodash style)"}]},"vault:test":{"id":"vault:test","description":"\nTests if an encrypted secrets file can be decrypted.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:test config/secrets.enc.json --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true}]},"es:indices:cat":{"id":"es:indices:cat","description":"Lists available ES indexes","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"grep":{"name":"grep","type":"option","char":"g","description":"Match output with pattern"}},"args":[]},"es:indices:get":{"id":"es:indices:get","description":"Gets a document from ES","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"}},"args":[{"name":"index","description":"ES Index name","required":true},{"name":"id","description":"Document ID","required":true}]},"es:indices:insert":{"id":"es:indices:insert","description":"Inserts a document directly into ES (will replace if exists)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"body":{"name":"body","type":"option","description":"Document body in JSON","default":"{}"},"id":{"name":"id","type":"option","description":"Document ID"},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"index","description":"ES Index name","required":true}]},"es:snapshot:create-repository":{"id":"es:snapshot:create-repository","description":"Create a FS snapshot repository inside an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"compress":{"name":"compress","type":"boolean","description":"Compress data when storing them","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"ES repository name","required":true},{"name":"location","description":"ES snapshot repository location","required":true}]},"es:snapshot:create":{"id":"es:snapshot:create","description":"Create a snapshot repository inside an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"ES repository name","required":true},{"name":"name","description":"ES snapshot name","required":true}]},"es:snapshot:list":{"id":"es:snapshot:list","description":"List all snapshot from a repository acknowledge by an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"Name of repository from which to fetch the snapshot information","required":true}]},"es:snapshot:restore":{"id":"es:snapshot:restore","description":"Restore a snapshot into an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"ES repository name","required":true},{"name":"name","description":"ES snapshot name","required":true}]}}}
|
|
1
|
+
{"version":"0.19.5","commands":{"import":{"id":"import","description":"Recursively imports dump files from a root directory","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"preserve-anonymous":{"name":"preserve-anonymous","type":"boolean","description":"Preserve anonymous rights","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Root directory containing dumps","required":true}]},"api-key:check":{"id":"api-key:check","description":"Checks an API key validity","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou api-key:check eyJhbG...QxfQrc"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"token","description":"API key token","required":true}]},"api-key:create":{"id":"api-key:create","description":"Creates a new API Key for a user","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"description":{"name":"description","type":"option","char":"d","description":"API Key description","required":true},"id":{"name":"id","type":"option","description":"API Key unique ID"},"expire":{"name":"expire","type":"option","description":"API Key validity","default":"-1"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true}]},"api-key:delete":{"id":"api-key:delete","description":"Deletes an API key.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:delete sigfox-gateway 1k-BF3EBjsXdvA2PR8x"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true},{"name":"id","description":"API Key unique ID","required":true}]},"api-key:search":{"id":"api-key:search","description":"Lists a user's API Keys.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"filter":{"name":"filter","type":"option","description":"Filter to match the API Key descriptions"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"user","description":"User kuid","required":true}]},"app:scaffold":{"id":"app:scaffold","description":"Scaffolds a new Kuzzle application","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"name","description":"Application name","required":true}]},"app:start-services":{"id":"app:start-services","description":"Starts Kuzzle services (Elasticsearch and Redis)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running services","allowNo":false}},"args":[]},"collection:create":{"id":"collection:create","description":"Creates a collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"body","description":"Collection mappings and settings in JS or JSON format. Will be read from STDIN if available"}]},"collection:export":{"id":"collection:export","description":"Exports a collection (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou collection:export nyc-open-data yellow-taxi","kourou collection:export nyc-open-data yellow-taxi --query '{ term: { city: \"Saigon\" } }'"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump root directory"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"query":{"name":"query","type":"option","description":"Only dump documents matching the query (JS or JSON format)","default":"{}"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the query before sending","allowNo":false},"format":{"name":"format","type":"option","description":"\"kuzzle\" will export in Kuzzle format usable for internal fixtures,\n\"jsonl\" allows to import that data back with kourou,\n\"csv\" allows to import data into Excel (please, specify the fields to export using the --fields option).","options":["jsonl","kuzzle","csv"],"default":"jsonl"},"fields":{"name":"fields","type":"option","description":"[CSV format only] The list of fields to be included in the CSV export in dot-path format.\n\nExample:\n--fields oneField,anotherField,yetAnotherOne.nested.moarNested\n\nNote that the '_id' field is always included in the CSV export. Leaving this option empty implies that all\nexportable fields in the mapping will be exported."},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true}]},"collection:import":{"id":"collection:import","description":"Imports a collection","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"collection":{"name":"collection","type":"option","description":"If set, override the collection destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collection mappings","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump directory path","required":true}]},"config:diff":{"id":"config:diff","description":"Returns differences between two Kuzzle configuration files (kuzzlerc)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou config:diff config/local/kuzzlerc config/production/kuzzlerc"],"flags":{"strict":{"name":"strict","type":"boolean","description":"Exit with an error if differences are found","allowNo":false},"values":{"name":"values","type":"boolean","description":"Also displays value changes","allowNo":false}},"args":[{"name":"first","description":"First configuration file","required":true},{"name":"second","description":"Second configuration file","required":true}]},"document:search":{"id":"document:search","description":"Searches for documents","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou document:search iot sensors '{ equals: { name: \"corona\" } }'","kourou document:search iot sensors '{ match: { name: \"cOrOnna\" } }' -a lang=elasticsearch","kourou document:search iot sensors --editor"],"flags":{"sort":{"name":"sort","type":"option","description":"Sort in JS or JSON format.","default":"{}"},"from":{"name":"from","type":"option","description":"Optional offset"},"size":{"name":"size","type":"option","description":"Optional page size"},"scroll":{"name":"scroll","type":"option","description":"Optional scroll TTL"},"lang":{"name":"lang","type":"option","description":"Specify the query language to use","default":"koncorde"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the request before sending","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"query","description":"Search query in JS or JSON format."}]},"es:migrate":{"id":"es:migrate","description":"Migrate all the index from one Elasticsearch server to another","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000","kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000 --no-interactive"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"src":{"name":"src","type":"option","description":"Source Elasticsearch server URL","required":true},"dest":{"name":"dest","type":"option","description":"Destination Elasticsearch server URL","required":true},"reset":{"name":"reset","type":"boolean","description":"Reset destination Elasticsearch server","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"How many documents to move in batch per operation","default":1000},"no-interactive":{"name":"no-interactive","type":"boolean","description":"Skip confirmation interactive prompts (perfect for scripting)","allowNo":false}},"args":[]},"file:decrypt":{"id":"file:decrypt","description":"Decrypts an encrypted file.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:decrypt books/cryptonomicon.txt.enc --vault-key <vault-key>","kourou file:decrypt books/cryptonomicon.txt.enc -o books/cryptonomicon.txt --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: remove \".enc\")"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Encrypted file","required":true}]},"file:encrypt":{"id":"file:encrypt","description":"Encrypts an entire file.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:encrypt books/cryptonomicon.txt --vault-key <vault-key>","kourou file:encrypt books/cryptonomicon.txt -o books/cryptonomicon.txt.enc --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <filename>.enc)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Filename","required":true}]},"file:test":{"id":"file:test","description":"Tests if an encrypted file can be decrypted.","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou file:test books/cryptonomicon.txt.enc --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"Encrypted file","required":true}]},"index:export":{"id":"index:export","description":"Exports an index (JSONL or Kuzzle format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou index:export nyc-open-data","kourou index:export nyc-open-data --query '{\"range\":{\"_kuzzle_info.createdAt\":{\"gt\":1632935638866}}}'"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump root directory"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"query":{"name":"query","type":"option","description":"Only dump documents in collections matching the query (JS or JSON format)","default":"{}"},"format":{"name":"format","type":"option","description":"\"jsonl or kuzzle - kuzzle will export in Kuzzle format usable for internal fixtures and jsonl allows to import that data back with kourou","default":"jsonl"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true}]},"index:import":{"id":"index:import","description":"Imports an index (JSONL format)","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou index:import ./dump/iot-data","kourou index:import ./dump/iot-data --index iot-data-production --no-mappings"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsWriteCount config)","default":"200"},"index":{"name":"index","type":"option","description":"If set, override the index destination name"},"no-mappings":{"name":"no-mappings","type":"boolean","description":"Skip collections mappings","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump directory or file","required":true}]},"instance:kill":{"id":"instance:kill","description":"Stop and remove all the containers of a running kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name [ex: stack-0]"},"all":{"name":"all","type":"boolean","char":"a","description":"Kill all instances","allowNo":false}},"args":[]},"instance:list":{"id":"instance:list","description":"Lists the Kuzzle running instances","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{},"args":[]},"instance:logs":{"id":"instance:logs","description":"Displays the logs of a running Kuzzle","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"instance":{"name":"instance","type":"option","char":"i","description":"Kuzzle instance name"},"follow":{"name":"follow","type":"boolean","char":"f","description":"Follow log output","allowNo":false}},"args":[]},"instance:spawn":{"id":"instance:spawn","description":"Spawn a new Kuzzle instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"check":{"name":"check","type":"boolean","description":"Check prerequisite before running Kuzzle","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"Core-version of the instance to spawn","default":"2"}},"args":[]},"profile:export":{"id":"profile:export","description":"Exports profiles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"profiles"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"profile:import":{"id":"profile:import","description":"Imports profiles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"realtime:subscribe":{"id":"realtime:subscribe","description":"Subscribes to realtime notifications","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou realtime:subscribe iot-data sensors","kourou realtime:subscribe iot-data sensors '{ range: { temperature: { gt: 0 } } }'","kourou realtime:subscribe iot-data sensors '{ exists: \"position\" }' --scope out","kourou realtime:subscribe iot-data sensors --users all --volatile '{ clientId: \"citizen-kane\" }'","kourou realtime:subscribe iot-data sensors --display result._source.temperature"],"flags":{"scope":{"name":"scope","type":"option","description":"Subscribe to document entering or leaving the scope (all, in, out, none)","default":"all"},"users":{"name":"users","type":"option","description":"Subscribe to users entering or leaving the room (all, in, out, none)","default":"all"},"volatile":{"name":"volatile","type":"option","description":"Additional subscription information used in user join/leave notifications","default":"{}"},"display":{"name":"display","type":"option","description":"Path of the property to display from the notification (empty string to display everything)","default":"result"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the filters before subscribing.","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (only websocket for realtime)","default":"websocket"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"index","description":"Index name","required":true},{"name":"collection","description":"Collection name","required":true},{"name":"filters","description":"Set of Koncorde filters"}]},"redis:list-keys":{"id":"redis:list-keys","description":"Lists keys stored in Redis","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou redis:list-keys \"*cluster*\"","kourou redis:list-keys \"counters/*\" --remove"],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"remove":{"name":"remove","type":"boolean","description":"Remove matching keys","allowNo":false},"size":{"name":"size","type":"option","description":"Page size","default":"100"},"max":{"name":"max","type":"option","description":"Maximum number of page to retrieve (-1 to retrieve everything)","default":"-1"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"match","description":"Match Redis keys with a pattern","default":"*"}]},"role:export":{"id":"role:export","description":"Exports roles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"roles"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"role:import":{"id":"role:import","description":"Import roles","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"preserve-anonymous":{"name":"preserve-anonymous","type":"boolean","description":"Preserve anonymous rights","allowNo":false},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"sdk:execute":{"id":"sdk:execute","description":"\nExecutes arbitrary code.\n\nCode Execution\n\n Provided code will be executed in an async method.\n You can access a connected and authenticated SDK with the \"sdk\" variable.\n Templated variable passed as the command arguments are also accessible within the same name.\n Returned value will be printed on the standard output (e.g. 'return await sdk.server.now();').\n Errors will be caught and printed on the error output (e.g. 'throw new Error(\"failure\");').\n\nProvide code\n\n code can be passed as an argument\n code will be read from STDIN if available\n\n Examples:\n - kourou sdk:execute 'return await sdk.server.now()'\n - kourou sdk:execute 'return await sdk.index.exists(index)' --var 'index=\"iot-data\"'\n - kourou sdk:execute < snippet.js\n - echo 'return await sdk.server.now()' | kourou sdk:execute\n\nOther\n\n use the --editor flag to modify the code before executing it\n\n Examples:\n - kourou sdk:execute 'return await sdk.server.now()' --editor\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"var":{"name":"var","type":"option","char":"v","description":"Additional arguments injected into the code. (eg: --var 'index=\"iot-data\"'"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the code before executing it.","allowNo":false},"keep-alive":{"name":"keep-alive","type":"boolean","description":"Keep the connection running (websocket only)","allowNo":false},"print-raw":{"name":"print-raw","type":"boolean","description":"Print only the script result to stdout","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"code","description":"Code to execute. Will be read from STDIN if available.","required":false}]},"sdk:query":{"id":"sdk:query","description":"\nExecutes an API query.\n\nQuery arguments\n\n Arguments can be passed and repeated using the --arg or -a flag.\n Index and collection names can be passed with --index (-i) and --collection (-c) flags\n ID can be passed with the --id flag.\n\n Examples:\n - kourou sdk:query document:delete -i iot -c sensors -a refresh=wait_for\n\nQuery body\n\n Body can be passed with the --body flag with either a JSON or JS string.\n Body will be read from STDIN if available\n\n Examples:\n - kourou sdk:query document:create -i iot -c sensors --body '{creation: Date.now())}'\n - kourou sdk:query admin:loadMappings < mappings.json\n - echo '{dynamic: \"strict\"}' | kourou sdk:query collection:create -i iot -c sensors\n\nOther\n\n Use the --editor flag to modify the query before sending it to Kuzzle\n Use the --display flag to display a specific property of the response\n\n Examples:\n - kourou sdk:query document:create -i iot -c sensors --editor\n - kourou sdk:query server:now --display 'result.now'\n\nDefault fallback to API action\n\n It's possible to use the \"sdk:query\" command by only specifying the corresponding controller\n and action as first argument.\n\n Kourou will try to infer the first arguments to one the following pattern:\n - <command> <index>\n - <command> <body>\n - <command> <index> <collection>\n - <command> <index> <collection> <id>\n - <command> <index> <collection> <body>\n - <command> <index> <collection> <id> <body>\n\n If a flag is given (-i, -c, --body or --id), then the flag value has priority over\n argument infering.\n\n Examples:\n - kourou collection:list iot\n - kourou security:createUser '{ \"content\": { \"profileIds\": [\"default\"] } }' --id yagmur\n - kourou collection:delete iot sensors\n - kourou document:createOrReplace iot sensors sigfox-1 '{}'\n - kourou bulk:import iot sensors '{ bulkData: [...] }'\n - kourou admin:loadMappings < mappings.json\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"arg":{"name":"arg","type":"option","char":"a","description":"Additional argument. Repeatable. (e.g. \"-a refresh=wait_for\")"},"body":{"name":"body","type":"option","description":"Request body in JS or JSON format. Will be read from STDIN if available.","default":"{}"},"editor":{"name":"editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the request before sending.","allowNo":false},"body-editor":{"name":"body-editor","type":"boolean","description":"Open an editor (EDITOR env variable) to edit the body before sending.","allowNo":false},"index":{"name":"index","type":"option","char":"i","description":"Index argument"},"collection":{"name":"collection","type":"option","char":"c","description":"Collection argument"},"id":{"name":"id","type":"option","description":"ID argument (_id)"},"display":{"name":"display","type":"option","description":"Path of the property to display from the response (empty string to display the result)","default":"result"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or ws)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"controller:action","description":"Controller and action (eg: \"server:now\")","required":true}]},"user:export-mappings":{"id":"user:export-mappings","description":"Exports users collection mappings to JSON.","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"users"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"user:export":{"id":"user:export","description":"\nExports users to JSON.\n\nThe users will be exported WITHOUT their credentials since Kuzzzle can't access them.\n\nYou can either:\n - Manually re-create credentials for your users\n - Use the \"mustChangePasswordIfSetByAdmin\" option Kuzzle password policies (see https://github.com/kuzzleio/kuzzle-plugin-auth-passport-local/#optional-properties)\n - Use the \"--generate-credentials\" flag to auto-generate credentials for your users\n\nAuto-generation of credentials\n\n With the \"--generate-credentials\" flag, Kourou will add credentials for the \"local\" strategy.\n By default, the username will be the user ID.\n Use the \"generated-username\" flag to use an other property than the user ID for the generated username\n The password will be a strong random 40 characters string\n\nExamples:\n\n - kourou user:export\n - kourou user:export --exclude '.*admin.*' --exclude 'supervisor.*'\n - kourou user:export --generate-credentials\n - kourou user:export --generate-credentials --generated-username content.email\n","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"path":{"name":"path","type":"option","description":"Dump directory","default":"users"},"exclude":{"name":"exclude","type":"option","description":"Exclude users by matching their IDs with a regexp"},"generate-credentials":{"name":"generate-credentials","type":"boolean","description":"Generate credentials with a random password for users","allowNo":false},"generated-username":{"name":"generated-username","type":"option","description":"User content property used as a username for local credentials","default":"_id"},"batch-size":{"name":"batch-size","type":"option","description":"Maximum batch size (see limits.documentsFetchCount config)","default":"2000"},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[]},"user:import-mappings":{"id":"user:import-mappings","description":"Imports users collection mappings","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"user:import":{"id":"user:import","description":"Imports users","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"host":{"name":"host","type":"option","description":"Kuzzle server host","default":"localhost"},"port":{"name":"port","type":"option","description":"Kuzzle server port","default":"7512"},"ssl":{"name":"ssl","type":"boolean","description":"Use SSL to connect to Kuzzle","allowNo":false},"username":{"name":"username","type":"option","description":"Kuzzle username (local strategy)","default":"anonymous"},"password":{"name":"password","type":"option","description":"Kuzzle user password"},"protocol":{"name":"protocol","type":"option","description":"Kuzzle protocol (http or websocket)","default":"ws"},"as":{"name":"as","type":"option","description":"Impersonate a user"},"api-key":{"name":"api-key","type":"option","description":"Kuzzle user api-key"}},"args":[{"name":"path","description":"Dump file","required":true}]},"vault:add":{"id":"vault:add","description":"\nAdds an encrypted key to an encrypted secrets file.\n\nA new secrets file is created if it does not yet exist.\n\nEncrypted secrets are meant to be loaded inside an application with Kuzzle Vault.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:add config/secrets.enc.json aws.s3.keyId b61e267676660c314b006b06 --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to the key (lodash style)","required":true},{"name":"value","description":"Value to encrypt","required":true}]},"vault:decrypt":{"id":"vault:decrypt","description":"\nDecrypts an entire secrets file.\n\nDecrypted secrets file must NEVER be committed into the repository.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:decrypt config/secrets.enc.json --vault-key <vault-key>","kourou vault:decrypt config/secrets.enc.json -o config/secrets.json --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: remove \".enc\")"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing encrypted secrets","required":true}]},"vault:encrypt":{"id":"vault:encrypt","description":"\nEncrypts an entire secrets file.\n\nThe secrets file must be in JSON format and it must contain only strings or objects.\n\nExample:\n{\n aws: {\n s3: {\n keyId: 'b61e267676660c314b006b06'\n }\n }\n}\n\nEncrypted secrets are meant to be loaded inside an application with Kuzzle Vault.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:encrypt config/secrets.json --vault-key <vault-key>","kourou vault:encrypt config/secrets.json -o config/secrets_prod.enc.json --vault-key <vault-key>"],"flags":{"force":{"name":"force","type":"boolean","char":"f","description":"Overwrite the output file if it already exists","allowNo":false},"output-file":{"name":"output-file","type":"option","char":"o","description":"Output file (default: <file>.enc.json)"},"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"file","description":"File containing unencrypted secrets","required":true}]},"vault:show":{"id":"vault:show","description":"\nPrints an encrypted secrets file content.\n\nThis method can display either:\n - the entire content of the secrets file\n - a single key value\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:show config/secrets.enc.json --vault-key <vault-key>","kourou vault:show config/secrets.enc.json aws.s3.secretKey --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true},{"name":"key","description":"Path to a key (lodash style)"}]},"vault:test":{"id":"vault:test","description":"\nTests if an encrypted secrets file can be decrypted.\n\nSee https://github.com/kuzzleio/kuzzle-vault/ for more information.\n","pluginName":"kourou","pluginType":"core","aliases":[],"examples":["kourou vault:test config/secrets.enc.json --vault-key <vault-key>"],"flags":{"vault-key":{"name":"vault-key","type":"option","description":"Kuzzle Vault Key (or KUZZLE_VAULT_KEY)"}},"args":[{"name":"secrets-file","description":"Encrypted secrets file","required":true}]},"es:indices:cat":{"id":"es:indices:cat","description":"Lists available ES indexes","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"grep":{"name":"grep","type":"option","char":"g","description":"Match output with pattern"}},"args":[]},"es:indices:get":{"id":"es:indices:get","description":"Gets a document from ES","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"}},"args":[{"name":"index","description":"ES Index name","required":true},{"name":"id","description":"Document ID","required":true}]},"es:indices:insert":{"id":"es:indices:insert","description":"Inserts a document directly into ES (will replace if exists)","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"body":{"name":"body","type":"option","description":"Document body in JSON","default":"{}"},"id":{"name":"id","type":"option","description":"Document ID"},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"index","description":"ES Index name","required":true}]},"es:snapshot:create-repository":{"id":"es:snapshot:create-repository","description":"Create a FS snapshot repository inside an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"compress":{"name":"compress","type":"boolean","description":"Compress data when storing them","allowNo":false},"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"ES repository name","required":true},{"name":"location","description":"ES snapshot repository location","required":true}]},"es:snapshot:create":{"id":"es:snapshot:create","description":"Create a snapshot repository inside an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"ES repository name","required":true},{"name":"name","description":"ES snapshot name","required":true}]},"es:snapshot:list":{"id":"es:snapshot:list","description":"List all snapshot from a repository acknowledge by an ES instance","pluginName":"kourou","pluginType":"core","aliases":[],"flags":{"node":{"name":"node","type":"option","char":"n","description":"Elasticsearch server URL","default":"http://localhost:9200"},"help":{"name":"help","type":"boolean","description":"show CLI help","allowNo":false}},"args":[{"name":"repository","description":"Name of repository from which to fetch the snapshot information","required":true}]}}}
|
package/package.json
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kourou",
|
|
3
3
|
"description": "The CLI that helps you manage your Kuzzle instances",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.5",
|
|
5
5
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"kourou": "./bin/run"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/kuzzleio/kourou/issues",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -b",
|
|
12
|
+
"dev": "./bin/run",
|
|
13
|
+
"postpack": "rm -f oclif.manifest.json",
|
|
14
|
+
"prepack": "tar czf templates.tgz templates/ && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
|
|
15
|
+
"postinstall": "[ -f templates.tgz ] && tar xf templates.tgz || true",
|
|
16
|
+
"version": "oclif-dev readme && git add README.md",
|
|
17
|
+
"test:lint": "eslint src/ test/ --ext .ts",
|
|
18
|
+
"test:lint:fix": "eslint src/ test/ --ext .ts --fix",
|
|
19
|
+
"test:functional": "npm run build && npm run test:functional:stdout && npm run test:functional:cucumber",
|
|
20
|
+
"test:functional:stdout": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
21
|
+
"test:functional:cucumber": "./node_modules/.bin/cucumber-js --fail-fast"
|
|
22
|
+
},
|
|
10
23
|
"dependencies": {
|
|
11
24
|
"@elastic/elasticsearch": "^7.12.0",
|
|
12
25
|
"@oclif/command": "^1.8.0",
|
|
13
26
|
"@oclif/config": "^1.17.0",
|
|
14
27
|
"@oclif/plugin-autocomplete": "^0.3.0",
|
|
15
|
-
"@oclif/plugin-help": "
|
|
28
|
+
"@oclif/plugin-help": "3.2.2",
|
|
16
29
|
"@types/bluebird": "^3.5.33",
|
|
17
30
|
"@types/inquirer": "^7.3.1",
|
|
18
31
|
"@types/ndjson": "^2.0.0",
|
|
@@ -122,18 +135,5 @@
|
|
|
122
135
|
}
|
|
123
136
|
},
|
|
124
137
|
"repository": "kuzzleio/kourou",
|
|
125
|
-
"scripts": {
|
|
126
|
-
"build": "tsc -b",
|
|
127
|
-
"dev": "./bin/run",
|
|
128
|
-
"postpack": "rm -f oclif.manifest.json",
|
|
129
|
-
"prepack": "tar czf templates.tgz templates/ && rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
|
|
130
|
-
"postinstall": "[ -f templates.tgz ] && tar xf templates.tgz || true",
|
|
131
|
-
"version": "oclif-dev readme && git add README.md",
|
|
132
|
-
"test:lint": "eslint src/ test/ --ext .ts",
|
|
133
|
-
"test:lint:fix": "eslint src/ test/ --ext .ts --fix",
|
|
134
|
-
"test:functional": "npm run build && npm run test:functional:stdout && npm run test:functional:cucumber",
|
|
135
|
-
"test:functional:stdout": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
136
|
-
"test:functional:cucumber": "./node_modules/.bin/cucumber-js"
|
|
137
|
-
},
|
|
138
138
|
"types": "lib/index.d.ts"
|
|
139
139
|
}
|
package/templates.tgz
CHANGED
|
Binary file
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { flags } from '@oclif/command';
|
|
2
|
-
import { Client } from '@elastic/elasticsearch';
|
|
3
|
-
import { Kommand } from '../../../common';
|
|
4
|
-
export default class ESRestore extends Kommand {
|
|
5
|
-
static initSdk: boolean;
|
|
6
|
-
static description: string;
|
|
7
|
-
static flags: {
|
|
8
|
-
node: flags.IOptionFlag<string>;
|
|
9
|
-
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
10
|
-
};
|
|
11
|
-
static args: {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
required: boolean;
|
|
15
|
-
}[];
|
|
16
|
-
getIndices(esClient: Client): Promise<any>;
|
|
17
|
-
runSafe(): Promise<void>;
|
|
18
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_1 = require("@oclif/command");
|
|
4
|
-
const elasticsearch_1 = require("@elastic/elasticsearch");
|
|
5
|
-
const common_1 = require("../../../common");
|
|
6
|
-
class ESRestore extends common_1.Kommand {
|
|
7
|
-
async getIndices(esClient) {
|
|
8
|
-
const beforeResponse = await esClient.cat.indices({ format: 'json' });
|
|
9
|
-
const indices = beforeResponse.body
|
|
10
|
-
.map(({ index }) => index);
|
|
11
|
-
return indices;
|
|
12
|
-
}
|
|
13
|
-
async runSafe() {
|
|
14
|
-
const esClient = new elasticsearch_1.Client({ node: this.flags.node });
|
|
15
|
-
const indices = await this.getIndices(esClient);
|
|
16
|
-
try {
|
|
17
|
-
for (const index of indices) {
|
|
18
|
-
await esClient.indices.close({ index });
|
|
19
|
-
}
|
|
20
|
-
const esRequest = {
|
|
21
|
-
repository: this.args.repository,
|
|
22
|
-
snapshot: this.args.name,
|
|
23
|
-
body: {}
|
|
24
|
-
};
|
|
25
|
-
const response = await esClient.snapshot.restore(esRequest);
|
|
26
|
-
this.logOk(`Success ${JSON.stringify(response.body, null, 2)}`);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
this.logKo(`Failed to restore requested snapshot ${this.args.name}`);
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
for (const index of indices) {
|
|
33
|
-
await esClient.indices.open({ index });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.default = ESRestore;
|
|
39
|
-
ESRestore.initSdk = false;
|
|
40
|
-
ESRestore.description = 'Restore a snapshot into an ES instance';
|
|
41
|
-
ESRestore.flags = {
|
|
42
|
-
node: command_1.flags.string({
|
|
43
|
-
char: 'n',
|
|
44
|
-
description: 'Elasticsearch server URL',
|
|
45
|
-
default: 'http://localhost:9200',
|
|
46
|
-
}),
|
|
47
|
-
help: command_1.flags.help(),
|
|
48
|
-
};
|
|
49
|
-
ESRestore.args = [
|
|
50
|
-
{ name: 'repository', description: 'ES repository name', required: true },
|
|
51
|
-
{ name: 'name', description: 'ES snapshot name', required: true },
|
|
52
|
-
];
|