@goscribe/server 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/check-difficulty.cjs +14 -0
  2. package/check-questions.cjs +14 -0
  3. package/db-summary.cjs +22 -0
  4. package/mcq-test.cjs +36 -0
  5. package/package.json +9 -2
  6. package/prisma/migrations/20260413143206_init/migration.sql +873 -0
  7. package/prisma/schema.prisma +471 -324
  8. package/src/context.ts +4 -1
  9. package/src/lib/activity_human_description.test.ts +28 -0
  10. package/src/lib/activity_human_description.ts +239 -0
  11. package/src/lib/activity_log_service.test.ts +37 -0
  12. package/src/lib/activity_log_service.ts +353 -0
  13. package/src/lib/ai-session.ts +79 -51
  14. package/src/lib/email.ts +213 -29
  15. package/src/lib/env.ts +23 -6
  16. package/src/lib/inference.ts +2 -2
  17. package/src/lib/notification-service.test.ts +106 -0
  18. package/src/lib/notification-service.ts +677 -0
  19. package/src/lib/prisma.ts +6 -1
  20. package/src/lib/pusher.ts +86 -2
  21. package/src/lib/stripe.ts +39 -0
  22. package/src/lib/subscription_service.ts +722 -0
  23. package/src/lib/usage_service.ts +74 -0
  24. package/src/lib/worksheet-generation.test.ts +31 -0
  25. package/src/lib/worksheet-generation.ts +139 -0
  26. package/src/routers/_app.ts +9 -0
  27. package/src/routers/admin.ts +710 -0
  28. package/src/routers/annotations.ts +41 -0
  29. package/src/routers/auth.ts +338 -28
  30. package/src/routers/copilot.ts +719 -0
  31. package/src/routers/flashcards.ts +201 -68
  32. package/src/routers/members.ts +280 -80
  33. package/src/routers/notifications.ts +142 -0
  34. package/src/routers/payment.ts +448 -0
  35. package/src/routers/podcast.ts +112 -83
  36. package/src/routers/studyguide.ts +12 -0
  37. package/src/routers/worksheets.ts +289 -66
  38. package/src/routers/workspace.ts +329 -122
  39. package/src/scripts/purge-deleted-users.ts +167 -0
  40. package/src/server.ts +137 -11
  41. package/src/services/flashcard-progress.service.ts +49 -37
  42. package/src/trpc.ts +184 -5
  43. package/test-generate.js +30 -0
  44. package/test-ratio.cjs +9 -0
  45. package/zod-test.cjs +22 -0
  46. package/prisma/migrations/20250826124819_add_worksheet_difficulty_and_estimated_time/migration.sql +0 -213
  47. package/prisma/migrations/20250826133236_add_worksheet_question_progress/migration.sql +0 -31
  48. package/prisma/seed.mjs +0 -135
