@workglow/task-graph 0.0.124 → 0.0.126

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/README.md CHANGED
@@ -32,6 +32,10 @@ bun add @workglow/task-graph
32
32
  yarn add @workglow/task-graph
33
33
  ```
34
34
 
35
+ ### Browser debugging
36
+
37
+ For Chrome DevTools custom formatters (`Workflow`, `TaskGraph`, `Task`, etc.), import `installDevToolsFormatters` from **`@workglow/task-graph`** (browser build only). See [`src/debug/README.md`](./src/debug/README.md).
38
+
35
39
  ## Quick Start
36
40
 
37
41
  Here's a simple example that demonstrates the core concepts:
@@ -711,9 +715,16 @@ const result = await workflow.run();
711
715
  Output caching lets repeat executions with identical inputs return instantly without redoing work.
712
716
 
713
717
  ```typescript
714
- import { Task, TaskGraph, Workflow } from "@workglow/task-graph";
718
+ import {
719
+ Task,
720
+ TaskGraph,
721
+ Workflow,
722
+ TaskOutputPrimaryKeyNames,
723
+ TaskOutputSchema,
724
+ TaskOutputTabularRepository,
725
+ } from "@workglow/task-graph";
726
+ import { InMemoryTabularStorage } from "@workglow/storage";
715
727
  import { DataPortSchema } from "@workglow/util";
716
- import { InMemoryTaskOutputRepository } from "@workglow/test";
717
728
 
718
729
  // A cacheable task that simulates expensive work
