@goscribe/server 1.0.5 → 1.0.7

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.
@@ -0,0 +1,127 @@
1
+ import { z } from 'zod';
2
+ import { TRPCError } from '@trpc/server';
3
+ import { router, authedProcedure } from '../trpc.js';
4
+ // Prisma enum values mapped manually to avoid type import issues in ESM
5
+ const ArtifactType = {
6
+ STUDY_GUIDE: 'STUDY_GUIDE',
7
+ FLASHCARD_SET: 'FLASHCARD_SET',
8
+ WORKSHEET: 'WORKSHEET',
9
+ MEETING_SUMMARY: 'MEETING_SUMMARY',
10
+ PODCAST_EPISODE: 'PODCAST_EPISODE',
11
+ };
12
+ export const flashcards = router({
13
+ listSets: authedProcedure
14
+ .input(z.object({ workspaceId: z.string().uuid() }))
15
+ .query(async ({ ctx, input }) => {
16
+ const workspace = await ctx.db.workspace.findFirst({
17
+ where: { id: input.workspaceId, ownerId: ctx.session.user.id },
18
+ });
19
+ if (!workspace)
20
+ throw new TRPCError({ code: 'NOT_FOUND' });
21
+ return ctx.db.artifact.findMany({
22
+ where: { workspaceId: input.workspaceId, type: ArtifactType.FLASHCARD_SET },
23
+ orderBy: { updatedAt: 'desc' },
24
+ });
25
+ }),
26
+ createSet: authedProcedure
27
+ .input(z.object({ workspaceId: z.string().uuid(), title: z.string().min(1).max(120) }))
28
+ .mutation(async ({ ctx, input }) => {
29
+ const workspace = await ctx.db.workspace.findFirst({
30
+ where: { id: input.workspaceId, ownerId: ctx.session.user.id },
31
+ });
32
+ if (!workspace)
33
+ throw new TRPCError({ code: 'NOT_FOUND' });
34
+ return ctx.db.artifact.create({
35
+ data: {
36
+ workspaceId: input.workspaceId,
37
+ type: ArtifactType.FLASHCARD_SET,
38
+ title: input.title,
39
+ createdById: ctx.session.user.id,
40
+ },
41
+ });
42
+ }),
43
+ getSet: authedProcedure
44
+ .input(z.object({ setId: z.string().uuid() }))
45
+ .query(async ({ ctx, input }) => {
46
+ const set = await ctx.db.artifact.findFirst({
47
+ where: {
48
+ id: input.setId,
49
+ type: ArtifactType.FLASHCARD_SET,
50
+ workspace: { ownerId: ctx.session.user.id },
51
+ },
52
+ include: { flashcards: true },
53
+ });
54
+ if (!set)
55
+ throw new TRPCError({ code: 'NOT_FOUND' });
56
+ return set;
57
+ }),
58
+ createCard: authedProcedure
59
+ .input(z.object({
60
+ setId: z.string().uuid(),
61
+ front: z.string().min(1),
62
+ back: z.string().min(1),
63
+ tags: z.array(z.string()).optional(),
64
+ order: z.number().int().optional(),
65
+ }))
66
+ .mutation(async ({ ctx, input }) => {
67
+ const set = await ctx.db.artifact.findFirst({
68
+ where: { id: input.setId, type: ArtifactType.FLASHCARD_SET, workspace: { ownerId: ctx.session.user.id } },
69
+ });
70
+ if (!set)
71
+ throw new TRPCError({ code: 'NOT_FOUND' });
72
+ return ctx.db.flashcard.create({
73
+ data: {
74
+ artifactId: input.setId,
75
+ front: input.front,
76
+ back: input.back,
77
+ tags: input.tags ?? [],
78
+ order: input.order ?? 0,
79
+ },
80
+ });
81
+ }),
82
+ updateCard: authedProcedure
83
+ .input(z.object({
84
+ cardId: z.string().uuid(),
85
+ front: z.string().optional(),
86
+ back: z.string().optional(),
87
+ tags: z.array(z.string()).optional(),
88
+ order: z.number().int().optional(),
89
+ }))
90
+ .mutation(async ({ ctx, input }) => {
91
+ const card = await ctx.db.flashcard.findFirst({
92
+ where: { id: input.cardId, artifact: { type: ArtifactType.FLASHCARD_SET, workspace: { ownerId: ctx.session.user.id } } },
93
+ });
94
+ if (!card)
95
+ throw new TRPCError({ code: 'NOT_FOUND' });
96
+ return ctx.db.flashcard.update({
97
+ where: { id: input.cardId },
98
+ data: {
99
+ front: input.front ?? card.front,
100
+ back: input.back ?? card.back,
101
+ tags: input.tags ?? card.tags,
102
+ order: input.order ?? card.order,
103
+ },
104
+ });
105
+ }),
106
+ deleteCard: authedProcedure
107
+ .input(z.object({ cardId: z.string().uuid() }))
108
+ .mutation(async ({ ctx, input }) => {
109
+ const card = await ctx.db.flashcard.findFirst({
110
+ where: { id: input.cardId, artifact: { workspace: { ownerId: ctx.session.user.id } } },
111
+ });
112
+ if (!card)
113
+ throw new TRPCError({ code: 'NOT_FOUND' });
114
+ await ctx.db.flashcard.delete({ where: { id: input.cardId } });
115
+ return true;
116
+ }),
117
+ deleteSet: authedProcedure
118
+ .input(z.object({ setId: z.string().uuid() }))
119
+ .mutation(async ({ ctx, input }) => {
120
+ const deleted = await ctx.db.artifact.deleteMany({
121
+ where: { id: input.setId, type: ArtifactType.FLASHCARD_SET, workspace: { ownerId: ctx.session.user.id } },
122
+ });
123
+ if (deleted.count === 0)
124
+ throw new TRPCError({ code: 'NOT_FOUND' });
125
+ return true;
126
+ }),
127
+ });
@@ -0,0 +1,21 @@
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
+ });
@@ -0,0 +1,129 @@
1
+ export declare const worksheets: import("@trpc/server").TRPCBuiltRouter<{
2
+ ctx: {
3
+ db: import("@prisma/client").PrismaClient<import("@prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>;
4
+ session: any;
5
+ req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
6
+ res: import("express").Response<any, Record<string, any>>;
7
+ cookies: any;
8
+ };
9
+ meta: object;
10
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
11
+ transformer: true;
12
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
13
+ listSets: import("@trpc/server").TRPCQueryProcedure<{
14
+ input: {
15
+ workspaceId: string;
16
+ };
17
+ output: {
18
+ id: string;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ title: string;
22
+ workspaceId: string;
23
+ type: import("@prisma/client").$Enums.ArtifactType;
24
+ isArchived: boolean;
25
+ createdById: string | null;
26
+ }[];
27
+ meta: object;
28
+ }>;
29
+ createSet: import("@trpc/server").TRPCMutationProcedure<{
30
+ input: {
31
+ workspaceId: string;
32
+ title: string;
33
+ };
34
+ output: {
35
+ id: string;
36
+ createdAt: Date;
37
+ updatedAt: Date;
38
+ title: string;
39
+ workspaceId: string;
40
+ type: import("@prisma/client").$Enums.ArtifactType;
41
+ isArchived: boolean;
42
+ createdById: string | null;
43
+ };
44
+ meta: object;
45
+ }>;
46
+ getSet: import("@trpc/server").TRPCQueryProcedure<{
47
+ input: {
48
+ setId: string;
49
+ };
50
+ output: {
51
+ questions: {
52
+ meta: import("@prisma/client/runtime/library").JsonValue | null;
53
+ id: string;
54
+ createdAt: Date;
55
+ artifactId: string;
56
+ order: number;
57
+ prompt: string;
58
+ answer: string | null;
59
+ difficulty: import("@prisma/client").$Enums.Difficulty;
60
+ }[];
61
+ } & {
62
+ id: string;
63
+ createdAt: Date;
64
+ updatedAt: Date;
65
+ title: string;
66
+ workspaceId: string;
67
+ type: import("@prisma/client").$Enums.ArtifactType;
68
+ isArchived: boolean;
69
+ createdById: string | null;
70
+ };
71
+ meta: object;
72
+ }>;
73
+ createQuestion: import("@trpc/server").TRPCMutationProcedure<{
74
+ input: {
75
+ setId: string;
76
+ prompt: string;
77
+ answer?: string | undefined;
78
+ difficulty?: "EASY" | "MEDIUM" | "HARD" | undefined;
79
+ order?: number | undefined;
80
+ meta?: Record<string, unknown> | undefined;
81
+ };
82
+ output: {
83
+ meta: import("@prisma/client/runtime/library").JsonValue | null;
84
+ id: string;
85
+ createdAt: Date;
86
+ artifactId: string;
87
+ order: number;
88
+ prompt: string;
89
+ answer: string | null;
90
+ difficulty: import("@prisma/client").$Enums.Difficulty;
91
+ };
92
+ meta: object;
93
+ }>;
94
+ updateQuestion: import("@trpc/server").TRPCMutationProcedure<{
95
+ input: {
96
+ questionId: string;
97
+ prompt?: string | undefined;
98
+ answer?: string | undefined;
99
+ difficulty?: "EASY" | "MEDIUM" | "HARD" | undefined;
100
+ order?: number | undefined;
101
+ meta?: Record<string, unknown> | undefined;
102
+ };
103
+ output: {
104
+ meta: import("@prisma/client/runtime/library").JsonValue | null;
105
+ id: string;
106
+ createdAt: Date;
107
+ artifactId: string;
108
+ order: number;
109
+ prompt: string;
110
+ answer: string | null;
111
+ difficulty: import("@prisma/client").$Enums.Difficulty;
112
+ };
113
+ meta: object;
114
+ }>;
115
+ deleteQuestion: import("@trpc/server").TRPCMutationProcedure<{
116
+ input: {
117
+ questionId: string;
118
+ };
119
+ output: boolean;
120
+ meta: object;
121
+ }>;
122
+ deleteSet: import("@trpc/server").TRPCMutationProcedure<{
123
+ input: {
124
+ setId: string;
125
+ };
126
+ output: boolean;
127
+ meta: object;
128
+ }>;
129
+ }>>;
@@ -0,0 +1,139 @@
1
+ import { z } from 'zod';
2
+ import { TRPCError } from '@trpc/server';
3
+ import { router, authedProcedure } from '../trpc.js';
4
+ // Avoid importing Prisma enums directly; mirror values as string literals
5
+ const ArtifactType = {
6
+ WORKSHEET: 'WORKSHEET',
7
+ };
8
+ const Difficulty = {
9
+ EASY: 'EASY',
10
+ MEDIUM: 'MEDIUM',
11
+ HARD: 'HARD',
12
+ };
13
+ export const worksheets = router({
14
+ // List all worksheet artifacts for a workspace
15
+ listSets: authedProcedure
16
+ .input(z.object({ workspaceId: z.string().uuid() }))
17
+ .query(async ({ ctx, input }) => {
18
+ const workspace = await ctx.db.workspace.findFirst({
19
+ where: { id: input.workspaceId, ownerId: ctx.session.user.id },
20
+ });
21
+ if (!workspace)
22
+ throw new TRPCError({ code: 'NOT_FOUND' });
23
+ return ctx.db.artifact.findMany({
24
+ where: { workspaceId: input.workspaceId, type: ArtifactType.WORKSHEET },
25
+ orderBy: { updatedAt: 'desc' },
26
+ });
27
+ }),
28
+ // Create a worksheet set
29
+ createSet: authedProcedure
30
+ .input(z.object({ workspaceId: z.string().uuid(), title: z.string().min(1).max(120) }))
31
+ .mutation(async ({ ctx, input }) => {
32
+ const workspace = await ctx.db.workspace.findFirst({
33
+ where: { id: input.workspaceId, ownerId: ctx.session.user.id },
34
+ });
35
+ if (!workspace)
36
+ throw new TRPCError({ code: 'NOT_FOUND' });
37
+ return ctx.db.artifact.create({
38
+ data: {
39
+ workspaceId: input.workspaceId,
40
+ type: ArtifactType.WORKSHEET,
41
+ title: input.title,
42
+ createdById: ctx.session.user.id,
43
+ },
44
+ });
45
+ }),
46
+ // Get a worksheet with its questions
47
+ getSet: authedProcedure
48
+ .input(z.object({ setId: z.string().uuid() }))
49
+ .query(async ({ ctx, input }) => {
50
+ const set = await ctx.db.artifact.findFirst({
51
+ where: {
52
+ id: input.setId,
53
+ type: ArtifactType.WORKSHEET,
54
+ workspace: { ownerId: ctx.session.user.id },
55
+ },
56
+ include: { questions: true },
57
+ });
58
+ if (!set)
59
+ throw new TRPCError({ code: 'NOT_FOUND' });
60
+ return set;
61
+ }),
62
+ // Add a question to a worksheet
63
+ createQuestion: authedProcedure
64
+ .input(z.object({
65
+ setId: z.string().uuid(),
66
+ prompt: z.string().min(1),
67
+ answer: z.string().optional(),
68
+ difficulty: z.enum(['EASY', 'MEDIUM', 'HARD']).optional(),
69
+ order: z.number().int().optional(),
70
+ meta: z.record(z.string(), z.unknown()).optional(),
71
+ }))
72
+ .mutation(async ({ ctx, input }) => {
73
+ const set = await ctx.db.artifact.findFirst({
74
+ where: { id: input.setId, type: ArtifactType.WORKSHEET, workspace: { ownerId: ctx.session.user.id } },
75
+ });
76
+ if (!set)
77
+ throw new TRPCError({ code: 'NOT_FOUND' });
78
+ return ctx.db.worksheetQuestion.create({
79
+ data: {
80
+ artifactId: input.setId,
81
+ prompt: input.prompt,
82
+ answer: input.answer,
83
+ difficulty: (input.difficulty ?? Difficulty.MEDIUM),
84
+ order: input.order ?? 0,
85
+ meta: input.meta,
86
+ },
87
+ });
88
+ }),
89
+ // Update a question
90
+ updateQuestion: authedProcedure
91
+ .input(z.object({
92
+ questionId: z.string().uuid(),
93
+ prompt: z.string().optional(),
94
+ answer: z.string().optional(),
95
+ difficulty: z.enum(['EASY', 'MEDIUM', 'HARD']).optional(),
96
+ order: z.number().int().optional(),
97
+ meta: z.record(z.string(), z.unknown()).optional(),
98
+ }))
99
+ .mutation(async ({ ctx, input }) => {
100
+ const q = await ctx.db.worksheetQuestion.findFirst({
101
+ where: { id: input.questionId, artifact: { type: ArtifactType.WORKSHEET, workspace: { ownerId: ctx.session.user.id } } },
102
+ });
103
+ if (!q)
104
+ throw new TRPCError({ code: 'NOT_FOUND' });
105
+ return ctx.db.worksheetQuestion.update({
106
+ where: { id: input.questionId },
107
+ data: {
108
+ prompt: input.prompt ?? q.prompt,
109
+ answer: input.answer ?? q.answer,
110
+ difficulty: (input.difficulty ?? q.difficulty),
111
+ order: input.order ?? q.order,
112
+ meta: (input.meta ?? q.meta),
113
+ },
114
+ });
115
+ }),
116
+ // Delete a question
117
+ deleteQuestion: authedProcedure
118
+ .input(z.object({ questionId: z.string().uuid() }))
119
+ .mutation(async ({ ctx, input }) => {
120
+ const q = await ctx.db.worksheetQuestion.findFirst({
121
+ where: { id: input.questionId, artifact: { workspace: { ownerId: ctx.session.user.id } } },
122
+ });
123
+ if (!q)
124
+ throw new TRPCError({ code: 'NOT_FOUND' });
125
+ await ctx.db.worksheetQuestion.delete({ where: { id: input.questionId } });
126
+ return true;
127
+ }),
128
+ // Delete a worksheet set and its questions
129
+ deleteSet: authedProcedure
130
+ .input(z.object({ setId: z.string().uuid() }))
131
+ .mutation(async ({ ctx, input }) => {
132
+ const deleted = await ctx.db.artifact.deleteMany({
133
+ where: { id: input.setId, type: ArtifactType.WORKSHEET, workspace: { ownerId: ctx.session.user.id } },
134
+ });
135
+ if (deleted.count === 0)
136
+ throw new TRPCError({ code: 'NOT_FOUND' });
137
+ return true;
138
+ }),
139
+ });
@@ -4,7 +4,7 @@ export declare const workspace: import("@trpc/server").TRPCBuiltRouter<{
4
4
  session: any;
5
5
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
6
6
  res: import("express").Response<any, Record<string, any>>;
7
- cookies: Record<string, string | undefined>;
7
+ cookies: any;
8
8
  };
9
9
  meta: object;
10
10
  errorShape: import("@trpc/server").TRPCDefaultErrorShape;
@@ -51,7 +51,7 @@ export declare const workspace: import("@trpc/server").TRPCBuiltRouter<{
51
51
  title: string;
52
52
  description: string | null;
53
53
  folderId: string | null;
54
- } | null;
54
+ };
55
55
  meta: object;
