@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.
- package/dist/context.d.ts +1 -1
- package/dist/lib/auth.js +10 -6
- package/dist/routers/_app.d.ts +70 -74
- package/dist/routers/_app.js +2 -2
- package/dist/routers/auth.d.ts +12 -11
- package/dist/routers/auth.js +48 -21
- package/dist/routers/flashcards.d.ts +21 -46
- package/dist/routers/flashcards.js +25 -41
- package/dist/routers/worksheets.d.ts +35 -15
- package/dist/routers/worksheets.js +38 -33
- package/dist/routers/workspace.d.ts +1 -1
- package/dist/routers/workspace.js +13 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -0
- package/dist/trpc.d.ts +5 -5
- package/package.json +2 -1
- package/src/lib/auth.ts +1 -1
- package/src/routers/flashcards.ts +19 -43
- package/src/routers/worksheets.ts +13 -14
- package/src/routers/workspace.ts +13 -0
- package/dist/context.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/auth.d.ts.map +0 -1
- package/dist/lib/file.d.ts.map +0 -1
- package/dist/lib/prisma.d.ts.map +0 -1
- package/dist/lib/storage.d.ts.map +0 -1
- package/dist/routers/_app.d.ts.map +0 -1
- package/dist/routers/auth.d.ts.map +0 -1
- package/dist/routers/sample.js +0 -21
- package/dist/routers/workspace.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/trpc.d.ts.map +0 -1
- package/src/routers/studyguide.ts +0 -0
|
@@ -15,28 +15,27 @@ const Difficulty = {
|
|
|
15
15
|
|
|
16
16
|
export const worksheets = router({
|
|
17
17
|
// List all worksheet artifacts for a workspace
|
|
18
|
-
|
|
19
|
-
.input(z.object({ workspaceId: z.string()
|
|
18
|
+
list: authedProcedure
|
|
19
|
+
.input(z.object({ workspaceId: z.string() }))
|
|
20
20
|
.query(async ({ ctx, input }) => {
|
|
21
|
-
const
|
|
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()
|
|
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
|
-
|
|
57
|
-
.input(z.object({ worksheetId: z.string()
|
|
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()
|
|
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()
|
|
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()
|
|
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()
|
|
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 } },
|
package/src/routers/workspace.ts
CHANGED
|
@@ -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;
|
package/dist/context.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/lib/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,0HA0BnB,CAAA"}
|
package/dist/lib/file.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/lib/file.ts"],"names":[],"mappings":""}
|
package/dist/lib/prisma.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/routers/sample.js
DELETED
|
@@ -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"}
|
package/dist/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
|
package/dist/trpc.d.ts.map
DELETED
|
@@ -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
|