feat: wire all barrel exports, resolve conflicts, add 8 sub-path import tests

This commit is contained in:
2026-05-21 22:55:37 +00:00
parent 4fcd544261
commit dd96ceb4f8
8 changed files with 101 additions and 77 deletions

View File

@@ -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 { class FlowgraphError extends Error {
constructor(message: string) { constructor(message: string) {
@@ -88,12 +94,6 @@ interface GraphValidationError {
details: unknown; details: unknown;
} }
interface TypeMismatch {
path: string;
expected: string;
actual: string;
}
interface TypeIncompatError { interface TypeIncompatError {
type: "type-compat"; type: "type-compat";
sourceKey: string; sourceKey: string;
@@ -116,10 +116,8 @@ export {
}; };
export type { export type {
CallStatus,
ValidationError, ValidationError,
GraphValidationError, GraphValidationError,
TypeMismatch,
TypeIncompatError, TypeIncompatError,
AnyValidationError, AnyValidationError,
}; };

View File

@@ -10,7 +10,8 @@ import {
InvalidInputError, InvalidInputError,
InvalidTransitionError, InvalidTransitionError,
} from "../error/index.js"; } 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 { import {
findCycles, findCycles,
reachableFrom as reachableFromFn, reachableFrom as reachableFromFn,

View File

@@ -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 { FlowGraph, buildTypeEdges, type FlowGraphOptions, type OperationSpec, type CallEventMapValue, type CallRequestedEvent, type CallRespondedEvent, type CallErrorEvent, type CallAbortedEvent, type CallCompletedEvent } from "./construction.js";
export { export {
topologicalOrder,
hasCycles, hasCycles,
findCycles, findCycles,
ancestors, } from "./queries.js";
descendants,
reachableFrom,
} from "./queries.js";
export {
validateSchema,
validateGraph,
validate,
} from "./validation.js";

View File

@@ -1,9 +1,7 @@
export * from "./error/index.js"; export * from "./error/index.js";
export * from "./schema/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 * from "./component/index.js";
export { typeCompat, type TypeCompatResult, type TypeMismatch } from "./analysis/type-compat.js"; export * from "./host/index.js";
export { export * from "./reactive/index.js";
validateSchema, export * from "./analysis/index.js";
validateGraph, export * from "./graph/index.js";
validate,
} from "./graph/validation.js";

View File

@@ -1,18 +1,17 @@
export { export {
WorkflowReactiveRoot, WorkflowReactiveRoot,
type FailurePolicy, type FailurePolicy,
type CallEventMapValue,
type CallRequestedEvent,
type CallRespondedEvent,
type CallErrorEvent,
type CallAbortedEvent,
type CallCompletedEvent,
type EventLogProjection, type EventLogProjection,
type AggregateStatus, type AggregateStatus,
type ParallelGroup, type ParallelGroup,
type ParallelGroupConfig, type ParallelGroupConfig,
} from "./workflow.js"; } from "./workflow.js";
export type {
WorkflowNode,
ReactiveContext,
} from "../host/reactive.js";
export { export {
computePreconditions, computePreconditions,
computeBlockedByFailure, computeBlockedByFailure,

View File

@@ -3,6 +3,8 @@ import type { Signal, ReadonlySignal } from "@preact/signals-core";
import type { DirectedGraph } from "graphology"; import type { DirectedGraph } from "graphology";
import type { NodeStatus } from "../schema/enums.js"; import type { NodeStatus } from "../schema/enums.js";
import type { CallResult } from "../schema/edge.js"; import type { CallResult } from "../schema/edge.js";
import type { CallEventMapValue } from "../graph/construction.js";
export type { CallEventMapValue } from "../graph/construction.js";
import { import {
computePreconditions, computePreconditions,
computeBlockedByFailure, computeBlockedByFailure,
@@ -22,48 +24,6 @@ export interface ParallelGroupConfig {
[groupKey: string]: ParallelGroup; [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 { export interface EventLogProjection {
append(event: CallEventMapValue): void; append(event: CallEventMapValue): void;
getStatus(nodeId: string): NodeStatus; getStatus(nodeId: string): NodeStatus;

77
test/exports.test.ts Normal file
View File

@@ -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();
});
});

View File

@@ -9,7 +9,7 @@ import {
CycleError, CycleError,
InvalidTransitionError, InvalidTransitionError,
} from "../../src/error/index.js"; } from "../../src/error/index.js";
import type { CallStatus } from "../../src/error/index.js"; import type { CallStatus } from "../../src/schema/enums.js";
describe("FlowGraph constructor", () => { describe("FlowGraph constructor", () => {
it("creates an empty graph", () => { it("creates an empty graph", () => {