@flowcore/cli 2.7.0 → 2.8.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 +7 -0
- package/README.md +4 -4
- package/dist/commands/stream.js +15 -6
- package/oclif.manifest.json +2 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
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.8.0](https://github.com/flowcore-io/flowcore-cli/compare/v2.7.0...v2.8.0) (2024-02-24)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add now option to start arg to start streaming from now ([8070602](https://github.com/flowcore-io/flowcore-cli/commit/80706025d0a3ce0c9a0e57294d39eb530b34d3f9))
|
|
19
|
+
|
|
13
20
|
## [2.7.0](https://github.com/flowcore-io/flowcore-cli/compare/v2.6.0...v2.7.0) (2024-02-22)
|
|
14
21
|
|
|
15
22
|
|
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.8.0 linux-x64 node-v20.11.1
|
|
22
22
|
$ flowcore --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ flowcore COMMAND
|
|
@@ -75,7 +75,7 @@ EXAMPLES
|
|
|
75
75
|
$ flowcore apply -f ./path/to/manifest.yml
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
_See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.
|
|
78
|
+
_See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.8.0/src/commands/apply.ts)_
|
|
79
79
|
|
|
80
80
|
## `flowcore autocomplete [SHELL]`
|
|
81
81
|
|
|
@@ -736,7 +736,7 @@ FLAGS
|
|
|
736
736
|
-l, --[no-]live Change to live mode when reaching last time bucket
|
|
737
737
|
-o, --output=<option> [default: http] Output format
|
|
738
738
|
<options: http|log>
|
|
739
|
-
-s, --start=<value> Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h)
|
|
739
|
+
-s, --start=<value> Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h, now)
|
|
740
740
|
-t, --timeout=<value> [default: 5000] Timeout in milliseconds to wait for a response from the destination
|
|
741
741
|
--profile=<value> Specify the configuration profile to use
|
|
742
742
|
|
|
@@ -753,7 +753,7 @@ EXAMPLES
|
|
|
753
753
|
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m
|
|
754
754
|
```
|
|
755
755
|
|
|
756
|
-
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.
|
|
756
|
+
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.8.0/src/commands/stream.ts)_
|
|
757
757
|
|
|
758
758
|
## `flowcore version`
|
|
759
759
|
|
package/dist/commands/stream.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Queue } from "@datastructures-js/queue";
|
|
2
2
|
import { BaseCommand, LOGIN_CODES, ValidateLogin } from "@flowcore/cli-plugin-config";
|
|
3
3
|
import { Args, Flags, ux } from '@oclif/core';
|
|
4
|
+
import { TimeUuid } from "cassandra-uuid";
|
|
4
5
|
import dayjs from "dayjs";
|
|
5
6
|
import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
|
|
6
7
|
import utc from "dayjs/plugin/utc.js";
|
|
@@ -32,7 +33,7 @@ export default class Stream extends BaseCommand {
|
|
|
32
33
|
live: Flags.boolean({ allowNo: true, char: 'l', default: true, description: 'Change to live mode when reaching last time bucket' }),
|
|
33
34
|
output: Flags.string({ char: 'o', default: 'http', description: 'Output format', options: ['http', 'log'] }),
|
|
34
35
|
scan: Flags.boolean({ char: 'c', default: false, description: 'Scan the full time range' }),
|
|
35
|
-
start: Flags.string({ char: 's', description: 'Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h)' }),
|
|
36
|
+
start: Flags.string({ char: 's', description: 'Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h, now)' }),
|
|
36
37
|
timeout: Flags.integer({ char: 't', default: 5000, description: 'Timeout in milliseconds to wait for a response from the destination' }),
|
|
37
38
|
};
|
|
38
39
|
async run() {
|
|
@@ -84,11 +85,17 @@ export default class Stream extends BaseCommand {
|
|
|
84
85
|
dataCoreId,
|
|
85
86
|
});
|
|
86
87
|
let firstTimeBucket = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => eventTypes.includes(e.name))?.catalog.range.firstTimeBucket;
|
|
88
|
+
let afterEventId;
|
|
87
89
|
if (!firstTimeBucket && !flags.start) {
|
|
88
90
|
firstTimeBucket = createTimebucket(dayjs());
|
|
89
91
|
!this.flags.json && this.warn(`First time bucket not found, setting to current time (${ux.colorize("yellowBright", firstTimeBucket)})`);
|
|
90
92
|
}
|
|
91
|
-
if (flags.start) {
|
|
93
|
+
if (flags.start === "now") {
|
|
94
|
+
afterEventId = TimeUuid.now();
|
|
95
|
+
firstTimeBucket = createTimebucket(dayjs());
|
|
96
|
+
!this.flags.json && this.log(ux.colorize("green", `Setting first time bucket and event id to now (${ux.colorize("yellowBright", firstTimeBucket)}), (${ux.colorize("yellowBright", afterEventId)})`));
|
|
97
|
+
}
|
|
98
|
+
else if (flags.start) {
|
|
92
99
|
firstTimeBucket = this.setTimeBucket(dayjs(), flags.start);
|
|
93
100
|
!this.flags.json && this.log(ux.colorize("green", `Setting first time bucket to ${ux.colorize("yellow", flags.start)} ago (${ux.colorize("yellowBright", firstTimeBucket)})`));
|
|
94
101
|
}
|
|
@@ -96,7 +103,9 @@ export default class Stream extends BaseCommand {
|
|
|
96
103
|
firstTimeBucket = this.setTimeBucket(dayjs(), "1d");
|
|
97
104
|
!this.flags.json && this.log(ux.colorize("green", `Setting first time bucket to ${ux.colorize("yellow", "1d")} ago (${ux.colorize("yellowBright", firstTimeBucket)})`));
|
|
98
105
|
}
|
|
99
|
-
let lastTimeBucket =
|
|
106
|
+
let lastTimeBucket = flags.start === "now"
|
|
107
|
+
? firstTimeBucket
|
|
108
|
+
: eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => eventTypes.includes(e.name))?.catalog.range.lastTimeBucket;
|
|
100
109
|
if (!lastTimeBucket) {
|
|
101
110
|
lastTimeBucket = createTimebucket(dayjs());
|
|
102
111
|
!this.flags.json && this.warn(`Last time bucket not found, setting to current time (${ux.colorize("yellowBright", lastTimeBucket)})`);
|
|
@@ -104,7 +113,7 @@ export default class Stream extends BaseCommand {
|
|
|
104
113
|
const observer = new Subject();
|
|
105
114
|
!this.flags.json && this.log(ux.colorize("blackBright", `Starting to stream events for ${dataCoreId} - ${aggregator} - ${eventTypes}, press ${ux.colorize("whiteBright", "ctrl+c")} to stop`));
|
|
106
115
|
// eslint-disable-next-line no-void
|
|
107
|
-
void this.streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, flags.live);
|
|
116
|
+
void this.streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, flags.live, afterEventId);
|
|
108
117
|
await this.processEvents(observer, flags.destination, flags.output, flags.header);
|
|
109
118
|
}
|
|
110
119
|
calculateBuckets(timediff, startTimeBucket) {
|
|
@@ -251,11 +260,11 @@ export default class Stream extends BaseCommand {
|
|
|
251
260
|
}
|
|
252
261
|
}
|
|
253
262
|
}
|
|
254
|
-
async streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, live) {
|
|
263
|
+
async streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, live, afterEventId) {
|
|
255
264
|
const startTimeBucket = dayjs(firstTimeBucket, TIME_BUCKET_HOUR_PATTERN);
|
|
256
265
|
const currentTime = dayjs.utc();
|
|
257
266
|
let liveMode = false;
|
|
258
|
-
let lastEventId = null;
|
|
267
|
+
let lastEventId = afterEventId ?? null;
|
|
259
268
|
const timediff = this.calculateTimeDifferenceInHours(lastTimeBucket, startTimeBucket, firstTimeBucket);
|
|
260
269
|
let timeBuckets = [];
|
|
261
270
|
timeBuckets = this.flags.scan ? this.calculateBuckets(timediff, startTimeBucket) : (await this.fetchTimeBuckets(dataCoreId, aggregator, eventTypes, startTimeBucket, lastTimeBucket, graphqlClient));
|
package/oclif.manifest.json
CHANGED
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
},
|
|
126
126
|
"start": {
|
|
127
127
|
"char": "s",
|
|
128
|
-
"description": "Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h)",
|
|
128
|
+
"description": "Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h, now)",
|
|
129
129
|
"name": "start",
|
|
130
130
|
"hasDynamicHelp": false,
|
|
131
131
|
"multiple": false,
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
]
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
|
-
"version": "2.
|
|
160
|
+
"version": "2.8.0"
|
|
161
161
|
}
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@oclif/plugin-plugins": "^4",
|
|
17
17
|
"@oclif/plugin-version": "^2.0.8",
|
|
18
18
|
"axios": "^1.6.2",
|
|
19
|
+
"cassandra-uuid": "^0.1.0",
|
|
19
20
|
"cross-fetch": "^4.0.0",
|
|
20
21
|
"dayjs": "^1.11.10",
|
|
21
22
|
"enquirer": "^2.4.1",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"prestart": "npm run build",
|
|
90
91
|
"update-schema": "rover graph introspect https://graph.api.staging.flowcore.io/graphql -o schema.gql"
|
|
91
92
|
},
|
|
92
|
-
"version": "2.
|
|
93
|
+
"version": "2.8.0",
|
|
93
94
|
"bugs": "https://github.com/flowcore-io/flowcore-cli/issues",
|
|
94
95
|
"keywords": [
|
|
95
96
|
"flowcore",
|