Add canvas interface (#461)
This commit is contained in:
parent
1a74a5ca9a
commit
b3cb0ea755
44 changed files with 7454 additions and 4691 deletions
82
db/schema.ts
82
db/schema.ts
|
|
@ -1,24 +1,80 @@
|
|||
import { Message } from "ai";
|
||||
import { InferSelectModel } from "drizzle-orm";
|
||||
import { pgTable, varchar, timestamp, json, uuid } from "drizzle-orm/pg-core";
|
||||
import { Message } from 'ai';
|
||||
import { InferSelectModel } from 'drizzle-orm';
|
||||
import {
|
||||
pgTable,
|
||||
varchar,
|
||||
timestamp,
|
||||
json,
|
||||
uuid,
|
||||
text,
|
||||
primaryKey,
|
||||
foreignKey,
|
||||
boolean,
|
||||
} from 'drizzle-orm/pg-core';
|
||||
|
||||
export const user = pgTable("User", {
|
||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||
email: varchar("email", { length: 64 }).notNull(),
|
||||
password: varchar("password", { length: 64 }),
|
||||
export const user = pgTable('User', {
|
||||
id: uuid('id').primaryKey().notNull().defaultRandom(),
|
||||
email: varchar('email', { length: 64 }).notNull(),
|
||||
password: varchar('password', { length: 64 }),
|
||||
});
|
||||
|
||||
export type User = InferSelectModel<typeof user>;
|
||||
|
||||
export const chat = pgTable("Chat", {
|
||||
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
||||
createdAt: timestamp("createdAt").notNull(),
|
||||
messages: json("messages").notNull(),
|
||||
userId: uuid("userId")
|
||||
export const chat = pgTable('Chat', {
|
||||
id: uuid('id').primaryKey().notNull().defaultRandom(),
|
||||
createdAt: timestamp('createdAt').notNull(),
|
||||
messages: json('messages').notNull(),
|
||||
userId: uuid('userId')
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
});
|
||||
|
||||
export type Chat = Omit<InferSelectModel<typeof chat>, "messages"> & {
|
||||
export type Chat = Omit<InferSelectModel<typeof chat>, 'messages'> & {
|
||||
messages: Array<Message>;
|
||||
};
|
||||
|
||||
export const document = pgTable(
|
||||
'Document',
|
||||
{
|
||||
id: uuid('id').notNull().defaultRandom(),
|
||||
createdAt: timestamp('createdAt').notNull(),
|
||||
title: text('title').notNull(),
|
||||
content: text('content'),
|
||||
userId: uuid('userId')
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
},
|
||||
(table) => {
|
||||
return {
|
||||
pk: primaryKey({ columns: [table.id, table.createdAt] }),
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export type Document = InferSelectModel<typeof document>;
|
||||
|
||||
export const Suggestion = pgTable(
|
||||
'Suggestion',
|
||||
{
|
||||
id: uuid('id').notNull().defaultRandom(),
|
||||
documentId: uuid('documentId').notNull(),
|
||||
documentCreatedAt: timestamp('documentCreatedAt').notNull(),
|
||||
originalText: text('originalText').notNull(),
|
||||
suggestedText: text('suggestedText').notNull(),
|
||||
description: text('description'),
|
||||
isResolved: boolean('isResolved').notNull().default(false),
|
||||
userId: uuid('userId')
|
||||
.notNull()
|
||||
.references(() => user.id),
|
||||
createdAt: timestamp('createdAt').notNull(),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.id] }),
|
||||
documentRef: foreignKey({
|
||||
columns: [table.documentId, table.documentCreatedAt],
|
||||
foreignColumns: [document.id, document.createdAt],
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
export type Suggestion = InferSelectModel<typeof Suggestion>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue