kourou 0.24.2 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +98 -12
  2. package/lib/commands/api-key/check.d.ts +3 -3
  3. package/lib/commands/api-key/check.js +5 -7
  4. package/lib/commands/api-key/create.d.ts +3 -3
  5. package/lib/commands/api-key/create.js +8 -10
  6. package/lib/commands/api-key/delete.d.ts +3 -3
  7. package/lib/commands/api-key/delete.js +4 -6
  8. package/lib/commands/api-key/search.d.ts +3 -3
  9. package/lib/commands/api-key/search.js +5 -7
  10. package/lib/commands/app/debug-proxy.d.ts +3 -3
  11. package/lib/commands/app/debug-proxy.js +57 -55
  12. package/lib/commands/app/doctor.d.ts +24 -0
  13. package/lib/commands/app/doctor.js +201 -0
  14. package/lib/commands/app/scaffold.d.ts +2 -2
  15. package/lib/commands/app/scaffold.js +20 -15
  16. package/lib/commands/app/start-services.d.ts +1 -1
  17. package/lib/commands/app/start-services.js +26 -26
  18. package/lib/commands/collection/create.d.ts +3 -3
  19. package/lib/commands/collection/create.js +9 -6
  20. package/lib/commands/collection/export.d.ts +5 -5
  21. package/lib/commands/collection/export.js +25 -26
  22. package/lib/commands/collection/import.d.ts +5 -5
  23. package/lib/commands/collection/import.js +17 -17
  24. package/lib/commands/collection/migrate.d.ts +27 -0
  25. package/lib/commands/collection/migrate.js +43 -0
  26. package/lib/commands/config/diff.d.ts +1 -1
  27. package/lib/commands/config/diff.js +27 -21
  28. package/lib/commands/document/search.d.ts +3 -3
  29. package/lib/commands/document/search.js +20 -20
  30. package/lib/commands/es/aliases/cat.d.ts +12 -0
  31. package/lib/commands/es/aliases/cat.js +36 -0
  32. package/lib/commands/es/indices/cat.d.ts +2 -2
  33. package/lib/commands/es/indices/cat.js +8 -8
  34. package/lib/commands/es/indices/get.d.ts +2 -2
  35. package/lib/commands/es/indices/get.js +7 -7
  36. package/lib/commands/es/indices/insert.d.ts +2 -2
  37. package/lib/commands/es/indices/insert.js +9 -9
  38. package/lib/commands/es/migrate.d.ts +10 -8
  39. package/lib/commands/es/migrate.js +86 -82
  40. package/lib/commands/es/snapshot/create-repository.d.ts +2 -2
  41. package/lib/commands/es/snapshot/create-repository.js +16 -12
  42. package/lib/commands/es/snapshot/create.d.ts +2 -2
  43. package/lib/commands/es/snapshot/create.js +7 -7
  44. package/lib/commands/es/snapshot/list.d.ts +2 -2
  45. package/lib/commands/es/snapshot/list.js +12 -8
  46. package/lib/commands/file/decrypt.d.ts +4 -4
  47. package/lib/commands/file/decrypt.js +21 -21
  48. package/lib/commands/file/encrypt.d.ts +4 -4
  49. package/lib/commands/file/encrypt.js +20 -22
  50. package/lib/commands/file/test.d.ts +3 -3
  51. package/lib/commands/file/test.js +13 -13
  52. package/lib/commands/import.d.ts +5 -5
  53. package/lib/commands/import.js +39 -28
  54. package/lib/commands/index/export.d.ts +5 -4
  55. package/lib/commands/index/export.js +21 -19
  56. package/lib/commands/index/import.d.ts +5 -5
  57. package/lib/commands/index/import.js +21 -19
  58. package/lib/commands/instance/kill.d.ts +2 -2
  59. package/lib/commands/instance/kill.js +34 -34
  60. package/lib/commands/instance/list.d.ts +1 -1
  61. package/lib/commands/instance/list.js +33 -30
  62. package/lib/commands/instance/logs.d.ts +2 -2
  63. package/lib/commands/instance/logs.js +26 -22
  64. package/lib/commands/instance/spawn.d.ts +2 -2
  65. package/lib/commands/instance/spawn.js +46 -40
  66. package/lib/commands/paas/deploy.d.ts +2 -2
  67. package/lib/commands/paas/deploy.js +33 -21
  68. package/lib/commands/paas/init.d.ts +1 -1
  69. package/lib/commands/paas/init.js +10 -6
  70. package/lib/commands/paas/login.d.ts +3 -3
  71. package/lib/commands/paas/login.js +32 -21
  72. package/lib/commands/paas/logs.d.ts +27 -0
  73. package/lib/commands/paas/logs.js +142 -18
  74. package/lib/commands/profile/export.d.ts +3 -3
  75. package/lib/commands/profile/export.js +12 -12
  76. package/lib/commands/profile/import.d.ts +3 -3
  77. package/lib/commands/profile/import.js +6 -8
  78. package/lib/commands/realtime/subscribe.d.ts +3 -3
  79. package/lib/commands/realtime/subscribe.js +25 -25
  80. package/lib/commands/redis/list-keys.d.ts +3 -3
  81. package/lib/commands/redis/list-keys.js +15 -11
  82. package/lib/commands/role/export.d.ts +3 -3
  83. package/lib/commands/role/export.js +11 -11
  84. package/lib/commands/role/import.d.ts +4 -4
  85. package/lib/commands/role/import.js +10 -12
  86. package/lib/commands/sdk/execute.d.ts +5 -5
  87. package/lib/commands/sdk/execute.js +23 -19
  88. package/lib/commands/sdk/query.d.ts +5 -4
  89. package/lib/commands/sdk/query.js +30 -24
  90. package/lib/commands/user/export-mappings.d.ts +3 -3
  91. package/lib/commands/user/export-mappings.js +11 -11
  92. package/lib/commands/user/export.d.ts +6 -6
  93. package/lib/commands/user/export.js +34 -33
  94. package/lib/commands/user/import-mappings.d.ts +3 -3
  95. package/lib/commands/user/import-mappings.js +7 -7
  96. package/lib/commands/user/import.d.ts +3 -3
  97. package/lib/commands/user/import.js +6 -8
  98. package/lib/commands/vault/add.d.ts +3 -3
  99. package/lib/commands/vault/add.js +27 -19
  100. package/lib/commands/vault/decrypt.d.ts +4 -4
  101. package/lib/commands/vault/decrypt.js +24 -20
  102. package/lib/commands/vault/encrypt.d.ts +4 -4
  103. package/lib/commands/vault/encrypt.js +24 -20
  104. package/lib/commands/vault/show.d.ts +3 -3
  105. package/lib/commands/vault/show.js +24 -20
  106. package/lib/commands/vault/test.d.ts +3 -3
  107. package/lib/commands/vault/test.js +16 -12
  108. package/lib/common.d.ts +3 -3
  109. package/lib/common.js +28 -29
  110. package/lib/hooks/command_not_found/api-action.d.ts +2 -2
  111. package/lib/hooks/command_not_found/api-action.js +20 -22
  112. package/lib/index.d.ts +1 -1
  113. package/lib/support/PaasKommand.d.ts +3 -2
  114. package/lib/support/PaasKommand.js +12 -9
  115. package/lib/support/dump-collection.js +50 -41
  116. package/lib/support/editor.js +12 -10
  117. package/lib/support/execute.d.ts +6 -1
  118. package/lib/support/execute.js +9 -8
  119. package/lib/support/kuzzle.d.ts +12 -4
  120. package/lib/support/kuzzle.js +67 -31
  121. package/lib/support/migrate/providers/elasticsearch.d.ts +16 -0
  122. package/lib/support/migrate/providers/elasticsearch.js +74 -0
  123. package/lib/support/migrate/providers/file.d.ts +15 -0
  124. package/lib/support/migrate/providers/file.js +74 -0
  125. package/lib/support/migrate/providers/index.d.ts +12 -0
  126. package/lib/support/migrate/providers/index.js +16 -0
  127. package/lib/support/migrate/types.d.ts +8 -0
  128. package/lib/support/migrate/types.js +2 -0
  129. package/lib/support/restore-collection.d.ts +2 -1
  130. package/lib/support/restore-collection.js +37 -26
  131. package/lib/support/restore-securities.js +22 -19
  132. package/package.json +16 -15