719
730
  class ExpensiveTask extends Task<{ n: number }, { result: number }> {
@@ -750,7 +761,11 @@ class ExpensiveTask extends Task<{ n: number }, { result: number }> {
750
761
  }
751
762
 
752
763
  // Create an output cache
753
- const outputCache = new InMemoryTaskOutputRepository();
764
+ const outputCache = new TaskOutputTabularRepository({
765
+ tabularRepository: new InMemoryTabularStorage(TaskOutputSchema, TaskOutputPrimaryKeyNames, [
766
+ "createdAt",
767
+ ]),
768
+ });
754
769
 
755
770
  // Example 1: TaskGraph caching (second run is near-instant)
756
771
  const graph = new TaskGraph({ outputCache });
@@ -799,10 +814,22 @@ console.log({ wfFirstMs, wfSecondMs });
799
814
  ### Task Graph Persistence
800
815
 
801
816
  ```typescript
802
- import { FsFolderTaskGraphRepository } from "@workglow/test";
817
+ import {
818
+ TaskGraph,
819
+ TaskGraphPrimaryKeyNames,
820
+ TaskGraphSchema,
821
+ TaskGraphTabularRepository,
822
+ } from "@workglow/task-graph";
823
+ import { FsFolderTabularStorage } from "@workglow/storage";
803
824
 
804
825
  // Create repository
805
- const repository = new FsFolderTaskGraphRepository("./task-graphs");
826
+ const repository = new TaskGraphTabularRepository({
827
+ tabularRepository: new FsFolderTabularStorage(
828
+ "./task-graphs",
829
+ TaskGraphSchema,
830
+ TaskGraphPrimaryKeyNames
831
+ ),
832
+ });
806
833
 
807
834
  // Save task graph
808
835
  const graph = new TaskGraph();
@@ -816,18 +843,87 @@ const results = await loadedGraph.run();
816
843
 
817
844
  ### Different Storage Options
818
845
 
846
+ Wire `TaskOutputTabularRepository` / `TaskGraphTabularRepository` from `@workglow/task-graph` to a `*TabularStorage` from `@workglow/storage`:
847
+
819
848
  ```typescript
820
- // In-memory (for testing)
821
- import { InMemoryTaskOutputRepository, InMemoryTaskGraphRepository } from "@workglow/test";
849
+ import {
850
+ TaskGraphPrimaryKeyNames,
851
+ TaskGraphSchema,
852
+ TaskGraphTabularRepository,
853
+ TaskOutputPrimaryKeyNames,
854
+ TaskOutputSchema,
855
+ TaskOutputTabularRepository,
856
+ } from "@workglow/task-graph";
857
+ import {
858
+ FsFolderTabularStorage,
859
+ InMemoryTabularStorage,
860
+ IndexedDbTabularStorage,
861
+ SqliteTabularStorage,
862
+ } from "@workglow/storage";
863
+ import { Sqlite } from "@workglow/storage/sqlite";
864
+
865
+ // In-memory (e.g. tests)
866
+ const memoryOutput = new TaskOutputTabularRepository({
867
+ tabularRepository: new InMemoryTabularStorage(TaskOutputSchema, TaskOutputPrimaryKeyNames, [
868
+ "createdAt",
869
+ ]),
870
+ });
871
+ const memoryGraph = new TaskGraphTabularRepository({
872
+ tabularRepository: new InMemoryTabularStorage(TaskGraphSchema, TaskGraphPrimaryKeyNames),
873
+ });
822
874
 
823
875
  // File system
824
- import { FsFolderTaskOutputRepository, FsFolderTaskGraphRepository } from "@workglow/test";
876
+ const fsOutput = new TaskOutputTabularRepository({
877
+ tabularRepository: new FsFolderTabularStorage(
878
+ "./task-output-cache",
879
+ TaskOutputSchema,
880
+ TaskOutputPrimaryKeyNames
881
+ ),
882
+ });
883
+ const fsGraph = new TaskGraphTabularRepository({
884
+ tabularRepository: new FsFolderTabularStorage(
885
+ "./task-graphs",
886
+ TaskGraphSchema,
887
+ TaskGraphPrimaryKeyNames
888
+ ),
889
+ });
825
890
 
826
- // SQLite
827
- import { SqliteTaskOutputRepository, SqliteTaskGraphRepository } from "@workglow/test";
891
+ // SQLite (await Sqlite.init() once before using a path or new Sqlite.Database)
892
+ await Sqlite.init();
893
+ const sqliteOutput = new TaskOutputTabularRepository({
894
+ tabularRepository: new SqliteTabularStorage(
895
+ ":memory:",
896
+ "task_outputs",
897
+ TaskOutputSchema,
898
+ TaskOutputPrimaryKeyNames,
899
+ ["createdAt"]
900
+ ),
901
+ });
902
+ const sqliteGraph = new TaskGraphTabularRepository({
903
+ tabularRepository: new SqliteTabularStorage(
904
+ ":memory:",
905
+ "task_graphs",
906
+ TaskGraphSchema,
907
+ TaskGraphPrimaryKeyNames
908
+ ),
909
+ });
828
910
 
829
- // IndexedDB (browser)
830
- import { IndexedDbTaskOutputRepository, IndexedDbTaskGraphRepository } from "@workglow/test";
911
+ // IndexedDB (browser) — the `@workglow/web` example under `examples/web` includes small helpers
912
+ const idbOutput = new TaskOutputTabularRepository({
913
+ tabularRepository: new IndexedDbTabularStorage(
914
+ "task_outputs",
915
+ TaskOutputSchema,
916
+ TaskOutputPrimaryKeyNames,
917
+ ["createdAt"]
918
+ ),
919
+ });
920
+ const idbGraph = new TaskGraphTabularRepository({
921
+ tabularRepository: new IndexedDbTabularStorage(
922
+ "task_graphs",
923
+ TaskGraphSchema,
924
+ TaskGraphPrimaryKeyNames
925
+ ),
926
+ });
831
927
  ```
832
928
 
833
929
  ## Error Handling
package/dist/browser.d.ts CHANGED
@@ -4,4 +4,5 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  export * from "./common";
7
+ export * from "./debug/console/ConsoleFormatters";
7
8
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,mCAAmC,CAAC"}