Merge branch 'feat/drift/replace-types-exports'

This commit is contained in:
2026-05-29 10:57:52 +00:00
5 changed files with 15 additions and 83 deletions

View File

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

View File

@@ -1,4 +1,4 @@
import { Type } from "@alkdev/typebox";
import { type Static, Type } from "@alkdev/typebox";
export const Metagraph = Type.Module({
Config: Type.Object({
@@ -23,6 +23,15 @@ export const Metagraph = Type.Module({
}),
});
export const GraphConfig = Metagraph.Import("Config");
export type GraphConfig = Static<typeof GraphConfig>;
export const BaseNodeAttributes = Metagraph.Import("BaseNode");
export type BaseNodeAttributes = Static<typeof BaseNodeAttributes>;
export const BaseEdgeAttributes = Metagraph.Import("BaseEdge");
export type BaseEdgeAttributes = Static<typeof BaseEdgeAttributes>;
export const GRAPH_STATUS = {
Active: "active",
Archived: "archived",

View File

@@ -1,79 +0,0 @@
import { type Static, type TSchema, Type } from "@alkdev/typebox";
export const BaseNodeAttributes: TSchema = 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())),
});
export type BaseNodeAttributes = Static<typeof BaseNodeAttributes>;
export const BaseEdgeAttributes: TSchema = Type.Object({
type: Type.String(),
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
});
export type BaseEdgeAttributes = Static<typeof BaseEdgeAttributes>;
export const GraphConfig: TSchema = 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 }),
});
export type GraphConfig = Static<typeof GraphConfig>;
export const NodeType: TSchema = Type.Object({
name: Type.String(),
schema: Type.Unknown(),
});
export type NodeType = Static<typeof NodeType>;
export const EdgeType: TSchema = Type.Object({
name: Type.String(),
schema: Type.Unknown(),
allowedSourceTypes: Type.Optional(Type.Array(Type.String())),
allowedTargetTypes: Type.Optional(Type.Array(Type.String())),
});
export type EdgeType = Static<typeof EdgeType>;
export const GraphSchema: TSchema = Type.Object({
config: GraphConfig,
nodeTypes: Type.Record(Type.String(), NodeType),
edgeTypes: Type.Record(Type.String(), EdgeType),
});
export type GraphSchema = Static<typeof GraphSchema>;
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: TSchema = Type.Union([
Type.Literal(GRAPH_STATUS.Active),
Type.Literal(GRAPH_STATUS.Archived),
Type.Literal(GRAPH_STATUS.Draft),
]);
export const GRAPH_BASE_TYPE = {
Directed: "directed",
Undirected: "undirected",
Mixed: "mixed",
} as const;
export type GraphBaseType =
(typeof GRAPH_BASE_TYPE)[keyof typeof GRAPH_BASE_TYPE];
export const GraphBaseType: TSchema = Type.Union([
Type.Literal(GRAPH_BASE_TYPE.Directed),
Type.Literal(GRAPH_BASE_TYPE.Undirected),
Type.Literal(GRAPH_BASE_TYPE.Mixed),
]);

View File

@@ -2,7 +2,7 @@ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { createInsertSchema, createSelectSchema } from "@alkdev/drizzlebox";
import { type Static, Type } from "@alkdev/typebox";
import { commonCols } from "./common.ts";
import type { GraphConfig } from "../../graphs/types.ts";
import type { GraphConfig } from "../../graphs/modules/metagraph.ts";
type GraphConfigType = Static<typeof GraphConfig>;

View File

@@ -3,7 +3,7 @@ import { createInsertSchema, createSelectSchema } from "@alkdev/drizzlebox";
import { type Static, Type } from "@alkdev/typebox";
import { commonCols } from "./common.ts";
import { graphTypes } from "./graphTypes.ts";
import { GRAPH_STATUS } from "../../graphs/types.ts";
import { GRAPH_STATUS } from "../../graphs/modules/metagraph.ts";
export const graphs = sqliteTable("graphs", {
...commonCols,