Add Obsidian Toolbox — 4 syntax generators under /tools
Inside-LMS toolbox for registered students: callout-CSS, YAML-frontmatter, theme CSS-variables, Style Settings generators. Auth inherited from (student) route group; no public surface, no email gate. - Pure generators in src/lib/tools/* with Vitest (33 tests) - Shared YAML-safe scalar quoter (_shared/yaml.ts) used by frontmatter + style-settings: unquoted user input was silently breaking YAML (tags '#x' -> null, color default '#7C3AED' -> null, 'a: b' -> parse error) - hex validation in callout (no NaN), date input constrained, clipboard + analytics calls guarded - Prisma ToolUsage model + migration; logToolUsage Server Action (auth-first, 10-min dedup window per user/tool) - Tool index /tools + ToolCard (explicit lucide map, no import *) + header link Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- Obsidian Toolbox — факт использования генератора участником (аналитика)
|
||||
CREATE TABLE "ToolUsage" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"tool" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "ToolUsage_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE INDEX "ToolUsage_userId_idx" ON "ToolUsage"("userId");
|
||||
CREATE INDEX "ToolUsage_tool_idx" ON "ToolUsage"("tool");
|
||||
CREATE INDEX "ToolUsage_createdAt_idx" ON "ToolUsage"("createdAt");
|
||||
|
||||
ALTER TABLE "ToolUsage" ADD CONSTRAINT "ToolUsage_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -46,6 +46,7 @@ model User {
|
||||
closedQuestions StudentQuestion[] @relation("QuestionClosedBy")
|
||||
questionMessages StudentQuestionMessage[]
|
||||
wrappedRuns WrappedRun[]
|
||||
toolUsages ToolUsage[]
|
||||
}
|
||||
|
||||
// Obsidian Wrapped — агрегаты прогона (БЕЗ имён/текстов заметок; обработка волта 100% client-side)
|
||||
@@ -68,6 +69,19 @@ model WrappedRun {
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// Obsidian Toolbox — факт использования генератора участником (для аналитики)
|
||||
model ToolUsage {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
tool String // callout | frontmatter | theme | style-settings
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([userId])
|
||||
@@index([tool])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
|
||||
Reference in New Issue
Block a user