@streamr/cli-tools 5.0.1 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +21 -6
- package/bin/common.ts +23 -22
- package/bin/streamr-storage-node-add-stream.ts +3 -1
- package/bin/streamr-storage-node-list-stream-parts.ts +5 -5
- package/bin/streamr-storage-node-list.ts +8 -3
- package/bin/streamr-storage-node-remove-stream.ts +3 -1
- package/bin/streamr-stream-create.ts +3 -3
- package/bin/streamr-stream-grant-permission.ts +4 -2
- package/bin/streamr-stream-publish.ts +3 -2
- package/bin/streamr-stream-resend.ts +7 -4
- package/bin/streamr-stream-revoke-permission.ts +4 -2
- package/bin/streamr-stream-show.ts +3 -2
- package/bin/streamr-stream-subscribe.ts +3 -2
- package/dist/bin/common.d.ts +2 -3
- package/dist/bin/common.js +26 -23
- package/dist/bin/common.js.map +1 -1
- package/dist/bin/streamr-misc-get-session-token.js +4 -4
- package/dist/bin/streamr-misc-get-session-token.js.map +1 -1
- package/dist/bin/streamr-mock-data-generate.js +3 -3
- package/dist/bin/streamr-mock-data-generate.js.map +1 -1
- package/dist/bin/streamr-storage-node-add-stream.js +6 -5
- package/dist/bin/streamr-storage-node-add-stream.js.map +1 -1
- package/dist/bin/streamr-storage-node-list-stream-parts.js +7 -7
- package/dist/bin/streamr-storage-node-list-stream-parts.js.map +1 -1
- package/dist/bin/streamr-storage-node-list.js +9 -7
- package/dist/bin/streamr-storage-node-list.js.map +1 -1
- package/dist/bin/streamr-storage-node-remove-stream.js +6 -5
- package/dist/bin/streamr-storage-node-remove-stream.js.map +1 -1
- package/dist/bin/streamr-stream-create.js +8 -8
- package/dist/bin/streamr-stream-create.js.map +1 -1
- package/dist/bin/streamr-stream-grant-permission.js +5 -4
- package/dist/bin/streamr-stream-grant-permission.js.map +1 -1
- package/dist/bin/streamr-stream-list.js +4 -4
- package/dist/bin/streamr-stream-list.js.map +1 -1
- package/dist/bin/streamr-stream-publish.js +6 -5
- package/dist/bin/streamr-stream-publish.js.map +1 -1
- package/dist/bin/streamr-stream-resend.js +15 -12
- package/dist/bin/streamr-stream-resend.js.map +1 -1
- package/dist/bin/streamr-stream-revoke-permission.js +6 -5
- package/dist/bin/streamr-stream-revoke-permission.js.map +1 -1
- package/dist/bin/streamr-stream-show.js +6 -5
- package/dist/bin/streamr-stream-show.js.map +1 -1
- package/dist/bin/streamr-stream-subscribe.js +7 -6
- package/dist/bin/streamr-stream-subscribe.js.map +1 -1
- package/dist/bin/streamr.js +0 -0
- package/dist/package.json +11 -9
- package/dist/src/create.d.ts +1 -1
- package/dist/src/create.js +3 -2
- package/dist/src/create.js.map +1 -1
- package/dist/src/publish.js +2 -3
- package/dist/src/publish.js.map +1 -1
- package/dist/src/resend.js +2 -17
- package/dist/src/resend.js.map +1 -1
- package/dist/src/show.js +1 -1
- package/dist/src/show.js.map +1 -1
- package/dist/src/subscribe.d.ts +1 -1
- package/dist/src/subscribe.js +3 -3
- package/dist/src/subscribe.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -8525
- package/package.json +11 -9
- package/src/create.ts +5 -2
- package/src/publish.ts +2 -3
- package/src/resend.ts +2 -20
- package/src/show.ts +1 -1
- package/src/subscribe.ts +3 -3
- package/dist/commands/common.js +0 -76
- package/dist/commands/streamor.js +0 -16
- package/dist/commands/streamr-mock-data-generate.js +0 -20
- package/dist/commands/streamr-mock-data.js +0 -14
- package/dist/commands/streamr-storage-node-add-stream.js +0 -24
- package/dist/commands/streamr-storage-node-list-stream-parts.js +0 -32
- package/dist/commands/streamr-storage-node-list.js +0 -44
- package/dist/commands/streamr-storage-node-remove-stream.js +0 -24
- package/dist/commands/streamr-storage-node.js +0 -17
- package/dist/commands/streamr-stream-create.js +0 -31
- package/dist/commands/streamr-stream-grant-permission.js +0 -62
- package/dist/commands/streamr-stream-list.js +0 -33
- package/dist/commands/streamr-stream-publish.js +0 -32
- package/dist/commands/streamr-stream-resend.js +0 -101
- package/dist/commands/streamr-stream-revoke-permission.js +0 -24
- package/dist/commands/streamr-stream-show.js +0 -23
- package/dist/commands/streamr-stream-subscribe.js +0 -25
- package/dist/commands/streamr-stream.js +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.0",
|
|
4
4
|
"description": "Command line tools for Streamr.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"streamr": "dist/bin/streamr.js"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git
|
|
16
|
+
"url": "git+https://github.com/streamr-dev/network-monorepo.git",
|
|
17
|
+
"directory": "packages/cli-tools"
|
|
17
18
|
},
|
|
18
19
|
"keywords": [
|
|
19
20
|
"streamr",
|
|
@@ -30,19 +31,20 @@
|
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"commander": "^7.2.0",
|
|
32
33
|
"easy-table": "^1.1.1",
|
|
34
|
+
"ethers": "^5.3.1",
|
|
33
35
|
"event-stream": "^4.0.1",
|
|
34
|
-
"streamr-client": "
|
|
36
|
+
"streamr-client": "6.0.0-alpha.17"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@streamr/dev-config": "^1.0.0",
|
|
38
40
|
"@types/easy-table": "0.0.32",
|
|
39
41
|
"@types/event-stream": "^3.3.34",
|
|
40
|
-
"@types/jest": "^
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
42
|
-
"@typescript-eslint/parser": "^4.
|
|
43
|
-
"eslint": "^7.
|
|
44
|
-
"eslint-config-streamr-ts": "^
|
|
42
|
+
"@types/jest": "^27.0.1",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
44
|
+
"@typescript-eslint/parser": "^4.31.2",
|
|
45
|
+
"eslint": "^7.32.0",
|
|
46
|
+
"eslint-config-streamr-ts": "^4.0.1",
|
|
45
47
|
"eslint-plugin-promise": "^5.1.0",
|
|
46
|
-
"typescript": "^4.
|
|
48
|
+
"typescript": "^4.3.4"
|
|
47
49
|
}
|
|
48
50
|
}
|
package/src/create.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { StreamProperties, StreamrClient, StreamrClientOptions} from 'streamr-client'
|
|
2
2
|
|
|
3
|
-
export const create = (
|
|
3
|
+
export const create = (
|
|
4
|
+
// id is required
|
|
5
|
+
body: Partial<StreamProperties> & Required<Pick<StreamProperties, "id">>,
|
|
6
|
+
streamrOptions: StreamrClientOptions
|
|
7
|
+
): void => {
|
|
4
8
|
const options = { ...streamrOptions }
|
|
5
9
|
|
|
6
10
|
const client = new StreamrClient(options)
|
|
7
11
|
client.createStream(body).then((stream) => {
|
|
8
|
-
// @ts-expect-error TODO: toObject() is internal in streamr-client-javascript
|
|
9
12
|
console.info(JSON.stringify(stream.toObject(), null, 2))
|
|
10
13
|
process.exit(0)
|
|
11
14
|
return true
|
package/src/publish.ts
CHANGED
|
@@ -35,8 +35,7 @@ export const publishStream = (
|
|
|
35
35
|
}
|
|
36
36
|
})
|
|
37
37
|
|
|
38
|
-
client
|
|
39
|
-
|
|
40
|
-
writable.once('finish', () => client.ensureDisconnected())
|
|
38
|
+
// destroy client when upstream pipe ends and data flushed
|
|
39
|
+
writable.once('finish', () => client.destroy())
|
|
41
40
|
return writable
|
|
42
41
|
}
|
package/src/resend.ts
CHANGED
|
@@ -8,7 +8,6 @@ export const resend = async (
|
|
|
8
8
|
const options = { ...streamrOptions }
|
|
9
9
|
const client = new StreamrClient(options)
|
|
10
10
|
|
|
11
|
-
let sub
|
|
12
11
|
try {
|
|
13
12
|
const subscribeOpts = {
|
|
14
13
|
stream: streamId,
|
|
@@ -19,29 +18,12 @@ export const resend = async (
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
if (options.subscribe) {
|
|
22
|
-
|
|
21
|
+
await client.subscribe(subscribeOpts, handler)
|
|
23
22
|
} else {
|
|
24
|
-
|
|
23
|
+
await client.resend(subscribeOpts, handler)
|
|
25
24
|
}
|
|
26
25
|
} catch (err) {
|
|
27
26
|
console.error(err.message ? err.message : err)
|
|
28
27
|
process.exit(1)
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
sub.on('error', (err: any) => {
|
|
32
|
-
console.error(err)
|
|
33
|
-
process.exit(1)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
sub.on('resent', () => {
|
|
37
|
-
if (!options.subscribe) {
|
|
38
|
-
process.exit(0)
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
sub.on('no_resend', () => {
|
|
43
|
-
if (!options.subscribe) {
|
|
44
|
-
process.exit(0)
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
29
|
}
|
package/src/show.ts
CHANGED
|
@@ -8,9 +8,9 @@ export const show = (
|
|
|
8
8
|
const options = { ...streamrOptions }
|
|
9
9
|
const client = new StreamrClient(options)
|
|
10
10
|
client.getStream(streamId).then(async (stream) => {
|
|
11
|
-
// @ts-expect-error accessing internal method, should be made public perhaps?
|
|
12
11
|
const obj = stream.toObject()
|
|
13
12
|
if (includePermissions) {
|
|
13
|
+
// @ts-expect-error permissions not on {}
|
|
14
14
|
obj.permissions = await stream.getPermissions()
|
|
15
15
|
}
|
|
16
16
|
console.info(JSON.stringify(obj, null, 2))
|
package/src/subscribe.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StreamrClient, StreamrClientOptions } from 'streamr-client'
|
|
2
2
|
|
|
3
|
-
export const subscribe = (
|
|
3
|
+
export const subscribe = (streamId: string, streamPartition: number, streamrOptions: StreamrClientOptions): void => {
|
|
4
4
|
const options = { ...streamrOptions }
|
|
5
5
|
new StreamrClient(options).subscribe({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
streamId,
|
|
7
|
+
streamPartition,
|
|
8
8
|
}, (message) => console.info(JSON.stringify(message)))
|
|
9
9
|
}
|
package/dist/commands/common.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFnParseInt = exports.formStreamrOptionsWithEnv = exports.exitWithHelpIfArgsNotBetween = exports.authOptions = exports.envOptions = void 0;
|
|
4
|
-
function envOptions(program) {
|
|
5
|
-
return program
|
|
6
|
-
.option('--dev', 'use pre-defined development environment')
|
|
7
|
-
.option('--stg', 'use pre-defined staging environment')
|
|
8
|
-
.option('--ws-url <url>', 'alternative websocket url to use')
|
|
9
|
-
.option('--http-url <url>', 'alternative http url to use');
|
|
10
|
-
}
|
|
11
|
-
exports.envOptions = envOptions;
|
|
12
|
-
function authOptions(program) {
|
|
13
|
-
return program
|
|
14
|
-
.option('--private-key <key>', 'use an Ethereum private key to authenticate')
|
|
15
|
-
.option('--api-key <key>', 'use an API key to authenticate (deprecated)');
|
|
16
|
-
}
|
|
17
|
-
exports.authOptions = authOptions;
|
|
18
|
-
function exitWithHelpIfArgsNotBetween(program, min, max) {
|
|
19
|
-
if (program.args.length < min || program.args.length > max) {
|
|
20
|
-
program.help();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.exitWithHelpIfArgsNotBetween = exitWithHelpIfArgsNotBetween;
|
|
24
|
-
function formStreamrOptionsWithEnv({ dev, stg, wsUrl, httpUrl, privateKey, apiKey }) {
|
|
25
|
-
const options = {};
|
|
26
|
-
if (dev && stg) {
|
|
27
|
-
console.error('flags --dev and --stg cannot be enabled at the same time');
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
if (dev) {
|
|
31
|
-
options.url = 'ws://localhost/api/v1/ws';
|
|
32
|
-
options.restUrl = 'http://localhost/api/v1';
|
|
33
|
-
options.storageNode = {
|
|
34
|
-
// "broker-node-storage-1" on Docker environment
|
|
35
|
-
address: '0xde1112f631486CfC759A50196853011528bC5FA0',
|
|
36
|
-
url: 'http://10.200.10.1:8891'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
else if (stg) {
|
|
40
|
-
options.url = 'wss://staging.streamr.com/api/v1/ws';
|
|
41
|
-
options.restUrl = 'https://staging.streamr.com/api/v1/';
|
|
42
|
-
}
|
|
43
|
-
if (wsUrl) {
|
|
44
|
-
options.url = wsUrl;
|
|
45
|
-
}
|
|
46
|
-
if (httpUrl) {
|
|
47
|
-
options.restUrl = httpUrl;
|
|
48
|
-
}
|
|
49
|
-
if (privateKey && apiKey) {
|
|
50
|
-
console.error('flags --privateKey and --apiKey cannot be used at the same time');
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
if (privateKey) {
|
|
54
|
-
options.auth = {
|
|
55
|
-
privateKey
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
else if (apiKey) {
|
|
59
|
-
options.auth = {
|
|
60
|
-
apiKey
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return options;
|
|
64
|
-
}
|
|
65
|
-
exports.formStreamrOptionsWithEnv = formStreamrOptionsWithEnv;
|
|
66
|
-
function createFnParseInt(name) {
|
|
67
|
-
return (str) => {
|
|
68
|
-
const n = parseInt(str, 10);
|
|
69
|
-
if (isNaN(n)) {
|
|
70
|
-
console.error(`${name} must be an integer (was "${str}")`);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
return n;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
exports.createFnParseInt = createFnParseInt;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
-
commander_1.program
|
|
10
|
-
.version(package_json_1.default.version)
|
|
11
|
-
.usage('<command> <subcommand> [<args>]')
|
|
12
|
-
.description('command line tools for interacting with Streamr https://streamr.network')
|
|
13
|
-
.command('stream', 'stream subcommands')
|
|
14
|
-
.command('storage-node', 'storage node subcommands')
|
|
15
|
-
.command('mock-data', 'mock data subcommands')
|
|
16
|
-
.parse(process.argv);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const generate_1 = require("../src/generate");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
program
|
|
13
|
-
.description('generate and print semi-random JSON data to stdout')
|
|
14
|
-
.option('-r, --rate <n>', 'rate in milliseconds', common_1.createFnParseInt('--rate'), 500)
|
|
15
|
-
.version(package_json_1.default.version)
|
|
16
|
-
.action((options) => {
|
|
17
|
-
generate_1.generate(options.rate);
|
|
18
|
-
})
|
|
19
|
-
.parse(process.argv);
|
|
20
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 0, 0);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
-
commander_1.program
|
|
10
|
-
.version(package_json_1.default.version)
|
|
11
|
-
.usage('<command> [<args>]')
|
|
12
|
-
.description('mock-data subcommands')
|
|
13
|
-
.command('generate', 'generate JSON data')
|
|
14
|
-
.parse(process.argv);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const streamr_client_1 = require("streamr-client");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
program
|
|
13
|
-
.arguments('<storageNodeAddress> <streamId>')
|
|
14
|
-
.description('add stream to a storage node');
|
|
15
|
-
common_1.authOptions(program);
|
|
16
|
-
common_1.envOptions(program)
|
|
17
|
-
.version(package_json_1.default.version)
|
|
18
|
-
.action((storageNodeAddress, streamId, options) => {
|
|
19
|
-
const client = new streamr_client_1.StreamrClient(common_1.formStreamrOptionsWithEnv(options));
|
|
20
|
-
client.getStream(streamId)
|
|
21
|
-
.then((stream) => stream.addToStorageNode(storageNodeAddress));
|
|
22
|
-
})
|
|
23
|
-
.parse(process.argv);
|
|
24
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 2, 2);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const streamr_client_1 = require("streamr-client");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const easy_table_1 = __importDefault(require("easy-table"));
|
|
12
|
-
const program = new commander_1.Command();
|
|
13
|
-
program
|
|
14
|
-
.arguments('<storageNodeAddress>')
|
|
15
|
-
.description('list streams parts in a storage node');
|
|
16
|
-
common_1.authOptions(program);
|
|
17
|
-
common_1.envOptions(program)
|
|
18
|
-
.version(package_json_1.default.version)
|
|
19
|
-
.action((storageNodeAddress, options) => {
|
|
20
|
-
const client = new streamr_client_1.StreamrClient(common_1.formStreamrOptionsWithEnv(options));
|
|
21
|
-
client.getStreamPartsByStorageNode(storageNodeAddress)
|
|
22
|
-
.then((streamParts) => {
|
|
23
|
-
if (streamParts.length > 0) {
|
|
24
|
-
console.info(easy_table_1.default.print(streamParts.map((streamPart) => ({
|
|
25
|
-
streamId: streamPart.getStreamId(),
|
|
26
|
-
streamPartition: streamPart.getStreamPartition()
|
|
27
|
-
}))));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
})
|
|
31
|
-
.parse(process.argv);
|
|
32
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 1, 1);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const streamr_client_1 = require("streamr-client");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const easy_table_1 = __importDefault(require("easy-table"));
|
|
12
|
-
const getStorageNodes = async (streamId, client) => {
|
|
13
|
-
if (streamId !== undefined) {
|
|
14
|
-
return client.getStream(streamId)
|
|
15
|
-
.then(stream => stream.getStorageNodes())
|
|
16
|
-
.then(storegeNodes => {
|
|
17
|
-
return storegeNodes.map(storageNode => storageNode.getAddress());
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// all storage nodes (currently there is only one)
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
return [client.options.storageNode.address];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const program = new commander_1.Command();
|
|
27
|
-
program
|
|
28
|
-
.description('fetch a list of storage nodes')
|
|
29
|
-
.option('-s, --stream <streamId>', 'only storage nodes which store the given stream (needs authentication)');
|
|
30
|
-
common_1.authOptions(program);
|
|
31
|
-
common_1.envOptions(program)
|
|
32
|
-
.version(package_json_1.default.version)
|
|
33
|
-
.action((options) => {
|
|
34
|
-
const client = new streamr_client_1.StreamrClient(common_1.formStreamrOptionsWithEnv(options));
|
|
35
|
-
getStorageNodes(options.stream, client).then((addresses) => {
|
|
36
|
-
if (addresses.length > 0) {
|
|
37
|
-
console.info(easy_table_1.default.print(addresses.map((address) => ({
|
|
38
|
-
address
|
|
39
|
-
}))));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
})
|
|
43
|
-
.parse(process.argv);
|
|
44
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 0, 0);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const streamr_client_1 = require("streamr-client");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
program
|
|
13
|
-
.arguments('<storageNodeAddress> <streamId>')
|
|
14
|
-
.description('remove stream from a storage node');
|
|
15
|
-
common_1.authOptions(program);
|
|
16
|
-
common_1.envOptions(program)
|
|
17
|
-
.version(package_json_1.default.version)
|
|
18
|
-
.action((storageNodeAddress, streamId, options) => {
|
|
19
|
-
const client = new streamr_client_1.StreamrClient(common_1.formStreamrOptionsWithEnv(options));
|
|
20
|
-
client.getStream(streamId)
|
|
21
|
-
.then((stream) => stream.removeFromStorageNode(storageNodeAddress));
|
|
22
|
-
})
|
|
23
|
-
.parse(process.argv);
|
|
24
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 2, 2);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
-
commander_1.program
|
|
10
|
-
.version(package_json_1.default.version)
|
|
11
|
-
.usage('<command> [<args>]')
|
|
12
|
-
.description('storage node subcommands')
|
|
13
|
-
.command('list', 'list storage nodes')
|
|
14
|
-
.command('add-stream', 'add stream')
|
|
15
|
-
.command('remove-stream', 'remove stream')
|
|
16
|
-
.command('list-stream-parts', 'list stream parts in a storage node')
|
|
17
|
-
.parse(process.argv);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const create_1 = require("../src/create");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
program
|
|
13
|
-
.arguments('<name>')
|
|
14
|
-
.description('create a new stream')
|
|
15
|
-
.option('-d, --description <description>', 'define a description')
|
|
16
|
-
.option('-c, --config <config>', 'define a configuration as JSON', (s) => JSON.parse(s))
|
|
17
|
-
.option('-p, --partitions <count>', 'define a partition count', common_1.createFnParseInt('--partitions'));
|
|
18
|
-
common_1.authOptions(program);
|
|
19
|
-
common_1.envOptions(program)
|
|
20
|
-
.version(package_json_1.default.version)
|
|
21
|
-
.action((name, options) => {
|
|
22
|
-
const body = {
|
|
23
|
-
name,
|
|
24
|
-
description: options.description,
|
|
25
|
-
config: options.config,
|
|
26
|
-
partitions: options.partitions
|
|
27
|
-
};
|
|
28
|
-
create_1.create(body, common_1.formStreamrOptionsWithEnv(options));
|
|
29
|
-
})
|
|
30
|
-
.parse(process.argv);
|
|
31
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 1, 1);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node -r ts-node/register
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
10
|
-
const streamr_client_1 = require("streamr-client");
|
|
11
|
-
const easy_table_1 = __importDefault(require("easy-table"));
|
|
12
|
-
const PUBLIC_PERMISSION_ID = 'public';
|
|
13
|
-
const OPERATION_PREFIX = 'stream_';
|
|
14
|
-
const getOperation = (id) => {
|
|
15
|
-
// we support both short ids (e.g. "publish"), and long ids (e.g. "stream_publish")
|
|
16
|
-
// the actual StreamOperation constant is the long id string
|
|
17
|
-
// backend does the validation of invalid constants
|
|
18
|
-
if (!id.startsWith(OPERATION_PREFIX)) {
|
|
19
|
-
return (OPERATION_PREFIX + id);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return id;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const getShortOperationId = (operation) => {
|
|
26
|
-
const longOperationId = operation;
|
|
27
|
-
if (longOperationId.startsWith(OPERATION_PREFIX)) {
|
|
28
|
-
return longOperationId.substring(OPERATION_PREFIX.length);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
throw new Error(`Assertion failed: unknown prefix for in ${longOperationId}`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const getTarget = (user) => {
|
|
35
|
-
if (user === PUBLIC_PERMISSION_ID) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return user;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const program = new commander_1.Command();
|
|
43
|
-
program
|
|
44
|
-
.arguments('<streamId> <user> <operations...>')
|
|
45
|
-
.description('grant permission: use keyword "public" as a user to grant a public permission');
|
|
46
|
-
common_1.authOptions(program);
|
|
47
|
-
common_1.envOptions(program)
|
|
48
|
-
.version(package_json_1.default.version)
|
|
49
|
-
.action(async (streamId, user, operationIds, options) => {
|
|
50
|
-
const operations = operationIds.map((o) => getOperation(o));
|
|
51
|
-
const target = getTarget(user);
|
|
52
|
-
const client = new streamr_client_1.StreamrClient(common_1.formStreamrOptionsWithEnv(options));
|
|
53
|
-
const stream = await client.getStream(streamId);
|
|
54
|
-
const tasks = operations.map((operation) => stream.grantPermission(operation, target));
|
|
55
|
-
const permissions = await Promise.all(tasks);
|
|
56
|
-
console.info(easy_table_1.default.print(permissions.map((permission) => ({
|
|
57
|
-
id: permission.id,
|
|
58
|
-
operation: getShortOperationId(permission.operation),
|
|
59
|
-
user: permission.anonymous ? PUBLIC_PERMISSION_ID : permission.user
|
|
60
|
-
}))));
|
|
61
|
-
})
|
|
62
|
-
.parseAsync(process.argv);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const list_1 = require("../src/list");
|
|
9
|
-
const common_1 = require("./common");
|
|
10
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
11
|
-
const program = new commander_1.Command();
|
|
12
|
-
program
|
|
13
|
-
.description('fetch a list of streams that are accessible by the authenticated user')
|
|
14
|
-
.option('-s, --search [term]', 'search for term in name or description')
|
|
15
|
-
// TODO could support shorter forms of operations: e.g. "publish" instead of "stream_publish", see streamr-stream-grant-permission.ts
|
|
16
|
-
.addOption(new commander_1.Option('-o, --operation [permission]', 'filter by permission').choices(['stream_get', 'stream_subscribe', 'stream_publish', 'stream_delete', 'stream_share']).default('stream_get'))
|
|
17
|
-
.option('--public-access', 'include publicly available streams')
|
|
18
|
-
.option('--no-granted-access', 'exclude streams that user has directly granted permissions to');
|
|
19
|
-
common_1.authOptions(program);
|
|
20
|
-
common_1.envOptions(program)
|
|
21
|
-
.version(package_json_1.default.version)
|
|
22
|
-
.action((options) => {
|
|
23
|
-
const query = {
|
|
24
|
-
operation: options.operation,
|
|
25
|
-
noConfig: true,
|
|
26
|
-
publicAccess: options.publicAccess,
|
|
27
|
-
search: options.search,
|
|
28
|
-
grantedAccess: options.grantedAccess
|
|
29
|
-
};
|
|
30
|
-
list_1.list(query, common_1.formStreamrOptionsWithEnv(options));
|
|
31
|
-
})
|
|
32
|
-
.parse(process.argv);
|
|
33
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 0, 0);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const event_stream_1 = __importDefault(require("event-stream"));
|
|
9
|
-
const publish_1 = require("../src/publish");
|
|
10
|
-
const common_1 = require("./common");
|
|
11
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
12
|
-
const program = new commander_1.Command();
|
|
13
|
-
program
|
|
14
|
-
.arguments('<streamId>')
|
|
15
|
-
.description('publish to a stream by reading JSON messages from stdin line-by-line')
|
|
16
|
-
.option('-k, --partition-key <string>', 'field name in each message to use for assigning the message to a stream partition');
|
|
17
|
-
common_1.authOptions(program);
|
|
18
|
-
common_1.envOptions(program)
|
|
19
|
-
.version(package_json_1.default.version)
|
|
20
|
-
.action((streamId, options) => {
|
|
21
|
-
const ps = publish_1.publishStream(streamId, options.partitionKey, common_1.formStreamrOptionsWithEnv(options));
|
|
22
|
-
process.stdin
|
|
23
|
-
.pipe(event_stream_1.default.split())
|
|
24
|
-
.pipe(ps)
|
|
25
|
-
.on('error', (err) => {
|
|
26
|
-
console.error(err);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
// process.stdin.pipe(ps) recover pipe to continue execution
|
|
29
|
-
});
|
|
30
|
-
})
|
|
31
|
-
.parse(process.argv);
|
|
32
|
-
common_1.exitWithHelpIfArgsNotBetween(program, 1, 1);
|