mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Minor cleanup and fix
This commit is contained in:
parent
ff14d77c11
commit
8af182abaf
15 changed files with 2389 additions and 59 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
bun.lockb
|
||||
tests/
|
||||
|
||||
packages/scripts/*
|
||||
# Dependencies
|
||||
|
|
|
|||
1
apps/backend/drizzle/0019_vengeful_marten_broadcloak.sql
Normal file
1
apps/backend/drizzle/0019_vengeful_marten_broadcloak.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE "documents" ADD COLUMN "metadata" jsonb;
|
||||
2
apps/backend/drizzle/0020_opposite_steel_serpent.sql
Normal file
2
apps/backend/drizzle/0020_opposite_steel_serpent.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
-- Active: 1732308352274@@127.0.0.1@5432@supermemorydhravya
|
||||
DROP TABLE "job";
|
||||
1228
apps/backend/drizzle/meta/0019_snapshot.json
Normal file
1228
apps/backend/drizzle/meta/0019_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
1127
apps/backend/drizzle/meta/0020_snapshot.json
Normal file
1127
apps/backend/drizzle/meta/0020_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -121,19 +121,26 @@
|
|||
"tag": "0016_good_deathbird",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 17,
|
||||
"version": "7",
|
||||
"when": 1739939067023,
|
||||
"tag": "0017_oval_misty_knight",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 18,
|
||||
"version": "7",
|
||||
"when": 1739939254444,
|
||||
"tag": "0018_past_inertia",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 19,
|
||||
"version": "7",
|
||||
"when": 1741025619581,
|
||||
"tag": "0019_vengeful_marten_broadcloak",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 20,
|
||||
"version": "7",
|
||||
"when": 1741026944027,
|
||||
"tag": "0020_opposite_steel_serpent",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -28,9 +28,7 @@ import { ConfigType, GeneralConfigType, rateLimiter } from "hono-rate-limiter";
|
|||
// Create base Hono app first
|
||||
const honoApp = new Hono<{ Variables: Variables; Bindings: Env }>();
|
||||
|
||||
const app = fromHono(honoApp, {
|
||||
base: "",
|
||||
});
|
||||
const app = fromHono(honoApp);
|
||||
|
||||
// Add all middleware and routes
|
||||
app.use("*", timing());
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ import { typeDecider } from "../utils/typeDecider";
|
|||
import { isErr, Ok } from "../errors/results";
|
||||
import { fromHono } from "chanfana";
|
||||
|
||||
const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
||||
base: "",
|
||||
})
|
||||
const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>())
|
||||
.post(
|
||||
"/chat",
|
||||
zValidator(
|
||||
|
|
@ -725,6 +723,10 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
|||
z.object({
|
||||
content: z.string().min(1, "Content cannot be empty"),
|
||||
spaces: z.array(z.string()).max(5).optional(),
|
||||
id: z.string().optional(),
|
||||
// any type of metadata. must be json serializable.
|
||||
metadata: z.any().optional(),
|
||||
images: z.array(z.string()).optional(),
|
||||
prefetched: z
|
||||
.object({
|
||||
contentToVectorize: z.string(),
|
||||
|
|
@ -739,7 +741,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
|||
),
|
||||
async (c) => {
|
||||
const body = c.req.valid("json");
|
||||
console.log("body", body);
|
||||
|
||||
const user = c.get("user");
|
||||
|
||||
if (!user) {
|
||||
|
|
@ -764,7 +766,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
|||
body.content = `https://${body.content}`;
|
||||
}
|
||||
|
||||
const uuid = randomId();
|
||||
const uuid = body.id ?? randomId();
|
||||
const contentId = `add-${user.id}-${uuid}`;
|
||||
|
||||
const db = database(c.env.HYPERDRIVE.connectionString);
|
||||
|
|
@ -910,6 +912,7 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
|||
contentHash: documentHash,
|
||||
raw:
|
||||
(body.prefetched ?? body.content) + "\n\n" + body.spaces?.join(" "),
|
||||
metadata: body.metadata,
|
||||
});
|
||||
|
||||
await c.env.CONTENT_WORKFLOW.create({
|
||||
|
|
@ -1198,4 +1201,3 @@ const actions = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
|||
);
|
||||
|
||||
export default actions;
|
||||
import { Context } from 'hono/jsx'
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ import { database } from "@supermemory/db";
|
|||
import { fromHono } from "chanfana";
|
||||
|
||||
const integrations = fromHono(
|
||||
new Hono<{ Variables: Variables; Bindings: Env }>(),
|
||||
{
|
||||
base: "",
|
||||
}
|
||||
).get("/notion/import", async (c) => {
|
||||
new Hono<{ Variables: Variables; Bindings: Env }>()).get("/notion/import", async (c) => {
|
||||
const user = c.get("user");
|
||||
if (!user) {
|
||||
return c.json({ error: "Unauthorized" }, 401);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ import {
|
|||
import { and, database, desc, eq, or, sql, isNull } from "@supermemory/db";
|
||||
import { fromHono } from "chanfana";
|
||||
|
||||
const memories = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
||||
base: "",
|
||||
})
|
||||
const memories = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>())
|
||||
.get(
|
||||
"/",
|
||||
zValidator(
|
||||
|
|
|
|||
|
|
@ -15,11 +15,7 @@ import { randomId } from "@supermemory/shared";
|
|||
import { fromHono } from "chanfana";
|
||||
|
||||
const spacesRoute = fromHono(
|
||||
new Hono<{ Variables: Variables; Bindings: Env }>(),
|
||||
{
|
||||
base: "",
|
||||
}
|
||||
)
|
||||
new Hono<{ Variables: Variables; Bindings: Env }>())
|
||||
.get("/", async (c) => {
|
||||
const user = c.get("user");
|
||||
if (!user) {
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ import { DurableObjectStore } from "@hono-rate-limiter/cloudflare";
|
|||
import { rateLimiter } from "hono-rate-limiter";
|
||||
import { fromHono } from "chanfana";
|
||||
|
||||
const user = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>(), {
|
||||
base: "",
|
||||
})
|
||||
const user = fromHono(new Hono<{ Variables: Variables; Bindings: Env }>())
|
||||
.get("/", (c) => {
|
||||
return c.json(c.get("user"));
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { Env } from "../types";
|
||||
|
||||
export const extractPageContent = async (content: string, env: Env) => {
|
||||
console.log("content", content);
|
||||
const resp = await fetch(`https://md.dhr.wtf?url=${content}`);
|
||||
const resp = await fetch(`https://r.jina.ai/${content}`);
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(
|
||||
|
|
|
|||
|
|
@ -3,10 +3,7 @@ import { getSignInUrl } from "@supermemory/authkit-remix-cloudflare";
|
|||
import { getSessionFromRequest } from "@supermemory/authkit-remix-cloudflare/src/session";
|
||||
|
||||
export async function loader({ request, context }: LoaderFunctionArgs) {
|
||||
const session = await getSessionFromRequest(request, context);
|
||||
if (session) {
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
const signinUrl = await getSignInUrl(context);
|
||||
return redirect(signinUrl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {
|
|||
timestamp,
|
||||
uniqueIndex,
|
||||
jsonb,
|
||||
date,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { sql } from "drizzle-orm";
|
||||
import { Metadata } from "../../apps/backend/src/types";
|
||||
|
|
@ -173,6 +172,7 @@ export const documents = pgTable(
|
|||
),
|
||||
errorMessage: text("error_message"),
|
||||
contentHash: text("content_hash"),
|
||||
metadata: jsonb("metadata"),
|
||||
},
|
||||
(table) => ({
|
||||
documentsIdIdx: uniqueIndex("document_id_idx").on(table.id),
|
||||
|
|
@ -244,25 +244,6 @@ export const chunk = pgTable(
|
|||
})
|
||||
);
|
||||
|
||||
export const jobs = pgTable(
|
||||
"job",
|
||||
{
|
||||
id: serial("id").primaryKey(),
|
||||
userId: integer("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }), //why restrict the jobs?? srrsly give me a reason
|
||||
url: text("url").notNull(),
|
||||
status: text("status").notNull(),
|
||||
attempts: integer("attempts").notNull().default(0),
|
||||
lastAttemptAt: timestamp("lastAttemptAt", { withTimezone: true }),
|
||||
error: text("error"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }),
|
||||
},
|
||||
(jobs) => ({
|
||||
userUniqueJobsIdx: uniqueIndex("user_id_url_idx").on(jobs.userId, jobs.url),
|
||||
})
|
||||
);
|
||||
|
||||
export const waitlist = pgTable("waitlist", {
|
||||
email: varchar("email", { length: 512 }).primaryKey(),
|
||||
|
|
@ -281,4 +262,3 @@ export type Chunk = typeof chunk.$inferSelect;
|
|||
export type ChunkInsert = typeof chunk.$inferInsert;
|
||||
export type DocumentType = typeof documentType.$inferSelect;
|
||||
export type ContentToSpace = typeof contentToSpace.$inferSelect;
|
||||
export type Job = typeof jobs.$inferInsert;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue