@gravito/flux 3.0.2 → 4.0.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/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as CronScheduleOptions, W as WorkflowDefinition, a as WorkflowState, F as FluxWaitResult } from './types-CRz5XdLd.cjs';
2
- export { b as FluxConfig, c as FluxLogger, d as FluxResult, e as FluxTraceEvent, f as FluxTraceEventType, g as FluxTraceSink, L as Lock, h as LockProvider, M as MemoryLockProvider, S as StepDefinition, i as StepDescriptor, j as StepExecution, k as StepResult, l as WorkflowContext, m as WorkflowDescriptor, n as WorkflowFilter, o as WorkflowStatus, p as WorkflowStorage } from './types-CRz5XdLd.cjs';
1
+ import { C as CronScheduleOptions, W as WorkflowDefinition, a as WorkflowState, F as FluxWaitResult } from './types-CGIEQPFv.cjs';
2
+ export { b as FluxConfig, c as FluxLogger, d as FluxResult, e as FluxTraceEvent, f as FluxTraceEventType, g as FluxTraceSink, L as Lock, h as LockProvider, M as MemoryLockProvider, S as StepDefinition, i as StepDescriptor, j as StepExecution, k as StepResult, l as WorkflowContext, m as WorkflowDescriptor, n as WorkflowFilter, o as WorkflowStatus, p as WorkflowStorage } from './types-CGIEQPFv.cjs';
3
3
  import { FluxEngine } from './index.node.cjs';
4
4
  export { BatchExecutionOptions, BatchExecutor, BatchItemResult, BatchResult, ContextManager, FluxConsoleLogger, FluxSilentLogger, JsonFileTraceSink, MemoryStorage, OrbitFlux, OrbitFluxOptions, PostgreSQLStorage, PostgreSQLStorageOptions, RedisClient, RedisLockProvider, RedisLockProviderOptions, StateMachine, StepExecutor, WorkflowBuilder, createWorkflow } from './index.node.cjs';
5
+ import { QueueException } from '@gravito/core';
5
6
  export { BunSQLiteStorage, BunSQLiteStorageOptions } from './bun.cjs';
6
- import '@gravito/core';
7
7
  import 'bun:sqlite';
8
8
 
9
9
  /**
@@ -48,6 +48,9 @@ declare enum FluxErrorCode {
48
48
  /**
49
49
  * Base class for all errors thrown by the FluxEngine.
50
50
  *
51
+ * Extends QueueException from @gravito/core, enabling consistent infrastructure
52
+ * error handling across the GravitoException hierarchy.
53
+ *
51
54
  * Includes a machine-readable error code and optional context for debugging.
52
55
  *
53
56
  * @example
@@ -61,17 +64,19 @@ declare enum FluxErrorCode {
61
64
  * }
62
65
  * ```
63
66
  */
