Merge branch 'feat/drift/metagraph-module'

# Conflicts:
#	src/graphs/mod.ts
This commit is contained in:
2026-05-29 10:55:28 +00:00
2 changed files with 42 additions and 0 deletions

View File

@@ -1 +1,6 @@
export * from "./types.ts"; export * from "./types.ts";
export {
Metagraph,
GRAPH_STATUS,
GraphStatus,
} from "./modules/metagraph.ts";

View File

@@ -0,0 +1,37 @@
import { Type } from "@alkdev/typebox";
export const Metagraph = Type.Module({
Config: Type.Object({
type: Type.Union([
Type.Literal("directed"),
Type.Literal("undirected"),
Type.Literal("mixed"),
], { default: "mixed" }),
multi: Type.Boolean({ default: true }),
allowSelfLoops: Type.Boolean({ default: true }),
}),
BaseNode: Type.Object({
created: Type.Optional(Type.String({ format: "date-time" })),
modified: Type.Optional(Type.String({ format: "date-time" })),
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
}),
BaseEdge: Type.Object({
type: Type.String(),
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
}),
});
export const GRAPH_STATUS = {
Active: "active",
Archived: "archived",
Draft: "draft",
} as const;
export type GraphStatus = (typeof GRAPH_STATUS)[keyof typeof GRAPH_STATUS];
export const GraphStatus = Type.Union([
Type.Literal(GRAPH_STATUS.Active),
Type.Literal(GRAPH_STATUS.Archived),
Type.Literal(GRAPH_STATUS.Draft),
]);