feat(api/public-exports): wire up selective public API surface in src/index.ts
Replace wildcard barrel with selective named re-exports, ensuring no internal implementation details (TaskGraphInner, Nullable, SerializedGraph, standalone mutation/query/validation functions, computeEffectiveP, splitFrontmatter) leak through the public API. All 590 tests pass, TypeScript declarations compile cleanly.
This commit is contained in:
113
src/index.ts
113
src/index.ts
@@ -1,8 +1,109 @@
|
||||
// @alkdev/taskgraph — Public API surface
|
||||
// Re-exports from all submodules
|
||||
//
|
||||
// This is the main entry point for consumers. Everything they need should be
|
||||
// importable from `@alkdev/taskgraph`. Internal implementation details (types
|
||||
// and functions that operate on the raw graphology instance) are intentionally
|
||||
// NOT re-exported here to maintain a clean public API boundary.
|
||||
|
||||
export * from './schema/index.js';
|
||||
export * from './graph/index.js';
|
||||
export * from './analysis/index.js';
|
||||
export * from './frontmatter/index.js';
|
||||
export * from './error/index.js';
|
||||
// ---------------------------------------------------------------------------
|
||||
// TaskGraph class (the primary data structure)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export { TaskGraph } from './graph/construction.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Analysis functions (standalone, composable)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Graph analysis
|
||||
export { parallelGroups } from './analysis/parallel-groups.js';
|
||||
export { criticalPath, weightedCriticalPath } from './analysis/critical-path.js';
|
||||
export { bottlenecks } from './analysis/bottleneck.js';
|
||||
export type { BottleneckResult } from './analysis/bottleneck.js';
|
||||
|
||||
// Cost-benefit analysis
|
||||
export { riskPath, riskDistribution } from './analysis/risk.js';
|
||||
export { calculateTaskEv, workflowCost } from './analysis/cost-benefit.js';
|
||||
export { shouldDecomposeTask } from './analysis/decompose.js';
|
||||
|
||||
// Categorical numeric methods
|
||||
export {
|
||||
scopeCostEstimate,
|
||||
scopeTokenEstimate,
|
||||
riskSuccessProbability,
|
||||
riskWeight,
|
||||
impactWeight,
|
||||
resolveDefaults,
|
||||
} from './analysis/defaults.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Frontmatter functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export { parseFrontmatter } from './frontmatter/parse.js';
|
||||
export { serializeFrontmatter } from './frontmatter/serialize.js';
|
||||
export { parseTaskFile, parseTaskDirectory } from './frontmatter/file-io.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Schemas and types
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Enum schemas + types (const+type pairs with same name: export by value, TS includes type)
|
||||
export {
|
||||
TaskScopeEnum,
|
||||
TaskRiskEnum,
|
||||
TaskImpactEnum,
|
||||
TaskLevelEnum,
|
||||
TaskPriorityEnum,
|
||||
TaskStatusEnum,
|
||||
} from './schema/enums.js';
|
||||
|
||||
export type {
|
||||
TaskScope,
|
||||
TaskRisk,
|
||||
TaskImpact,
|
||||
TaskLevel,
|
||||
TaskPriority,
|
||||
TaskStatus,
|
||||
} from './schema/enums.js';
|
||||
|
||||
// Input schemas + types
|
||||
export { TaskInput, DependencyEdge } from './schema/task.js';
|
||||
|
||||
// Graph schemas + types (exclude SerializedGraph generic factory and TaskGraphNodeAttributesUpdate)
|
||||
export {
|
||||
TaskGraphNodeAttributes,
|
||||
TaskGraphEdgeAttributes,
|
||||
TaskGraphSerialized,
|
||||
} from './schema/graph.js';
|
||||
|
||||
// Result schemas + types
|
||||
export {
|
||||
RiskPathResult,
|
||||
DecomposeResult,
|
||||
WorkflowCostOptions,
|
||||
WorkflowCostResult,
|
||||
EvConfig,
|
||||
EvResult,
|
||||
RiskDistributionResult,
|
||||
ResolvedTaskAttributes,
|
||||
} from './schema/results.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Error classes + validation error types
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
TaskgraphError,
|
||||
TaskNotFoundError,
|
||||
CircularDependencyError,
|
||||
InvalidInputError,
|
||||
DuplicateNodeError,
|
||||
DuplicateEdgeError,
|
||||
} from './error/index.js';
|
||||
|
||||
export type {
|
||||
ValidationError,
|
||||
GraphValidationError,
|
||||
AnyValidationError,
|
||||
} from './error/index.js';
|
||||
@@ -1,4 +1,7 @@
|
||||
// Schema submodule — re-exports
|
||||
// Schema submodule — public re-exports
|
||||
//
|
||||
// Excludes: Nullable (internal TypeBox helper), SerializedGraph (generic factory),
|
||||
// TaskGraphNodeAttributesUpdate (internal use for update operations)
|
||||
|
||||
export * from './enums.js';
|
||||
export * from './task.js';
|
||||
|
||||
@@ -9,9 +9,6 @@ import {
|
||||
TaskPriorityEnum,
|
||||
} from "./enums.js";
|
||||
|
||||
// Re-export Nullable for convenience (originally defined in enums.ts)
|
||||
export { Nullable } from "./enums.js";
|
||||
|
||||
// --- Input Schemas ---
|
||||
|
||||
/**
|
||||
|
||||
@@ -369,14 +369,8 @@ describe('Type alias correctness — TaskInput and DependencyEdge (compile-time)
|
||||
});
|
||||
});
|
||||
|
||||
// Re-export Nullable from task.ts to verify the re-export works
|
||||
import { Nullable as NullableFromTask } from '../src/schema/task.js';
|
||||
|
||||
describe('Nullable re-export from task.ts', () => {
|
||||
it('is the same function as from enums.ts', () => {
|
||||
expect(NullableFromTask).toBe(Nullable);
|
||||
});
|
||||
});
|
||||
// Nullable is no longer re-exported from task.ts — it's an internal helper
|
||||
// and excluded from the public API surface per src/index.ts
|
||||
|
||||
// Intentionally import type aliases to verify they exist at compile time
|
||||
type TaskScope = import('../src/schema/enums.js').TaskScope;
|
||||
|
||||
Reference in New Issue
Block a user