@flowcore/cli 2.6.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 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.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
+
20
+ ## [2.7.0](https://github.com/flowcore-io/flowcore-cli/compare/v2.6.0...v2.7.0) (2024-02-22)
21
+
22
+
23
+ ### Features
24
+
25
+ * add generate manifest commands for scenario and data core ([551d80f](https://github.com/flowcore-io/flowcore-cli/commit/551d80f47e6537cb26e56ce9f69f4b25bb554ef2))
26
+
13
27
  ## [2.6.0](https://github.com/flowcore-io/flowcore-cli/compare/v2.5.2...v2.6.0) (2024-02-22)
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.6.0 linux-x64 node-v20.11.1
21
+ @flowcore/cli/2.8.0 linux-x64 node-v20.11.1
22
22
  $ flowcore --help [COMMAND]
23
23
  USAGE
24
24
  $ flowcore COMMAND
@@ -32,6 +32,9 @@ USAGE
32
32
  * [`flowcore config set`](#flowcore-config-set)
33
33
  * [`flowcore config show`](#flowcore-config-show)
34
34
  * [`flowcore data-core apply`](#flowcore-data-core-apply)
35
+ * [`flowcore data-core generate event-type FLOWTYPE`](#flowcore-data-core-generate-event-type-flowtype)
36
+ * [`flowcore data-core generate flow-type`](#flowcore-data-core-generate-flow-type)
37
+ * [`flowcore data-core generate manifest`](#flowcore-data-core-generate-manifest)
35
38
  * [`flowcore help [COMMANDS]`](#flowcore-help-commands)
36
39
  * [`flowcore login`](#flowcore-login)
37
40
  * [`flowcore plugins`](#flowcore-plugins)
@@ -45,6 +48,8 @@ USAGE
45
48
  * [`flowcore plugins:uninstall PLUGIN...`](#flowcore-pluginsuninstall-plugin-2)
46
49
  * [`flowcore plugins update`](#flowcore-plugins-update)
47
50
  * [`flowcore scenario apply`](#flowcore-scenario-apply)
51
+ * [`flowcore scenario generate manifest`](#flowcore-scenario-generate-manifest)
52
+ * [`flowcore scenario generate transformer`](#flowcore-scenario-generate-transformer)
48
53
  * [`flowcore scenario local`](#flowcore-scenario-local)
49
54
  * [`flowcore stream STREAM`](#flowcore-stream-stream)
50
55
  * [`flowcore version`](#flowcore-version)
@@ -70,7 +75,7 @@ EXAMPLES
70
75
  $ flowcore apply -f ./path/to/manifest.yml
71
76
  ```
72
77
 
73
- _See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.6.0/src/commands/apply.ts)_
78
+ _See code: [src/commands/apply.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.8.0/src/commands/apply.ts)_
74
79
 
75
80
  ## `flowcore autocomplete [SHELL]`
76
81
 
@@ -180,7 +185,93 @@ EXAMPLES
180
185
  $ cat <<EOF | flowcore data-core apply -f -
181
186
  ```
182
187
 
183
- _See code: [@flowcore/cli-plugin-data-core](https://github.com/flowcore/flowcore-cli-data-core/blob/v2.0.0/src/commands/data-core/apply.ts)_
188
+ _See code: [@flowcore/cli-plugin-data-core](https://github.com/flowcore/flowcore-cli-data-core/blob/v2.1.0/src/commands/data-core/apply.ts)_
189
+
190
+ ## `flowcore data-core generate event-type FLOWTYPE`
191
+
192
+ add a event type to a data core manifest
193
+
194
+ ```
195
+ USAGE
196
+ $ flowcore data-core generate event-type FLOWTYPE [--profile <value>] [-d <value>] [-f <value>] [-n <value>]
197
+
198
+ FLAGS
199
+ -d, --description=<value> description of the event type
200
+ -f, --file=<value> file to modify
201
+ -n, --name=<value> name of the event type to generate
202
+ --profile=<value> Specify the configuration profile to use
203
+
204
+ DESCRIPTION
205
+ add a event type to a data core manifest
206
+
207
+ EXAMPLES
208
+ $ flowcore data-core generate event-type flow-type-name -n event-type-name
209
+
210
+ $ flowcore data-core generate event-type flow-type-name -n event-type-name -d "description of the event type"
211
+
212
+ $ flowcore data-core generate event-type flow-type-name -n event-type-name -d "description of the event type" -f example.yaml
213
+ ```
214
+
215
+ _See code: [@flowcore/cli-plugin-data-core](https://github.com/flowcore/flowcore-cli-data-core/blob/v2.1.0/src/commands/data-core/generate/event-type.ts)_
216
+
217
+ ## `flowcore data-core generate flow-type`
218
+
219
+ add a flow type to a data core manifest
220
+
221
+ ```
222
+ USAGE
223
+ $ flowcore data-core generate flow-type [--profile <value>] [-d <value>] [-f <value>] [-n <value>]
224
+
225
+ FLAGS
226
+ -d, --description=<value> description of the flow type
227
+ -f, --file=<value> file to modify
228
+ -n, --name=<value> name of the flow type to generate
229
+ --profile=<value> Specify the configuration profile to use
230
+
231
+ DESCRIPTION
232
+ add a flow type to a data core manifest
233
+
234
+ EXAMPLES
235
+ $ flowcore data-core generate flow-type -n flow-type-name
236
+
237
+ $ flowcore data-core generate flow-type -n flow-type-name -d "description of the flow type"
238
+
239
+ $ flowcore data-core generate flow-type -n flow-type-name -d "description of the flow type" -f example.yaml
240
+ ```
241
+
242
+ _See code: [@flowcore/cli-plugin-data-core](https://github.com/flowcore/flowcore-cli-data-core/blob/v2.1.0/src/commands/data-core/generate/flow-type.ts)_
243
+
244
+ ## `flowcore data-core generate manifest`
245
+
246
+ Generate a data core manifest
247
+
248
+ ```
249
+ USAGE
250
+ $ flowcore data-core generate manifest -t <value> [--profile <value>] [-f <value>] [-n <value>] [-o] [--placeholder]
251
+
252
+ FLAGS
253
+ -f, --file=<value> file to apply
254
+ -n, --name=<value> name of the data core to generate
255
+ -o, --overwrite overwrite the existing data core
256
+ -t, --tenant=<value> (required) tenant to apply the data core to, this is the org for your organization, it can be
257
+ seen in the url when accessing your organization
258
+ --placeholder generate a placeholder manifest
259
+ --profile=<value> Specify the configuration profile to use
260
+
261
+ DESCRIPTION
262
+ Generate a data core manifest
263
+
264
+ EXAMPLES
265
+ $ flowcore data-core generate manifest -t flowcore
266
+
267
+ $ flowcore data-core generate manifest -t flowcore --placeholder
268
+
269
+ $ flowcore data-core generate manifest -t flowcore -f example.yaml
270
+
271
+ $ flowcore data-core generate manifest -t flowcore -n data-core-name -f example.yaml
272
+ ```
273
+
274
+ _See code: [@flowcore/cli-plugin-data-core](https://github.com/flowcore/flowcore-cli-data-core/blob/v2.1.0/src/commands/data-core/generate/manifest.ts)_
184
275
 
185
276
  ## `flowcore help [COMMANDS]`
186
277
 
@@ -532,7 +623,66 @@ EXAMPLES
532
623
  $ cat <<EOF | flowcore scenario apply -f -
533
624
  ```
534
625
 
535
- _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.3.0/src/commands/scenario/apply.ts)_
626
+ _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.5.0/src/commands/scenario/apply.ts)_
627
+
628
+ ## `flowcore scenario generate manifest`
629
+
630
+ Generate a scenario manifest
631
+
632
+ ```
633
+ USAGE
634
+ $ flowcore scenario generate manifest -t <value> [--profile <value>] [-f <value>] [-n <value>] [-o] [--placeholder]
635
+
636
+ FLAGS
637
+ -f, --file=<value> file to apply
638
+ -n, --name=<value> name of the scenario to generate
639
+ -o, --overwrite overwrite the existing scenario
640
+ -t, --tenant=<value> (required) tenant to apply the scenario to, this is the org for your organization, it can be
641
+ seen in the url when accessing your organization
642
+ --placeholder generate a placeholder manifest
643
+ --profile=<value> Specify the configuration profile to use
644
+
645
+ DESCRIPTION
646
+ Generate a scenario manifest
647
+
648
+ EXAMPLES
649
+ $ flowcore scenario generate manifest -t flowcore
650
+
651
+ $ flowcore scenario generate manifest -t flowcore --placeholder
652
+
653
+ $ flowcore scenario generate manifest -t flowcore -f example.yaml
654
+
655
+ $ flowcore scenario generate manifest -t flowcore -n scenario-name -f example.yaml
656
+ ```
657
+
658
+ _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.5.0/src/commands/scenario/generate/manifest.ts)_
659
+
660
+ ## `flowcore scenario generate transformer`
661
+
662
+ add a transformer to a scenario manifest
663
+
664
+ ```
665
+ USAGE
666
+ $ flowcore scenario generate transformer [--profile <value>] [-d <value>] [-f <value>] [-n <value>]
667
+
668
+ FLAGS
669
+ -d, --description=<value> description of the transformer
670
+ -f, --file=<value> file to modify
671
+ -n, --name=<value> name of the transformer to generate
672
+ --profile=<value> Specify the configuration profile to use
673
+
674
+ DESCRIPTION
675
+ add a transformer to a scenario manifest
676
+
677
+ EXAMPLES
678
+ $ flowcore scenario generate transformer -n flow-type-name
679
+
680
+ $ flowcore scenario generate transformer -n flow-type-name -d "description of the transformer"
681
+
682
+ $ flowcore scenario generate transformer -n flow-type-name -d "description of the transformer" -f example.yaml
683
+ ```
684
+
685
+ _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.5.0/src/commands/scenario/generate/transformer.ts)_
536
686
 
537
687
  ## `flowcore scenario local`
538
688
 
@@ -540,18 +690,20 @@ Spin up local stream threads based on a scenario manifest
540
690
 
541
691
  ```
542
692
  USAGE
543
- $ flowcore scenario local -e <value> -f <value> [--profile <value>] [-m http] [-c] [-s <value>] [-t <value>] [-y]
693
+ $ flowcore scenario local -e <value> -f <value> [--profile <value>] [-H <value>] [-m http] [-c] [-s <value>] [-t
694
+ <value>] [-y]
544
695
 
545
696
  FLAGS
546
- -c, --scan Scan the full time range
547
- -e, --endpoint=<value> (required) stream endpoint
548
- -f, --file=<value>... (required) file to apply
549
- -m, --mode=<option> [default: http] stream mode
550
- <options: http>
551
- -s, --start=<value> Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h)
552
- -t, --timeout=<value> [default: 5000] Timeout in milliseconds to wait for a response from the destination
553
- -y, --yes skip confirmation
554
- --profile=<value> Specify the configuration profile to use
697
+ -H, --header=<value>... [default: ] header to send with the request, example: (-H 'Authorization: Bearer TOKEN')
698
+ -c, --scan Scan the full time range
699
+ -e, --endpoint=<value> (required) stream endpoint
700
+ -f, --file=<value>... (required) file to apply
701
+ -m, --mode=<option> [default: http] stream mode
702
+ <options: http>
703
+ -s, --start=<value> Start time bucket to stream from, example: (1y, 1m, 1w, 1d, 1h)
704
+ -t, --timeout=<value> [default: 5000] Timeout in milliseconds to wait for a response from the destination
705
+ -y, --yes skip confirmation
706
+ --profile=<value> Specify the configuration profile to use
555
707
 
556
708
  DESCRIPTION
557
709
  Spin up local stream threads based on a scenario manifest
@@ -562,7 +714,7 @@ EXAMPLES
562
714
  $ cat <<EOF | flowcore scenario local -f -
563
715
  ```
564
716
 
565
- _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.3.0/src/commands/scenario/local.ts)_
717
+ _See code: [@flowcore/cli-plugin-scenario](https://github.com/flowcore/flowcore-cli-plugin-scenario/blob/v2.5.0/src/commands/scenario/local.ts)_
566
718
 
567
719
  ## `flowcore stream STREAM`
568
720
 
@@ -584,7 +736,7 @@ FLAGS
584
736
  -l, --[no-]live Change to live mode when reaching last time bucket
585
737
  -o, --output=<option> [default: http] Output format
586
738
  <options: http|log>
587
- -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)
588
740
  -t, --timeout=<value> [default: 5000] Timeout in milliseconds to wait for a response from the destination
589
741
  --profile=<value> Specify the configuration profile to use
590
742
 
@@ -601,7 +753,7 @@ EXAMPLES
601
753
  $ flowcore stream https://flowcore.io/<org>/<data core>/<flow type>/[<event type1>,<event type2>,<event type3>].stream -o log -s 3m
602
754
  ```
603
755
 
604
- _See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.6.0/src/commands/stream.ts)_
756
+ _See code: [src/commands/stream.ts](https://github.com/flowcore-io/flowcore-cli/blob/v2.8.0/src/commands/stream.ts)_
605
757
 
606
758
  ## `flowcore version`
607
759
 
@@ -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 = eventRangeRequest.datacore.flowtypes.find(ft => ft.aggregator === aggregator)?.events.find(e => eventTypes.includes(e.name))?.catalog.range.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));
@@ -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.6.0"
160
+ "version": "2.8.0"
161
161
  }
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "dependencies": {
7
7
  "@datastructures-js/queue": "^4.2.3",
8
8
  "@flowcore/cli-plugin-config": "^1.0.5",
9
- "@flowcore/cli-plugin-data-core": "^2.0.0",
10
- "@flowcore/cli-plugin-scenario": "^2.3.0",
9
+ "@flowcore/cli-plugin-data-core": "^2.1.0",
10
+ "@flowcore/cli-plugin-scenario": "^2.5.0",
11
11
  "@flowcore/time-bucket": "^1.1.0",
12
12
  "@oclif/core": "^3",
13
13
  "@oclif/plugin-autocomplete": "^3.0.2",
@@ -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.6.0",
93
+ "version": "2.8.0",
93
94
  "bugs": "https://github.com/flowcore-io/flowcore-cli/issues",
94
95
  "keywords": [
95
96
  "flowcore",