yaml-flow 5.4.2 → 7.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/board-live-cards-cli.js +6 -6
- package/browser/asset-integrity.json +10 -0
- package/browser/board-livecards-client.js +2 -0
- package/browser/board-livecards-client.js.map +1 -0
- package/browser/board-livecards-localstorage.js +10 -0
- package/browser/board-livecards-localstorage.js.map +1 -0
- package/browser/board-livegraph-engine.js +2 -1676
- package/browser/board-livegraph-engine.js.map +1 -1
- package/browser/card-compute.js +28 -28
- package/browser/compute-jsonata.js +5 -0
- package/browser/compute-jsonata.js.map +1 -0
- package/browser/live-cards.js +561 -129
- package/browser/live-cards.schema.json +418 -132
- package/card-store.js +37 -0
- package/dist/batch/index.cjs +1 -108
- package/dist/batch/index.cjs.map +1 -1
- package/dist/batch/index.js +1 -106
- package/dist/batch/index.js.map +1 -1
- package/dist/board-live-cards-lib-Bg6EvCo5.d.cts +136 -0
- package/dist/board-live-cards-lib-jM2uYG1v.d.ts +136 -0
- package/dist/board-live-cards-public-CW5074xr.d.cts +318 -0
- package/dist/board-live-cards-public-hnZo0mAf.d.ts +318 -0
- package/dist/board-livegraph-runtime/index.cjs +2 -1671
- package/dist/board-livegraph-runtime/index.cjs.map +1 -1
- package/dist/board-livegraph-runtime/index.d.cts +12 -11
- package/dist/board-livegraph-runtime/index.d.ts +12 -11
- package/dist/board-livegraph-runtime/index.js +2 -1662
- package/dist/board-livegraph-runtime/index.js.map +1 -1
- package/dist/board-livegraph-runtime/jsonata-sync.cjs +7623 -0
- package/dist/card-compute/index.cjs +9 -7159
- package/dist/card-compute/index.cjs.map +1 -1
- package/dist/card-compute/index.d.cts +27 -1
- package/dist/card-compute/index.d.ts +27 -1
- package/dist/card-compute/index.js +9 -7145
- package/dist/card-compute/index.js.map +1 -1
- package/dist/card-compute/jsonata-sync.cjs +7623 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs +3 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.cjs.map +1 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.cts +37 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.d.ts +37 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js +3 -0
- package/dist/cli/browser-api/board-live-cards-browser-adapter.js.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs +2 -0
- package/dist/cli/browser-api/card-store-browser-api.cjs.map +1 -0
- package/dist/cli/browser-api/card-store-browser-api.d.cts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.d.ts +26 -0
- package/dist/cli/browser-api/card-store-browser-api.js +2 -0
- package/dist/cli/browser-api/card-store-browser-api.js.map +1 -0
- package/dist/cli/browser-api/jsonata-sync.cjs +7623 -0
- package/dist/cli/node/artifacts-store-cli.cjs +11 -0
- package/dist/cli/node/artifacts-store-cli.cjs.map +1 -0
- package/dist/cli/node/artifacts-store-cli.d.cts +8 -0
- package/dist/cli/node/artifacts-store-cli.d.ts +8 -0
- package/dist/cli/node/artifacts-store-cli.js +11 -0
- package/dist/cli/node/artifacts-store-cli.js.map +1 -0
- package/dist/cli/node/board-live-cards-cli.cjs +15 -0
- package/dist/cli/node/board-live-cards-cli.cjs.map +1 -0
- package/dist/cli/node/board-live-cards-cli.d.cts +20 -0
- package/dist/cli/node/board-live-cards-cli.d.ts +20 -0
- package/dist/cli/node/board-live-cards-cli.js +15 -0
- package/dist/cli/node/board-live-cards-cli.js.map +1 -0
- package/dist/cli/node/card-store-cli.cjs +8 -0
- package/dist/cli/node/card-store-cli.cjs.map +1 -0
- package/dist/cli/node/card-store-cli.d.cts +15 -0
- package/dist/cli/node/card-store-cli.d.ts +15 -0
- package/dist/cli/node/card-store-cli.js +8 -0
- package/dist/cli/node/card-store-cli.js.map +1 -0
- package/dist/cli/node/execution-adapter.cjs +3 -0
- package/dist/cli/node/execution-adapter.cjs.map +1 -0
- package/dist/cli/node/execution-adapter.d.cts +174 -0
- package/dist/cli/node/execution-adapter.d.ts +174 -0
- package/dist/cli/node/execution-adapter.js +3 -0
- package/dist/cli/node/execution-adapter.js.map +1 -0
- package/dist/cli/node/fs-board-adapter.cjs +14 -0
- package/dist/cli/node/fs-board-adapter.cjs.map +1 -0
- package/dist/cli/node/fs-board-adapter.d.cts +204 -0
- package/dist/cli/node/fs-board-adapter.d.ts +204 -0
- package/dist/cli/node/fs-board-adapter.js +14 -0
- package/dist/cli/node/fs-board-adapter.js.map +1 -0
- package/dist/cli/node/jsonata-sync.cjs +7623 -0
- package/dist/cli/node/source-cli-task-executor.cjs +11 -0
- package/dist/cli/node/source-cli-task-executor.cjs.map +1 -0
- package/dist/cli/node/source-cli-task-executor.d.cts +1 -0
- package/dist/cli/node/source-cli-task-executor.d.ts +1 -0
- package/dist/cli/node/source-cli-task-executor.js +11 -0
- package/dist/cli/node/source-cli-task-executor.js.map +1 -0
- package/dist/config/index.cjs +1 -79
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.js +1 -76
- package/dist/config/index.js.map +1 -1
- package/dist/continuous-event-graph/index.cjs +2 -2129
- package/dist/continuous-event-graph/index.cjs.map +1 -1
- package/dist/continuous-event-graph/index.d.cts +81 -5
- package/dist/continuous-event-graph/index.d.ts +81 -5
- package/dist/continuous-event-graph/index.js +2 -2088
- package/dist/continuous-event-graph/index.js.map +1 -1
- package/dist/continuous-event-graph/jsonata-sync.cjs +7623 -0
- package/dist/event-graph/index.cjs +22 -8292
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.js +22 -8237
- package/dist/event-graph/index.js.map +1 -1
- package/dist/execution-refs.cjs +3 -0
- package/dist/execution-refs.cjs.map +1 -0
- package/dist/execution-refs.d.cts +260 -0
- package/dist/execution-refs.d.ts +260 -0
- package/dist/execution-refs.js +3 -0
- package/dist/execution-refs.js.map +1 -0
- package/dist/index.cjs +29 -13221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +29 -13112
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +5 -617
- package/dist/inference/index.cjs.map +1 -1
- package/dist/inference/index.js +5 -610
- package/dist/inference/index.js.map +1 -1
- package/dist/jsonata-sync.cjs +7623 -0
- package/dist/{live-cards-bridge-x5XREkXm.d.cts → live-cards-bridge-BXbVTsna.d.cts} +27 -4
- package/dist/{live-cards-bridge-EQjytzI_.d.ts → live-cards-bridge-Ds28XR15.d.ts} +27 -4
- package/dist/server-runtime/index.cjs +9 -0
- package/dist/server-runtime/index.cjs.map +1 -0
- package/dist/server-runtime/index.d.cts +31 -0
- package/dist/server-runtime/index.d.ts +31 -0
- package/dist/server-runtime/index.js +9 -0
- package/dist/server-runtime/index.js.map +1 -0
- package/dist/server-runtime/jsonata-sync.cjs +7623 -0
- package/dist/step-machine/index.cjs +11 -7129
- package/dist/step-machine/index.cjs.map +1 -1
- package/dist/step-machine/index.js +11 -7113
- package/dist/step-machine/index.js.map +1 -1
- package/dist/step-machine-public/index.cjs +2 -0
- package/dist/step-machine-public/index.cjs.map +1 -0
- package/dist/step-machine-public/index.d.cts +159 -0
- package/dist/step-machine-public/index.d.ts +159 -0
- package/dist/step-machine-public/index.js +2 -0
- package/dist/step-machine-public/index.js.map +1 -0
- package/dist/step-machine-public/jsonata-sync.cjs +7623 -0
- package/dist/storage-refs.cjs +10 -0
- package/dist/storage-refs.cjs.map +1 -0
- package/dist/storage-refs.d.cts +93 -0
- package/dist/storage-refs.d.ts +93 -0
- package/dist/storage-refs.js +10 -0
- package/dist/storage-refs.js.map +1 -0
- package/dist/stores/file.cjs +1 -114
- package/dist/stores/file.cjs.map +1 -1
- package/dist/stores/file.js +1 -112
- package/dist/stores/file.js.map +1 -1
- package/dist/stores/index.cjs +1 -231
- package/dist/stores/index.cjs.map +1 -1
- package/dist/stores/index.js +1 -227
- package/dist/stores/index.js.map +1 -1
- package/dist/stores/localStorage.cjs +1 -76
- package/dist/stores/localStorage.cjs.map +1 -1
- package/dist/stores/localStorage.js +1 -74
- package/dist/stores/localStorage.js.map +1 -1
- package/dist/stores/memory.cjs +1 -47
- package/dist/stores/memory.cjs.map +1 -1
- package/dist/stores/memory.js +1 -45
- package/dist/stores/memory.js.map +1 -1
- package/dist/types-B1ZRa4aI.d.ts +147 -0
- package/dist/types-BxEFcVK9.d.cts +147 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-t4.js +291 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.js +218 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-fetch-prices.py +201 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-http-test.js +357 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-inference-adapter.js +25 -16
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-public.js +552 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.js +300 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-server.py +617 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-sse-worker.js +48 -0
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.py +366 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/.runtime-out +1 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/--base-ref/board-graph.json +32 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +70 -3
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/add-cards-cli.js +16 -11
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/init-board-cli.js +9 -8
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/poll-status-cli.js +49 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/reset-board-dir-cli.js +2 -6
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/retrigger-cli.js +4 -8
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/status-cli.js +3 -7
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/update-holdings-cli.js +9 -8
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/wait-completed-cli.js +12 -17
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers/write-prices-cli.js +2 -6
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/_board_pycli.py +107 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/add-cards.py +51 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/init-board.py +45 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/poll-status.py +71 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/handlers-py/reset-board-dir.py +36 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-demo.flow.yaml +26 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/inline-python-handlers.py +39 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker-pycli.flow.yaml +80 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.flow.yaml +36 -187
- package/examples/cli/step-machine-cli/portfolio-tracker/portfolio-tracker.input.json +40 -34
- package/examples/cli/step-machine-cli/portfolio-tracker/run-inline-python-demo-pycli.py +43 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker-pycli.py +77 -0
- package/examples/cli/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/examples/cli/step-machine-demo/jsonata-init-board-cli.js +8 -13
- package/examples/cli/step-machine-demo/jsonata-init-board.flow.yaml +33 -9
- package/examples/cli/step-machine-demo/one-step-cli-only.flow.yaml +3 -1
- package/examples/cli/step-machine-demo/step2-double-cli.js +6 -12
- package/examples/cli/step-machine-demo/two-step-math.flow.yaml +66 -4
- package/examples/cli/step-machine-demo/two-step-mixed.flow.yaml +13 -5
- package/examples/example-board/agent-instructions.md +11 -5
- package/examples/example-board/cards/_index.json +47 -0
- package/examples/example-board/cards/card-market-prices.json +33 -9
- package/examples/example-board/cards/card-my-identity.json +30 -6
- package/examples/example-board/cards/card-portfolio-action.json +24 -6
- package/examples/example-board/cards/card-portfolio-intelligence.json +97 -0
- package/examples/example-board/cards/card-portfolio-risks.json +24 -6
- package/examples/example-board/cards/card-portfolio-value.json +38 -10
- package/examples/example-board/cards/card-portfolio.json +57 -13
- package/examples/example-board/cards/card-rebalance-impact.json +22 -6
- package/examples/example-board/cards/card-rebalance-sim.json +66 -15
- package/examples/example-board/demo-chat-handler.js +14 -4
- package/examples/example-board/demo-server-config.json +1 -0
- package/examples/example-board/demo-server.js +366 -68
- package/examples/example-board/demo-shell-localstorage.html +774 -0
- package/examples/example-board/demo-shell-with-server.html +20 -37
- package/examples/example-board/demo-shell.html +5 -4
- package/examples/example-board/demo-task-executor.js +273 -275
- package/examples/index.html +0 -14
- package/examples/step-machine-cli/portfolio-tracker/handlers/_board-cli.js +0 -1
- package/examples/step-machine-cli/portfolio-tracker/run-portfolio-tracker.bat +1 -2
- package/package.json +46 -8
- package/schema/live-cards.schema.json +418 -132
- package/step-machine-cli.js +43 -310
- package/board-livecards-server-runtime.js +0 -1574
- package/browser/board-livecards-runtime-client.js +0 -263
- package/dist/cli/board-live-cards-cli.cjs +0 -10650
- package/dist/cli/board-live-cards-cli.cjs.map +0 -1
- package/dist/cli/board-live-cards-cli.d.cts +0 -179
- package/dist/cli/board-live-cards-cli.d.ts +0 -179
- package/dist/cli/board-live-cards-cli.js +0 -10598
- package/dist/cli/board-live-cards-cli.js.map +0 -1
- package/dist/journal-9HEgs7dU.d.ts +0 -28
- package/dist/journal-B-JCfQnh.d.cts +0 -28
- package/dist/schedule-Cszq9LYY.d.ts +0 -21
- package/dist/schedule-qWNL0RQh.d.cts +0 -21
- package/examples/browser/boards/portfolio-tracker/cards/holdings-table.json +0 -22
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-form.json +0 -16
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-risk-assessment.json +0 -28
- package/examples/browser/boards/portfolio-tracker/cards/portfolio-value.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/price-fetch.json +0 -15
- package/examples/browser/boards/portfolio-tracker/cards/rebalancing-strategy.json +0 -28
- package/examples/browser/boards/portfolio-tracker/fetch-prices.js +0 -43
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker-task-executor.cjs +0 -96
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.bat +0 -7
- package/examples/browser/boards/portfolio-tracker/portfolio-tracker.js +0 -351
- package/examples/cli/step-machine-demo/two-step-math-handlers.js +0 -32
- package/examples/cli/step-machine-demo/two-step-mixed-handlers.js +0 -24
- package/examples/example-board/demo-shell-browser.html +0 -674
package/card-store.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const distCli = path.join(__dirname, 'dist', 'cli', 'node', 'card-store-cli.js');
|
|
10
|
+
const srcCli = path.join(__dirname, 'src', 'cli', 'node', 'card-store-cli.ts');
|
|
11
|
+
const tsxCli = path.join(__dirname, 'node_modules', 'tsx', 'dist', 'cli.mjs');
|
|
12
|
+
|
|
13
|
+
if (fs.existsSync(srcCli)) {
|
|
14
|
+
const result = spawnSync(process.execPath, [tsxCli, srcCli, ...process.argv.slice(2)], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: false,
|
|
17
|
+
windowsHide: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
console.error(`[card-store] Failed to launch dev fallback: ${result.error.message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
process.exit(result.status ?? 0);
|
|
26
|
+
} else if (fs.existsSync(distCli)) {
|
|
27
|
+
const { cli } = await import(pathToFileUrl(distCli).href);
|
|
28
|
+
await cli(process.argv.slice(2));
|
|
29
|
+
} else {
|
|
30
|
+
console.error('[card-store] Could not find dist or src CLI entrypoint.');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function pathToFileUrl(filePath) {
|
|
35
|
+
const resolved = path.resolve(filePath).replace(/\\/g, '/');
|
|
36
|
+
return new URL(`file:///${resolved.startsWith('/') ? resolved.slice(1) : resolved}`);
|
|
37
|
+
}
|
package/dist/batch/index.cjs
CHANGED
|
@@ -1,109 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/batch/runner.ts
|
|
4
|
-
async function batch(items, options) {
|
|
5
|
-
const {
|
|
6
|
-
concurrency = 5,
|
|
7
|
-
processor,
|
|
8
|
-
onItemComplete,
|
|
9
|
-
onItemError,
|
|
10
|
-
onProgress,
|
|
11
|
-
signal
|
|
12
|
-
} = options;
|
|
13
|
-
const total = items.length;
|
|
14
|
-
const results = new Array(total);
|
|
15
|
-
const batchStart = Date.now();
|
|
16
|
-
let completed = 0;
|
|
17
|
-
let failed = 0;
|
|
18
|
-
let nextIndex = 0;
|
|
19
|
-
function makeProgress(active) {
|
|
20
|
-
const done = completed + failed;
|
|
21
|
-
return {
|
|
22
|
-
completed,
|
|
23
|
-
failed,
|
|
24
|
-
active,
|
|
25
|
-
pending: total - done - active,
|
|
26
|
-
total,
|
|
27
|
-
percent: total === 0 ? 100 : Math.round(done / total * 100),
|
|
28
|
-
elapsedMs: Date.now() - batchStart
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (total === 0) {
|
|
32
|
-
return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };
|
|
33
|
-
}
|
|
34
|
-
return new Promise((resolve) => {
|
|
35
|
-
let active = 0;
|
|
36
|
-
function tryStartNext() {
|
|
37
|
-
while (active < concurrency && nextIndex < total) {
|
|
38
|
-
if (signal?.aborted) {
|
|
39
|
-
while (nextIndex < total) {
|
|
40
|
-
const idx2 = nextIndex++;
|
|
41
|
-
results[idx2] = {
|
|
42
|
-
item: items[idx2],
|
|
43
|
-
index: idx2,
|
|
44
|
-
status: "failed",
|
|
45
|
-
error: new Error("Batch aborted"),
|
|
46
|
-
durationMs: 0
|
|
47
|
-
};
|
|
48
|
-
failed++;
|
|
49
|
-
}
|
|
50
|
-
if (active === 0 && completed + failed === total) {
|
|
51
|
-
resolve({
|
|
52
|
-
items: results,
|
|
53
|
-
completed,
|
|
54
|
-
failed,
|
|
55
|
-
total,
|
|
56
|
-
durationMs: Date.now() - batchStart
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
const idx = nextIndex++;
|
|
62
|
-
const item = items[idx];
|
|
63
|
-
active++;
|
|
64
|
-
const itemStart = Date.now();
|
|
65
|
-
processor(item, idx).then((result) => {
|
|
66
|
-
results[idx] = {
|
|
67
|
-
item,
|
|
68
|
-
index: idx,
|
|
69
|
-
status: "completed",
|
|
70
|
-
result,
|
|
71
|
-
durationMs: Date.now() - itemStart
|
|
72
|
-
};
|
|
73
|
-
completed++;
|
|
74
|
-
onItemComplete?.(item, result, idx);
|
|
75
|
-
}).catch((err) => {
|
|
76
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
77
|
-
results[idx] = {
|
|
78
|
-
item,
|
|
79
|
-
index: idx,
|
|
80
|
-
status: "failed",
|
|
81
|
-
error,
|
|
82
|
-
durationMs: Date.now() - itemStart
|
|
83
|
-
};
|
|
84
|
-
failed++;
|
|
85
|
-
onItemError?.(item, error, idx);
|
|
86
|
-
}).finally(() => {
|
|
87
|
-
active--;
|
|
88
|
-
onProgress?.(makeProgress(active));
|
|
89
|
-
if (completed + failed === total) {
|
|
90
|
-
resolve({
|
|
91
|
-
items: results,
|
|
92
|
-
completed,
|
|
93
|
-
failed,
|
|
94
|
-
total,
|
|
95
|
-
durationMs: Date.now() - batchStart
|
|
96
|
-
});
|
|
97
|
-
} else {
|
|
98
|
-
tryStartNext();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
tryStartNext();
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.batch = batch;
|
|
108
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';async function y(u,f){let{concurrency:B=5,processor:w,onItemComplete:I,onItemError:R,onProgress:x,signal:T}=f,t=u.length,a=new Array(t),m=Date.now(),r=0,o=0,l=0;function g(c){let n=r+o;return {completed:r,failed:o,active:c,pending:t-n-c,total:t,percent:t===0?100:Math.round(n/t*100),elapsedMs:Date.now()-m}}return t===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(c=>{let n=0;function d(){for(;n<B&&l<t;){if(T?.aborted){for(;l<t;){let e=l++;a[e]={item:u[e],index:e,status:"failed",error:new Error("Batch aborted"),durationMs:0},o++;}n===0&&r+o===t&&c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m});break}let s=l++,i=u[s];n++;let h=Date.now();w(i,s).then(e=>{a[s]={item:i,index:s,status:"completed",result:e,durationMs:Date.now()-h},r++,I?.(i,e,s);}).catch(e=>{let p=e instanceof Error?e:new Error(String(e));a[s]={item:i,index:s,status:"failed",error:p,durationMs:Date.now()-h},o++,R?.(i,p,s);}).finally(()=>{n--,x?.(g(n)),r+o===t?c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m}):d();});}}d();})}exports.batch=y;//# sourceMappingURL=index.cjs.map
|
|
109
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/batch/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/batch/runner.ts"],"names":["idx"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/batch/runner.ts"],"names":["batch","items","options","concurrency","processor","onItemComplete","onItemError","onProgress","signal","total","results","batchStart","completed","failed","nextIndex","makeProgress","active","done","resolve","tryStart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AAA,CAAI,CACb,IAAA,CAAAC,CAAAA,CACA,KAAA,CAAOD,EACP,MAAA,CAAQ,QAAA,CACR,KAAA,CAAAK,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIH,CAC3B,CAAA,CACAT,CAAAA,EAAAA,CACAP,CAAAA,GAAce,CAAAA,CAAMI,EAAOL,CAAG,EAChC,CAAC,CAAA,CACA,QAAQ,IAAM,CACbJ,CAAAA,EAAAA,CACAT,CAAAA,GAAaQ,CAAAA,CAAaC,CAAM,CAAC,CAAA,CAE7BJ,EAAYC,CAAAA,GAAWJ,CAAAA,CACzBS,CAAAA,CAAQ,CACN,KAAA,CAAOR,CAAAA,CACP,SAAA,CAAAE,CAAAA,CACA,OAAAC,CAAAA,CACA,KAAA,CAAAJ,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIE,CAC3B,CAAC,CAAA,CAEDQ,CAAAA,GAEJ,CAAC,EACL,CACF,CAEAA,CAAAA,GACF,CAAC,CACH","file":"index.cjs","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
|
package/dist/batch/index.js
CHANGED
|
@@ -1,107 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
async function batch(items, options) {
|
|
3
|
-
const {
|
|
4
|
-
concurrency = 5,
|
|
5
|
-
processor,
|
|
6
|
-
onItemComplete,
|
|
7
|
-
onItemError,
|
|
8
|
-
onProgress,
|
|
9
|
-
signal
|
|
10
|
-
} = options;
|
|
11
|
-
const total = items.length;
|
|
12
|
-
const results = new Array(total);
|
|
13
|
-
const batchStart = Date.now();
|
|
14
|
-
let completed = 0;
|
|
15
|
-
let failed = 0;
|
|
16
|
-
let nextIndex = 0;
|
|
17
|
-
function makeProgress(active) {
|
|
18
|
-
const done = completed + failed;
|
|
19
|
-
return {
|
|
20
|
-
completed,
|
|
21
|
-
failed,
|
|
22
|
-
active,
|
|
23
|
-
pending: total - done - active,
|
|
24
|
-
total,
|
|
25
|
-
percent: total === 0 ? 100 : Math.round(done / total * 100),
|
|
26
|
-
elapsedMs: Date.now() - batchStart
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
if (total === 0) {
|
|
30
|
-
return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };
|
|
31
|
-
}
|
|
32
|
-
return new Promise((resolve) => {
|
|
33
|
-
let active = 0;
|
|
34
|
-
function tryStartNext() {
|
|
35
|
-
while (active < concurrency && nextIndex < total) {
|
|
36
|
-
if (signal?.aborted) {
|
|
37
|
-
while (nextIndex < total) {
|
|
38
|
-
const idx2 = nextIndex++;
|
|
39
|
-
results[idx2] = {
|
|
40
|
-
item: items[idx2],
|
|
41
|
-
index: idx2,
|
|
42
|
-
status: "failed",
|
|
43
|
-
error: new Error("Batch aborted"),
|
|
44
|
-
durationMs: 0
|
|
45
|
-
};
|
|
46
|
-
failed++;
|
|
47
|
-
}
|
|
48
|
-
if (active === 0 && completed + failed === total) {
|
|
49
|
-
resolve({
|
|
50
|
-
items: results,
|
|
51
|
-
completed,
|
|
52
|
-
failed,
|
|
53
|
-
total,
|
|
54
|
-
durationMs: Date.now() - batchStart
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
const idx = nextIndex++;
|
|
60
|
-
const item = items[idx];
|
|
61
|
-
active++;
|
|
62
|
-
const itemStart = Date.now();
|
|
63
|
-
processor(item, idx).then((result) => {
|
|
64
|
-
results[idx] = {
|
|
65
|
-
item,
|
|
66
|
-
index: idx,
|
|
67
|
-
status: "completed",
|
|
68
|
-
result,
|
|
69
|
-
durationMs: Date.now() - itemStart
|
|
70
|
-
};
|
|
71
|
-
completed++;
|
|
72
|
-
onItemComplete?.(item, result, idx);
|
|
73
|
-
}).catch((err) => {
|
|
74
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
75
|
-
results[idx] = {
|
|
76
|
-
item,
|
|
77
|
-
index: idx,
|
|
78
|
-
status: "failed",
|
|
79
|
-
error,
|
|
80
|
-
durationMs: Date.now() - itemStart
|
|
81
|
-
};
|
|
82
|
-
failed++;
|
|
83
|
-
onItemError?.(item, error, idx);
|
|
84
|
-
}).finally(() => {
|
|
85
|
-
active--;
|
|
86
|
-
onProgress?.(makeProgress(active));
|
|
87
|
-
if (completed + failed === total) {
|
|
88
|
-
resolve({
|
|
89
|
-
items: results,
|
|
90
|
-
completed,
|
|
91
|
-
failed,
|
|
92
|
-
total,
|
|
93
|
-
durationMs: Date.now() - batchStart
|
|
94
|
-
});
|
|
95
|
-
} else {
|
|
96
|
-
tryStartNext();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
tryStartNext();
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { batch };
|
|
106
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
async function y(u,f){let{concurrency:B=5,processor:w,onItemComplete:I,onItemError:R,onProgress:x,signal:T}=f,t=u.length,a=new Array(t),m=Date.now(),r=0,o=0,l=0;function g(c){let n=r+o;return {completed:r,failed:o,active:c,pending:t-n-c,total:t,percent:t===0?100:Math.round(n/t*100),elapsedMs:Date.now()-m}}return t===0?{items:[],completed:0,failed:0,total:0,durationMs:0}:new Promise(c=>{let n=0;function d(){for(;n<B&&l<t;){if(T?.aborted){for(;l<t;){let e=l++;a[e]={item:u[e],index:e,status:"failed",error:new Error("Batch aborted"),durationMs:0},o++;}n===0&&r+o===t&&c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m});break}let s=l++,i=u[s];n++;let h=Date.now();w(i,s).then(e=>{a[s]={item:i,index:s,status:"completed",result:e,durationMs:Date.now()-h},r++,I?.(i,e,s);}).catch(e=>{let p=e instanceof Error?e:new Error(String(e));a[s]={item:i,index:s,status:"failed",error:p,durationMs:Date.now()-h},o++,R?.(i,p,s);}).finally(()=>{n--,x?.(g(n)),r+o===t?c({items:a,completed:r,failed:o,total:t,durationMs:Date.now()-m}):d();});}}d();})}export{y as batch};//# sourceMappingURL=index.js.map
|
|
107
2
|
//# sourceMappingURL=index.js.map
|
package/dist/batch/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/batch/runner.ts"],"names":["idx"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/batch/runner.ts"],"names":["batch","items","options","concurrency","processor","onItemComplete","onItemError","onProgress","signal","total","results","batchStart","completed","failed","nextIndex","makeProgress","active","done","resolve","tryStartNext","idx","item","itemStart","result","err","error"],"mappings":"AAoDA,eAAsBA,CAAAA,CACpBC,CAAAA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AQ,QAAA,CACR,KAAA,CAAAK,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIH,CAC3B,CAAA,CACAT,CAAAA,EAAAA,CACAP,CAAAA,GAAce,CAAAA,CAAMI,EAAOL,CAAG,EAChC,CAAC,CAAA,CACA,QAAQ,IAAM,CACbJ,CAAAA,EAAAA,CACAT,CAAAA,GAAaQ,CAAAA,CAAaC,CAAM,CAAC,CAAA,CAE7BJ,EAAYC,CAAAA,GAAWJ,CAAAA,CACzBS,CAAAA,CAAQ,CACN,KAAA,CAAOR,CAAAA,CACP,SAAA,CAAAE,CAAAA,CACA,OAAAC,CAAAA,CACA,KAAA,CAAAJ,CAAAA,CACA,UAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAAIE,CAC3B,CAAC,CAAA,CAEDQ,CAAAA,GAEJ,CAAC,EACL,CACF,CAEAA,CAAAA,GACF,CAAC,CACH","file":"index.js","sourcesContent":["/**\n * Batch Runner — Core\n *\n * Slot-based concurrent processor. Pure control flow — no I/O opinions.\n *\n * @example Step Machine batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { createStepMachine, loadStepFlow } from 'yaml-flow/step-machine';\n *\n * const flow = await loadStepFlow('./support-ticket.yaml');\n * const results = await batch(tickets, {\n * concurrency: 5,\n * processor: async (ticket) => {\n * const machine = createStepMachine(flow, handlers);\n * return machine.run(ticket);\n * },\n * });\n * ```\n *\n * @example Event Graph batch\n * ```ts\n * import { batch } from 'yaml-flow/batch';\n * import { next, apply, createInitialExecutionState } from 'yaml-flow/event-graph';\n *\n * const results = await batch(items, {\n * concurrency: 3,\n * processor: async (item, index) => {\n * let state = createInitialExecutionState(graph, `exec-${index}`);\n * state = apply(state, { type: 'inject-tokens', tokens: [item.token], timestamp: new Date().toISOString() }, graph);\n * // ... drive the graph loop\n * return state;\n * },\n * });\n * ```\n */\n\nimport type {\n BatchOptions,\n BatchResult,\n BatchItemResult,\n BatchProgress,\n} from './types.js';\n\n/**\n * Run an array of items through an async processor with concurrency control.\n *\n * - Items are started in order, up to `concurrency` at a time.\n * - Results are returned in the original item order.\n * - If a processor throws, the item is marked as failed; other items continue.\n * - An AbortSignal prevents new items from starting (in-flight items are not cancelled).\n */\nexport async function batch<TItem, TResult>(\n items: TItem[],\n options: BatchOptions<TItem, TResult>\n): Promise<BatchResult<TItem, TResult>> {\n const {\n concurrency = 5,\n processor,\n onItemComplete,\n onItemError,\n onProgress,\n signal,\n } = options;\n\n const total = items.length;\n const results: BatchItemResult<TItem, TResult>[] = new Array(total);\n const batchStart = Date.now();\n\n let completed = 0;\n let failed = 0;\n let nextIndex = 0;\n\n function makeProgress(active: number): BatchProgress {\n const done = completed + failed;\n return {\n completed,\n failed,\n active,\n pending: total - done - active,\n total,\n percent: total === 0 ? 100 : Math.round((done / total) * 100),\n elapsedMs: Date.now() - batchStart,\n };\n }\n\n // Empty input — short-circuit\n if (total === 0) {\n return { items: [], completed: 0, failed: 0, total: 0, durationMs: 0 };\n }\n\n return new Promise<BatchResult<TItem, TResult>>((resolve) => {\n let active = 0;\n\n function tryStartNext() {\n while (active < concurrency && nextIndex < total) {\n // Respect abort signal — don't start new items\n if (signal?.aborted) {\n // Mark remaining as failed with abort error\n while (nextIndex < total) {\n const idx = nextIndex++;\n results[idx] = {\n item: items[idx],\n index: idx,\n status: 'failed',\n error: new Error('Batch aborted'),\n durationMs: 0,\n };\n failed++;\n }\n // If nothing is in-flight, resolve immediately\n if (active === 0 && completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n }\n break;\n }\n\n const idx = nextIndex++;\n const item = items[idx];\n active++;\n const itemStart = Date.now();\n\n processor(item, idx)\n .then((result) => {\n results[idx] = {\n item,\n index: idx,\n status: 'completed',\n result,\n durationMs: Date.now() - itemStart,\n };\n completed++;\n onItemComplete?.(item, result, idx);\n })\n .catch((err) => {\n const error = err instanceof Error ? err : new Error(String(err));\n results[idx] = {\n item,\n index: idx,\n status: 'failed',\n error,\n durationMs: Date.now() - itemStart,\n };\n failed++;\n onItemError?.(item, error, idx);\n })\n .finally(() => {\n active--;\n onProgress?.(makeProgress(active));\n\n if (completed + failed === total) {\n resolve({\n items: results,\n completed,\n failed,\n total,\n durationMs: Date.now() - batchStart,\n });\n } else {\n tryStartNext();\n }\n });\n }\n }\n\n tryStartNext();\n });\n}\n"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { f as GraphEvent, G as GraphConfig } from './types-BBhqYGhE.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* board-live-cards-lib — Pure logic library for the board-live-cards CLI.
|
|
5
|
+
*
|
|
6
|
+
* Merged from:
|
|
7
|
+
* board-live-cards-all-stores.ts
|
|
8
|
+
* board-live-cards-lib-types.ts
|
|
9
|
+
* board-live-cards-lib-board-status.ts
|
|
10
|
+
* board-live-cards-lib-card-handler.ts
|
|
11
|
+
* board-live-cards-cli-board-commands.ts
|
|
12
|
+
* board-live-cards-cli-card-commands.ts
|
|
13
|
+
* board-live-cards-cli-callbacks.ts
|
|
14
|
+
*
|
|
15
|
+
* Zero platform imports. All storage is injected via adapter interfaces.
|
|
16
|
+
* Safe for Node, browser, and neutral (V8/PyMiniRacer) bundles.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface LiveCard {
|
|
20
|
+
id: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
interface CardIndexEntry {
|
|
24
|
+
/** Storage-specific address (file path, Cosmos doc id, localStorage key). */
|
|
25
|
+
key: string;
|
|
26
|
+
/** Checksum of card content — computed by the adapter at write time. */
|
|
27
|
+
checksum: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
}
|
|
30
|
+
type CardIndex = Record<string, CardIndexEntry>;
|
|
31
|
+
type CardChecksumIndex = Record<string, string>;
|
|
32
|
+
interface CardStorageAdapter {
|
|
33
|
+
readIndex(): CardIndex | null;
|
|
34
|
+
writeIndex(index: CardIndex): void;
|
|
35
|
+
readCard(key: string): LiveCard | null;
|
|
36
|
+
/** Write card content; returns checksum of what was written. */
|
|
37
|
+
writeCard(key: string, card: LiveCard): string;
|
|
38
|
+
cardExists(key: string): boolean;
|
|
39
|
+
defaultCardKey(cardId: string): string;
|
|
40
|
+
}
|
|
41
|
+
interface CardStore {
|
|
42
|
+
readCard(id: string): LiveCard | null;
|
|
43
|
+
readCardKey(id: string): string | null;
|
|
44
|
+
readAllCards(): LiveCard[];
|
|
45
|
+
readChecksumIndex(): CardChecksumIndex;
|
|
46
|
+
changedSince(snapshotChecksumIndex: CardChecksumIndex): string[];
|
|
47
|
+
}
|
|
48
|
+
interface CardUpsertValidation {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
interface CardAdminStore extends CardStore {
|
|
53
|
+
validateUpsert(id: string, cardKey: string): CardUpsertValidation;
|
|
54
|
+
writeCard(id: string, card: LiveCard, cardKey?: string): void;
|
|
55
|
+
patchCard(id: string, jsonPath: string, value: unknown): void;
|
|
56
|
+
removeCard(id: string): void;
|
|
57
|
+
readIndex(): CardIndex;
|
|
58
|
+
}
|
|
59
|
+
declare function createCardStore(adapter: CardStorageAdapter, onWarn?: (msg: string) => void): CardAdminStore;
|
|
60
|
+
interface JournalEntry {
|
|
61
|
+
id: string;
|
|
62
|
+
event: GraphEvent;
|
|
63
|
+
}
|
|
64
|
+
interface JournalStorageAdapter {
|
|
65
|
+
readAllEntries(): JournalEntry[];
|
|
66
|
+
appendEntry(entry: JournalEntry): void;
|
|
67
|
+
generateId(): string;
|
|
68
|
+
}
|
|
69
|
+
declare const SNAPSHOT_SCHEMA_VERSION_V1 = "v1";
|
|
70
|
+
declare const BOARD_GRAPH_KEY = "board/graph";
|
|
71
|
+
type OutputStoreEvent = {
|
|
72
|
+
kind: 'computed_values';
|
|
73
|
+
cardId: string;
|
|
74
|
+
values: Record<string, unknown>;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'data_object';
|
|
77
|
+
key: string;
|
|
78
|
+
payload: unknown;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'status';
|
|
81
|
+
status: unknown;
|
|
82
|
+
};
|
|
83
|
+
interface BoardStatusCard {
|
|
84
|
+
name: string;
|
|
85
|
+
status: string;
|
|
86
|
+
error?: {
|
|
87
|
+
message: string;
|
|
88
|
+
code?: string;
|
|
89
|
+
at?: string;
|
|
90
|
+
source?: 'task-runtime' | 'source-fetch' | 'timeout' | 'unknown';
|
|
91
|
+
};
|
|
92
|
+
requires: string[];
|
|
93
|
+
requires_satisfied: string[];
|
|
94
|
+
requires_missing: string[];
|
|
95
|
+
provides_declared: string[];
|
|
96
|
+
provides_runtime: string[];
|
|
97
|
+
blocked_by: string[];
|
|
98
|
+
unblocks: string[];
|
|
99
|
+
runtime: {
|
|
100
|
+
attempt_count: number;
|
|
101
|
+
restart_count: number;
|
|
102
|
+
in_progress_since: string | null;
|
|
103
|
+
last_transition_at: string | null;
|
|
104
|
+
last_completed_at: string | null;
|
|
105
|
+
last_restarted_at: string | null;
|
|
106
|
+
status_age_ms: number | null;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
interface BoardStatusObject {
|
|
110
|
+
schema_version: 'v1';
|
|
111
|
+
meta: {
|
|
112
|
+
board: {
|
|
113
|
+
path: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
summary: {
|
|
117
|
+
card_count: number;
|
|
118
|
+
completed: number;
|
|
119
|
+
eligible: number;
|
|
120
|
+
pending: number;
|
|
121
|
+
blocked: number;
|
|
122
|
+
unresolved: number;
|
|
123
|
+
failed?: number;
|
|
124
|
+
in_progress?: number;
|
|
125
|
+
orphan_cards?: number;
|
|
126
|
+
topology?: {
|
|
127
|
+
edge_count: number;
|
|
128
|
+
max_fan_out_card: string | null;
|
|
129
|
+
max_fan_out: number;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
cards: BoardStatusCard[];
|
|
133
|
+
}
|
|
134
|
+
declare const EMPTY_CONFIG: GraphConfig;
|
|
135
|
+
|
|
136
|
+
export { type BoardStatusObject as B, type CardAdminStore as C, EMPTY_CONFIG as E, type JournalStorageAdapter as J, type LiveCard as L, type OutputStoreEvent as O, SNAPSHOT_SCHEMA_VERSION_V1 as S, BOARD_GRAPH_KEY as a, createCardStore as c };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { f as GraphEvent, G as GraphConfig } from './types-BBhqYGhE.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* board-live-cards-lib — Pure logic library for the board-live-cards CLI.
|
|
5
|
+
*
|
|
6
|
+
* Merged from:
|
|
7
|
+
* board-live-cards-all-stores.ts
|
|
8
|
+
* board-live-cards-lib-types.ts
|
|
9
|
+
* board-live-cards-lib-board-status.ts
|
|
10
|
+
* board-live-cards-lib-card-handler.ts
|
|
11
|
+
* board-live-cards-cli-board-commands.ts
|
|
12
|
+
* board-live-cards-cli-card-commands.ts
|
|
13
|
+
* board-live-cards-cli-callbacks.ts
|
|
14
|
+
*
|
|
15
|
+
* Zero platform imports. All storage is injected via adapter interfaces.
|
|
16
|
+
* Safe for Node, browser, and neutral (V8/PyMiniRacer) bundles.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface LiveCard {
|
|
20
|
+
id: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
interface CardIndexEntry {
|
|
24
|
+
/** Storage-specific address (file path, Cosmos doc id, localStorage key). */
|
|
25
|
+
key: string;
|
|
26
|
+
/** Checksum of card content — computed by the adapter at write time. */
|
|
27
|
+
checksum: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
}
|
|
30
|
+
type CardIndex = Record<string, CardIndexEntry>;
|
|
31
|
+
type CardChecksumIndex = Record<string, string>;
|
|
32
|
+
interface CardStorageAdapter {
|
|
33
|
+
readIndex(): CardIndex | null;
|
|
34
|
+
writeIndex(index: CardIndex): void;
|
|
35
|
+
readCard(key: string): LiveCard | null;
|
|
36
|
+
/** Write card content; returns checksum of what was written. */
|
|
37
|
+
writeCard(key: string, card: LiveCard): string;
|
|
38
|
+
cardExists(key: string): boolean;
|
|
39
|
+
defaultCardKey(cardId: string): string;
|
|
40
|
+
}
|
|
41
|
+
interface CardStore {
|
|
42
|
+
readCard(id: string): LiveCard | null;
|
|
43
|
+
readCardKey(id: string): string | null;
|
|
44
|
+
readAllCards(): LiveCard[];
|
|
45
|
+
readChecksumIndex(): CardChecksumIndex;
|
|
46
|
+
changedSince(snapshotChecksumIndex: CardChecksumIndex): string[];
|
|
47
|
+
}
|
|
48
|
+
interface CardUpsertValidation {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
interface CardAdminStore extends CardStore {
|
|
53
|
+
validateUpsert(id: string, cardKey: string): CardUpsertValidation;
|
|
54
|
+
writeCard(id: string, card: LiveCard, cardKey?: string): void;
|
|
55
|
+
patchCard(id: string, jsonPath: string, value: unknown): void;
|
|
56
|
+
removeCard(id: string): void;
|
|
57
|
+
readIndex(): CardIndex;
|
|
58
|
+
}
|
|
59
|
+
declare function createCardStore(adapter: CardStorageAdapter, onWarn?: (msg: string) => void): CardAdminStore;
|
|
60
|
+
interface JournalEntry {
|
|
61
|
+
id: string;
|
|
62
|
+
event: GraphEvent;
|
|
63
|
+
}
|
|
64
|
+
interface JournalStorageAdapter {
|
|
65
|
+
readAllEntries(): JournalEntry[];
|
|
66
|
+
appendEntry(entry: JournalEntry): void;
|
|
67
|
+
generateId(): string;
|
|
68
|
+
}
|
|
69
|
+
declare const SNAPSHOT_SCHEMA_VERSION_V1 = "v1";
|
|
70
|
+
declare const BOARD_GRAPH_KEY = "board/graph";
|
|
71
|
+
type OutputStoreEvent = {
|
|
72
|
+
kind: 'computed_values';
|
|
73
|
+
cardId: string;
|
|
74
|
+
values: Record<string, unknown>;
|
|
75
|
+
} | {
|
|
76
|
+
kind: 'data_object';
|
|
77
|
+
key: string;
|
|
78
|
+
payload: unknown;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'status';
|
|
81
|
+
status: unknown;
|
|
82
|
+
};
|
|
83
|
+
interface BoardStatusCard {
|
|
84
|
+
name: string;
|
|
85
|
+
status: string;
|
|
86
|
+
error?: {
|
|
87
|
+
message: string;
|
|
88
|
+
code?: string;
|
|
89
|
+
at?: string;
|
|
90
|
+
source?: 'task-runtime' | 'source-fetch' | 'timeout' | 'unknown';
|
|
91
|
+
};
|
|
92
|
+
requires: string[];
|
|
93
|
+
requires_satisfied: string[];
|
|
94
|
+
requires_missing: string[];
|
|
95
|
+
provides_declared: string[];
|
|
96
|
+
provides_runtime: string[];
|
|
97
|
+
blocked_by: string[];
|
|
98
|
+
unblocks: string[];
|
|
99
|
+
runtime: {
|
|
100
|
+
attempt_count: number;
|
|
101
|
+
restart_count: number;
|
|
102
|
+
in_progress_since: string | null;
|
|
103
|
+
last_transition_at: string | null;
|
|
104
|
+
last_completed_at: string | null;
|
|
105
|
+
last_restarted_at: string | null;
|
|
106
|
+
status_age_ms: number | null;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
interface BoardStatusObject {
|
|
110
|
+
schema_version: 'v1';
|
|
111
|
+
meta: {
|
|
112
|
+
board: {
|
|
113
|
+
path: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
summary: {
|
|
117
|
+
card_count: number;
|
|
118
|
+
completed: number;
|
|
119
|
+
eligible: number;
|
|
120
|
+
pending: number;
|
|
121
|
+
blocked: number;
|
|
122
|
+
unresolved: number;
|
|
123
|
+
failed?: number;
|
|
124
|
+
in_progress?: number;
|
|
125
|
+
orphan_cards?: number;
|
|
126
|
+
topology?: {
|
|
127
|
+
edge_count: number;
|
|
128
|
+
max_fan_out_card: string | null;
|
|
129
|
+
max_fan_out: number;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
cards: BoardStatusCard[];
|
|
133
|
+
}
|
|
134
|
+
declare const EMPTY_CONFIG: GraphConfig;
|
|
135
|
+
|
|
136
|
+
export { type BoardStatusObject as B, type CardAdminStore as C, EMPTY_CONFIG as E, type JournalStorageAdapter as J, type LiveCard as L, type OutputStoreEvent as O, SNAPSHOT_SCHEMA_VERSION_V1 as S, BOARD_GRAPH_KEY as a, createCardStore as c };
|