kourou 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +80 -22
  2. package/lib/commands/api-key/check.d.ts +24 -0
  3. package/lib/commands/api-key/check.js +25 -0
  4. package/lib/commands/api-key/create.d.ts +26 -0
  5. package/lib/commands/api-key/create.js +30 -0
  6. package/lib/commands/api-key/delete.d.ts +24 -0
  7. package/lib/commands/api-key/delete.js +21 -0
  8. package/lib/commands/api-key/search.d.ts +24 -0
  9. package/lib/commands/api-key/search.js +39 -0
  10. package/lib/commands/app/debug-proxy.d.ts +24 -0
  11. package/lib/commands/app/debug-proxy.js +176 -0
  12. package/lib/commands/app/scaffold.d.ts +17 -0
  13. package/lib/commands/app/scaffold.js +41 -0
  14. package/lib/commands/app/start-services.d.ts +11 -0
  15. package/lib/commands/app/start-services.js +110 -0
  16. package/lib/commands/collection/create.d.ts +27 -0
  17. package/lib/commands/collection/create.js +25 -0
  18. package/lib/commands/collection/export.d.ts +31 -0
  19. package/lib/commands/collection/export.js +75 -0
  20. package/lib/commands/collection/import.d.ts +27 -0
  21. package/lib/commands/collection/import.js +40 -0
  22. package/lib/commands/config/diff.d.ts +17 -0
  23. package/lib/commands/config/diff.js +80 -0
  24. package/lib/commands/document/search.d.ts +33 -0
  25. package/lib/commands/document/search.js +60 -0
  26. package/lib/commands/es/indices/cat.d.ts +12 -0
  27. package/lib/commands/es/indices/cat.js +37 -0
  28. package/lib/commands/es/indices/get.d.ts +16 -0
  29. package/lib/commands/es/indices/get.js +31 -0
  30. package/lib/commands/es/indices/insert.d.ts +18 -0
  31. package/lib/commands/es/indices/insert.js +38 -0
  32. package/lib/commands/es/migrate.d.ts +23 -0
  33. package/lib/commands/es/migrate.js +137 -0
  34. package/lib/commands/es/snapshot/create-repository.d.ts +17 -0
  35. package/lib/commands/es/snapshot/create-repository.js +42 -0
  36. package/lib/commands/es/snapshot/create.d.ts +16 -0
  37. package/lib/commands/es/snapshot/create.js +32 -0
  38. package/lib/commands/es/snapshot/list.d.ts +16 -0
  39. package/lib/commands/es/snapshot/list.js +44 -0
  40. package/lib/commands/file/decrypt.d.ts +18 -0
  41. package/lib/commands/file/decrypt.js +64 -0
  42. package/lib/commands/file/encrypt.d.ts +18 -0
  43. package/lib/commands/file/encrypt.js +64 -0
  44. package/lib/commands/file/test.d.ts +16 -0
  45. package/lib/commands/file/test.js +52 -0
  46. package/lib/commands/import.d.ts +27 -0
  47. package/lib/commands/import.js +133 -0
  48. package/lib/commands/index/export.d.ts +28 -0
  49. package/lib/commands/index/export.js +59 -0
  50. package/lib/commands/index/import.d.ts +27 -0
  51. package/lib/commands/index/import.js +55 -0
  52. package/lib/commands/instance/kill.d.ts +13 -0
  53. package/lib/commands/instance/kill.js +101 -0
  54. package/lib/commands/instance/list.d.ts +7 -0
  55. package/lib/commands/instance/list.js +73 -0
  56. package/lib/commands/instance/logs.d.ts +13 -0
  57. package/lib/commands/instance/logs.js +69 -0
  58. package/lib/commands/instance/spawn.d.ts +16 -0
  59. package/lib/commands/instance/spawn.js +233 -0
  60. package/lib/commands/paas/deploy.d.ts +18 -0
  61. package/lib/commands/paas/deploy.js +66 -0
  62. package/lib/commands/paas/init.d.ts +14 -0
  63. package/lib/commands/paas/init.js +31 -0
  64. package/lib/commands/paas/login.d.ts +15 -0
  65. package/lib/commands/paas/login.js +64 -0
  66. package/lib/commands/paas/logs.d.ts +17 -0
  67. package/lib/commands/paas/logs.js +54 -0
  68. package/lib/commands/profile/export.d.ts +19 -0
  69. package/lib/commands/profile/export.js +46 -0
  70. package/lib/commands/profile/import.d.ts +22 -0
  71. package/lib/commands/profile/import.js +25 -0
  72. package/lib/commands/realtime/subscribe.d.ts +34 -0
  73. package/lib/commands/realtime/subscribe.js +68 -0
  74. package/lib/commands/redis/list-keys.d.ts +27 -0
  75. package/lib/commands/redis/list-keys.js +61 -0
  76. package/lib/commands/role/export.d.ts +19 -0
  77. package/lib/commands/role/export.js +45 -0
  78. package/lib/commands/role/import.d.ts +23 -0
  79. package/lib/commands/role/import.js +28 -0
  80. package/lib/commands/sdk/execute.d.ts +31 -0
  81. package/lib/commands/sdk/execute.js +122 -0
  82. package/lib/commands/sdk/query.d.ts +32 -0
  83. package/lib/commands/sdk/query.js +123 -0
  84. package/lib/commands/user/export-mappings.d.ts +18 -0
  85. package/lib/commands/user/export-mappings.js +31 -0
  86. package/lib/commands/user/export.d.ts +25 -0
  87. package/lib/commands/user/export.js +111 -0
  88. package/lib/commands/user/import-mappings.d.ts +22 -0
  89. package/lib/commands/user/import-mappings.js +23 -0
  90. package/lib/commands/user/import.d.ts +22 -0
  91. package/lib/commands/user/import.js +25 -0
  92. package/lib/commands/vault/add.d.ts +16 -0
  93. package/lib/commands/vault/add.js +59 -0
  94. package/lib/commands/vault/decrypt.d.ts +18 -0
  95. package/lib/commands/vault/decrypt.js +71 -0
  96. package/lib/commands/vault/encrypt.d.ts +18 -0
  97. package/lib/commands/vault/encrypt.js +83 -0
  98. package/lib/commands/vault/show.d.ts +20 -0
  99. package/lib/commands/vault/show.js +71 -0
  100. package/lib/commands/vault/test.d.ts +16 -0
  101. package/lib/commands/vault/test.js +45 -0
  102. package/lib/common.d.ts +53 -0
  103. package/lib/common.js +198 -0
  104. package/lib/hooks/command_not_found/api-action.d.ts +28 -0
  105. package/lib/hooks/command_not_found/api-action.js +97 -0
  106. package/lib/index.d.ts +1 -0
  107. package/lib/index.js +5 -0
  108. package/lib/support/PaasKommand.d.ts +22 -0
  109. package/lib/support/PaasKommand.js +58 -0
  110. package/lib/support/dump-collection.d.ts +2 -0
  111. package/lib/support/dump-collection.js +244 -0
  112. package/lib/support/editor.d.ts +12 -0
  113. package/lib/support/editor.js +47 -0
  114. package/lib/support/execute.d.ts +23 -0
  115. package/lib/support/execute.js +49 -0
  116. package/lib/support/kuzzle.d.ts +50 -0
  117. package/lib/support/kuzzle.js +172 -0
  118. package/lib/support/restore-collection.d.ts +29 -0
  119. package/lib/support/restore-collection.js +147 -0
  120. package/lib/support/restore-securities.d.ts +3 -0
  121. package/lib/support/restore-securities.js +53 -0
  122. package/package.json +7 -2
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.21.0 linux-x64 node-v16.13.2
29
+ kourou/0.23.0 linux-x64 node-v14.18.2
30
30
  $ kourou --help [COMMAND]
