diff --git a/pnpm-monorepo/apps/app/src/app/api/classification-level/[id]/route.ts b/pnpm-monorepo/apps/app/src/app/api/classification-level/[id]/route.ts deleted file mode 100644 index b44b3055d..000000000 --- a/pnpm-monorepo/apps/app/src/app/api/classification-level/[id]/route.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { prisma } from "@/db"; -import { AuditEventType } from "@/modules/audit/utils/AuditEventTypes"; -import { createAuditEvents } from "@/modules/audit/utils/createAuditEvent"; -import { requireAuthenticationApi } from "@/modules/auth/server"; -import apiErrorHandler from "@/modules/common/utils/apiErrorHandler"; -import { NextResponse } from "next/server"; -import { z } from "zod"; - -type Params = Promise<{ - id: string; -}>; - -const paramsSchema = z.object({ id: z.cuid() }); - -const patchBodySchema = z.object({ - name: z.string().trim().min(1).max(255), -}); - -export async function PATCH(request: Request, props: { params: Params }) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/classification-level/[id]", - "PATCH", - ); - await authentication.authorizeApi("classificationLevel", "manage"); - - /** - * Validate the request params and body - */ - const paramsData = paramsSchema.parse(await props.params); - const body: unknown = await request.json(); - const data = patchBodySchema.parse(body); - - /** - * Do the thing - */ - const existingItem = await prisma.classificationLevel.findUnique({ - where: { - id: paramsData.id, - }, - select: { - name: true, - }, - }); - if (!existingItem) throw new Error("Not found"); - - const item = await prisma.classificationLevel.update({ - where: { - id: paramsData.id, - }, - data, - }); - - await createAuditEvents([ - { - type: AuditEventType.CLASSIFICATION_LEVEL_UPDATED, - data: { - classificationLevelId: item.id, - previousName: existingItem.name, - newName: item.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json(item); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} - -export async function DELETE(request: Request, props: { params: Params }) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/classification-level/[id]", - "DELETE", - ); - await authentication.authorizeApi("classificationLevel", "manage"); - - /** - * Validate the request params - */ - const paramsData = paramsSchema.parse(await props.params); - - /** - * Do the thing - */ - const deletedItem = await prisma.classificationLevel.delete({ - where: { - id: paramsData.id, - }, - }); - - await createAuditEvents([ - { - type: AuditEventType.CLASSIFICATION_LEVEL_DELETED, - data: { - classificationLevelId: deletedItem.id, - name: deletedItem.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json({}); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} diff --git a/pnpm-monorepo/apps/app/src/app/api/classification-level/route.ts b/pnpm-monorepo/apps/app/src/app/api/classification-level/route.ts deleted file mode 100644 index f786da858..000000000 --- a/pnpm-monorepo/apps/app/src/app/api/classification-level/route.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { prisma } from "@/db"; -import { AuditEventType } from "@/modules/audit/utils/AuditEventTypes"; -import { createAuditEvents } from "@/modules/audit/utils/createAuditEvent"; -import { requireAuthenticationApi } from "@/modules/auth/server"; -import apiErrorHandler from "@/modules/common/utils/apiErrorHandler"; -import { NextResponse } from "next/server"; -import { z } from "zod"; - -const postBodySchema = z.object({ - name: z.string().trim().min(1).max(255), -}); - -export async function POST(request: Request) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/classification-level", - "POST", - ); - await authentication.authorizeApi("classificationLevel", "manage"); - - /** - * Validate the request body - */ - const body: unknown = await request.json(); - const data = postBodySchema.parse(body); - - /** - * Do the thing - */ - const item = await prisma.classificationLevel.create({ - data, - }); - - await createAuditEvents([ - { - type: AuditEventType.CLASSIFICATION_LEVEL_CREATED, - data: { - classificationLevelId: item.id, - name: item.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json(item); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} diff --git a/pnpm-monorepo/apps/app/src/app/api/note-type/[id]/route.ts b/pnpm-monorepo/apps/app/src/app/api/note-type/[id]/route.ts deleted file mode 100644 index ff37dcb8d..000000000 --- a/pnpm-monorepo/apps/app/src/app/api/note-type/[id]/route.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { prisma } from "@/db"; -import { AuditEventType } from "@/modules/audit/utils/AuditEventTypes"; -import { createAuditEvents } from "@/modules/audit/utils/createAuditEvent"; -import { requireAuthenticationApi } from "@/modules/auth/server"; -import apiErrorHandler from "@/modules/common/utils/apiErrorHandler"; -import { NextResponse } from "next/server"; -import { z } from "zod"; - -type Params = Promise<{ - id: string; -}>; - -const paramsSchema = z.object({ id: z.cuid() }); - -const patchBodySchema = z.object({ - name: z.string().trim().min(1).max(255), -}); - -export async function PATCH(request: Request, props: { params: Params }) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/note-type/[id]", - "PATCH", - ); - await authentication.authorizeApi("noteType", "manage"); - - /** - * Validate the request params and body - */ - const paramsData = paramsSchema.parse(await props.params); - const body: unknown = await request.json(); - const data = patchBodySchema.parse(body); - - /** - * Do the thing - */ - const existingItem = await prisma.noteType.findUnique({ - where: { - id: paramsData.id, - }, - select: { - name: true, - }, - }); - if (!existingItem) throw new Error("Not found"); - - const item = await prisma.noteType.update({ - where: { - id: paramsData.id, - }, - data, - }); - - await createAuditEvents([ - { - type: AuditEventType.NOTE_TYPE_UPDATED, - data: { - noteTypeId: item.id, - previousName: existingItem.name, - newName: item.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json(item); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} - -export async function DELETE(request: Request, props: { params: Params }) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/note-type/[id]", - "DELETE", - ); - await authentication.authorizeApi("noteType", "manage"); - - /** - * Validate the request params - */ - const paramsData = paramsSchema.parse(await props.params); - - /** - * Do the thing - */ - const deletedItem = await prisma.noteType.delete({ - where: { - id: paramsData.id, - }, - }); - - await createAuditEvents([ - { - type: AuditEventType.NOTE_TYPE_DELETED, - data: { - noteTypeId: deletedItem.id, - name: deletedItem.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json({}); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} diff --git a/pnpm-monorepo/apps/app/src/app/api/note-type/route.ts b/pnpm-monorepo/apps/app/src/app/api/note-type/route.ts deleted file mode 100644 index d330a1923..000000000 --- a/pnpm-monorepo/apps/app/src/app/api/note-type/route.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { prisma } from "@/db"; -import { AuditEventType } from "@/modules/audit/utils/AuditEventTypes"; -import { createAuditEvents } from "@/modules/audit/utils/createAuditEvent"; -import { requireAuthenticationApi } from "@/modules/auth/server"; -import apiErrorHandler from "@/modules/common/utils/apiErrorHandler"; -import { NextResponse } from "next/server"; -import { z } from "zod"; - -const postBodySchema = z.object({ - name: z.string().trim().min(1).max(255), -}); - -export async function POST(request: Request) { - try { - /** - * Authenticate and authorize the request - */ - const authentication = await requireAuthenticationApi( - "/api/note-type", - "POST", - ); - await authentication.authorizeApi("noteType", "manage"); - - /** - * Validate the request body - */ - const body: unknown = await request.json(); - const data = postBodySchema.parse(body); - - /** - * Do the thing - */ - const item = await prisma.noteType.create({ - data, - }); - - await createAuditEvents([ - { - type: AuditEventType.NOTE_TYPE_CREATED, - data: { - noteTypeId: item.id, - name: item.name, - }, - createdById: authentication.session.user.id, - }, - ]); - - /** - * Respond with the result - */ - return NextResponse.json(item); - } catch (error) { - /** - * Respond with an error - */ - return apiErrorHandler(error); - } -} diff --git a/pnpm-monorepo/apps/app/src/env.ts b/pnpm-monorepo/apps/app/src/env.ts index a581cacdf..c566786d1 100644 --- a/pnpm-monorepo/apps/app/src/env.ts +++ b/pnpm-monorepo/apps/app/src/env.ts @@ -48,6 +48,12 @@ export const env = createEnv({ UNLEASH_SERVER_API_URL: z.url().optional(), /** Unleash (or any other Unleash-compatible feature flag provider like GitLab) */ UNLEASH_SERVER_API_TOKEN: z.string().optional(), + /** + * Seconds the fetched flag definitions are cached for. Lets the + * Playwright stack pick up a toggled flag without waiting out the + * production window. + */ + UNLEASH_REVALIDATE_SECONDS: z.coerce.number().int().positive().default(30), COMMIT_SHA: z.preprocess( // Uses VERCEL_GIT_COMMIT_SHA if COMMIT_SHA is not set (str) => str || process.env.VERCEL_GIT_COMMIT_SHA, @@ -188,6 +194,7 @@ export const env = createEnv({ S3_PUBLIC_URL: process.env.S3_PUBLIC_URL, UNLEASH_SERVER_API_URL: process.env.UNLEASH_SERVER_API_URL, UNLEASH_SERVER_API_TOKEN: process.env.UNLEASH_SERVER_API_TOKEN, + UNLEASH_REVALIDATE_SECONDS: process.env.UNLEASH_REVALIDATE_SECONDS, NEXT_PUBLIC_HOST: process.env.NEXT_PUBLIC_HOST, COMMIT_SHA: process.env.COMMIT_SHA, NEXT_PUBLIC_CARE_BEAR_SHOOTER_BUILD_URL: diff --git a/pnpm-monorepo/apps/app/src/modules/citizen/components/CitizenInput.tsx b/pnpm-monorepo/apps/app/src/modules/citizen/components/CitizenInput.tsx index 7aa0f4e48..f37628272 100644 --- a/pnpm-monorepo/apps/app/src/modules/citizen/components/CitizenInput.tsx +++ b/pnpm-monorepo/apps/app/src/modules/citizen/components/CitizenInput.tsx @@ -258,6 +258,7 @@ const Multiple = ({ } triggerRender={