@gravito/flux 3.0.1 → 3.0.2

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 (48) hide show
  1. package/README.md +298 -0
  2. package/bin/flux.js +25 -1
  3. package/dev/viewer/app.js +4 -4
  4. package/dist/bun.cjs +2 -2
  5. package/dist/bun.cjs.map +1 -1
  6. package/dist/bun.d.cts +65 -26
  7. package/dist/bun.d.ts +65 -26
  8. package/dist/bun.js +1 -1
  9. package/dist/chunk-4DXCQ6CL.js +3486 -0
  10. package/dist/chunk-4DXCQ6CL.js.map +1 -0
  11. package/dist/chunk-6AZNHVEO.cjs +316 -0
  12. package/dist/chunk-6AZNHVEO.cjs.map +1 -0
  13. package/dist/{chunk-ZAMVC732.js → chunk-NAIVO7RR.js} +64 -15
  14. package/dist/chunk-NAIVO7RR.js.map +1 -0
  15. package/dist/chunk-WAPZDXSX.cjs +3486 -0
  16. package/dist/chunk-WAPZDXSX.cjs.map +1 -0
  17. package/dist/chunk-WGDTB6OC.js +316 -0
  18. package/dist/chunk-WGDTB6OC.js.map +1 -0
  19. package/dist/{chunk-SJSPR4ZU.cjs → chunk-YXBEYVGY.cjs} +66 -17
  20. package/dist/chunk-YXBEYVGY.cjs.map +1 -0
  21. package/dist/cli/flux-visualize.cjs +108 -0
  22. package/dist/cli/flux-visualize.cjs.map +1 -0
  23. package/dist/cli/flux-visualize.d.cts +1 -0
  24. package/dist/cli/flux-visualize.d.ts +1 -0
  25. package/dist/cli/flux-visualize.js +108 -0
  26. package/dist/cli/flux-visualize.js.map +1 -0
  27. package/dist/index.cjs +97 -9
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +369 -13
  30. package/dist/index.d.ts +369 -13
  31. package/dist/index.js +96 -8
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.node.cjs +11 -3
  34. package/dist/index.node.cjs.map +1 -1
  35. package/dist/index.node.d.cts +1110 -247
  36. package/dist/index.node.d.ts +1110 -247
  37. package/dist/index.node.js +10 -2
  38. package/dist/types-CRz5XdLd.d.cts +433 -0
  39. package/dist/types-CRz5XdLd.d.ts +433 -0
  40. package/package.json +17 -6
  41. package/dist/chunk-3JGQYHUN.js +0 -1006
  42. package/dist/chunk-3JGQYHUN.js.map +0 -1
  43. package/dist/chunk-5OXXH442.cjs +0 -1006
  44. package/dist/chunk-5OXXH442.cjs.map +0 -1
  45. package/dist/chunk-SJSPR4ZU.cjs.map +0 -1
  46. package/dist/chunk-ZAMVC732.js.map +0 -1
  47. package/dist/types-CZwYGpou.d.cts +0 -353
  48. package/dist/types-CZwYGpou.d.ts +0 -353
package/dist/bun.d.ts CHANGED
@@ -1,74 +1,113 @@
1
1
  import { Database } from 'bun:sqlite';
2
- import { o as WorkflowStorage, m as WorkflowState, l as WorkflowFilter } from './types-CZwYGpou.js';
2
+ import { p as WorkflowStorage, a as WorkflowState, n as WorkflowFilter } from './types-CRz5XdLd.js';
3
3
 
4
4
  /**
5
- * @fileoverview Bun SQLite Storage Adapter
6
- *
7
- * High-performance storage using Bun's built-in SQLite.
8
- *
9
- * @module @gravito/flux/storage
10
- */
11
-
12
- /**
13
- * SQLite Storage Options
5
+ * Configuration options for the Bun SQLite storage adapter.
14
6
  */
15
7
  interface BunSQLiteStorageOptions {
16
- /** Database file path (default: ':memory:') */
8
+ /**
9
+ * Path to the SQLite database file.
10
+ * Use ':memory:' for an ephemeral in-memory database.
11
+ */
17
12
  path?: string;
18
- /** Table name (default: 'flux_workflows') */
13
+ /**
14
+ * Name of the table used to store workflow states.
15
+ */
19
16
  tableName?: string;
20
17
  }