31
31
  USAGE
32
32
  $ kourou COMMAND
@@ -129,6 +129,7 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
129
129
  * [`kourou api-key:create USER`](#kourou-api-keycreate-user)
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
+ * [`kourou app:debug-proxy`](#kourou-appdebug-proxy)
132
133
  * [`kourou app:scaffold DESTINATION`](#kourou-appscaffold-destination)
133
134
  * [`kourou app:start-services`](#kourou-appstart-services)
134
135
  * [`kourou autocomplete [SHELL]`](#kourou-autocomplete-shell)
@@ -155,9 +156,10 @@ All other arguments and options will be passed as-is to the `sdk:query` method.
155
156
  * [`kourou instance:list`](#kourou-instancelist)
156
157
  * [`kourou instance:logs`](#kourou-instancelogs)
157
158
  * [`kourou instance:spawn`](#kourou-instancespawn)
158
- * [`kourou paas:init USERNAME NAMESPACE`](#kourou-paasinit-username-namespace)
159
+ * [`kourou paas:deploy ENVIRONMENT IMAGE`](#kourou-paasdeploy-environment-image)
160
+ * [`kourou paas:init PROJECT`](#kourou-paasinit-project)
159
161
  * [`kourou paas:login`](#kourou-paaslogin)
160
- * [`kourou paas:publish PROJECT IMAGE`](#kourou-paaspublish-project-image)
162
+ * [`kourou paas:logs ENVIRONMENT APPLICATION`](#kourou-paaslogs-environment-application)
161
163
  * [`kourou profile:export`](#kourou-profileexport)
162
164
  * [`kourou profile:import PATH`](#kourou-profileimport-path)
163
165
  * [`kourou realtime:subscribe INDEX COLLECTION [FILTERS]`](#kourou-realtimesubscribe-index-collection-filters)
@@ -287,6 +289,41 @@ OPTIONS
287
289
 
288
290
  _See code: [src/commands/api-key/search.ts](src/commands/api-key/search.ts)_
289
291
 
292
+ ## `kourou app:debug-proxy`
293
+
294
+ Create a Proxy Server that allows Chrome to debug Kuzzle remotely using the DebugController
295
+
296
+ ```
297
+ USAGE
298
+ $ kourou app:debug-proxy
299
+
300
+ OPTIONS
301
+ --api-key=api-key Kuzzle user api-key
302
+ --as=as Impersonate a user
303
+ --forwardPort=forwardPort [default: 9222] Port of the forwarding server
304
+ --help show CLI help
305
+ --host=host [default: localhost] Kuzzle server host
306
+
307
+ --nonoAutoEnableDebugger True if Kourou should not enable and disable the Debugger automatically before and after
308
+ usage
309
+
310
+ --password=password Kuzzle user password
311
+
312
+ --port=port [default: 7512] Kuzzle server port
313
+
314
+ --protocol=protocol [default: ws] Kuzzle protocol (http or ws)
315
+
316
+ --showDebuggerEvents Verbose mode to display events sent to the Chrome Debugger
317
+
318
+ --showDebuggerPayloads Verbose mode to display payloads sent by and to the Chrome Debugger
319
+
320
+ --ssl Use SSL to connect to Kuzzle
321
+
322
+ --username=username [default: anonymous] Kuzzle username (local strategy)
323
+ ```
324
+
325
+ _See code: [src/commands/app/debug-proxy.ts](src/commands/app/debug-proxy.ts)_
326
+
290
327
  ## `kourou app:scaffold DESTINATION`
291
328
 
292
329
  Scaffolds a new Kuzzle application
@@ -341,7 +378,7 @@ EXAMPLES
341
378
  $ kourou autocomplete --refresh-cache
342
379
  ```
343
380
 
344
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.2.0/src/commands/autocomplete/index.ts)_
381
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.3.0/src/commands/autocomplete/index.ts)_
345
382
 
346
383
  ## `kourou collection:create INDEX COLLECTION [BODY]`
347
384
 
@@ -602,9 +639,12 @@ USAGE
602
639
  OPTIONS
603
640
  --batch-size=batch-size [default: 1000] How many documents to move in batch per operation
604
641
  --dest=dest (required) Destination Elasticsearch server URL
642
+ --dry-run Print witch collections will be migrated
605
643
  --help show CLI help
606
644
  --no-interactive Skip confirmation interactive prompts (perfect for scripting)
645
+ --pattern=pattern Pattern to match indices to migrate
607
646
  --reset Reset destination Elasticsearch server
647
+ --scroll=scroll [default: 30s] Scroll duration for Elasticsearch scrolling
608
648
  --src=src (required) Source Elasticsearch server URL
609
649
 
610
650
  EXAMPLES
@@ -915,17 +955,36 @@ OPTIONS
915
955
 
916
956
  _See code: [src/commands/instance/spawn.ts](src/commands/instance/spawn.ts)_
917
957
 
918
- ## `kourou paas:init USERNAME NAMESPACE`
958
+ ## `kourou paas:deploy ENVIRONMENT IMAGE`
919
959
 
920
- Initialize a PaaS namespace in current directory
960
+ Deploy a new version of the application in the PaaS
961
+
962
+ ```
963
+ USAGE
964
+ $ kourou paas:deploy ENVIRONMENT IMAGE
965
+
966
+ ARGUMENTS
967
+ ENVIRONMENT Project environment name
968
+ IMAGE Image name and hash as myimage:mytag
969
+
970
+ OPTIONS
971
+ --help show CLI help
972
+ --project=project Current PaaS project
973
+ --token=token Authentication token
974
+ ```
975
+
976
+ _See code: [src/commands/paas/deploy.ts](src/commands/paas/deploy.ts)_
977
+
978
+ ## `kourou paas:init PROJECT`
979
+
980
+ Initialize a PaaS project in current directory
921
981
 
922
982
  ```
923
983
  USAGE
924
- $ kourou paas:init USERNAME NAMESPACE
984
+ $ kourou paas:init PROJECT
925
985
 
926
986
  ARGUMENTS
927
- USERNAME Username
928
- NAMESPACE Namespace
987
+ PROJECT Kuzzle PaaS project name
929
988
 
930
989
  OPTIONS
931
990
  --help show CLI help
@@ -935,39 +994,38 @@ _See code: [src/commands/paas/init.ts](src/commands/paas/init.ts)_
935
994
 
936
995
  ## `kourou paas:login`
937
996
 
938
- Login for a PaaS namespace
997
+ Login for a PaaS project
939
998
 
940
999
  ```
941
1000
  USAGE
942
1001
  $ kourou paas:login
943
1002
 
944
1003
  OPTIONS
945
- --help show CLI help
946
- --namespace=namespace Current PaaS namespace
947
- --username=username PaaS username
1004
+ --help show CLI help
1005
+ --project=project Current PaaS project
1006
+ --username=username PaaS username
948
1007
  ```
949
1008
 
950
1009
  _See code: [src/commands/paas/login.ts](src/commands/paas/login.ts)_
951
1010
 
952
- ## `kourou paas:publish PROJECT IMAGE`
1011
+ ## `kourou paas:logs ENVIRONMENT APPLICATION`
953
1012
 
954
- Deploy a new version of the application in the PaaS
1013
+ Show logs of the targeted application
955
1014
 
956
1015
  ```
957
1016
  USAGE
958
- $ kourou paas:publish PROJECT IMAGE
1017
+ $ kourou paas:logs ENVIRONMENT APPLICATION
959
1018
 
960
1019
  ARGUMENTS
961
- PROJECT Project name
962
- IMAGE Image name and hash
1020
+ ENVIRONMENT Kuzzle PaaS environment
1021
+ APPLICATION Kuzzle PaaS application
963
1022
 
964
1023
  OPTIONS
965
- --help show CLI help
966
- --namespace=namespace Current PaaS namespace
967
- --token=token Authentication token
1024
+ --help show CLI help
1025
+ --project=project Current PaaS project
968
1026
  ```
969
1027
 
970
- _See code: [src/commands/paas/publish.ts](src/commands/paas/publish.ts)_
1028
+ _See code: [src/commands/paas/logs.ts](src/commands/paas/logs.ts)_
971
1029
 
972
1030
  ## `kourou profile:export`
973
1031
 
@@ -0,0 +1,24 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ declare class ApiKeyCheck extends Kommand {
4
+ static description: string;
5
+ static flags: {
6
+ host: flags.IOptionFlag<string>;
7
+ port: flags.IOptionFlag<string>;
8
+ ssl: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ username: flags.IOptionFlag<string>;
10
+ password: flags.IOptionFlag<string | undefined>;
11
+ protocol: flags.IOptionFlag<string>;
12
+ as: flags.IOptionFlag<string | undefined>;
13
+ 'api-key': flags.IOptionFlag<string | undefined>;
14
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
+ };
16
+ static args: {
17
+ name: string;
18
+ description: string;
19
+ required: boolean;
20
+ }[];
21
+ static examples: string[];
22
+ runSafe(): Promise<void>;
23
+ }
24
+ export default ApiKeyCheck;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const common_1 = require("../../common");
5
+ const kuzzle_1 = require("../../support/kuzzle");
6
+ class ApiKeyCheck extends common_1.Kommand {
7
+ async runSafe() {
8
+ const { valid } = await this.sdk.auth.checkToken(this.args.token);
9
+ if (valid) {
10
+ this.logOk('API key is still valid');
11
+ }
12
+ else {
13
+ this.logKo('API key is not valid');
14
+ }
15
+ }
16
+ }
17
+ ApiKeyCheck.description = 'Checks an API key validity';
18
+ ApiKeyCheck.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags);
19
+ ApiKeyCheck.args = [
20
+ { name: 'token', description: 'API key token', required: true },
21
+ ];
22
+ ApiKeyCheck.examples = [
23
+ 'kourou api-key:check eyJhbG...QxfQrc'
24
+ ];
25
+ exports.default = ApiKeyCheck;
@@ -0,0 +1,26 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ declare class ApiKeyCreate extends Kommand {
4
+ static description: string;
5
+ static flags: {
6
+ host: flags.IOptionFlag<string>;
7
+ port: flags.IOptionFlag<string>;
8
+ ssl: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ username: flags.IOptionFlag<string>;
10
+ password: flags.IOptionFlag<string | undefined>;
11
+ protocol: flags.IOptionFlag<string>;
12
+ as: flags.IOptionFlag<string | undefined>;
13
+ 'api-key': flags.IOptionFlag<string | undefined>;
14
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
+ description: flags.IOptionFlag<string>;
16
+ id: flags.IOptionFlag<string | undefined>;
17
+ expire: flags.IOptionFlag<string>;
18
+ };
19
+ static args: {
20
+ name: string;
21
+ description: string;
22
+ required: boolean;
23
+ }[];
24
+ runSafe(): Promise<void>;
25
+ }
26
+ export default ApiKeyCreate;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const common_1 = require("../../common");
5
+ const kuzzle_1 = require("../../support/kuzzle");
6
+ class ApiKeyCreate extends common_1.Kommand {
7
+ async runSafe() {
8
+ const apiKey = await this.sdk.security.createApiKey(this.args.user, this.flags.description, {
9
+ _id: this.flags.id,
10
+ expiresIn: this.flags.expire
11
+ });
12
+ this.logOk(`Successfully created API Key "${apiKey._id}" for user "${this.args.user}"`);
13
+ this.log(apiKey._source.token);
14
+ }
15
+ }
16
+ ApiKeyCreate.description = 'Creates a new API Key for a user';
17
+ ApiKeyCreate.flags = Object.assign({ help: command_1.flags.help(), description: command_1.flags.string({
18
+ char: 'd',
19
+ description: 'API Key description',
20
+ required: true,
21
+ }), id: command_1.flags.string({
22
+ description: 'API Key unique ID',
23
+ }), expire: command_1.flags.string({
24
+ description: 'API Key validity',
25
+ default: '-1',
26
+ }) }, kuzzle_1.kuzzleFlags);
27
+ ApiKeyCreate.args = [
28
+ { name: 'user', description: 'User kuid', required: true },
29
+ ];
30
+ exports.default = ApiKeyCreate;
@@ -0,0 +1,24 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ declare class ApiKeyDelete extends Kommand {
4
+ static description: string;
5
+ static flags: {
6
+ host: flags.IOptionFlag<string>;
7
+ port: flags.IOptionFlag<string>;
8
+ ssl: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ username: flags.IOptionFlag<string>;
10
+ password: flags.IOptionFlag<string | undefined>;
11
+ protocol: flags.IOptionFlag<string>;
12
+ as: flags.IOptionFlag<string | undefined>;
13
+ 'api-key': flags.IOptionFlag<string | undefined>;
14
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
+ };
16
+ static args: {
17
+ name: string;
18
+ description: string;
19
+ required: boolean;
20
+ }[];
21
+ static examples: string[];
22
+ runSafe(): Promise<void>;
23
+ }
24
+ export default ApiKeyDelete;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const common_1 = require("../../common");
5
+ const kuzzle_1 = require("../../support/kuzzle");
6
+ class ApiKeyDelete extends common_1.Kommand {
7
+ async runSafe() {
8
+ await this.sdk.security.deleteApiKey(this.args.user, this.args.id);
9
+ this.logOk(`Successfully deleted API Key "${this.args.id}" of user "${this.args.user}"`);
10
+ }
11
+ }
12
+ ApiKeyDelete.description = 'Deletes an API key.';
13
+ ApiKeyDelete.flags = Object.assign({ help: command_1.flags.help() }, kuzzle_1.kuzzleFlags);
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'
20
+ ];
21
+ exports.default = ApiKeyDelete;
@@ -0,0 +1,24 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ declare class ApiKeySearch extends Kommand {
4
+ static description: string;
5
+ static flags: {
6
+ host: flags.IOptionFlag<string>;
7
+ port: flags.IOptionFlag<string>;
8
+ ssl: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ username: flags.IOptionFlag<string>;
10
+ password: flags.IOptionFlag<string | undefined>;
11
+ protocol: flags.IOptionFlag<string>;
12
+ as: flags.IOptionFlag<string | undefined>;
13
+ 'api-key': flags.IOptionFlag<string | undefined>;
14
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
+ filter: flags.IOptionFlag<string | undefined>;
16
+ };
17
+ static args: {
18
+ name: string;
19
+ description: string;
20
+ required: boolean;
21
+ }[];
22
+ runSafe(): Promise<void>;
23
+ }
24
+ export default ApiKeySearch;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const common_1 = require("../../common");
5
+ const kuzzle_1 = require("../../support/kuzzle");
6
+ class ApiKeySearch extends common_1.Kommand {
7
+ async runSafe() {
8
+ let query = {};
9
+ if (this.flags.filter) {
10
+ query = {
11
+ match: {
12
+ description: this.flags.filter,
13
+ },
14
+ };
15
+ }
16
+ const result = await this.sdk.security.searchApiKeys(this.args.user, query, {
17
+ from: 0,
18
+ size: 100
19
+ });
20
+ this.logOk(`${result.total} API Keys found for user ${this.args.user}`);
21
+ if (result.total !== 0) {
22
+ this.log('');
23
+ for (const { _id, _source } of result.hits) {
24
+ this.log(` - Key "${_id}"`);
25
+ this.log(` Description: ${_source.description}`);
26
+ this.log(` Fingerprint: ${_source.fingerprint}`);
27
+ this.log(` Expires at: ${_source.expiresAt}`);
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ApiKeySearch.description = 'Lists a user\'s API Keys.';
33
+ ApiKeySearch.flags = Object.assign({ help: command_1.flags.help(), filter: command_1.flags.string({
34
+ description: 'Filter to match the API Key descriptions',
35
+ }) }, kuzzle_1.kuzzleFlags);
36
+ ApiKeySearch.args = [
37
+ { name: 'user', description: 'User kuid', required: true },
38
+ ];
39
+ exports.default = ApiKeySearch;
@@ -0,0 +1,24 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ export default class DebugProxy extends Kommand {
4
+ static description: string;
5
+ static flags: {
6
+ host: flags.IOptionFlag<string>;
7
+ port: flags.IOptionFlag<string>;
8
+ ssl: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ username: flags.IOptionFlag<string>;
10
+ password: flags.IOptionFlag<string | undefined>;
11
+ protocol: flags.IOptionFlag<string>;
12
+ as: flags.IOptionFlag<string | undefined>;
13
+ 'api-key': flags.IOptionFlag<string | undefined>;
14
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
15
+ forwardPort: import("@oclif/parser/lib/flags").IOptionFlag<number>;
16
+ nonoAutoEnableDebugger: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
17
+ showDebuggerEvents: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
18
+ showDebuggerPayloads: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
19
+ };
20
+ static sdkOptions: {
21
+ protocol: string;
22
+ };
23
+ runSafe(): Promise<void>;
24
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const command_1 = require("@oclif/command");
5
+ const common_1 = require("../../common");
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"));
9
+ // Add the proper headers and send the body in the response
10
+ function sendResponse(response, bodyObject) {
11
+ response.setHeader('Content-Type', 'application/json; charset=UTF-8');
12
+ response.setHeader('Cache-Control', 'no-cache');
13
+ const body = JSON.stringify(bodyObject);
14
+ response.setHeader('Content-Length', Buffer.byteLength(body));
15
+ response.writeHead(200);
16
+ response.end(body);
17
+ }
18
+ class DebugProxy extends common_1.Kommand {
19
+ async runSafe() {
20
+ const nodeVersionResponse = await this.sdk.query({
21
+ controller: 'debug',
22
+ action: 'nodeVersion'
23
+ });
24
+ this.logInfo(`Connected to Kuzzle node: ${nodeVersionResponse.node}`);
25
+ /**
26
+ * To allow the Chrome Debugger to see the proxy server we must implement the following routes:
27
+ * - /json/version
28
+ * - /json
29
+ */
30
+ const server = http_1.default.createServer((request, response) => {
31
+ if (request.url === '/json/version') {
32
+ sendResponse(response, {
33
+ Browser: `node.js/${nodeVersionResponse.result}`,
34
+ "Protocol-Version": "1.1"
35
+ });
36
+ return;
37
+ }
38
+ else if (request.url === '/json') {
39
+ // Here we send a bunch of information about the Remote Target to the Chrome Debugger
40
+ // Those are the informations that the Chrome Debugger uses to know how to connect to Remote Target
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',
44
+ devtoolsFrontendUrl: `devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=${request.headers.host}/kuzzle-debugger`,
45
+ 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',
48
+ title: `Kuzzle Debugger - ${this.flags.host}:${this.flags.port}`,
49
+ type: 'node',
50
+ webSocketDebuggerUrl: `ws://${request.headers.host}/kuzzle-debugger`
51
+ }]);
52
+ return;
53
+ }
54
+ response.writeHead(404);
55
+ });
56
+ const closeServer = async () => {
57
+ this.logInfo('Connection closed.');
58
+ if (!this.flags.noAutoEnableDebugger) {
59
+ await this.sdk.query({
60
+ controller: 'debug',
61
+ action: 'disable'
62
+ });
63
+ }
64
+ this.sdk.disconnect();
65
+ server.close();
66
+ };
67
+ const wss = new ws_1.default.Server({
68
+ server
69
+ });
70
+ if (!this.flags.noAutoEnableDebugger) {
71
+ await this.sdk.query({
72
+ controller: 'debug',
73
+ action: 'enable'
74
+ });
75
+ }
76
+ // Listen to all events emitted by the Debug Controller
77
+ await this.sdk.query({
78
+ controller: 'debug',
79
+ action: 'addListener',
80
+ body: {
81
+ event: '*'
82
+ }
83
+ });
84
+ wss.on('connection', ws => {
85
+ this.logInfo('Connection established.');
86
+ /**
87
+ * Listen to the room were events from the DebugController are sent
88
+ * and only forward events from the Chrome Devtools Protocol
89
+ */
90
+ this.sdk.sdk.protocol.on('kuzzle-debugger-event', (payload) => {
91
+ if (!payload.event || payload.event.startsWith('Kuzzle')) {
92
+ return;
93
+ }
94
+ if (this.flags.showDebuggerEvents) {
95
+ this.logInfo(JSON.stringify(payload.result, null, 2));
96
+ }
97
+ ws.send(JSON.stringify(payload.result));
98
+ });
99
+ // When receiving message from Chrome Devtools Protocol, we forward it to the DebugController
100
+ ws.on('message', async (message) => {
101
+ try {
102
+ const json = JSON.parse(message.toString());
103
+ if (json.id === undefined || json.method === undefined) {
104
+ return;
105
+ }
106
+ if (this.flags.showDebuggerPayloads) {
107
+ this.logInfo(JSON.stringify({
108
+ method: json.method,
109
+ params: json.params,
110
+ }, null, 2));
111
+ }
112
+ const response = await this.sdk.query({
113
+ controller: 'debug',
114
+ action: 'post',
115
+ body: {
116
+ method: json.method,
117
+ params: json.params,
118
+ }
119
+ });
120
+ if (this.flags.showDebuggerPayloads) {
121
+ this.logInfo(JSON.stringify({
122
+ id: json.id,
123
+ result: response.result
124
+ }, null, 2));
125
+ }
126
+ // Send back the response using the same ID received
127
+ ws.send(JSON.stringify({
128
+ id: json.id,
129
+ result: response.result
130
+ }));
131
+ }
132
+ catch (e) {
133
+ this.logKo(`${e}`);
134
+ }
135
+ });
136
+ ws.on('close', closeServer);
137
+ });
138
+ server.on('error', async (err) => {
139
+ this.logKo(err.message);
140
+ this.logKo(err.stack);
141
+ await closeServer();
142
+ });
143
+ server.listen(this.flags.forwardPort, () => {
144
+ this.logOk(`Listening on port ${this.flags.forwardPort}, forwarding to Kuzzle at ${this.flags.host}:${this.flags.port}`);
145
+ this.logInfo(`Showing to Chrome Debugger as "Kuzzle Debugger - ${this.flags.host}:${this.flags.port}"`);
146
+ this.logInfo('Waiting for Chrome Debugger to connect...');
147
+ });
148
+ let resolve;
149
+ const promise = new Promise(res => {
150
+ resolve = res;
151
+ });
152
+ server.on('close', () => {
153
+ resolve();
154
+ });
155
+ await promise;
156
+ }
157
+ }
158
+ exports.default = DebugProxy;
159
+ DebugProxy.description = 'Create a Proxy Server that allows Chrome to debug Kuzzle remotely using the DebugController';
160
+ 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
+ }), nonoAutoEnableDebugger: command_1.flags.boolean({
164
+ description: 'True if Kourou should not enable and disable the Debugger automatically before and after usage',
165
+ default: true
166
+ }), showDebuggerEvents: command_1.flags.boolean({
167
+ description: 'Verbose mode to display events sent to the Chrome Debugger',
168
+ default: false,
169
+ }), showDebuggerPayloads: command_1.flags.boolean({
170
+ description: 'Verbose mode to display payloads sent by and to the Chrome Debugger',
171
+ default: false,
172
+ }) }, kuzzle_1.kuzzleFlags);
173
+ // Force the usage of Websocket otherwise each request might end up executed on a different Kuzzle Node
174
+ DebugProxy.sdkOptions = {
175
+ protocol: 'ws'
176
+ };
@@ -0,0 +1,17 @@
1
+ import { flags } from '@oclif/command';
2
+ import { Kommand } from '../../common';
3
+ export default class AppScaffold extends Kommand {
4
+ static initSdk: boolean;
5
+ static description: string;
6
+ static flags: {
7
+ help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
+ flavor: flags.IOptionFlag<string>;
9
+ };
10
+ static args: {
11
+ name: string;
12
+ description: string;
13
+ required: boolean;
14
+ }[];
15
+ runSafe(): Promise<void>;
16
+ cloneTemplate(flavor: string, destination: string): Promise<void>;
17
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const command_1 = require("@oclif/command");
5
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
+ const listr_1 = tslib_1.__importDefault(require("listr"));
7
+ const common_1 = require("../../common");
8
+ const execute_1 = require("../../support/execute");
9
+ class AppScaffold extends common_1.Kommand {
10
+ async runSafe() {
11
+ const destination = this.args.destination;
12
+ const flavor = this.flags.flavor;
13
+ const tasks = new listr_1.default([
14
+ {
15
+ title: 'Creating and rendering application files',
16
+ task: async () => this.cloneTemplate(flavor, destination)
17
+ },
18
+ ]);
19
+ await tasks.run();
20
+ this.log('');
21
+ this.logOk(`Scaffolding complete! Use ${chalk_1.default.grey(`cd ${destination} && npm run docker npm install`)} install dependencies and then ${chalk_1.default.grey(`npm run docker:dev`)} to run your application!`);
22
+ }
23
+ async cloneTemplate(flavor, destination) {
24
+ await (0, execute_1.execute)('git', 'clone', '--depth=1', 'https://github.com/kuzzleio/project-templates', '--branch', flavor, '--single-branch');
25
+ await (0, execute_1.execute)('mv', `project-templates/${flavor}`, `${destination}/`);
26
+ await (0, execute_1.execute)('rm', '-rf', 'project-templates/');
27
+ }
28
+ }
29
+ exports.default = AppScaffold;
30
+ AppScaffold.initSdk = false;
31
+ AppScaffold.description = 'Scaffolds a new Kuzzle application';
32
+ AppScaffold.flags = {
33
+ help: command_1.flags.help(),
34
+ flavor: command_1.flags.string({
35
+ default: 'generic',
36
+ description: 'Template flavor ("generic", "iot-platform")'
37
+ })
38
+ };
39
+ AppScaffold.args = [
40
+ { name: 'destination', description: 'Directory to scaffold the app', required: true },
41
+ ];