@flowcore/data-pump 0.10.0 → 0.12.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/esm/data-pump/data-pump.d.ts +1 -0
  3. package/esm/data-pump/data-pump.d.ts.map +1 -1
  4. package/esm/data-pump/data-pump.js +11 -0
  5. package/esm/data-pump/data-source.d.ts +92 -8
  6. package/esm/data-pump/data-source.d.ts.map +1 -1
  7. package/esm/data-pump/data-source.js +75 -0
  8. package/esm/data-pump/no-op-logger.d.ts +3 -0
  9. package/esm/data-pump/no-op-logger.d.ts.map +1 -0
  10. package/esm/data-pump/no-op-logger.js +6 -0
  11. package/esm/data-pump/notifier.js +1 -1
  12. package/esm/mod.d.ts +1 -2
  13. package/esm/mod.d.ts.map +1 -1
  14. package/esm/mod.js +1 -2
  15. package/package.json +1 -1
  16. package/script/data-pump/data-pump.d.ts +1 -0
  17. package/script/data-pump/data-pump.d.ts.map +1 -1
  18. package/script/data-pump/data-pump.js +11 -0
  19. package/script/data-pump/data-source.d.ts +92 -8
  20. package/script/data-pump/data-source.d.ts.map +1 -1
  21. package/script/data-pump/data-source.js +75 -0
  22. package/script/data-pump/no-op-logger.d.ts +3 -0
  23. package/script/data-pump/no-op-logger.d.ts.map +1 -0
  24. package/script/data-pump/no-op-logger.js +9 -0
  25. package/script/data-pump/notifier.js +2 -2
  26. package/script/mod.d.ts +1 -2
  27. package/script/mod.d.ts.map +1 -1
  28. package/script/mod.js +1 -2
  29. package/esm/lib/data-pump-create.d.ts +0 -46
  30. package/esm/lib/data-pump-create.d.ts.map +0 -1
  31. package/esm/lib/data-pump-create.js +0 -64
  32. package/esm/lib/data-pump.d.ts +0 -80
  33. package/esm/lib/data-pump.d.ts.map +0 -1
  34. package/esm/lib/data-pump.js +0 -437
  35. package/esm/lib/nats-notifier.d.ts +0 -18
  36. package/esm/lib/nats-notifier.d.ts.map +0 -1
  37. package/esm/lib/nats-notifier.js +0 -88
  38. package/esm/lib/ws-notifier.d.ts +0 -37
  39. package/esm/lib/ws-notifier.d.ts.map +0 -1
  40. package/esm/lib/ws-notifier.js +0 -86
  41. package/script/lib/data-pump-create.d.ts +0 -46
  42. package/script/lib/data-pump-create.d.ts.map +0 -1
  43. package/script/lib/data-pump-create.js +0 -68
  44. package/script/lib/data-pump.d.ts +0 -80
  45. package/script/lib/data-pump.d.ts.map +0 -1
  46. package/script/lib/data-pump.js +0 -441
  47. package/script/lib/nats-notifier.d.ts +0 -18
  48. package/script/lib/nats-notifier.d.ts.map +0 -1
  49. package/script/lib/nats-notifier.js +0 -115
  50. package/script/lib/ws-notifier.d.ts +0 -37
  51. package/script/lib/ws-notifier.d.ts.map +0 -1
  52. package/script/lib/ws-notifier.js +0 -90
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.0](https://github.com/flowcore-io/data-pump/compare/v0.11.0...v0.12.0) (2025-04-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * remove old datapump code ([d940e25](https://github.com/flowcore-io/data-pump/commit/d940e25bf9e5c67a6609d33f741c23b3dad3ca23))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add 1 sec delay when rechecking for events in livemode ([024a9e0](https://github.com/flowcore-io/data-pump/commit/024a9e09dbd9998e36257f29c154d50ed82ff7a4))
14
+ * add no op logger ([fd83978](https://github.com/flowcore-io/data-pump/commit/fd83978275b1102b80c853dd53c00764b747a9c7))
15
+
16
+ ## [0.11.0](https://github.com/flowcore-io/data-pump/compare/v0.10.0...v0.11.0) (2025-04-14)
17
+
18
+
19
+ ### Features
20
+
21
+ * **data-pump:** :sparkles: enhance FlowcoreDataSource with detailed JSDoc comments ([1e3308d](https://github.com/flowcore-io/data-pump/commit/1e3308d6c1aca7da47c96650f0b1e9ef9c8b7c8a))
22
+
3
23
  ## [0.10.0](https://github.com/flowcore-io/data-pump/compare/v0.9.0...v0.10.0) (2025-04-14)
4
24
 
5
25
 
@@ -43,6 +43,7 @@ export declare class FlowcoreDataPump {
43
43
  private buffer;
44
44
  private bufferState;
45
45
  private stopAtState?;
46
+ private isLive;
46
47
  private constructor();
47
48
  get isRunning(): boolean;
48
49
  static create(options: FlowcoreDataPumpOptions, dataSourceOverride?: FlowcoreDataSource): FlowcoreDataPump;
@@ -1 +1 @@
1
- {"version":3,"file":"data-pump.d.ts","sourceRoot":"","sources":["../../src/data-pump/data-pump.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAA;AAGnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,UAAU,mCAAmC;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,UAAU,wCAAwC;IAChD,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,UAAU,qCAAqC;IAC7C,IAAI,EAAE,QAAQ,CAAA;IACd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,+BAA+B,GAChC,mCAAmC,GACnC,wCAAwC,GACxC,qCAAqC,CAAA;AAEzC,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,oBAAoB,CAAA;IAC1B,UAAU,EAAE,0BAA0B,CAAA;IACtC,YAAY,EAAE,4BAA4B,CAAA;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,SAAS,CAAC,EAAE,yBAAyB,CAAA;IACrC,QAAQ,CAAC,EAAE,+BAA+B,CAAA;IAC1C,MAAM,CAAC,EAAE,cAAc,CAA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C,YAAY,CAAC,CAAY;YACnB,aAAa;IAO3B,OAAO,CAAC,qBAAqB,CAAC,CAAY;YAC5B,sBAAsB;IAOpC,OAAO,CAAC,iBAAiB,CAAC,CAAY;YACxB,kBAAkB;CAWjC"}
@@ -72,6 +72,12 @@ export class FlowcoreDataPump {
72
72
  writable: true,
73
73
  value: void 0
74
74
  });
75
+ Object.defineProperty(this, "isLive", {
76
+ enumerable: true,
77
+ configurable: true,
78
+ writable: true,
79
+ value: false
80
+ });
75
81
  // #endregion
76
82
  // #region Waiters
77
83
  Object.defineProperty(this, "waiterEvents", {
@@ -127,6 +133,7 @@ export class FlowcoreDataPump {
127
133
  }, options.logger);
128
134
  }
129
135
  async start(callback) {
136
+ this.isLive = false;
130
137
  if (this.running) {
131
138
  throw new Error("Data pump already running");
132
139
  }
@@ -224,10 +231,14 @@ export class FlowcoreDataPump {
224
231
  const previousTimeBucket = this.bufferState.timeBucket;
225
232
  this.bufferState.timeBucket = format(startOfHour(utc(new Date())), "yyyyMMddHH0000");
226
233
  if (previousTimeBucket === this.bufferState.timeBucket && !events.length) {
234
+ this.isLive = true;
227
235
  this.logger?.debug("Going live...");
228
236
  this.abortController = new AbortController();
229
237
  await this.notifier.wait(this.abortController.signal);
230
238
  }
239
+ else if (this.isLive) {
240
+ await new Promise((resolve) => setTimeout(resolve, 1000));
241
+ }
231
242
  }
232
243
  }
233
244
  } while (this.running);
@@ -1,32 +1,116 @@
1
- import { type FlowcoreEvent } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js";
1
+ /**
2
+ * @module data-source
3
+ * @description Provides functionality to interact with Flowcore data sources
4
+ */
5
+ import { type FlowcoreClient, type FlowcoreEvent } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js";
2
6
  import type { FlowcoreDataPumpAuth, FlowcoreDataPumpDataSource, FlowcoreDataPumpState } from "./types.js";
7
+ /**
8
+ * Options for configuring a Flowcore data source
9
+ * @interface FlowcoreDataSourceOptions
10
+ */
3
11
  export interface FlowcoreDataSourceOptions {
12
+ /** Authentication information for Flowcore */
4
13
  auth: FlowcoreDataPumpAuth;
14
+ /** Data source configuration */
5
15
  dataSource: FlowcoreDataPumpDataSource;
16
+ /** Optional base URL override for the Flowcore API */
6
17
  baseUrlOverride?: string;
18
+ /** When true, disables name-to-ID translation for tenant, dataCore, flowType, and eventTypes */
7
19
  noTranslation?: boolean;
20
+ /** When true, executes commands in direct mode */
8
21
  directMode?: boolean;
9
22
  }
23
+ /**
24
+ * Provides methods to interact with a Flowcore data source
25
+ * @class FlowcoreDataSource
26
+ */
10
27
  export declare class FlowcoreDataSource {
11
- private readonly options;
12
- private flowcoreClient;
13
- private tenantId?;
14
- private dataCoreId?;
15
- private flowTypeId?;
16
- private eventTypeIds?;
17
- private timeBuckets?;
28
+ protected readonly options: FlowcoreDataSourceOptions;
29
+ /** Flowcore client instance */
30
+ protected flowcoreClient: FlowcoreClient;
31
+ /** Cached tenant ID */
32
+ protected tenantId?: string;
33
+ /** Cached data core ID */
34
+ protected dataCoreId?: string;
35
+ /** Cached flow type ID */
36
+ protected flowTypeId?: string;
37
+ /** Cached event type IDs */
38
+ protected eventTypeIds?: string[];
39
+ /** Cached time buckets */
40
+ protected timeBuckets?: string[];
41
+ /**
42
+ * Creates a new FlowcoreDataSource instance
43
+ * @param options - Configuration options for the data source
44
+ */
18
45
  constructor(options: FlowcoreDataSourceOptions);
46
+ /**
47
+ * Gets the tenant name from the data source configuration
48
+ * @returns Tenant name
49
+ */
19
50
  get tenant(): string;
51
+ /**
52
+ * Gets the data core name from the data source configuration
53
+ * @returns Data core name
54
+ */
20
55
  get dataCore(): string;
56
+ /**
57
+ * Gets the flow type name from the data source configuration
58
+ * @returns Flow type name
59
+ */
21
60
  get flowType(): string;
61
+ /**
62
+ * Gets the event type names from the data source configuration
63
+ * @returns Array of event type names
64
+ */
22
65
  get eventTypes(): string[];
66
+ /**
67
+ * Gets the tenant ID, translating from name if necessary
68
+ * @returns Promise that resolves to the tenant ID
69
+ */
23
70
  getTenantId(): Promise<string>;
71
+ /**
72
+ * Gets the data core ID, translating from name if necessary
73
+ * @returns Promise that resolves to the data core ID
74
+ */
24
75
  getDataCoreId(): Promise<string>;
76
+ /**
77
+ * Gets the flow type ID, translating from name if necessary
78
+ * @returns Promise that resolves to the flow type ID
79
+ */
25
80
  getFlowTypeId(): Promise<string>;
81
+ /**
82
+ * Gets the event type IDs, translating from names if necessary
83
+ * @returns Promise that resolves to an array of event type IDs
84
+ * @throws Error if an event type is not found
85
+ */
26
86
  getEventTypeIds(): Promise<string[]>;
87
+ /**
88
+ * Gets all time buckets for the configured event types
89
+ * @param force - When true, forces a refresh of cached time buckets
90
+ * @returns Promise that resolves to an array of time bucket strings
91
+ */
27
92
  getTimeBuckets(force?: boolean): Promise<string[]>;
93
+ /**
94
+ * Gets the next time bucket after the specified time bucket
95
+ * @param timeBucket - The reference time bucket
96
+ * @returns Promise that resolves to the next time bucket, or null if none exists
97
+ */
28
98
  getNextTimeBucket(timeBucket: string): Promise<string | null>;
99
+ /**
100
+ * Gets the closest time bucket to the specified time bucket
101
+ * @param timeBucket - The reference time bucket
102
+ * @param getBefore - When true, gets the closest time bucket before the reference
103
+ * @returns Promise that resolves to the closest time bucket, or null if none exists
104
+ * @throws Error if the time bucket format is invalid
105
+ */
29
106
  getClosestTimeBucket(timeBucket: string, getBefore?: boolean): Promise<string | null>;
107
+ /**
108
+ * Gets events from the data source starting from a specific state
109
+ * @param from - The state to start from (includes timeBucket and eventId)
110
+ * @param amount - Maximum number of events to retrieve
111
+ * @param toEventId - Optional ID to stop at when retrieving events
112
+ * @returns Promise that resolves to an array of Flowcore events
113
+ */
30
114
  getEvents(from: FlowcoreDataPumpState, amount: number, toEventId?: string): Promise<FlowcoreEvent[]>;
31
115
  }
32
116
  //# sourceMappingURL=data-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../src/data-pump/data-source.ts"],"names":[],"mappings":"AAAA,O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AGG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;OAGG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;OAGG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,MAAM,EAAE,CAEhC;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAiB3C;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAkB7C;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAkB7C;;;;OAIG;IACU,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBjD;;;;OAIG;IACU,cAAc,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwB7D;;;;OAIG;IACU,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa1E;;;;;;OAMG;IACU,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiBhG;;;;;;OAMG;IACU,SAAS,CAAC,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAelH"}
@@ -1,6 +1,18 @@
1
+ /**
2
+ * @module data-source
3
+ * @description Provides functionality to interact with Flowcore data sources
4
+ */
1
5
  import { DataCoreFetchCommand, EventListCommand, EventTypeListCommand, FlowTypeFetchCommand, TenantTranslateNameToIdCommand, TimeBucketListCommand, } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js";
2
6
  import { getFlowcoreClient } from "./flowcore-client.js";
7
+ /**
8
+ * Provides methods to interact with a Flowcore data source
9
+ * @class FlowcoreDataSource
10
+ */
3
11
  export class FlowcoreDataSource {
12
+ /**
13
+ * Creates a new FlowcoreDataSource instance
14
+ * @param options - Configuration options for the data source
15
+ */
4
16
  constructor(options) {
5
17
  Object.defineProperty(this, "options", {
6
18
  enumerable: true,
@@ -8,36 +20,42 @@ export class FlowcoreDataSource {
8
20
  writable: true,
9
21
  value: options
10
22
  });
23
+ /** Flowcore client instance */
11
24
  Object.defineProperty(this, "flowcoreClient", {
12
25
  enumerable: true,
13
26
  configurable: true,
14
27
  writable: true,
15
28
  value: void 0
16
29
  });
30
+ /** Cached tenant ID */
17
31
  Object.defineProperty(this, "tenantId", {
18
32
  enumerable: true,
19
33
  configurable: true,
20
34
  writable: true,
21
35
  value: void 0
22
36
  });
37
+ /** Cached data core ID */
23
38
  Object.defineProperty(this, "dataCoreId", {
24
39
  enumerable: true,
25
40
  configurable: true,
26
41
  writable: true,
27
42
  value: void 0
28
43
  });
44
+ /** Cached flow type ID */
29
45
  Object.defineProperty(this, "flowTypeId", {
30
46
  enumerable: true,
31
47
  configurable: true,
32
48
  writable: true,
33
49
  value: void 0
34
50
  });
51
+ /** Cached event type IDs */
35
52
  Object.defineProperty(this, "eventTypeIds", {
36
53
  enumerable: true,
37
54
  configurable: true,
38
55
  writable: true,
39
56
  value: void 0
40
57
  });
58
+ /** Cached time buckets */
41
59
  Object.defineProperty(this, "timeBuckets", {
42
60
  enumerable: true,
43
61
  configurable: true,
@@ -46,18 +64,38 @@ export class FlowcoreDataSource {
46
64
  });
47
65
  this.flowcoreClient = getFlowcoreClient(this.options.auth, this.options.baseUrlOverride);
48
66
  }
67
+ /**
68
+ * Gets the tenant name from the data source configuration
69
+ * @returns Tenant name
70
+ */
49
71
  get tenant() {
50
72
  return this.options.dataSource.tenant;
51
73
  }
74
+ /**
75
+ * Gets the data core name from the data source configuration
76
+ * @returns Data core name
77
+ */
52
78
  get dataCore() {
53
79
  return this.options.dataSource.dataCore;
54
80
  }
81
+ /**
82
+ * Gets the flow type name from the data source configuration
83
+ * @returns Flow type name
84
+ */
55
85
  get flowType() {
56
86
  return this.options.dataSource.flowType;
57
87
  }
88
+ /**
89
+ * Gets the event type names from the data source configuration
90
+ * @returns Array of event type names
91
+ */
58
92
  get eventTypes() {
59
93
  return this.options.dataSource.eventTypes;
60
94
  }
95
+ /**
96
+ * Gets the tenant ID, translating from name if necessary
97
+ * @returns Promise that resolves to the tenant ID
98
+ */
61
99
  async getTenantId() {
62
100
  if (this.tenantId) {
63
101
  return this.tenantId;
@@ -74,6 +112,10 @@ export class FlowcoreDataSource {
74
112
  }
75
113
  return this.tenantId;
76
114
  }
115
+ /**
116
+ * Gets the data core ID, translating from name if necessary
117
+ * @returns Promise that resolves to the data core ID
118
+ */
77
119
  async getDataCoreId() {
78
120
  if (this.dataCoreId) {
79
121
  return this.dataCoreId;
@@ -91,6 +133,10 @@ export class FlowcoreDataSource {
91
133
  }
92
134
  return this.dataCoreId;
93
135
  }
136
+ /**
137
+ * Gets the flow type ID, translating from name if necessary
138
+ * @returns Promise that resolves to the flow type ID
139
+ */
94
140
  async getFlowTypeId() {
95
141
  if (this.flowTypeId) {
96
142
  return this.flowTypeId;
@@ -108,6 +154,11 @@ export class FlowcoreDataSource {
108
154
  }
109
155
  return this.flowTypeId;
110
156
  }
157
+ /**
158
+ * Gets the event type IDs, translating from names if necessary
159
+ * @returns Promise that resolves to an array of event type IDs
160
+ * @throws Error if an event type is not found
161
+ */
111
162
  async getEventTypeIds() {
112
163
  if (this.eventTypeIds) {
113
164
  return this.eventTypeIds;
@@ -132,6 +183,11 @@ export class FlowcoreDataSource {
132
183
  }
133
184
  return this.eventTypeIds;
134
185
  }
186
+ /**
187
+ * Gets all time buckets for the configured event types
188
+ * @param force - When true, forces a refresh of cached time buckets
189
+ * @returns Promise that resolves to an array of time bucket strings
190
+ */
135
191
  async getTimeBuckets(force = false) {
136
192
  if (this.timeBuckets && !force) {
137
193
  return this.timeBuckets;
@@ -151,6 +207,11 @@ export class FlowcoreDataSource {
151
207
  this.timeBuckets = timeBuckets;
152
208
  return this.timeBuckets;
153
209
  }
210
+ /**
211
+ * Gets the next time bucket after the specified time bucket
212
+ * @param timeBucket - The reference time bucket
213
+ * @returns Promise that resolves to the next time bucket, or null if none exists
214
+ */
154
215
  async getNextTimeBucket(timeBucket) {
155
216
  const closestTimeBucket = await this.getClosestTimeBucket(timeBucket);
156
217
  if (!closestTimeBucket) {
@@ -163,6 +224,13 @@ export class FlowcoreDataSource {
163
224
  }
164
225
  return timeBuckets[index + 1] ?? null;
165
226
  }
227
+ /**
228
+ * Gets the closest time bucket to the specified time bucket
229
+ * @param timeBucket - The reference time bucket
230
+ * @param getBefore - When true, gets the closest time bucket before the reference
231
+ * @returns Promise that resolves to the closest time bucket, or null if none exists
232
+ * @throws Error if the time bucket format is invalid
233
+ */
166
234
  async getClosestTimeBucket(timeBucket, getBefore = false) {
167
235
  const timeBuckets = await this.getTimeBuckets();
168
236
  if (!timeBucket.match(/^\d{14}$/)) {
@@ -175,6 +243,13 @@ export class FlowcoreDataSource {
175
243
  return (timeBuckets.find((t) => Number.parseFloat(t) >= Number.parseFloat(timeBucket)) ??
176
244
  timeBuckets[timeBuckets.length - 1]);
177
245
  }
246
+ /**
247
+ * Gets events from the data source starting from a specific state
248
+ * @param from - The state to start from (includes timeBucket and eventId)
249
+ * @param amount - Maximum number of events to retrieve
250
+ * @param toEventId - Optional ID to stop at when retrieving events
251
+ * @returns Promise that resolves to an array of Flowcore events
252
+ */
178
253
  async getEvents(from, amount, toEventId) {
179
254
  const eventTypeIds = await this.getEventTypeIds();
180
255
  const result = await this.flowcoreClient.execute(new EventListCommand({
@@ -0,0 +1,3 @@
1
+ import type { FlowcoreLogger } from "./types.js";
2
+ export declare const noOpLogger: FlowcoreLogger;
3
+ //# sourceMappingURL=no-op-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-op-logger.d.ts","sourceRoot":"","sources":["../../src/data-pump/no-op-logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,eAAO,MAAM,UAAU,EAAE,cAKxB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export const noOpLogger = {
2
+ debug: () => { },
3
+ info: () => { },
4
+ warn: () => { },
5
+ error: console.error,
6
+ };
@@ -2,7 +2,7 @@ import { NotificationClient } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.
2
2
  import * as Nats from "nats";
3
3
  import { Subject } from "rxjs";
4
4
  import { FlowcoreDataSource } from "./data-source.js";
5
- import { noOpLogger } from "../lib/data-pump-create.js";
5
+ import { noOpLogger } from "./no-op-logger.js";
6
6
  const DEFAULT_TIMEOUT_MS = 20_000;
7
7
  export class FlowcoreNotifier {
8
8
  constructor(options) {
package/esm/mod.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import "./_dnt.polyfills.js";
2
- export * from "./lib/data-pump.js";
3
- export * from "./lib/data-pump-create.js";
4
2
  export * from "./data-pump/data-pump.js";
5
3
  export * from "./data-pump/data-source.js";
6
4
  export * from "./data-pump/metrics.js";
7
5
  export * from "./data-pump/types.js";
6
+ export * from "./data-pump/no-op-logger.js";
8
7
  //# sourceMappingURL=mod.d.ts.map
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA"}
package/esm/mod.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import "./_dnt.polyfills.js";
2
- export * from "./lib/data-pump.js";
3
- export * from "./lib/data-pump-create.js";
4
2
  export * from "./data-pump/data-pump.js";
5
3
  export * from "./data-pump/data-source.js";
6
4
  export * from "./data-pump/metrics.js";
7
5
  export * from "./data-pump/types.js";
6
+ export * from "./data-pump/no-op-logger.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/data-pump",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Flowcore Data Pump",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-data-pump#readme",
6
6
  "repository": {
@@ -43,6 +43,7 @@ export declare class FlowcoreDataPump {
43
43
  private buffer;
44
44
  private bufferState;
45
45
  private stopAtState?;
46
+ private isLive;
46
47
  private constructor();
47
48
  get isRunning(): boolean;
48
49
  static create(options: FlowcoreDataPumpOptions, dataSourceOverride?: FlowcoreDataSource): FlowcoreDataPump;
@@ -1 +1 @@
1
- {"version":3,"file":"data-pump.d.ts","sourceRoot":"","sources":["../../src/data-pump/data-pump.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAA;AAGnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC5B,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB,UAAU,mCAAmC;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,UAAU,wCAAwC;IAChD,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,UAAU,qCAAqC;IAC7C,IAAI,EAAE,QAAQ,CAAA;IACd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,+B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BAAqB,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI;IAQjE,IAAI,CAAC,SAAS,UAAQ,GAAG,IAAI;IAWpC,OAAO,CAAC,WAAW;YAaL,IAAI;IAwEL,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAoCjD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE;IA0B9B,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE;YA4BtB,MAAM;YAiDN,WAAW;IAiBzB,OAAO,CAAC,mBAAmB;IA4D3B,OAAO,CAAC,iBAAiB;IA0CzB,OAAO,CAAC,YAAY,CAAC,CAAY;YACnB,aAAa;IAO3B,OAAO,CAAC,qBAAqB,CAAC,CAAY;YAC5B,sBAAsB;IAOpC,OAAO,CAAC,iBAAiB,CAAC,CAAY;YACxB,kBAAkB;CAWjC"}
@@ -75,6 +75,12 @@ class FlowcoreDataPump {
75
75
  writable: true,
76
76
  value: void 0
77
77
  });
78
+ Object.defineProperty(this, "isLive", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: false
83
+ });
78
84
  // #endregion
79
85
  // #region Waiters
80
86
  Object.defineProperty(this, "waiterEvents", {
@@ -130,6 +136,7 @@ class FlowcoreDataPump {
130
136
  }, options.logger);
131
137
  }
132
138
  async start(callback) {
139
+ this.isLive = false;
133
140
  if (this.running) {
134
141
  throw new Error("Data pump already running");
135
142
  }
@@ -227,10 +234,14 @@ class FlowcoreDataPump {
227
234
  const previousTimeBucket = this.bufferState.timeBucket;
228
235
  this.bufferState.timeBucket = (0, date_fns_1.format)((0, date_fns_1.startOfHour)((0, utc_1.utc)(new Date())), "yyyyMMddHH0000");
229
236
  if (previousTimeBucket === this.bufferState.timeBucket && !events.length) {
237
+ this.isLive = true;
230
238
  this.logger?.debug("Going live...");
231
239
  this.abortController = new AbortController();
232
240
  await this.notifier.wait(this.abortController.signal);
233
241
  }
242
+ else if (this.isLive) {
243
+ await new Promise((resolve) => setTimeout(resolve, 1000));
244
+ }
234
245
  }
235
246
  }
236
247
  } while (this.running);
@@ -1,32 +1,116 @@
1
- import { type FlowcoreEvent } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js";
1
+ /**
2
+ * @module data-source
3
+ * @description Provides functionality to interact with Flowcore data sources
4
+ */
5
+ import { type FlowcoreClient, type FlowcoreEvent } from "../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js";
2
6
  import type { FlowcoreDataPumpAuth, FlowcoreDataPumpDataSource, FlowcoreDataPumpState } from "./types.js";
7
+ /**
8
+ * Options for configuring a Flowcore data source
9
+ * @interface FlowcoreDataSourceOptions
10
+ */
3
11
  export interface FlowcoreDataSourceOptions {
12
+ /** Authentication information for Flowcore */
4
13
  auth: FlowcoreDataPumpAuth;
14
+ /** Data source configuration */
5
15
  dataSource: FlowcoreDataPumpDataSource;
16
+ /** Optional base URL override for the Flowcore API */
6
17
  baseUrlOverride?: string;
18
+ /** When true, disables name-to-ID translation for tenant, dataCore, flowType, and eventTypes */
7
19
  noTranslation?: boolean;
20
+ /** When true, executes commands in direct mode */
8
21
  directMode?: boolean;
9
22
  }
23
+ /**
24
+ * Provides methods to interact with a Flowcore data source
25
+ * @class FlowcoreDataSource
26
+ */
10
27
  export declare class FlowcoreDataSource {
11
- private readonly options;
12
- private flowcoreClient;
13
- private tenantId?;
14
- private dataCoreId?;
15
- private flowTypeId?;
16
- private eventTypeIds?;
17
- private timeBuckets?;
28
+ protected readonly options: FlowcoreDataSourceOptions;
29
+ /** Flowcore client instance */
30
+ protected flowcoreClient: FlowcoreClient;
31
+ /** Cached tenant ID */
32
+ protected tenantId?: string;
33
+ /** Cached data core ID */
34
+ protected dataCoreId?: string;
35
+ /** Cached flow type ID */
36
+ protected flowTypeId?: string;
37
+ /** Cached event type IDs */
38
+ protected eventTypeIds?: string[];
39
+ /** Cached time buckets */
40
+ protected timeBuckets?: string[];
41
+ /**
42
+ * Creates a new FlowcoreDataSource instance
43
+ * @param options - Configuration options for the data source
44
+ */
18
45
  constructor(options: FlowcoreDataSourceOptions);
46
+ /**
47
+ * Gets the tenant name from the data source configuration
48
+ * @returns Tenant name
49
+ */
19
50
  get tenant(): string;
51
+ /**
52
+ * Gets the data core name from the data source configuration
53
+ * @returns Data core name
54
+ */
20
55
  get dataCore(): string;
56
+ /**
57
+ * Gets the flow type name from the data source configuration
58
+ * @returns Flow type name
59
+ */
21
60
  get flowType(): string;
61
+ /**
62
+ * Gets the event type names from the data source configuration
63
+ * @returns Array of event type names
64
+ */
22
65
  get eventTypes(): string[];
66
+ /**
67
+ * Gets the tenant ID, translating from name if necessary
68
+ * @returns Promise that resolves to the tenant ID
69
+ */
23
70
  getTenantId(): Promise<string>;
71
+ /**
72
+ * Gets the data core ID, translating from name if necessary
73
+ * @returns Promise that resolves to the data core ID
74
+ */
24
75
  getDataCoreId(): Promise<string>;
76
+ /**
77
+ * Gets the flow type ID, translating from name if necessary
78
+ * @returns Promise that resolves to the flow type ID
79
+ */
25
80
  getFlowTypeId(): Promise<string>;
81
+ /**
82
+ * Gets the event type IDs, translating from names if necessary
83
+ * @returns Promise that resolves to an array of event type IDs
84
+ * @throws Error if an event type is not found
85
+ */
26
86
  getEventTypeIds(): Promise<string[]>;
87
+ /**
88
+ * Gets all time buckets for the configured event types
89
+ * @param force - When true, forces a refresh of cached time buckets
90
+ * @returns Promise that resolves to an array of time bucket strings
91
+ */
27
92
  getTimeBuckets(force?: boolean): Promise<string[]>;
93
+ /**
94
+ * Gets the next time bucket after the specified time bucket
95
+ * @param timeBucket - The reference time bucket
96
+ * @returns Promise that resolves to the next time bucket, or null if none exists
97
+ */
28
98
  getNextTimeBucket(timeBucket: string): Promise<string | null>;
99
+ /**
100
+ * Gets the closest time bucket to the specified time bucket
101
+ * @param timeBucket - The reference time bucket
102
+ * @param getBefore - When true, gets the closest time bucket before the reference
103
+ * @returns Promise that resolves to the closest time bucket, or null if none exists
104
+ * @throws Error if the time bucket format is invalid
105
+ */
29
106
  getClosestTimeBucket(timeBucket: string, getBefore?: boolean): Promise<string | null>;
107
+ /**
108
+ * Gets events from the data source starting from a specific state
109
+ * @param from - The state to start from (includes timeBucket and eventId)
110
+ * @param amount - Maximum number of events to retrieve
111
+ * @param toEventId - Optional ID to stop at when retrieving events
112
+ * @returns Promise that resolves to an array of Flowcore events
113
+ */
30
114
  getEvents(from: FlowcoreDataPumpState, amount: number, toEventId?: string): Promise<FlowcoreEvent[]>;
31
115
  }
32
116
  //# sourceMappingURL=data-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../src/data-pump/data-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,gDAAgD,CAAA;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACzG,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,oBAAoB,CAAA;IAC1B,UAAU,EAAE,0BAA0B,CAAA;IACtC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,qBAAa,kBAAkB;IAQjB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,CAAQ;IACzB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,YAAY,CAAC,CAAU;IAC/B,OAAO,CAAC,WAAW,CAAC,CAAU;gBAED,OAAO,EAAE,yBAAyB;IAI/D,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,UAAU,IAAI,MAA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