@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 +108 -12
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1242 -767
- package/dist/browser.js.map +21 -21
- package/dist/bun.js +605 -767
- package/dist/bun.js.map +19 -20
- package/dist/debug/console/ConsoleFormatters.d.ts +45 -0
- package/dist/debug/console/ConsoleFormatters.d.ts.map +1 -0
- package/dist/node.js +605 -767
- package/dist/node.js.map +19 -20
- package/dist/task-graph/Conversions.d.ts.map +1 -1
- package/package.json +20 -11
- package/src/debug/README.md +115 -0
- package/src/storage/README.md +51 -5
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +0 -1
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 {
|
|
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
|
|
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 {
|
|
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
|
|
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
|
-
|
|
821
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
package/dist/browser.d.ts.map
CHANGED
|
@@ -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"}
|