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:
35
src/sqlite/tables/graphs.ts
Normal file
35
src/sqlite/tables/graphs.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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 { EnumGraphStatus } 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(EnumGraphStatus.Active),
|
||||
Type.Literal(EnumGraphStatus.Archived),
|
||||
Type.Literal(EnumGraphStatus.Draft),
|
||||
])),
|
||||
});
|
||||
|
||||
export type InsertGraph = Static<typeof InsertGraph>;
|
||||
Reference in New Issue
Block a user