package/README.md CHANGED
@@ -26,7 +26,7 @@ $ npm install -g kourou
26
26
  $ kourou COMMAND
27
27
  running command...
28
28
  $ kourou (-v|--version|version)
29
- kourou/0.24.2 darwin-x64 node-v16.17.0
29
+ kourou/0.25.1 linux-x64 node-v16.15.0
30
30
  $ kourou --help [COMMAND]
31
31
  USAGE
32
32
  $ kourou COMMAND
@@ -130,14 +130,17 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
130
130
  * [`kourou api-key:delete USER ID`](#kourou-api-keydelete-user-id)
131
131
  * [`kourou api-key:search USER`](#kourou-api-keysearch-user)
132
132
  * [`kourou app:debug-proxy`](#kourou-appdebug-proxy)
133
+ * [`kourou app:doctor`](#kourou-appdoctor)
133
134
  * [`kourou app:scaffold DESTINATION`](#kourou-appscaffold-destination)
134
135
  * [`kourou app:start-services`](#kourou-appstart-services)
135
136
  * [`kourou autocomplete [SHELL]`](#kourou-autocomplete-shell)
136
137
  * [`kourou collection:create INDEX COLLECTION [BODY]`](#kourou-collectioncreate-index-collection-body)
137
138
  * [`kourou collection:export INDEX COLLECTION`](#kourou-collectionexport-index-collection)
138
139
  * [`kourou collection:import PATH`](#kourou-collectionimport-path)
140
+ * [`kourou collection:migrate SCRIPT PATH`](#kourou-collectionmigrate-script-path)
139
141
  * [`kourou config:diff FIRST SECOND`](#kourou-configdiff-first-second)
140
142
  * [`kourou document:search INDEX COLLECTION [QUERY]`](#kourou-documentsearch-index-collection-query)
143
+ * [`kourou es:aliases:cat`](#kourou-esaliasescat)
141
144
  * [`kourou es:indices:cat`](#kourou-esindicescat)
142
145
  * [`kourou es:indices:get INDEX ID`](#kourou-esindicesget-index-id)
143
146
  * [`kourou es:indices:insert INDEX`](#kourou-esindicesinsert-index)
@@ -327,6 +330,29 @@ OPTIONS
327
330
 
328
331
  _See code: [src/commands/app/debug-proxy.ts](src/commands/app/debug-proxy.ts)_
329
332
 
333
+ ## `kourou app:doctor`
334
+
335
+ Analyze a Kuzzle application
336
+
337
+ ```
338
+ USAGE
339
+ $ kourou app:doctor
340
+
341
+ OPTIONS
342
+ --api-key=api-key Kuzzle user api-key
343
+ --as=as Impersonate a user
344
+ --elasticsearch=elasticsearch [default: http://localhost:9200] Elasticsearch server URL
345
+ --help show CLI help
346
+ --host=host [default: localhost] Kuzzle server host
347
+ --password=password Kuzzle user password
348
+ --port=port [default: 7512] Kuzzle server port
349
+ --protocol=protocol [default: ws] Kuzzle protocol (http or ws)
350
+ --ssl Use SSL to connect to Kuzzle
351
+ --username=username [default: anonymous] Kuzzle username (local strategy)
352
+ ```
353
+
354
+ _See code: [src/commands/app/doctor.ts](src/commands/app/doctor.ts)_
355
+
330
356
  ## `kourou app:scaffold DESTINATION`
331
357
 
332
358
  Scaffolds a new Kuzzle application
@@ -339,7 +365,9 @@ ARGUMENTS
339
365
  DESTINATION Directory to scaffold the app
340
366
 
341
367
  OPTIONS
342
- --flavor=flavor [default: generic] Template flavor ("generic", "iot-platform")
368
+ --flavor=flavor [default: generic] Template flavor ("generic", "iot-backend", "iot-console").
369
+ Those can be found here: https://github.com/kuzzleio/project-templates
370
+
343
371
  --help show CLI help
344
372
  ```
345
373
 
@@ -381,7 +409,7 @@ EXAMPLES
381
409
  $ kourou autocomplete --refresh-cache
382
410
  ```
383
411
 
384
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.2.0/src/commands/autocomplete/index.ts)_
412
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.3.10/src/commands/autocomplete/index.ts)_
385
413
 
386
414
  ## `kourou collection:create INDEX COLLECTION [BODY]`
387
415
 
@@ -471,7 +499,8 @@ OPTIONS
471
499
  [default: {}] Only dump documents matching the query (JS or JSON format)
472
500
 
473
501
  --scrollTTL=scrollTTL
474
- The scroll TTL option to pass to the dump operation (which performs a document.search under the hood),
502
+ [default: 20s] The scroll TTL option to pass to the dump operation (which performs a document.search under the
503
+ hood),
475
504
  expressed in ms format, e.g. '2s', '1m', '3h'.
476
505
 
477
506
  --ssl
@@ -516,6 +545,35 @@ OPTIONS
516
545
 
517
546
  _See code: [src/commands/collection/import.ts](src/commands/collection/import.ts)_
518
547
 
548
+ ## `kourou collection:migrate SCRIPT PATH`
549
+
550
+ Migrate a collection by transforming documents from a dump file and importing them into Kuzzle
551
+
552
+ ```
553
+ USAGE
554
+ $ kourou collection:migrate SCRIPT PATH
555
+
556
+ ARGUMENTS
557
+ SCRIPT Migration script path
558
+ PATH Collection dump path
559
+
560
+ OPTIONS
561
+ --api-key=api-key Kuzzle user api-key
562
+ --as=as Impersonate a user
563
+ --batch-size=batch-size [default: 200] Maximum batch size (see limits.documentsWriteCount config)
564
+ --collection=collection If set, override the collection destination name
565
+ --help show CLI help
566
+ --host=host [default: localhost] Kuzzle server host
567
+ --index=index If set, override the index destination name
568
+ --password=password Kuzzle user password
569
+ --port=port [default: 7512] Kuzzle server port
570
+ --protocol=protocol [default: ws] Kuzzle protocol (http or websocket)
571
+ --ssl Use SSL to connect to Kuzzle
572
+ --username=username [default: anonymous] Kuzzle username (local strategy)
573
+ ```
574
+
575
+ _See code: [src/commands/collection/migrate.ts](src/commands/collection/migrate.ts)_
576
+
519
577
  ## `kourou config:diff FIRST SECOND`
520
578
 
521
579
  Returns differences between two Kuzzle configuration files (kuzzlerc)
@@ -576,6 +634,22 @@ EXAMPLES
576
634
 
577
635
  _See code: [src/commands/document/search.ts](src/commands/document/search.ts)_
578
636
 
637
+ ## `kourou es:aliases:cat`
638
+
639
+ Lists available ES aliases
640
+
641
+ ```
642
+ USAGE
643
+ $ kourou es:aliases:cat
644
+
645
+ OPTIONS
646
+ -g, --grep=grep Match output with pattern
647
+ -n, --node=node [default: http://localhost:9200] Elasticsearch server URL
648
+ --help show CLI help
649
+ ```
650
+
651
+ _See code: [src/commands/es/aliases/cat.ts](src/commands/es/aliases/cat.ts)_
652
+
579
653
  ## `kourou es:indices:cat`
580
654
 
581
655
  Lists available ES indexes
@@ -633,7 +707,7 @@ _See code: [src/commands/es/indices/insert.ts](src/commands/es/indices/insert.ts
633
707
 
634
708
  ## `kourou es:migrate`
635
709
 
636
- Migrate all the index from one Elasticsearch server to another
710
+ Migrate all the index from an Elasticsearch (or a file) to another Elasticsearch
637
711
 
638
712
  ```
639
713
  USAGE
@@ -641,19 +715,19 @@ USAGE
641
715
 
642
716
  OPTIONS
643
717
  --batch-size=batch-size [default: 1000] How many documents to move in batch per operation
644
- --dest=dest (required) Destination Elasticsearch server URL
718
+ --dest=dest (required) Migration destination provider
645
719
  --dry-run Print witch collections will be migrated
646
720
  --help show CLI help
647
721
  --no-interactive Skip confirmation interactive prompts (perfect for scripting)
648
722
  --pattern=pattern Pattern to match indices to migrate
649
723
  --reset Reset destination Elasticsearch server
650
724
  --scroll=scroll [default: 30s] Scroll duration for Elasticsearch scrolling
651
- --src=src (required) Source Elasticsearch server URL
725
+ --src=src (required) Migration source provider
652
726
 
653
727
  EXAMPLES
654
- kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000
655
- kourou es:migrate --src http://elasticsearch:9200 --dest http://otherElasticsearch:9200 --reset --batch-size 2000
656
- --no-interactive
728
+ kourou es:migrate --src http://elasticsearch:9200 --dest ./my-backup --batch-size 2000 --pattern
729
+ '&myindexes.collection-*'
730
+ kourou es:migrate --src ./my-backup --dest http://elasticsearch:9200 --reset --batch-size 2000 --no-interactive
657
731
  ```
658
732
 
659
733
  _See code: [src/commands/es/migrate.ts](src/commands/es/migrate.ts)_
@@ -796,7 +870,7 @@ OPTIONS
796
870
  --all see all commands in CLI
797
871
  ```
798
872
 
799
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2/src/commands/help.ts)_
873
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_
800
874
 
801
875
  ## `kourou import PATH`
802
876
 
@@ -858,6 +932,10 @@ OPTIONS
858
932
 
859
933
  --query=query [default: {}] Only dump documents in collections matching the query (JS or JSON format)
860
934
 
935
+ --scrollTTL=scrollTTL [default: 20s] The scroll TTL option to pass to the dump operation (which performs a
936
+ document.search under the hood),
937
+ expressed in ms format, e.g. '2s', '1m', '3h'.
938
+
861
939
  --ssl Use SSL to connect to Kuzzle
862
940
 
863
941
  --username=username [default: anonymous] Kuzzle username (local strategy)
@@ -1026,8 +1104,14 @@ ARGUMENTS
1026
1104
  APPLICATION Kuzzle PaaS application
1027
1105
 
1028
1106
  OPTIONS
1107
+ -f, --follow Follow log output
1108
+ -n, --tail=tail Number of lines to show from the end of the logs
1109
+ -t, --timestamp Show timestamp
1029
1110
  --help show CLI help
1111
+ --podName=podName Name of the pod to show logs from
1030
1112
  --project=project Current PaaS project
1113
+ --since=since Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time
1114
+ --until=until Display logs until a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time
1031
1115
  ```
1032
1116
 
1033
1117
  _See code: [src/commands/paas/logs.ts](src/commands/paas/logs.ts)_
@@ -1306,6 +1390,8 @@ OPTIONS
1306
1390
 
1307
1391
  --port=port [default: 7512] Kuzzle server port
1308
1392
 
1393
+ --print-raw Print only the query result to stdout
1394
+
1309
1395
  --protocol=protocol [default: ws] Kuzzle protocol (http or ws)
1310
1396
 
1311
1397
  --ssl Use SSL to connect to Kuzzle
@@ -1678,7 +1764,7 @@ $ kourou sdk:execute --print-raw '(
1678
1764
 
1679
1765
  # Telemetry
1680
1766
 
1681
- We use a custom Open Source analytics backend (you can check the code [here](https://gihtub.com/kuzzleio/kepler)) to record the use of Kourou by users.
1767
+ We use a custom Open Source analytics backend (you can check the code [here](https://github.com/kuzzleio/kepler)) to record the use of Kourou by users.
1682
1768
 
1683
1769
  Collected metrics will allow us to study the use of our products in order to improve them. We do not collect any personal data about users.
1684
1770
 
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  declare class ApiKeyCheck extends Kommand {
4
4
  static description: string;
5
5
  static flags: {
@@ -10,7 +10,7 @@ declare class ApiKeyCheck extends Kommand {
10
10
  password: flags.IOptionFlag<string | undefined>;
11
11
  protocol: flags.IOptionFlag<string>;
12
12
  as: flags.IOptionFlag<string | undefined>;
13
- 'api-key': flags.IOptionFlag<string | undefined>;
13
+ "api-key": flags.IOptionFlag<string | undefined>;
14
14
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
15
  };
16
16
  static args: {
@@ -7,19 +7,17 @@ class ApiKeyCheck extends common_1.Kommand {
7
7
  async runSafe() {
8
8
  const { valid } = await this.sdk.auth.checkToken(this.args.token);
9
9
  if (valid) {
10
- this.logOk('API key is still valid');
10
+ this.logOk("API key is still valid");
11
11
  }
12
12
  else {
13
- this.logKo('API key is not valid');
13
+ this.logKo("API key is not valid");
14
14
  }
15
15
  }
16
16
  }
17
- ApiKeyCheck.description = 'Checks an API key validity';
17
+ ApiKeyCheck.description = "Checks an API key validity";
18
18
  ApiKeyCheck.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags);
19
19
  ApiKeyCheck.args = [
20
- { name: 'token', description: 'API key token', required: true },
21
- ];
22
- ApiKeyCheck.examples = [
23
- 'kourou api-key:check eyJhbG...QxfQrc'
20
+ { name: "token", description: "API key token", required: true },
24
21
  ];
22
+ ApiKeyCheck.examples = ["kourou api-key:check eyJhbG...QxfQrc"];
25
23
  exports.default = ApiKeyCheck;
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  declare class ApiKeyCreate extends Kommand {
4
4
  static description: string;
5
5
  static flags: {
@@ -10,7 +10,7 @@ declare class ApiKeyCreate extends Kommand {
10
10
  password: flags.IOptionFlag<string | undefined>;
11
11
  protocol: flags.IOptionFlag<string>;
12
12
  as: flags.IOptionFlag<string | undefined>;
13
- 'api-key': flags.IOptionFlag<string | undefined>;
13
+ "api-key": flags.IOptionFlag<string | undefined>;
14
14
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
15
  description: flags.IOptionFlag<string>;
16
16
  id: flags.IOptionFlag<string | undefined>;
@@ -7,24 +7,22 @@ class ApiKeyCreate extends common_1.Kommand {
7
7
  async runSafe() {
8
8
  const apiKey = await this.sdk.security.createApiKey(this.args.user, this.flags.description, {
9
9
  _id: this.flags.id,
10
- expiresIn: this.flags.expire
10
+ expiresIn: this.flags.expire,
11
11
  });
12
12
  this.logOk(`Successfully created API Key "${apiKey._id}" for user "${this.args.user}"`);
13
13
  this.log(apiKey._source.token);
14
14
  }
15
15
  }
16
- ApiKeyCreate.description = 'Creates a new API Key for a user';
16
+ ApiKeyCreate.description = "Creates a new API Key for a user";
17
17
  ApiKeyCreate.flags = Object.assign({ help: command_1.flags.help(), description: command_1.flags.string({
18
- char: 'd',
19
- description: 'API Key description',
18
+ char: "d",
19
+ description: "API Key description",
20
20
  required: true,
21
21
  }), id: command_1.flags.string({
22
- description: 'API Key unique ID',
22
+ description: "API Key unique ID",
23
23
  }), expire: command_1.flags.string({
24
- description: 'API Key validity',
25
- default: '-1',
24
+ description: "API Key validity",
25
+ default: "-1",
26
26
  }) }, kuzzle_1.kuzzleFlags);
27
- ApiKeyCreate.args = [
28
- { name: 'user', description: 'User kuid', required: true },
29
- ];
27
+ ApiKeyCreate.args = [{ name: "user", description: "User kuid", required: true }];
30
28
  exports.default = ApiKeyCreate;
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  declare class ApiKeyDelete extends Kommand {
4
4
  static description: string;
5
5
  static flags: {
@@ -10,7 +10,7 @@ declare class ApiKeyDelete extends Kommand {
10
10
  password: flags.IOptionFlag<string | undefined>;
11
11
  protocol: flags.IOptionFlag<string>;
12
12
  as: flags.IOptionFlag<string | undefined>;
13
- 'api-key': flags.IOptionFlag<string | undefined>;
13
+ "api-key": flags.IOptionFlag<string | undefined>;
14
14
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
15
  };
16
16
  static args: {
@@ -9,13 +9,11 @@ class ApiKeyDelete extends common_1.Kommand {
9
9
  this.logOk(`Successfully deleted API Key "${this.args.id}" of user "${this.args.user}"`);
10
10
  }
11
11
  }
12
- ApiKeyDelete.description = 'Deletes an API key.';
12
+ ApiKeyDelete.description = "Deletes an API key.";
13
13
  ApiKeyDelete.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags);
14
14
  ApiKeyDelete.args = [
15
- { name: 'user', description: 'User kuid', required: true },
16
- { name: 'id', description: 'API Key unique ID', required: true },
17
- ];
18
- ApiKeyDelete.examples = [
19
- 'kourou vault:delete sigfox-gateway 1k-BF3EBjsXdvA2PR8x'
15
+ { name: "user", description: "User kuid", required: true },
16
+ { name: "id", description: "API Key unique ID", required: true },
20
17
  ];
18
+ ApiKeyDelete.examples = ["kourou vault:delete sigfox-gateway 1k-BF3EBjsXdvA2PR8x"];
21
19
  exports.default = ApiKeyDelete;
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  declare class ApiKeySearch extends Kommand {
4
4
  static description: string;
5
5
  static flags: {
@@ -10,7 +10,7 @@ declare class ApiKeySearch extends Kommand {
10
10
  password: flags.IOptionFlag<string | undefined>;
11
11
  protocol: flags.IOptionFlag<string>;
12
12
  as: flags.IOptionFlag<string | undefined>;
13
- 'api-key': flags.IOptionFlag<string | undefined>;
13
+ "api-key": flags.IOptionFlag<string | undefined>;
14
14
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
15
  filter: flags.IOptionFlag<string | undefined>;
16
16
  };
@@ -15,11 +15,11 @@ class ApiKeySearch extends common_1.Kommand {
15
15
  }
16
16
  const result = await this.sdk.security.searchApiKeys(this.args.user, query, {
17
17
  from: 0,
18
- size: 100
18
+ size: 100,
19
19
  });
20
20
  this.logOk(`${result.total} API Keys found for user ${this.args.user}`);
21
21
  if (result.total !== 0) {
22
- this.log('');
22
+ this.log("");
23
23
  for (const { _id, _source } of result.hits) {
24
24
  this.log(` - Key "${_id}"`);
25
25
  this.log(` Description: ${_source.description}`);
@@ -29,11 +29,9 @@ class ApiKeySearch extends common_1.Kommand {
29
29
  }
30
30
  }
31
31
  }
32
- ApiKeySearch.description = 'Lists a user\'s API Keys.';
32
+ ApiKeySearch.description = "Lists a user's API Keys.";
33
33
  ApiKeySearch.flags = Object.assign({ help: command_1.flags.help(), filter: command_1.flags.string({
34
- description: 'Filter to match the API Key descriptions',
34
+ description: "Filter to match the API Key descriptions",
35
35
  }) }, kuzzle_1.kuzzleFlags);
36
- ApiKeySearch.args = [
37
- { name: 'user', description: 'User kuid', required: true },
38
- ];
36
+ ApiKeySearch.args = [{ name: "user", description: "User kuid", required: true }];
39
37
  exports.default = ApiKeySearch;
@@ -1,5 +1,5 @@
1
- import { flags } from '@oclif/command';
2
- import { Kommand } from '../../common';
1
+ import { flags } from "@oclif/command";
2
+ import { Kommand } from "../../common";
3
3
  export default class DebugProxy extends Kommand {
4
4
  static description: string;
5
5
  static flags: {
@@ -10,7 +10,7 @@ export default class DebugProxy extends Kommand {
10
10
  password: flags.IOptionFlag<string | undefined>;
11
11
  protocol: flags.IOptionFlag<string>;
12
12
  as: flags.IOptionFlag<string | undefined>;
13
- 'api-key': flags.IOptionFlag<string | undefined>;
13
+ "api-key": flags.IOptionFlag<string | undefined>;
14
14
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
15
  forwardPort: import("@oclif/parser/lib/flags").IOptionFlag<number>;
16
16
  ttl: flags.IOptionFlag<string>;
@@ -4,23 +4,23 @@ const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
5
  const common_1 = require("../../common");
6
6
  const kuzzle_1 = require("../../support/kuzzle");
7
- const http_1 = tslib_1.__importDefault(require("http"));
8
- const ws_1 = tslib_1.__importDefault(require("ws"));
7
+ const http_1 = (0, tslib_1.__importDefault)(require("http"));
8
+ const ws_1 = (0, tslib_1.__importDefault)(require("ws"));
9
9
  // Add the proper headers and send the body in the response
10
10
  function sendResponse(response, bodyObject) {
11
- response.setHeader('Content-Type', 'application/json; charset=UTF-8');
12
- response.setHeader('Cache-Control', 'no-cache');
11
+ response.setHeader("Content-Type", "application/json; charset=UTF-8");
12
+ response.setHeader("Cache-Control", "no-cache");
13
13
  const body = JSON.stringify(bodyObject);
14
- response.setHeader('Content-Length', Buffer.byteLength(body));
14
+ response.setHeader("Content-Length", Buffer.byteLength(body));
15
15
  response.writeHead(200);
16
16
  response.end(body);
17
17
  }
18
18
  class DebugProxy extends common_1.Kommand {
19
19
  async runSafe() {
20
- const nodeVersionResponse = await this.sdk.query({
21
- controller: 'debug',
22
- action: 'nodeVersion'
23
- });
20
+ const nodeVersionResponse = (await this.sdk.query({
21
+ controller: "debug",
22
+ action: "nodeVersion",
23
+ }));
24
24
  this.logInfo(`Connected to Kuzzle node: ${nodeVersionResponse.node}`);
25
25
  /**
26
26
  * To allow the Chrome Debugger to see the proxy server we must implement the following routes:
@@ -28,67 +28,69 @@ class DebugProxy extends common_1.Kommand {
28
28
  * - /json
29
29
  */
30
30
  const server = http_1.default.createServer((request, response) => {
31
- if (request.url === '/json/version') {
31
+ if (request.url === "/json/version") {
32
32
  sendResponse(response, {
33
33
  Browser: `node.js/${nodeVersionResponse.result}`,
34
- "Protocol-Version": "1.1"
34
+ "Protocol-Version": "1.1",
35
35
  });
36
36
  return;
37
37
  }
38
- else if (request.url === '/json') {
38
+ else if (request.url === "/json") {
39
39
  // Here we send a bunch of information about the Remote Target to the Chrome Debugger
40
40
  // Those are the informations that the Chrome Debugger uses to know how to connect to Remote Target
41
41
  // We give the Chrome Inspector our own Websocket endpoint so that it can connect to our proxy server
42
- sendResponse(response, [{
43
- description: 'node.js instance',
42
+ sendResponse(response, [
43
+ {
44
+ description: "node.js instance",
44
45
  devtoolsFrontendUrl: `devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=${request.headers.host}/kuzzle-debugger`,
45
46
  devtoolsFrontendUrlCompat: `devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=${request.headers.host}/kuzzle-debugger`,
46
- faviconUrl: 'https://nodejs.org/static/images/favicons/favicon.ico',
47
- id: 'kuzzle-debugger',
47
+ faviconUrl: "https://nodejs.org/static/images/favicons/favicon.ico",
48
+ id: "kuzzle-debugger",
48
49
  title: `Kuzzle Debugger - ${this.flags.host}:${this.flags.port}`,
49
- type: 'node',
50
- webSocketDebuggerUrl: `ws://${request.headers.host}/kuzzle-debugger`
51
- }]);
50
+ type: "node",
51
+ webSocketDebuggerUrl: `ws://${request.headers.host}/kuzzle-debugger`,
52
+ },
53
+ ]);
52
54
  return;
53
55
  }
54
56
  response.writeHead(404);
55
57
  });
56
58
  const closeServer = async () => {
57
- this.logInfo('Connection closed.');
59
+ this.logInfo("Connection closed.");
58
60
  if (!this.flags.noAutoEnableDebugger) {
59
61
  await this.sdk.query({
60
- controller: 'debug',
61
- action: 'disable'
62
+ controller: "debug",
63
+ action: "disable",
62
64
  });
63
65
  }
64
66
  this.sdk.disconnect();
65
67
  server.close();
66
68
  };
67
69
  const wss = new ws_1.default.Server({
68
- server
70
+ server,
69
71
  });
70
72
  if (!this.flags.noAutoEnableDebugger) {
71
73
  await this.sdk.query({
72
- controller: 'debug',
73
- action: 'enable'
74
+ controller: "debug",
75
+ action: "enable",
74
76
  });
75
77
  }
76
78
  // Listen to all events emitted by the Debug Controller
77
79
  await this.sdk.query({
78
- controller: 'debug',
79
- action: 'addListener',
80
+ controller: "debug",
81
+ action: "addListener",
80
82
  body: {
81
- event: '*'
82
- }
83
+ event: "*",
84
+ },
83
85
  });
84
- wss.on('connection', ws => {
85
- this.logInfo('Connection established.');
86
+ wss.on("connection", (ws) => {
87
+ this.logInfo("Connection established.");
86
88
  /**
87
89
  * Listen to the room were events from the DebugController are sent
88
90
  * and only forward events from the Chrome Devtools Protocol
89
91
  */
90
- this.sdk.sdk.protocol.on('kuzzle-debugger-event', (payload) => {
91
- if (!payload.event || payload.event.startsWith('Kuzzle')) {
92
+ this.sdk.sdk.protocol.on("kuzzle-debugger-event", (payload) => {
93
+ if (!payload.event || payload.event.startsWith("Kuzzle")) {
92
94
  return;
93
95
  }
94
96
  if (this.flags.showDebuggerEvents) {
@@ -97,7 +99,7 @@ class DebugProxy extends common_1.Kommand {
97
99
  ws.send(JSON.stringify(payload.result));
98
100
  });
99
101
  // When receiving message from Chrome Devtools Protocol, we forward it to the DebugController
100
- ws.on('message', async (message) => {
102
+ ws.on("message", async (message) => {
101
103
  try {
102
104
  const json = JSON.parse(message.toString());
103
105
  if (json.id === undefined || json.method === undefined) {
@@ -110,32 +112,32 @@ class DebugProxy extends common_1.Kommand {
110
112
  }, null, 2));
111
113
  }
112
114
  const response = await this.sdk.query({
113
- controller: 'debug',
114
- action: 'post',
115
+ controller: "debug",
116
+ action: "post",
115
117
  body: {
116
118
  method: json.method,
117
119
  params: json.params,
118
- }
120
+ },
119
121
  });
120
122
  if (this.flags.showDebuggerPayloads) {
121
123
  this.logInfo(JSON.stringify({
122
124
  id: json.id,
123
- result: response.result
125
+ result: response.result,
124
126
  }, null, 2));
125
127
  }
126
128
  // Send back the response using the same ID received
127
129
  ws.send(JSON.stringify({
128
130
  id: json.id,
129
- result: response.result
131
+ result: response.result,
130
132
  }));
131
133
  }
132
134
  catch (e) {
133
135
  this.logKo(`${e}`);
134
136
  }
135
137
  });
136
- ws.on('close', closeServer);
138
+ ws.on("close", closeServer);
137
139
  });
138
- server.on('error', async (err) => {
140
+ server.on("error", async (err) => {
139
141
  this.logKo(err.message);
140
142
  this.logKo(err.stack);
141
143
  await closeServer();
@@ -143,40 +145,40 @@ class DebugProxy extends common_1.Kommand {
143
145
  server.listen(this.flags.forwardPort, () => {
144
146
  this.logOk(`Listening on port ${this.flags.forwardPort}, forwarding to Kuzzle at ${this.flags.host}:${this.flags.port}`);
145
147
  this.logInfo(`Showing to Chrome Debugger as "Kuzzle Debugger - ${this.flags.host}:${this.flags.port}"`);
146
- this.logInfo('Waiting for Chrome Debugger to connect...');
148
+ this.logInfo("Waiting for Chrome Debugger to connect...");
147
149
  });
148
150
  let resolve;
149
- const promise = new Promise(res => {
151
+ const promise = new Promise((res) => {
150
152
  resolve = res;
151
153
  });
152
- server.on('close', () => {
154
+ server.on("close", () => {
153
155
  resolve();
154
156
  });
155
157
  await promise;
156
158
  }
157
159
  }
158
160
  exports.default = DebugProxy;
159
- DebugProxy.description = 'Create a Proxy Server that allows Chrome to debug Kuzzle remotely using the DebugController';
161
+ DebugProxy.description = "Create a Proxy Server that allows Chrome to debug Kuzzle remotely using the DebugController";
160
162
  DebugProxy.flags = Object.assign({ help: command_1.flags.help(), forwardPort: command_1.flags.integer({
161
- description: 'Port of the forwarding server',
162
- default: 9222
163
+ description: "Port of the forwarding server",
164
+ default: 9222,
163
165
  }), ttl: command_1.flags.string({
164
- description: 'Kuzzle login TTL',
165
- default: '1h',
166
+ description: "Kuzzle login TTL",
167
+ default: "1h",
166
168
  }), keepAuth: command_1.flags.boolean({
167
- description: 'Keep the user authenticated',
169
+ description: "Keep the user authenticated",
168
170
  default: false,
169
171
  }), noAutoEnableDebugger: command_1.flags.boolean({
170
- description: 'True if Kourou should not enable and disable the Debugger automatically before and after usage',
171
- default: false
172
+ description: "True if Kourou should not enable and disable the Debugger automatically before and after usage",
173
+ default: false,
172
174
  }), showDebuggerEvents: command_1.flags.boolean({
173
- description: 'Verbose mode to display events sent to the Chrome Debugger',
175
+ description: "Verbose mode to display events sent to the Chrome Debugger",
174
176
  default: false,
175
177
  }), showDebuggerPayloads: command_1.flags.boolean({
176
- description: 'Verbose mode to display payloads sent by and to the Chrome Debugger',
178
+ description: "Verbose mode to display payloads sent by and to the Chrome Debugger",
177
179
  default: false,
178
180
  }) }, kuzzle_1.kuzzleFlags);
179
181
  // Force the usage of Websocket otherwise each request might end up executed on a different Kuzzle Node
180
182
  DebugProxy.sdkOptions = {
181
- protocol: 'ws'
183
+ protocol: "ws",
182
184
  };