21
18
  /**
22
- * Bun SQLite Storage
19
+ * BunSQLiteStorage provides a persistent storage backend for Flux workflows using Bun's native SQLite module.
23
20
  *
24
- * High-performance storage adapter using Bun's built-in SQLite.
21
+ * It handles automatic table creation, indexing for performance, and serialization of workflow state
22
+ * into a relational format.
25
23
  *
26
24
  * @example
27
25
  * ```typescript
28
- * const engine = new FluxEngine({
29
- * storage: new BunSQLiteStorage({ path: './data/flux.db' })
30
- * })
26
+ * const storage = new BunSQLiteStorage({
27
+ * path: './workflows.db',
28
+ * tableName: 'my_workflows'
29
+ * });
30
+ * await storage.init();
31
31
  * ```
32
32
  */
33
33
  declare class BunSQLiteStorage implements WorkflowStorage {
34
34
  private db;
35
35
  private tableName;
36
36
  private initialized;
37
+ /**
38
+ * Creates a new instance of BunSQLiteStorage.
39
+ *
40
+ * @param options - Configuration for the database connection and table naming.
41
+ */
37
42
  constructor(options?: BunSQLiteStorageOptions);
38
43
  /**
39
- * Initialize storage (create tables)
44
+ * Initializes the database schema and required indexes.
45
+ *
46
+ * This method is idempotent and will be called automatically by other operations if not invoked manually.
47
+ *
48
+ * @throws {Error} If the database schema cannot be created or indexes fail to initialize.
40
49
  */
41
50
  init(): Promise<void>;
42
51
  /**
43
- * Save workflow state
52
+ * Persists or updates a workflow state in the database.
53
+ *
54
+ * Uses an "INSERT OR REPLACE" strategy to ensure the latest state is always stored for a given ID.
55
+ *
56
+ * @param state - The current state of the workflow to be saved.
57
+ * @throws {Error} If the database write operation fails or serialization errors occur.
44
58
  */
45
59
  save(state: WorkflowState): Promise<void>;
46
60
  /**
47
- * Load workflow state by ID
61
+ * Retrieves a workflow state by its unique identifier.
62
+ *
63
+ * @param id - The unique ID of the workflow to load.
64
+ * @returns The reconstructed workflow state, or null if no record is found.
65
+ * @throws {Error} If the database query fails or deserialization of stored JSON fails.
48
66
  */
49
67
  load(id: string): Promise<WorkflowState | null>;
50
68
  /**
51
- * List workflow states with optional filter
69
+ * Lists workflow states based on the provided filtering criteria.
70
+ *
71
+ * Results are returned in descending order of creation time.
72
+ *
73
+ * @param filter - Criteria for filtering and paginating the results.
74
+ * @returns An array of workflow states matching the filter.
75
+ * @throws {Error} If the database query fails.
52
76
  */
53
77
  list(filter?: WorkflowFilter): Promise<WorkflowState[]>;
54
78
  /**
55
- * Delete workflow state
79
+ * Deletes a workflow state from the database.
80
+ *
81
+ * @param id - The unique ID of the workflow to delete.
82
+ * @throws {Error} If the database deletion fails.
56
83
  */
57
84
  delete(id: string): Promise<void>;
58
85
  /**
59
- * Close database connection
86
+ * Closes the database connection and resets the initialization state.
87
+ *
88
+ * @throws {Error} If the database connection cannot be closed cleanly.
60
89
  */
61
90
  close(): Promise<void>;
62
91
  /**
63
- * Convert SQLite row to WorkflowState
92
+ * Converts a raw database row into a structured WorkflowState object.
93
+ *
94
+ * @param row - The raw SQLite row data.
95
+ * @returns The parsed workflow state.
96
+ * @private
64
97
  */
65
98
  private rowToState;
66
99
  /**
67
- * Get raw database (for advanced usage)
100
+ * Provides direct access to the underlying Bun SQLite Database instance.
101
+ *
102
+ * Useful for performing custom queries or maintenance tasks.
103
+ *
104
+ * @returns The raw Database instance.
68
105
  */
69
106
  getDatabase(): Database;
70
107
  /**
71
- * Run a vacuum to optimize database
108
+ * Performs a VACUUM operation to reclaim unused space and defragment the database.
109
+ *
110
+ * @throws {Error} If the VACUUM operation fails.
72
111
  */
73
112
  vacuum(): void;
74
113
  }
package/dist/bun.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BunSQLiteStorage
3
- } from "./chunk-ZAMVC732.js";
3
+ } from "./chunk-NAIVO7RR.js";
4
4
  export {
5
5
  BunSQLiteStorage
6
6
  };