@flowcore/cli 1.1.1 → 1.2.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
CHANGED
|
@@ -7,6 +7,20 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
## [1.2.0](https://github.com/flowcore-io/flowcore-cli/compare/v1.1.2...v1.2.0) (2024-01-09)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* added multiple events, added weeks functionality to start time ([9a2f8cc](https://github.com/flowcore-io/flowcore-cli/commit/9a2f8cc5e4c5dd885f5cab6c3fbd886caf6b482d))
|
|
16
|
+
|
|
17
|
+
## [1.1.2](https://github.com/flowcore-io/flowcore-cli/compare/v1.1.1...v1.1.2) (2024-01-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* removed extra log ([8c877c5](https://github.com/flowcore-io/flowcore-cli/commit/8c877c5dbbf1e4938dca7702f5652b634b08f3ef))
|
|
23
|
+
|
|
10
24
|
## [1.1.1](https://github.com/flowcore-io/flowcore-cli/compare/v1.1.0...v1.1.1) (2024-01-09)
|
|
11
25
|
|
|
12
26
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @flowcore/cli
|
|
|
17
17
|
$ flowcore COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ flowcore (--version)
|
|
20
|
-
@flowcore/cli/1.
|
|
20
|
+
@flowcore/cli/1.2.0 linux-x64 node-v20.10.0
|
|
21
21
|
$ flowcore --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ flowcore COMMAND
|
|
@@ -103,7 +103,7 @@ EXAMPLES
|
|
|
103
103
|
$ flowcore config set -l https://auth.flowcore.io/realms/flowcore/.well-known/openid-configuration -c my-client-id -p
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
_See code: [src/commands/config/set.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.
|
|
106
|
+
_See code: [src/commands/config/set.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.2.0/src/commands/config/set.ts)_
|
|
107
107
|
|
|
108
108
|
## `flowcore config show`
|
|
109
109
|
|
|
@@ -123,7 +123,7 @@ EXAMPLES
|
|
|
123
123
|
$ flowcore config show
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
_See code: [src/commands/config/show.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.
|
|
126
|
+
_See code: [src/commands/config/show.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.2.0/src/commands/config/show.ts)_
|
|
127
127
|
|
|
128
128
|
## `flowcore help [COMMANDS]`
|
|
129
129
|
|
|
@@ -166,7 +166,7 @@ EXAMPLES
|
|
|
166
166
|
$ flowcore login --port 8080
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
_See code: [src/commands/login.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.
|
|
169
|
+
_See code: [src/commands/login.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.2.0/src/commands/login.ts)_
|
|
170
170
|
|
|
171
171
|
## `flowcore plugins`
|
|
172
172
|
|
|
@@ -467,10 +467,16 @@ DESCRIPTION
|
|
|
467
467
|
Stream events from a datacore running on the Flowcore Platform
|
|
468
468
|
|
|
469
469
|
EXAMPLES
|
|
470
|
-
$ flowcore stream https://
|
|
470
|
+
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream
|
|
471
|
+
|
|
472
|
+
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -s 1y
|
|
473
|
+
|
|
474
|
+
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -o log -s 3m --json > some.json
|
|
475
|
+
|
|
476
|
+
$ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m
|
|
471
477
|
```
|
|
472
478
|
|
|
473
|
-
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.
|
|
479
|
+
_See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.2.0/src/commands/stream.ts)_
|
|
474
480
|
|
|
475
481
|
## `flowcore version`
|
|
476
482
|
|
|
@@ -507,5 +513,5 @@ DESCRIPTION
|
|
|
507
513
|
Check what user you are logged in as
|
|
508
514
|
```
|
|
509
515
|
|
|
510
|
-
_See code: [src/commands/whoami.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.
|
|
516
|
+
_See code: [src/commands/whoami.ts](https://github.com/flowcore-io/flowcore-cli/blob/v1.2.0/src/commands/whoami.ts)_
|
|
511
517
|
<!-- commandsstop -->
|
package/dist/commands/stream.js
CHANGED
|
@@ -19,7 +19,10 @@ export default class Stream extends BaseCommand {
|
|
|
19
19
|
};
|
|
20
20
|
static description = 'Stream events from a datacore running on the Flowcore Platform';
|
|
21
21
|
static examples = [
|
|
22
|
-
'<%= config.bin %> <%= command.id %> https://
|
|
22
|
+
'<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -s 1y',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -o log -s 3m --json > some.json',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m',
|
|
23
26
|
];
|
|
24
27
|
static flags = {
|
|
25
28
|
destination: Flags.string({ char: 'd', default: "http://localhost:3000/transform", description: 'Destination to send events to' }),
|
|
@@ -53,7 +56,7 @@ export default class Stream extends BaseCommand {
|
|
|
53
56
|
const org = parts[1];
|
|
54
57
|
const dataCore = parts[2];
|
|
55
58
|
const aggregator = parts[3];
|
|
56
|
-
const
|
|
59
|
+
const eventTypes = parts[4].replace(/\.stream$/i, "").replace("[", "").replace("]", "").split(",");
|
|
57
60
|
const fetchDataCoreResponse = await graphqlClient.client.request(FETCH_DATA_CORE_GQL_QUERY, {
|
|
58
61
|
dataCore,
|
|
59
62
|
organization: org,
|
|
@@ -63,7 +66,7 @@ export default class Stream extends BaseCommand {
|
|
|
63
66
|
aggregator,
|
|
64
67
|
dataCoreId,
|
|
65
68
|
});
|
|
66
|
-
let firstTimeBucket = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => e.name
|
|
69
|
+
let firstTimeBucket = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => eventTypes.includes(e.name))?.catalog.range.firstTimeBucket;
|
|
67
70
|
if (!firstTimeBucket && !flags.start) {
|
|
68
71
|
firstTimeBucket = createTimebucket(dayjs());
|
|
69
72
|
!this.flags.json && this.warn(`First time bucket not found, setting to current time (${ux.colorize("yellowBright", firstTimeBucket)})`);
|
|
@@ -76,15 +79,15 @@ export default class Stream extends BaseCommand {
|
|
|
76
79
|
firstTimeBucket = this.setTimeBucket(dayjs(), "1d");
|
|
77
80
|
!this.flags.json && this.log(ux.colorize("green", `Setting first time bucket to ${ux.colorize("yellow", "1d")} ago (${ux.colorize("yellowBright", firstTimeBucket)})`));
|
|
78
81
|
}
|
|
79
|
-
let lastTimeBucket = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => e.name
|
|
82
|
+
let lastTimeBucket = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => eventTypes.includes(e.name))?.catalog.range.lastTimeBucket;
|
|
80
83
|
if (!lastTimeBucket) {
|
|
81
84
|
lastTimeBucket = createTimebucket(dayjs());
|
|
82
85
|
!this.flags.json && this.warn(`Last time bucket not found, setting to current time (${ux.colorize("yellowBright", lastTimeBucket)})`);
|
|
83
86
|
}
|
|
84
87
|
const observer = new Subject();
|
|
85
|
-
!this.flags.json && this.log(ux.colorize("blackBright", `Starting to stream events for ${dataCoreId} - ${aggregator} - ${
|
|
88
|
+
!this.flags.json && this.log(ux.colorize("blackBright", `Starting to stream events for ${dataCoreId} - ${aggregator} - ${eventTypes}, press ${ux.colorize("whiteBright", "ctrl+c")} to stop`));
|
|
86
89
|
// eslint-disable-next-line no-void
|
|
87
|
-
void this.streamEvents(dataCoreId, aggregator,
|
|
90
|
+
void this.streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, flags.live);
|
|
88
91
|
await this.processEvents(observer, flags.destination, flags.output);
|
|
89
92
|
}
|
|
90
93
|
async processEvents(observer, destination, output) {
|
|
@@ -111,23 +114,23 @@ export default class Stream extends BaseCommand {
|
|
|
111
114
|
while (!processingQueue.isEmpty()) {
|
|
112
115
|
const event = processingQueue.dequeue();
|
|
113
116
|
if (output === "log") {
|
|
114
|
-
ux.info(JSON.stringify(event));
|
|
115
117
|
this.flags.json ? this.log(JSON.stringify({
|
|
116
118
|
event,
|
|
117
119
|
type: "input",
|
|
118
120
|
}, null, 2)) : this.log(JSON.stringify(event));
|
|
119
121
|
continue;
|
|
120
122
|
}
|
|
121
|
-
this.log(`Sending event to ${destination}: ${event.eventId}`);
|
|
123
|
+
!this.flags.json && this.log(`Sending event to ${destination}: ${event.eventId}`);
|
|
122
124
|
try {
|
|
123
125
|
// eslint-disable-next-line no-await-in-loop
|
|
124
|
-
const result = await fetch(destination, {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
const result = await Promise.race([fetch(destination, {
|
|
127
|
+
body: JSON.stringify(event),
|
|
128
|
+
headers: {
|
|
129
|
+
"Content-Type": "application/json",
|
|
130
|
+
},
|
|
131
|
+
method: "POST",
|
|
132
|
+
}),
|
|
133
|
+
new Promise((resolve, reject) => { setTimeout(() => reject(new Error("Timeout waiting for response")), 5000); }),]);
|
|
131
134
|
if (!result.ok) {
|
|
132
135
|
!this.flags.json && this.warn(`Error sending event to ${destination}: ${result.statusText}`);
|
|
133
136
|
}
|
|
@@ -162,6 +165,9 @@ export default class Stream extends BaseCommand {
|
|
|
162
165
|
case "m": {
|
|
163
166
|
return createTimebucket(date.subtract(Number.parseInt(parts[1], 10), "month"));
|
|
164
167
|
}
|
|
168
|
+
case "w": {
|
|
169
|
+
return createTimebucket(date.subtract(Number.parseInt(parts[1], 10), "week"));
|
|
170
|
+
}
|
|
165
171
|
case "d": {
|
|
166
172
|
return createTimebucket(date.subtract(Number.parseInt(parts[1], 10), "day"));
|
|
167
173
|
}
|
|
@@ -173,7 +179,7 @@ export default class Stream extends BaseCommand {
|
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
|
-
async streamEvents(dataCoreId, aggregator,
|
|
182
|
+
async streamEvents(dataCoreId, aggregator, eventTypes, firstTimeBucket, lastTimeBucket, graphqlClient, observer, live) {
|
|
177
183
|
let startTimeBucket = dayjs(firstTimeBucket, TIME_BUCKET_HOUR_PATTERN);
|
|
178
184
|
const currentTime = dayjs.utc();
|
|
179
185
|
let liveMode = false;
|
|
@@ -198,7 +204,7 @@ export default class Stream extends BaseCommand {
|
|
|
198
204
|
afterEventId: lastEventId || undefined,
|
|
199
205
|
aggregator,
|
|
200
206
|
dataCoreId,
|
|
201
|
-
|
|
207
|
+
eventTypes,
|
|
202
208
|
timeBucket,
|
|
203
209
|
});
|
|
204
210
|
cursor = response.datacore.fetchEvents.cursor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { gql } from "graphql-request";
|
|
2
2
|
export const FETCH_EVENTS_GQL_QUERY = gql `
|
|
3
|
-
query FLOWCORE_CLI_FETCH_EVENTS($dataCoreId: ID!, $aggregator: String!, $
|
|
3
|
+
query FLOWCORE_CLI_FETCH_EVENTS($dataCoreId: ID!, $aggregator: String!, $eventTypes: [String!]!, $timeBucket: String!, $cursor: String, $afterEventId: String, $beforeEventId: String, $pageSize: Int) {
|
|
4
4
|
datacore(search: {id: $dataCoreId}) {
|
|
5
5
|
fetchEvents(input: {
|
|
6
6
|
aggregator: $aggregator,
|
|
7
|
-
eventTypes:
|
|
7
|
+
eventTypes: $eventTypes,
|
|
8
8
|
timeBucket: $timeBucket
|
|
9
9
|
cursor: $cursor
|
|
10
10
|
afterEventId: $afterEventId
|
package/oclif.manifest.json
CHANGED
|
@@ -52,7 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"description": "Stream events from a datacore running on the Flowcore Platform",
|
|
54
54
|
"examples": [
|
|
55
|
-
"<%= config.bin %> <%= command.id %> https://
|
|
55
|
+
"<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream",
|
|
56
|
+
"<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -s 1y",
|
|
57
|
+
"<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/<event type>.stream -o log -s 3m --json > some.json",
|
|
58
|
+
"<%= config.bin %> <%= command.id %> https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m"
|
|
56
59
|
],
|
|
57
60
|
"flags": {
|
|
58
61
|
"profile": {
|
|
@@ -256,5 +259,5 @@
|
|
|
256
259
|
]
|
|
257
260
|
}
|
|
258
261
|
},
|
|
259
|
-
"version": "1.
|
|
262
|
+
"version": "1.2.0"
|
|
260
263
|
}
|
package/package.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"prestart": "npm run build",
|
|
87
87
|
"update-schema": "rover graph introspect https://graph.api.staging.flowcore.io/graphql -o schema.gql"
|
|
88
88
|
},
|
|
89
|
-
"version": "1.
|
|
89
|
+
"version": "1.2.0",
|
|
90
90
|
"bugs": "https://github.com/flowcore-io/flowcore-cli/issues",
|
|
91
91
|
"keywords": [
|
|
92
92
|
"flowcore",
|