import { sqliteTable, text } from 'drizzle-orm/sqlite-core'; import type { Record as BookRecord } from '$lexicon/book'; import { sql } from 'drizzle-orm'; import type { Author } from '$lexicon/defs'; export const authSession = sqliteTable('session', { key: text('key').primaryKey(), session: text('session', { mode: 'json' }).notNull() }); export const authState = sqliteTable('state', { key: text('key').primaryKey(), state: text('state', { mode: 'json' }).notNull() }); export const book = sqliteTable('book', { uri: text('uri').primaryKey(), authorDid: text('authorDid').notNull(), createdAt: text('createdAt').notNull(), indexedAt: text('indexedAt').notNull(), OLID: text('OLID').notNull(), title: text('title').notNull(), authors: text('authors', { mode: 'json' }) .notNull() .$type() .default(sql`'[]'`), description: text('description').notNull(), firstPublishedAt: text('firstPublishedAt').notNull() }); export type Session = typeof authSession.$inferSelect; export type State = typeof authState.$inferSelect; export type Book = typeof book.$inferSelect; type LexiconShape = { [K in keyof T as string extends K ? never : K extends '$type' ? never : K]: T[K]; }; const _typeCheckBook: LexiconShape = {} as Book;