64
- declare class FluxError extends Error {
65
- readonly code: FluxErrorCode;
66
- readonly context?: Record<string, unknown> | undefined;
67
+ declare class FluxError extends QueueException {
68
+ /**
69
+ * Additional metadata related to the error.
70
+ */
71
+ readonly context?: Record<string, unknown>;
67
72
  /**
68
73
  * Creates a new FluxError.
69
74
  *
70
75
  * @param message - Human-readable error description.
71
- * @param code - Machine-readable error code.
76
+ * @param code - Machine-readable error code (FluxErrorCode enum value).
72
77
  * @param context - Additional metadata related to the error.
73
78
  */
74
- constructor(message: string, code: FluxErrorCode, context?: Record<string, unknown> | undefined);
79
+ constructor(message: string, code: FluxErrorCode | string, context?: Record<string, unknown>);
75
80
  }
76
81
  /**
77
82
  * Creates a FluxError for a missing workflow instance.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as CronScheduleOptions, W as WorkflowDefinition, a as WorkflowState, F as FluxWaitResult } from './types-CRz5XdLd.js';
2
- export { b as FluxConfig, c as FluxLogger, d as FluxResult, e as FluxTraceEvent, f as FluxTraceEventType, g as FluxTraceSink, L as Lock, h as LockProvider, M as MemoryLockProvider, S as StepDefinition, i as StepDescriptor, j as StepExecution, k as StepResult, l as WorkflowContext, m as WorkflowDescriptor, n as WorkflowFilter, o as WorkflowStatus, p as WorkflowStorage } from './types-CRz5XdLd.js';
1
+ import { C as CronScheduleOptions, W as WorkflowDefinition, a as WorkflowState, F as FluxWaitResult } from './types-CGIEQPFv.js';
2
+ export { b as FluxConfig, c as FluxLogger, d as FluxResult, e as FluxTraceEvent, f as FluxTraceEventType, g as FluxTraceSink, L as Lock, h as LockProvider, M as MemoryLockProvider, S as StepDefinition, i as StepDescriptor, j as StepExecution, k as StepResult, l as WorkflowContext, m as WorkflowDescriptor, n as WorkflowFilter, o as WorkflowStatus, p as WorkflowStorage } from './types-CGIEQPFv.js';
3
3
  import { FluxEngine } from './index.node.js';
4
4
  export { BatchExecutionOptions, BatchExecutor, BatchItemResult, BatchResult, ContextManager, FluxConsoleLogger, FluxSilentLogger, JsonFileTraceSink, MemoryStorage, OrbitFlux, OrbitFluxOptions, PostgreSQLStorage, PostgreSQLStorageOptions, RedisClient, RedisLockProvider, RedisLockProviderOptions, StateMachine, StepExecutor, WorkflowBuilder, createWorkflow } from './index.node.js';
5
+ import { QueueException } from '@gravito/core';
5
6
  export { BunSQLiteStorage, BunSQLiteStorageOptions } from './bun.js';
6
- import '@gravito/core';
7
7
  import 'bun:sqlite';
8
8
 
9
9
  /**
@@ -48,6 +48,9 @@ declare enum FluxErrorCode {
48
48
  /**
49
49
  * Base class for all errors thrown by the FluxEngine.
50
50
  *
51
+ * Extends QueueException from @gravito/core, enabling consistent infrastructure
52
+ * error handling across the GravitoException hierarchy.
53
+ *
51
54
  * Includes a machine-readable error code and optional context for debugging.
52
55
  *
53
56
  * @example
@@ -61,17 +64,19 @@ declare enum FluxErrorCode {
61
64
  * }
62
65
  * ```
63
66
  */
64
- declare class FluxError extends Error {
65
- readonly code: FluxErrorCode;
66
- readonly context?: Record<string, unknown> | undefined;
67
+ declare class FluxError extends QueueException {
68
+ /**
69
+ * Additional metadata related to the error.
70
+ */
71
+ readonly context?: Record<string, unknown>;
67
72
  /**
68
73
  * Creates a new FluxError.
69
74
  *
70
75
  * @param message - Human-readable error description.
71
- * @param code - Machine-readable error code.
76
+ * @param code - Machine-readable error code (FluxErrorCode enum value).
72
77
  * @param context - Additional metadata related to the error.
73
78
  */
74
- constructor(message: string, code: FluxErrorCode, context?: Record<string, unknown> | undefined);
79
+ constructor(message: string, code: FluxErrorCode | string, context?: Record<string, unknown>);
75
80
  }
76
81
  /**
77
82
  * Creates a FluxError for a missing workflow instance.
package/dist/index.js CHANGED
@@ -4,8 +4,6 @@ import {
4
4
  CronTrigger,
5
5
  FluxConsoleLogger,
6
6
  FluxEngine,
7
- FluxError,
8
- FluxErrorCode,
9
7
  FluxSilentLogger,
10
8
  JsonFileTraceSink,
11
9
  MemoryLockProvider,
@@ -16,9 +14,14 @@ import {
16
14
  StateMachine,
17
15
  StepExecutor,
18
16
  WorkflowBuilder,
17
+ createWorkflow
18
+ } from "./chunk-JUCSCBHA.js";
19
+ import {
20
+ BunSQLiteStorage,
21
+ FluxError,
22
+ FluxErrorCode,
19
23
  cannotRemoveRoot,
20
24
  cannotReplaceRoot,
21
- createWorkflow,
22
25
  emptyWorkflow,
23
26
  invalidInput,
24
27
  invalidJsonPointer,
@@ -31,10 +34,7 @@ import {
31
34
  workflowNameMismatch,
32
35
  workflowNotFound,
33
36
  workflowNotSuspended
34
- } from "./chunk-4DXCQ6CL.js";
35
- import {
36
- BunSQLiteStorage
37
- } from "./chunk-NAIVO7RR.js";
37
+ } from "./chunk-UZKSACBE.js";
38
38
  import {
39
39
  MermaidGenerator
40
40
  } from "./chunk-WGDTB6OC.js";
@@ -14,8 +14,8 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkWAPZDXSXcjs = require('./chunk-WAPZDXSX.cjs');
18
- require('./chunk-YXBEYVGY.cjs');
17
+ var _chunkAVWZYY7Ucjs = require('./chunk-AVWZYY7U.cjs');
18
+ require('./chunk-OAJWPPYG.cjs');
19
19
 
20
20
 
21
21
 
@@ -32,5 +32,5 @@ require('./chunk-YXBEYVGY.cjs');
32
32
 
33
33
 
34
34
 
35
- exports.BatchExecutor = _chunkWAPZDXSXcjs.BatchExecutor; exports.ContextManager = _chunkWAPZDXSXcjs.ContextManager; exports.FluxConsoleLogger = _chunkWAPZDXSXcjs.FluxConsoleLogger; exports.FluxEngine = _chunkWAPZDXSXcjs.FluxEngine; exports.FluxSilentLogger = _chunkWAPZDXSXcjs.FluxSilentLogger; exports.JsonFileTraceSink = _chunkWAPZDXSXcjs.JsonFileTraceSink; exports.MemoryLockProvider = _chunkWAPZDXSXcjs.MemoryLockProvider; exports.MemoryStorage = _chunkWAPZDXSXcjs.MemoryStorage; exports.OrbitFlux = _chunkWAPZDXSXcjs.OrbitFlux; exports.PostgreSQLStorage = _chunkWAPZDXSXcjs.PostgreSQLStorage; exports.RedisLockProvider = _chunkWAPZDXSXcjs.RedisLockProvider; exports.StateMachine = _chunkWAPZDXSXcjs.StateMachine; exports.StepExecutor = _chunkWAPZDXSXcjs.StepExecutor; exports.WorkflowBuilder = _chunkWAPZDXSXcjs.WorkflowBuilder; exports.createWorkflow = _chunkWAPZDXSXcjs.createWorkflow;
35
+ exports.BatchExecutor = _chunkAVWZYY7Ucjs.BatchExecutor; exports.ContextManager = _chunkAVWZYY7Ucjs.ContextManager; exports.FluxConsoleLogger = _chunkAVWZYY7Ucjs.FluxConsoleLogger; exports.FluxEngine = _chunkAVWZYY7Ucjs.FluxEngine; exports.FluxSilentLogger = _chunkAVWZYY7Ucjs.FluxSilentLogger; exports.JsonFileTraceSink = _chunkAVWZYY7Ucjs.JsonFileTraceSink; exports.MemoryLockProvider = _chunkAVWZYY7Ucjs.MemoryLockProvider; exports.MemoryStorage = _chunkAVWZYY7Ucjs.MemoryStorage; exports.OrbitFlux = _chunkAVWZYY7Ucjs.OrbitFlux; exports.PostgreSQLStorage = _chunkAVWZYY7Ucjs.PostgreSQLStorage; exports.RedisLockProvider = _chunkAVWZYY7Ucjs.RedisLockProvider; exports.StateMachine = _chunkAVWZYY7Ucjs.StateMachine; exports.StepExecutor = _chunkAVWZYY7Ucjs.StepExecutor; exports.WorkflowBuilder = _chunkAVWZYY7Ucjs.WorkflowBuilder; exports.createWorkflow = _chunkAVWZYY7Ucjs.createWorkflow;
36
36
  //# sourceMappingURL=index.node.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/carl/Dev/Carl/gravito-core-ci-fix/packages/flux/dist/index.node.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,43BAAC","file":"/Users/carl/Dev/Carl/gravito-core-ci-fix/packages/flux/dist/index.node.cjs"}
1
+ {"version":3,"sources":["/Users/carl/Dev/Carl/gravito-core/packages/flux/dist/index.node.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,43BAAC","file":"/Users/carl/Dev/Carl/gravito-core/packages/flux/dist/index.node.cjs"}
@@ -1,5 +1,5 @@
1
- import { l as WorkflowContext, q as StepHandlerResult, W as WorkflowDefinition, m as WorkflowDescriptor, a as WorkflowState, o as WorkflowStatus, h as LockProvider, L as Lock, S as StepDefinition, j as StepExecution, k as StepResult, c as FluxLogger, p as WorkflowStorage, n as WorkflowFilter, g as FluxTraceSink, e as FluxTraceEvent, b as FluxConfig, d as FluxResult, C as CronScheduleOptions } from './types-CRz5XdLd.cjs';
2
- export { f as FluxTraceEventType, M as MemoryLockProvider, i as StepDescriptor } from './types-CRz5XdLd.cjs';
1
+ import { l as WorkflowContext, q as StepHandlerResult, W as WorkflowDefinition, m as WorkflowDescriptor, a as WorkflowState, o as WorkflowStatus, h as LockProvider, L as Lock, S as StepDefinition, j as StepExecution, k as StepResult, c as FluxLogger, p as WorkflowStorage, n as WorkflowFilter, g as FluxTraceSink, e as FluxTraceEvent, b as FluxConfig, d as FluxResult, C as CronScheduleOptions } from './types-CGIEQPFv.cjs';
2
+ export { f as FluxTraceEventType, M as MemoryLockProvider, i as StepDescriptor } from './types-CGIEQPFv.cjs';
3
3
  import { GravitoOrbit, PlanetCore } from '@gravito/core';
4
4
 
5
5
  /**
@@ -971,7 +971,8 @@ declare class PostgreSQLStorage implements WorkflowStorage {
971
971
  /**
972
972
  * @fileoverview JSON file trace sink (NDJSON)
973
973
  *
974
- * Writes trace events to a newline-delimited JSON file.
974
+ * Writes trace events to a newline-delimited JSON file with buffering support.
975
+ * Uses RuntimeAdapter's FileSink for efficient batch writes instead of individual syscalls.
975
976
  */
976
977
 
977
978
  /**
@@ -984,6 +985,8 @@ interface JsonFileTraceSinkOptions {
984
985
  path: string;
985
986
  /** Whether to reset (clear) the file on initialization. @default true */
986
987
  reset?: boolean;
988
+ /** Buffer size for batch writes. Events are flushed when buffer reaches this size. @default 50 */
989
+ bufferSize?: number;
987
990
  }
988
991
  /**
989
992
  * A trace sink that writes events to a newline-delimited JSON (NDJSON) file.
@@ -991,11 +994,17 @@ interface JsonFileTraceSinkOptions {
991
994
  * This sink is ideal for local development and debugging as it produces
992
995
  * a human-readable and easily machine-parsable log of workflow events.
993
996
  *
997
+ * Optimizations:
998
+ * - Uses RuntimeAdapter's FileSink for buffered writes (reduces syscalls)
999
+ * - Automatic flush on buffer overflow
1000
+ * - Batch write support for better I/O efficiency
1001
+ *
994
1002
  * @example
995
1003
  * ```typescript
996
1004
  * const sink = new JsonFileTraceSink({
997
1005
  * path: './traces/workflow.jsonl',
998
- * reset: true
1006
+ * reset: true,
1007
+ * bufferSize: 100 // Flush every 100 events
999
1008
  * });
1000
1009
  * ```
1001
1010
  *
@@ -1004,8 +1013,12 @@ interface JsonFileTraceSinkOptions {
1004
1013
  declare class JsonFileTraceSink implements FluxTraceSink {
1005
1014
  private path;
1006
1015
  private ready;
1016
+ private fileSink;
1017
+ private buffer;
1018
+ private bufferSize;
1019
+ private adapter;
1007
1020
  /**
1008
- * Creates a new JSON file trace sink.
1021
+ * Creates a new JSON file trace sink with buffering support.
1009
1022
  *
1010
1023
  * @param options - Configuration options for the sink.
1011
1024
  */
@@ -1020,7 +1033,8 @@ declare class JsonFileTraceSink implements FluxTraceSink {
1020
1033
  /**
1021
1034
  * Appends a trace event to the file in NDJSON format.
1022
1035
  *
1023
- * Waits for initialization to complete before writing.
1036
+ * Events are buffered and written in batches using FileSink
1037
+ * for improved I/O efficiency. Waits for initialization to complete before writing.
1024
1038
  *
1025
1039
  * @param event - The trace event to record.
1026
1040
  * @throws {Error} If writing to the file fails.
@@ -1036,6 +1050,23 @@ declare class JsonFileTraceSink implements FluxTraceSink {
1036
1050
  * ```
1037
1051
  */
1038
1052
  emit(event: FluxTraceEvent): Promise<void>;
1053
+ /**
1054
+ * Flushes buffered events to disk.
1055
+ *
1056
+ * This is called automatically when the buffer reaches the configured size.
1057
+ * Can also be called manually to ensure all events are written.
1058
+ *
1059
+ * @throws {Error} If flushing fails.
1060
+ */
1061
+ flushBuffer(): Promise<void>;
1062
+ /**
1063
+ * Closes the sink and flushes any remaining buffered events.
1064
+ *
1065
+ * Should be called before process exit to ensure all events are persisted.
1066
+ *
1067
+ * @throws {Error} If closing or flushing fails.
1068
+ */
1069
+ close(): Promise<void>;
1039
1070
  }
1040
1071
 
1041
1072
  /**
@@ -1,5 +1,5 @@
1
- import { l as WorkflowContext, q as StepHandlerResult, W as WorkflowDefinition, m as WorkflowDescriptor, a as WorkflowState, o as WorkflowStatus, h as LockProvider, L as Lock, S as StepDefinition, j as StepExecution, k as StepResult, c as FluxLogger, p as WorkflowStorage, n as WorkflowFilter, g as FluxTraceSink, e as FluxTraceEvent, b as FluxConfig, d as FluxResult, C as CronScheduleOptions } from './types-CRz5XdLd.js';
2
- export { f as FluxTraceEventType, M as MemoryLockProvider, i as StepDescriptor } from './types-CRz5XdLd.js';
1
+ import { l as WorkflowContext, q as StepHandlerResult, W as WorkflowDefinition, m as WorkflowDescriptor, a as WorkflowState, o as WorkflowStatus, h as LockProvider, L as Lock, S as StepDefinition, j as StepExecution, k as StepResult, c as FluxLogger, p as WorkflowStorage, n as WorkflowFilter, g as FluxTraceSink, e as FluxTraceEvent, b as FluxConfig, d as FluxResult, C as CronScheduleOptions } from './types-CGIEQPFv.js';
2
+ export { f as FluxTraceEventType, M as MemoryLockProvider, i as StepDescriptor } from './types-CGIEQPFv.js';
3
3
  import { GravitoOrbit, PlanetCore } from '@gravito/core';
4
4
 
5
5
  /**
@@ -971,7 +971,8 @@ declare class PostgreSQLStorage implements WorkflowStorage {
971
971
  /**
972
972
  * @fileoverview JSON file trace sink (NDJSON)
973
973
  *
974
- * Writes trace events to a newline-delimited JSON file.
974
+ * Writes trace events to a newline-delimited JSON file with buffering support.
975
+ * Uses RuntimeAdapter's FileSink for efficient batch writes instead of individual syscalls.
975
976
  */
976
977
 
977
978
  /**
@@ -984,6 +985,8 @@ interface JsonFileTraceSinkOptions {
984
985
  path: string;
985
986
  /** Whether to reset (clear) the file on initialization. @default true */
986
987
  reset?: boolean;
988
+ /** Buffer size for batch writes. Events are flushed when buffer reaches this size. @default 50 */
989
+ bufferSize?: number;
987
990
  }
