@streamr/cli-tools 0.0.1-tatum.2 → 0.0.1-tatum.4
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.
|
@@ -5,6 +5,7 @@ import isString from 'lodash/isString'
|
|
|
5
5
|
import { StreamrClient, MessageMetadata } from 'streamr-client'
|
|
6
6
|
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
7
7
|
import { createFnParseInt } from '../src/common'
|
|
8
|
+
import { binaryToHex } from '@streamr/utils'
|
|
8
9
|
|
|
9
10
|
interface Options extends BaseOptions {
|
|
10
11
|
partition: number
|
|
@@ -14,15 +15,16 @@ interface Options extends BaseOptions {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
18
|
+
const formContent = (content: unknown) => options.raw ? binaryToHex(content as Uint8Array) : content
|
|
17
19
|
const formMessage = options.withMetadata
|
|
18
|
-
? (
|
|
19
|
-
: (
|
|
20
|
+
? (content: unknown, metadata: MessageMetadata) => ({ content: formContent(content), metadata: omit(metadata, 'streamMessage') })
|
|
21
|
+
: (content: unknown) => formContent(content)
|
|
20
22
|
await client.subscribe({
|
|
21
23
|
streamId,
|
|
22
24
|
partition: options.partition,
|
|
23
25
|
raw: options.raw
|
|
24
|
-
}, (
|
|
25
|
-
const output = formMessage(
|
|
26
|
+
}, (content, metadata) => {
|
|
27
|
+
const output = formMessage(content, metadata)
|
|
26
28
|
console.info(isString(output) ? output : JSON.stringify(output))
|
|
27
29
|
})
|
|
28
30
|
}, {
|
|
@@ -9,16 +9,18 @@ const omit_1 = __importDefault(require("lodash/omit"));
|
|
|
9
9
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
10
10
|
const command_1 = require("../src/command");
|
|
11
11
|
const common_1 = require("../src/common");
|
|
12
|
+
const utils_1 = require("@streamr/utils");
|
|
12
13
|
(0, command_1.createClientCommand)(async (client, streamId, options) => {
|
|
14
|
+
const formContent = (content) => options.raw ? (0, utils_1.binaryToHex)(content) : content;
|
|
13
15
|
const formMessage = options.withMetadata
|
|
14
|
-
? (
|
|
15
|
-
: (
|
|
16
|
+
? (content, metadata) => ({ content: formContent(content), metadata: (0, omit_1.default)(metadata, 'streamMessage') })
|
|
17
|
+
: (content) => formContent(content);
|
|
16
18
|
await client.subscribe({
|
|
17
19
|
streamId,
|
|
18
20
|
partition: options.partition,
|
|
19
21
|
raw: options.raw
|
|
20
|
-
}, (
|
|
21
|
-
const output = formMessage(
|
|
22
|
+
}, (content, metadata) => {
|
|
23
|
+
const output = formMessage(content, metadata);
|
|
22
24
|
console.info((0, isString_1.default)(output) ? output : JSON.stringify(output));
|
|
23
25
|
});
|
|
24
26
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,uDAA8B;AAC9B,+DAAsC;AAEtC,4CAA4E;AAC5E,0CAAgD;
|
|
1
|
+
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,uDAA8B;AAC9B,+DAAsC;AAEtC,4CAA4E;AAC5E,0CAAgD;AAChD,0CAA4C;AAS5C,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IACpF,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,OAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACpG,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY;QACpC,CAAC,CAAC,CAAC,OAAgB,EAAE,QAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,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
+
"version": "0.0.1-tatum.4",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"license": "AGPL-3.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
|
-
"@snapshot-labs/snapshot.js": "^0.
|
|
31
|
-
"@streamr/utils": "0.0.1-tatum.
|
|
30
|
+
"@snapshot-labs/snapshot.js": "^0.6.2",
|
|
31
|
+
"@streamr/utils": "0.0.1-tatum.4",
|
|
32
32
|
"commander": "^11.0.0",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "0.0.1-tatum.
|
|
36
|
+
"streamr-client": "0.0.1-tatum.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@streamr/test-utils": "0.0.1-tatum.
|
|
40
|
-
"@types/event-stream": "^4.0.
|
|
41
|
-
"@types/lodash": "^4.14.
|
|
39
|
+
"@streamr/test-utils": "0.0.1-tatum.4",
|
|
40
|
+
"@types/event-stream": "^4.0.2",
|
|
41
|
+
"@types/lodash": "^4.14.199",
|
|
42
42
|
"@types/merge2": "^1.4.0",
|
|
43
43
|
"merge2": "^1.4.1"
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "0.0.1-tatum.
|
|
3
|
+
"version": "0.0.1-tatum.4",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"license": "AGPL-3.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
|
-
"@snapshot-labs/snapshot.js": "^0.
|
|
31
|
-
"@streamr/utils": "0.0.1-tatum.
|
|
30
|
+
"@snapshot-labs/snapshot.js": "^0.6.2",
|
|
31
|
+
"@streamr/utils": "0.0.1-tatum.4",
|
|
32
32
|
"commander": "^11.0.0",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "0.0.1-tatum.
|
|
36
|
+
"streamr-client": "0.0.1-tatum.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@streamr/test-utils": "0.0.1-tatum.
|
|
40
|
-
"@types/event-stream": "^4.0.
|
|
41
|
-
"@types/lodash": "^4.14.
|
|
39
|
+
"@streamr/test-utils": "0.0.1-tatum.4",
|
|
40
|
+
"@types/event-stream": "^4.0.2",
|
|
41
|
+
"@types/lodash": "^4.14.199",
|
|
42
42
|
"@types/merge2": "^1.4.0",
|
|
43
43
|
"merge2": "^1.4.1"
|
|
44
44
|
}
|
|
@@ -70,7 +70,7 @@ describe('publish and subscribe', () => {
|
|
|
70
70
|
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
71
71
|
subscriberAbortController.abort()
|
|
72
72
|
expect(JSON.parse(receivedMessage)).toMatchObject({
|
|
73
|
-
|
|
73
|
+
content: {
|
|
74
74
|
foo: 123
|
|
75
75
|
},
|
|
76
76
|
metadata: {
|
|
@@ -83,4 +83,26 @@ describe('publish and subscribe', () => {
|
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
}, TIMEOUT)
|
|
86
|
+
|
|
87
|
+
it('with metadata and raw', async () => {
|
|
88
|
+
const subscriberAbortController = new AbortController()
|
|
89
|
+
const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --with-metadata --raw`, {
|
|
90
|
+
privateKey: subscriberPrivateKey,
|
|
91
|
+
abortSignal: subscriberAbortController.signal,
|
|
92
|
+
})
|
|
93
|
+
publishViaCliCommand()
|
|
94
|
+
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
95
|
+
subscriberAbortController.abort()
|
|
96
|
+
expect(JSON.parse(receivedMessage)).toMatchObject({
|
|
97
|
+
content: expect.stringMatching(/^[0-9a-fA-F]+$/),
|
|
98
|
+
metadata: {
|
|
99
|
+
streamId,
|
|
100
|
+
streamPartition: 0,
|
|
101
|
+
timestamp: expect.any(Number),
|
|
102
|
+
sequenceNumber: 0,
|
|
103
|
+
publisherId: new Wallet(publisherPrivateKey).address.toLowerCase(),
|
|
104
|
+
msgChainId: expect.stringMatching(/[0-9a-zA-Z]+/)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}, TIMEOUT)
|
|
86
108
|
})
|