@flowcore/cli 2.5.1 → 2.6.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 +14 -0
- package/README.md +8 -7
- package/dist/commands/stream.d.ts +1 -0
- package/dist/commands/stream.js +15 -2
- package/oclif.manifest.json +10 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
* added description to start that includes week ([58687a7](https://github.com/flowcore-io/flowcore-cli/commit/58687a7bbb66aaa5d6da26af88e555cbb1e72467))
|
|
12
12
|
|
|
13
|
+
## [2.6.0](https://github.com/flowcore-io/flowcore-cli/compare/v2.5.2...v2.6.0) (2024-02-22)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add option to add headers to stream ([41f88f3](https://github.com/flowcore-io/flowcore-cli/commit/41f88f39f53c233705507e7b3ece8bbf346b76e2))
|
|
19
|
+
|
|
20
|
+
## [2.5.2](https://github.com/flowcore-io/flowcore-cli/compare/v2.5.1...v2.5.2) (2024-02-22)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* update flowcore/cli version to 2.5.1 and flowcore/cli-plugin-scenario version to 2.3.0 ([10d2c34](https://github.com/flowcore-io/flowcore-cli/commit/10d2c346a005a8e707f85ec5bf0772ae283927c0))
|
|
26
|
+
|
|
13
27
|
## [2.5.1](https://github.com/flowcore-io/flowcore-cli/compare/v2.5.0...v2.5.1) (2024-02-21)
|
|
14
28
|
|
|
15
29
|
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g @flowcore/cli
|
|
|
18
18
|
$ flowcore COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ flowcore (--version)
|
|
21
|
-
@flowcore/cli/2.
|
|
21
|
+
@flowcore/cli/2.6.0 linux-x64 node-v20.11.1
|
|
22
22
|
$ flowcore --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ flowcore COMMAND
|
|
@@ -70,7 +70,7 @@ EXAMPLES
|
|
|
70
70
|
$ flowcore apply -f ./path/to/manifest.yml
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
_See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.
|
|
73
|
+
_See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.6.0/src/commands/apply.ts)_
|
|
74
74
|
|
|
75
75
|
## `flowcore autocomplete [SHELL]`
|
|
76
76
|
|
|
@@ -532,7 +532,7 @@ EXAMPLES
|
|
|
532
532
|
$ cat <<EOF | flowcore scenario apply -f -
|
|
533
533
|
```
|
|
534
534
|
|
|
535
|
-
_See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.
|
|
535
|
+
_See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.3.0/src/commands/scenario/apply.ts)_
|
|
536
536
|
|
|
537
537
|
## `flowcore scenario local`
|
|
538
538
|
|
|
@@ -562,7 +562,7 @@ EXAMPLES
|
|
|
562
562
|
$ cat <<EOF | flowcore scenario local -f -
|
|
563
563
|
```
|
|
564
564
|
|
|
565
|
-
_See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.
|
|
565
|
+
_See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.3.0/src/commands/scenario/local.ts)_
|
|
566
566
|
|
|
567
567
|
## `flowcore stream STREAM`
|
|
568
568
|
|
|
@@ -570,13 +570,14 @@ Stream events from a datacore running on the Flowcore Platform
|
|
|
570
570
|
|
|
571
571
|
```
|
|
572
572
|
USAGE
|
|
573
|
-
$ flowcore stream STREAM [--profile <value>] [-d <value>] [-j] [-l] [-o http|log] [-c] [-s
|
|
574
|
-
<value>]
|
|
573
|
+
$ flowcore stream STREAM [--profile <value>] [-d <value>] [-H <value>] [-j] [-l] [-o http|log] [-c] [-s
|
|
574
|
+
<value>] [-t <value>]
|
|
575
575
|
|
|
576
576
|
ARGUMENTS
|
|
577
577
|
STREAM stream url to connect to
|
|
578
578
|
|
|
579
579
|
FLAGS
|
|
580
|
+
-H, --header=<value>... [default: ] header to send with the request, example: (-H 'Authorization: Bearer TOKEN')
|
|
580
581
|
-c, --scan Scan the full time range
|
|
581
582
|
-d, --destination=<value> [default: http://localhost:3000/transform] Destination to send events to
|
|
582
583
|
-j, --json Output json only
|
|
@@ -600,7 +601,7 @@ EXAMPLES
|
|
|
600
601
|
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m
|
|
601
602
|
```
|
|
602
603
|
|
|
603
|
-
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.
|
|
604
|
+
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.6.0/src/commands/stream.ts)_
|
|
604
605
|
|
|
605
606
|
## `flowcore version`
|
|
606
607
|
|
|
@@ -7,6 +7,7 @@ export default class Stream extends BaseCommand<typeof Stream> {
|
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
9
|
destination: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
header: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[], import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
11
|
json: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
11
12
|
live: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
13
|
output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
package/dist/commands/stream.js
CHANGED
|
@@ -27,6 +27,7 @@ export default class Stream extends BaseCommand {
|
|
|
27
27
|
];
|
|
28
28
|
static flags = {
|
|
29
29
|
destination: Flags.string({ char: 'd', default: "http://localhost:3000/transform", description: 'Destination to send events to' }),
|
|
30
|
+
header: Flags.string({ char: 'H', default: [], description: 'header to send with the request, example: (-H \'Authorization: Bearer TOKEN\')', multiple: true }),
|
|
30
31
|
json: Flags.boolean({ char: 'j', description: 'Output json only' }),
|
|
31
32
|
live: Flags.boolean({ allowNo: true, char: 'l', default: true, description: 'Change to live mode when reaching last time bucket' }),
|
|
32
33
|
output: Flags.string({ char: 'o', default: 'http', description: 'Output format', options: ['http', 'log'] }),
|
|
@@ -36,6 +37,12 @@ export default class Stream extends BaseCommand {
|
|
|
36
37
|
};
|
|
37
38
|
async run() {
|
|
38
39
|
const { args, flags } = await this.parse(Stream);
|
|
40
|
+
for (const header of flags.header) {
|
|
41
|
+
const parts = header.split(": ");
|
|
42
|
+
if (parts.length !== 2) {
|
|
43
|
+
ux.error(`Invalid header: ${header}. (correct example: -H 'X-Custom-Header: some value')`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
const parts = args.STREAM.replace(/https?:\/\//i, "").split("/");
|
|
40
47
|
if (parts.length !== 5) {
|
|
41
48
|
ux.error(`Invalid stream url, ${args.STREAM}`);
|
|
@@ -98,7 +105,7 @@ export default class Stream extends BaseCommand {
|
|
|
98
105
|
!this.flags.json && this.log(ux.colorize("blackBright", `Starting to stream events for ${dataCoreId} - ${aggregator} - ${eventTypes}, press ${ux.colorize("whiteBright", "ctrl+c")} to stop`));
|
|
99
106
|
// eslint-disable-next-line no-void
|
|
100
107
|
void this.streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, flags.live);
|
|
101
|
-
await this.processEvents(observer, flags.destination, flags.output);
|
|
108
|
+
await this.processEvents(observer, flags.destination, flags.output, flags.header);
|
|
102
109
|
}
|
|
103
110
|
calculateBuckets(timediff, startTimeBucket) {
|
|
104
111
|
return _.times(timediff + 1, (n) => dayjs(startTimeBucket).add(n, "hour").format(TIME_BUCKET_PATTERN));
|
|
@@ -149,7 +156,7 @@ export default class Stream extends BaseCommand {
|
|
|
149
156
|
}
|
|
150
157
|
return timeBuckets;
|
|
151
158
|
}
|
|
152
|
-
async processEvents(observer, destination, output) {
|
|
159
|
+
async processEvents(observer, destination, output, header = []) {
|
|
153
160
|
let done = false;
|
|
154
161
|
let events = [];
|
|
155
162
|
const warn = this.flags.json ? () => { } : this.warn.bind(this);
|
|
@@ -181,11 +188,17 @@ export default class Stream extends BaseCommand {
|
|
|
181
188
|
}
|
|
182
189
|
!this.flags.json && this.log(`Sending event to ${destination}: ${event.eventId}`);
|
|
183
190
|
try {
|
|
191
|
+
const headers = {};
|
|
192
|
+
for (const h of header) {
|
|
193
|
+
const [name, value] = h.split(": ");
|
|
194
|
+
headers[name] = value;
|
|
195
|
+
}
|
|
184
196
|
// eslint-disable-next-line no-await-in-loop
|
|
185
197
|
const result = await Promise.race([fetch(destination, {
|
|
186
198
|
body: JSON.stringify(event),
|
|
187
199
|
headers: {
|
|
188
200
|
"Content-Type": "application/json",
|
|
201
|
+
...headers,
|
|
189
202
|
},
|
|
190
203
|
method: "POST",
|
|
191
204
|
}),
|
package/oclif.manifest.json
CHANGED
|
@@ -80,6 +80,15 @@
|
|
|
80
80
|
"multiple": false,
|
|
81
81
|
"type": "option"
|
|
82
82
|
},
|
|
83
|
+
"header": {
|
|
84
|
+
"char": "H",
|
|
85
|
+
"description": "header to send with the request, example: (-H 'Authorization: Bearer TOKEN')",
|
|
86
|
+
"name": "header",
|
|
87
|
+
"default": [],
|
|
88
|
+
"hasDynamicHelp": false,
|
|
89
|
+
"multiple": true,
|
|
90
|
+
"type": "option"
|
|
91
|
+
},
|
|
83
92
|
"json": {
|
|
84
93
|
"char": "j",
|
|
85
94
|
"description": "Output json only",
|
|
@@ -148,5 +157,5 @@
|
|
|
148
157
|
]
|
|
149
158
|
}
|
|
150
159
|
},
|
|
151
|
-
"version": "2.
|
|
160
|
+
"version": "2.6.0"
|
|
152
161
|
}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"@datastructures-js/queue": "^4.2.3",
|
|
8
8
|
"@flowcore/cli-plugin-config": "^1.0.5",
|
|
9
9
|
"@flowcore/cli-plugin-data-core": "^2.0.0",
|
|
10
|
-
"@flowcore/cli-plugin-scenario": "^2.
|
|
10
|
+
"@flowcore/cli-plugin-scenario": "^2.3.0",
|
|
11
11
|
"@flowcore/time-bucket": "^1.1.0",
|
|
12
12
|
"@oclif/core": "^3",
|
|
13
13
|
"@oclif/plugin-autocomplete": "^3.0.2",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"prestart": "npm run build",
|
|
90
90
|
"update-schema": "rover graph introspect https://graph.api.staging.flowcore.io/graphql -o schema.gql"
|
|
91
91
|
},
|
|
92
|
-
"version": "2.
|
|
92
|
+
"version": "2.6.0",
|
|
93
93
|
"bugs": "https://github.com/flowcore-io/flowcore-cli/issues",
|
|
94
94
|
"keywords": [
|
|
95
95
|
"flowcore",
|