From dd96ceb4f8c533c7d38dae2e4129734aac91636b Mon Sep 17 00:00:00 2001 From: "glm-5.1" Date: Thu, 21 May 2026 22:55:37 +0000 Subject: [PATCH] feat: wire all barrel exports, resolve conflicts, add 8 sub-path import tests --- src/error/index.ts | 16 +++---- src/graph/construction.ts | 3 +- src/graph/index.ts | 11 +---- src/index.ts | 14 +++--- src/reactive/index.ts | 11 +++-- src/reactive/workflow.ts | 44 +------------------ test/exports.test.ts | 77 +++++++++++++++++++++++++++++++++ test/graph/construction.test.ts | 2 +- 8 files changed, 101 insertions(+), 77 deletions(-) create mode 100644 test/exports.test.ts diff --git a/src/error/index.ts b/src/error/index.ts index 41722ee..956555a 100644 --- a/src/error/index.ts +++ b/src/error/index.ts @@ -1,4 +1,10 @@ -type CallStatus = "pending" | "running" | "completed" | "failed" | "aborted"; +import type { CallStatus } from "../schema/enums.js"; + +interface TypeMismatch { + path: string; + expected: string; + actual: string; +} class FlowgraphError extends Error { constructor(message: string) { @@ -88,12 +94,6 @@ interface GraphValidationError { details: unknown; } -interface TypeMismatch { - path: string; - expected: string; - actual: string; -} - interface TypeIncompatError { type: "type-compat"; sourceKey: string; @@ -116,10 +116,8 @@ export { }; export type { - CallStatus, ValidationError, GraphValidationError, - TypeMismatch, TypeIncompatError, AnyValidationError, }; \ No newline at end of file diff --git a/src/graph/construction.ts b/src/graph/construction.ts index ae18734..6616315 100644 --- a/src/graph/construction.ts +++ b/src/graph/construction.ts @@ -10,7 +10,8 @@ import { InvalidInputError, InvalidTransitionError, } from "../error/index.js"; -import type { CallStatus, AnyValidationError, ValidationError } from "../error/index.js"; +import type { AnyValidationError, ValidationError } from "../error/index.js"; +import type { CallStatus } from "../schema/enums.js"; import { findCycles, reachableFrom as reachableFromFn, diff --git a/src/graph/index.ts b/src/graph/index.ts index 6d249ff..19fde17 100644 --- a/src/graph/index.ts +++ b/src/graph/index.ts @@ -1,14 +1,5 @@ export { FlowGraph, buildTypeEdges, type FlowGraphOptions, type OperationSpec, type CallEventMapValue, type CallRequestedEvent, type CallRespondedEvent, type CallErrorEvent, type CallAbortedEvent, type CallCompletedEvent } from "./construction.js"; export { - topologicalOrder, hasCycles, findCycles, - ancestors, - descendants, - reachableFrom, -} from "./queries.js"; -export { - validateSchema, - validateGraph, - validate, -} from "./validation.js"; \ No newline at end of file +} from "./queries.js"; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ba683d5..5434358 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,7 @@ export * from "./error/index.js"; - -export { FlowGraph, buildTypeEdges, type FlowGraphOptions, type OperationSpec, type CallEventMapValue, type CallRequestedEvent, type CallRespondedEvent, type CallErrorEvent, type CallAbortedEvent, type CallCompletedEvent } from "./graph/index.js"; -export { typeCompat, type TypeCompatResult, type TypeMismatch } from "./analysis/type-compat.js"; -export { - validateSchema, - validateGraph, - validate, -} from "./graph/validation.js"; \ No newline at end of file +export * from "./schema/index.js"; +export * from "./component/index.js"; +export * from "./host/index.js"; +export * from "./reactive/index.js"; +export * from "./analysis/index.js"; +export * from "./graph/index.js"; \ No newline at end of file diff --git a/src/reactive/index.ts b/src/reactive/index.ts index 70aca3d..986a11a 100644 --- a/src/reactive/index.ts +++ b/src/reactive/index.ts @@ -1,18 +1,17 @@ export { WorkflowReactiveRoot, type FailurePolicy, - type CallEventMapValue, - type CallRequestedEvent, - type CallRespondedEvent, - type CallErrorEvent, - type CallAbortedEvent, - type CallCompletedEvent, type EventLogProjection, type AggregateStatus, type ParallelGroup, type ParallelGroupConfig, } from "./workflow.js"; +export type { + WorkflowNode, + ReactiveContext, +} from "../host/reactive.js"; + export { computePreconditions, computeBlockedByFailure, diff --git a/src/reactive/workflow.ts b/src/reactive/workflow.ts index 6be9168..ecf9949 100644 --- a/src/reactive/workflow.ts +++ b/src/reactive/workflow.ts @@ -3,6 +3,8 @@ import type { Signal, ReadonlySignal } from "@preact/signals-core"; import type { DirectedGraph } from "graphology"; import type { NodeStatus } from "../schema/enums.js"; import type { CallResult } from "../schema/edge.js"; +import type { CallEventMapValue } from "../graph/construction.js"; +export type { CallEventMapValue } from "../graph/construction.js"; import { computePreconditions, computeBlockedByFailure, @@ -22,48 +24,6 @@ export interface ParallelGroupConfig { [groupKey: string]: ParallelGroup; } -export interface CallRequestedEvent { - type: "call.requested"; - requestId: string; - operationId: string; - input: unknown; - timestamp: string; -} - -export interface CallRespondedEvent { - type: "call.responded"; - requestId: string; - output: unknown; - timestamp: string; -} - -export interface CallErrorEvent { - type: "call.error"; - requestId: string; - error: { code: string; message: string; details?: unknown }; - timestamp: string; -} - -export interface CallAbortedEvent { - type: "call.aborted"; - requestId: string; - timestamp: string; -} - -export interface CallCompletedEvent { - type: "call.completed"; - requestId: string; - output: unknown; - timestamp: string; -} - -export type CallEventMapValue = - | CallRequestedEvent - | CallRespondedEvent - | CallErrorEvent - | CallAbortedEvent - | CallCompletedEvent; - export interface EventLogProjection { append(event: CallEventMapValue): void; getStatus(nodeId: string): NodeStatus; diff --git a/test/exports.test.ts b/test/exports.test.ts new file mode 100644 index 0000000..38a3bf3 --- /dev/null +++ b/test/exports.test.ts @@ -0,0 +1,77 @@ +import { describe, it, expect } from "vitest"; + +import { FlowGraph, typeCompat, CycleError, OperationNodeAttrs, Operation, GraphologyHostConfig, WorkflowReactiveRoot, topologicalOrder } from "../src/index.js"; +import { buildTypeEdges as buildTypeEdgesGraph } from "../src/graph/index.js"; +import { CallStatusEnum, NodeStatusEnum, EdgeTypeEnum, CallResultSchema, OperationEdgeAttrs, CallEdgeAttrs, TemplateEdgeAttrs, CallNodeAttrs } from "../src/schema/index.js"; +import { Sequential, Parallel, Conditional, Map } from "../src/component/index.js"; +import { ReactiveHostConfig } from "../src/host/index.js"; +import { WorkflowReactiveRoot as ReactiveRootFromReactive, computePreconditions, computeBlockedByFailure } from "../src/reactive/index.js"; +import { typeCompat as typeCompatAnalysis, buildTypeEdges, validateGraph, validateTemplate, topologicalOrder as topologicalOrderAnalysis, parallelGroups, criticalPath, reachableFrom } from "../src/analysis/index.js"; +import { FlowgraphError, ConstructionError, CycleError as CycleErrorFromError, InvalidTransitionError } from "../src/error/index.js"; + +describe("Sub-path imports", () => { + it("@alkdev/flowgraph → all public types", () => { + expect(FlowGraph).toBeDefined(); + expect(typeCompat).toBeDefined(); + expect(CycleError).toBeDefined(); + expect(OperationNodeAttrs).toBeDefined(); + expect(Operation).toBeDefined(); + expect(GraphologyHostConfig).toBeDefined(); + expect(WorkflowReactiveRoot).toBeDefined(); + expect(topologicalOrder).toBeDefined(); + }); + + it("@alkdev/flowgraph/graph → FlowGraph, FlowGraphOptions", () => { + expect(FlowGraph).toBeDefined(); + expect(buildTypeEdgesGraph).toBeDefined(); + }); + + it("@alkdev/flowgraph/schema → all schemas, enums, types, CallResult", () => { + expect(OperationNodeAttrs).toBeDefined(); + expect(CallNodeAttrs).toBeDefined(); + expect(OperationEdgeAttrs).toBeDefined(); + expect(CallEdgeAttrs).toBeDefined(); + expect(TemplateEdgeAttrs).toBeDefined(); + expect(CallResultSchema).toBeDefined(); + expect(CallStatusEnum).toBeDefined(); + expect(NodeStatusEnum).toBeDefined(); + expect(EdgeTypeEnum).toBeDefined(); + }); + + it("@alkdev/flowgraph/component → Operation, Sequential, Parallel, Conditional, Map", () => { + expect(Operation).toBeDefined(); + expect(Sequential).toBeDefined(); + expect(Parallel).toBeDefined(); + expect(Conditional).toBeDefined(); + expect(Map).toBeDefined(); + }); + + it("@alkdev/flowgraph/host → GraphologyHostConfig, ReactiveHostConfig", () => { + expect(GraphologyHostConfig).toBeDefined(); + expect(ReactiveHostConfig).toBeDefined(); + }); + + it("@alkdev/flowgraph/reactive → WorkflowReactiveRoot, EventLogProjection", () => { + expect(ReactiveRootFromReactive).toBeDefined(); + expect(computePreconditions).toBeDefined(); + expect(computeBlockedByFailure).toBeDefined(); + }); + + it("@alkdev/flowgraph/analysis → typeCompat, buildTypeEdges, validateGraph, validateTemplate, topologicalOrder, parallelGroups, criticalPath, reachableFrom", () => { + expect(typeCompatAnalysis).toBeDefined(); + expect(buildTypeEdges).toBeDefined(); + expect(validateGraph).toBeDefined(); + expect(validateTemplate).toBeDefined(); + expect(topologicalOrderAnalysis).toBeDefined(); + expect(parallelGroups).toBeDefined(); + expect(criticalPath).toBeDefined(); + expect(reachableFrom).toBeDefined(); + }); + + it("@alkdev/flowgraph/error → all error classes", () => { + expect(FlowgraphError).toBeDefined(); + expect(ConstructionError).toBeDefined(); + expect(CycleErrorFromError).toBeDefined(); + expect(InvalidTransitionError).toBeDefined(); + }); +}); \ No newline at end of file diff --git a/test/graph/construction.test.ts b/test/graph/construction.test.ts index 76e049d..5905971 100644 --- a/test/graph/construction.test.ts +++ b/test/graph/construction.test.ts @@ -9,7 +9,7 @@ import { CycleError, InvalidTransitionError, } from "../../src/error/index.js"; -import type { CallStatus } from "../../src/error/index.js"; +import type { CallStatus } from "../../src/schema/enums.js"; describe("FlowGraph constructor", () => { it("creates an empty graph", () => {