Merge branch 'feat/schema-graph-schemas'

This commit is contained in:
2026-05-21 21:06:43 +00:00
4 changed files with 431 additions and 3 deletions

View File

@@ -23,7 +23,8 @@ export type TriggeredEdgeAttrs = Static<typeof TriggeredEdgeAttrs>;
export const DependencyEdgeAttrs = Type.Object({});
export type DependencyEdgeAttrs = Static<typeof DependencyEdgeAttrs>;
export type CallEdgeAttrs = TriggeredEdgeAttrs | DependencyEdgeAttrs;
export const CallEdgeAttrs = Type.Union([TriggeredEdgeAttrs, DependencyEdgeAttrs]);
export type CallEdgeAttrs = Static<typeof CallEdgeAttrs>;
export const TemplateEdgeAttrs = Type.Object({
edgeType: Type.Union([Type.Literal("sequential"), Type.Literal("conditional")]),

View File

@@ -1 +1,47 @@
export {};
import { Type, type Static, type TSchema } from "@alkdev/typebox";
import { OperationNodeAttrs, CallNodeAttrs } from "./node.js";
import { OperationEdgeAttrs, CallEdgeAttrs } from "./edge.js";
export const SerializedGraph = <N extends TSchema, E extends TSchema, G extends TSchema>(
NodeAttrs: N,
EdgeAttrs: E,
GraphAttrs: G,
) =>
Type.Object({
attributes: GraphAttrs,
options: Type.Object({
type: Type.Literal("directed"),
multi: Type.Literal(false),
allowSelfLoops: Type.Literal(false),
}),
nodes: Type.Array(
Type.Object({
key: Type.String(),
attributes: NodeAttrs,
}),
),
edges: Type.Array(
Type.Object({
key: Type.String(),
source: Type.String(),
target: Type.String(),
attributes: EdgeAttrs,
}),
),
});
export const OperationGraphSerialized = SerializedGraph(
OperationNodeAttrs,
OperationEdgeAttrs,
Type.Object({}),
);
export type OperationGraphSerialized = Static<typeof OperationGraphSerialized>;
export const CallGraphSerialized = SerializedGraph(
CallNodeAttrs,
CallEdgeAttrs,
Type.Object({}),
);
export type CallGraphSerialized = Static<typeof CallGraphSerialized>;
export type FlowGraphSerialized = OperationGraphSerialized | CallGraphSerialized;

View File

@@ -12,4 +12,6 @@ export {
export * from "./node.js";
export * from "./edge.js";
export * from "./edge.js";
export * from "./graph.js";