@streamr/cli-tools 8.3.0 → 8.4.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 → OLD_CHANGELOG.md} +6 -28
- package/bin/streamr-mock-data-generate.ts +6 -2
- package/bin/streamr-storage-node-list.ts +6 -2
- package/bin/streamr-stream-create.ts +9 -3
- package/bin/streamr-stream-publish.ts +6 -2
- package/bin/streamr-stream-resend-from.ts +8 -2
- package/bin/streamr-stream-resend-last.ts +7 -2
- package/bin/streamr-stream-resend-range.ts +8 -2
- package/bin/streamr-stream-search.ts +10 -3
- package/bin/streamr-stream-show.ts +7 -3
- package/bin/streamr-stream-subscribe.ts +22 -4
- package/dist/bin/streamr-mock-data-generate.js.map +1 -1
- package/dist/bin/streamr-storage-node-list.js.map +1 -1
- package/dist/bin/streamr-stream-create.js +1 -1
- package/dist/bin/streamr-stream-create.js.map +1 -1
- package/dist/bin/streamr-stream-publish.js.map +1 -1
- package/dist/bin/streamr-stream-resend-from.js.map +1 -1
- package/dist/bin/streamr-stream-resend-last.js.map +1 -1
- package/dist/bin/streamr-stream-resend-range.js.map +1 -1
- package/dist/bin/streamr-stream-search.js.map +1 -1
- package/dist/bin/streamr-stream-show.js +1 -1
- package/dist/bin/streamr-stream-show.js.map +1 -1
- package/dist/bin/streamr-stream-subscribe.js +15 -1
- package/dist/bin/streamr-stream-subscribe.js.map +1 -1
- package/dist/package.json +8 -5
- package/dist/src/client.d.ts +3 -3
- package/dist/src/client.js +6 -6
- package/dist/src/client.js.map +1 -1
- package/dist/src/command.d.ts +5 -0
- package/dist/src/command.js +3 -3
- package/dist/src/command.js.map +1 -1
- package/dist/src/common.d.ts +0 -5
- package/dist/src/common.js.map +1 -1
- package/dist/src/resend.d.ts +1 -1
- package/dist/src/resend.js.map +1 -1
- package/package.json +8 -5
- package/src/client.ts +7 -7
- package/src/command.ts +9 -3
- package/src/common.ts +0 -6
- package/src/resend.ts +4 -4
- package/test/mock-data.test.ts +19 -0
- package/test/storage-node.test.ts +32 -0
- package/test/stream-create.test.ts +26 -0
- package/test/stream-permission.test.ts +29 -0
- package/test/stream-publish-subscribe.test.ts +84 -0
- package/test/stream-resend.test.ts +66 -0
- package/test/stream-search.test.ts +20 -0
- package/test/stream-show.test.ts +30 -0
- package/test/utils.ts +75 -0
- package/test/wallet.test.ts +11 -0
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
|
|
4
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
### Changed
|
|
13
|
-
|
|
14
|
-
### Deprecated
|
|
15
|
-
|
|
16
|
-
### Removed
|
|
17
|
-
|
|
18
|
-
### Fixed
|
|
19
|
-
|
|
20
|
-
### Security
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## [7.0.0] - 2022-11-15
|
|
24
|
-
|
|
25
|
-
### Changed
|
|
26
|
-
|
|
27
|
-
- Replace command `storage-node list-stream-parts` with `storage-node list-streams` and change the output format
|
|
1
|
+
# Old Changelog
|
|
28
2
|
|
|
3
|
+
Versions before 7.0.0 and below are collected into this file. Changelogs for
|
|
4
|
+
newer versions of the cli-tool are available at the root-level CHANGELOG.md
|
|
5
|
+
file.
|
|
29
6
|
|
|
30
7
|
## [6.1.1] - 2022-11-03
|
|
31
8
|
|
|
@@ -149,7 +126,8 @@ ordering and gap filling.
|
|
|
149
126
|
- Re-organize README.md and a few touches to Developing section paragraphs.
|
|
150
127
|
|
|
151
128
|
|
|
152
|
-
[Unreleased]: https://github.com/streamr-dev/network/compare/cli-tools%
|
|
129
|
+
[Unreleased]: https://github.com/streamr-dev/network/compare/cli-tools%2fv8.3.1...HEAD
|
|
130
|
+
[8.3.1]: https://github.com/streamr-dev/network/compare/cli-tools%2fv7.0.0...cli-tools%2fv8.3.1
|
|
153
131
|
[7.0.0]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.1.1...cli-tools%2fv7.0.0
|
|
154
132
|
[6.1.1]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.1.0...cli-tools%2fv6.1.1
|
|
155
133
|
[6.1.0]: https://github.com/streamr-dev/network/compare/cli-tools%2fv6.0.0...cli-tools%2fv6.1.0
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import pkg from '../package.json'
|
|
3
3
|
import { createFnParseInt } from '../src/common'
|
|
4
|
-
import { createCommand } from '../src/command'
|
|
4
|
+
import { createCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { randomString } from '@streamr/utils'
|
|
6
6
|
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
rate: number
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
function genArray<T>(size: number, elementFn: () => T): T[] {
|
|
8
12
|
const arr = []
|
|
9
13
|
for (let i = 0; i < size; ++i) {
|
|
@@ -30,7 +34,7 @@ createCommand()
|
|
|
30
34
|
.description('generate and print semi-random JSON data to stdout')
|
|
31
35
|
.option('-r, --rate <n>', 'rate in milliseconds', createFnParseInt('--rate'), 500)
|
|
32
36
|
.version(pkg.version)
|
|
33
|
-
.action((options:
|
|
37
|
+
.action((options: Options) => {
|
|
34
38
|
generate(options.rate)
|
|
35
39
|
})
|
|
36
40
|
.parse()
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import { StreamrClient } from 'streamr-client'
|
|
4
4
|
import EasyTable from 'easy-table'
|
|
5
|
-
import { createClientCommand } from '../src/command'
|
|
5
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
stream?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
createClientCommand(async (client: StreamrClient, options: Options) => {
|
|
8
12
|
const streamId = options.stream
|
|
9
13
|
const addresses = await client.getStorageNodes(streamId)
|
|
10
14
|
if (addresses.length > 0) {
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import StreamrClient from 'streamr-client'
|
|
4
4
|
import { createFnParseInt } from '../src/common'
|
|
5
|
-
import { createClientCommand } from '../src/command'
|
|
5
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
description?: string
|
|
9
|
+
streamConfig?: any
|
|
10
|
+
partitions?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createClientCommand(async (client: StreamrClient, streamIdOrPath: string, options: Options) => {
|
|
8
14
|
const body: any = {
|
|
9
15
|
id: streamIdOrPath,
|
|
10
16
|
description: options.description,
|
|
@@ -12,7 +18,7 @@ createClientCommand(async (client: StreamrClient, streamIdOrPath: string, option
|
|
|
12
18
|
partitions: options.partitions
|
|
13
19
|
}
|
|
14
20
|
const stream = await client.createStream(body)
|
|
15
|
-
console.info({ id: stream.id, ...stream.getMetadata() }, null, 2)
|
|
21
|
+
console.info(JSON.stringify({ id: stream.id, ...stream.getMetadata() }, null, 2))
|
|
16
22
|
})
|
|
17
23
|
.arguments('<streamId>')
|
|
18
24
|
.description('create a new stream')
|
|
@@ -4,7 +4,11 @@ import { Writable } from 'stream'
|
|
|
4
4
|
import { StreamrClient } from 'streamr-client'
|
|
5
5
|
import { wait } from '@streamr/utils'
|
|
6
6
|
import es from 'event-stream'
|
|
7
|
-
import { createClientCommand } from '../src/command'
|
|
7
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
8
|
+
|
|
9
|
+
interface Options extends BaseOptions {
|
|
10
|
+
partitionKeyField?: string
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
const publishStream = (
|
|
10
14
|
stream: string,
|
|
@@ -37,7 +41,7 @@ const publishStream = (
|
|
|
37
41
|
return writable
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
createClientCommand(async (client: StreamrClient, streamId: string, options:
|
|
44
|
+
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
41
45
|
const ps = publishStream(streamId, options.partitionKeyField, client)
|
|
42
46
|
return new Promise((resolve, reject) => {
|
|
43
47
|
process.stdin
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import StreamrClient from 'streamr-client'
|
|
4
|
-
import { createClientCommand } from '../src/command'
|
|
4
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { resend } from '../src/resend'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
publisherId?: string
|
|
9
|
+
disableOrdering: boolean
|
|
10
|
+
subscribe: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createClientCommand(async (client: StreamrClient, from: string, streamId: string, options: Options) => {
|
|
8
14
|
const resendOptions = {
|
|
9
15
|
from: {
|
|
10
16
|
timestamp: Date.parse(from),
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import StreamrClient from 'streamr-client'
|
|
4
|
-
import { createClientCommand } from '../src/command'
|
|
4
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { resend } from '../src/resend'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
disableOrdering: boolean
|
|
9
|
+
subscribe: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
createClientCommand(async (client: StreamrClient, n: string, streamId: string, options: Options) => {
|
|
8
13
|
if (isNaN(n as any)) {
|
|
9
14
|
console.error('argument n is not a number')
|
|
10
15
|
process.exit(1)
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import { StreamrClient } from 'streamr-client'
|
|
4
|
-
import { createClientCommand } from '../src/command'
|
|
4
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { assertBothOrNoneDefined, resend } from '../src/resend'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
publisherId?: string
|
|
9
|
+
msgChainId?: string
|
|
10
|
+
subscribe: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createClientCommand(async (client: StreamrClient, from: string, to: string, streamId: string, options: Options) => {
|
|
8
14
|
const resendOptions = {
|
|
9
15
|
from: {
|
|
10
16
|
timestamp: Date.parse(from),
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import StreamrClient, { SearchStreamsPermissionFilter, StreamPermission } from 'streamr-client'
|
|
4
|
-
import { createClientCommand } from '../src/command'
|
|
4
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { Option } from 'commander'
|
|
6
6
|
import { getPermission, PERMISSIONS } from '../src/permission'
|
|
7
7
|
import { getOptionType, OptionType } from '../src/common'
|
|
8
8
|
|
|
9
|
+
interface Options extends BaseOptions {
|
|
10
|
+
user?: string | true
|
|
11
|
+
public: boolean
|
|
12
|
+
all?: StreamPermission[]
|
|
13
|
+
any?: StreamPermission[]
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
const createPermissionFilter = async (
|
|
10
|
-
user: string |
|
|
17
|
+
user: string | true | undefined,
|
|
11
18
|
allowPublic: boolean | undefined,
|
|
12
19
|
allOf: StreamPermission[] | undefined,
|
|
13
20
|
anyOf: StreamPermission[] | undefined,
|
|
@@ -32,7 +39,7 @@ const createPermissionListOption = (id: string) => {
|
|
|
32
39
|
.argParser((value: string) => value.split(',').map((id) => getPermission(id)))
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
createClientCommand(async (client: StreamrClient, term: string | undefined, options:
|
|
42
|
+
createClientCommand(async (client: StreamrClient, term: string | undefined, options: Options) => {
|
|
36
43
|
const permissionFilter = await createPermissionFilter(
|
|
37
44
|
options.user,
|
|
38
45
|
options.public,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import StreamrClient from 'streamr-client'
|
|
4
|
-
import { createClientCommand } from '../src/command'
|
|
4
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { getPermissionId } from '../src/permission'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
interface Options extends BaseOptions {
|
|
8
|
+
includePermissions: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
8
12
|
const stream = await client.getStream(streamId)
|
|
9
13
|
const obj: any = { id: stream.id, ...stream.getMetadata() }
|
|
10
14
|
if (options.includePermissions) {
|
|
@@ -20,5 +24,5 @@ createClientCommand(async (client: StreamrClient, streamId: string, options: any
|
|
|
20
24
|
})
|
|
21
25
|
.arguments('<streamId>')
|
|
22
26
|
.description('show detailed information about a stream')
|
|
23
|
-
.option('--include-permissions', 'include list of permissions')
|
|
27
|
+
.option('--include-permissions', 'include list of permissions', false)
|
|
24
28
|
.parseAsync()
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import omit from 'lodash/omit'
|
|
4
|
+
import isString from 'lodash/isString'
|
|
5
|
+
import StreamrClient, { MessageMetadata } from 'streamr-client'
|
|
6
|
+
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
7
|
import { createFnParseInt } from '../src/common'
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
interface Options extends BaseOptions {
|
|
10
|
+
partition: number
|
|
11
|
+
disableOrdering: boolean
|
|
12
|
+
raw: boolean
|
|
13
|
+
withMetadata: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
17
|
+
const formMessage = options.withMetadata
|
|
18
|
+
? (message: unknown, metadata: MessageMetadata) => ({ message, metadata: omit(metadata, 'streamMessage') })
|
|
19
|
+
: (message: unknown) => message
|
|
8
20
|
await client.subscribe({
|
|
9
21
|
streamId,
|
|
10
22
|
partition: options.partition,
|
|
11
|
-
|
|
23
|
+
raw: options.raw
|
|
24
|
+
}, (message, metadata) => {
|
|
25
|
+
const output = formMessage(message, metadata)
|
|
26
|
+
console.info(isString(output) ? output : JSON.stringify(output))
|
|
27
|
+
})
|
|
12
28
|
}, {
|
|
13
29
|
autoDestroyClient: false,
|
|
14
30
|
clientOptionsFactory: (options) => ({
|
|
@@ -19,4 +35,6 @@ createClientCommand(async (client: StreamrClient, streamId: string, options: any
|
|
|
19
35
|
.description('subscribe to a stream, prints JSON messages to stdout line-by-line')
|
|
20
36
|
.option('-p, --partition [partition]', 'partition', createFnParseInt('--partition'), 0)
|
|
21
37
|
.option('-d, --disable-ordering', 'disable ordering of messages by OrderingUtil', false)
|
|
38
|
+
.option('-r, --raw', 'subscribe raw', false)
|
|
39
|
+
.option('-m, --with-metadata', 'print each message with its metadata included', false)
|
|
22
40
|
.parseAsync()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-mock-data-generate.js","sourceRoot":"","sources":["../../bin/streamr-mock-data-generate.ts"],"names":[],"mappings":";;;;;;;AACA,mEAAiC;AACjC,0CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"streamr-mock-data-generate.js","sourceRoot":"","sources":["../../bin/streamr-mock-data-generate.ts"],"names":[],"mappings":";;;;;;;AACA,mEAAiC;AACjC,0CAAgD;AAChD,4CAAsE;AACtE,0CAA6C;AAM7C,SAAS,QAAQ,CAAI,IAAY,EAAE,SAAkB;IACjD,MAAM,GAAG,GAAG,EAAE,CAAA;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,EAAE;QAC3B,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;KACxB;IACD,OAAO,GAAG,CAAA;AACd,CAAC;AAEM,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAQ,EAAE;IAC3C,WAAW,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YACxB,QAAQ,EAAE,IAAA,oBAAY,EAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK;YAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;YACtB,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG;YAC5B,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,IAAA,oBAAY,EAAC,CAAC,CAAC,CAAC;YAC/E,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;SAEnG,CAAC,CAAC,CAAA;IACP,CAAC,EAAE,IAAI,CAAC,CAAA;AACZ,CAAC,CAAA;AAZY,QAAA,QAAQ,YAYpB;AAED,IAAA,uBAAa,GAAE;KACV,WAAW,CAAC,oDAAoD,CAAC;KACjE,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,IAAA,yBAAgB,EAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;KACjF,OAAO,CAAC,sBAAG,CAAC,OAAO,CAAC;KACpB,MAAM,CAAC,CAAC,OAAgB,EAAE,EAAE;IACzB,IAAA,gBAAQ,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC,CAAC;KACD,KAAK,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-storage-node-list.js","sourceRoot":"","sources":["../../bin/streamr-storage-node-list.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,4DAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"streamr-storage-node-list.js","sourceRoot":"","sources":["../../bin/streamr-storage-node-list.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,4DAAkC;AAClC,4CAA4E;AAM5E,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,OAAgB,EAAE,EAAE;IAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAA;IAC/B,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IACxD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,OAAO,CAAC,IAAI,CAAC,oBAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC;YAC7D,OAAO;SACV,CAAC,CAAC,CAAC,CAAC,CAAA;KACR;AACL,CAAC,CAAC;KACG,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,yBAAyB,EAAE,wEAAwE,CAAC;KAC3G,UAAU,EAAE,CAAA"}
|
|
@@ -12,7 +12,7 @@ const command_1 = require("../src/command");
|
|
|
12
12
|
partitions: options.partitions
|
|
13
13
|
};
|
|
14
14
|
const stream = await client.createStream(body);
|
|
15
|
-
console.info({ id: stream.id, ...stream.getMetadata() }, null, 2);
|
|
15
|
+
console.info(JSON.stringify({ id: stream.id, ...stream.getMetadata() }, null, 2));
|
|
16
16
|
})
|
|
17
17
|
.arguments('<streamId>')
|
|
18
18
|
.description('create a new stream')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-create.js","sourceRoot":"","sources":["../../bin/streamr-stream-create.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,0CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"streamr-stream-create.js","sourceRoot":"","sources":["../../bin/streamr-stream-create.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,0CAAgD;AAChD,4CAA4E;AAQ5E,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,cAAsB,EAAE,OAAgB,EAAE,EAAE;IAC1F,MAAM,IAAI,GAAQ;QACd,EAAE,EAAE,cAAc;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,YAAY;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;KACjC,CAAA;IACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAC9C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACrF,CAAC,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,iCAAiC,EAAE,sBAAsB,CAAC;KACjE,MAAM,CAAC,8BAA8B,EAAE,gCAAgC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACtG,MAAM,CAAC,0BAA0B,EAAE,0BAA0B,EAC1D,IAAA,yBAAgB,EAAC,cAAc,CAAC,CAAC;KACpC,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-publish.js","sourceRoot":"","sources":["../../bin/streamr-stream-publish.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,mCAAiC;AAEjC,0CAAqC;AACrC,gEAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"streamr-stream-publish.js","sourceRoot":"","sources":["../../bin/streamr-stream-publish.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,mCAAiC;AAEjC,0CAAqC;AACrC,gEAA6B;AAC7B,4CAA4E;AAM5E,MAAM,aAAa,GAAG,CAClB,MAAc,EACd,iBAAqC,EACrC,MAAqB,EACb,EAAE;IACV,MAAM,QAAQ,GAAG,IAAI,iBAAQ,CAAC;QAC1B,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,CAAC,IAAS,EAAE,CAAM,EAAE,IAAS,EAAE,EAAE;YACpC,IAAI,IAAI,GAAG,IAAI,CAAA;YACf,uBAAuB;YACvB,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBACrC,IAAI,EAAE,CAAA;gBACN,OAAM;aACT;YACD,IAAI;gBACA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;aAC1B;YAAC,OAAO,CAAC,EAAE;gBACR,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;gBAC9B,IAAI,CAAC,CAAC,CAAC,CAAA;gBACP,OAAM;aACT;YACD,MAAM,YAAY,GAAG,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YAC5F,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,CAC/C,GAAG,EAAE,CAAC,IAAI,EAAE,EACZ,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CACrB,CAAA;QACL,CAAC;KACJ,CAAC,CAAA;IACF,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAED,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IACpF,MAAM,EAAE,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAA;IACrE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,OAAO,CAAC,KAAK;aACR,IAAI,CAAC,sBAAE,CAAC,KAAK,EAAE,CAAC;aAChB,IAAI,CAAC,EAAE,CAAC;aACR,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YACvB,iFAAiF;YACjF,2EAA2E;YAC3E,iFAAiF;YACjF,2EAA2E;YAC3E,sFAAsF;YACtF,uDAAuD;YACvD,MAAM,IAAA,YAAI,EAAC,IAAI,CAAC,CAAA;YAChB,OAAO,CAAC,SAAS,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,IAAI,CAAC,OAAO,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,CAAA;IAClD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,sEAAsE,CAAC;KACnF,MAAM,CAAC,oCAAoC,EAAE,mFAAmF,CAAC;KACjI,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-resend-from.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-from.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-resend-from.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-from.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,4CAA4E;AAC5E,0CAAsC;AAQtC,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,IAAY,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IAClG,MAAM,aAAa,GAAG;QAClB,IAAI,EAAE;YACF,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAC3B,cAAc,EAAE,CAAC;SACpB;QACD,WAAW,EAAE,OAAO,CAAC,WAAW;KACnC,CAAA;IACD,MAAM,IAAA,eAAM,EAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC,EAAE;IACC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,mBAAmB,CAAC;KAC9B,WAAW,CAAC,qFAAqF,CAAC;KAClG,MAAM,CAAC,yBAAyB,EAAE,6BAA6B,CAAC;KAChE,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,MAAM,CAAC,iBAAiB,EAAE,iCAAiC,EAAE,KAAK,CAAC;KACnE,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-resend-last.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-last.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-resend-last.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-last.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,4CAA4E;AAC5E,0CAAsC;AAOtC,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,CAAS,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IAC/F,IAAI,KAAK,CAAC,CAAQ,CAAC,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;IACD,MAAM,aAAa,GAAG;QAClB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;KACpB,CAAA;IACD,MAAM,IAAA,eAAM,EAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC,EAAE;IACC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,gBAAgB,CAAC;KAC3B,WAAW,CAAC,yBAAyB,CAAC;KACtC,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,MAAM,CAAC,iBAAiB,EAAE,iCAAiC,EAAE,KAAK,CAAC;KACnE,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-resend-range.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-range.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-resend-range.js","sourceRoot":"","sources":["../../bin/streamr-stream-resend-range.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,4CAA4E;AAC5E,0CAA+D;AAQ/D,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,IAAY,EAAE,EAAU,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IAC9G,MAAM,aAAa,GAAG;QAClB,IAAI,EAAE;YACF,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAC3B,cAAc,EAAE,CAAC;SACpB;QACD,EAAE,EAAE;YACA,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,cAAc,EAAE,CAAC;SACpB;QACD,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;KACjC,CAAA;IACD,IAAA,gCAAuB,EAAC,aAAa,EAAE,YAAY,EAAE,6DAA6D,EAAE,OAAO,CAAC,CAAA;IAC5H,MAAM,IAAA,eAAM,EAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AACxD,CAAC,EAAE;IACC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,wBAAwB,CAAC;KACnC,WAAW,CAAC,oFAAoF,CAAC;KACjG,MAAM,CAAC,yBAAyB,EAAE,6BAA6B,CAAC;KAChE,MAAM,CAAC,yBAAyB,EAAE,iCAAiC,CAAC;KACpE,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-search.js","sourceRoot":"","sources":["../../bin/streamr-stream-search.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-search.js","sourceRoot":"","sources":["../../bin/streamr-stream-search.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,4CAA4E;AAC5E,yCAAkC;AAClC,kDAA8D;AAC9D,0CAAyD;AASzD,MAAM,sBAAsB,GAAG,KAAK,EAChC,IAA+B,EAC/B,WAAgC,EAChC,KAAqC,EACrC,KAAqC,EACrC,MAAqB,EAC6B,EAAE;IACpD,IAAI,IAAI,KAAK,SAAS,EAAE;QACpB,OAAO;YACH,IAAI,EAAE,CAAC,IAAA,sBAAa,EAAC,IAAI,CAAC,KAAK,mBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE;YAChG,WAAW,EAAE,WAAW,IAAI,KAAK;YACjC,KAAK;YACL,KAAK;SACR,CAAA;KACJ;SAAM,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE;QACtF,OAAO,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAA;QACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC,CAAA;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAU,EAAE,EAAE;IAC9C,OAAO,IAAI,kBAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,qCAAqC,CAAC;SAC5E,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,wBAAW,CAAC,IAAI,EAAE,CAAC,CAAC;SACvC,SAAS,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAA,0BAAa,EAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AACtF,CAAC,CAAA;AAED,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,IAAwB,EAAE,OAAgB,EAAE,EAAE;IAC5F,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACjD,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,GAAG,EACX,MAAM,CACT,CAAA;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;IAC5D,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,OAAO,EAAE;QAChC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;KACzB;AACL,CAAC,CAAC;KACG,SAAS,CAAC,QAAQ,CAAC;KACnB,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,eAAe,EAAE,uFAAuF,CAAC;KAChH,MAAM,CAAC,UAAU,EAAE,oEAAoE,CAAC;KACxF,SAAS,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;KAC5C,SAAS,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;KAC5C,UAAU,EAAE,CAAA"}
|
|
@@ -20,6 +20,6 @@ const permission_1 = require("../src/permission");
|
|
|
20
20
|
})
|
|
21
21
|
.arguments('<streamId>')
|
|
22
22
|
.description('show detailed information about a stream')
|
|
23
|
-
.option('--include-permissions', 'include list of permissions')
|
|
23
|
+
.option('--include-permissions', 'include list of permissions', false)
|
|
24
24
|
.parseAsync();
|
|
25
25
|
//# sourceMappingURL=streamr-stream-show.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-show.js","sourceRoot":"","sources":["../../bin/streamr-stream-show.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-show.js","sourceRoot":"","sources":["../../bin/streamr-stream-show.ts"],"names":[],"mappings":";;;AACA,2BAAwB;AAExB,4CAA4E;AAC5E,kDAAmD;AAMnD,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IACpF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,GAAG,GAAQ,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,CAAA;IAC3D,IAAI,OAAO,CAAC,kBAAkB,EAAE;QAC5B,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAA;QAChD,GAAG,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC5C,OAAO;gBACH,GAAG,UAAU;gBACb,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,4BAAe,CAAC;aAC3D,CAAA;QACL,CAAC,CAAC,CAAA;KACL;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC9C,CAAC,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,uBAAuB,EAAE,6BAA6B,EAAE,KAAK,CAAC;KACrE,UAAU,EAAE,CAAA"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
require("../src/logLevel");
|
|
8
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
9
|
+
const isString_1 = __importDefault(require("lodash/isString"));
|
|
5
10
|
const command_1 = require("../src/command");
|
|
6
11
|
const common_1 = require("../src/common");
|
|
7
12
|
(0, command_1.createClientCommand)(async (client, streamId, options) => {
|
|
13
|
+
const formMessage = options.withMetadata
|
|
14
|
+
? (message, metadata) => ({ message, metadata: (0, omit_1.default)(metadata, 'streamMessage') })
|
|
15
|
+
: (message) => message;
|
|
8
16
|
await client.subscribe({
|
|
9
17
|
streamId,
|
|
10
18
|
partition: options.partition,
|
|
11
|
-
|
|
19
|
+
raw: options.raw
|
|
20
|
+
}, (message, metadata) => {
|
|
21
|
+
const output = formMessage(message, metadata);
|
|
22
|
+
console.info((0, isString_1.default)(output) ? output : JSON.stringify(output));
|
|
23
|
+
});
|
|
12
24
|
}, {
|
|
13
25
|
autoDestroyClient: false,
|
|
14
26
|
clientOptionsFactory: (options) => ({
|
|
@@ -19,5 +31,7 @@ const common_1 = require("../src/common");
|
|
|
19
31
|
.description('subscribe to a stream, prints JSON messages to stdout line-by-line')
|
|
20
32
|
.option('-p, --partition [partition]', 'partition', (0, common_1.createFnParseInt)('--partition'), 0)
|
|
21
33
|
.option('-d, --disable-ordering', 'disable ordering of messages by OrderingUtil', false)
|
|
34
|
+
.option('-r, --raw', 'subscribe raw', false)
|
|
35
|
+
.option('-m, --with-metadata', 'print each message with its metadata included', false)
|
|
22
36
|
.parseAsync();
|
|
23
37
|
//# sourceMappingURL=streamr-stream-subscribe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":"
|
|
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;AAShD,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IACpF,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY;QACpC,CAAC,CAAC,CAAC,OAAgB,EAAE,QAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAA,cAAI,EAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,CAAC;QAC3G,CAAC,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAA;IACnC,MAAM,MAAM,CAAC,SAAS,CAAC;QACnB,QAAQ;QACR,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,GAAG,EAAE,OAAO,CAAC,GAAG;KACnB,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC7C,OAAO,CAAC,IAAI,CAAC,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;AACN,CAAC,EAAE;IACC,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,oEAAoE,CAAC;KACjF,MAAM,CAAC,6BAA6B,EAAE,WAAW,EAAE,IAAA,yBAAgB,EAAC,aAAa,CAAC,EAAE,CAAC,CAAC;KACtF,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC;KAC3C,MAAM,CAAC,qBAAqB,EAAE,+CAA+C,EAAE,KAAK,CAAC;KACrF,UAAU,EAAE,CAAA"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"check": "tsc -p ./tsconfig.json --noEmit",
|
|
16
16
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
17
17
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "npm run build && jest --forceExit"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"streamr",
|
|
@@ -28,15 +28,18 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
30
|
"@snapshot-labs/snapshot.js": "^0.4.43",
|
|
31
|
-
"@streamr/utils": "8.
|
|
31
|
+
"@streamr/utils": "8.4.0",
|
|
32
32
|
"commander": "^10.0.1",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "8.
|
|
36
|
+
"streamr-client": "8.4.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@streamr/test-utils": "8.4.0",
|
|
39
40
|
"@types/event-stream": "^4.0.0",
|
|
40
|
-
"@types/lodash": "^4.14.175"
|
|
41
|
+
"@types/lodash": "^4.14.175",
|
|
42
|
+
"@types/merge2": "^1.4.0",
|
|
43
|
+
"merge2": "^1.4.1"
|
|
41
44
|
}
|
|
42
45
|
}
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StreamrClientConfig, StreamrClient } from 'streamr-client';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getClientConfig: (
|
|
4
|
-
export declare const createClient: (
|
|
2
|
+
import { Options } from './command';
|
|
3
|
+
export declare const getClientConfig: (commandOptions: Options, overridenOptions?: StreamrClientConfig) => StreamrClientConfig;
|
|
4
|
+
export declare const createClient: (commandOptions: Options, overridenOptions?: StreamrClientConfig) => StreamrClient;
|
package/dist/src/client.js
CHANGED
|
@@ -8,10 +8,10 @@ const omit_1 = __importDefault(require("lodash/omit"));
|
|
|
8
8
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
9
9
|
const streamr_client_1 = require("streamr-client");
|
|
10
10
|
const config_1 = require("./config");
|
|
11
|
-
const getClientConfig = (
|
|
12
|
-
const environmentOptions =
|
|
13
|
-
const configFileJson = (0, config_1.getConfig)(
|
|
14
|
-
const authenticationOptions = (
|
|
11
|
+
const getClientConfig = (commandOptions, overridenOptions = {}) => {
|
|
12
|
+
const environmentOptions = commandOptions.dev ? (0, omit_1.default)(streamr_client_1.CONFIG_TEST, 'auth') : undefined;
|
|
13
|
+
const configFileJson = (0, config_1.getConfig)(commandOptions.config)?.client;
|
|
14
|
+
const authenticationOptions = (commandOptions.privateKey !== undefined) ? { auth: { privateKey: commandOptions.privateKey } } : undefined;
|
|
15
15
|
return (0, merge_1.default)(environmentOptions, configFileJson, authenticationOptions, overridenOptions);
|
|
16
16
|
};
|
|
17
17
|
exports.getClientConfig = getClientConfig;
|
|
@@ -26,8 +26,8 @@ const addInterruptHandler = (client) => {
|
|
|
26
26
|
process.exit();
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
const createClient = (
|
|
30
|
-
const config = (0, exports.getClientConfig)(
|
|
29
|
+
const createClient = (commandOptions, overridenOptions = {}) => {
|
|
30
|
+
const config = (0, exports.getClientConfig)(commandOptions, overridenOptions);
|
|
31
31
|
const client = new streamr_client_1.StreamrClient(config);
|
|
32
32
|
addInterruptHandler(client);
|
|
33
33
|
return client;
|
package/dist/src/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA8B;AAC9B,yDAAgC;AAChC,mDAAgF;AAEhF,qCAAoC;AAE7B,MAAM,eAAe,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA8B;AAC9B,yDAAgC;AAChC,mDAAgF;AAEhF,qCAAoC;AAE7B,MAAM,eAAe,GAAG,CAAC,cAAuB,EAAE,mBAAwC,EAAE,EAAuB,EAAE;IACxH,MAAM,kBAAkB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,cAAI,EAAC,4BAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACrF,MAAM,cAAc,GAAG,IAAA,kBAAS,EAAC,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IAC/D,MAAM,qBAAqB,GAAG,CAAC,cAAc,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IACzI,OAAO,IAAA,eAAK,EACR,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,CACnB,CAAA;AACL,CAAC,CAAA;AAVY,QAAA,eAAe,mBAU3B;AAED,MAAM,mBAAmB,GAAG,CAAC,MAAqB,EAAE,EAAE;IAClD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC5B,IAAI;YACA,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;SACzB;QAAC,MAAM;YACJ,QAAQ;SACX;QACD,OAAO,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAEM,MAAM,YAAY,GAAG,CAAC,cAAuB,EAAE,mBAAwC,EAAE,EAAiB,EAAE;IAC/G,MAAM,MAAM,GAAG,IAAA,uBAAe,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,IAAI,8BAAa,CAAC,MAAM,CAAC,CAAA;IACxC,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAC3B,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AALY,QAAA,YAAY,gBAKxB"}
|
package/dist/src/command.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import commander, { Command } from 'commander';
|
|
2
2
|
import { StreamrClientConfig } from 'streamr-client';
|
|
3
|
+
export interface Options {
|
|
4
|
+
privateKey?: string;
|
|
5
|
+
config?: string;
|
|
6
|
+
dev: boolean;
|
|
7
|
+
}
|
|
3
8
|
export declare const createCommand: () => commander.Command;
|
|
4
9
|
export interface CommandOpts {
|
|
5
10
|
autoDestroyClient?: boolean;
|
package/dist/src/command.js
CHANGED
|
@@ -21,11 +21,11 @@ const createClientCommand = (action, opts = {
|
|
|
21
21
|
return (0, exports.createCommand)()
|
|
22
22
|
.option('--private-key <key>', 'use an Ethereum private key to authenticate')
|
|
23
23
|
.option('--config <file>', 'read connection and authentication settings from a config file')
|
|
24
|
-
.option('--dev', 'use pre-defined development environment')
|
|
24
|
+
.option('--dev', 'use pre-defined development environment', false)
|
|
25
25
|
.action(async (...args) => {
|
|
26
|
-
const
|
|
26
|
+
const commandOptions = args[args.length - 1].opts();
|
|
27
27
|
try {
|
|
28
|
-
const client = (0, client_1.createClient)(
|
|
28
|
+
const client = (0, client_1.createClient)(commandOptions, opts.clientOptionsFactory(commandOptions));
|
|
29
29
|
try {
|
|
30
30
|
await action(...[client].concat(args));
|
|
31
31
|
}
|
package/dist/src/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/command.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA8C;AAE9C,mEAAiC;AACjC,qCAAuC;
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/command.ts"],"names":[],"mappings":";;;;;;AAAA,yCAA8C;AAE9C,mEAAiC;AACjC,qCAAuC;AAQhC,MAAM,aAAa,GAAG,GAAsB,EAAE;IACjD,OAAO,IAAI,mBAAO,EAAE;SACf,OAAO,CAAC,sBAAG,CAAC,OAAO,CAAC;SACpB,kBAAkB,EAAE;SACpB,oBAAoB,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC,CAAA;AALY,QAAA,aAAa,iBAKzB;AAOM,MAAM,mBAAmB,GAAG,CAC/B,MAA+C,EAC/C,OAAoB;IAChB,iBAAiB,EAAE,IAAI;IACvB,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;CACnC,EACgB,EAAE;IACnB,OAAO,IAAA,qBAAa,GAAE;SACjB,MAAM,CAAC,qBAAqB,EAAE,6CAA6C,CAAC;SAC5E,MAAM,CAAC,iBAAiB,EAAE,gEAAgE,CAAC;SAC3F,MAAM,CAAC,OAAO,EAAE,yCAAyC,EAAE,KAAK,CAAC;SACjE,MAAM,CAAC,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;QAC7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACnD,IAAI;YACA,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,cAAc,EAAE,IAAI,CAAC,oBAAqB,CAAC,cAAc,CAAC,CAAC,CAAA;YACvF,IAAI;gBACA,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;aACzC;oBAAS;gBACN,IAAI,IAAI,CAAC,iBAAiB,EAAE;oBACxB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;iBACzB;aACJ;SACJ;QAAC,OAAO,CAAM,EAAE;YACb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SAClB;IACL,CAAC,CAAC,CAAA;AACV,CAAC,CAAA;AA3BY,QAAA,mBAAmB,uBA2B/B"}
|
package/dist/src/common.d.ts
CHANGED
package/dist/src/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,2CAAI,CAAA;IACJ,mDAAQ,CAAA,CAAE,8BAA8B;AAC5C,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAEM,MAAM,aAAa,GAAG,CAAC,KAAuB,EAAsB,EAAE;IACzE,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC5B,OAAO,UAAU,CAAC,IAAI,CAAA;KACzB;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC,QAAQ,CAAA;KAC7B;SAAM;QACH,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,GAAG,CAAC,CAAA;KAC3D;AACL,CAAC,CAAA;AARY,QAAA,aAAa,iBAQzB;AAED,SAAgB,gBAAgB,CAAC,IAAY;IACzC,OAAO,CAAC,GAAW,EAAE,EAAE;QACnB,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC3B,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,6BAA6B,GAAG,IAAI,CAAC,CAAA;YAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SAClB;QACD,OAAO,CAAC,CAAA;IACZ,CAAC,CAAA;AACL,CAAC;AATD,4CASC"}
|
package/dist/src/resend.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StreamrClient, ResendOptions } from 'streamr-client';
|
|
2
|
-
export declare const assertBothOrNoneDefined: (option1:
|
|
2
|
+
export declare const assertBothOrNoneDefined: <T extends object>(option1: keyof T, option2: keyof T, errorMessage: string, commandOptions: T) => void | never;
|
|
3
3
|
export declare const resend: (streamId: string, resendOpts: ResendOptions, client: StreamrClient, subscribe: boolean) => Promise<void>;
|
package/dist/src/resend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resend.js","sourceRoot":"","sources":["../../src/resend.ts"],"names":[],"mappings":";;;AAEO,MAAM,uBAAuB,GAAG,CACnC,
|
|
1
|
+
{"version":3,"file":"resend.js","sourceRoot":"","sources":["../../src/resend.ts"],"names":[],"mappings":";;;AAEO,MAAM,uBAAuB,GAAG,CACnC,OAAgB,EAChB,OAAgB,EAChB,YAAoB,EACpB,cAAiB,EACL,EAAE;IACd,IAAI,CAAC,OAAO,IAAI,cAAc,IAAI,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,cAAc,IAAI,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC,EAAE;QAC5H,OAAO,CAAC,KAAK,CAAC,UAAU,YAAY,EAAE,CAAC,CAAA;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC,CAAA;AAVY,QAAA,uBAAuB,2BAUnC;AAEM,MAAM,MAAM,GAAG,KAAK,EACvB,QAAgB,EAChB,UAAyB,EACzB,MAAqB,EACrB,SAAkB,EACL,EAAE;IACf,IAAI;QACA,MAAM,OAAO,GAAG,CAAC,OAAY,EAAE,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;QACzC,CAAC,CAAA;QACD,IAAI,SAAS,EAAE;YACX,MAAM,MAAM,CAAC,SAAS,CAAC;gBACnB,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,UAAU;aACrB,EAAE,OAAO,CAAC,CAAA;SACd;aAAM;YACH,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;SACrD;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAClB;AACL,CAAC,CAAA;AAtBY,QAAA,MAAM,UAsBlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"check": "tsc -p ./tsconfig.json --noEmit",
|
|
16
16
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
17
17
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
18
|
-
"test": "
|
|
18
|
+
"test": "npm run build && jest --forceExit"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"streamr",
|
|
@@ -28,15 +28,18 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
30
|
"@snapshot-labs/snapshot.js": "^0.4.43",
|
|
31
|
-
"@streamr/utils": "8.
|
|
31
|
+
"@streamr/utils": "8.4.0",
|
|
32
32
|
"commander": "^10.0.1",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "8.
|
|
36
|
+
"streamr-client": "8.4.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@streamr/test-utils": "8.4.0",
|
|
39
40
|
"@types/event-stream": "^4.0.0",
|
|
40
|
-
"@types/lodash": "^4.14.175"
|
|
41
|
+
"@types/lodash": "^4.14.175",
|
|
42
|
+
"@types/merge2": "^1.4.0",
|
|
43
|
+
"merge2": "^1.4.1"
|
|
41
44
|
}
|
|
42
45
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import omit from 'lodash/omit'
|
|
2
2
|
import merge from 'lodash/merge'
|
|
3
3
|
import { StreamrClientConfig, StreamrClient, CONFIG_TEST } from 'streamr-client'
|
|
4
|
-
import {
|
|
4
|
+
import { Options } from './command'
|
|
5
5
|
import { getConfig } from './config'
|
|
6
6
|
|
|
7
|
-
export const getClientConfig = (
|
|
8
|
-
const environmentOptions =
|
|
9
|
-
const configFileJson = getConfig(
|
|
10
|
-
const authenticationOptions = (
|
|
7
|
+
export const getClientConfig = (commandOptions: Options, overridenOptions: StreamrClientConfig = {}): StreamrClientConfig => {
|
|
8
|
+
const environmentOptions = commandOptions.dev ? omit(CONFIG_TEST, 'auth') : undefined
|
|
9
|
+
const configFileJson = getConfig(commandOptions.config)?.client
|
|
10
|
+
const authenticationOptions = (commandOptions.privateKey !== undefined) ? { auth: { privateKey: commandOptions.privateKey } } : undefined
|
|
11
11
|
return merge(
|
|
12
12
|
environmentOptions,
|
|
13
13
|
configFileJson,
|
|
@@ -27,8 +27,8 @@ const addInterruptHandler = (client: StreamrClient) => {
|
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const createClient = (
|
|
31
|
-
const config = getClientConfig(
|
|
30
|
+
export const createClient = (commandOptions: Options, overridenOptions: StreamrClientConfig = {}): StreamrClient => {
|
|
31
|
+
const config = getClientConfig(commandOptions, overridenOptions)
|
|
32
32
|
const client = new StreamrClient(config)
|
|
33
33
|
addInterruptHandler(client)
|
|
34
34
|
return client
|
package/src/command.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { StreamrClientConfig } from 'streamr-client'
|
|
|
3
3
|
import pkg from '../package.json'
|
|
4
4
|
import { createClient } from './client'
|
|
5
5
|
|
|
6
|
+
export interface Options {
|
|
7
|
+
privateKey?: string
|
|
8
|
+
config?: string
|
|
9
|
+
dev: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
export const createCommand = (): commander.Command => {
|
|
7
13
|
return new Command()
|
|
8
14
|
.version(pkg.version)
|
|
@@ -25,11 +31,11 @@ export const createClientCommand = (
|
|
|
25
31
|
return createCommand()
|
|
26
32
|
.option('--private-key <key>', 'use an Ethereum private key to authenticate')
|
|
27
33
|
.option('--config <file>', 'read connection and authentication settings from a config file')
|
|
28
|
-
.option('--dev', 'use pre-defined development environment')
|
|
34
|
+
.option('--dev', 'use pre-defined development environment', false)
|
|
29
35
|
.action(async (...args: any[]) => {
|
|
30
|
-
const
|
|
36
|
+
const commandOptions = args[args.length - 1].opts()
|
|
31
37
|
try {
|
|
32
|
-
const client = createClient(
|
|
38
|
+
const client = createClient(commandOptions, opts.clientOptionsFactory!(commandOptions))
|
|
33
39
|
try {
|
|
34
40
|
await action(...[client].concat(args))
|
|
35
41
|
} finally {
|
package/src/common.ts
CHANGED
package/src/resend.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StreamrClient, ResendOptions } from 'streamr-client'
|
|
2
2
|
|
|
3
|
-
export const assertBothOrNoneDefined = (
|
|
4
|
-
option1:
|
|
5
|
-
option2:
|
|
3
|
+
export const assertBothOrNoneDefined = <T extends object>(
|
|
4
|
+
option1: keyof T,
|
|
5
|
+
option2: keyof T,
|
|
6
6
|
errorMessage: string,
|
|
7
|
-
commandOptions:
|
|
7
|
+
commandOptions: T
|
|
8
8
|
): void | never => {
|
|
9
9
|
if ((option1 in commandOptions && !(option2 in commandOptions)) || (option2 in commandOptions && !(option1 in commandOptions))) {
|
|
10
10
|
console.error(`option ${errorMessage}`)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { collect } from '@streamr/utils'
|
|
2
|
+
import 'jest-extended'
|
|
3
|
+
import { startCommand } from './utils'
|
|
4
|
+
|
|
5
|
+
describe('mock-data', () => {
|
|
6
|
+
|
|
7
|
+
it('generate', async () => {
|
|
8
|
+
const abortController = new AbortController()
|
|
9
|
+
const outputIterable = startCommand('mock-data generate', {
|
|
10
|
+
abortSignal: abortController.signal,
|
|
11
|
+
devEnvironment: false
|
|
12
|
+
})
|
|
13
|
+
const firstLine = (await collect(outputIterable, 1))[0]
|
|
14
|
+
abortController.abort()
|
|
15
|
+
const json = JSON.parse(firstLine)
|
|
16
|
+
expect(json).toBeObject()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
2
|
+
import 'jest-extended'
|
|
3
|
+
import { StreamID } from 'streamr-client'
|
|
4
|
+
import { DOCKER_DEV_STORAGE_NODE, createTestClient, runCommand } from './utils'
|
|
5
|
+
|
|
6
|
+
const isStored = async (streamId: StreamID): Promise<boolean> => {
|
|
7
|
+
const output = await runCommand(`storage-node list-streams ${DOCKER_DEV_STORAGE_NODE}`)
|
|
8
|
+
return output.join().includes(streamId)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('storage node', () => {
|
|
12
|
+
|
|
13
|
+
it('add and remove stream', async () => {
|
|
14
|
+
const privateKey = await fetchPrivateKeyWithGas()
|
|
15
|
+
const client = createTestClient(privateKey)
|
|
16
|
+
const stream = await client.createStream(`/${Date.now()}`)
|
|
17
|
+
await client.destroy()
|
|
18
|
+
await runCommand(`storage-node add-stream ${DOCKER_DEV_STORAGE_NODE} ${stream.id}`, {
|
|
19
|
+
privateKey
|
|
20
|
+
})
|
|
21
|
+
expect(await isStored(stream.id)).toBeTrue()
|
|
22
|
+
await runCommand(`storage-node remove-stream ${DOCKER_DEV_STORAGE_NODE} ${stream.id}`, {
|
|
23
|
+
privateKey
|
|
24
|
+
})
|
|
25
|
+
expect(await isStored(stream.id)).toBeFalse()
|
|
26
|
+
}, 80 * 1000)
|
|
27
|
+
|
|
28
|
+
it('list nodes', async () => {
|
|
29
|
+
const outputLines = await runCommand('storage-node list')
|
|
30
|
+
expect(outputLines.join()).toMatch(DOCKER_DEV_STORAGE_NODE.toLowerCase())
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Wallet } from '@ethersproject/wallet'
|
|
2
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
3
|
+
import { createTestClient, runCommand } from './utils'
|
|
4
|
+
|
|
5
|
+
describe('create stream', () => {
|
|
6
|
+
|
|
7
|
+
it('happy path', async () => {
|
|
8
|
+
const privateKey = await fetchPrivateKeyWithGas()
|
|
9
|
+
const address = new Wallet(privateKey).address.toLowerCase()
|
|
10
|
+
const path = `/${Date.now()}`
|
|
11
|
+
const streamId = `${address}${path}`
|
|
12
|
+
const outputLines = await runCommand(`stream create ${path}`, {
|
|
13
|
+
privateKey
|
|
14
|
+
})
|
|
15
|
+
const outputJson = JSON.parse(outputLines.join(''))
|
|
16
|
+
expect(outputJson).toMatchObject({
|
|
17
|
+
id: streamId,
|
|
18
|
+
partitions: 1
|
|
19
|
+
})
|
|
20
|
+
const client = createTestClient()
|
|
21
|
+
const stream = await client.getStream(streamId)
|
|
22
|
+
expect(stream.getMetadata().partitions).toBe(1)
|
|
23
|
+
await client.destroy()
|
|
24
|
+
}, 20 * 1000)
|
|
25
|
+
|
|
26
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { fetchPrivateKeyWithGas, randomEthereumAddress } from '@streamr/test-utils'
|
|
2
|
+
import 'jest-extended'
|
|
3
|
+
import { StreamPermission } from 'streamr-client'
|
|
4
|
+
import { createTestClient, runCommand } from './utils'
|
|
5
|
+
|
|
6
|
+
describe('permission', () => {
|
|
7
|
+
|
|
8
|
+
it('grant and revoke', async () => {
|
|
9
|
+
const privateKey = await fetchPrivateKeyWithGas()
|
|
10
|
+
const client = createTestClient(privateKey)
|
|
11
|
+
const stream = await client.createStream(`/${Date.now()}`)
|
|
12
|
+
const otherUser = randomEthereumAddress()
|
|
13
|
+
const hasPermission = () => client.hasPermission({
|
|
14
|
+
user: otherUser,
|
|
15
|
+
permission: StreamPermission.PUBLISH,
|
|
16
|
+
streamId: stream.id,
|
|
17
|
+
allowPublic: false
|
|
18
|
+
})
|
|
19
|
+
await runCommand(`stream grant-permission ${stream.id} ${otherUser} publish`, {
|
|
20
|
+
privateKey
|
|
21
|
+
})
|
|
22
|
+
expect(await hasPermission()).toBeTrue()
|
|
23
|
+
await runCommand(`stream revoke-permission ${stream.id} ${otherUser} publish`, {
|
|
24
|
+
privateKey
|
|
25
|
+
})
|
|
26
|
+
expect(await hasPermission()).toBeFalse()
|
|
27
|
+
await client.destroy()
|
|
28
|
+
}, 40 * 1000)
|
|
29
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Wallet } from '@ethersproject/wallet'
|
|
2
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
3
|
+
import { collect } from '@streamr/utils'
|
|
4
|
+
import { StreamPermission } from 'streamr-client'
|
|
5
|
+
import { createTestClient, runCommand, startCommand } from './utils'
|
|
6
|
+
|
|
7
|
+
describe('publish and subscribe', () => {
|
|
8
|
+
|
|
9
|
+
let publisherPrivateKey: string
|
|
10
|
+
let subscriberPrivateKey: string
|
|
11
|
+
let streamId: string
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
publisherPrivateKey = await fetchPrivateKeyWithGas()
|
|
15
|
+
subscriberPrivateKey = await fetchPrivateKeyWithGas()
|
|
16
|
+
const client = createTestClient(publisherPrivateKey)
|
|
17
|
+
const stream = await client.createStream(`/${Date.now()}`)
|
|
18
|
+
await stream.grantPermissions({
|
|
19
|
+
user: new Wallet(subscriberPrivateKey).address,
|
|
20
|
+
permissions: [StreamPermission.SUBSCRIBE]
|
|
21
|
+
})
|
|
22
|
+
streamId = stream.id
|
|
23
|
+
await client.destroy()
|
|
24
|
+
}, 40 * 1000)
|
|
25
|
+
|
|
26
|
+
function publishViaCliCommand() {
|
|
27
|
+
setImmediate(async () => {
|
|
28
|
+
await runCommand(`stream publish ${streamId}`, {
|
|
29
|
+
inputLines: [JSON.stringify({ foo: 123 })],
|
|
30
|
+
privateKey: publisherPrivateKey
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
it('happy path', async () => {
|
|
36
|
+
const subscriberAbortController = new AbortController()
|
|
37
|
+
const subscriberOutputIterable = startCommand(`stream subscribe ${streamId}`, {
|
|
38
|
+
privateKey: subscriberPrivateKey,
|
|
39
|
+
abortSignal: subscriberAbortController.signal
|
|
40
|
+
})
|
|
41
|
+
publishViaCliCommand()
|
|
42
|
+
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
43
|
+
subscriberAbortController.abort()
|
|
44
|
+
expect(JSON.parse(receivedMessage)).toEqual({
|
|
45
|
+
foo: 123
|
|
46
|
+
})
|
|
47
|
+
}, 40 * 1000)
|
|
48
|
+
|
|
49
|
+
it('raw subscription', async () => {
|
|
50
|
+
const subscriberAbortController = new AbortController()
|
|
51
|
+
const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --raw`, {
|
|
52
|
+
privateKey: subscriberPrivateKey,
|
|
53
|
+
abortSignal: subscriberAbortController.signal,
|
|
54
|
+
})
|
|
55
|
+
publishViaCliCommand()
|
|
56
|
+
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
57
|
+
subscriberAbortController.abort()
|
|
58
|
+
expect(receivedMessage).toMatch(/^[0-9a-fA-F]+$/)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('with metadata', async () => {
|
|
62
|
+
const subscriberAbortController = new AbortController()
|
|
63
|
+
const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --with-metadata`, {
|
|
64
|
+
privateKey: subscriberPrivateKey,
|
|
65
|
+
abortSignal: subscriberAbortController.signal,
|
|
66
|
+
})
|
|
67
|
+
publishViaCliCommand()
|
|
68
|
+
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
69
|
+
subscriberAbortController.abort()
|
|
70
|
+
expect(JSON.parse(receivedMessage)).toMatchObject({
|
|
71
|
+
message: {
|
|
72
|
+
foo: 123
|
|
73
|
+
},
|
|
74
|
+
metadata: {
|
|
75
|
+
streamId,
|
|
76
|
+
streamPartition: 0,
|
|
77
|
+
timestamp: expect.any(Number),
|
|
78
|
+
sequenceNumber: 0,
|
|
79
|
+
publisherId: '0x7e5f4552091a69125d5dfcb7b8c2659029395bdf',
|
|
80
|
+
msgChainId: expect.stringMatching(/[0-9a-zA-Z]+/)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
2
|
+
import range from 'lodash/range'
|
|
3
|
+
import { Message, Stream } from 'streamr-client'
|
|
4
|
+
import { DOCKER_DEV_STORAGE_NODE, createTestClient, runCommand } from './utils'
|
|
5
|
+
import { wait } from '@streamr/utils'
|
|
6
|
+
|
|
7
|
+
const parseJSONs = (lines: string[]): any[] => {
|
|
8
|
+
return lines.map((line) => JSON.parse(line))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('resend stream', () => {
|
|
12
|
+
|
|
13
|
+
let privateKey: string
|
|
14
|
+
let stream: Stream
|
|
15
|
+
const messages: Message[] = []
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
privateKey = await fetchPrivateKeyWithGas()
|
|
19
|
+
const client = createTestClient(privateKey)
|
|
20
|
+
stream = await client.createStream(`/${Date.now()}`)
|
|
21
|
+
await stream.addToStorageNode(DOCKER_DEV_STORAGE_NODE)
|
|
22
|
+
for (const msgId of range(10)) {
|
|
23
|
+
await wait(10) // to prevent duplicate timestamps (to make test assertions simpler)
|
|
24
|
+
const msg = await stream.publish({ msgId })
|
|
25
|
+
messages.push(msg)
|
|
26
|
+
}
|
|
27
|
+
await wait(1000)
|
|
28
|
+
await client.destroy()
|
|
29
|
+
}, 20 * 1000)
|
|
30
|
+
|
|
31
|
+
it('last', async () => {
|
|
32
|
+
const outputLines = await runCommand(`stream resend last 3 ${stream.id}`, {
|
|
33
|
+
privateKey
|
|
34
|
+
})
|
|
35
|
+
expect(parseJSONs(outputLines)).toEqual([
|
|
36
|
+
{ msgId: 7 },
|
|
37
|
+
{ msgId: 8 },
|
|
38
|
+
{ msgId: 9 }
|
|
39
|
+
])
|
|
40
|
+
}, 20 * 1000)
|
|
41
|
+
|
|
42
|
+
it('from', async () => {
|
|
43
|
+
const minTimestamp = new Date(messages[8].timestamp).toISOString()
|
|
44
|
+
const outputLines = await runCommand(`stream resend from ${minTimestamp} ${stream.id}`, {
|
|
45
|
+
privateKey
|
|
46
|
+
})
|
|
47
|
+
expect(parseJSONs(outputLines)).toEqual([
|
|
48
|
+
{ msgId: 8 },
|
|
49
|
+
{ msgId: 9 }
|
|
50
|
+
])
|
|
51
|
+
}, 20 * 1000)
|
|
52
|
+
|
|
53
|
+
it('range', async () => {
|
|
54
|
+
const minTimestamp = new Date(messages[2].timestamp).toISOString()
|
|
55
|
+
const maxTimestamp = new Date(messages[4].timestamp).toISOString()
|
|
56
|
+
const outputLines = await runCommand(`stream resend range ${minTimestamp} ${maxTimestamp} ${stream.id}`, {
|
|
57
|
+
privateKey
|
|
58
|
+
})
|
|
59
|
+
expect(parseJSONs(outputLines)).toEqual([
|
|
60
|
+
{ msgId: 2 },
|
|
61
|
+
{ msgId: 3 },
|
|
62
|
+
{ msgId: 4 }
|
|
63
|
+
])
|
|
64
|
+
}, 20 * 1000)
|
|
65
|
+
|
|
66
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
2
|
+
import { randomString } from '@streamr/utils'
|
|
3
|
+
import { createTestClient, runCommand } from './utils'
|
|
4
|
+
|
|
5
|
+
describe('search streams', () => {
|
|
6
|
+
|
|
7
|
+
it('happy path', async () => {
|
|
8
|
+
const testId = randomString(10)
|
|
9
|
+
const client = createTestClient(await fetchPrivateKeyWithGas())
|
|
10
|
+
const stream1 = await client.createStream(`/${testId}-1`)
|
|
11
|
+
const stream2 = await client.createStream(`/${testId}-2`)
|
|
12
|
+
await client.destroy()
|
|
13
|
+
const outputLines = await runCommand(`stream search ${testId}`)
|
|
14
|
+
expect(outputLines).toEqual([
|
|
15
|
+
stream1.id,
|
|
16
|
+
stream2.id
|
|
17
|
+
])
|
|
18
|
+
}, 20 * 1000)
|
|
19
|
+
|
|
20
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Wallet } from '@ethersproject/wallet'
|
|
2
|
+
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
3
|
+
import { createTestClient, runCommand } from './utils'
|
|
4
|
+
|
|
5
|
+
describe('show stream', () => {
|
|
6
|
+
|
|
7
|
+
it('happy path', async () => {
|
|
8
|
+
const creatorPrivateKey = await fetchPrivateKeyWithGas()
|
|
9
|
+
const client = createTestClient(creatorPrivateKey)
|
|
10
|
+
const stream = await client.createStream(`/${Date.now()}`)
|
|
11
|
+
await client.destroy()
|
|
12
|
+
const outputLines = await runCommand(`stream show ${stream.id} --include-permissions`)
|
|
13
|
+
const outputJson = JSON.parse(outputLines.join(''))
|
|
14
|
+
expect(outputJson).toMatchObject({
|
|
15
|
+
id: stream.id,
|
|
16
|
+
partitions: 1,
|
|
17
|
+
permissions: [{
|
|
18
|
+
permissions: [
|
|
19
|
+
'edit',
|
|
20
|
+
'delete',
|
|
21
|
+
'publish',
|
|
22
|
+
'subscribe',
|
|
23
|
+
'grant'
|
|
24
|
+
],
|
|
25
|
+
user: new Wallet(creatorPrivateKey).address.toLowerCase()
|
|
26
|
+
}]
|
|
27
|
+
})
|
|
28
|
+
}, 20 * 1000)
|
|
29
|
+
|
|
30
|
+
})
|
package/test/utils.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { collect } from '@streamr/utils'
|
|
2
|
+
import { spawn } from 'child_process'
|
|
3
|
+
import merge2 from 'merge2'
|
|
4
|
+
import { CONFIG_TEST, StreamrClient } from 'streamr-client'
|
|
5
|
+
|
|
6
|
+
export const DOCKER_DEV_STORAGE_NODE = '0xde1112f631486CfC759A50196853011528bC5FA0'
|
|
7
|
+
|
|
8
|
+
export interface StartCommandOptions {
|
|
9
|
+
privateKey?: string
|
|
10
|
+
devEnvironment?: boolean
|
|
11
|
+
inputLines?: string[]
|
|
12
|
+
abortSignal?: AbortSignal
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const runCommand = async (commandLine: string, opts?: StartCommandOptions): Promise<string[]> => {
|
|
16
|
+
const lines = startCommand(commandLine, opts)
|
|
17
|
+
return await collect(lines)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function* startCommand(commandLine: string, opts?: StartCommandOptions): AsyncGenerator<string> {
|
|
21
|
+
const args: string[] = ['dist/bin/streamr.js']
|
|
22
|
+
args.push(...commandLine.split(' '))
|
|
23
|
+
if (opts?.privateKey !== undefined) {
|
|
24
|
+
args.push('--private-key', opts.privateKey)
|
|
25
|
+
}
|
|
26
|
+
if (opts?.devEnvironment !== false) {
|
|
27
|
+
args.push('--dev')
|
|
28
|
+
}
|
|
29
|
+
const executable = spawn(`node`, args, {
|
|
30
|
+
signal: opts?.abortSignal,
|
|
31
|
+
env: {
|
|
32
|
+
PATH: process.env.PATH,
|
|
33
|
+
STREAMR_DOCKER_DEV_HOST: process.env.STREAMR_DOCKER_DEV_HOST
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
executable.on('error', (err: any) => {
|
|
37
|
+
// expected error when AbortSignal#abort is called
|
|
38
|
+
if (err.code !== 'ABORT_ERR') {
|
|
39
|
+
console.error(err)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
const outputs = merge2(executable.stdout, executable.stderr)
|
|
43
|
+
if (opts?.inputLines !== undefined) {
|
|
44
|
+
setImmediate(() => {
|
|
45
|
+
executable.stdin.write(opts.inputLines!.join('\n') + '\n')
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
yield* lines(outputs[Symbol.asyncIterator]())
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function* lines(src: AsyncIterable<Buffer>): AsyncGenerator<string, any, any> {
|
|
52
|
+
let buffer = ''
|
|
53
|
+
for await (const chunk of src) {
|
|
54
|
+
buffer += chunk.toString('utf-8')
|
|
55
|
+
while (true) {
|
|
56
|
+
const delimeterPos = buffer.indexOf('\n')
|
|
57
|
+
if (delimeterPos === -1) {
|
|
58
|
+
break
|
|
59
|
+
}
|
|
60
|
+
const line = buffer.substring(0, delimeterPos)
|
|
61
|
+
yield line
|
|
62
|
+
buffer = buffer.substring(delimeterPos + 1)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (buffer !== '') {
|
|
66
|
+
yield buffer
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const createTestClient = (privateKey?: string): StreamrClient => {
|
|
71
|
+
return new StreamrClient({
|
|
72
|
+
...CONFIG_TEST,
|
|
73
|
+
auth: (privateKey !== undefined) ? { privateKey } : undefined
|
|
74
|
+
})
|
|
75
|
+
}
|