feat: deno-first storage package with sqlite host and graph schemas

Scaffolded @alkdev/storage from @ade/storage_sqlite and @ade/core/graphs:
- graphs/ module: TypeBox schema types + SchemaBuilder (from @ade/core/graphs)
- sqlite/ module: Drizzle table defs, relations, injectable client (from @ade/storage_sqlite)
- pg/ module: placeholder for Postgres host
- deno.json configured for JSR with subpath exports (./graphs, ./sqlite, ./pg)
- Imports swapped: @sinclair/typebox → @alkdev/typebox, drizzle-typebox → @alkdev/drizzlebox
- Client is now injectable (no hardcoded env vars or module-level side effects)
- no-slow-types lint excluded (Drizzle generics); --allow-slow-types on publish
This commit is contained in:
2026-05-28 12:19:48 +00:00
parent c6ea6c15e9
commit 8c68dd6b07
20 changed files with 540 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import { sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
import { createInsertSchema } from "@alkdev/drizzlebox";
import { Type, type Static } from "@alkdev/typebox";
import { commonCols } from "./common.ts";
import { graphs } from "./graphs.ts";
const AttributesSchema = Type.Record(Type.String(), Type.Any());
export const nodes = sqliteTable("nodes", {
...commonCols,
graphId: text("graph_id").notNull().references(() => graphs.id, { onDelete: "cascade" }),
key: text("key").notNull(),
attributes: text("attributes", { mode: "json" }).notNull().default({}),
}, (table) => ({
graphKeyIdx: unique().on(table.graphId, table.key),
}));
export const InsertNodeSchema = createInsertSchema(nodes, {
key: Type.String({ minLength: 1 }),
attributes: AttributesSchema,
});
export type InsertNode = Static<typeof InsertNodeSchema>;