988
991
  /**
989
992
  * A trace sink that writes events to a newline-delimited JSON (NDJSON) file.
@@ -991,11 +994,17 @@ interface JsonFileTraceSinkOptions {
991
994
  * This sink is ideal for local development and debugging as it produces
992
995
  * a human-readable and easily machine-parsable log of workflow events.
993
996
  *
997
+ * Optimizations:
998
+ * - Uses RuntimeAdapter's FileSink for buffered writes (reduces syscalls)
999
+ * - Automatic flush on buffer overflow
1000
+ * - Batch write support for better I/O efficiency
1001
+ *
994
1002
  * @example
995
1003
  * ```typescript
996
1004
  * const sink = new JsonFileTraceSink({
997
1005
  * path: './traces/workflow.jsonl',
998
- * reset: true
1006
+ * reset: true,
1007
+ * bufferSize: 100 // Flush every 100 events
999
1008
  * });
1000
1009
  * ```
1001
1010
  *
@@ -1004,8 +1013,12 @@ interface JsonFileTraceSinkOptions {
1004
1013
  declare class JsonFileTraceSink implements FluxTraceSink {
1005
1014
  private path;
1006
1015
  private ready;
1016
+ private fileSink;
1017
+ private buffer;
1018
+ private bufferSize;
1019
+ private adapter;
1007
1020
  /**
1008
- * Creates a new JSON file trace sink.
1021
+ * Creates a new JSON file trace sink with buffering support.
1009
1022
  *
1010
1023
  * @param options - Configuration options for the sink.
1011
1024
  */