56
56
  }>;
57
57
  update: import("@trpc/server").TRPCMutationProcedure<{
@@ -98,7 +98,7 @@ export declare const workspace: import("@trpc/server").TRPCBuiltRouter<{
98
98
  fileId: string[];
99
99
  id: string;
100
100
  };
101
- output: import("@prisma/client").Prisma.BatchPayload;
101
+ output: boolean;
102
102
  meta: object;
103
103
  }>;
104
104
  }>>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/routers/workspace.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuJpB,CAAC"}
@@ -1,14 +1,16 @@
1
1
  import { z } from 'zod';
2
+ import { TRPCError } from '@trpc/server';
2
3
  import { router, authedProcedure } from '../trpc.js';
3
4
  import { bucket } from '../lib/storage.js';
4
5
  export const workspace = router({
5
- // Mutation with Zod input
6
+ // List current user's workspaces
6
7
  list: authedProcedure
7
- .query(async ({ ctx, input }) => {
8
+ .query(async ({ ctx }) => {
8
9
  const workspaces = await ctx.db.workspace.findMany({
9
10
  where: {
10
- ownerId: ctx.session?.user.id,
11
+ ownerId: ctx.session.user.id,
11
12
  },
13
+ orderBy: { updatedAt: 'desc' },
12
14
  });
13
15
  return workspaces;
14
16
  }),
@@ -17,25 +19,27 @@ export const workspace = router({
17
19
  name: z.string().min(1).max(100),
18
20
  description: z.string().max(500).optional(),
19
21
  }))
20
- .mutation(({ ctx, input }) => {
21
- return ctx.db.workspace.create({
22
+ .mutation(async ({ ctx, input }) => {
23
+ const ws = await ctx.db.workspace.create({
22
24
  data: {
23
25
  title: input.name,
24
26
  description: input.description,
25
- ownerId: ctx.session?.user.id,
27
+ ownerId: ctx.session.user.id,
26
28
  },
27
29
  });
30
+ return ws;
28
31
  }),
29
32
  get: authedProcedure
30
33
  .input(z.object({
31
34
  id: z.string().uuid(),
32
35
  }))
33
- .query(({ ctx, input }) => {
34
- return ctx.db.workspace.findUnique({
35
- where: {
36
- id: input.id,
37
- },
36
+ .query(async ({ ctx, input }) => {
37
+ const ws = await ctx.db.workspace.findFirst({
38
+ where: { id: input.id, ownerId: ctx.session.user.id },
38
39
  });
40
+ if (!ws)
41
+ throw new TRPCError({ code: 'NOT_FOUND' });
42
+ return ws;
39
43
  }),
40
44
  update: authedProcedure
41
45
  .input(z.object({
@@ -43,27 +47,31 @@ export const workspace = router({
43
47
  name: z.string().min(1).max(100).optional(),
44
48
  description: z.string().max(500).optional(),
45
49
  }))
46
- .mutation(({ ctx, input }) => {
47
- return ctx.db.workspace.update({
48
- where: {
49
- id: input.id,
50
- },
50
+ .mutation(async ({ ctx, input }) => {
51
+ const existed = await ctx.db.workspace.findFirst({
52
+ where: { id: input.id, ownerId: ctx.session.user.id },
53
+ });
54
+ if (!existed)
55
+ throw new TRPCError({ code: 'NOT_FOUND' });
56
+ const updated = await ctx.db.workspace.update({
57
+ where: { id: input.id },
51
58
  data: {
52
- title: input.name,
59
+ title: input.name ?? existed.title,
53
60
  description: input.description,
54
61
  },
55
62
  });
63
+ return updated;
56
64
  }),
57
65
  delete: authedProcedure
58
66
  .input(z.object({
59
67
  id: z.string().uuid(),
60
68
  }))
61
- .mutation(({ ctx, input }) => {
62
- ctx.db.workspace.delete({
63
- where: {
64
- id: input.id,
65
- },
69
+ .mutation(async ({ ctx, input }) => {
70
+ const deleted = await ctx.db.workspace.deleteMany({
71
+ where: { id: input.id, ownerId: ctx.session.user.id },
66
72
  });
73
+ if (deleted.count === 0)
74
+ throw new TRPCError({ code: 'NOT_FOUND' });
67
75
  return true;
68
76
  }),
69
77
  uploadFiles: authedProcedure
@@ -76,6 +84,10 @@ export const workspace = router({
76
84
  })),
77
85
  }))
78
86
  .mutation(async ({ ctx, input }) => {
87
+ // ensure workspace belongs to user
88
+ const ws = await ctx.db.workspace.findFirst({ where: { id: input.id, ownerId: ctx.session.user.id } });
89
+ if (!ws)
90
+ throw new TRPCError({ code: 'NOT_FOUND' });
79
91
  const results = [];
80
92
  for (const file of input.files) {
81
93
  // 1. Insert into DB
@@ -116,29 +128,31 @@ export const workspace = router({
116
128
  fileId: z.array(z.string().uuid()),
117
129
  id: z.string().uuid(),
118
130
  }))
119
- .mutation(({ ctx, input }) => {
120
- const files = ctx.db.fileAsset.findMany({
131
+ .mutation(async ({ ctx, input }) => {
132
+ // ensure files are in the user's workspace
133
+ const files = await ctx.db.fileAsset.findMany({
121
134
  where: {
122
135
  id: { in: input.fileId },
123
136
  workspaceId: input.id,
137
+ userId: ctx.session.user.id,
124
138
  },
125
139
  });
126
- // Delete from GCS
127
- files.then((fileRecords) => {
128
- fileRecords.forEach((file) => {
129
- if (file.bucket && file.objectKey) {
130
- const gcsFile = bucket.file(file.objectKey);
131
- gcsFile.delete({ ignoreNotFound: true }).catch((err) => {
132
- console.error(`Error deleting file ${file.objectKey} from bucket ${file.bucket}:`, err);
133
- });
134
- }
135
- });
136
- });
137
- return ctx.db.fileAsset.deleteMany({
140
+ // Delete from GCS (best-effort)
141
+ for (const file of files) {
142
+ if (file.bucket && file.objectKey) {
143
+ const gcsFile = bucket.file(file.objectKey);
144
+ gcsFile.delete({ ignoreNotFound: true }).catch((err) => {
145
+ console.error(`Error deleting file ${file.objectKey} from bucket ${file.bucket}:`, err);
146
+ });
147
+ }
148
+ }
149
+ await ctx.db.fileAsset.deleteMany({
138
150
  where: {
139
151
  id: { in: input.fileId },
140
152
  workspaceId: input.id,
153
+ userId: ctx.session.user.id,
141
154
  },
142
155
  });
156
+ return true;
143
157
  }),
144
158
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
package/dist/trpc.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare const router: import("@trpc/server").TRPCRouterBuilder<{
4
4
  session: any;
5
5
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
6
6
  res: import("express").Response<any, Record<string, any>>;
7
- cookies: Record<string, string | undefined>;
7
+ cookies: any;
8
8
  };
9
9
  meta: object;
10
10
  errorShape: import("@trpc/server").TRPCDefaultErrorShape;
@@ -15,20 +15,20 @@ export declare const middleware: <$ContextOverrides>(fn: import("@trpc/server").
15
15
  session: any;
16
16
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
17
17
  res: import("express").Response<any, Record<string, any>>;
18
- cookies: Record<string, string | undefined>;
18
+ cookies: any;
19
19
  }, object, object, $ContextOverrides, unknown>) => import("@trpc/server").TRPCMiddlewareBuilder<{
20
20
  db: import("@prisma/client").PrismaClient<import("@prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>;
21
21
  session: any;
22
22
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
23
23
  res: import("express").Response<any, Record<string, any>>;
24
- cookies: Record<string, string | undefined>;
24
+ cookies: any;
25
25
  }, object, $ContextOverrides, unknown>;
26
26
  export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<{
27
27
  db: import("@prisma/client").PrismaClient<import("@prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client/runtime/library").DefaultArgs>;
28
28
  session: any;
29
29
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
30
30
  res: import("express").Response<any, Record<string, any>>;
31
- cookies: Record<string, string | undefined>;
31
+ cookies: any;
32
32
  }, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
33
33
  /** Exported authed procedure */
34
34
  export declare const authedProcedure: import("@trpc/server").TRPCProcedureBuilder<{
@@ -36,7 +36,7 @@ export declare const authedProcedure: import("@trpc/server").TRPCProcedureBuilde
36
36
  session: any;
37
37
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
38
38
  res: import("express").Response<any, Record<string, any>>;
39
- cookies: Record<string, string | undefined>;
39
+ cookies: any;
40
40
  }, object, {
41
41
  session: any;
42
42
  }, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
@@ -0,0 +1 @@
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"}