refactor(tasks): remove flow registry layer

This commit is contained in:
Vincent Koc
2026-04-01 02:24:51 +09:00
parent 76b3235207
commit 1a313caff3
25 changed files with 55 additions and 3448 deletions

View File

@@ -1,9 +1,3 @@
import {
configureFlowRegistryRuntime,
type FlowRegistryStore,
type FlowRegistryStoreSnapshot,
} from "../tasks/flow-registry.store.js";
import type { FlowRecord } from "../tasks/flow-registry.types.js";
import {
configureTaskRegistryRuntime,
type TaskRegistryStore,
@@ -22,24 +16,13 @@ function cloneDeliveryState(state: TaskDeliveryState): TaskDeliveryState {
};
}
function cloneFlow(flow: FlowRecord): FlowRecord {
return {
...flow,
...(flow.requesterOrigin ? { requesterOrigin: { ...flow.requesterOrigin } } : {}),
};
}
export function installInMemoryTaskAndFlowRegistryRuntime(): {
export function installInMemoryTaskRegistryRuntime(): {
taskStore: TaskRegistryStore;
flowStore: FlowRegistryStore;
} {
let taskSnapshot: TaskRegistryStoreSnapshot = {
tasks: new Map<string, TaskRecord>(),
deliveryStates: new Map<string, TaskDeliveryState>(),
};
let flowSnapshot: FlowRegistryStoreSnapshot = {
flows: new Map<string, FlowRecord>(),
};
const taskStore: TaskRegistryStore = {
loadSnapshot: () => ({
@@ -80,28 +63,6 @@ export function installInMemoryTaskAndFlowRegistryRuntime(): {
},
};
const flowStore: FlowRegistryStore = {
loadSnapshot: () => ({
flows: new Map(
[...flowSnapshot.flows.entries()].map(([flowId, flow]) => [flowId, cloneFlow(flow)]),
),
}),
saveSnapshot: (snapshot) => {
flowSnapshot = {
flows: new Map(
[...snapshot.flows.entries()].map(([flowId, flow]) => [flowId, cloneFlow(flow)]),
),
};
},
upsertFlow: (flow) => {
flowSnapshot.flows.set(flow.flowId, cloneFlow(flow));
},
deleteFlow: (flowId) => {
flowSnapshot.flows.delete(flowId);
},
};
configureTaskRegistryRuntime({ store: taskStore });
configureFlowRegistryRuntime({ store: flowStore });
return { taskStore, flowStore };
return { taskStore };
}