@@ -1020,7 +1033,8 @@ declare class JsonFileTraceSink implements FluxTraceSink {
1020
1033
  /**
1021
1034
  * Appends a trace event to the file in NDJSON format.
1022
1035
  *
1023
- * Waits for initialization to complete before writing.
1036
+ * Events are buffered and written in batches using FileSink
1037
+ * for improved I/O efficiency. Waits for initialization to complete before writing.
1024
1038
  *
1025
1039
  * @param event - The trace event to record.
1026
1040
  * @throws {Error} If writing to the file fails.
@@ -1036,6 +1050,23 @@ declare class JsonFileTraceSink implements FluxTraceSink {
1036
1050
  * ```
1037
1051
  */
1038
1052
  emit(event: FluxTraceEvent): Promise<void>;
1053
+ /**
1054
+ * Flushes buffered events to disk.
1055
+ *
1056
+ * This is called automatically when the buffer reaches the configured size.
1057
+ * Can also be called manually to ensure all events are written.
1058
+ *
1059
+ * @throws {Error} If flushing fails.
1060
+ */
1061
+ flushBuffer(): Promise<void>;
1062
+ /**
1063
+ * Closes the sink and flushes any remaining buffered events.
1064
+ *
1065
+ * Should be called before process exit to ensure all events are persisted.
1066
+ *
1067
+ * @throws {Error} If closing or flushing fails.
1068
+ */
1069
+ close(): Promise<void>;
1039
1070
  }