@@ -0,0 +1,14 @@
1
+ const { PrismaClient } = require('@prisma/client');
2
+ const prisma = new PrismaClient();
3
+
4
+ async function check() {
5
+ const artifacts = await prisma.artifact.findMany({
6
+ where: { type: 'WORKSHEET' },
7
+ orderBy: { createdAt: 'desc' },
8
+ take: 5,
9
+ select: { id: true, title: true, difficulty: true, generatingMetadata: true }
10
+ });
11
+ console.log("Recent Worksheets:", JSON.stringify(artifacts, null, 2));
12
+ }
13
+
14
+ check().catch(console.error).finally(() => prisma.$disconnect());
@@ -0,0 +1,14 @@
1
+ const { PrismaClient } = require('@prisma/client');
2
+ const prisma = new PrismaClient();
3
+
4
+ async function check() {
5
+ const artifacts = await prisma.artifact.findMany({
6
+ where: { type: 'WORKSHEET' },
7
+ orderBy: { createdAt: 'desc' },
8
+ take: 3,
9
+ select: { id: true, title: true, generatingMetadata: true, createdAt: true, questions: true }
10
+ });
11
+ console.log("Recent Worksheets:", JSON.stringify(artifacts, null, 2));
12
+ }
13
+
14
+ check().catch(console.error).finally(() => prisma.$disconnect());
package/db-summary.cjs ADDED
@@ -0,0 +1,22 @@
1
+ const { PrismaClient } = require('@prisma/client');
2
+ const prisma = new PrismaClient();
3
+
4
+ async function summary() {
5
+ const artifacts = await prisma.artifact.findMany({
6
+ where: { type: 'WORKSHEET' },
7
+ orderBy: { createdAt: 'desc' },
8
+ take: 10,
9
+ select: { id: true, createdAt: true, generatingMetadata: true, questions: { select: { type: true } } }
10
+ });
11
+
12
+ for (const a of artifacts) {
13
+ let mcqs = 0; let texts = 0;
14
+ for (const q of a.questions) {
15
+ if (q.type === 'MULTIPLE_CHOICE') mcqs++;
16
+ else if (q.type === 'TEXT') texts++;
17
+ }
18
+ console.log(`Worksheet ${a.id} at ${a.createdAt.toISOString()}: ${mcqs} MCQs, ${texts} Texts`);
19
+ }
20
+ }
21
+
22
+ summary().catch(console.error).finally(() => prisma.$disconnect());
package/mcq-test.cjs ADDED
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+
3
+ const worksheetModeSchema = z.enum(['practice', 'quiz']);
4
+ const worksheetDifficultyInputSchema = z.enum(['easy', 'medium', 'hard']);
5
+ const questionTypeSchema = z.enum([
6
+ 'MULTIPLE_CHOICE',
7
+ 'TEXT',
8
+ 'NUMERIC',
9
+ 'TRUE_FALSE',
10
+ 'MATCHING',
11
+ 'FILL_IN_THE_BLANK',
12
+ ]);
13
+
14
+
15
+ const worksheetPresetConfigSchema = z.object({
16
+ mode: worksheetModeSchema.default('practice'),
17
+ numQuestions: z.number().int().min(1).max(20).default(8),
18
+ difficulty: worksheetDifficultyInputSchema.default('medium'),
19
+ questionTypes: z.array(questionTypeSchema).optional(),
20
+ mcqRatio: z.number().min(0).max(1).optional(),
21
+ });
22
+
23
+ function test(mcqCount, numQuestions) {
24
+ const configOverride = {
25
+ questionTypes: ['MULTIPLE_CHOICE', 'TEXT'],
26
+ mcqRatio: mcqCount / Math.max(1, numQuestions),
27
+ };
28
+
29
+ const merged = {
30
+ ...worksheetPresetConfigSchema.parse({}),
31
+ ...configOverride,
32
+ };
33
+ console.log(`mcqCount: ${mcqCount}, numQuestions: ${numQuestions} -> mcqRatio: ${merged.mcqRatio}`);
34
+ }
35
+
36
+ test(4, 8);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goscribe/server",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,6 +15,10 @@
15
15
  "dev": "tsx watch src/server.ts",
16
16
  "build": "npx prisma generate && tsc -p .",
17
17
  "start": "node --experimental-specifier-resolution=node dist/server.js",
18
+ "test": "tsx --test src/lib/worksheet-generation.test.ts",
19
+ "test:activity": "tsx --test src/lib/activity_log_service.test.ts src/lib/activity_human_description.test.ts"
20
+ },
21
+ "prisma": {
18
22
  "seed": "node --experimental-specifier-resolution=node prisma/seed.mjs"
19
23
  },
20
24
  "author": "",
@@ -36,12 +40,14 @@
36
40
  "express": "^5.1.0",
37
41
  "helmet": "^8.1.0",
38
42
  "morgan": "^1.10.1",
43
+ "nodemailer": "^8.0.1",
39
44
  "openai": "^6.3.0",
40
45
  "prisma": "^6.14.0",
41
46
  "pusher": "^5.2.0",
42
47
  "pusher-js": "^8.4.0",
43
48
  "resend": "^6.9.2",
44
49
  "socket.io": "^4.8.1",
50
+ "stripe": "^20.4.1",
45
51
  "superjson": "^2.2.2",
46
52
  "uuid": "^13.0.0",
47
53
  "zod": "^4.1.1"
@@ -53,6 +59,7 @@
53
59
  "@types/express": "^5.0.3",
54
60
  "@types/morgan": "^1.9.10",
55
61
  "@types/node": "^24.3.0",
62
+ "@types/nodemailer": "^7.0.11",
56
63
  "ts-node": "^10.9.2",
57
64
  "ts-node-dev": "^2.0.0",
58
65
  "tsc-alias": "^1.8.16",
@@ -61,4 +68,4 @@
61
68
  "typescript": "^5.9.2",
62
69
  "typescript-transform-paths": "^3.5.5"
63
70
  }
64
- }
71
+ }