0.6 rust重构01

This commit is contained in:
lix-2026
2026-04-14 13:22:29 +08:00
parent 71fb1aee7e
commit 84a8454fa9
401 changed files with 5841 additions and 1512 deletions
+3 -20
View File
@@ -1,9 +1,10 @@
import { internalMutation, internalQuery, mutation, query } from "./_generated/server";
import { v } from "convex/values";
import { getAuthUserId } from "@convex-dev/auth/server";
import { requireUserId } from "./_utils/auth";
import { nowIso } from "./_utils/time";
import { enqueueIngestMindmapJob } from "./_utils/ingestJobs";
import { internal } from "./_generated/api";
import { requireCanonicalOwnedDocument } from "./_utils/documentRecord";
const defaultMindmapData = {
data: { text: "中心主题" },
@@ -19,14 +20,6 @@ function resolveGraceSeconds(): number {
return Math.floor(parsed);
}
async function requireUserId(ctx: any): Promise<string> {
const userId = await getAuthUserId(ctx);
if (userId === null) {
throw new Error("未登录");
}
return userId;
}
function normalizeMindmapId(docId: string, mindmapId: string): string {
const raw = String(mindmapId ?? "").trim();
if (raw) return raw;
@@ -35,17 +28,7 @@ function normalizeMindmapId(docId: string, mindmapId: string): string {
}
async function requireOwnedDocument(ctx: any, userId: string, docId: string) {
const doc = await ctx.db
.query("documents")
.withIndex("by_document_id", (q: any) => q.eq("id", docId))
.first();
if (!doc) {
throw new Error("页面不存在");
}
if (doc.user_id !== userId) {
throw new Error("无权限");
}
return doc;
return await requireCanonicalOwnedDocument<any>(ctx, docId, userId);
}
export const get = query({