1040
1071
 
1041
1072
  /**
@@ -14,8 +14,8 @@ import {
14
14
  StepExecutor,
15
15
  WorkflowBuilder,
16
16
  createWorkflow
17
- } from "./chunk-4DXCQ6CL.js";
18
- import "./chunk-NAIVO7RR.js";
17
+ } from "./chunk-JUCSCBHA.js";
18
+ import "./chunk-UZKSACBE.js";
19
19
  export {
20
20
  BatchExecutor,
21
21
  ContextManager,
@@ -359,6 +359,16 @@ interface FluxTraceSink {
359
359
  * @param event - The event to record.
360
360
  */
361
361
  emit(event: FluxTraceEvent): void | Promise<void>;
362
+ /**
363
+ * Optional method to flush any buffered events.
364
+ * Called to ensure all events are persisted before shutdown.
365
+ */
366
+ flush?(): Promise<void>;
367
+ /**
368
+ * Optional method to close the sink and release resources.
369
+ * Should be called before process exit.
370
+ */
371
+ close?(): Promise<void>;
362
372
  }
363
373
  /**
364
374
  * Global configuration for the Flux engine instance.
@@ -359,6 +359,16 @@ interface FluxTraceSink {
359
359
  * @param event - The event to record.
360
360
  */
361
361
  emit(event: FluxTraceEvent): void | Promise<void>;
