Files
calendar/packages/lib/server/repository/PrismaRoutingFormRepositoryInterface.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

79 lines
1.9 KiB
TypeScript

// Dedicated type definition for routing form data
export type RoutingForm = {
id: string;
description: string | null;
position: number;
routes: any; // JSON field
createdAt: Date;
updatedAt: Date;
name: string;
fields: any; // JSON field
updatedById: number | null;
userId: number | null;
teamId: number | null;
disabled: boolean;
settings: any; // JSON field
};
// Helper type for select parameter
export type RoutingFormSelect = {
[K in keyof RoutingForm]?: boolean;
};
// Helper type for selected fields
export type SelectedFields<T> = T extends undefined
? RoutingForm
: {
[K in keyof T as T[K] extends true ? K : never]: K extends keyof RoutingForm ? RoutingForm[K] : never;
};
// Type for findById options
export type FindByIdOptions<T extends RoutingFormSelect | undefined = undefined> = {
select?: T;
};
// Type for findFormByIdIncludeUserTeamAndOrg result
export type RoutingFormWithUserTeamAndOrg = {
id: string;
description: string | null;
position: number;
routes: any;
createdAt: Date;
updatedAt: Date;
name: string;
fields: any;
updatedById: number | null;
userId: number;
teamId: number | null;
disabled: boolean;
settings: any;
user: {
id: number;
metadata: any;
organization: {
slug: string | null;
} | null;
username: string | null;
email: string;
movedToProfileId: number | null;
};
team: {
metadata: any;
slug: string | null;
parentId: number | null;
parent: {
slug: string | null;
} | null;
} | null;
};
// Interface for static methods (for documentation and type checking purposes)
export interface IPrismaRoutingFormRepositoryStatic {
findById<T extends RoutingFormSelect | undefined = undefined>(
id: string,
options?: FindByIdOptions<T>
): Promise<SelectedFields<T> | null>;
findFormByIdIncludeUserTeamAndOrg(formId: string): Promise<RoutingFormWithUserTeamAndOrg | null>;
}