aboutsummaryrefslogtreecommitdiff
path: root/apps/web
diff options
context:
space:
mode:
authorKush Thaker <[email protected]>2024-07-31 10:56:40 +0530
committerKush Thaker <[email protected]>2024-07-31 10:56:40 +0530
commit6e1d53e28a056e429c54e1e6af45eaa7939daa41 (patch)
tree21dfd3c64742d9e9405e68b1695acbb95f5fdde2 /apps/web
parentfix ids not present in storecontent (diff)
downloadsupermemory-6e1d53e28a056e429c54e1e6af45eaa7939daa41.tar.xz
supermemory-6e1d53e28a056e429c54e1e6af45eaa7939daa41.zip
queues so far
Co-authored-by: Dhravya Shah <[email protected]>
Diffstat (limited to 'apps/web')
-rw-r--r--apps/web/app/actions/doers.ts481
-rw-r--r--apps/web/lib/get-metadata.ts40
-rw-r--r--apps/web/migrations/0000_omniscient_stick.sql (renamed from apps/web/migrations/0000_steep_moira_mactaggert.sql)19
-rw-r--r--apps/web/migrations/meta/0000_snapshot.json1847
-rw-r--r--apps/web/migrations/meta/_journal.json24
-rw-r--r--apps/web/server/db/schema.ts26
6 files changed, 1332 insertions, 1105 deletions
diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts
index 9a831921..910226a5 100644
--- a/apps/web/app/actions/doers.ts
+++ b/apps/web/app/actions/doers.ts
@@ -15,7 +15,7 @@ import {
import { ServerActionReturnType } from "./types";
import { auth } from "../../server/auth";
import { Tweet } from "react-tweet/api";
-import { getMetaData } from "@/lib/get-metadata";
+// import { getMetaData } from "@/lib/get-metadata";
import { and, eq, inArray, sql } from "drizzle-orm";
import { LIMITS } from "@/lib/constants";
import { ChatHistory } from "@repo/shared-types";
@@ -197,122 +197,16 @@ export const createMemory = async (input: {
return { error: "Not authenticated", success: false };
}
- const type = typeDecider(input.content);
-
- let pageContent = input.content;
- let metadata: Awaited<ReturnType<typeof getMetaData>>;
- let vectorData: string;
-
- if (!(await limit(data.user.id, type))) {
- return {
- success: false,
- data: 0,
- error: `You have exceeded the limit of ${LIMITS[type as keyof typeof LIMITS]} ${type}s.`,
- };
- }
-
- let noteId = 0;
-
- if (type === "page") {
- const response = await fetch("https://md.dhr.wtf/?url=" + input.content, {
- headers: {
- Authorization: "Bearer " + process.env.BACKEND_SECURITY_KEY,
- },
- });
- pageContent = await response.text();
- vectorData = pageContent;
- try {
- metadata = await getMetaData(input.content);
- } catch (e) {
- return {
- success: false,
- error: "Failed to fetch metadata for the page. Please try again later.",
- };
- }
- } else if (type === "tweet") {
- //Request the worker for the entire thread
-
- let thread: string;
- let errorOccurred: boolean = false;
-
- try {
- const cf_thread_endpoint = process.env.THREAD_CF_WORKER;
- const authKey = process.env.THREAD_CF_AUTH;
- const threadRequest = await fetch(cf_thread_endpoint, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: authKey,
- },
- body: JSON.stringify({ url: input.content }),
- });
-
- if (threadRequest.status !== 200) {
- throw new Error(
- `Failed to fetch the thread: ${input.content}, Reason: ${threadRequest.statusText}`,
- );
- }
-
- thread = await threadRequest.text();
- if (thread.trim().length === 2) {
- console.log("Thread is an empty array");
- throw new Error(
- "[THREAD FETCHING SERVICE] Got no content form thread worker",
- );
- }
- } catch (e) {
- console.log("[THREAD FETCHING SERVICE] Failed to fetch the thread", e);
- errorOccurred = true;
- }
-
- const tweet = await getTweetData(input.content.split("/").pop() as string);
-
- pageContent = tweetToMd(tweet);
- console.log("THis ishte page content!!", pageContent);
- //@ts-ignore
- vectorData = errorOccurred ? JSON.stringify(pageContent) : thread;
- metadata = {
- baseUrl: input.content,
- description: tweet.text.slice(0, 200),
- image: tweet.user.profile_image_url_https,
- title: `Tweet by ${tweet.user.name}`,
- };
- } else if (type === "note") {
- pageContent = input.content;
- vectorData = pageContent;
- noteId = new Date().getTime();
- metadata = {
- baseUrl: `https://supermemory.ai/note/${noteId}`,
- description: `Note created at ${new Date().toLocaleString()}`,
- image: "https://supermemory.ai/logo.png",
- title: `${pageContent.slice(0, 20)} ${pageContent.length > 20 ? "..." : ""}`,
- };
- } else {
- return {
- success: false,
- data: 0,
- error: "Invalid type",
- };
- }
-
- let storeToSpaces = input.spaces;
-
- if (!storeToSpaces) {
- storeToSpaces = [];
- }
-
- const vectorSaveResponse = await fetch(
+
+ // make the backend reqeust for the queue here
+ const vectorSaveResponses = await fetch(
`${process.env.BACKEND_BASE_URL}/api/add`,
{
method: "POST",
body: JSON.stringify({
- pageContent: vectorData,
- title: metadata.title,
- description: metadata.description,
- url: metadata.baseUrl,
- spaces: storeToSpaces.map((spaceId) => spaceId.toString()),
+ url: input.content,
+ spaces: input.spaces,
user: data.user.id,
- type,
}),
headers: {
"Content-Type": "application/json",
@@ -321,125 +215,249 @@ export const createMemory = async (input: {
},
);
- if (!vectorSaveResponse.ok) {
- const errorData = await vectorSaveResponse.text();
- console.error(errorData);
- return {
- success: false,
- data: 0,
- error: `Failed to save to vector store. Backend returned error: ${errorData}`,
- };
- }
-
- let contentId: number;
-
- const response = (await vectorSaveResponse.json()) as {
- status: string;
- chunkedInput: string;
- message?: string;
- };
-
- try {
- if (response.status !== "ok") {
- if (response.status === "error") {
- return {
- success: false,
- data: 0,
- error: response.message,
- };
- } else {
- return {
- success: false,
- data: 0,
- error: `Failed to save to vector store. Backend returned error: ${response.message}`,
- };
- }
- }
- } catch (e) {
- return {
- success: false,
- data: 0,
- error: `Failed to save to vector store. Backend returned error: ${e}`,
- };
- }
-
- const saveToDbUrl =
- (metadata.baseUrl.split("#supermemory-user-")[0] ?? metadata.baseUrl) +
- "#supermemory-user-" +
- data.user.id;
-
- // Insert into database
- try {
- const insertResponse = await db
- .insert(storedContent)
- .values({
- content: pageContent,
- title: metadata.title,
- description: metadata.description,
- url: saveToDbUrl,
- baseUrl: saveToDbUrl,
- image: metadata.image,
- savedAt: new Date(),
- userId: data.user.id,
- type,
- noteId,
- })
- .returning({ id: storedContent.id });
- revalidatePath("/memories");
- revalidatePath("/home");
-
- if (!insertResponse[0]?.id) {
- return {
- success: false,
- data: 0,
- error: "Something went wrong while saving the document to the database",
- };
- }
-
- contentId = insertResponse[0]?.id;
- } catch (e) {
- const error = e as Error;
- console.log("Error: ", error.message);
-
- if (
- error.message.includes(
- "D1_ERROR: UNIQUE constraint failed: storedContent.baseUrl",
- )
- ) {
- return {
- success: false,
- data: 0,
- error: "Content already exists",
- };
- }
-
- return {
- success: false,
- data: 0,
- error: "Failed to save to database with error: " + error.message,
- };
- }
-
- if (storeToSpaces.length > 0) {
- // Adding the many-to-many relationship between content and spaces
- const spaceData = await db
- .select()
- .from(space)
- .where(
- and(inArray(space.id, storeToSpaces), eq(space.user, data.user.id)),
- )
- .all();
-
- await Promise.all(
- spaceData.map(async (s) => {
- await db
- .insert(contentToSpace)
- .values({ contentId: contentId, spaceId: s.id });
-
- await db.update(space).set({ numItems: s.numItems + 1 });
- }),
- );
- }
+// const type = typeDecider(input.content);
+
+// let pageContent = input.content;
+// let metadata: Awaited<ReturnType<typeof getMetaData>>;
+// let vectorData: string;
+
+// if (!(await limit(data.user.id, type))) {
+// return {
+// success: false,
+// data: 0,
+// error: `You have exceeded the limit of ${LIMITS[type as keyof typeof LIMITS]} ${type}s.`,
+// };
+// }
+
+// let noteId = 0;
+
+// if (type === "page") {
+// const response = await fetch("https://md.dhr.wtf/?url=" + input.content, {
+// headers: {
+// Authorization: "Bearer " + process.env.BACKEND_SECURITY_KEY,
+// },
+// });
+// pageContent = await response.text();
+// vectorData = pageContent;
+// try {
+// metadata = await getMetaData(input.content);
+// } catch (e) {
+// return {
+// success: false,
+// error: "Failed to fetch metadata for the page. Please try again later.",
+// };
+// }
+// } else if (type === "tweet") {
+// //Request the worker for the entire thread
+
+// let thread: string;
+// let errorOccurred: boolean = false;
+
+// try {
+// const cf_thread_endpoint = process.env.THREAD_CF_WORKER;
+// const authKey = process.env.THREAD_CF_AUTH;
+// const threadRequest = await fetch(cf_thread_endpoint, {
+// method: "POST",
+// headers: {
+// "Content-Type": "application/json",
+// Authorization: authKey,
+// },
+// body: JSON.stringify({ url: input.content }),
+// });
+
+// if (threadRequest.status !== 200) {
+// throw new Error(
+// `Failed to fetch the thread: ${input.content}, Reason: ${threadRequest.statusText}`,
+// );
+// }
+
+// thread = await threadRequest.text();
+// if (thread.trim().length === 2) {
+// console.log("Thread is an empty array");
+// throw new Error(
+// "[THREAD FETCHING SERVICE] Got no content form thread worker",
+// );
+// }
+// } catch (e) {
+// console.log("[THREAD FETCHING SERVICE] Failed to fetch the thread", e);
+// errorOccurred = true;
+// }
+
+// const tweet = await getTweetData(input.content.split("/").pop() as string);
+
+// pageContent = tweetToMd(tweet);
+// console.log("THis ishte page content!!", pageContent);
+// //@ts-ignore
+// vectorData = errorOccurred ? JSON.stringify(pageContent) : thread;
+// metadata = {
+// baseUrl: input.content,
+// description: tweet.text.slice(0, 200),
+// image: tweet.user.profile_image_url_https,
+// title: `Tweet by ${tweet.user.name}`,
+// };
+// } else if (type === "note") {
+// pageContent = input.content;
+// vectorData = pageContent;
+// noteId = new Date().getTime();
+// metadata = {
+// baseUrl: `https://supermemory.ai/note/${noteId}`,
+// description: `Note created at ${new Date().toLocaleString()}`,
+// image: "https://supermemory.ai/logo.png",
+// title: `${pageContent.slice(0, 20)} ${pageContent.length > 20 ? "..." : ""}`,
+// };
+// } else {
+// return {
+// success: false,
+// data: 0,
+// error: "Invalid type",
+// };
+// }
+
+// let storeToSpaces = input.spaces;
+
+// if (!storeToSpaces) {
+// storeToSpaces = [];
+// }
+
+// const vectorSaveResponse = await fetch(
+// `${process.env.BACKEND_BASE_URL}/api/add`,
+// {
+// method: "POST",
+// body: JSON.stringify({
+// pageContent: vectorData,
+// title: metadata.title,
+// description: metadata.description,
+// url: metadata.baseUrl,
+// spaces: storeToSpaces.map((spaceId) => spaceId.toString()),
+// user: data.user.id,
+// type,
+// }),
+// headers: {
+// "Content-Type": "application/json",
+// Authorization: "Bearer " + process.env.BACKEND_SECURITY_KEY,
+// },
+// },
+// );
+
+// if (!vectorSaveResponse.ok) {
+// const errorData = await vectorSaveResponse.text();
+// console.error(errorData);
+// return {
+// success: false,
+// data: 0,
+// error: `Failed to save to vector store. Backend returned error: ${errorData}`,
+// };
+// }
+
+// let contentId: number;
+
+// const response = (await vectorSaveResponse.json()) as {
+// status: string;
+// chunkedInput: string;
+// message?: string;
+// };
+
+// try {
+// if (response.status !== "ok") {
+// if (response.status === "error") {
+// return {
+// success: false,
+// data: 0,
+// error: response.message,
+// };
+// } else {
+// return {
+// success: false,
+// data: 0,
+// error: `Failed to save to vector store. Backend returned error: ${response.message}`,
+// };
+// }
+// }
+// } catch (e) {
+// return {
+// success: false,
+// data: 0,
+// error: `Failed to save to vector store. Backend returned error: ${e}`,
+// };
+// }
+
+// const saveToDbUrl =
+// (metadata.baseUrl.split("#supermemory-user-")[0] ?? metadata.baseUrl) +
+// "#supermemory-user-" +
+// data.user.id;
+
+// // Insert into database
+// try {
+// const insertResponse = await db
+// .insert(storedContent)
+// .values({
+// content: pageContent,
+// title: metadata.title,
+// description: metadata.description,
+// url: saveToDbUrl,
+// baseUrl: saveToDbUrl,
+// image: metadata.image,
+// savedAt: new Date(),
+// userId: data.user.id,
+// type,
+// noteId,
+// })
+// .returning({ id: storedContent.id });
+// revalidatePath("/memories");
+// revalidatePath("/home");
+
+// if (!insertResponse[0]?.id) {
+// return {
+// success: false,
+// data: 0,
+// error: "Something went wrong while saving the document to the database",
+// };
+// }
+
+// contentId = insertResponse[0]?.id;
+// } catch (e) {
+// const error = e as Error;
+// console.log("Error: ", error.message);
+
+// if (
+// error.message.includes(
+// "D1_ERROR: UNIQUE constraint failed: storedContent.baseUrl",
+// )
+// ) {
+// return {
+// success: false,
+// data: 0,
+// error: "Content already exists",
+// };
+// }
+
+// return {
+// success: false,
+// data: 0,
+// error: "Failed to save to database with error: " + error.message,
+// };
+// }
+
+// if (storeToSpaces.length > 0) {
+// // Adding the many-to-many relationship between content and spaces
+// const spaceData = await db
+// .select()
+// .from(space)
+// .where(
+// and(inArray(space.id, storeToSpaces), eq(space.user, data.user.id)),
+// )
+// .all();
+
+// await Promise.all(
+// spaceData.map(async (s) => {
+// await db
+// .insert(contentToSpace)
+// .values({ contentId: contentId, spaceId: s.id });
+
+// await db.update(space).set({ numItems: s.numItems + 1 });
+// }),
+// );
+// }
return {
success: true,
@@ -457,6 +475,7 @@ export const createChatThread = async (
return { error: "Not authenticated", success: false };
}
+
const thread = await db
.insert(chatThreads)
.values({
diff --git a/apps/web/lib/get-metadata.ts b/apps/web/lib/get-metadata.ts
deleted file mode 100644
index c81397ff..00000000
--- a/apps/web/lib/get-metadata.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-"use server";
-import * as cheerio from "cheerio";
-
-// TODO: THIS SHOULD PROBABLY ALSO FETCH THE OG-IMAGE
-export async function getMetaData(url: string) {
- const response = await fetch(url);
- const html = await response.text();
-
- const $ = cheerio.load(html);
-
- // Extract the base URL
- const baseUrl = url;
-
- // Extract title
- const title = $("title").text().trim();
-
- const description = $("meta[name=description]").attr("content") ?? "";
-
- const _favicon =
- $("link[rel=icon]").attr("href") ?? "https://supermemory.dhr.wtf/web.svg";
-
- let favicon =
- _favicon.trim().length > 0
- ? _favicon.trim()
- : "https://supermemory.dhr.wtf/web.svg";
- if (favicon.startsWith("/")) {
- favicon = baseUrl + favicon;
- } else if (favicon.startsWith("./")) {
- favicon = baseUrl + favicon.slice(1);
- }
-
- // Prepare the metadata object
- const metadata = {
- title,
- description,
- image: favicon,
- baseUrl,
- };
- return metadata;
-}
diff --git a/apps/web/migrations/0000_steep_moira_mactaggert.sql b/apps/web/migrations/0000_omniscient_stick.sql
index 5813639d..542d6d0e 100644
--- a/apps/web/migrations/0000_steep_moira_mactaggert.sql
+++ b/apps/web/migrations/0000_omniscient_stick.sql
@@ -43,7 +43,7 @@ CREATE TABLE `chatHistory` (
`answerParts` text,
`answerSources` text,
`answerJustification` text,
- `createdAt` integer DEFAULT '"2024-07-25T22:31:50.848Z"' NOT NULL,
+ `createdAt` integer DEFAULT '"2024-07-29T17:06:56.122Z"' NOT NULL,
FOREIGN KEY (`threadId`) REFERENCES `chatThread`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
@@ -62,6 +62,19 @@ CREATE TABLE `contentToSpace` (
FOREIGN KEY (`spaceId`) REFERENCES `space`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
+CREATE TABLE `jobs` (
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
+ `userId` text NOT NULL,
+ `url` text NOT NULL,
+ `status` text NOT NULL,
+ `attempts` integer DEFAULT 0 NOT NULL,
+ `lastAttemptAt` integer,
+ `error` blob,
+ `createdAt` integer NOT NULL,
+ `updatedAt` integer NOT NULL,
+ FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
+);
+--> statement-breakpoint
CREATE TABLE `session` (
`sessionToken` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
@@ -122,6 +135,10 @@ CREATE UNIQUE INDEX `authenticator_credentialID_unique` ON `authenticator` (`cre
CREATE INDEX `canvas_user_userId` ON `canvas` (`userId`);--> statement-breakpoint
CREATE INDEX `chatHistory_thread_idx` ON `chatHistory` (`threadId`);--> statement-breakpoint
CREATE INDEX `chatThread_user_idx` ON `chatThread` (`userId`);--> statement-breakpoint
+CREATE INDEX `jobs_userId_idx` ON `jobs` (`userId`);--> statement-breakpoint
+CREATE INDEX `jobs_status_idx` ON `jobs` (`status`);--> statement-breakpoint
+CREATE INDEX `jobs_createdAt_idx` ON `jobs` (`createdAt`);--> statement-breakpoint
+CREATE INDEX `jobs_url_idx` ON `jobs` (`url`);--> statement-breakpoint
CREATE UNIQUE INDEX `space_name_unique` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_name_idx` ON `space` (`name`);--> statement-breakpoint
CREATE INDEX `spaces_user_idx` ON `space` (`user`);--> statement-breakpoint
diff --git a/apps/web/migrations/meta/0000_snapshot.json b/apps/web/migrations/meta/0000_snapshot.json
index a7689010..8141d674 100644
--- a/apps/web/migrations/meta/0000_snapshot.json
+++ b/apps/web/migrations/meta/0000_snapshot.json
@@ -1,822 +1,1027 @@
{
- "version": "6",
- "dialect": "sqlite",
- "id": "8705302a-eae7-4fbf-9ce8-8ae23df228a2",
- "prevId": "00000000-0000-0000-0000-000000000000",
- "tables": {
- "account": {
- "name": "account",
- "columns": {
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "provider": {
- "name": "provider",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "providerAccountId": {
- "name": "providerAccountId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "refresh_token": {
- "name": "refresh_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "access_token": {
- "name": "access_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "expires_at": {
- "name": "expires_at",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "token_type": {
- "name": "token_type",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "scope": {
- "name": "scope",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "id_token": {
- "name": "id_token",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "session_state": {
- "name": "session_state",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "account_userId_user_id_fk": {
- "name": "account_userId_user_id_fk",
- "tableFrom": "account",
- "tableTo": "user",
- "columnsFrom": ["userId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "account_provider_providerAccountId_pk": {
- "columns": ["provider", "providerAccountId"],
- "name": "account_provider_providerAccountId_pk"
- }
- },
- "uniqueConstraints": {}
- },
- "authenticator": {
- "name": "authenticator",
- "columns": {
- "credentialID": {
- "name": "credentialID",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "providerAccountId": {
- "name": "providerAccountId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "credentialPublicKey": {
- "name": "credentialPublicKey",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "counter": {
- "name": "counter",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "credentialDeviceType": {
- "name": "credentialDeviceType",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "credentialBackedUp": {
- "name": "credentialBackedUp",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "transports": {
- "name": "transports",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- }
- },
- "indexes": {
- "authenticator_credentialID_unique": {
- "name": "authenticator_credentialID_unique",
- "columns": ["credentialID"],
- "isUnique": true
- }
- },
- "foreignKeys": {
- "authenticator_userId_user_id_fk": {
- "name": "authenticator_userId_user_id_fk",
- "tableFrom": "authenticator",
- "tableTo": "user",
- "columnsFrom": ["userId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "authenticator_userId_credentialID_pk": {
- "columns": ["credentialID", "userId"],
- "name": "authenticator_userId_credentialID_pk"
- }
- },
- "uniqueConstraints": {}
- },
- "canvas": {
- "name": "canvas",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "title": {
- "name": "title",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'Untitled'"
- },
- "description": {
- "name": "description",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'Untitled'"
- },
- "url": {
- "name": "url",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "''"
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {
- "canvas_user_userId": {
- "name": "canvas_user_userId",
- "columns": ["userId"],
- "isUnique": false
- }
- },
- "foreignKeys": {
- "canvas_userId_user_id_fk": {
- "name": "canvas_userId_user_id_fk",
- "tableFrom": "canvas",
- "tableTo": "user",
- "columnsFrom": ["userId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "chatHistory": {
- "name": "chatHistory",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": true
- },
- "threadId": {
- "name": "threadId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "question": {
- "name": "question",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "answerParts": {
- "name": "answerParts",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "answerSources": {
- "name": "answerSources",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "answerJustification": {
- "name": "answerJustification",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'\"2024-07-25T22:31:50.848Z\"'"
- }
- },
- "indexes": {
- "chatHistory_thread_idx": {
- "name": "chatHistory_thread_idx",
- "columns": ["threadId"],
- "isUnique": false
- }
- },
- "foreignKeys": {
- "chatHistory_threadId_chatThread_id_fk": {
- "name": "chatHistory_threadId_chatThread_id_fk",
- "tableFrom": "chatHistory",
- "tableTo": "chatThread",
- "columnsFrom": ["threadId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "chatThread": {
- "name": "chatThread",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "firstMessage": {
- "name": "firstMessage",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {
- "chatThread_user_idx": {
- "name": "chatThread_user_idx",
- "columns": ["userId"],
- "isUnique": false
- }
- },
- "foreignKeys": {
- "chatThread_userId_user_id_fk": {
- "name": "chatThread_userId_user_id_fk",
- "tableFrom": "chatThread",
- "tableTo": "user",
- "columnsFrom": ["userId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "contentToSpace": {
- "name": "contentToSpace",
- "columns": {
- "contentId": {
- "name": "contentId",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "spaceId": {
- "name": "spaceId",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "contentToSpace_contentId_storedContent_id_fk": {
- "name": "contentToSpace_contentId_storedContent_id_fk",
- "tableFrom": "contentToSpace",
- "tableTo": "storedContent",
- "columnsFrom": ["contentId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- },
- "contentToSpace_spaceId_space_id_fk": {
- "name": "contentToSpace_spaceId_space_id_fk",
- "tableFrom": "contentToSpace",
- "tableTo": "space",
- "columnsFrom": ["spaceId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "contentToSpace_contentId_spaceId_pk": {
- "columns": ["contentId", "spaceId"],
- "name": "contentToSpace_contentId_spaceId_pk"
- }
- },
- "uniqueConstraints": {}
- },
- "session": {
- "name": "session",
- "columns": {
- "sessionToken": {
- "name": "sessionToken",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "userId": {
- "name": "userId",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires": {
- "name": "expires",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "session_userId_user_id_fk": {
- "name": "session_userId_user_id_fk",
- "tableFrom": "session",
- "tableTo": "user",
- "columnsFrom": ["userId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "space": {
- "name": "space",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": true
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": "'none'"
- },
- "user": {
- "name": "user",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "createdAt": {
- "name": "createdAt",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "numItems": {
- "name": "numItems",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false,
- "default": 0
- }
- },
- "indexes": {
- "space_name_unique": {
- "name": "space_name_unique",
- "columns": ["name"],
- "isUnique": true
- },
- "spaces_name_idx": {
- "name": "spaces_name_idx",
- "columns": ["name"],
- "isUnique": false
- },
- "spaces_user_idx": {
- "name": "spaces_user_idx",
- "columns": ["user"],
- "isUnique": false
- }
- },
- "foreignKeys": {
- "space_user_user_id_fk": {
- "name": "space_user_user_id_fk",
- "tableFrom": "space",
- "tableTo": "user",
- "columnsFrom": ["user"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "spacesAccess": {
- "name": "spacesAccess",
- "columns": {
- "spaceId": {
- "name": "spaceId",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "userEmail": {
- "name": "userEmail",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {
- "spacesAccess_spaceId_space_id_fk": {
- "name": "spacesAccess_spaceId_space_id_fk",
- "tableFrom": "spacesAccess",
- "tableTo": "space",
- "columnsFrom": ["spaceId"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {
- "spacesAccess_spaceId_userEmail_pk": {
- "columns": ["spaceId", "userEmail"],
- "name": "spacesAccess_spaceId_userEmail_pk"
- }
- },
- "uniqueConstraints": {}
- },
- "storedContent": {
- "name": "storedContent",
- "columns": {
- "id": {
- "name": "id",
- "type": "integer",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": true
- },
- "content": {
- "name": "content",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "title": {
- "name": "title",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "description": {
- "name": "description",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "url": {
- "name": "url",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "savedAt": {
- "name": "savedAt",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "baseUrl": {
- "name": "baseUrl",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "ogImage": {
- "name": "ogImage",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "type": {
- "name": "type",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false,
- "default": "'page'"
- },
- "image": {
- "name": "image",
- "type": "text(255)",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "user": {
- "name": "user",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "noteId": {
- "name": "noteId",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- }
- },
- "indexes": {
- "storedContent_baseUrl_unique": {
- "name": "storedContent_baseUrl_unique",
- "columns": ["baseUrl"],
- "isUnique": true
- },
- "storedContent_url_idx": {
- "name": "storedContent_url_idx",
- "columns": ["url"],
- "isUnique": false
- },
- "storedContent_savedAt_idx": {
- "name": "storedContent_savedAt_idx",
- "columns": ["savedAt"],
- "isUnique": false
- },
- "storedContent_title_idx": {
- "name": "storedContent_title_idx",
- "columns": ["title"],
- "isUnique": false
- },
- "storedContent_user_idx": {
- "name": "storedContent_user_idx",
- "columns": ["user"],
- "isUnique": false
- }
- },
- "foreignKeys": {
- "storedContent_user_user_id_fk": {
- "name": "storedContent_user_user_id_fk",
- "tableFrom": "storedContent",
- "tableTo": "user",
- "columnsFrom": ["user"],
- "columnsTo": ["id"],
- "onDelete": "cascade",
- "onUpdate": "no action"
- }
- },
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "user": {
- "name": "user",
- "columns": {
- "id": {
- "name": "id",
- "type": "text",
- "primaryKey": true,
- "notNull": true,
- "autoincrement": false
- },
- "name": {
- "name": "name",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "email": {
- "name": "email",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "emailVerified": {
- "name": "emailVerified",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "image": {
- "name": "image",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "telegramId": {
- "name": "telegramId",
- "type": "text",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false
- },
- "hasOnboarded": {
- "name": "hasOnboarded",
- "type": "integer",
- "primaryKey": false,
- "notNull": false,
- "autoincrement": false,
- "default": false
- }
- },
- "indexes": {
- "users_email_idx": {
- "name": "users_email_idx",
- "columns": ["email"],
- "isUnique": false
- },
- "users_telegram_idx": {
- "name": "users_telegram_idx",
- "columns": ["telegramId"],
- "isUnique": false
- },
- "users_id_idx": {
- "name": "users_id_idx",
- "columns": ["id"],
- "isUnique": false
- }
- },
- "foreignKeys": {},
- "compositePrimaryKeys": {},
- "uniqueConstraints": {}
- },
- "verificationToken": {
- "name": "verificationToken",
- "columns": {
- "identifier": {
- "name": "identifier",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "token": {
- "name": "token",
- "type": "text",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- },
- "expires": {
- "name": "expires",
- "type": "integer",
- "primaryKey": false,
- "notNull": true,
- "autoincrement": false
- }
- },
- "indexes": {},
- "foreignKeys": {},
- "compositePrimaryKeys": {
- "verificationToken_identifier_token_pk": {
- "columns": ["identifier", "token"],
- "name": "verificationToken_identifier_token_pk"
- }
- },
- "uniqueConstraints": {}
- }
- },
- "enums": {},
- "_meta": {
- "schemas": {},
- "tables": {},
- "columns": {}
- }
-}
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "1197a463-b72a-47c8-b018-ddce31ef9c31",
+ "prevId": "00000000-0000-0000-0000-000000000000",
+ "tables": {
+ "account": {
+ "name": "account",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "account_userId_user_id_fk": {
+ "name": "account_userId_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "account_provider_providerAccountId_pk": {
+ "columns": [
+ "provider",
+ "providerAccountId"
+ ],
+ "name": "account_provider_providerAccountId_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "authenticator": {
+ "name": "authenticator",
+ "columns": {
+ "credentialID": {
+ "name": "credentialID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "credentialPublicKey": {
+ "name": "credentialPublicKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "credentialDeviceType": {
+ "name": "credentialDeviceType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "credentialBackedUp": {
+ "name": "credentialBackedUp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "authenticator_credentialID_unique": {
+ "name": "authenticator_credentialID_unique",
+ "columns": [
+ "credentialID"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "authenticator_userId_user_id_fk": {
+ "name": "authenticator_userId_user_id_fk",
+ "tableFrom": "authenticator",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "authenticator_userId_credentialID_pk": {
+ "columns": [
+ "credentialID",
+ "userId"
+ ],
+ "name": "authenticator_userId_credentialID_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "canvas": {
+ "name": "canvas",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'Untitled'"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'Untitled'"
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "canvas_user_userId": {
+ "name": "canvas_user_userId",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "canvas_userId_user_id_fk": {
+ "name": "canvas_userId_user_id_fk",
+ "tableFrom": "canvas",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "chatHistory": {
+ "name": "chatHistory",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "threadId": {
+ "name": "threadId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "question": {
+ "name": "question",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "answerParts": {
+ "name": "answerParts",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "answerSources": {
+ "name": "answerSources",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "answerJustification": {
+ "name": "answerJustification",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'\"2024-07-29T17:06:56.122Z\"'"
+ }
+ },
+ "indexes": {
+ "chatHistory_thread_idx": {
+ "name": "chatHistory_thread_idx",
+ "columns": [
+ "threadId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "chatHistory_threadId_chatThread_id_fk": {
+ "name": "chatHistory_threadId_chatThread_id_fk",
+ "tableFrom": "chatHistory",
+ "tableTo": "chatThread",
+ "columnsFrom": [
+ "threadId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "chatThread": {
+ "name": "chatThread",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "firstMessage": {
+ "name": "firstMessage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "chatThread_user_idx": {
+ "name": "chatThread_user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "chatThread_userId_user_id_fk": {
+ "name": "chatThread_userId_user_id_fk",
+ "tableFrom": "chatThread",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "contentToSpace": {
+ "name": "contentToSpace",
+ "columns": {
+ "contentId": {
+ "name": "contentId",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "contentToSpace_contentId_storedContent_id_fk": {
+ "name": "contentToSpace_contentId_storedContent_id_fk",
+ "tableFrom": "contentToSpace",
+ "tableTo": "storedContent",
+ "columnsFrom": [
+ "contentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "contentToSpace_spaceId_space_id_fk": {
+ "name": "contentToSpace_spaceId_space_id_fk",
+ "tableFrom": "contentToSpace",
+ "tableTo": "space",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "contentToSpace_contentId_spaceId_pk": {
+ "columns": [
+ "contentId",
+ "spaceId"
+ ],
+ "name": "contentToSpace_contentId_spaceId_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "jobs": {
+ "name": "jobs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "lastAttemptAt": {
+ "name": "lastAttemptAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error": {
+ "name": "error",
+ "type": "blob",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "jobs_userId_idx": {
+ "name": "jobs_userId_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "jobs_status_idx": {
+ "name": "jobs_status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ },
+ "jobs_createdAt_idx": {
+ "name": "jobs_createdAt_idx",
+ "columns": [
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "jobs_url_idx": {
+ "name": "jobs_url_idx",
+ "columns": [
+ "url"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "jobs_userId_user_id_fk": {
+ "name": "jobs_userId_user_id_fk",
+ "tableFrom": "jobs",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "session_userId_user_id_fk": {
+ "name": "session_userId_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "space": {
+ "name": "space",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'none'"
+ },
+ "user": {
+ "name": "user",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "numItems": {
+ "name": "numItems",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "space_name_unique": {
+ "name": "space_name_unique",
+ "columns": [
+ "name"
+ ],
+ "isUnique": true
+ },
+ "spaces_name_idx": {
+ "name": "spaces_name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": false
+ },
+ "spaces_user_idx": {
+ "name": "spaces_user_idx",
+ "columns": [
+ "user"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "space_user_user_id_fk": {
+ "name": "space_user_user_id_fk",
+ "tableFrom": "space",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "spacesAccess": {
+ "name": "spacesAccess",
+ "columns": {
+ "spaceId": {
+ "name": "spaceId",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userEmail": {
+ "name": "userEmail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "spacesAccess_spaceId_space_id_fk": {
+ "name": "spacesAccess_spaceId_space_id_fk",
+ "tableFrom": "spacesAccess",
+ "tableTo": "space",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spacesAccess_spaceId_userEmail_pk": {
+ "columns": [
+ "spaceId",
+ "userEmail"
+ ],
+ "name": "spacesAccess_spaceId_userEmail_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ },
+ "storedContent": {
+ "name": "storedContent",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "savedAt": {
+ "name": "savedAt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "baseUrl": {
+ "name": "baseUrl",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ogImage": {
+ "name": "ogImage",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "'page'"
+ },
+ "image": {
+ "name": "image",
+ "type": "text(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user": {
+ "name": "user",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "noteId": {
+ "name": "noteId",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "storedContent_baseUrl_unique": {
+ "name": "storedContent_baseUrl_unique",
+ "columns": [
+ "baseUrl"
+ ],
+ "isUnique": true
+ },
+ "storedContent_url_idx": {
+ "name": "storedContent_url_idx",
+ "columns": [
+ "url"
+ ],
+ "isUnique": false
+ },
+ "storedContent_savedAt_idx": {
+ "name": "storedContent_savedAt_idx",
+ "columns": [
+ "savedAt"
+ ],
+ "isUnique": false
+ },
+ "storedContent_title_idx": {
+ "name": "storedContent_title_idx",
+ "columns": [
+ "title"
+ ],
+ "isUnique": false
+ },
+ "storedContent_user_idx": {
+ "name": "storedContent_user_idx",
+ "columns": [
+ "user"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "storedContent_user_user_id_fk": {
+ "name": "storedContent_user_user_id_fk",
+ "tableFrom": "storedContent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "telegramId": {
+ "name": "telegramId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "hasOnboarded": {
+ "name": "hasOnboarded",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "users_email_idx": {
+ "name": "users_email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": false
+ },
+ "users_telegram_idx": {
+ "name": "users_telegram_idx",
+ "columns": [
+ "telegramId"
+ ],
+ "isUnique": false
+ },
+ "users_id_idx": {
+ "name": "users_id_idx",
+ "columns": [
+ "id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {}
+ },
+ "verificationToken": {
+ "name": "verificationToken",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verificationToken_identifier_token_pk": {
+ "columns": [
+ "identifier",
+ "token"
+ ],
+ "name": "verificationToken_identifier_token_pk"
+ }
+ },
+ "uniqueConstraints": {}
+ }
+ },
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ }
+} \ No newline at end of file
diff --git a/apps/web/migrations/meta/_journal.json b/apps/web/migrations/meta/_journal.json
index d79e2607..254b90c6 100644
--- a/apps/web/migrations/meta/_journal.json
+++ b/apps/web/migrations/meta/_journal.json
@@ -1,13 +1,13 @@
{
- "version": "6",
- "dialect": "sqlite",
- "entries": [
- {
- "idx": 0,
- "version": "6",
- "when": 1721946710900,
- "tag": "0000_steep_moira_mactaggert",
- "breakpoints": true
- }
- ]
-}
+ "version": "6",
+ "dialect": "sqlite",
+ "entries": [
+ {
+ "idx": 0,
+ "version": "6",
+ "when": 1722272816127,
+ "tag": "0000_omniscient_stick",
+ "breakpoints": true
+ }
+ ]
+} \ No newline at end of file
diff --git a/apps/web/server/db/schema.ts b/apps/web/server/db/schema.ts
index 32b80719..11711997 100644
--- a/apps/web/server/db/schema.ts
+++ b/apps/web/server/db/schema.ts
@@ -7,6 +7,7 @@ import {
sqliteTableCreator,
text,
integer,
+ blob,
} from "drizzle-orm/sqlite-core";
import type { AdapterAccountType } from "next-auth/adapters";
@@ -242,3 +243,28 @@ export const canvas = createTable(
export type ChatThread = typeof chatThreads.$inferSelect;
export type ChatHistory = typeof chatHistory.$inferSelect;
+
+export const jobs = createTable(
+ "jobs",
+ {
+ id: integer("id").notNull().primaryKey({ autoIncrement: true }),
+ userId: text("userId")
+ .notNull()
+ .references(() => users.id, { onDelete: "cascade" }),
+ url: text("url").notNull(),
+ status: text("status").notNull(),
+ attempts: integer("attempts").notNull().default(0),
+ lastAttemptAt: integer("lastAttemptAt"),
+ error: blob("error"),
+ createdAt: integer("createdAt").notNull(),
+ updatedAt: integer("updatedAt").notNull(),
+ },
+ (job) => ({
+ userIdx: index("jobs_userId_idx").on(job.userId),
+ statusIdx: index("jobs_status_idx").on(job.status),
+ createdAtIdx: index("jobs_createdAt_idx").on(job.createdAt),
+ urlIdx: index("jobs_url_idx").on(job.url),
+ }),
+);
+
+export type Job = typeof jobs.$inferSelect;