Skip to content

Commit b4b31e1

Browse files
committed
feat: migrate to Prisma 7
1 parent 1a957fd commit b4b31e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+64706
-179
lines changed

apps/dashboard/src/app/(internal)/audit-log/[id]/page.tsx

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,40 @@ export default function AuditLogDetailsPage() {
4343
// Fetches specific audit
4444
const { auditLog } = useAuditLogDetailsQuery()
4545

46-
const changed_fields =
47-
auditLog.rowData &&
48-
Object.entries(auditLog.rowData).map(([field, change], index) => {
49-
return (
50-
<Accordion.Item key={field} value={field}>
51-
<Accordion.Control>
52-
<strong>{field === "new" ? "Data lagt til" : field}</strong>
53-
</Accordion.Control>
54-
<Accordion.Panel>
55-
<div style={{ whiteSpace: "pre-wrap" }}>
56-
{change.old ? (
57-
<StringDiff // This component shows the string-difference
58-
oldValue={change.old ?? ""}
59-
newValue={change.new ?? ""}
60-
method={DiffMethod.Lines}
61-
styles={diffStyles}
62-
key={isDark ? "dark" : "light"}
63-
/>
64-
) : (
65-
// Prints all values if there is no existing "old" value
66-
Object.entries(change).map(([key, value]) => (
67-
<div key={key}>
68-
<strong>{key}:</strong> {String(value)}
69-
</div>
70-
))
71-
)}
72-
</div>
73-
</Accordion.Panel>
74-
</Accordion.Item>
75-
)
76-
})
77-
if (!auditLog.rowData) return null
46+
if (!auditLog.rowData) {
47+
return null
48+
}
49+
50+
const changed_fields = Object.entries(auditLog.rowData).map(([field, change], index) => {
51+
return (
52+
<Accordion.Item key={field} value={field}>
53+
<Accordion.Control>
54+
<strong>{field === "new" ? "Data lagt til" : field}</strong>
55+
</Accordion.Control>
56+
<Accordion.Panel>
57+
<div style={{ whiteSpace: "pre-wrap" }}>
58+
{change.old ? (
59+
<StringDiff // This component shows the string-difference
60+
oldValue={change.old ?? ""}
61+
newValue={change.new ?? ""}
62+
method={DiffMethod.Lines}
63+
styles={diffStyles}
64+
key={isDark ? "dark" : "light"}
65+
/>
66+
) : (
67+
// Prints all values if there is no existing "old" value
68+
Object.entries(change).map(([key, value]) => (
69+
<div key={key}>
70+
<strong>{key}:</strong> {String(value)}
71+
</div>
72+
))
73+
)}
74+
</div>
75+
</Accordion.Panel>
76+
</Accordion.Item>
77+
)
78+
})
79+
7880
return (
7981
<Stack>
8082
<Title order={2}>Hendelse</Title>

apps/rpc/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"@dotkomonline/utils": "workspace:*",
3939
"@fastify/cors": "^11.0.0",
4040
"@opentelemetry/api": "^1.9.0",
41-
"@prisma/client": "^6.8.2",
4241
"@sentry/node": "^9.24.0",
4342
"@trpc/server": "11.4.4",
4443
"auth0": "^4.23.1",

apps/rpc/src/modules/event/event-repository.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DBHandle } from "@dotkomonline/db"
1+
import type { DBHandle, Prisma } from "@dotkomonline/db"
22
import {
33
type AttendanceId,
44
type CompanyId,
@@ -16,7 +16,6 @@ import {
1616
type UserId,
1717
} from "@dotkomonline/types"
1818
import { getCurrentUTC } from "@dotkomonline/utils"
19-
import type { Prisma } from "@prisma/client"
2019
import invariant from "tiny-invariant"
2120
import { parseOrReport } from "../../invariant"
2221
import { type Pageable, pageQuery } from "../../query"

apps/rpc/src/modules/feedback-form/feedback-form-answer-repository.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DBHandle, FeedbackQuestionAnswer, FeedbackQuestionOption } from "@dotkomonline/db"
1+
import { type DBHandle, type FeedbackQuestionAnswer, type FeedbackQuestionOption, Prisma } from "@dotkomonline/db"
22
import {
33
type AttendeeId,
44
type FeedbackFormAnswer,
@@ -10,7 +10,6 @@ import {
1010
FeedbackQuestionAnswerSchema,
1111
type FeedbackQuestionAnswerWrite,
1212
} from "@dotkomonline/types"
13-
import { Prisma } from "@prisma/client"
1413
import { parseOrReport } from "../../invariant"
1514

1615
export interface FeedbackFormAnswerRepository {

apps/rpc/src/modules/group/__test__/group-service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomUUID } from "node:crypto"
22
import type { S3Client } from "@aws-sdk/client-s3"
3+
import { PrismaClient } from "@dotkomonline/db"
34
import type { Group } from "@dotkomonline/types"
4-
import { PrismaClient } from "@prisma/client"
55
import type { ManagementClient } from "auth0"
66
import { getFeideGroupsRepository } from "src/modules/feide/feide-groups-repository"
77
import { getMembershipService } from "src/modules/user/membership-service"

apps/rpc/src/modules/group/group-repository.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DBHandle } from "@dotkomonline/db"
1+
import type { DBHandle, GroupType } from "@dotkomonline/db"
22
import {
33
type Group,
44
type GroupId,
@@ -14,7 +14,6 @@ import {
1414
type GroupWrite,
1515
type UserId,
1616
} from "@dotkomonline/types"
17-
import type { GroupType } from "@prisma/client"
1817
import z from "zod"
1918
import { parseOrReport } from "../../invariant"
2019

apps/rpc/src/modules/mark/__test__/mark-service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { randomUUID } from "node:crypto"
2-
import { PrismaClient } from "@prisma/client"
2+
import { PrismaClient } from "@dotkomonline/db"
33
import { NotFoundError } from "../../../error"
44
import { getMarkRepository } from "../mark-repository"
55
import { getMarkService } from "../mark-service"

apps/rpc/src/modules/task/task-executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { clearInterval, type setInterval } from "node:timers"
2-
import type { DBClient, PrismaClient } from "@dotkomonline/db"
2+
import type { DBClient, Prisma, PrismaClient } from "@dotkomonline/db"
33
import { getLogger } from "@dotkomonline/logger"
44
import type { Task } from "@dotkomonline/types"
55
import { getCurrentUTC } from "@dotkomonline/utils"
@@ -60,7 +60,7 @@ export function getLocalTaskExecutor(
6060
// leave the system in a tainted state, but that's a less severe bug than leaving the database in a tainted state.
6161
await client.$transaction(async (handle) => {
6262
const definition = getTaskDefinition(task.type)
63-
const payload = taskService.parse(definition, task.payload)
63+
const payload = taskService.parse(definition, task.payload as Prisma.JsonValue)
6464

6565
switch (task.type) {
6666
case tasks.RESERVE_ATTENDEE.type:

apps/rpc/src/modules/task/task-repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DBHandle, TaskStatus } from "@dotkomonline/db"
2+
import { Prisma } from "@dotkomonline/db"
23
import {
34
type AttendanceId,
45
type AttendeeId,
@@ -9,7 +10,6 @@ import {
910
type TaskType,
1011
type TaskWrite,
1112
} from "@dotkomonline/types"
12-
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"
1313
import { parseOrReport } from "../../invariant"
1414
import { tasks } from "./task-definition"
1515

@@ -57,7 +57,7 @@ export function getTaskRepository(): TaskRepository {
5757

5858
return parseOrReport(TaskSchema, task)
5959
} catch (e) {
60-
if (e instanceof PrismaClientKnownRequestError) {
60+
if (e instanceof Prisma.PrismaClientKnownRequestError) {
6161
// "An operation failed because it depends on one or more records that were required but not found. {cause}"
6262
if (e.code === "P2025") {
6363
return null

apps/rpc/src/modules/task/task-scheduling-service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { SchedulerClient } from "@aws-sdk/client-scheduler"
22
import type { TZDate } from "@date-fns/tz"
3-
import type { DBHandle } from "@dotkomonline/db"
3+
import type { DBHandle, Prisma } from "@dotkomonline/db"
44
import { getLogger } from "@dotkomonline/logger"
55
import type { AttendanceId, AttendeeId, FeedbackFormId, RecurringTaskId, Task, TaskId } from "@dotkomonline/types"
6-
import type { JsonValue } from "@prisma/client/runtime/library"
76
import { UnimplementedError } from "../../error"
87
import type { InferTaskData, TaskDefinition } from "./task-definition"
98
import type { TaskRepository } from "./task-repository"
@@ -42,7 +41,7 @@ export function getLocalTaskSchedulingService(
4241
return {
4342
async scheduleAt(handle, task, data, executeAt, recurringTaskId) {
4443
logger.info("Scheduling task of TaskKind=%s with data: %o", task, data)
45-
const payload = taskService.parse(task, data) as JsonValue
44+
const payload = taskService.parse(task, data) as Prisma.JsonValue
4645

4746
const scheduledTask = await taskRepository.create(handle, task.type, {
4847
payload,

0 commit comments

Comments
 (0)