Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions apps/dashboard/src/app/(internal)/audit-log/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,40 @@ export default function AuditLogDetailsPage() {
// Fetches specific audit
const { auditLog } = useAuditLogDetailsQuery()

const changed_fields =
auditLog.rowData &&
Object.entries(auditLog.rowData).map(([field, change], _index) => {
return (
<Accordion.Item key={field} value={field}>
<Accordion.Control>
<strong>{field === "new" ? "Data lagt til" : field}</strong>
</Accordion.Control>
<Accordion.Panel>
<div style={{ whiteSpace: "pre-wrap" }}>
{change.old ? (
<StringDiff // This component shows the string-difference
oldValue={change.old ?? ""}
newValue={change.new ?? ""}
method={DiffMethod.Lines}
styles={diffStyles}
key={isDark ? "dark" : "light"}
/>
) : (
// Prints all values if there is no existing "old" value
Object.entries(change).map(([key, value]) => (
<div key={key}>
<strong>{key}:</strong> {String(value)}
</div>
))
)}
</div>
</Accordion.Panel>
</Accordion.Item>
)
})
if (!auditLog.rowData) return null
if (!auditLog.rowData) {
return null
}

const changed_fields = Object.entries(auditLog.rowData).map(([field, change]) => {
return (
<Accordion.Item key={field} value={field}>
<Accordion.Control>
<strong>{field === "new" ? "Data lagt til" : field}</strong>
</Accordion.Control>
<Accordion.Panel>
<div style={{ whiteSpace: "pre-wrap" }}>
{change.old ? (
<StringDiff // This component shows the string-difference
oldValue={change.old ?? ""}
newValue={change.new ?? ""}
method={DiffMethod.Lines}
styles={diffStyles}
key={isDark ? "dark" : "light"}
/>
) : (
// Prints all values if there is no existing "old" value
Object.entries(change).map(([key, value]) => (
<div key={key}>
<strong>{key}:</strong> {String(value)}
</div>
))
)}
</div>
</Accordion.Panel>
</Accordion.Item>
)
})

return (
<Stack>
<Title order={2}>Hendelse</Title>
Expand Down
1 change: 0 additions & 1 deletion apps/rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@dotkomonline/utils": "workspace:*",
"@fastify/cors": "^11.0.0",
"@opentelemetry/api": "^1.9.0",
"@prisma/client": "^6.8.2",
"@sentry/node": "^9.24.0",
"@trpc/server": "11.8.0",
"auth0": "^4.23.1",
Expand Down
3 changes: 1 addition & 2 deletions apps/rpc/src/modules/event/event-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DBHandle } from "@dotkomonline/db"
import type { DBHandle, Prisma } from "@dotkomonline/db"
import {
type AttendanceId,
type CompanyId,
Expand All @@ -16,7 +16,6 @@ import {
type UserId,
} from "@dotkomonline/types"
import { getCurrentUTC } from "@dotkomonline/utils"
import type { Prisma } from "@prisma/client"
import invariant from "tiny-invariant"
import { parseOrReport } from "../../invariant"
import { type Pageable, pageQuery } from "../../query"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DBHandle, FeedbackQuestionAnswer, FeedbackQuestionOption } from "@dotkomonline/db"
import { type DBHandle, type FeedbackQuestionAnswer, type FeedbackQuestionOption, Prisma } from "@dotkomonline/db"
import {
type AttendeeId,
type FeedbackFormAnswer,
Expand All @@ -10,7 +10,6 @@ import {
FeedbackQuestionAnswerSchema,
type FeedbackQuestionAnswerWrite,
} from "@dotkomonline/types"
import { Prisma } from "@prisma/client"
import { parseOrReport } from "../../invariant"

export interface FeedbackFormAnswerRepository {
Expand Down
2 changes: 1 addition & 1 deletion apps/rpc/src/modules/group/__test__/group-service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto"
import type { S3Client } from "@aws-sdk/client-s3"
import { PrismaClient } from "@dotkomonline/db"
import type { Group } from "@dotkomonline/types"
import { PrismaClient } from "@prisma/client"
import type { ManagementClient } from "auth0"
import { getFeideGroupsRepository } from "src/modules/feide/feide-groups-repository"
import { getMembershipService } from "src/modules/user/membership-service"
Expand Down
3 changes: 1 addition & 2 deletions apps/rpc/src/modules/group/group-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DBHandle } from "@dotkomonline/db"
import type { DBHandle, GroupType } from "@dotkomonline/db"
import {
type Group,
type GroupId,
Expand All @@ -14,7 +14,6 @@ import {
type GroupWrite,
type UserId,
} from "@dotkomonline/types"
import type { GroupType } from "@prisma/client"
import z from "zod"
import { parseOrReport } from "../../invariant"

Expand Down
2 changes: 1 addition & 1 deletion apps/rpc/src/modules/mark/__test__/mark-service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomUUID } from "node:crypto"
import { PrismaClient } from "@prisma/client"
import { PrismaClient } from "@dotkomonline/db"
import { NotFoundError } from "../../../error"
import { getMarkRepository } from "../mark-repository"
import { getMarkService } from "../mark-service"
Expand Down
4 changes: 2 additions & 2 deletions apps/rpc/src/modules/task/task-executor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clearInterval, type setInterval } from "node:timers"
import type { DBClient, PrismaClient } from "@dotkomonline/db"
import type { DBClient, Prisma, PrismaClient } from "@dotkomonline/db"
import { getLogger } from "@dotkomonline/logger"
import type { Task } from "@dotkomonline/types"
import { getCurrentUTC } from "@dotkomonline/utils"
Expand Down Expand Up @@ -60,7 +60,7 @@ export function getLocalTaskExecutor(
// leave the system in a tainted state, but that's a less severe bug than leaving the database in a tainted state.
await client.$transaction(async (handle) => {
const definition = getTaskDefinition(task.type)
const payload = taskService.parse(definition, task.payload)
const payload = taskService.parse(definition, task.payload as Prisma.JsonValue)

switch (task.type) {
case tasks.RESERVE_ATTENDEE.type:
Expand Down
4 changes: 2 additions & 2 deletions apps/rpc/src/modules/task/task-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DBHandle, TaskStatus } from "@dotkomonline/db"
import { Prisma } from "@dotkomonline/db"
import {
type AttendanceId,
type AttendeeId,
Expand All @@ -9,7 +10,6 @@ import {
type TaskType,
type TaskWrite,
} from "@dotkomonline/types"
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"
import { parseOrReport } from "../../invariant"
import { tasks } from "./task-definition"

Expand Down Expand Up @@ -57,7 +57,7 @@ export function getTaskRepository(): TaskRepository {

return parseOrReport(TaskSchema, task)
} catch (e) {
if (e instanceof PrismaClientKnownRequestError) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
// "An operation failed because it depends on one or more records that were required but not found. {cause}"
if (e.code === "P2025") {
return null
Expand Down
5 changes: 2 additions & 3 deletions apps/rpc/src/modules/task/task-scheduling-service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { SchedulerClient } from "@aws-sdk/client-scheduler"
import type { TZDate } from "@date-fns/tz"
import type { DBHandle } from "@dotkomonline/db"
import type { DBHandle, Prisma } from "@dotkomonline/db"
import { getLogger } from "@dotkomonline/logger"
import type { AttendanceId, AttendeeId, FeedbackFormId, RecurringTaskId, Task, TaskId } from "@dotkomonline/types"
import type { JsonValue } from "@prisma/client/runtime/library"
import { UnimplementedError } from "../../error"
import type { InferTaskData, TaskDefinition } from "./task-definition"
import type { TaskRepository } from "./task-repository"
Expand Down Expand Up @@ -42,7 +41,7 @@ export function getLocalTaskSchedulingService(
return {
async scheduleAt(handle, task, data, executeAt, recurringTaskId) {
logger.info("Scheduling task of TaskKind=%s with data: %o", task, data)
const payload = taskService.parse(task, data) as JsonValue
const payload = taskService.parse(task, data) as Prisma.JsonValue

const scheduledTask = await taskRepository.create(handle, task.type, {
payload,
Expand Down
7 changes: 3 additions & 4 deletions apps/rpc/src/modules/task/task-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { DBHandle } from "@dotkomonline/db"
import type { DBHandle, Prisma } from "@dotkomonline/db"
import { getLogger } from "@dotkomonline/logger"
import type { Task, TaskId, TaskStatus, TaskType, TaskWrite } from "@dotkomonline/types"
import type { JsonValue } from "@prisma/client/runtime/library"
import { IllegalStateError, InvalidArgumentError, NotFoundError } from "../../error"
import { type InferTaskData, type TaskDefinition, getTaskDefinition } from "./task-definition"
import type { TaskRepository } from "./task-repository"
Expand All @@ -25,7 +24,7 @@ export type TaskService = {
// biome-ignore lint/suspicious/noExplicitAny: these are used in inference position
parse<const TTaskDef extends TaskDefinition<any, any>>(
taskDefinition: TTaskDef,
payload: JsonValue
payload: Prisma.JsonValue
): InferTaskData<TTaskDef>
}

Expand All @@ -44,7 +43,7 @@ export function getTaskService(taskRepository: TaskRepository): TaskService {
let newPayload = requestedTask.payload
if (data.payload) {
const definition = getTaskDefinition(requestedTask.type)
newPayload = this.parse(definition, data.payload) as JsonValue
newPayload = this.parse(definition, data.payload) as Prisma.JsonValue
}

// Update the task with the new data and the updated and validated payload.
Expand Down
2 changes: 1 addition & 1 deletion apps/rpc/src/scripts/migrate-events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from "node:fs/promises"
import path from "node:path"
import type { EventType, Prisma } from "@prisma/client"
import type { EventType, Prisma } from "@dotkomonline/db"
import { Command } from "commander"
import { marked } from "marked"
import { createServiceLayer, createThirdPartyClients } from "src/modules/core"
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"test:it": "pnpm run -r test:it",
"dev": "pnpm -rc --parallel -F @dotkomonline/ui -F @dotkomonline/web -F @dotkomonline/dashboard -F @dotkomonline/rpc -F @dotkomonline/invoicification -F @dotkomonline/rif exec doppler run --preserve-env pnpm run dev",
"dev:web": "pnpm -rc --parallel -F @dotkomonline/ui -F @dotkomonline/web -F @dotkomonline/dashboard -F @dotkomonline/rpc exec doppler run --preserve-env pnpm run dev",
"prisma": "pnpm -F @dotkomonline/db prisma",
"generate": "pnpm -F @dotkomonline/db generate",
"migrate:dev": "pnpm -F @dotkomonline/db migrate",
"migrate:dev-with-fixtures": "pnpm -F @dotkomonline/db prisma migrate dev && pnpm -F @dotkomonline/db apply-fixtures",
"migrate:deploy": "pnpm -F @dotkomonline/db prisma migrate deploy",
"migrate:deploy-with-fixtures": "pnpm -F @dotkomonline/db prisma migrate deploy && pnpm -F @dotkomonline/db apply-fixtures",
"prisma": "doppler run --config dev --project monoweb-rpc --preserve-env -- pnpm -F @dotkomonline/db prisma",
"generate": "doppler run --config dev --project monoweb-rpc --preserve-env -- pnpm -F @dotkomonline/db generate",
"migrate:dev": "doppler run --config dev --project monoweb-rpc --preserve-env -- pnpm -F @dotkomonline/db migrate",
"migrate:dev-with-fixtures": "doppler run --config dev --project monoweb-rpc --preserve-env -- pnpm -F @dotkomonline/db prisma migrate dev && pnpm -F @dotkomonline/db apply-fixtures",
"migrate:deploy": "doppler run --config dev --project monoweb-rpc -- pnpm -F @dotkomonline/db prisma migrate deploy",
"migrate:deploy-with-fixtures": "doppler run --config dev --project monoweb-rpc -- pnpm -F @dotkomonline/db prisma migrate deploy && pnpm -F @dotkomonline/db apply-fixtures",
"migrate:staging": "doppler run --config stg --project monoweb-rpc -- pnpm migrate:deploy",
"migrate:prod": "doppler run --config prd --project monoweb-rpc -- pnpm migrate:deploy",
"storybook": "pnpm run -r --filter=storybook storybook",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ node_modules
# Keep environment variables out of version control
.env

src/schemas
generated/schema/.prisma-zod-generator-manifest.json
4 changes: 2 additions & 2 deletions packages/db/biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"root": false,
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"formatter": {
"includes": ["**", "!**/src/schemas/**/*"]
"includes": ["**", "!**/generated/**/*"]
},
"files": {
"includes": ["**", "!**/src/schemas/**/*"]
"includes": ["**", "!**/generated/**/*"]
},
"extends": "//"
}
Loading
Loading