362
+ /**
363
+ * Optional method to flush any buffered events.
364
+ * Called to ensure all events are persisted before shutdown.
365
+ */
366
+ flush?(): Promise<void>;
367
+ /**
368
+ * Optional method to close the sink and release resources.
369
+ * Should be called before process exit.
370
+ */
371
+ close?(): Promise<void>;
362
372
  }
363
373
  /**
364
374
  * Global configuration for the Flux engine instance.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@gravito/flux",
3
- "version": "3.0.2",
3
+ "sideEffects": false,
4
+ "version": "4.0.0",
4
5
  "description": "Platform-agnostic workflow engine for Gravito",
5
6
  "type": "module",
6
7
  "main": "./dist/index.node.cjs",
@@ -39,6 +40,7 @@
39
40
  ],
40
41
  "scripts": {
41
42
  "build": "tsup",
43
+ "build:dts": "tsup --dts --dts-only",
42
44
  "dev:viewer": "node ./bin/flux.js dev --trace ./.flux/trace.ndjson --port 4280",
43
45
  "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
44
46
  "test": "bun test --timeout=10000",
@@ -48,7 +50,7 @@
48
50
  "test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'"
49
51
  },
50
52
  "peerDependencies": {
51
- "@gravito/core": "^1.6.1",
53
+ "@gravito/core": "^3.0.0",
52
54
  "pg": "^8.18.0"
53
55
  },
54
56
  "peerDependenciesMeta": {
@@ -60,7 +62,7 @@
60
62
  }
61
63
  },
62
64
  "devDependencies": {
63
- "@gravito/core": "^1.6.1",
65
+ "@gravito/core": "workspace:*",
64
66
  "@types/pg": "^8.16.0",
65
67
  "bun-types": "latest",
66
68
  "pg": "^8.18.0",