@flowcore/data-pump 0.9.0 → 0.11.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
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0](https://github.com/flowcore-io/data-pump/compare/v0.10.0...v0.11.0) (2025-04-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * **data-pump:** :sparkles: enhance FlowcoreDataSource with detailed JSDoc comments ([1e3308d](https://github.com/flowcore-io/data-pump/commit/1e3308d6c1aca7da47c96650f0b1e9ef9c8b7c8a))
9
+
10
+ ## [0.10.0](https://github.com/flowcore-io/data-pump/compare/v0.9.0...v0.10.0) (2025-04-14)
11
+
12
+
13
+ ### Features
14
+
15
+ * **data-pump:** :sparkles: export data source module ([6208e42](https://github.com/flowcore-io/data-pump/commit/6208e42bbf59e67d70235833a08d6e116b29dc60))
16
+
3
17
  ## [0.9.0](https://github.com/flowcore-io/data-pump/compare/v0.8.3...v0.9.0) (2025-04-14)
4
18
 
5
19
 
@@ -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;I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;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({
package/esm/mod.d.ts CHANGED
@@ -2,6 +2,7 @@ import "./_dnt.polyfills.js";
2
2
  export * from "./lib/data-pump.js";
3
3
  export * from "./lib/data-pump-create.js";
4
4
  export * from "./data-pump/data-pump.js";
5
+ export * from "./data-pump/data-source.js";
5
6
  export * from "./data-pump/metrics.js";
6
7
  export * from "./data-pump/types.js";
7
8
  //# 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,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,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA"}
package/esm/mod.js CHANGED
@@ -2,5 +2,6 @@ import "./_dnt.polyfills.js";
2
2
  export * from "./lib/data-pump.js";
3
3
  export * from "./lib/data-pump-create.js";
4
4
  export * from "./data-pump/data-pump.js";
5
+ export * from "./data-pump/data-source.js";
5
6
  export * from "./data-pump/metrics.js";
6
7
  export * from "./data-pump/types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/data-pump",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Flowcore Data Pump",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-data-pump#readme",
6
6
  "repository": {
@@ -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,yBAAy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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,9 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowcoreDataSource = void 0;
4
+ /**
5
+ * @module data-source
6
+ * @description Provides functionality to interact with Flowcore data sources
7
+ */
4
8
  const mod_js_1 = require("../deps/jsr.io/@flowcore/sdk/1.26.3/src/mod.js");
5
9
  const flowcore_client_js_1 = require("./flowcore-client.js");
10
+ /**
11
+ * Provides methods to interact with a Flowcore data source
12
+ * @class FlowcoreDataSource
13
+ */
6
14
  class FlowcoreDataSource {
15
+ /**
16
+ * Creates a new FlowcoreDataSource instance
17
+ * @param options - Configuration options for the data source
18
+ */
7
19
  constructor(options) {
8
20
  Object.defineProperty(this, "options", {
9
21
  enumerable: true,
@@ -11,36 +23,42 @@ class FlowcoreDataSource {
11
23
  writable: true,
12
24
  value: options
13
25
  });
26
+ /** Flowcore client instance */
14
27
  Object.defineProperty(this, "flowcoreClient", {
15
28
  enumerable: true,
16
29
  configurable: true,
17
30
  writable: true,
18
31
  value: void 0
19
32
  });
33
+ /** Cached tenant ID */
20
34
  Object.defineProperty(this, "tenantId", {
21
35
  enumerable: true,
22
36
  configurable: true,
23
37
  writable: true,
24
38
  value: void 0
25
39
  });
40
+ /** Cached data core ID */
26
41
  Object.defineProperty(this, "dataCoreId", {
27
42
  enumerable: true,
28
43
  configurable: true,
29
44
  writable: true,
30
45
  value: void 0
31
46
  });
47
+ /** Cached flow type ID */
32
48
  Object.defineProperty(this, "flowTypeId", {
33
49
  enumerable: true,
34
50
  configurable: true,
35
51
  writable: true,
36
52
  value: void 0
37
53
  });
54
+ /** Cached event type IDs */
38
55
  Object.defineProperty(this, "eventTypeIds", {
39
56
  enumerable: true,
40
57
  configurable: true,
41
58
  writable: true,
42
59
  value: void 0
43
60
  });
61
+ /** Cached time buckets */
44
62
  Object.defineProperty(this, "timeBuckets", {
45
63
  enumerable: true,
46
64
  configurable: true,
@@ -49,18 +67,38 @@ class FlowcoreDataSource {
49
67
  });
50
68
  this.flowcoreClient = (0, flowcore_client_js_1.getFlowcoreClient)(this.options.auth, this.options.baseUrlOverride);
51
69
  }
70
+ /**
71
+ * Gets the tenant name from the data source configuration
72
+ * @returns Tenant name
73
+ */
52
74
  get tenant() {
53
75
  return this.options.dataSource.tenant;
54
76
  }
77
+ /**
78
+ * Gets the data core name from the data source configuration
79
+ * @returns Data core name
80
+ */
55
81
  get dataCore() {
56
82
  return this.options.dataSource.dataCore;
57
83
  }
84
+ /**
85
+ * Gets the flow type name from the data source configuration
86
+ * @returns Flow type name
87
+ */
58
88
  get flowType() {
59
89
  return this.options.dataSource.flowType;
60
90
  }
91
+ /**
92
+ * Gets the event type names from the data source configuration
93
+ * @returns Array of event type names
94
+ */
61
95
  get eventTypes() {
62
96
  return this.options.dataSource.eventTypes;
63
97
  }
98
+ /**
99
+ * Gets the tenant ID, translating from name if necessary
100
+ * @returns Promise that resolves to the tenant ID
101
+ */
64
102
  async getTenantId() {
65
103
  if (this.tenantId) {
66
104
  return this.tenantId;
@@ -77,6 +115,10 @@ class FlowcoreDataSource {
77
115
  }
78
116
  return this.tenantId;
79
117
  }
118
+ /**
119
+ * Gets the data core ID, translating from name if necessary
120
+ * @returns Promise that resolves to the data core ID
121
+ */
80
122
  async getDataCoreId() {
81
123
  if (this.dataCoreId) {
82
124
  return this.dataCoreId;
@@ -94,6 +136,10 @@ class FlowcoreDataSource {
94
136
  }
95
137
  return this.dataCoreId;
96
138
  }
139
+ /**
140
+ * Gets the flow type ID, translating from name if necessary
141
+ * @returns Promise that resolves to the flow type ID
142
+ */
97
143
  async getFlowTypeId() {
98
144
  if (this.flowTypeId) {
99
145
  return this.flowTypeId;
@@ -111,6 +157,11 @@ class FlowcoreDataSource {
111
157
  }
112
158
  return this.flowTypeId;
113
159
  }
160
+ /**
161
+ * Gets the event type IDs, translating from names if necessary
162
+ * @returns Promise that resolves to an array of event type IDs
163
+ * @throws Error if an event type is not found
164
+ */
114
165
  async getEventTypeIds() {
115
166
  if (this.eventTypeIds) {
116
167
  return this.eventTypeIds;
@@ -135,6 +186,11 @@ class FlowcoreDataSource {
135
186
  }
136
187
  return this.eventTypeIds;
137
188
  }
189
+ /**
190
+ * Gets all time buckets for the configured event types
191
+ * @param force - When true, forces a refresh of cached time buckets
192
+ * @returns Promise that resolves to an array of time bucket strings
193
+ */
138
194
  async getTimeBuckets(force = false) {
139
195
  if (this.timeBuckets && !force) {
140
196
  return this.timeBuckets;
@@ -154,6 +210,11 @@ class FlowcoreDataSource {
154
210
  this.timeBuckets = timeBuckets;
155
211
  return this.timeBuckets;
156
212
  }
213
+ /**
214
+ * Gets the next time bucket after the specified time bucket
215
+ * @param timeBucket - The reference time bucket
216
+ * @returns Promise that resolves to the next time bucket, or null if none exists
217
+ */
157
218
  async getNextTimeBucket(timeBucket) {
158
219
  const closestTimeBucket = await this.getClosestTimeBucket(timeBucket);
159
220
  if (!closestTimeBucket) {
@@ -166,6 +227,13 @@ class FlowcoreDataSource {
166
227
  }
167
228
  return timeBuckets[index + 1] ?? null;
168
229
  }
230
+ /**
231
+ * Gets the closest time bucket to the specified time bucket
232
+ * @param timeBucket - The reference time bucket
233
+ * @param getBefore - When true, gets the closest time bucket before the reference
234
+ * @returns Promise that resolves to the closest time bucket, or null if none exists
235
+ * @throws Error if the time bucket format is invalid
236
+ */
169
237
  async getClosestTimeBucket(timeBucket, getBefore = false) {
170
238
  const timeBuckets = await this.getTimeBuckets();
171
239
  if (!timeBucket.match(/^\d{14}$/)) {
@@ -178,6 +246,13 @@ class FlowcoreDataSource {
178
246
  return (timeBuckets.find((t) => Number.parseFloat(t) >= Number.parseFloat(timeBucket)) ??
179
247
  timeBuckets[timeBuckets.length - 1]);
180
248
  }
249
+ /**
250
+ * Gets events from the data source starting from a specific state
251
+ * @param from - The state to start from (includes timeBucket and eventId)
252
+ * @param amount - Maximum number of events to retrieve
253
+ * @param toEventId - Optional ID to stop at when retrieving events
254
+ * @returns Promise that resolves to an array of Flowcore events
255
+ */
181
256
  async getEvents(from, amount, toEventId) {
182
257
  const eventTypeIds = await this.getEventTypeIds();
183
258
  const result = await this.flowcoreClient.execute(new mod_js_1.EventListCommand({
package/script/mod.d.ts CHANGED
@@ -2,6 +2,7 @@ import "./_dnt.polyfills.js";
2
2
  export * from "./lib/data-pump.js";
3
3
  export * from "./lib/data-pump-create.js";
4
4
  export * from "./data-pump/data-pump.js";
5
+ export * from "./data-pump/data-source.js";
5
6
  export * from "./data-pump/metrics.js";
6
7
  export * from "./data-pump/types.js";
7
8
  //# sourceMappingURL=mod.d.ts.map
@@ -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,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,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA"}
package/script/mod.js CHANGED
@@ -18,5 +18,6 @@ require("./_dnt.polyfills.js");
18
18
  __exportStar(require("./lib/data-pump.js"), exports);
19
19
  __exportStar(require("./lib/data-pump-create.js"), exports);
20
20
  __exportStar(require("./data-pump/data-pump.js"), exports);
21
+ __exportStar(require("./data-pump/data-source.js"), exports);
21
22
  __exportStar(require("./data-pump/metrics.js"), exports);
22
23
  __exportStar(require("./data-pump/types.js"), exports);