Files
calendar/packages/lib/server/repository/PrismaRoutingFormRepository.ts
T
Eunjae LeeGitHubHariom BalharaDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
6fe6540bc6 fix: apply PBAC to routing form CRUD (#22859)
* fix: apply PBAC to routing form CRUD

* apply permission checks to the UI

* moving prisma call to repository [WIP]

* rename repository and fix type error

* update implementation

* fix formMutation handler

* remove unused import

* revert some rename

* add RolePermission for 'routingForm'

* Revert "revert some rename"

This reverts commit 0ef3114c0d27b821271b36296de531654b37749f.

* clean up PrismaRoutingFormRepository

* fix unit test

* remove no longer necessary code

* fix type definition

* explicit permission handling

* do not disable un-editable routing form

* fix: correct property name from readonly to readOnly in ListLinkItem

- Fix TypeScript error in routing forms component
- Change readonly={readOnly} to readOnly={readOnly} to match component interface
- Resolves type check failure in CI

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-08-08 13:18:18 +01:00

76 lines
1.7 KiB
TypeScript

import prisma from "@calcom/prisma";
import type {
RoutingFormSelect,
SelectedFields,
FindByIdOptions,
RoutingFormWithUserTeamAndOrg,
} from "./PrismaRoutingFormRepositoryInterface";
const defaultSelect = {
id: true,
description: true,
position: true,
routes: true,
createdAt: true,
updatedAt: true,
name: true,
fields: true,
updatedById: true,
userId: true,
teamId: true,
disabled: true,
settings: true,
} as const;
export class PrismaRoutingFormRepository {
static async findById<T extends RoutingFormSelect | undefined = undefined>(
id: string,
options?: FindByIdOptions<T>
): Promise<SelectedFields<T> | null> {
const select = options?.select ?? defaultSelect;
return (await prisma.app_RoutingForms_Form.findUnique({
where: { id },
select,
})) as SelectedFields<T> | null;
}
static async findFormByIdIncludeUserTeamAndOrg(
formId: string
): Promise<RoutingFormWithUserTeamAndOrg | null> {
return (await prisma.app_RoutingForms_Form.findUnique({
where: {
id: formId,
},
include: {
user: {
select: {
id: true,
username: true,
email: true,
movedToProfileId: true,
metadata: true,
organization: {
select: {
slug: true,
},
},
},
},
team: {
select: {
parentId: true,
parent: {
select: {
slug: true,
},
},
slug: true,
metadata: true,
},
},
},
})) as RoutingFormWithUserTeamAndOrg | null;
}
}