Files
storage/src/sqlite/tables/graphs.ts
glm-5.1 b0298663dc feat: add architecture docs, fix code issues from review, add analyze_lint script
Architecture docs (docs/architecture/):
- overview.md: package purpose, exports, terminology, design decisions, gaps
- metagraph.md: core graph model, schema types, SchemaBuilder, validation
- sqlite-host.md: SQLite tables, common columns, relations, concurrency model
- encrypted-data.md: encrypted data as a node type, AES-256-GCM crypto utility design

Code fixes from architecture review:
- Remove ConfigSchema duplication in graphTypes.ts (import GraphConfig from types.ts)
- Add missing SelectNodeSchema/SelectNode to nodes.ts
- Fix InsertEdge.key to be Optional (match nullable DB column)
- Replace TypeScript enums with as const objects (GRAPH_STATUS, GRAPH_BASE_TYPE)
- Add verbatim-module-syntax to lint exclusions (TypeBox false positive)
- Add @std/flags and @std/path to deno.json imports

Infrastructure:
- Add scripts/analyze_lint.ts from @ade for grouped lint analysis
- Add deno task lint:analyze
- Update AGENTS.md with architecture doc references, enum convention, crypto todo
2026-05-28 13:18:56 +00:00

35 lines
1.2 KiB
TypeScript

import { sqliteTable, text } from "drizzle-orm/sqlite-core";
import { createInsertSchema, createSelectSchema } from "@alkdev/drizzlebox";
import { Type, type Static } from "@alkdev/typebox";
import { commonCols } from "./common.ts";
import { graphTypes } from "./graphTypes.ts";
import { GRAPH_STATUS } from "../../graphs/types.ts";
export const graphs = sqliteTable("graphs", {
...commonCols,
graphTypeId: text("graph_type_id").references(() => graphTypes.id, { onDelete: "set null" }),
name: text("name").notNull(),
description: text("description").default(""),
status: text("status", { enum: ["active", "archived", "draft"] })
.default("draft")
.notNull(),
});
export const SelectGraph = createSelectSchema(graphs, {
metadata: Type.Object({}, { additionalProperties: true }),
createdAt: Type.Date(),
updatedAt: Type.Date(),
});
export type SelectGraph = Static<typeof SelectGraph>;
export const InsertGraph = createInsertSchema(graphs, {
name: Type.String({ minLength: 2 }),
status: Type.Optional(Type.Union([
Type.Literal(GRAPH_STATUS.Active),
Type.Literal(GRAPH_STATUS.Archived),
Type.Literal(GRAPH_STATUS.Draft),
])),
});
export type InsertGraph = Static<typeof InsertGraph>;