@goscribe/server 1.0.7 → 1.0.8

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.
@@ -15,28 +15,27 @@ const Difficulty = {
15
15
 
16
16
  export const worksheets = router({
17
17
  // List all worksheet artifacts for a workspace
18
- listSets: authedProcedure
19
- .input(z.object({ workspaceId: z.string().uuid() }))
18
+ list: authedProcedure
19
+ .input(z.object({ workspaceId: z.string() }))
20
20
  .query(async ({ ctx, input }) => {
21
- const workspace = await ctx.db.workspace.findFirst({
22
- where: { id: input.workspaceId, ownerId: ctx.session.user.id },
23
- });
24
- if (!workspace) throw new TRPCError({ code: 'NOT_FOUND' });
25
- return ctx.db.artifact.findMany({
21
+ const worksheets = await ctx.db.artifact.findMany({
26
22
  where: { workspaceId: input.workspaceId, type: ArtifactType.WORKSHEET },
27
23
  include: {
28
24
  versions: {
29
25
  orderBy: { version: 'desc' },
30
26
  take: 1, // Get only the latest version
31
27
  },
28
+ questions: true,
32
29
  },
33
30
  orderBy: { updatedAt: 'desc' },
34
31
  });
32
+ if (!worksheets) throw new TRPCError({ code: 'NOT_FOUND' });
33
+ return worksheets;
35
34
  }),
36
35
 
37
36
  // Create a worksheet set
38
37
  createWorksheet: authedProcedure
39
- .input(z.object({ workspaceId: z.string().uuid(), title: z.string().min(1).max(120) }))
38
+ .input(z.object({ workspaceId: z.string(), title: z.string().min(1).max(120) }))
40
39
  .mutation(async ({ ctx, input }) => {
41
40
  const workspace = await ctx.db.workspace.findFirst({
42
41
  where: { id: input.workspaceId, ownerId: ctx.session.user.id },
@@ -53,8 +52,8 @@ export const worksheets = router({
53
52
  }),
54
53
 
55
54
  // Get a worksheet with its questions
56
- getWorksheet: authedProcedure
57
- .input(z.object({ worksheetId: z.string().uuid() }))
55
+ get: authedProcedure
56
+ .input(z.object({ worksheetId: z.string() }))
58
57
  .query(async ({ ctx, input }) => {
59
58
  const worksheet = await ctx.db.artifact.findFirst({
60
59
  where: {
@@ -71,7 +70,7 @@ export const worksheets = router({
71
70
  // Add a question to a worksheet
72
71
  createWorksheetQuestion: authedProcedure
73
72
  .input(z.object({
74
- worksheetId: z.string().uuid(),
73
+ worksheetId: z.string(),
75
74
  prompt: z.string().min(1),
76
75
  answer: z.string().optional(),
77
76
  difficulty: z.enum(['EASY', 'MEDIUM', 'HARD']).optional(),
@@ -98,7 +97,7 @@ export const worksheets = router({
98
97
  // Update a question
99
98
  updateWorksheetQuestion: authedProcedure
100
99
  .input(z.object({
101
- worksheetQuestionId: z.string().uuid(),
100
+ worksheetQuestionId: z.string(),
102
101
  prompt: z.string().optional(),
103
102
  answer: z.string().optional(),
104
103
  difficulty: z.enum(['EASY', 'MEDIUM', 'HARD']).optional(),
@@ -124,7 +123,7 @@ export const worksheets = router({
124
123
 
125
124
  // Delete a question
126
125
  deleteWorksheetQuestion: authedProcedure
127
- .input(z.object({ worksheetQuestionId: z.string().uuid() }))
126
+ .input(z.object({ worksheetQuestionId: z.string() }))
128
127
  .mutation(async ({ ctx, input }) => {
129
128
  const q = await ctx.db.worksheetQuestion.findFirst({
130
129
  where: { id: input.worksheetQuestionId, artifact: { workspace: { ownerId: ctx.session.user.id } } },
@@ -136,7 +135,7 @@ export const worksheets = router({
136
135
 
137
136
  // Delete a worksheet set and its questions
138
137
  deleteWorksheet: authedProcedure
139
- .input(z.object({ worksheetId: z.string().uuid() }))
138
+ .input(z.object({ worksheetId: z.string() }))
140
139
  .mutation(async ({ ctx, input }) => {
141
140
  const deleted = await ctx.db.artifact.deleteMany({
142
141
  where: { id: input.worksheetId, type: ArtifactType.WORKSHEET, workspace: { ownerId: ctx.session.user.id } },
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { TRPCError } from '@trpc/server';
3
3
  import { router, publicProcedure, authedProcedure } from '../trpc.js';
4
4
  import { bucket } from '../lib/storage.js';
5
+ import { ArtifactType } from '@prisma/client';
5
6
 
6
7
  export const workspace = router({
7
8
  // List current user's workspaces
@@ -27,6 +28,18 @@ export const workspace = router({
27
28
  title: input.name,
28
29
  description: input.description,
29
30
  ownerId: ctx.session.user.id,
31
+ artifacts: {
32
+ create: {
33
+ type: ArtifactType.FLASHCARD_SET,
34
+ title: "New Flashcard Set",
35
+ },
36
+ createMany: {
37
+ data: [
38
+ { type: ArtifactType.WORKSHEET, title: "Worksheet 1" },
39
+ { type: ArtifactType.WORKSHEET, title: "Worksheet 2" },
40
+ ],
41
+ },
42
+ },
30
43
  },
31
44
  });
32
45
  return ws;
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAGjF,wBAAsB,aAAa,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,2BAA2B;;;;;GAI5E;AAED,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,0HA0BnB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/lib/file.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/lib/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,eAAO,MAAM,MAAM,gIAIf,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/lib/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,eAAO,MAAM,OAAO,SAMlB,CAAC;AAEH,eAAO,MAAM,MAAM,wCAA0C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_app.d.ts","sourceRoot":"","sources":["../../src/routers/_app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAKrE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGpB,CAAC;AAGH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC;AACzC,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACxD,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routers/auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;GA4Bf,CAAC"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sampleRouter = void 0;
4
- const zod_1 = require("zod");
5
- const trpc_1 = require("../trpc");
6
- exports.sampleRouter = (0, trpc_1.router)({
7
- // GET-like: query without input
8
- hello: trpc_1.publicProcedure.query(() => {
9
- return { message: 'Hello from tRPC + Express 👋' };
10
- }),
11
- // Mutation with Zod input
12
- echo: trpc_1.publicProcedure
13
- .input(zod_1.z.object({ text: zod_1.z.string().min(1) }))
14
- .mutation(({ input }) => {
15
- return { echoed: input.text };
16
- }),
17
- // Authed query
18
- me: trpc_1.authedProcedure.query(({ ctx }) => {
19
- return { userId: ctx.user.id, role: ctx.user.role };
20
- }),
21
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/routers/workspace.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuJpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../src/trpc.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM;;;;;;;;;;EAAW,CAAC;AAC/B,eAAO,MAAM,UAAU;;;;;;;;;;sCAAe,CAAC;AACvC,eAAO,MAAM,eAAe;;;;;yLAAc,CAAC;AAsB3C,gCAAgC;AAChC,eAAO,MAAM,eAAe;;;;;;;;;;yKAAgC,CAAC"}
File without changes