Repository: calcom/cal.com
Pull request #21084: chore: get bookings with kysely
Author: login: ThyMinimalDev
Labels: name: ⬆️ dependencies
description: Pull requests that update a dependency file
name: platform
description: Anything related to our platform plan
name: bookings
description: area: bookings, availability, timezones, double booking
name: core
description: area: core, team members only
name: 💻 refactor
name: ready-for-e2e
Created: 2025-05-02T13:58:53Z | Merged: 2025-05-06T00:21:15Z

Refactor getBookings to use Kysely instead of Prisma






Diff:
diff --git a/apps/api/v2/package.json b/apps/api/v2/package.json
index 13a7cf46380abb..a754cc5774c987 100644
--- a/apps/api/v2/package.json
+++ b/apps/api/v2/package.json
@@ -38,7 +38,7 @@
     "@axiomhq/winston": "^1.2.0",
     "@calcom/platform-constants": "*",
     "@calcom/platform-enums": "*",
-    "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.185",
+    "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.194",
     "@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
     "@calcom/platform-types": "*",
     "@calcom/platform-utils": "*",
diff --git a/apps/api/v2/src/ee/bookings/2024-04-15/bookings.module.ts b/apps/api/v2/src/ee/bookings/2024-04-15/bookings.module.ts
index 24a74903919b95..2f642824074d72 100644
--- a/apps/api/v2/src/ee/bookings/2024-04-15/bookings.module.ts
+++ b/apps/api/v2/src/ee/bookings/2024-04-15/bookings.module.ts
@@ -9,6 +9,7 @@ import { ApiKeysRepository } from "@/modules/api-keys/api-keys-repository";
 import { AppsRepository } from "@/modules/apps/apps.repository";
 import { BillingModule } from "@/modules/billing/billing.module";
 import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
+import { KyselyModule } from "@/modules/kysely/kysely.module";
 import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
 import { OAuthClientUsersService } from "@/modules/oauth-clients/services/oauth-clients-users.service";
 import { OAuthFlowService } from "@/modules/oauth-clients/services/oauth-flow.service";
@@ -23,6 +24,7 @@ import { Module } from "@nestjs/common";
 @Module({
   imports: [
     PrismaModule,
+    KyselyModule,
     RedisModule,
     TokensModule,
     BillingModule,
diff --git a/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts b/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
index cf4d0ace1655d9..a0691a18f48e66 100644
--- a/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
+++ b/apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
@@ -13,6 +13,7 @@ import { Permissions } from "@/modules/auth/decorators/permissions/permissions.d
 import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
 import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard";
 import { BillingService } from "@/modules/billing/services/billing.service";
+import { KyselyReadService } from "@/modules/kysely/kysely-read.service";
 import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
 import { OAuthClientUsersService } from "@/modules/oauth-clients/services/oauth-clients-users.service";
 import { OAuthFlowService } from "@/modules/oauth-clients/services/oauth-flow.service";
@@ -99,6 +100,7 @@ export class BookingsController_2024_04_15 {
   constructor(
     private readonly oAuthFlowService: OAuthFlowService,
     private readonly prismaReadService: PrismaReadService,
+    private readonly kyselyReadService: KyselyReadService,
     private readonly oAuthClientRepository: OAuthClientRepository,
     private readonly billingService: BillingService,
     private readonly config: ConfigService,
@@ -129,6 +131,7 @@ export class BookingsController_2024_04_15 {
       ctx: {
         user: { email: user.email, id: user.id, orgId: profile?.organizationId },
         prisma: this.prismaReadService.prisma as unknown as PrismaClient,
+        kysely: this.kyselyReadService.kysely,
       },
     });
 
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts b/apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts
index 87f9c4ab201f45..b85527b4000f20 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts
@@ -17,6 +17,7 @@ import { BillingModule } from "@/modules/billing/billing.module";
 import { BookingSeatModule } from "@/modules/booking-seat/booking-seat.module";
 import { BookingSeatRepository } from "@/modules/booking-seat/booking-seat.repository";
 import { CredentialsRepository } from "@/modules/credentials/credentials.repository";
+import { KyselyModule } from "@/modules/kysely/kysely.module";
 import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
 import { OAuthClientUsersService } from "@/modules/oauth-clients/services/oauth-clients-users.service";
 import { OAuthFlowService } from "@/modules/oauth-clients/services/oauth-flow.service";
@@ -36,6 +37,7 @@ import { Module } from "@nestjs/common";
 @Module({
   imports: [
     PrismaModule,
+    KyselyModule,
     RedisModule,
     TokensModule,
     BillingModule,
diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
index ea32105e58b1c4..fa08dfce699a60 100644
--- a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
+++ b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
@@ -7,6 +7,7 @@ import { PlatformBookingsService } from "@/ee/bookings/shared/platform-bookings.
 import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
 import { BillingService } from "@/modules/billing/services/billing.service";
 import { BookingSeatRepository } from "@/modules/booking-seat/booking-seat.repository";
+import { KyselyReadService } from "@/modules/kysely/kysely-read.service";
 import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository";
 import { OAuthClientUsersService } from "@/modules/oauth-clients/services/oauth-clients-users.service";
 import { OrganizationsRepository } from "@/modules/organizations/index/organizations.repository";
@@ -78,6 +79,7 @@ export class BookingsService_2024_08_13 {
     private readonly bookingSeatRepository: BookingSeatRepository,
     private readonly eventTypesRepository: EventTypesRepository_2024_06_14,
     private readonly prismaReadService: PrismaReadService,
+    private readonly kyselyReadService: KyselyReadService,
     private readonly billingService: BillingService,
     private readonly usersService: UsersService,
     private readonly usersRepository: UsersRepository,
@@ -385,6 +387,7 @@ export class BookingsService_2024_08_13 {
       ctx: {
         user,
         prisma: this.prismaReadService.prisma as unknown as PrismaClient,
+        kysely: this.kyselyReadService.kysely,
       },
       sort: this.inputService.transformGetBookingsSort(queryParams),
     });
diff --git a/apps/api/v2/src/modules/kysely/kysely-read.service.ts b/apps/api/v2/src/modules/kysely/kysely-read.service.ts
new file mode 100644
index 00000000000000..894a0a5c68b040
--- /dev/null
+++ b/apps/api/v2/src/modules/kysely/kysely-read.service.ts
@@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { DeduplicateJoinsPlugin, Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyReadService implements OnModuleDestroy {
+  private logger = new Logger("KyselyReadService");
+
+  public kysely: Kysely<DB>;
+
+  constructor(readonly configService: ConfigService) {
+    const dbUrl = configService.get("db.readUrl", { infer: true });
+    const pool = new Pool({ connectionString: dbUrl });
+
+    // 3. Create the Dialect, passing the configured pool instance
+    const dialect = new PostgresDialect({
+      pool: pool, // Use the pool instance created above
+    });
+    this.kysely = new Kysely<DB>({
+      dialect,
+      plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+    });
+  }
+
+  async onModuleDestroy() {
+    try {
+      await this.kysely.destroy();
+    } catch (error) {
+      this.logger.error(error);
+    }
+  }
+}
diff --git a/apps/api/v2/src/modules/kysely/kysely-write.service.ts b/apps/api/v2/src/modules/kysely/kysely-write.service.ts
new file mode 100644
index 00000000000000..c8decb83e9227e
--- /dev/null
+++ b/apps/api/v2/src/modules/kysely/kysely-write.service.ts
@@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyWriteService implements OnModuleDestroy {
+  private logger = new Logger("KyselyWriteService");
+
+  public kysely: Kysely<DB>;
+
+  constructor(readonly configService: ConfigService) {
+    const dbUrl = configService.get("db.writeUrl", { infer: true });
+    const pool = new Pool({ connectionString: dbUrl });
+
+    // 3. Create the Dialect, passing the configured pool instance
+    const dialect = new PostgresDialect({
+      pool: pool, // Use the pool instance created above
+    });
+    this.kysely = new Kysely<DB>({
+      dialect,
+      plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+    });
+  }
+
+  async onModuleDestroy() {
+    try {
+      await this.kysely.destroy();
+    } catch (error) {
+      this.logger.error(error);
+    }
+  }
+}
diff --git a/apps/api/v2/src/modules/kysely/kysely.module.ts b/apps/api/v2/src/modules/kysely/kysely.module.ts
new file mode 100644
index 00000000000000..3b2d5757c52621
--- /dev/null
+++ b/apps/api/v2/src/modules/kysely/kysely.module.ts
@@ -0,0 +1,9 @@
+import { KyselyReadService } from "@/modules/kysely/kysely-read.service";
+import { KyselyWriteService } from "@/modules/kysely/kysely-write.service";
+import { Module } from "@nestjs/common";
+
+@Module({
+  providers: [KyselyReadService, KyselyWriteService],
+  exports: [KyselyReadService, KyselyWriteService],
+})
+export class KyselyModule {}
diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json
index 6ae330759ad132..59dab8ac4ab4a8 100644
--- a/apps/api/v2/swagger/documentation.json
+++ b/apps/api/v2/swagger/documentation.json
@@ -9563,7 +9563,7 @@
         ]
       }
     },
-    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phone-numbers": {
+    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phones": {
       "get": {
         "operationId": "OrgTeamsVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers of an org team.",
@@ -9671,7 +9671,7 @@
         ]
       }
     },
-    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phone-numbers/{id}": {
+    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phones/{id}": {
       "get": {
         "operationId": "OrgTeamsVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number of an org team by id.",
@@ -11855,7 +11855,7 @@
         ]
       }
     },
-    "/v2/teams/{teamId}/verified-resources/phone-numbers": {
+    "/v2/teams/{teamId}/verified-resources/phones": {
       "get": {
         "operationId": "TeamsVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers of a team.",
@@ -11963,7 +11963,7 @@
         ]
       }
     },
-    "/v2/teams/{teamId}/verified-resources/phone-numbers/{id}": {
+    "/v2/teams/{teamId}/verified-resources/phones/{id}": {
       "get": {
         "operationId": "TeamsVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number of a team by id.",
@@ -12235,7 +12235,7 @@
         ]
       }
     },
-    "/v2/verified-resources/phone-numbers": {
+    "/v2/verified-resources/phones": {
       "get": {
         "operationId": "UserVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers.",
@@ -12327,7 +12327,7 @@
         ]
       }
     },
-    "/v2/verified-resources/phone-numbers/{id}": {
+    "/v2/verified-resources/phones/{id}": {
       "get": {
         "operationId": "UserVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number by id.",
diff --git a/docs/api-reference/v2/openapi.json b/docs/api-reference/v2/openapi.json
index de1f3d7bec9796..be5082563cd961 100644
--- a/docs/api-reference/v2/openapi.json
+++ b/docs/api-reference/v2/openapi.json
@@ -9110,7 +9110,7 @@
         "tags": ["Organization Team Verified Resources"]
       }
     },
-    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phone-numbers": {
+    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phones": {
       "get": {
         "operationId": "OrgTeamsVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers of an org team.",
@@ -9214,7 +9214,7 @@
         "tags": ["Organization Team Verified Resources"]
       }
     },
-    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phone-numbers/{id}": {
+    "/v2/organizations/{orgId}/teams/{teamId}/verified-resources/phones/{id}": {
       "get": {
         "operationId": "OrgTeamsVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number of an org team by id.",
@@ -11311,7 +11311,7 @@
         "tags": ["Teams Verified Resources"]
       }
     },
-    "/v2/teams/{teamId}/verified-resources/phone-numbers": {
+    "/v2/teams/{teamId}/verified-resources/phones": {
       "get": {
         "operationId": "TeamsVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers of a team.",
@@ -11415,7 +11415,7 @@
         "tags": ["Teams Verified Resources"]
       }
     },
-    "/v2/teams/{teamId}/verified-resources/phone-numbers/{id}": {
+    "/v2/teams/{teamId}/verified-resources/phones/{id}": {
       "get": {
         "operationId": "TeamsVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number of a team by id.",
@@ -11675,7 +11675,7 @@
         "tags": ["Verified Resources"]
       }
     },
-    "/v2/verified-resources/phone-numbers": {
+    "/v2/verified-resources/phones": {
       "get": {
         "operationId": "UserVerifiedResourcesController_getVerifiedPhoneNumbers",
         "summary": "Get list of verified phone numbers.",
@@ -11763,7 +11763,7 @@
         "tags": ["Verified Resources"]
       }
     },
-    "/v2/verified-resources/phone-numbers/{id}": {
+    "/v2/verified-resources/phones/{id}": {
       "get": {
         "operationId": "UserVerifiedResourcesController_getVerifiedPhoneById",
         "summary": "Get verified phone number by id.",
diff --git a/packages/kysely/.gitignore b/packages/kysely/.gitignore
new file mode 100644
index 00000000000000..ead638761e9da6
--- /dev/null
+++ b/packages/kysely/.gitignore
@@ -0,0 +1,2 @@
+# Generated dynamically based on Prisma schema
+types.ts
\ No newline at end of file
diff --git a/packages/kysely/README.md b/packages/kysely/README.md
new file mode 100644
index 00000000000000..368094fecc563f
--- /dev/null
+++ b/packages/kysely/README.md
@@ -0,0 +1 @@
+# kysely
diff --git a/packages/kysely/index.ts b/packages/kysely/index.ts
new file mode 100644
index 00000000000000..286e30981bb4b2
--- /dev/null
+++ b/packages/kysely/index.ts
@@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types";
+
+export type { DB, Booking };
+
+const connectionString = process.env.DATABASE_URL ?? "postgresql://postgres:@localhost:5450/calendso";
+
+const pool = new Pool({ connectionString });
+
+// 3. Create the Dialect, passing the configured pool instance
+const dialect = new PostgresDialect({
+  pool: pool, // Use the pool instance created above
+});
+
+// 4. Create the Kysely instance as before
+const db = new Kysely<DB>({
+  dialect,
+  plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+});
+
+export default db;
diff --git a/packages/kysely/package.json b/packages/kysely/package.json
new file mode 100644
index 00000000000000..9d0431297bd064
--- /dev/null
+++ b/packages/kysely/package.json
@@ -0,0 +1,12 @@
+{
+  "name": "@calcom/kysely",
+  "private": true,
+  "main": "index.ts",
+  "dependencies": {
+    "kysely": "^0.28.2",
+    "pg": "^8.11.3"
+  },
+  "devDependencies": {
+    "@types/pg": "^8.10.7"
+  }
+}
diff --git a/packages/kysely/utils/json/traverse/index.ts b/packages/kysely/utils/json/traverse/index.ts
new file mode 100644
index 00000000000000..10c63ec42c8924
--- /dev/null
+++ b/packages/kysely/utils/json/traverse/index.ts
@@ -0,0 +1,14 @@
+import type { ExpressionBuilder, StringReference } from "kysely";
+import { sql } from "kysely";
+
+export function traverseJSON<DB, TB extends keyof DB>(
+  eb: ExpressionBuilder<DB, TB>,
+  column: StringReference<DB, TB>,
+  path: string | [string, ...string[]]
+) {
+  if (!Array.isArray(path)) {
+    path = [path];
+  }
+
+  return sql`${sql.ref(column)}->${sql.raw(path.map((item) => `'${item}'`).join("->"))}`;
+}
diff --git a/packages/lib/bookings/getAllUserBookings.ts b/packages/lib/bookings/getAllUserBookings.ts
index 0dbd39382a98a1..7d870d30ebb956 100644
--- a/packages/lib/bookings/getAllUserBookings.ts
+++ b/packages/lib/bookings/getAllUserBookings.ts
@@ -1,11 +1,12 @@
+import type { Kysely } from "kysely";
+
 import type { TextFilterValue } from "@calcom/features/data-table/lib/types";
+import type { DB } from "@calcom/kysely";
 import type { PrismaClient } from "@calcom/prisma";
-import type { Prisma } from "@calcom/prisma/client";
-import { BookingStatus } from "@calcom/prisma/enums";
 import { getBookings } from "@calcom/trpc/server/routers/viewer/bookings/get.handler";
 
 type InputByStatus = "upcoming" | "recurring" | "past" | "cancelled" | "unconfirmed";
-type SortOptions = {
+export type SortOptions = {
   sortStart?: "asc" | "desc";
   sortEnd?: "asc" | "desc";
   sortCreated?: "asc" | "desc";
@@ -15,6 +16,7 @@ type GetOptions = {
   ctx: {
     user: { id: number; email: string; orgId?: number | null };
     prisma: PrismaClient;
+    kysely: Kysely<DB>;
   };
   bookingListingByStatus: InputByStatus[];
   take: number;
@@ -31,59 +33,15 @@ type GetOptions = {
 };
 
 const getAllUserBookings = async ({ ctx, filters, bookingListingByStatus, take, skip, sort }: GetOptions) => {
-  const { prisma, user } = ctx;
-
-  const bookingListingFilters: Record<InputByStatus, Prisma.BookingWhereInput> = {
-    upcoming: {
-      endTime: { gte: new Date() },
-      // These changes are needed to not show confirmed recurring events,
-      // as rescheduling or cancel for recurring event bookings should be
-      // handled separately for each occurrence
-      OR: [
-        {
-          recurringEventId: { not: null },
-          status: { equals: BookingStatus.ACCEPTED },
-        },
-        {
-          recurringEventId: { equals: null },
-          status: { notIn: [BookingStatus.CANCELLED, BookingStatus.REJECTED] },
-        },
-      ],
-    },
-    recurring: {
-      endTime: { gte: new Date() },
-      AND: [
-        { NOT: { recurringEventId: { equals: null } } },
-        { status: { notIn: [BookingStatus.CANCELLED, BookingStatus.REJECTED] } },
-      ],
-    },
-    past: {
-      endTime: { lte: new Date() },
-      AND: [
-        { NOT: { status: { equals: BookingStatus.CANCELLED } } },
-        { NOT: { status: { equals: BookingStatus.REJECTED } } },
-      ],
-    },
-    cancelled: {
-      OR: [{ status: { equals: BookingStatus.CANCELLED } }, { status: { equals: BookingStatus.REJECTED } }],
-    },
-    unconfirmed: {
-      endTime: { gte: new Date() },
-      status: { equals: BookingStatus.PENDING },
-    },
-  };
+  const { prisma, user, kysely } = ctx;
 
-  const orderBy = getOrderBy(bookingListingByStatus, sort);
-
-  const combinedFilters = bookingListingByStatus.map((status) => bookingListingFilters[status]);
   const { bookings, recurringInfo, totalCount } = await getBookings({
     user,
     prisma,
-    passedBookingsStatusFilter: {
-      OR: combinedFilters,
-    },
+    kysely,
+    bookingListingByStatus,
     filters: filters,
-    orderBy,
+    sort,
     take,
     skip,
   });
@@ -95,36 +53,4 @@ const getAllUserBookings = async ({ ctx, filters, bookingListingByStatus, take,
   };
 };
 
-function getOrderBy(
-  bookingListingByStatus: InputByStatus[],
-  sort?: SortOptions
-): Prisma.BookingOrderByWithAggregationInput {
-  const bookingListingOrderby: Record<InputByStatus, Prisma.BookingOrderByWithAggregationInput> = {
-    upcoming: { startTime: "asc" },
-    recurring: { startTime: "asc" },
-    past: { startTime: "desc" },
-    cancelled: { startTime: "desc" },
-    unconfirmed: { startTime: "asc" },
-  };
-
-  if (bookingListingByStatus?.length === 1 && !sort) {
-    return bookingListingOrderby[bookingListingByStatus[0]];
-  }
-
-  if (sort?.sortStart) {
-    return { startTime: sort.sortStart };
-  }
-  if (sort?.sortEnd) {
-    return { endTime: sort.sortEnd };
-  }
-  if (sort?.sortCreated) {
-    return { createdAt: sort.sortCreated };
-  }
-  if (sort?.sortUpdated) {
-    return { updatedAt: sort.sortUpdated };
-  }
-
-  return { startTime: "asc" };
-}
-
 export default getAllUserBookings;
diff --git a/packages/prisma/package.json b/packages/prisma/package.json
index 01b77249683977..c7470b0513ddba 100644
--- a/packages/prisma/package.json
+++ b/packages/prisma/package.json
@@ -30,6 +30,7 @@
     "@prisma/extension-accelerate": "^0.6.2",
     "@prisma/generator-helper": "^5.4.2",
     "prisma": "^5.4.2",
+    "prisma-kysely": "^1.7.1",
     "ts-node": "^10.9.1",
     "zod": "^3.22.4",
     "zod-prisma": "^0.5.4"
diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma
index 57291bf6793dd6..bc9356fab4590c 100644
--- a/packages/prisma/schema.prisma
+++ b/packages/prisma/schema.prisma
@@ -19,6 +19,12 @@ generator zod {
   relationModel = "default"
 }
 
+generator kysely {
+  provider = "prisma-kysely"
+  output   = "../kysely"
+  fileName = "types.ts"
+}
+
 generator enums {
   provider = "ts-node --transpile-only ./enum-generator"
 }
diff --git a/packages/trpc/server/routers/viewer/bookings/get.handler.ts b/packages/trpc/server/routers/viewer/bookings/get.handler.ts
index 2bec2847817eeb..4e8176f4e59f06 100644
--- a/packages/trpc/server/routers/viewer/bookings/get.handler.ts
+++ b/packages/trpc/server/routers/viewer/bookings/get.handler.ts
@@ -1,16 +1,19 @@
-import { Prisma as PrismaClientType } from "@prisma/client";
+import type { Booking, Prisma, Prisma as PrismaClientType } from "@prisma/client";
+import type { Kysely } from "kysely";
+import { DeduplicateJoinsPlugin, type SelectQueryBuilder } from "kysely";
+import { jsonObjectFrom, jsonArrayFrom } from "kysely/helpers/postgres";
 
 import dayjs from "@calcom/dayjs";
-import { makeWhereClause } from "@calcom/features/data-table/lib/server";
 import { isTextFilterValue } from "@calcom/features/data-table/lib/utils";
+import type { DB } from "@calcom/kysely";
+import kysely from "@calcom/kysely";
 import { parseRecurringEvent, parseEventTypeColor } from "@calcom/lib";
 import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
 import logger from "@calcom/lib/logger";
 import { safeStringify } from "@calcom/lib/safeStringify";
 import type { PrismaClient } from "@calcom/prisma";
-import { bookingMinimalSelect } from "@calcom/prisma";
-import type { Prisma } from "@calcom/prisma/client";
-import { type BookingStatus } from "@calcom/prisma/enums";
+import { SchedulingType } from "@calcom/prisma/enums";
+import { BookingStatus } from "@calcom/prisma/enums";
 import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
 
 import { TRPCError } from "@trpc/server";
@@ -26,6 +29,8 @@ type GetOptions = {
   input: TGetInputSchema;
 };
 
+type InputByStatus = "upcoming" | "recurring" | "past" | "cancelled" | "unconfirmed";
+
 const log = logger.getSubLogger({ prefix: ["bookings.get"] });
 
 export const getHandler = async ({ ctx, input }: GetOptions) => {
@@ -41,6 +46,7 @@ export const getHandler = async ({ ctx, input }: GetOptions) => {
     ctx: {
       user: { id: user.id, email: user.email, orgId: user?.profile?.organizationId },
       prisma: prisma,
+      kysely: kysely,
     },
     bookingListingByStatus: bookingListingByStatus,
     take,
@@ -55,110 +61,36 @@ export const getHandler = async ({ ctx, input }: GetOptions) => {
   };
 };
 
+type BookingsUnionQuery = SelectQueryBuilder<
+  DB,
+  "Booking",
+  Pick<Booking, "id" | "createdAt" | "updatedAt" | "startTime" | "endTime">
+>;
+
 export async function getBookings({
   user,
   prisma,
-  passedBookingsStatusFilter,
+  kysely,
+  bookingListingByStatus,
+  sort,
   filters,
-  orderBy,
   take,
   skip,
 }: {
   user: { id: number; email: string; orgId?: number | null };
   filters: TGetInputSchema["filters"];
   prisma: PrismaClient;
-  passedBookingsStatusFilter: Prisma.BookingWhereInput;
-  orderBy: Prisma.BookingOrderByWithAggregationInput;
+  kysely: Kysely<DB>;
+  bookingListingByStatus: InputByStatus[];
+  sort?: {
+    sortStart?: "asc" | "desc";
+    sortEnd?: "asc" | "desc";
+    sortCreated?: "asc" | "desc";
+    sortUpdated?: "asc" | "desc";
+  };
   take: number;
   skip: number;
 }) {
-  const bookingSelect = {
-    ...bookingMinimalSelect,
-    uid: true,
-    responses: true,
-    /**
-     * Who uses it -
-     * 1. We need to be able to decide which booking can have a 'Reroute' action
-     */
-    routedFromRoutingFormReponse: {
-      select: {
-        id: true,
-      },
-    },
-    recurringEventId: true,
-    location: true,
-    eventType: {
-      select: {
-        slug: true,
-        id: true,
-        title: true,
-        eventName: true,
-        price: true,
-        recurringEvent: true,
-        currency: true,
-        metadata: true,
-        disableGuests: true,
-        seatsShowAttendees: true,
-        seatsShowAvailabilityCount: true,
-        eventTypeColor: true,
-        customReplyToEmail: true,
-        allowReschedulingPastBookings: true,
-        hideOrganizerEmail: true,
-        disableCancelling: true,
-        disableRescheduling: true,
-        schedulingType: true,
-        length: true,
-        team: {
-          select: {
-            id: true,
-            name: true,
-            slug: true,
-          },
-        },
-      },
-    },
-    status: true,
-    paid: true,
-    payment: {
-      select: {
-        paymentOption: true,
-        amount: true,
-        currency: true,
-        success: true,
-      },
-    },
-    user: {
-      select: {
-        id: true,
-        name: true,
-        email: true,
-      },
-    },
-    fromReschedule: true,
-    rescheduled: true,
-    references: true,
-    isRecorded: true,
-    seatsReferences: {
-      where: {
-        attendee: {
-          email: user.email,
-        },
-      },
-      select: {
-        referenceUid: true,
-        attendee: {
-          select: {
-            email: true,
-          },
-        },
-      },
-    },
-    assignmentReason: {
-      orderBy: { createdAt: PrismaClientType.SortOrder.desc },
-      take: 1,
-    },
-  };
-
   const membershipIdsWhereUserIsAdminOwner = (
     await prisma.membership.findMany({
       where: {
@@ -193,11 +125,12 @@ export async function getBookings({
     getUserIdsAndEmailsWhereUserIsAdminOrOwner(prisma, membershipConditionWhereUserIsAdminOwner, user.orgId),
   ]);
 
+  const bookingQueries: BookingsUnionQuery[] = [];
+
   // If user is organization owner/admin, contains organization members emails and ids (organization plan)
   // If user is only team owner/admin, contain team members emails and ids (teams plan)
   const [userIdsWhereUserIsAdminOrOwner, userEmailsWhereUserIsAdminOrOwner] =
     userIdsAndEmailsWhereUserIsAdminOrOwner;
-  const orConditions = [];
 
   // If userIds filter is provided
   if (!!filters?.userIds && filters.userIds.length > 0) {
@@ -215,165 +148,402 @@ export async function getBookings({
       });
     }
 
-    // Filtered view: Booking must match one of the specified users or their attendees
-    const usersFilter = { in: [...filters.userIds] };
-    const attendeesEmailFilter = { in: attendeeEmailsFromUserIdsFilter };
-
     // 1. Booking created by one of the filtered users
-    orConditions.push({ userId: usersFilter });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("userId", "in", filters.userIds)
+    );
+
     // 2. Attendee email matches one of the filtered users' emails
-    orConditions.push({ attendees: { some: { email: attendeesEmailFilter } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
+
     // 3. Seat reference attendee email matches one of the filtered users' emails
-    orConditions.push({ seatsReferences: { some: { attendee: { email: attendeesEmailFilter } } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
   } else {
-    // Filter by emails for auth user.
-    const userEmailFilter = { equals: user.email };
-    // Auth user is ORG_OWNER/ADMIN or TEAM_OWNER/ADMIN, filter by emails of members of the organization or team
-    const userEmailsFilterWhereUserIsOrgAdminOrOwner = userEmailsWhereUserIsAdminOrOwner?.length
-      ? { in: userEmailsWhereUserIsAdminOrOwner }
-      : undefined;
-
     // 1. Current user created bookings
-    orConditions.push({ userId: { equals: user.id } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("Booking.userId", "=", user.id)
+    );
     // 2. Current user is an attendee
-    orConditions.push({ attendees: { some: { email: userEmailFilter } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 3. Current user is an attendee via seats reference
-    orConditions.push({ seatsReferences: { some: { attendee: { email: userEmailFilter } } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("BookingSeat", "BookingSeat.bookingId", "Booking.id")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 4. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({ attendees: { some: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
     // 5. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees via seatsReference
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees via seatsReference
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({
-        seatsReferences: { some: { attendee: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } },
-      });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
+
     // 6. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get booking created for an event type within the organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created for an event type within the team
     eventTypeIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ eventTypeId: { in: eventTypeIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("EventType", "EventType.id", "Booking.eventTypeId")
+          .where("Booking.eventTypeId", "in", eventTypeIdsWhereUserIsAdminOrOwner)
+      );
+
     // 7. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get bookings created by users within the same organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created by users within the same organization
     userIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ userId: { in: userIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .where("Booking.userId", "in", userIdsWhereUserIsAdminOrOwner)
+      );
   }
 
-  const andConditions = [];
+  const queriesWithFilters = bookingQueries.map((query) => {
+    // 1. Apply mandatory status filter
+    let fullQuery = addStatusesQueryFilters(query, bookingListingByStatus);
 
-  // 1. Apply mandatory status filter
-  andConditions.push(passedBookingsStatusFilter);
-
-  // 2. Filter by Event Type IDs derived from Team IDs (if provided)
-  if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromTeamIdsFilter } });
-  }
-
-  // 3. Filter by specific Event Type IDs (if provided)
-  // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
-  if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromEventTypeIdsFilter } });
-  }
+    // 2. Filter by Event Type IDs derived from Team IDs (if provided)
+    if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromTeamIdsFilter);
+    }
 
-  // 4. Filter by Attendee Email (if provided)
-  if (filters?.attendeeEmail) {
-    if (typeof filters.attendeeEmail === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { email: filters.attendeeEmail.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeEmail)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "email",
-            filterValue: filters.attendeeEmail,
-          }),
-        },
-      });
+    // 3. Filter by specific Event Type IDs (if provided)
+    // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
+    if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromEventTypeIdsFilter);
     }
-  }
 
-  // 5. Filter by Attendee Name (if provided)
-  if (filters?.attendeeName) {
-    if (typeof filters.attendeeName === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { name: filters.attendeeName.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeName)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "name",
-            filterValue: filters.attendeeName,
-          }),
-        },
-      });
+    // 4. Filter by Attendee Name (if provided)
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery,
+          "name",
+          filters.attendeeName.data.operator,
+          filters.attendeeName.data.operand
+        );
+      }
     }
-  }
 
-  // 6. Date Range Filters
-  if (filters?.afterStartDate) {
-    andConditions.push({ startTime: { gte: dayjs.utc(filters.afterStartDate).toDate() } });
-  }
-  if (filters?.beforeEndDate) {
-    andConditions.push({ endTime: { lte: dayjs.utc(filters.beforeEndDate).toDate() } });
-  }
-  if (filters?.afterUpdatedDate) {
-    andConditions.push({ updatedAt: { gte: dayjs.utc(filters.afterUpdatedDate).toDate() } });
-  }
-  if (filters?.beforeUpdatedDate) {
-    andConditions.push({ updatedAt: { lte: dayjs.utc(filters.beforeUpdatedDate).toDate() } });
-  }
-  if (filters?.afterCreatedDate) {
-    andConditions.push({ createdAt: { gte: dayjs.utc(filters.afterCreatedDate).toDate() } });
-  }
-  if (filters?.beforeCreatedDate) {
-    andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
-  }
+    // 5. Filter by Attendee Email (if provided)
+    if (filters?.attendeeEmail) {
+      if (typeof filters.attendeeEmail === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .withPlugin(new DeduplicateJoinsPlugin())
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeEmail.trim());
+      } else if (isTextFilterValue(filters.attendeeEmail)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery.withPlugin(new DeduplicateJoinsPlugin()),
+          "email",
+          filters.attendeeEmail.data.operator,
+          filters.attendeeEmail.data.operand
+        );
+      }
+    }
 
-  // All the possible date filter keys
-  const dateFilterKeys = [
-    "afterStartDate",
-    "beforeEndDate",
-    "afterUpdatedDate",
-    "beforeUpdatedDate",
-    "afterCreatedDate",
-    "beforeCreatedDate",
-  ] as const;
-
-  const hasAnyDateFilter = dateFilterKeys.some((key) => filters?.[key]);
-
-  if (!hasAnyDateFilter) {
-    // is ORG/TEAM admin/owner
-    if (userIdsWhereUserIsAdminOrOwner?.length || userEmailsWhereUserIsAdminOrOwner?.length) {
-      const oneMonthAgo = dayjs.utc().subtract(1, "month").startOf("day").toDate();
-      andConditions.push({ startTime: { gte: oneMonthAgo } });
+    // 6. Booking Start/End Time Range Filters
+    if (filters?.afterStartDate) {
+      fullQuery = fullQuery.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      fullQuery = fullQuery.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
     }
-  }
 
-  const whereClause = {
-    OR: orConditions,
-    AND: andConditions,
-  };
+    return fullQuery;
+  });
 
-  log.info(`Get bookings where clause for user ${user.id}`, JSON.stringify(whereClause));
+  const queryUnion = queriesWithFilters.reduce((acc, query) => {
+    return acc.union(query);
+  });
 
-  const [plainBookings, totalCount] = await Promise.all([
-    prisma.booking.findMany({
-      where: whereClause,
-      select: bookingSelect,
-      orderBy,
-      take,
-      skip,
-    }),
-    prisma.booking.count({
-      where: whereClause,
-    }),
-  ]);
+  const orderBy = getOrderBy(bookingListingByStatus, sort);
+
+  const getBookingsUnionCompiled = kysely
+    .selectFrom(queryUnion.as("union_subquery"))
+    .selectAll("union_subquery")
+    .$if(Boolean(filters?.afterUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters?.beforeUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters?.afterCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate())
+    )
+    .$if(Boolean(filters?.beforeCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate())
+    )
+    .orderBy(orderBy.key, orderBy.order)
+    .limit(take)
+    .offset(skip)
+    .compile();
+
+  const bookingsFromUnion = (await kysely.executeQuery(getBookingsUnionCompiled)).rows;
+
+  log.debug(`Get bookings for user ${user.id} SQL:`, getBookingsUnionCompiled.sql);
+  const totalCount = Number(
+    (
+      await kysely
+        .selectFrom(queryUnion.as("union_subquery"))
+        .select(({ fn }) => fn.countAll().as("bookingCount"))
+        .executeTakeFirst()
+    )?.bookingCount ?? 0
+  );
+
+  const plainBookings = !(bookingsFromUnion?.length === 0)
+    ? await kysely
+        .selectFrom("Booking")
+        .where(
+          "id",
+          "in",
+          bookingsFromUnion.map((booking) => booking.id)
+        )
+        .select((eb) => [
+          "Booking.id",
+          "Booking.title",
+          "Booking.userPrimaryEmail",
+          "Booking.description",
+          "Booking.customInputs",
+          "Booking.startTime",
+          "Booking.createdAt",
+          "Booking.updatedAt",
+          "Booking.endTime",
+          "Booking.metadata",
+          "Booking.uid",
+
+          eb
+            .cast<Prisma.JsonValue>( // Target TypeScript type
+              eb.ref("Booking.responses"), // Source column
+              "jsonb" // Target SQL type
+            )
+            .as("responses"),
+          "Booking.recurringEventId",
+          "Booking.location",
+          eb
+            .cast<BookingStatus>(
+              eb
+                .case()
+                .when("Booking.status", "=", "cancelled")
+                .then(BookingStatus["CANCELLED"])
+                .when("Booking.status", "=", "accepted")
+                .then(BookingStatus["ACCEPTED"])
+                .when("Booking.status", "=", "rejected")
+                .then(BookingStatus["REJECTED"])
+                .when("Booking.status", "=", "pending")
+                .then(BookingStatus["PENDING"])
+                .when("Booking.status", "=", "awaiting_host")
+                .then(BookingStatus["AWAITING_HOST"])
+                .else(BookingStatus["PENDING"])
+                .end(), // End of CASE expression
+              "varchar"
+            )
+            .as("status"),
+          "Booking.paid",
+          "Booking.fromReschedule",
+          "Booking.rescheduled",
+          "Booking.isRecorded",
+          jsonObjectFrom(
+            eb
+              .selectFrom("App_RoutingForms_FormResponse")
+              .select("id")
+              .whereRef("App_RoutingForms_FormResponse.routedToBookingUid", "=", "Booking.uid")
+          ).as("routedFromRoutingFormReponse"),
+          jsonObjectFrom(
+            eb
+              .selectFrom("EventType")
+              .select((eb) => [
+                "EventType.slug",
+                "EventType.id",
+                "EventType.title",
+                "EventType.eventName",
+                "EventType.price",
+                "EventType.recurringEvent",
+                "EventType.currency",
+                "EventType.metadata",
+                "EventType.disableGuests",
+                "EventType.seatsShowAttendees",
+                "EventType.seatsShowAvailabilityCount",
+                "EventType.eventTypeColor",
+                "EventType.customReplyToEmail",
+                "EventType.allowReschedulingPastBookings",
+                "EventType.hideOrganizerEmail",
+                "EventType.disableCancelling",
+                "EventType.disableRescheduling",
+                eb
+                  .cast<SchedulingType>(
+                    eb
+                      .case()
+                      .when("EventType.schedulingType", "=", "roundRobin")
+                      .then(SchedulingType["ROUND_ROBIN"])
+                      .when("EventType.schedulingType", "=", "collective")
+                      .then(SchedulingType["COLLECTIVE"])
+                      .when("EventType.schedulingType", "=", "managed")
+                      .then(SchedulingType["MANAGED"])
+                      .else(SchedulingType["ROUND_ROBIN"]) // Ensure ELSE provides a value within SchedulingTypeLiteral for cast safety
+                      .end(),
+                    "varchar" // Or 'text' - use the actual SQL data type
+                  )
+                  .as("schedulingType"),
+                "EventType.length",
+                jsonObjectFrom(
+                  eb
+                    .selectFrom("Team")
+                    .select(["Team.id", "Team.name", "Team.slug"])
+                    .whereRef("EventType.teamId", "=", "Team.id")
+                ).as("team"),
+              ])
+              .whereRef("EventType.id", "=", "Booking.eventTypeId")
+          ).as("eventType"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("BookingReference")
+              .selectAll()
+              .whereRef("BookingReference.bookingId", "=", "Booking.id")
+          ).as("references"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("Payment")
+              .select(["Payment.paymentOption", "Payment.amount", "Payment.currency", "Payment.success"])
+              .whereRef("Payment.bookingId", "=", "Booking.id")
+          ).as("payment"),
+          jsonObjectFrom(
+            eb
+              .selectFrom("users")
+              .select(["users.id", "users.name", "users.email"])
+              .whereRef("Booking.userId", "=", "users.id")
+          ).as("user"),
+          jsonArrayFrom(
+            eb.selectFrom("Attendee").selectAll().whereRef("Attendee.bookingId", "=", "Booking.id")
+          ).as("attendees"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("BookingSeat")
+              .select((eb) => [
+                "BookingSeat.referenceUid",
+                jsonObjectFrom(
+                  eb
+                    .selectFrom("Attendee")
+                    .select(["Attendee.email"])
+                    .whereRef("BookingSeat.attendeeId", "=", "Attendee.id")
+                    .where("Attendee.email", "=", user.email)
+                ).as("attendee"),
+              ])
+              .whereRef("BookingSeat.bookingId", "=", "Booking.id")
+          ).as("seatsReferences"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("AssignmentReason")
+              .selectAll()
+              .whereRef("AssignmentReason.bookingId", "=", "Booking.id")
+              .orderBy("AssignmentReason.createdAt", "desc")
+              .limit(1)
+          ).as("assignmentReason"),
+        ])
+        .orderBy(orderBy.key, orderBy.order)
+        .execute()
+    : [];
 
   const [
     recurringInfoBasic,
@@ -680,3 +850,150 @@ async function getUserIdsAndEmailsWhereUserIsAdminOrOwner(
   });
   return [users.map((user) => user.id), users.map((user) => user.email)];
 }
+
+function addStatusesQueryFilters(query: BookingsUnionQuery, statuses: InputByStatus[]) {
+  if (statuses?.length) {
+    return query.where(({ eb, or, and }) =>
+      or(
+        statuses.map((status) => {
+          if (status === "upcoming") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
+              or([
+                and([eb("Booking.recurringEventId", "is not", null), eb("Booking.status", "=", "accepted")]),
+                and([
+                  eb("Booking.recurringEventId", "is", null),
+                  eb("Booking.status", "not in", ["cancelled", "rejected"]),
+                ]),
+              ]),
+            ]);
+          }
+
+          if (status === "recurring") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
+              eb("Booking.recurringEventId", "is not", null),
+              eb("Booking.status", "not in", ["cancelled", "rejected"]),
+            ]);
+          }
+
+          if (status === "past") {
+            return and([
+              eb("Booking.endTime", "<=", new Date()),
+              eb("Booking.status", "not in", ["cancelled", "rejected"]),
+            ]);
+          }
+
+          if (status === "cancelled") {
+            return eb("Booking.status", "in", ["cancelled", "rejected"]);
+          }
+
+          if (status === "unconfirmed") {
+            return and([eb("Booking.endTime", ">=", new Date()), eb("Booking.status", "=", "pending")]);
+          }
+          return and([]);
+        })
+      )
+    );
+  }
+
+  return query;
+}
+
+function addAdvancedAttendeeWhereClause(
+  query: BookingsUnionQuery,
+  key: "name" | "email",
+  operator:
+    | "endsWith"
+    | "startsWith"
+    | "equals"
+    | "notEquals"
+    | "contains"
+    | "notContains"
+    | "isEmpty"
+    | "isNotEmpty",
+  operand: string
+) {
+  switch (operator) {
+    case "endsWith":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `%${operand}`);
+      break;
+    case "startsWith":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `${operand}%`);
+      break;
+
+    case "equals":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "=", `${operand}`);
+      break;
+
+    case "notEquals":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "!=", `${operand}`);
+      break;
+
+    case "contains":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `%${operand}%`);
+      break;
+
+    case "notContains":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "not like", `%${operand}%`);
+      break;
+
+    case "isEmpty":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "=", "");
+      break;
+
+    case "isNotEmpty":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "!=", "");
+      break;
+
+    default:
+      break;
+  }
+
+  return query;
+}
+
+function getOrderBy(
+  bookingListingByStatus: InputByStatus[],
+  sort?: {
+    sortStart?: "asc" | "desc";
+    sortEnd?: "asc" | "desc";
+    sortCreated?: "asc" | "desc";
+    sortUpdated?: "asc" | "desc";
+  }
+): { key: "startTime" | "endTime" | "createdAt" | "updatedAt"; order: "desc" | "asc" } {
+  const bookingListingOrderby = {
+    upcoming: { startTime: "asc" },
+    recurring: { startTime: "asc" },
+    past: { startTime: "desc" },
+    cancelled: { startTime: "desc" },
+    unconfirmed: { startTime: "asc" },
+  } as const;
+
+  if (bookingListingByStatus?.length === 1 && !sort) {
+    return { key: "startTime", order: bookingListingOrderby[bookingListingByStatus[0]].startTime };
+  }
+
+  if (sort?.sortStart) {
+    return { key: "startTime", order: sort.sortStart };
+  }
+  if (sort?.sortEnd) {
+    return { key: "endTime", order: sort.sortEnd };
+  }
+  if (sort?.sortCreated) {
+    return { key: "createdAt", order: sort.sortCreated };
+  }
+  if (sort?.sortUpdated) {
+    return { key: "updatedAt", order: sort.sortUpdated };
+  }
+
+  return { key: "startTime", order: "asc" };
+}
diff --git a/yarn.lock b/yarn.lock
index 6215e176d00e5d..7475786119d7f2 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -89,6 +89,21 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@antfu/ni@npm:0.21.8":
+  version: 0.21.8
+  resolution: "@antfu/ni@npm:0.21.8"
+  bin:
+    na: bin/na.mjs
+    nci: bin/nci.mjs
+    ni: bin/ni.mjs
+    nlx: bin/nlx.mjs
+    nr: bin/nr.mjs
+    nu: bin/nu.mjs
+    nun: bin/nun.mjs
+  checksum: 3ee503d84005fa8285e456136fc3661e0a0fe3fa4b7cd615288c2cd26ac0cbdc51b53f572e3e915ff0b2c088f8e3214859849eebe5897e6f74384ce985d63d43
+  languageName: node
+  linkType: hard
+
 "@antfu/utils@npm:^0.7.7":
   version: 0.7.8
   resolution: "@antfu/utils@npm:0.7.8"
@@ -2504,7 +2519,7 @@ __metadata:
     "@axiomhq/winston": ^1.2.0
     "@calcom/platform-constants": "*"
     "@calcom/platform-enums": "*"
-    "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.185"
+    "@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.194"
     "@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2"
     "@calcom/platform-types": "*"
     "@calcom/platform-utils": "*"
@@ -3331,6 +3346,16 @@ __metadata:
   languageName: unknown
   linkType: soft
 
+"@calcom/kysely@workspace:packages/kysely":
+  version: 0.0.0-use.local
+  resolution: "@calcom/kysely@workspace:packages/kysely"
+  dependencies:
+    "@types/pg": ^8.10.7
+    kysely: ^0.28.2
+    pg: ^8.11.3
+  languageName: unknown
+  linkType: soft
+
 "@calcom/larkcalendar@workspace:packages/app-store/larkcalendar":
   version: 0.0.0-use.local
   resolution: "@calcom/larkcalendar@workspace:packages/app-store/larkcalendar"
@@ -3553,13 +3578,13 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.185":
-  version: 0.0.185
-  resolution: "@calcom/platform-libraries@npm:0.0.185"
+"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.194":
+  version: 0.0.194
+  resolution: "@calcom/platform-libraries@npm:0.0.194"
   dependencies:
     "@calcom/features": "*"
     "@calcom/lib": "*"
-  checksum: 189073285f8cd9f859366b80610cf90ef0aa912438105f99f7c5fa9eb28a99602805d2ae13e56f660440351508b29cdbb6783b94e5a1d09293030de7c7e48b38
+  checksum: 85d15cdce86ec2c663da393cc35fddbe7b657c0d61ccf6c08dccd510fd64530c82ff9b78cca325f77400d233d8cb5fbf4073f63e1ad4408bdc0a3f548ee91462
   languageName: node
   linkType: hard
 
@@ -3631,6 +3656,7 @@ __metadata:
     "@prisma/generator-helper": ^5.4.2
     npm-run-all: ^4.1.5
     prisma: ^5.4.2
+    prisma-kysely: ^1.7.1
     ts-node: ^10.9.1
     zod: ^3.22.4
     zod-prisma: ^0.5.4
@@ -8588,6 +8614,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@mrleebo/prisma-ast@npm:^0.7.0":
+  version: 0.7.0
+  resolution: "@mrleebo/prisma-ast@npm:0.7.0"
+  dependencies:
+    chevrotain: ^10.5.0
+    lilconfig: ^2.1.0
+  checksum: a9da6f075cead30a2ca728024055bdfee108901813be344ab37e56fc594102c8065e73e6bc40995deb662325cf877f4cd90f205e66fe13540e372d7653de61f3
+  languageName: node
+  linkType: hard
+
 "@msgpackr-extract/msgpackr-extract-darwin-arm64@npm:3.0.3":
   version: 3.0.3
   resolution: "@msgpackr-extract/msgpackr-extract-darwin-arm64@npm:3.0.3"
@@ -9783,6 +9819,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@opentelemetry/api@npm:1.4.1":
+  version: 1.4.1
+  resolution: "@opentelemetry/api@npm:1.4.1"
+  checksum: e783c40d1a518abf9c4c5d65223237c1392cd9a6c53ac6e2c3ef0c05ff7266e3dfc4fd9874316dae0dcb7a97950878deb513bcbadfaad653d48f0215f2a0911b
+  languageName: node
+  linkType: hard
+
 "@opentelemetry/api@npm:1.9.0, @opentelemetry/api@npm:^1.3.0, @opentelemetry/api@npm:^1.6.0, @opentelemetry/api@npm:^1.8, @opentelemetry/api@npm:^1.9.0":
   version: 1.9.0
   resolution: "@opentelemetry/api@npm:1.9.0"
@@ -11296,6 +11339,17 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/debug@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/debug@npm:5.3.1"
+  dependencies:
+    "@types/debug": 4.1.8
+    debug: 4.3.4
+    strip-ansi: 6.0.1
+  checksum: 9eaddf4b4d60a1bd41901a9d28b4f37ae369e4b952f53cdd02681eaadfff81222ef29fe73f37a6060746eeb5e457a26d9aa1cbdc217e882aeab7e48dce74e1d5
+  languageName: node
+  linkType: hard
+
 "@prisma/debug@npm:5.4.2":
   version: 5.4.2
   resolution: "@prisma/debug@npm:5.4.2"
@@ -11352,6 +11406,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/engines@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/engines@npm:5.3.1"
+  checksum: a231adad60ac42569b560ea9782bc181818d8ad15e65283d1317bda5d7aa754e5b536a3f9365ce1eda8961e1eff4eca5978c456fa9764a867fe4339d123e7371
+  languageName: node
+  linkType: hard
+
 "@prisma/engines@npm:5.4.2":
   version: 5.4.2
   resolution: "@prisma/engines@npm:5.4.2"
@@ -11390,6 +11451,31 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/fetch-engine@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/fetch-engine@npm:5.3.1"
+  dependencies:
+    "@prisma/debug": 5.3.1
+    "@prisma/get-platform": 5.3.1
+    execa: 5.1.1
+    find-cache-dir: 3.3.2
+    fs-extra: 11.1.1
+    hasha: 5.2.2
+    http-proxy-agent: 7.0.0
+    https-proxy-agent: 7.0.2
+    kleur: 4.1.5
+    node-fetch: 2.7.0
+    p-filter: 2.1.0
+    p-map: 4.0.0
+    p-retry: 4.6.2
+    progress: 2.0.3
+    rimraf: 3.0.2
+    temp-dir: 2.0.0
+    tempy: 1.0.1
+  checksum: f491bfc6ee7682f2b94ddc90ebd90633558c4aaef22bca74489b18c422cc466d89805f06fe2c51277bc7917ae338f6ae80ec716b1ad2b9c947223354a242d76a
+  languageName: node
+  linkType: hard
+
 "@prisma/generator-helper@npm:5.21.1":
   version: 5.21.1
   resolution: "@prisma/generator-helper@npm:5.21.1"
@@ -11399,6 +11485,18 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/generator-helper@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/generator-helper@npm:5.3.1"
+  dependencies:
+    "@prisma/debug": 5.3.1
+    "@types/cross-spawn": 6.0.2
+    cross-spawn: 7.0.3
+    kleur: 4.1.5
+  checksum: 2cb0cf86c1719db5007d3ac46d2e0a741d1431d26cda032d180b2edbad7a849c2d7b8cb90fbd1638da24de429ac1b6b0c4326eab38d2d97f66f774361ec11206
+  languageName: node
+  linkType: hard
+
 "@prisma/generator-helper@npm:^5.4.2":
   version: 5.4.2
   resolution: "@prisma/generator-helper@npm:5.4.2"
@@ -11441,6 +11539,24 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/get-platform@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/get-platform@npm:5.3.1"
+  dependencies:
+    "@prisma/debug": 5.3.1
+    escape-string-regexp: 4.0.0
+    execa: 5.1.1
+    fs-jetpack: 5.1.0
+    kleur: 4.1.5
+    replace-string: 3.1.0
+    strip-ansi: 6.0.1
+    tempy: 1.0.1
+    terminal-link: 2.1.1
+    ts-pattern: 4.3.0
+  checksum: 83729e189d06f0fe6ffd113b3fd4bfac7c27fbc69c14325de6a14fadbf038d4dda0970daae2e130fb9d695f1bc48e4fb3fb655cbd7023c1266c29422b5097731
+  languageName: node
+  linkType: hard
+
 "@prisma/instrumentation@npm:5.15.0":
   version: 5.15.0
   resolution: "@prisma/instrumentation@npm:5.15.0"
@@ -11491,6 +11607,56 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/internals@npm:5.3.1":
+  version: 5.3.1
+  resolution: "@prisma/internals@npm:5.3.1"
+  dependencies:
+    "@antfu/ni": 0.21.8
+    "@opentelemetry/api": 1.4.1
+    "@prisma/debug": 5.3.1
+    "@prisma/engines": 5.3.1
+    "@prisma/fetch-engine": 5.3.1
+    "@prisma/generator-helper": 5.3.1
+    "@prisma/get-platform": 5.3.1
+    "@prisma/prisma-schema-wasm": 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
+    archiver: 5.3.2
+    arg: 5.0.2
+    checkpoint-client: 1.1.27
+    cli-truncate: 2.1.0
+    dotenv: 16.0.3
+    escape-string-regexp: 4.0.0
+    execa: 5.1.1
+    find-up: 5.0.0
+    fp-ts: 2.16.1
+    fs-extra: 11.1.1
+    fs-jetpack: 5.1.0
+    global-dirs: 3.0.1
+    globby: 11.1.0
+    indent-string: 4.0.0
+    is-windows: 1.0.2
+    is-wsl: 2.2.0
+    kleur: 4.1.5
+    new-github-issue-url: 0.2.1
+    node-fetch: 2.7.0
+    npm-packlist: 5.1.3
+    open: 7.4.2
+    p-map: 4.0.0
+    prompts: 2.4.2
+    read-pkg-up: 7.0.1
+    replace-string: 3.1.0
+    resolve: 1.22.4
+    string-width: 4.2.3
+    strip-ansi: 6.0.1
+    strip-indent: 3.0.0
+    temp-dir: 2.0.0
+    tempy: 1.0.1
+    terminal-link: 2.1.1
+    tmp: 0.2.1
+    ts-pattern: 4.3.0
+  checksum: bac741cd4e435a2c3c769c2d289fcffc178960b1a5d6bc4d4da4344a0577c92847ff1eda981249a6f6f5889789a34e5a9050922dd1524dcafbba5a16cc8bad4f
+  languageName: node
+  linkType: hard
+
 "@prisma/prisma-schema-wasm@npm:5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36":
   version: 5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36
   resolution: "@prisma/prisma-schema-wasm@npm:5.21.1-1.bf0e5e8a04cada8225617067eaa03d041e2bba36"
@@ -11498,6 +11664,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@prisma/prisma-schema-wasm@npm:5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59":
+  version: 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
+  resolution: "@prisma/prisma-schema-wasm@npm:5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59"
+  checksum: d4639f673559ee94dd995c1d1046ce437a909103850339c8850c37f60c7c31da1bca3738ad875757ff7caee8753c4907526deb7426ee9281dd7ac6e0e013d35b
+  languageName: node
+  linkType: hard
+
 "@prisma/schema-files-loader@npm:5.21.1":
   version: 5.21.1
   resolution: "@prisma/schema-files-loader@npm:5.21.1"
@@ -17481,6 +17654,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/debug@npm:4.1.8":
+  version: 4.1.8
+  resolution: "@types/debug@npm:4.1.8"
+  dependencies:
+    "@types/ms": "*"
+  checksum: a9a9bb40a199e9724aa944e139a7659173a9b274798ea7efbc277cb084bc37d32fc4c00877c3496fac4fed70a23243d284adb75c00b5fdabb38a22154d18e5df
+  languageName: node
+  linkType: hard
+
 "@types/debug@npm:4.1.9":
   version: 4.1.9
   resolution: "@types/debug@npm:4.1.9"
@@ -18224,6 +18406,17 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/pg@npm:^8.10.7":
+  version: 8.11.14
+  resolution: "@types/pg@npm:8.11.14"
+  dependencies:
+    "@types/node": "*"
+    pg-protocol: "*"
+    pg-types: ^4.0.1
+  checksum: 2b7cab5521d86357c615d36206108dea0be9193b5175edb0b0a4d19eb6c8f2e1542aa19276d1e78a0dfb337227f3aa0cf286e1db4beb7ad926d4bc73d06e2ca0
+  languageName: node
+  linkType: hard
+
 "@types/pretty-hrtime@npm:^1.0.0":
   version: 1.0.1
   resolution: "@types/pretty-hrtime@npm:1.0.1"
@@ -18344,6 +18537,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/retry@npm:0.12.0":
+  version: 0.12.0
+  resolution: "@types/retry@npm:0.12.0"
+  checksum: 61a072c7639f6e8126588bf1eb1ce8835f2cb9c2aba795c4491cf6310e013267b0c8488039857c261c387e9728c1b43205099223f160bb6a76b4374f741b5603
+  languageName: node
+  linkType: hard
+
 "@types/sanitize-html@npm:^2.9.0":
   version: 2.9.0
   resolution: "@types/sanitize-html@npm:2.9.0"
@@ -20201,6 +20401,57 @@ __metadata:
   languageName: node
   linkType: hard
 
+"archiver-utils@npm:^2.1.0":
+  version: 2.1.0
+  resolution: "archiver-utils@npm:2.1.0"
+  dependencies:
+    glob: ^7.1.4
+    graceful-fs: ^4.2.0
+    lazystream: ^1.0.0
+    lodash.defaults: ^4.2.0
+    lodash.difference: ^4.5.0
+    lodash.flatten: ^4.4.0
+    lodash.isplainobject: ^4.0.6
+    lodash.union: ^4.6.0
+    normalize-path: ^3.0.0
+    readable-stream: ^2.0.0
+  checksum: 5665f40bde87ee82cb638177bdccca8cc6e55edea1b94338f7e6b56a1d9367b0d9a39e42b47866eaf84b8c67669a7d250900a226207ecc30fa163b52aae859a5
+  languageName: node
+  linkType: hard
+
+"archiver-utils@npm:^3.0.4":
+  version: 3.0.4
+  resolution: "archiver-utils@npm:3.0.4"
+  dependencies:
+    glob: ^7.2.3
+    graceful-fs: ^4.2.0
+    lazystream: ^1.0.0
+    lodash.defaults: ^4.2.0
+    lodash.difference: ^4.5.0
+    lodash.flatten: ^4.4.0
+    lodash.isplainobject: ^4.0.6
+    lodash.union: ^4.6.0
+    normalize-path: ^3.0.0
+    readable-stream: ^3.6.0
+  checksum: 5c6568f1185fb6c4b85282ad3281a5a024761bf27e525de1ec54255d15ca98e19532e7b5403930273911a5c8c961aa0c1e9148d6c2810784fa6bd8a97c0021a7
+  languageName: node
+  linkType: hard
+
+"archiver@npm:5.3.2":
+  version: 5.3.2
+  resolution: "archiver@npm:5.3.2"
+  dependencies:
+    archiver-utils: ^2.1.0
+    async: ^3.2.4
+    buffer-crc32: ^0.2.1
+    readable-stream: ^3.6.0
+    readdir-glob: ^1.1.2
+    tar-stream: ^2.2.0
+    zip-stream: ^4.1.0
+  checksum: 7d3b9b9b51cf54d88c89fbca9b0847c120bfcf9776c7025c52dd0b62f6603dc63dc0f3f1a09582f936f67e3906b46d58954cc762a255be45e8d3e14e3cb0b0b1
+  languageName: node
+  linkType: hard
+
 "are-we-there-yet@npm:^3.0.0":
   version: 3.0.1
   resolution: "are-we-there-yet@npm:3.0.1"
@@ -21630,6 +21881,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"buffer-crc32@npm:^0.2.1, buffer-crc32@npm:^0.2.13":
+  version: 0.2.13
+  resolution: "buffer-crc32@npm:0.2.13"
+  checksum: 06252347ae6daca3453b94e4b2f1d3754a3b146a111d81c68924c22d91889a40623264e95e67955b1cb4a68cbedf317abeabb5140a9766ed248973096db5ce1c
+  languageName: node
+  linkType: hard
+
 "buffer-equal-constant-time@npm:1.0.1":
   version: 1.0.1
   resolution: "buffer-equal-constant-time@npm:1.0.1"
@@ -22348,6 +22606,20 @@ __metadata:
   languageName: node
   linkType: hard
 
+"checkpoint-client@npm:1.1.27":
+  version: 1.1.27
+  resolution: "checkpoint-client@npm:1.1.27"
+  dependencies:
+    ci-info: 3.8.0
+    env-paths: 2.2.1
+    make-dir: 4.0.0
+    ms: 2.1.3
+    node-fetch: 2.6.12
+    uuid: 9.0.0
+  checksum: 178b4160f7c6d3ca0deecee6d0820c859fd73ff6e3c11b34b27411617c5b32ffb31194d5f9c880b3600376ddf9f0845e89889e519d17a870db69e7e2851c1e90
+  languageName: node
+  linkType: hard
+
 "chevrotain@npm:^10.5.0":
   version: 10.5.0
   resolution: "chevrotain@npm:10.5.0"
@@ -22608,7 +22880,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"cli-truncate@npm:^2.1.0":
+"cli-truncate@npm:2.1.0, cli-truncate@npm:^2.1.0":
   version: 2.1.0
   resolution: "cli-truncate@npm:2.1.0"
   dependencies:
@@ -23041,6 +23313,18 @@ __metadata:
   languageName: node
   linkType: hard
 
+"compress-commons@npm:^4.1.2":
+  version: 4.1.2
+  resolution: "compress-commons@npm:4.1.2"
+  dependencies:
+    buffer-crc32: ^0.2.13
+    crc32-stream: ^4.0.2
+    normalize-path: ^3.0.0
+    readable-stream: ^3.6.0
+  checksum: b50c4b5d6b8917ea164eef81d414b1824f27e02427f9266926c80aad55f9e15f81f74c274770773c2b732c22d1081b81dedce4f133271a466151f7f36b8e9dc9
+  languageName: node
+  linkType: hard
+
 "compute-scroll-into-view@npm:^1.0.17":
   version: 1.0.17
   resolution: "compute-scroll-into-view@npm:1.0.17"
@@ -23411,6 +23695,25 @@ __metadata:
   languageName: node
   linkType: hard
 
+"crc-32@npm:^1.2.0":
+  version: 1.2.2
+  resolution: "crc-32@npm:1.2.2"
+  bin:
+    crc32: bin/crc32.njs
+  checksum: ad2d0ad0cbd465b75dcaeeff0600f8195b686816ab5f3ba4c6e052a07f728c3e70df2e3ca9fd3d4484dc4ba70586e161ca5a2334ec8bf5a41bf022a6103ff243
+  languageName: node
+  linkType: hard
+
+"crc32-stream@npm:^4.0.2":
+  version: 4.0.3
+  resolution: "crc32-stream@npm:4.0.3"
+  dependencies:
+    crc-32: ^1.2.0
+    readable-stream: ^3.4.0
+  checksum: d44d0ec6f04d8a1bed899ac3e4fbb82111ed567ea6d506be39147362af45c747887fce1032f4beca1646b4824e5a9614cd3332bfa94bbc5577ca5445e7f75ddd
+  languageName: node
+  linkType: hard
+
 "create-ecdh@npm:^4.0.0":
   version: 4.0.4
   resolution: "create-ecdh@npm:4.0.4"
@@ -23616,6 +23919,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"crypto-random-string@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "crypto-random-string@npm:2.0.0"
+  checksum: 0283879f55e7c16fdceacc181f87a0a65c53bc16ffe1d58b9d19a6277adcd71900d02bb2c4843dd55e78c51e30e89b0fec618a7f170ebcc95b33182c28f05fd6
+  languageName: node
+  linkType: hard
+
 "crypto@npm:^1.0.1":
   version: 1.0.1
   resolution: "crypto@npm:1.0.1"
@@ -24339,6 +24649,22 @@ __metadata:
   languageName: node
   linkType: hard
 
+"del@npm:^6.0.0":
+  version: 6.1.1
+  resolution: "del@npm:6.1.1"
+  dependencies:
+    globby: ^11.0.1
+    graceful-fs: ^4.2.4
+    is-glob: ^4.0.1
+    is-path-cwd: ^2.2.0
+    is-path-inside: ^3.0.2
+    p-map: ^4.0.0
+    rimraf: ^3.0.2
+    slash: ^3.0.0
+  checksum: 563288b73b8b19a7261c47fd21a330eeab6e2acd7c6208c49790dfd369127120dd7836cdf0c1eca216b77c94782a81507eac6b4734252d3bef2795cb366996b6
+  languageName: node
+  linkType: hard
+
 "delayed-stream@npm:~1.0.0":
   version: 1.0.0
   resolution: "delayed-stream@npm:1.0.0"
@@ -24754,6 +25080,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"dotenv@npm:16.0.3, dotenv@npm:^16.0.3":
+  version: 16.0.3
+  resolution: "dotenv@npm:16.0.3"
+  checksum: afcf03f373d7a6d62c7e9afea6328e62851d627a4e73f2e12d0a8deae1cd375892004f3021883f8aec85932cd2834b091f568ced92b4774625b321db83b827f8
+  languageName: node
+  linkType: hard
+
 "dotenv@npm:16.3.1, dotenv@npm:^16.3.1":
   version: 16.3.1
   resolution: "dotenv@npm:16.3.1"
@@ -24775,13 +25108,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"dotenv@npm:^16.0.3":
-  version: 16.0.3
-  resolution: "dotenv@npm:16.0.3"
-  checksum: afcf03f373d7a6d62c7e9afea6328e62851d627a4e73f2e12d0a8deae1cd375892004f3021883f8aec85932cd2834b091f568ced92b4774625b321db83b827f8
-  languageName: node
-  linkType: hard
-
 "downshift@npm:^6.1.9":
   version: 6.1.9
   resolution: "downshift@npm:6.1.9"
@@ -25108,7 +25434,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"env-paths@npm:^2.2.0, env-paths@npm:^2.2.1":
+"env-paths@npm:2.2.1, env-paths@npm:^2.2.0, env-paths@npm:^2.2.1":
   version: 2.2.1
   resolution: "env-paths@npm:2.2.1"
   checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e
@@ -27024,7 +27350,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"execa@npm:^5.0.0, execa@npm:^5.1.1":
+"execa@npm:5.1.1, execa@npm:^5.0.0, execa@npm:^5.1.1":
   version: 5.1.1
   resolution: "execa@npm:5.1.1"
   dependencies:
@@ -27674,7 +28000,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"find-cache-dir@npm:^3.0.0":
+"find-cache-dir@npm:3.3.2, find-cache-dir@npm:^3.0.0":
   version: 3.3.2
   resolution: "find-cache-dir@npm:3.3.2"
   dependencies:
@@ -27692,6 +28018,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"find-up@npm:5.0.0, find-up@npm:^5.0.0":
+  version: 5.0.0
+  resolution: "find-up@npm:5.0.0"
+  dependencies:
+    locate-path: ^6.0.0
+    path-exists: ^4.0.0
+  checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095
+  languageName: node
+  linkType: hard
+
 "find-up@npm:^2.1.0":
   version: 2.1.0
   resolution: "find-up@npm:2.1.0"
@@ -27720,16 +28056,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"find-up@npm:^5.0.0":
-  version: 5.0.0
-  resolution: "find-up@npm:5.0.0"
-  dependencies:
-    locate-path: ^6.0.0
-    path-exists: ^4.0.0
-  checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095
-  languageName: node
-  linkType: hard
-
 "find-yarn-workspace-root2@npm:1.2.16":
   version: 1.2.16
   resolution: "find-yarn-workspace-root2@npm:1.2.16"
@@ -27986,6 +28312,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"fp-ts@npm:2.16.1":
+  version: 2.16.1
+  resolution: "fp-ts@npm:2.16.1"
+  checksum: 94e8bb1d037fdc44414ac93bbabecc3f94fb798d6564e77427ae2ecfa0f77681ec35968598d7b0cbf8274566469c7b42e8727390eb889e1121c199341939c2a3
+  languageName: node
+  linkType: hard
+
 "fraction.js@npm:^4.2.0":
   version: 4.2.0
   resolution: "fraction.js@npm:4.2.0"
@@ -28102,6 +28435,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"fs-jetpack@npm:5.1.0":
+  version: 5.1.0
+  resolution: "fs-jetpack@npm:5.1.0"
+  dependencies:
+    minimatch: ^5.1.0
+  checksum: a30fc7884ded99619b981f16bf096d93693d36c53dab87f1d8339d63f6c9c89c45981c47ddd4d08f4045c3181cc843ee2a83ed4834683eb8cb96665332f89b36
+  languageName: node
+  linkType: hard
+
 "fs-minipass@npm:^2.0.0, fs-minipass@npm:^2.1.0":
   version: 2.1.0
   resolution: "fs-minipass@npm:2.1.0"
@@ -28798,7 +29140,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"glob@npm:^7.0.0":
+"glob@npm:^7.0.0, glob@npm:^7.2.3":
   version: 7.2.3
   resolution: "glob@npm:7.2.3"
   dependencies:
@@ -28851,6 +29193,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"global-dirs@npm:3.0.1":
+  version: 3.0.1
+  resolution: "global-dirs@npm:3.0.1"
+  dependencies:
+    ini: 2.0.0
+  checksum: 70147b80261601fd40ac02a104581432325c1c47329706acd773f3a6ce99bb36d1d996038c85ccacd482ad22258ec233c586b6a91535b1a116b89663d49d6438
+  languageName: node
+  linkType: hard
+
 "global@npm:~4.4.0":
   version: 4.4.0
   resolution: "global@npm:4.4.0"
@@ -28910,7 +29261,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"globby@npm:^11.0.0, globby@npm:^11.0.3, globby@npm:^11.1.0":
+"globby@npm:11.1.0, globby@npm:^11.0.0, globby@npm:^11.0.1, globby@npm:^11.0.3, globby@npm:^11.1.0":
   version: 11.1.0
   resolution: "globby@npm:11.1.0"
   dependencies:
@@ -29462,6 +29813,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"hasha@npm:5.2.2":
+  version: 5.2.2
+  resolution: "hasha@npm:5.2.2"
+  dependencies:
+    is-stream: ^2.0.0
+    type-fest: ^0.8.0
+  checksum: 06cc474bed246761ff61c19d629977eb5f53fa817be4313a255a64ae0f433e831a29e83acb6555e3f4592b348497596f1d1653751008dda4f21c9c21ca60ac5a
+  languageName: node
+  linkType: hard
+
 "hasown@npm:^2.0.0":
   version: 2.0.0
   resolution: "hasown@npm:2.0.0"
@@ -29796,6 +30157,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"http-proxy-agent@npm:7.0.0":
+  version: 7.0.0
+  resolution: "http-proxy-agent@npm:7.0.0"
+  dependencies:
+    agent-base: ^7.1.0
+    debug: ^4.3.4
+  checksum: 48d4fac997917e15f45094852b63b62a46d0c8a4f0b9c6c23ca26d27b8df8d178bed88389e604745e748bd9a01f5023e25093722777f0593c3f052009ff438b6
+  languageName: node
+  linkType: hard
+
 "http-proxy-agent@npm:^4.0.1":
   version: 4.0.1
   resolution: "http-proxy-agent@npm:4.0.1"
@@ -29899,6 +30270,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"https-proxy-agent@npm:7.0.2, https-proxy-agent@npm:^7.0.1":
+  version: 7.0.2
+  resolution: "https-proxy-agent@npm:7.0.2"
+  dependencies:
+    agent-base: ^7.0.2
+    debug: 4
+  checksum: 088969a0dd476ea7a0ed0a2cf1283013682b08f874c3bc6696c83fa061d2c157d29ef0ad3eb70a2046010bb7665573b2388d10fdcb3e410a66995e5248444292
+  languageName: node
+  linkType: hard
+
 "https-proxy-agent@npm:^5.0.1":
   version: 5.0.1
   resolution: "https-proxy-agent@npm:5.0.1"
@@ -29919,16 +30300,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"https-proxy-agent@npm:^7.0.1":
-  version: 7.0.2
-  resolution: "https-proxy-agent@npm:7.0.2"
-  dependencies:
-    agent-base: ^7.0.2
-    debug: 4
-  checksum: 088969a0dd476ea7a0ed0a2cf1283013682b08f874c3bc6696c83fa061d2c157d29ef0ad3eb70a2046010bb7665573b2388d10fdcb3e410a66995e5248444292
-  languageName: node
-  linkType: hard
-
 "https-proxy-agent@npm:^7.0.5":
   version: 7.0.6
   resolution: "https-proxy-agent@npm:7.0.6"
@@ -30070,6 +30441,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"ignore-walk@npm:^5.0.1":
+  version: 5.0.1
+  resolution: "ignore-walk@npm:5.0.1"
+  dependencies:
+    minimatch: ^5.0.1
+  checksum: 1a4ef35174653a1aa6faab3d9f8781269166536aee36a04946f6e2b319b2475c1903a75ed42f04219274128242f49d0a10e20c4354ee60d9548e97031451150b
+  languageName: node
+  linkType: hard
+
 "ignore@npm:^5.2.0":
   version: 5.2.0
   resolution: "ignore@npm:5.2.0"
@@ -30259,6 +30639,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"ini@npm:2.0.0":
+  version: 2.0.0
+  resolution: "ini@npm:2.0.0"
+  checksum: e7aadc5fb2e4aefc666d74ee2160c073995a4061556b1b5b4241ecb19ad609243b9cceafe91bae49c219519394bbd31512516cb22a3b1ca6e66d869e0447e84e
+  languageName: node
+  linkType: hard
+
 "ini@npm:~1.3.0":
   version: 1.3.8
   resolution: "ini@npm:1.3.8"
@@ -31084,7 +31471,14 @@ __metadata:
   languageName: node
   linkType: hard
 
-"is-path-inside@npm:^3.0.3":
+"is-path-cwd@npm:^2.2.0":
+  version: 2.2.0
+  resolution: "is-path-cwd@npm:2.2.0"
+  checksum: 46a840921bb8cc0dc7b5b423a14220e7db338072a4495743a8230533ce78812dc152548c86f4b828411fe98c5451959f07cf841c6a19f611e46600bd699e8048
+  languageName: node
+  linkType: hard
+
+"is-path-inside@npm:^3.0.2, is-path-inside@npm:^3.0.3":
   version: 3.0.3
   resolution: "is-path-inside@npm:3.0.3"
   checksum: abd50f06186a052b349c15e55b182326f1936c89a78bf6c8f2b707412517c097ce04bc49a0ca221787bc44e1049f51f09a2ffb63d22899051988d3a618ba13e9
@@ -31407,21 +31801,14 @@ __metadata:
   languageName: node
   linkType: hard
 
-"is-windows@npm:^1.0.0, is-windows@npm:^1.0.1":
+"is-windows@npm:1.0.2, is-windows@npm:^1.0.0, is-windows@npm:^1.0.1":
   version: 1.0.2
   resolution: "is-windows@npm:1.0.2"
   checksum: 438b7e52656fe3b9b293b180defb4e448088e7023a523ec21a91a80b9ff8cdb3377ddb5b6e60f7c7de4fa8b63ab56e121b6705fe081b3cf1b828b0a380009ad7
   languageName: node
   linkType: hard
 
-"is-wsl@npm:^1.1.0":
-  version: 1.1.0
-  resolution: "is-wsl@npm:1.1.0"
-  checksum: ea157d232351e68c92bd62fc541771096942fe72f69dff452dd26dcc31466258c570a3b04b8cda2e01cd2968255b02951b8670d08ea4ed76d6b1a646061ac4fe
-  languageName: node
-  linkType: hard
-
-"is-wsl@npm:^2.2.0":
+"is-wsl@npm:2.2.0, is-wsl@npm:^2.1.1, is-wsl@npm:^2.2.0":
   version: 2.2.0
   resolution: "is-wsl@npm:2.2.0"
   dependencies:
@@ -31430,6 +31817,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"is-wsl@npm:^1.1.0":
+  version: 1.1.0
+  resolution: "is-wsl@npm:1.1.0"
+  checksum: ea157d232351e68c92bd62fc541771096942fe72f69dff452dd26dcc31466258c570a3b04b8cda2e01cd2968255b02951b8670d08ea4ed76d6b1a646061ac4fe
+  languageName: node
+  linkType: hard
+
 "is-wsl@npm:^3.1.0":
   version: 3.1.0
   resolution: "is-wsl@npm:3.1.0"
@@ -32885,6 +33279,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"kysely@npm:^0.28.2":
+  version: 0.28.2
+  resolution: "kysely@npm:0.28.2"
+  checksum: 04ff6d8537aff9086c2a8003551a533e1e984a32a3ae65dce229eee828546176c1a0e487892d938ca1bccc5ccf7a8fb6aa36ac2980fce2be3772fd5b349086fe
+  languageName: node
+  linkType: hard
+
 "language-subtag-registry@npm:^0.3.20":
   version: 0.3.22
   resolution: "language-subtag-registry@npm:0.3.22"
@@ -32928,6 +33329,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"lazystream@npm:^1.0.0":
+  version: 1.0.1
+  resolution: "lazystream@npm:1.0.1"
+  dependencies:
+    readable-stream: ^2.0.5
+  checksum: 822c54c6b87701a6491c70d4fabc4cafcf0f87d6b656af168ee7bb3c45de9128a801cb612e6eeeefc64d298a7524a698dd49b13b0121ae50c2ae305f0dcc5310
+  languageName: node
+  linkType: hard
+
 "level-blobs@npm:^0.1.7":
   version: 0.1.7
   resolution: "level-blobs@npm:0.1.7"
@@ -33315,6 +33725,20 @@ __metadata:
   languageName: node
   linkType: hard
 
+"lodash.difference@npm:^4.5.0":
+  version: 4.5.0
+  resolution: "lodash.difference@npm:4.5.0"
+  checksum: ecee276aa578f300e79350805a14a51be8d1f12b3c1389a19996d8ab516f814211a5f65c68331571ecdad96522b863ccc484b55504ce8c9947212a29f8857d5a
+  languageName: node
+  linkType: hard
+
+"lodash.flatten@npm:^4.4.0":
+  version: 4.4.0
+  resolution: "lodash.flatten@npm:4.4.0"
+  checksum: 0ac34a393d4b795d4b7421153d27c13ae67e08786c9cbb60ff5b732210d46f833598eee3fb3844bb10070e8488efe390ea53bb567377e0cb47e9e630bf0811cb
+  languageName: node
+  linkType: hard
+
 "lodash.get@npm:^4.4.2, lodash.get@npm:~4.4.2":
   version: 4.4.2
   resolution: "lodash.get@npm:4.4.2"
@@ -33441,6 +33865,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"lodash.union@npm:^4.6.0":
+  version: 4.6.0
+  resolution: "lodash.union@npm:4.6.0"
+  checksum: 1514dc6508b2614ec071a6470f36eb7a70f69bf1abb6d55bdfdc21069635a4517783654b28504c0f025059a7598d37529766888e6d5902b8ab28b712228f7b2a
+  languageName: node
+  linkType: hard
+
 "lodash@npm:4.17.21, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:~4.17.0, lodash@npm:~4.17.15":
   version: 4.17.21
   resolution: "lodash@npm:4.17.21"
@@ -33822,6 +34253,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"make-dir@npm:4.0.0":
+  version: 4.0.0
+  resolution: "make-dir@npm:4.0.0"
+  dependencies:
+    semver: ^7.5.3
+  checksum: bf0731a2dd3aab4db6f3de1585cea0b746bb73eb5a02e3d8d72757e376e64e6ada190b1eddcde5b2f24a81b688a9897efd5018737d05e02e2a671dda9cff8a8a
+  languageName: node
+  linkType: hard
+
 "make-dir@npm:^3.0.0, make-dir@npm:^3.0.2":
   version: 3.1.0
   resolution: "make-dir@npm:3.1.0"
@@ -35003,7 +35443,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"minimatch@npm:^5.0.1":
+"minimatch@npm:^5.0.1, minimatch@npm:^5.1.0":
   version: 5.1.6
   resolution: "minimatch@npm:5.1.6"
   dependencies:
@@ -35812,6 +36252,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"new-github-issue-url@npm:0.2.1":
+  version: 0.2.1
+  resolution: "new-github-issue-url@npm:0.2.1"
+  checksum: 123c34296521353883ac7c43109a01a565a56fbd6d8e876db86978a74c798a9e1703180a77196b6abb5f608fd54c9853dda97a1eb43148ebebe7b0c89269f46d
+  languageName: node
+  linkType: hard
+
 "next-api-middleware@npm:^1.0.1":
   version: 1.0.1
   resolution: "next-api-middleware@npm:1.0.1"
@@ -36321,6 +36768,20 @@ __metadata:
   languageName: node
   linkType: hard
 
+"node-fetch@npm:2.6.12":
+  version: 2.6.12
+  resolution: "node-fetch@npm:2.6.12"
+  dependencies:
+    whatwg-url: ^5.0.0
+  peerDependencies:
+    encoding: ^0.1.0
+  peerDependenciesMeta:
+    encoding:
+      optional: true
+  checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592
+  languageName: node
+  linkType: hard
+
 "node-fetch@npm:2.6.7, node-fetch@npm:^2.6.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7":
   version: 2.6.7
   resolution: "node-fetch@npm:2.6.7"
@@ -36335,7 +36796,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"node-fetch@npm:^2.0.0, node-fetch@npm:^2.6.12, node-fetch@npm:^2.6.9, node-fetch@npm:^2.7.0":
+"node-fetch@npm:2.7.0, node-fetch@npm:^2.0.0, node-fetch@npm:^2.6.12, node-fetch@npm:^2.6.9, node-fetch@npm:^2.7.0":
   version: 2.7.0
   resolution: "node-fetch@npm:2.7.0"
   dependencies:
@@ -36721,6 +37182,36 @@ __metadata:
   languageName: node
   linkType: hard
 
+"npm-bundled@npm:^2.0.0":
+  version: 2.0.1
+  resolution: "npm-bundled@npm:2.0.1"
+  dependencies:
+    npm-normalize-package-bin: ^2.0.0
+  checksum: 7747293985c48c5268871efe691545b03731cb80029692000cbdb0b3344b9617be5187aa36281cabbe6b938e3651b4e87236d1c31f9e645eef391a1a779413e6
+  languageName: node
+  linkType: hard
+
+"npm-normalize-package-bin@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "npm-normalize-package-bin@npm:2.0.0"
+  checksum: 7c5379f9b188b564c4332c97bdd9a5d6b7b15f02b5823b00989d6a0e6fb31eb0280f02b0a924f930e1fcaf00e60fae333aec8923d2a4c7747613c7d629d8aa25
+  languageName: node
+  linkType: hard
+
+"npm-packlist@npm:5.1.3":
+  version: 5.1.3
+  resolution: "npm-packlist@npm:5.1.3"
+  dependencies:
+    glob: ^8.0.1
+    ignore-walk: ^5.0.1
+    npm-bundled: ^2.0.0
+    npm-normalize-package-bin: ^2.0.0
+  bin:
+    npm-packlist: bin/index.js
+  checksum: 94cc9c66740e8f80243301de85eb0a2cec5bbd570c3f26b6ad7af1a3eca155f7e810580dc7ea4448f12a8fd82f6db307e7132a5fe69e157eb45b325acadeb22a
+  languageName: node
+  linkType: hard
+
 "npm-run-all@npm:^4.1.5":
   version: 4.1.5
   resolution: "npm-run-all@npm:4.1.5"
@@ -37295,6 +37786,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"open@npm:7.4.2":
+  version: 7.4.2
+  resolution: "open@npm:7.4.2"
+  dependencies:
+    is-docker: ^2.0.0
+    is-wsl: ^2.1.1
+  checksum: 3333900ec0e420d64c23b831bc3467e57031461d843c801f569b2204a1acc3cd7b3ec3c7897afc9dde86491dfa289708eb92bba164093d8bd88fb2c231843c91
+  languageName: node
+  linkType: hard
+
 "open@npm:8.4.0, open@npm:^8.4.0":
   version: 8.4.0
   resolution: "open@npm:8.4.0"
@@ -37478,7 +37979,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"p-filter@npm:^2.1.0":
+"p-filter@npm:2.1.0, p-filter@npm:^2.1.0":
   version: 2.1.0
   resolution: "p-filter@npm:2.1.0"
   dependencies:
@@ -37566,14 +38067,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"p-map@npm:^2.0.0":
-  version: 2.1.0
-  resolution: "p-map@npm:2.1.0"
-  checksum: 9e3ad3c9f6d75a5b5661bcad78c91f3a63849189737cd75e4f1225bf9ac205194e5c44aac2ef6f09562b1facdb9bd1425584d7ac375bfaa17b3f1a142dab936d
-  languageName: node
-  linkType: hard
-
-"p-map@npm:^4.0.0":
+"p-map@npm:4.0.0, p-map@npm:^4.0.0":
   version: 4.0.0
   resolution: "p-map@npm:4.0.0"
   dependencies:
@@ -37582,6 +38076,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"p-map@npm:^2.0.0":
+  version: 2.1.0
+  resolution: "p-map@npm:2.1.0"
+  checksum: 9e3ad3c9f6d75a5b5661bcad78c91f3a63849189737cd75e4f1225bf9ac205194e5c44aac2ef6f09562b1facdb9bd1425584d7ac375bfaa17b3f1a142dab936d
+  languageName: node
+  linkType: hard
+
 "p-queue@npm:6.6.2":
   version: 6.6.2
   resolution: "p-queue@npm:6.6.2"
@@ -37592,6 +38093,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"p-retry@npm:4.6.2":
+  version: 4.6.2
+  resolution: "p-retry@npm:4.6.2"
+  dependencies:
+    "@types/retry": 0.12.0
+    retry: ^0.13.1
+  checksum: 45c270bfddaffb4a895cea16cb760dcc72bdecb6cb45fef1971fa6ea2e91ddeafddefe01e444ac73e33b1b3d5d29fb0dd18a7effb294262437221ddc03ce0f2e
+  languageName: node
+  linkType: hard
+
 "p-timeout@npm:^3.2.0":
   version: 3.2.0
   resolution: "p-timeout@npm:3.2.0"
@@ -38087,6 +38598,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"pg-cloudflare@npm:^1.2.5":
+  version: 1.2.5
+  resolution: "pg-cloudflare@npm:1.2.5"
+  checksum: 1d10b067f71f678975441dc63d318dd4307ce1ca5780ceb9fdb0eea3986cdc80ec09612847e7022d74548d6cc0f4eea75b76d8d763aa94a1ec29869fbf1b1ee1
+  languageName: node
+  linkType: hard
+
 "pg-connection-string@npm:^2.7.0":
   version: 2.7.0
   resolution: "pg-connection-string@npm:2.7.0"
@@ -38094,6 +38612,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"pg-connection-string@npm:^2.8.5":
+  version: 2.8.5
+  resolution: "pg-connection-string@npm:2.8.5"
+  checksum: 436d0d30d6a2f1671c48ed2861499dcc9b4232dc308b9d84ba53fb651a0ab6c8a89c1f6bb8d99ac35837e0b6215d33ccb704f09cb298862bfaf82987611022d9
+  languageName: node
+  linkType: hard
+
 "pg-int8@npm:1.0.1":
   version: 1.0.1
   resolution: "pg-int8@npm:1.0.1"
@@ -38117,6 +38642,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"pg-pool@npm:^3.9.6":
+  version: 3.9.6
+  resolution: "pg-pool@npm:3.9.6"
+  peerDependencies:
+    pg: ">=8.0"
+  checksum: d674211a510d209ac534e6b1085ddff7394f4031dbd961dfd232a9897af0fce5f0390cf0700376567ff02c8f6adbdc1157b07415f6fe9edb83b88c4bc2d732c6
+  languageName: node
+  linkType: hard
+
 "pg-protocol@npm:*":
   version: 1.6.0
   resolution: "pg-protocol@npm:1.6.0"
@@ -38131,6 +38665,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"pg-protocol@npm:^1.9.5":
+  version: 1.9.5
+  resolution: "pg-protocol@npm:1.9.5"
+  checksum: 192ec9c3f7f3534104bf07efdc38726a6bdce38bd7cd17e115691eed8e3224c70660bfc4416b4cdfc99709c862cda9df587881ea57ff1b831a6e60430e9fbfab
+  languageName: node
+  linkType: hard
+
 "pg-types@npm:^2.1.0, pg-types@npm:^2.2.0":
   version: 2.2.0
   resolution: "pg-types@npm:2.2.0"
@@ -38181,6 +38722,28 @@ __metadata:
   languageName: node
   linkType: hard
 
+"pg@npm:^8.11.3":
+  version: 8.15.6
+  resolution: "pg@npm:8.15.6"
+  dependencies:
+    pg-cloudflare: ^1.2.5
+    pg-connection-string: ^2.8.5
+    pg-pool: ^3.9.6
+    pg-protocol: ^1.9.5
+    pg-types: ^2.1.0
+    pgpass: 1.x
+  peerDependencies:
+    pg-native: ">=3.0.1"
+  dependenciesMeta:
+    pg-cloudflare:
+      optional: true
+  peerDependenciesMeta:
+    pg-native:
+      optional: true
+  checksum: 8610219cf793c100908f2f036838b1565c9270fca09b972b101dd36c2b1d3c6f9793352a0cda67b3a67e26820c5df1082b5aff5729379d4fc9e3701806e6cbf3
+  languageName: node
+  linkType: hard
+
 "pgpass@npm:1.x":
   version: 1.0.5
   resolution: "pgpass@npm:1.0.5"
@@ -38942,6 +39505,21 @@ __metadata:
   languageName: node
   linkType: hard
 
+"prisma-kysely@npm:^1.7.1":
+  version: 1.8.0
+  resolution: "prisma-kysely@npm:1.8.0"
+  dependencies:
+    "@mrleebo/prisma-ast": ^0.7.0
+    "@prisma/generator-helper": 5.3.1
+    "@prisma/internals": 5.3.1
+    typescript: ^5.2.2
+    zod: ^3.22.2
+  bin:
+    prisma-kysely: dist/bin.js
+  checksum: 98ecddf04e68056bc8da2487062cb067410361dbcab75013c01cfb6ea05970b75b0c552d637d35d5b89fe72265da48416a67efc814d22e0f1c80c949d94b87d3
+  languageName: node
+  linkType: hard
+
 "prisma@npm:^5.4.2":
   version: 5.4.2
   resolution: "prisma@npm:5.4.2"
@@ -39021,7 +39599,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"progress@npm:^2.0.3":
+"progress@npm:2.0.3, progress@npm:^2.0.3":
   version: 2.0.3
   resolution: "progress@npm:2.0.3"
   checksum: f67403fe7b34912148d9252cb7481266a354bd99ce82c835f79070643bb3c6583d10dbcfda4d41e04bbc1d8437e9af0fb1e1f2135727878f5308682a579429b7
@@ -40239,7 +40817,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"read-pkg-up@npm:^7.0.1":
+"read-pkg-up@npm:7.0.1, read-pkg-up@npm:^7.0.1":
   version: 7.0.1
   resolution: "read-pkg-up@npm:7.0.1"
   dependencies:
@@ -40297,9 +40875,9 @@ __metadata:
   languageName: node
   linkType: hard
 
-"readable-stream@npm:^2.0.5, readable-stream@npm:^2.2.2":
-  version: 2.3.7
-  resolution: "readable-stream@npm:2.3.7"
+"readable-stream@npm:^2.0.0, readable-stream@npm:^2.1.0":
+  version: 2.3.8
+  resolution: "readable-stream@npm:2.3.8"
   dependencies:
     core-util-is: ~1.0.0
     inherits: ~2.0.3
@@ -40308,13 +40886,13 @@ __metadata:
     safe-buffer: ~5.1.1
     string_decoder: ~1.1.1
     util-deprecate: ~1.0.1
-  checksum: e4920cf7549a60f8aaf694d483a0e61b2a878b969d224f89b3bc788b8d920075132c4b55a7494ee944c7b6a9a0eada28a7f6220d80b0312ece70bbf08eeca755
+  checksum: 65645467038704f0c8aaf026a72fbb588a9e2ef7a75cd57a01702ee9db1c4a1e4b03aaad36861a6a0926546a74d174149c8c207527963e0c2d3eee2f37678a42
   languageName: node
   linkType: hard
 
-"readable-stream@npm:^2.1.0":
-  version: 2.3.8
-  resolution: "readable-stream@npm:2.3.8"
+"readable-stream@npm:^2.0.5, readable-stream@npm:^2.2.2":
+  version: 2.3.7
+  resolution: "readable-stream@npm:2.3.7"
   dependencies:
     core-util-is: ~1.0.0
     inherits: ~2.0.3
@@ -40323,7 +40901,7 @@ __metadata:
     safe-buffer: ~5.1.1
     string_decoder: ~1.1.1
     util-deprecate: ~1.0.1
-  checksum: 65645467038704f0c8aaf026a72fbb588a9e2ef7a75cd57a01702ee9db1c4a1e4b03aaad36861a6a0926546a74d174149c8c207527963e0c2d3eee2f37678a42
+  checksum: e4920cf7549a60f8aaf694d483a0e61b2a878b969d224f89b3bc788b8d920075132c4b55a7494ee944c7b6a9a0eada28a7f6220d80b0312ece70bbf08eeca755
   languageName: node
   linkType: hard
 
@@ -40374,6 +40952,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"readdir-glob@npm:^1.1.2":
+  version: 1.1.3
+  resolution: "readdir-glob@npm:1.1.3"
+  dependencies:
+    minimatch: ^5.1.0
+  checksum: 1dc0f7440ff5d9378b593abe9d42f34ebaf387516615e98ab410cf3a68f840abbf9ff1032d15e0a0dbffa78f9e2c46d4fafdbaac1ca435af2efe3264e3f21874
+  languageName: node
+  linkType: hard
+
 "readdirp@npm:^4.0.1":
   version: 4.1.2
   resolution: "readdirp@npm:4.1.2"
@@ -40869,6 +41456,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"replace-string@npm:3.1.0":
+  version: 3.1.0
+  resolution: "replace-string@npm:3.1.0"
+  checksum: 39eebbb8ec24220bdd44677708989895ccf0628388e283232a78fb2ef72097084dd603ce354e5105a819c517f01e040539419275f0deecfc6be9e9d398969f71
+  languageName: node
+  linkType: hard
+
 "request@npm:^2.72.0":
   version: 2.88.2
   resolution: "request@npm:2.88.2"
@@ -40973,6 +41567,19 @@ __metadata:
   languageName: node
   linkType: hard
 
+"resolve@npm:1.22.4":
+  version: 1.22.4
+  resolution: "resolve@npm:1.22.4"
+  dependencies:
+    is-core-module: ^2.13.0
+    path-parse: ^1.0.7
+    supports-preserve-symlinks-flag: ^1.0.0
+  bin:
+    resolve: bin/resolve
+  checksum: 23f25174c2736ce24c6d918910e0d1f89b6b38fefa07a995dff864acd7863d59a7f049e691f93b4b2ee29696303390d921552b6d1b841ed4a8101f517e1d0124
+  languageName: node
+  linkType: hard
+
 "resolve@npm:1.22.8, resolve@npm:^1.1.6, resolve@npm:^1.17.0, resolve@npm:^1.22.2, resolve@npm:^1.22.4, resolve@npm:~1.22.1":
   version: 1.22.8
   resolution: "resolve@npm:1.22.8"
@@ -41058,6 +41665,19 @@ __metadata:
   languageName: node
   linkType: hard
 
+"resolve@patch:resolve@1.22.4#~builtin<compat/resolve>":
+  version: 1.22.4
+  resolution: "resolve@patch:resolve@npm%3A1.22.4#~builtin<compat/resolve>::version=1.22.4&hash=c3c19d"
+  dependencies:
+    is-core-module: ^2.13.0
+    path-parse: ^1.0.7
+    supports-preserve-symlinks-flag: ^1.0.0
+  bin:
+    resolve: bin/resolve
+  checksum: c45f2545fdc4d21883861b032789e20aa67a2f2692f68da320cc84d5724cd02f2923766c5354b3210897e88f1a7b3d6d2c7c22faeead8eed7078e4c783a444bc
+  languageName: node
+  linkType: hard
+
 "resolve@patch:resolve@1.22.8#~builtin<compat/resolve>, resolve@patch:resolve@^1.1.6#~builtin<compat/resolve>, resolve@patch:resolve@^1.17.0#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.2#~builtin<compat/resolve>, resolve@patch:resolve@^1.22.4#~builtin<compat/resolve>, resolve@patch:resolve@~1.22.1#~builtin<compat/resolve>":
   version: 1.22.8
   resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin<compat/resolve>::version=1.22.8&hash=c3c19d"
@@ -41198,6 +41818,17 @@ __metadata:
   languageName: node
   linkType: hard
 
+"rimraf@npm:3.0.2, rimraf@npm:^3.0.0, rimraf@npm:^3.0.2":
+  version: 3.0.2
+  resolution: "rimraf@npm:3.0.2"
+  dependencies:
+    glob: ^7.1.3
+  bin:
+    rimraf: bin.js
+  checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0
+  languageName: node
+  linkType: hard
+
 "rimraf@npm:4.4.1":
   version: 4.4.1
   resolution: "rimraf@npm:4.4.1"
@@ -41209,17 +41840,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"rimraf@npm:^3.0.2":
-  version: 3.0.2
-  resolution: "rimraf@npm:3.0.2"
-  dependencies:
-    glob: ^7.1.3
-  bin:
-    rimraf: bin.js
-  checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0
-  languageName: node
-  linkType: hard
-
 "ripemd160@npm:2.0.2, ripemd160@npm:^2.0.0, ripemd160@npm:^2.0.1":
   version: 2.0.2
   resolution: "ripemd160@npm:2.0.2"
@@ -43270,7 +43890,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.0.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.2, string-width@npm:^4.2.3":
+"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:4.2.3, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.0.0, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.2, string-width@npm:^4.2.3":
   version: 4.2.3
   resolution: "string-width@npm:4.2.3"
   dependencies:
@@ -43602,7 +44222,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"strip-indent@npm:^3.0.0":
+"strip-indent@npm:3.0.0, strip-indent@npm:^3.0.0":
   version: 3.0.0
   resolution: "strip-indent@npm:3.0.0"
   dependencies:
@@ -43861,7 +44481,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"supports-hyperlinks@npm:^2.2.0":
+"supports-hyperlinks@npm:^2.0.0, supports-hyperlinks@npm:^2.2.0":
   version: 2.3.0
   resolution: "supports-hyperlinks@npm:2.3.0"
   dependencies:
@@ -44178,7 +44798,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"tar-stream@npm:^2.1.4":
+"tar-stream@npm:^2.1.4, tar-stream@npm:^2.2.0":
   version: 2.2.0
   resolution: "tar-stream@npm:2.2.0"
   dependencies:
@@ -44253,6 +44873,26 @@ __metadata:
   languageName: node
   linkType: hard
 
+"temp-dir@npm:2.0.0, temp-dir@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "temp-dir@npm:2.0.0"
+  checksum: cc4f0404bf8d6ae1a166e0e64f3f409b423f4d1274d8c02814a59a5529f07db6cd070a749664141b992b2c1af337fa9bb451a460a43bb9bcddc49f235d3115aa
+  languageName: node
+  linkType: hard
+
+"tempy@npm:1.0.1":
+  version: 1.0.1
+  resolution: "tempy@npm:1.0.1"
+  dependencies:
+    del: ^6.0.0
+    is-stream: ^2.0.0
+    temp-dir: ^2.0.0
+    type-fest: ^0.16.0
+    unique-string: ^2.0.0
+  checksum: e77ca4440af18e42dc64d8903b7ed0be673455b76680ff94a7d7c6ee7c16f7604bdcdee3c39436342b1082c23eda010dbe48f6094e836e0bd53c8b1aa63e5b95
+  languageName: node
+  linkType: hard
+
 "term-size@npm:^2.1.0":
   version: 2.2.1
   resolution: "term-size@npm:2.2.1"
@@ -44267,6 +44907,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"terminal-link@npm:2.1.1":
+  version: 2.1.1
+  resolution: "terminal-link@npm:2.1.1"
+  dependencies:
+    ansi-escapes: ^4.2.1
+    supports-hyperlinks: ^2.0.0
+  checksum: ce3d2cd3a438c4a9453947aa664581519173ea40e77e2534d08c088ee6dda449eabdbe0a76d2a516b8b73c33262fedd10d5270ccf7576ae316e3db170ce6562f
+  languageName: node
+  linkType: hard
+
 "terser-webpack-plugin@npm:^5.3.10":
   version: 5.3.10
   resolution: "terser-webpack-plugin@npm:5.3.10"
@@ -44555,6 +45205,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"tmp@npm:0.2.1":
+  version: 0.2.1
+  resolution: "tmp@npm:0.2.1"
+  dependencies:
+    rimraf: ^3.0.0
+  checksum: 8b1214654182575124498c87ca986ac53dc76ff36e8f0e0b67139a8d221eaecfdec108c0e6ec54d76f49f1f72ab9325500b246f562b926f85bcdfca8bf35df9e
+  languageName: node
+  linkType: hard
+
 "tmp@npm:^0.0.33":
   version: 0.0.33
   resolution: "tmp@npm:0.0.33"
@@ -44951,6 +45610,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"ts-pattern@npm:4.3.0":
+  version: 4.3.0
+  resolution: "ts-pattern@npm:4.3.0"
+  checksum: f5167f6f721212c1e22f8590bb1fc21e27fd591d6fc5af0e467778f8e5b2dc1ae490cf5c633c83a3021a61283a671a53faf250b081c17c0f025e73eb775e5fe3
+  languageName: node
+  linkType: hard
+
 "tsc-absolute@npm:^1.0.0":
   version: 1.0.0
   resolution: "tsc-absolute@npm:1.0.0"
@@ -45290,6 +45956,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"type-fest@npm:^0.16.0":
+  version: 0.16.0
+  resolution: "type-fest@npm:0.16.0"
+  checksum: 1a4102c06dc109db00418c753062e206cab65befd469d000ece4452ee649bf2a9cf57686d96fb42326bc9d918d9a194d4452897b486dcc41989e5c99e4e87094
+  languageName: node
+  linkType: hard
+
 "type-fest@npm:^0.18.0":
   version: 0.18.1
   resolution: "type-fest@npm:0.18.1"
@@ -45332,7 +46005,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"type-fest@npm:^0.8.1":
+"type-fest@npm:^0.8.0, type-fest@npm:^0.8.1":
   version: 0.8.1
   resolution: "type-fest@npm:0.8.1"
   checksum: d61c4b2eba24009033ae4500d7d818a94fd6d1b481a8111612ee141400d5f1db46f199c014766b9fa9b31a6a7374d96fc748c6d688a78a3ce5a33123839becb7
@@ -45652,6 +46325,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"typescript@npm:^5.2.2":
+  version: 5.8.3
+  resolution: "typescript@npm:5.8.3"
+  bin:
+    tsc: bin/tsc
+    tsserver: bin/tsserver
+  checksum: cb1d081c889a288b962d3c8ae18d337ad6ee88a8e81ae0103fa1fecbe923737f3ba1dbdb3e6d8b776c72bc73bfa6d8d850c0306eed1a51377d2fccdfd75d92c4
+  languageName: node
+  linkType: hard
+
 "typescript@patch:typescript@5.3.3#~builtin<compat/typescript>":
   version: 5.3.3
   resolution: "typescript@patch:typescript@npm%3A5.3.3#~builtin<compat/typescript>::version=5.3.3&hash=1f5320"
@@ -45682,6 +46365,16 @@ __metadata:
   languageName: node
   linkType: hard
 
+"typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
+  version: 5.8.3
+  resolution: "typescript@patch:typescript@npm%3A5.8.3#~builtin<compat/typescript>::version=5.8.3&hash=1f5320"
+  bin:
+    tsc: bin/tsc
+    tsserver: bin/tsserver
+  checksum: 1b503525a88ff0ff5952e95870971c4fb2118c17364d60302c21935dedcd6c37e6a0a692f350892bafcef6f4a16d09073fe461158547978d2f16fbe4cb18581c
+  languageName: node
+  linkType: hard
+
 "tzdata@npm:^1.0.30":
   version: 1.0.40
   resolution: "tzdata@npm:1.0.40"
@@ -45852,6 +46545,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"unique-string@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "unique-string@npm:2.0.0"
+  dependencies:
+    crypto-random-string: ^2.0.0
+  checksum: ef68f639136bcfe040cf7e3cd7a8dff076a665288122855148a6f7134092e6ed33bf83a7f3a9185e46c98dddc445a0da6ac25612afa1a7c38b8b654d6c02498e
+  languageName: node
+  linkType: hard
+
 "unist-util-is@npm:^6.0.0":
   version: 6.0.0
   resolution: "unist-util-is@npm:6.0.0"
@@ -47916,6 +48618,17 @@ __metadata:
   languageName: node
   linkType: hard
 
+"zip-stream@npm:^4.1.0":
+  version: 4.1.1
+  resolution: "zip-stream@npm:4.1.1"
+  dependencies:
+    archiver-utils: ^3.0.4
+    compress-commons: ^4.1.2
+    readable-stream: ^3.6.0
+  checksum: 33bd5ee7017656c2ad728b5d4ba510e15bd65ce1ec180c5bbdc7a5f063256353ec482e6a2bc74de7515219d8494147924b9aae16e63fdaaf37cdf7d1ee8df125
+  languageName: node
+  linkType: hard
+
 "zod-error@npm:^1.5.0":
   version: 1.5.0
   resolution: "zod-error@npm:1.5.0"
@@ -47961,6 +48674,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"zod@npm:^3.22.2":
+  version: 3.24.4
+  resolution: "zod@npm:3.24.4"
+  checksum: 62829789765a9187bd72bed3972a7c1a39fdfe6c59bc752eedabec5f99af701658471b8577d22e0fee2081e6e35d4efc93c02c90e13350755a36feadbf72bbbc
+  languageName: node
+  linkType: hard
+
 "zod@npm:^3.24.1, zod@npm:^3.24.2":
   version: 3.24.2
   resolution: "zod@npm:3.24.2"


Reviews:
user: login: cubic-dev-ai[bot]
body: mrge found 8 issues across 10 files. View them in [mrge.io](https://mrge.io/pr/calcom/cal.com/pull/21084)
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T14:03:18Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:19:10Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:19:37Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:20:05Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:20:08Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:22:17Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:23:28Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:26:00Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:26:09Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:27:10Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T19:44:09Z
user: login: cubic-dev-ai[bot]
body: mrge found 7 issues across 10 files. View them in [mrge.io](https://mrge.io/pr/calcom/cal.com/pull/21084)
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T09:54:12Z
user: login: ThyMinimalDev
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T09:57:26Z
user: login: keithwillcode
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T14:55:21Z
user: login: cubic-dev-ai[bot]
body: mrge found 11 issues across 19 files. View them in [mrge.io](https://mrge.io/pr/calcom/cal.com/pull/21084)
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T18:31:47Z
user: login: keithwillcode
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T19:35:38Z
user: login: zomars
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-05T21:52:38Z
user: login: zomars
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-06T00:21:14Z

Review comments:
diff_hunk: @@ -375,6 +527,13 @@ export async function getBookings({
     }),
   ]);
 
+  const queryUnion = queriesWithFilters.reduce((acc, query) => {
+    return acc.union(query);
+  });
+
+  const bookingsWithKysely = await queryUnion.execute();
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll analyze the changed code for violations of the \"Enforce Singular Naming for Single-Item Functions\" rule. Let me examine the code carefully.\n\nFirst, I'll look at the new functions and their naming patterns in the changed code to identify any violations.","toolCalls":[{"args":{"pattern":"packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try a broader pattern to find the file:","toolCalls":[{"args":{"pattern":"**/get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try to find the file using a more general pattern:","toolCalls":[{"args":{"pattern":"**/*bookings*"},"toolName":"listFiles"}]},{"text":"Let me try to find the specific file using a more targeted pattern:","toolCalls":[{"args":{"command":"find . -name \"get.handler.ts\" | grep -i bookings"},"toolName":"executeCommand"}]},{"text":"Now I'll examine the file content to identify any violations:","toolCalls":[{"args":{"command":"grep -n \"function\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Now I'll analyze the newly added code to identify any function naming violations:","toolCalls":[{"args":{"command":"grep -n \"bookingQueries\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the newly added functions in the code:","toolCalls":[{"args":{"command":"grep -n \"queryUnion\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Enforce Singular Naming for Single-Item Functions**
      
      Variable name 'bookingsWithKysely' uses plural form but appears to store a single query result
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,21 @@
+import { Kysely, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
+
+export type { DB, Booking };
+const dialect = new PostgresDialect({
+  pool: new Pool({
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":10,"steps":[]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Database credentials are hardcoded directly in the source code
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -375,6 +527,13 @@
     }),
   ]);
 
+  const queryUnion = queriesWithFilters.reduce((acc, query) => {
+    return acc.union(query);
+  });
+
+  const bookingsWithKysely = await queryUnion.execute();
+  console.log({ bookingsWithKysely }, { plainBookings });
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":10,"steps":[{"text":"I'll analyze the changed code for any violations of the \"Avoid Logging Sensitive Information\" rule, focusing only on the added lines (starting with +).\n\nLet me examine the code carefully to identify any instances where sensitive information might be logged.","toolCalls":[{"args":{"command":"grep -r \"console.log\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"I found a console.log statement in the changed code that could potentially expose sensitive information. Let me check what data is being logged:","toolCalls":[{"args":{"pattern":"packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try with a broader pattern:","toolCalls":[{"args":{"pattern":"**/*get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try to find the file another way:","toolCalls":[{"args":{"command":"find . -name \"get.handler.ts\""},"toolName":"executeCommand"}]},{"text":"Now let's examine the content of the bookings get.handler.ts file:","toolCalls":[{"args":{"command":"grep -A 5 -B 5 \"console.log\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let's check what data is contained in the `bookingsWithKysely` and `plainBookings` variables:","toolCalls":[{"args":{"command":"grep -A 20 \"const bookingSelect\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let's check more of the booking selection to understand what data might be logged:","toolCalls":[{"args":{"command":"grep -A 50 \"const bookingSelect\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let's check more of the booking selection:","toolCalls":[{"args":{"command":"grep -A 50 -B 0 \"currency: true,\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let's also check what data is in the `bookingsWithKysely` variable:","toolCalls":[{"args":{"command":"grep -A 10 -B 10 \"const bookingsWithKysely\" ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Logging sensitive booking information that contains PII
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -19,6 +19,12 @@ generator zod {
   relationModel = "default"
 }
 
+generator kysely {
+  provider = "prisma-kysely"
+  output   = "../kysely"
+  fileName = "types.ts"
path: packages/prisma/schema.prisma
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":7,"steps":[{"text":"I'll review the changed lines in the Prisma schema file to identify any potential issues or violations.","toolCalls":[{"args":{"pattern":"packages/kysely/**"},"toolName":"listFiles"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"kysely\" packages/"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"pattern":"packages/kysely/index.ts"},"toolName":"listFiles"}]},{"text":"","toolCalls":[{"args":{"command":"mkdir -p packages/kysely && touch packages/kysely/index.ts"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"get bookings\" packages/"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"cat packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Ensure types.ts is properly imported and exported in the kysely package index file
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -19,6 +19,12 @@
   relationModel = "default"
 }
 
+generator kysely {
+  provider = "prisma-kysely"
+  output   = "../kysely"
path: packages/prisma/schema.prisma
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll review the changed lines in the Prisma schema file to identify any potential issues or violations.","toolCalls":[{"args":{"pattern":"packages/kysely/**"},"toolName":"listFiles"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"kysely\" packages/"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"pattern":"packages/kysely/index.ts"},"toolName":"listFiles"}]},{"text":"","toolCalls":[{"args":{"command":"mkdir -p packages/kysely && touch packages/kysely/index.ts"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"get bookings\" packages/"},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"cat packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Ensure the output directory exists before running Prisma generate to avoid build failures
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,6 +1,6 @@
 {
   "name": "@calcom/platform-libraries",
-  "version": "0.0.0",
+  "version": "9.9.9",
path: packages/platform/libraries/package.json
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll review the changed lines in the PR for any issues, focusing on the version change in `packages/platform/libraries/package.json`. Let me analyze this change.","toolCalls":[{"args":{"command":"grep -r \"version\" packages/platform/libraries/package.json"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files that might reference this version number or if there's a standard versioning pattern in the project:","toolCalls":[{"args":{"command":"grep -r \"version\" --include=\"package.json\" | head -n 20"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any scripts or workflows that might be affected by this version change:","toolCalls":[{"args":{"command":"grep -r \"platform-libraries.*version\" --include=\"*.js\" --include=\"*.ts\" --include=\"*.yml\" | head -n 10"},"toolName":"executeCommand"}]},{"text":"Let me check the prepublish script to understand how versioning is handled:","toolCalls":[{"args":{"command":"cat packages/platform/libraries/scripts/prepublish.js"},"toolName":"executeCommand"}]},{"text":"Let me also check the publish script to understand the workflow:","toolCalls":[{"args":{"command":"cat packages/platform/libraries/scripts/postpublish.js"},"toolName":"executeCommand"}]}]} -->
Manually setting version to "9.9.9" breaks the automated versioning workflow
created_at: 2025-05-02T14:03:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,21 @@
+import { Kysely, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
+
+export type { DB, Booking };
+const dialect = new PostgresDialect({
+  pool: new Pool({
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":10,"steps":[{"text":"I'll review the changed lines in `packages/kysely/index.ts` for potential issues, focusing on the lines starting with '+'. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"packages/kysely/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if the types file exists in a different location:","toolCalls":[{"args":{"pattern":"**/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there's a types file specifically for kysely:","toolCalls":[{"args":{"pattern":"packages/kysely/**/*.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files in the kysely directory:","toolCalls":[{"args":{"pattern":"**/kysely/**"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files with \"kysely\" in their name:","toolCalls":[{"args":{"pattern":"**/*kysely*/**"},"toolName":"listFiles"}]},{"text":"Let me check if there are any files that might contain database configuration:","toolCalls":[{"args":{"command":"grep -r \"database:\" --include=\"*.ts\" --include=\"*.js\" ."},"toolName":"executeCommand"}]},{"text":"Let me check for environment variables related to database configuration:","toolCalls":[{"args":{"command":"grep -r \"DATABASE_URL\" --include=\"*.ts\" --include=\"*.js\" --include=\"*.env*\" ."},"toolName":"executeCommand"}]}]} -->
Database credentials are hardcoded instead of using environment variables.
created_at: 2025-05-02T14:03:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,21 @@
+import { Kysely, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
+
+export type { DB, Booking };
+const dialect = new PostgresDialect({
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll review the changed lines in `packages/kysely/index.ts` for potential issues, focusing on the lines starting with '+'. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"packages/kysely/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if the types file exists in a different location:","toolCalls":[{"args":{"pattern":"**/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there's a types file specifically for kysely:","toolCalls":[{"args":{"pattern":"packages/kysely/**/*.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files in the kysely directory:","toolCalls":[{"args":{"pattern":"**/kysely/**"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files with \"kysely\" in their name:","toolCalls":[{"args":{"pattern":"**/*kysely*/**"},"toolName":"listFiles"}]},{"text":"Let me check if there are any files that might contain database configuration:","toolCalls":[{"args":{"command":"grep -r \"database:\" --include=\"*.ts\" --include=\"*.js\" ."},"toolName":"executeCommand"}]},{"text":"Let me check for environment variables related to database configuration:","toolCalls":[{"args":{"command":"grep -r \"DATABASE_URL\" --include=\"*.ts\" --include=\"*.js\" --include=\"*.env*\" ."},"toolName":"executeCommand"}]}]} -->
Database connection configuration is not exported, making it difficult to configure for different environments.
created_at: 2025-05-02T14:03:18Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeName.data.operand);
+      }
+    }
+
+    // TODO: convert bookingListingFilters for kysely
+    query.where((eb) => eb("Booking.status", "=", "accepted").or("Booking.status", "=", "cancelled"));
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: this needs to be replaced with proper filters extracted from `passedBookingsStatusFilter`
created_at: 2025-05-02T19:19:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeName.data.operand);
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: handle complex filters like makeWhereClause function do
created_at: 2025-05-02T19:19:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: this will require this plugin to be added to the query https://kysely.dev/docs/recipes/deduplicate-joins
created_at: 2025-05-02T19:20:04Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        query
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: this will require this plugin to be added to the query https://kysely.dev/docs/recipes/deduplicate-joins
created_at: 2025-05-02T19:20:08Z
author_association: CONTRIBUTOR
diff_hunk: @@ -221,10 +226,33 @@ export async function getBookings({
 
     // 1. Booking created by one of the filtered users
     orConditions.push({ userId: usersFilter });
+    bookingQueries.push(
+      kysely.selectFrom("Booking").selectAll("Booking").where("userId", "in", filters.userIds)
+    );
     // 2. Attendee email matches one of the filtered users' emails
     orConditions.push({ attendees: { some: { email: attendeesEmailFilter } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .selectAll("Booking")
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: convert bookingSelect used in prisma in order to select only the required fields everywhere 
created_at: 2025-05-02T19:22:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeName.data.operand);
+      }
+    }
+
+    // TODO: convert bookingListingFilters for kysely
+    query.where((eb) => eb("Booking.status", "=", "accepted").or("Booking.status", "=", "cancelled"));
+
+    if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
+      query.where("Booking.eventTypeId", "in", eventTypeIdsFromTeamIdsFilter);
+    }
+
+    if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
+      query.where("Booking.eventTypeId", "in", eventTypeIdsFromEventTypeIdsFilter);
+    }
+
+    return query;
+  });
+
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: handle !hasAnyDateFilter case below with kysely too
created_at: 2025-05-02T19:23:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        query
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: `query.withPlugin(new DeduplicateJoinsPlugin())...`
created_at: 2025-05-02T19:26:00Z
author_association: CONTRIBUTOR
diff_hunk: @@ -335,6 +413,54 @@ export async function getBookings({
     andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
   }
 
+  const queriesWithFilters = bookingQueries.map((query) => {
+    if (filters?.afterStartDate) {
+      query.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      query.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
+    }
+    if (filters?.afterUpdatedDate) {
+      query.where("Booking.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate());
+    }
+    if (filters?.beforeUpdatedDate) {
+      query.where("Booking.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate());
+    }
+    if (filters?.afterCreatedDate) {
+      query.where("Booking.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate());
+    }
+    if (filters?.beforeCreatedDate) {
+      query.where("Booking.createdAt", "<=", dayjs.utc(filters.beforeCreatedDate).toDate());
+    }
+
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        query
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: query.withPlugin(new DeduplicateJoinsPlugin())...
created_at: 2025-05-02T19:26:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,21 @@
+import { Kysely, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
+
+export type { DB, Booking };
+const dialect = new PostgresDialect({
+  pool: new Pool({
+    database: "calendso",
+    host: "localhost",
+    user: "postgres",
+    password: "postgres",
+    port: 5450,
path: packages/kysely/index.ts
user: login: ThyMinimalDev
body: need environment variables
created_at: 2025-05-02T19:27:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,6 +1,6 @@
 {
   "name": "@calcom/platform-libraries",
-  "version": "0.0.0",
+  "version": "9.9.9",
path: packages/platform/libraries/package.json
user: login: ThyMinimalDev
body: `yarn local` in order to work with libraries in local
created_at: 2025-05-02T19:44:09Z
author_association: CONTRIBUTOR
diff_hunk: @@ -680,3 +804,151 @@ async function getUserIdsAndEmailsWhereUserIsAdminOrOwner(
   });
   return [users.map((user) => user.id), users.map((user) => user.email)];
 }
+
+function addStatusesQueryFilters(query: BookingsUnionQuery, statuses: InputByStatus[]) {
+  if (statuses?.length) {
+    return query.where(({ eb, or, and }) =>
+      or(
+        statuses.map((status) => {
+          if (status === "upcoming") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll analyze the changed code for violations of the \"Prevent Direct NOW() Usage in Database Queries\" rule. Let me carefully review the code to identify any instances where NOW() is used without proper timezone specification.\n\nFirst, let me understand what I'm looking for:\n- Direct usage of NOW() function in database queries without timezone specification\n- This can cause inconsistent timestamp data if not using UTC timezone consistently\n\nLet me examine the code changes:","toolCalls":[{"args":{"command":"grep -r \"NOW()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check for other common date/time functions that might be used:","toolCalls":[{"args":{"command":"grep -r \"new Date()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"I found several instances of `new Date()` being used in the code. Let me check the context of these usages to determine if they violate the rule:","toolCalls":[{"args":{"command":"grep -A 5 -B 5 \"new Date()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Now I have a better understanding of the context. Let me analyze these instances:\n\nThe code is using `new Date()` in several places within the `addStatusesQueryFilters` function to filter bookings based on their status:\n\n1. For \"upcoming\" bookings: `eb(\"Booking.endTime\", \">=\", new Date())`\n2. For \"recurring\" bookings: `eb(\"Booking.endTime\", \">=\", new Date())`\n3. For \"past\" bookings: `eb(\"Booking.endTime\", \"<=\", new Date())`\n4. For \"unconfirmed\" bookings: `eb(\"Booking.endTime\", \">=\", new Date())`\n\nThese are all instances where `new Date()` is being used in database queries without timezone specification. This could potentially lead to inconsistent timestamp data if the application server's timezone differs from UTC.\n\nLet me check if there are any other date-related functions being used:","toolCalls":[{"args":{"command":"grep -r \"dayjs\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Prevent Direct NOW() Usage in Database Queries**
      
      Using new Date() without timezone specification can lead to inconsistent timestamp data
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -680,3 +804,151 @@
   });
   return [users.map((user) => user.id), users.map((user) => user.email)];
 }
+
+function addStatusesQueryFilters(query: BookingsUnionQuery, statuses: InputByStatus[]) {
+  if (statuses?.length) {
+    return query.where(({ eb, or, and }) =>
+      or(
+        statuses.map((status) => {
+          if (status === "upcoming") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
+              or([
+                and([eb("Booking.recurringEventId", "is not", null), eb("Booking.status", "=", "accepted")]),
+                and([
+                  eb("Booking.recurringEventId", "is", null),
+                  eb("Booking.status", "not in", ["cancelled", "rejected"]),
+                ]),
+              ]),
+            ]);
+          }
+
+          if (status === "recurring") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
+              eb("Booking.recurringEventId", "is not", null),
+              eb("Booking.status", "not in", ["cancelled", "rejected"]),
+            ]);
+          }
+
+          if (status === "past") {
+            return and([
+              eb("Booking.endTime", "<=", new Date()),
+              eb("Booking.status", "not in", ["cancelled", "rejected"]),
+            ]);
+          }
+
+          if (status === "cancelled") {
+            return eb("Booking.status", "in", ["cancelled", "rejected"]);
+          }
+
+          if (status === "unconfirmed") {
+            return and([eb("Booking.endTime", ">=", new Date()), eb("Booking.status", "=", "pending")]);
+          }
+
+          return and([]);
+        })
+      )
+    );
+  }
+
+  return query;
+}
+
+function addAdvancedAttendeeWhereClause(
+  query: BookingsUnionQuery,
+  key: "name" | "email",
+  operator:
+    | "endsWith"
+    | "startsWith"
+    | "equals"
+    | "notEquals"
+    | "contains"
+    | "notContains"
+    | "isEmpty"
+    | "isNotEmpty",
+  operand: string
+) {
+  switch (operator) {
+    case "endsWith":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `%${operand}`);
+      break;
+    case "startsWith":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `${operand}%`);
+      break;
+
+    case "equals":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "=", `${operand}`);
+      break;
+
+    case "notEquals":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "!=", `${operand}`);
+      break;
+
+    case "contains":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "like", `%${operand}%`);
+      break;
+
+    case "notContains":
+      query
+        .innerJoin("Attendee", "Attendee.id", "Booking.id")
+        .where(`Attendee.${key}`, "not like", `%${operand}%`);
+      break;
+
+    case "isEmpty":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "=", "");
+      break;
+
+    case "isNotEmpty":
+      query.innerJoin("Attendee", "Attendee.id", "Booking.id").where(`Attendee.${key}`, "!=", "");
+      break;
+
+    default:
+      break;
+  }
+
+  return query;
+}
+
+function getOrderBy(
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[]} -->
Rule violated: **Enforce Singular Naming for Single-Item Functions**
      
      Function name should be singular as it returns a single order configuration object
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -215,165 +143,361 @@
       });
     }
 
-    // Filtered view: Booking must match one of the specified users or their attendees
-    const usersFilter = { in: [...filters.userIds] };
-    const attendeesEmailFilter = { in: attendeeEmailsFromUserIdsFilter };
-
     // 1. Booking created by one of the filtered users
-    orConditions.push({ userId: usersFilter });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("userId", "in", filters.userIds)
+    );
+
     // 2. Attendee email matches one of the filtered users' emails
-    orConditions.push({ attendees: { some: { email: attendeesEmailFilter } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
+
     // 3. Seat reference attendee email matches one of the filtered users' emails
-    orConditions.push({ seatsReferences: { some: { attendee: { email: attendeesEmailFilter } } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
   } else {
-    // Filter by emails for auth user.
-    const userEmailFilter = { equals: user.email };
-    // Auth user is ORG_OWNER/ADMIN or TEAM_OWNER/ADMIN, filter by emails of members of the organization or team
-    const userEmailsFilterWhereUserIsOrgAdminOrOwner = userEmailsWhereUserIsAdminOrOwner?.length
-      ? { in: userEmailsWhereUserIsAdminOrOwner }
-      : undefined;
-
     // 1. Current user created bookings
-    orConditions.push({ userId: { equals: user.id } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("Booking.userId", "=", user.id)
+    );
     // 2. Current user is an attendee
-    orConditions.push({ attendees: { some: { email: userEmailFilter } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 3. Current user is an attendee via seats reference
-    orConditions.push({ seatsReferences: { some: { attendee: { email: userEmailFilter } } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("BookingSeat", "BookingSeat.bookingId", "Booking.id")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 4. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({ attendees: { some: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
     // 5. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees via seatsReference
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees via seatsReference
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({
-        seatsReferences: { some: { attendee: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } },
-      });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
+
     // 6. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get booking created for an event type within the organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created for an event type within the team
     eventTypeIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ eventTypeId: { in: eventTypeIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("EventType", "EventType.id", "Booking.eventTypeId")
+          .where("Booking.eventTypeId", "in", eventTypeIdsWhereUserIsAdminOrOwner)
+      );
+
     // 7. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get bookings created by users within the same organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created by users within the same organization
     userIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ userId: { in: userIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .where("Booking.userId", "in", userIdsWhereUserIsAdminOrOwner)
+      );
   }
 
-  const andConditions = [];
-
-  // 1. Apply mandatory status filter
-  andConditions.push(passedBookingsStatusFilter);
-
-  // 2. Filter by Event Type IDs derived from Team IDs (if provided)
-  if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromTeamIdsFilter } });
-  }
+  const queriesWithFilters = bookingQueries.map((query) => {
+    // 1. Apply mandatory status filter
+    let fullQuery = addStatusesQueryFilters(query, bookingListingByStatus);
 
-  // 3. Filter by specific Event Type IDs (if provided)
-  // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
-  if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromEventTypeIdsFilter } });
-  }
+    // 2. Filter by Event Type IDs derived from Team IDs (if provided)
+    if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromTeamIdsFilter);
+    }
 
-  // 4. Filter by Attendee Email (if provided)
-  if (filters?.attendeeEmail) {
-    if (typeof filters.attendeeEmail === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { email: filters.attendeeEmail.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeEmail)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "email",
-            filterValue: filters.attendeeEmail,
-          }),
-        },
-      });
+    // 3. Filter by specific Event Type IDs (if provided)
+    // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
+    if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromEventTypeIdsFilter);
     }
-  }
 
-  // 5. Filter by Attendee Name (if provided)
-  if (filters?.attendeeName) {
-    if (typeof filters.attendeeName === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { name: filters.attendeeName.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeName)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "name",
-            filterValue: filters.attendeeName,
-          }),
-        },
-      });
+    // 4. Filter by Attendee Name (if provided)
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .withPlugin(new DeduplicateJoinsPlugin())
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery.withPlugin(new DeduplicateJoinsPlugin()),
+          "name",
+          filters.attendeeName.data.operator,
+          filters.attendeeName.data.operand
+        );
+      }
     }
-  }
 
-  // 6. Date Range Filters
-  if (filters?.afterStartDate) {
-    andConditions.push({ startTime: { gte: dayjs.utc(filters.afterStartDate).toDate() } });
-  }
-  if (filters?.beforeEndDate) {
-    andConditions.push({ endTime: { lte: dayjs.utc(filters.beforeEndDate).toDate() } });
-  }
-  if (filters?.afterUpdatedDate) {
-    andConditions.push({ updatedAt: { gte: dayjs.utc(filters.afterUpdatedDate).toDate() } });
-  }
-  if (filters?.beforeUpdatedDate) {
-    andConditions.push({ updatedAt: { lte: dayjs.utc(filters.beforeUpdatedDate).toDate() } });
-  }
-  if (filters?.afterCreatedDate) {
-    andConditions.push({ createdAt: { gte: dayjs.utc(filters.afterCreatedDate).toDate() } });
-  }
-  if (filters?.beforeCreatedDate) {
-    andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
-  }
+    // 5. Filter by Attendee Email (if provided)
+    if (filters?.attendeeEmail) {
+      if (typeof filters.attendeeEmail === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .withPlugin(new DeduplicateJoinsPlugin())
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeEmail.trim());
+      } else if (isTextFilterValue(filters.attendeeEmail)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery.withPlugin(new DeduplicateJoinsPlugin()),
+          "email",
+          filters.attendeeEmail.data.operator,
+          filters.attendeeEmail.data.operand
+        );
+      }
+    }
 
-  // All the possible date filter keys
-  const dateFilterKeys = [
-    "afterStartDate",
-    "beforeEndDate",
-    "afterUpdatedDate",
-    "beforeUpdatedDate",
-    "afterCreatedDate",
-    "beforeCreatedDate",
-  ] as const;
-
-  const hasAnyDateFilter = dateFilterKeys.some((key) => filters?.[key]);
-
-  if (!hasAnyDateFilter) {
-    // is ORG/TEAM admin/owner
-    if (userIdsWhereUserIsAdminOrOwner?.length || userEmailsWhereUserIsAdminOrOwner?.length) {
-      const oneMonthAgo = dayjs.utc().subtract(1, "month").startOf("day").toDate();
-      andConditions.push({ startTime: { gte: oneMonthAgo } });
+    // 6. Booking Start/End Time Range Filters
+    if (filters?.afterStartDate) {
+      fullQuery = fullQuery.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      fullQuery = fullQuery.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
     }
-  }
 
-  const whereClause = {
-    OR: orConditions,
-    AND: andConditions,
-  };
+    return fullQuery;
+  });
 
-  log.info(`Get bookings where clause for user ${user.id}`, JSON.stringify(whereClause));
+  const queryUnion = queriesWithFilters.reduce((acc, query) => {
+    return acc.union(query);
+  });
 
-  const [plainBookings, totalCount] = await Promise.all([
-    prisma.booking.findMany({
-      where: whereClause,
-      select: bookingSelect,
-      orderBy,
-      take,
-      skip,
-    }),
-    prisma.booking.count({
-      where: whereClause,
-    }),
-  ]);
+  const orderBy = getOrderBy(bookingListingByStatus, sort);
+
+  const getBookingsUnionCompiled = kysely
+    .selectFrom(queryUnion.as("union_subquery"))
+    .selectAll("union_subquery")
+    .$if(Boolean(filters.afterUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters.beforeUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters.afterCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate())
+    )
+    .$if(Boolean(filters.beforeCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", "<=", dayjs.utc(filters.afterCreatedDate).toDate())
+    )
+    .orderBy(orderBy.key, orderBy.order)
+    .limit(take)
+    .offset(skip)
+    .compile();
+
+  const bookingsFromUnion = (await kysely.executeQuery(getBookingsUnionCompiled)).rows;
+
+  log.debug(`Get bookings for user ${user.id} SQL:`, getBookingsUnionCompiled);
+  console.log(
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll analyze the changed code for any violations of the \"Avoid Logging Sensitive Information\" rule, focusing only on the added lines (starting with +).\n\nLet me examine the code carefully to identify any instances where sensitive information might be logged.","toolCalls":[{"args":{"command":"grep -r \"log\\.\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the console.log statements in the file:","toolCalls":[{"args":{"command":"grep -r \"console.log\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me see the full context of these logging statements:","toolCalls":[{"args":{"command":"grep -A 5 -B 1 \"log.debug\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"I've found a potential issue. There's a console.log statement that logs SQL query details including parameters. Let me analyze this further to determine if it contains sensitive information.\n\nThe console.log statement is logging:\n1. `getBookingsUnionCompiled.sql` - The SQL query string\n2. `getBookingsUnionCompiled.parameters` - The parameters used in the SQL query\n3. `bookingsFromUnion.map((b) => b.id)` - The IDs of the bookings returned\n\nLet me check what's in `getBookingsUnionCompiled` to understand what might be exposed:","toolCalls":[{"args":{"command":"grep -A 30 -B 5 \"getBookingsUnionCompiled\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check what's in the `queryUnion` and what parameters might be included:","toolCalls":[{"args":{"command":"grep -A 10 -B 5 \"queryUnion\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check what filters are being applied to the queries:","toolCalls":[{"args":{"command":"grep -A 10 -B 5 \"filters\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Logging SQL query parameters may expose sensitive information
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,14 @@
+import type { ExpressionBuilder, StringReference } from "kysely";
+import { sql } from "kysely";
+
+export function traverseJSON<DB, TB extends keyof DB>(
+  eb: ExpressionBuilder<DB, TB>,
+  column: StringReference<DB, TB>,
+  path: string | [string, ...string[]]
+) {
+  if (!Array.isArray(path)) {
path: packages/kysely/utils/json/traverse/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":7,"steps":[{"text":"I'll review the changed lines in `packages/kysely/utils/json/traverse/index.ts` for any issues, focusing on the lines starting with '+'. Let me analyze the code first.","toolCalls":[{"args":{"command":"grep -r \"traverseJSON\" --include=\"*.ts\" --include=\"*.tsx\" packages/"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files in the `packages/kysely` directory to understand the context better:","toolCalls":[{"args":{"pattern":"packages/kysely/**/*.ts"},"toolName":"listFiles"}]},{"text":"Let me try a broader pattern:","toolCalls":[{"args":{"pattern":"packages/kysely/**"},"toolName":"listFiles"}]},{"text":"It seems the file might be newly created and not yet fully indexed. Let me check for any SQL injection related patterns in the codebase:","toolCalls":[{"args":{"command":"grep -r \"sql.raw\" --include=\"*.ts\" --include=\"*.tsx\" packages/"},"toolName":"executeCommand"}]},{"text":"Let me check for any similar Kysely usage patterns in the codebase:","toolCalls":[{"args":{"command":"grep -r \"sql`\" --include=\"*.ts\" --include=\"*.tsx\" packages/"},"toolName":"executeCommand"}]},{"text":"Let me try a different approach:","toolCalls":[{"args":{"command":"grep -r \"sql\\\\`\" --include=\"*.ts\" --include=\"*.tsx\" packages/"},"toolName":"executeCommand"}]},{"text":"Let me try to find any Kysely usage in the codebase:","toolCalls":[{"args":{"command":"grep -r \"kysely\" --include=\"*.ts\" --include=\"*.tsx\" packages/"},"toolName":"executeCommand"}]},{"text":"Let me check the `packages/kysely/index.ts` file to understand the Kysely setup:","toolCalls":[{"args":{"command":"cat packages/kysely/index.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the usage of the `traverseJSON` function in the bookings handler:","toolCalls":[{"args":{"command":"grep -r \"traverseJSON\" --include=\"*.ts\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Missing validation for empty path array
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1,11 +1,9 @@
 import type { TextFilterValue } from "@calcom/features/data-table/lib/types";
 import type { PrismaClient } from "@calcom/prisma";
-import type { Prisma } from "@calcom/prisma/client";
-import { BookingStatus } from "@calcom/prisma/enums";
 import { getBookings } from "@calcom/trpc/server/routers/viewer/bookings/get.handler";
 
 type InputByStatus = "upcoming" | "recurring" | "past" | "cancelled" | "unconfirmed";
-type SortOptions = {
+export type SortOptions = {
path: packages/lib/bookings/getAllUserBookings.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":7,"steps":[{"text":"I'll review the changed lines in the PR for issues, focusing on the code changes in `packages/lib/bookings/getAllUserBookings.ts`. Let me analyze the changes and identify any potential problems.\n\nFirst, let me understand what's happening in this PR. Based on the PR title and description, it seems the team is adding Kysely support for fetching bookings, which is a SQL query builder. The changes in this file appear to be removing the Prisma-specific filtering and ordering logic, likely moving it to the `getBookings` handler which will now handle both Prisma and Kysely implementations.\n\nLet me check the `getBookings` function to understand how it's being used:","toolCalls":[{"args":{"character":25,"file":"packages/lib/bookings/getAllUserBookings.ts","line":4},"toolName":"goToDefinition"}]},{"text":"Let me try to find the file directly:","toolCalls":[{"args":{"pattern":"**/get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try a broader search:","toolCalls":[{"args":{"pattern":"**/bookings/get*"},"toolName":"listFiles"}]},{"text":"Let me try to find the file using grep:","toolCalls":[{"args":{"command":"grep -r \"getBookings\" --include=\"*.ts\" ."},"toolName":"executeCommand"}]},{"text":"Let me look at the get.handler.ts file:","toolCalls":[{"args":{"pattern":"**/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"listFiles"}]},{"text":"Let me try to find the file with a more specific pattern:","toolCalls":[{"args":{"command":"find . -name \"get.handler.ts\" | grep -i bookings"},"toolName":"executeCommand"}]},{"text":"Now let me examine the content of this file to understand the changes:","toolCalls":[{"args":{"command":"cat ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Changing a non-exported type to exported without updating references may cause issues
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
+
+export type { DB, Booking };
+
+const connectionString = process.env.DATABASE_URL ?? "postgresql://postgres:@localhost:5450/calendso";
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll review the changed lines in `packages/kysely/index.ts` for any issues, focusing on the lines starting with '+'. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"packages/kysely/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if the types file exists in a different location:","toolCalls":[{"args":{"command":"find packages -name \"types.ts\" | grep kysely"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files in the kysely package:","toolCalls":[{"args":{"pattern":"packages/kysely/*"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files related to this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i booking"},"toolName":"executeCommand"}]},{"text":"Let me check for any handler files that might be related to this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i handler | grep -i booking"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files modified in this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i kysely"},"toolName":"executeCommand"}]},{"text":"Let me check the content of the utils file:","toolCalls":[{"args":{"command":"cat packages/kysely/utils/json/traverse/index.ts"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any bookings handler files that might have been modified to use Kysely:","toolCalls":[{"args":{"command":"find packages/trpc/server/routers/viewer/bookings -name \"*.ts\" | xargs grep -l \"kysely\" 2>/dev/null"},"toolName":"executeCommand"}]},{"text":"Let me check the content of this file to understand how Kysely is being used:","toolCalls":[{"args":{"command":"cat packages/trpc/server/routers/viewer/bookings/get.handler.ts | grep -A 20 -B 20 \"kysely\""},"toolName":"executeCommand"}]}]} -->
Hardcoded database credentials in code
created_at: 2025-05-05T09:54:11Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types.ts";
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll review the changed lines in `packages/kysely/index.ts` for any issues, focusing on the lines starting with '+'. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"packages/kysely/types.ts"},"toolName":"listFiles"}]},{"text":"Let me check if the types file exists in a different location:","toolCalls":[{"args":{"command":"find packages -name \"types.ts\" | grep kysely"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files in the kysely package:","toolCalls":[{"args":{"pattern":"packages/kysely/*"},"toolName":"listFiles"}]},{"text":"Let me check if there are any other files related to this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i booking"},"toolName":"executeCommand"}]},{"text":"Let me check for any handler files that might be related to this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i handler | grep -i booking"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any other files modified in this PR:","toolCalls":[{"args":{"command":"find packages -name \"*.ts\" | grep -i kysely"},"toolName":"executeCommand"}]},{"text":"Let me check the content of the utils file:","toolCalls":[{"args":{"command":"cat packages/kysely/utils/json/traverse/index.ts"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any bookings handler files that might have been modified to use Kysely:","toolCalls":[{"args":{"command":"find packages/trpc/server/routers/viewer/bookings -name \"*.ts\" | xargs grep -l \"kysely\" 2>/dev/null"},"toolName":"executeCommand"}]},{"text":"Let me check the content of this file to understand how Kysely is being used:","toolCalls":[{"args":{"command":"cat packages/trpc/server/routers/viewer/bookings/get.handler.ts | grep -A 20 -B 20 \"kysely\""},"toolName":"executeCommand"}]}]} -->
Importing from a file that doesn't exist
created_at: 2025-05-05T09:54:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -215,165 +143,361 @@ export async function getBookings({
       });
     }
 
-    // Filtered view: Booking must match one of the specified users or their attendees
-    const usersFilter = { in: [...filters.userIds] };
-    const attendeesEmailFilter = { in: attendeeEmailsFromUserIdsFilter };
-
     // 1. Booking created by one of the filtered users
-    orConditions.push({ userId: usersFilter });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("userId", "in", filters.userIds)
+    );
+
     // 2. Attendee email matches one of the filtered users' emails
-    orConditions.push({ attendees: { some: { email: attendeesEmailFilter } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
+
     // 3. Seat reference attendee email matches one of the filtered users' emails
-    orConditions.push({ seatsReferences: { some: { attendee: { email: attendeesEmailFilter } } } });
+    if (attendeeEmailsFromUserIdsFilter?.length) {
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", attendeeEmailsFromUserIdsFilter)
+      );
+    }
   } else {
-    // Filter by emails for auth user.
-    const userEmailFilter = { equals: user.email };
-    // Auth user is ORG_OWNER/ADMIN or TEAM_OWNER/ADMIN, filter by emails of members of the organization or team
-    const userEmailsFilterWhereUserIsOrgAdminOrOwner = userEmailsWhereUserIsAdminOrOwner?.length
-      ? { in: userEmailsWhereUserIsAdminOrOwner }
-      : undefined;
-
     // 1. Current user created bookings
-    orConditions.push({ userId: { equals: user.id } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .where("Booking.userId", "=", user.id)
+    );
     // 2. Current user is an attendee
-    orConditions.push({ attendees: { some: { email: userEmailFilter } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 3. Current user is an attendee via seats reference
-    orConditions.push({ seatsReferences: { some: { attendee: { email: userEmailFilter } } } });
+    bookingQueries.push(
+      kysely
+        .selectFrom("Booking")
+        .select("Booking.id")
+        .select("Booking.startTime")
+        .select("Booking.endTime")
+        .select("Booking.createdAt")
+        .select("Booking.updatedAt")
+        .innerJoin("BookingSeat", "BookingSeat.bookingId", "Booking.id")
+        .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+        .where("Attendee.email", "=", user.email)
+    );
     // 4. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({ attendees: { some: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
     // 5. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees via seatsReference
     // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees via seatsReference
-    userEmailsFilterWhereUserIsOrgAdminOrOwner &&
-      orConditions.push({
-        seatsReferences: { some: { attendee: { email: userEmailsFilterWhereUserIsOrgAdminOrOwner } } },
-      });
+    userEmailsWhereUserIsAdminOrOwner?.length &&
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .innerJoin("BookingSeat", "Attendee.id", "BookingSeat.attendeeId")
+          .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner)
+      );
+
     // 6. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get booking created for an event type within the organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created for an event type within the team
     eventTypeIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ eventTypeId: { in: eventTypeIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .innerJoin("EventType", "EventType.id", "Booking.eventTypeId")
+          .where("Booking.eventTypeId", "in", eventTypeIdsWhereUserIsAdminOrOwner)
+      );
+
     // 7. Scope depends on `user.orgId`:
     // - If Current user is ORG_OWNER/ADMIN, get bookings created by users within the same organization
     // - If Current user is TEAM_OWNER/ADMIN, get bookings created by users within the same organization
     userIdsWhereUserIsAdminOrOwner?.length &&
-      orConditions.push({ userId: { in: userIdsWhereUserIsAdminOrOwner } });
+      bookingQueries.push(
+        kysely
+          .selectFrom("Booking")
+          .select("Booking.id")
+          .select("Booking.startTime")
+          .select("Booking.endTime")
+          .select("Booking.createdAt")
+          .select("Booking.updatedAt")
+          .where("Booking.userId", "in", userIdsWhereUserIsAdminOrOwner)
+      );
   }
 
-  const andConditions = [];
-
-  // 1. Apply mandatory status filter
-  andConditions.push(passedBookingsStatusFilter);
-
-  // 2. Filter by Event Type IDs derived from Team IDs (if provided)
-  if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromTeamIdsFilter } });
-  }
+  const queriesWithFilters = bookingQueries.map((query) => {
+    // 1. Apply mandatory status filter
+    let fullQuery = addStatusesQueryFilters(query, bookingListingByStatus);
 
-  // 3. Filter by specific Event Type IDs (if provided)
-  // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
-  if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
-    andConditions.push({ eventTypeId: { in: eventTypeIdsFromEventTypeIdsFilter } });
-  }
+    // 2. Filter by Event Type IDs derived from Team IDs (if provided)
+    if (eventTypeIdsFromTeamIdsFilter && eventTypeIdsFromTeamIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromTeamIdsFilter);
+    }
 
-  // 4. Filter by Attendee Email (if provided)
-  if (filters?.attendeeEmail) {
-    if (typeof filters.attendeeEmail === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { email: filters.attendeeEmail.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeEmail)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "email",
-            filterValue: filters.attendeeEmail,
-          }),
-        },
-      });
+    // 3. Filter by specific Event Type IDs (if provided)
+    // If both teamIds filter and eventTypeIds filter are provided, filter 2. ensures the event-types are within the teams
+    if (eventTypeIdsFromEventTypeIdsFilter && eventTypeIdsFromEventTypeIdsFilter.length > 0) {
+      fullQuery = fullQuery.where("Booking.eventTypeId", "in", eventTypeIdsFromEventTypeIdsFilter);
     }
-  }
 
-  // 5. Filter by Attendee Name (if provided)
-  if (filters?.attendeeName) {
-    if (typeof filters.attendeeName === "string") {
-      // Simple string match (exact)
-      andConditions.push({ attendees: { some: { name: filters.attendeeName.trim() } } });
-    } else if (isTextFilterValue(filters.attendeeName)) {
-      // Complex text filter (contains, startsWith, etc.) using makeWhereClause
-      andConditions.push({
-        attendees: {
-          some: makeWhereClause({
-            columnName: "name",
-            filterValue: filters.attendeeName,
-          }),
-        },
-      });
+    // 4. Filter by Attendee Name (if provided)
+    if (filters?.attendeeName) {
+      if (typeof filters.attendeeName === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .withPlugin(new DeduplicateJoinsPlugin())
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.name", "=", filters.attendeeName.trim());
+      } else if (isTextFilterValue(filters.attendeeName)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery.withPlugin(new DeduplicateJoinsPlugin()),
+          "name",
+          filters.attendeeName.data.operator,
+          filters.attendeeName.data.operand
+        );
+      }
     }
-  }
 
-  // 6. Date Range Filters
-  if (filters?.afterStartDate) {
-    andConditions.push({ startTime: { gte: dayjs.utc(filters.afterStartDate).toDate() } });
-  }
-  if (filters?.beforeEndDate) {
-    andConditions.push({ endTime: { lte: dayjs.utc(filters.beforeEndDate).toDate() } });
-  }
-  if (filters?.afterUpdatedDate) {
-    andConditions.push({ updatedAt: { gte: dayjs.utc(filters.afterUpdatedDate).toDate() } });
-  }
-  if (filters?.beforeUpdatedDate) {
-    andConditions.push({ updatedAt: { lte: dayjs.utc(filters.beforeUpdatedDate).toDate() } });
-  }
-  if (filters?.afterCreatedDate) {
-    andConditions.push({ createdAt: { gte: dayjs.utc(filters.afterCreatedDate).toDate() } });
-  }
-  if (filters?.beforeCreatedDate) {
-    andConditions.push({ createdAt: { lte: dayjs.utc(filters.beforeCreatedDate).toDate() } });
-  }
+    // 5. Filter by Attendee Email (if provided)
+    if (filters?.attendeeEmail) {
+      if (typeof filters.attendeeEmail === "string") {
+        // Simple string match (exact)
+        fullQuery = fullQuery
+          .withPlugin(new DeduplicateJoinsPlugin())
+          .innerJoin("Attendee", "Attendee.bookingId", "Booking.id")
+          .where("Attendee.email", "=", filters.attendeeEmail.trim());
+      } else if (isTextFilterValue(filters.attendeeEmail)) {
+        // TODO: write makeWhereClause equivalent for kysely
+        fullQuery = addAdvancedAttendeeWhereClause(
+          fullQuery.withPlugin(new DeduplicateJoinsPlugin()),
+          "email",
+          filters.attendeeEmail.data.operator,
+          filters.attendeeEmail.data.operand
+        );
+      }
+    }
 
-  // All the possible date filter keys
-  const dateFilterKeys = [
-    "afterStartDate",
-    "beforeEndDate",
-    "afterUpdatedDate",
-    "beforeUpdatedDate",
-    "afterCreatedDate",
-    "beforeCreatedDate",
-  ] as const;
-
-  const hasAnyDateFilter = dateFilterKeys.some((key) => filters?.[key]);
-
-  if (!hasAnyDateFilter) {
-    // is ORG/TEAM admin/owner
-    if (userIdsWhereUserIsAdminOrOwner?.length || userEmailsWhereUserIsAdminOrOwner?.length) {
-      const oneMonthAgo = dayjs.utc().subtract(1, "month").startOf("day").toDate();
-      andConditions.push({ startTime: { gte: oneMonthAgo } });
+    // 6. Booking Start/End Time Range Filters
+    if (filters?.afterStartDate) {
+      fullQuery = fullQuery.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
+    }
+    if (filters?.beforeEndDate) {
+      fullQuery = fullQuery.where("Booking.endTime", "<=", dayjs.utc(filters.beforeEndDate).toDate());
     }
-  }
 
-  const whereClause = {
-    OR: orConditions,
-    AND: andConditions,
-  };
+    return fullQuery;
+  });
 
-  log.info(`Get bookings where clause for user ${user.id}`, JSON.stringify(whereClause));
+  const queryUnion = queriesWithFilters.reduce((acc, query) => {
+    return acc.union(query);
+  });
 
-  const [plainBookings, totalCount] = await Promise.all([
-    prisma.booking.findMany({
-      where: whereClause,
-      select: bookingSelect,
-      orderBy,
-      take,
-      skip,
-    }),
-    prisma.booking.count({
-      where: whereClause,
-    }),
-  ]);
+  const orderBy = getOrderBy(bookingListingByStatus, sort);
+
+  const getBookingsUnionCompiled = kysely
+    .selectFrom(queryUnion.as("union_subquery"))
+    .selectAll("union_subquery")
+    .$if(Boolean(filters.afterUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", ">=", dayjs.utc(filters.afterUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters.beforeUpdatedDate), (eb) =>
+      eb.where("union_subquery.updatedAt", "<=", dayjs.utc(filters.beforeUpdatedDate).toDate())
+    )
+    .$if(Boolean(filters.afterCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", ">=", dayjs.utc(filters.afterCreatedDate).toDate())
+    )
+    .$if(Boolean(filters.beforeCreatedDate), (eb) =>
+      eb.where("union_subquery.createdAt", "<=", dayjs.utc(filters.afterCreatedDate).toDate())
+    )
+    .orderBy(orderBy.key, orderBy.order)
+    .limit(take)
+    .offset(skip)
+    .compile();
+
+  const bookingsFromUnion = (await kysely.executeQuery(getBookingsUnionCompiled)).rows;
+
+  log.debug(`Get bookings for user ${user.id} SQL:`, getBookingsUnionCompiled);
+  console.log(
+    getBookingsUnionCompiled.sql,
+    getBookingsUnionCompiled.parameters,
+    bookingsFromUnion.map((b) => b.id)
+  );
+  const totalCount = Number(
+    (
+      await kysely
+        .selectFrom(queryUnion.as("union_subquery"))
+        .select(({ fn }) => fn.countAll().as("bookingCount"))
+        .executeTakeFirst()
+    )?.bookingCount ?? 0
+  );
+
+  const plainBookings = !(bookingsFromUnion?.length === 0)
+    ? await kysely
+        .selectFrom("Booking")
+        .where(
+          "id",
+          "in",
+          bookingsFromUnion.map((booking) => booking.id)
+        )
+        .select((eb) => [
+          "Booking.id",
+          "Booking.title",
+          "Booking.userPrimaryEmail",
+          "Booking.description",
+          "Booking.customInputs",
+          "Booking.startTime",
+          "Booking.createdAt",
+          "Booking.updatedAt",
+          "Booking.endTime",
+          "Booking.metadata",
+          "Booking.uid",
+          "Booking.responses",
+          "Booking.recurringEventId",
+          "Booking.location",
+          "Booking.status",
+          "Booking.paid",
+          "Booking.fromReschedule",
+          "Booking.rescheduled",
+          "Booking.isRecorded",
+          jsonObjectFrom(
+            eb
+              .selectFrom("App_RoutingForms_FormResponse")
+              .select("id")
+              .whereRef("App_RoutingForms_FormResponse.routedToBookingUid", "=", "Booking.uid")
+          ).as("routedFromRoutingFormReponse"),
+          jsonObjectFrom(
+            eb
+              .selectFrom("EventType")
+              .select((eb) => [
+                "EventType.slug",
+                "EventType.id",
+                "EventType.title",
+                "EventType.eventName",
+                "EventType.price",
+                "EventType.recurringEvent",
+                "EventType.currency",
+                "EventType.metadata",
+                "EventType.disableGuests",
+                "EventType.seatsShowAttendees",
+                "EventType.seatsShowAvailabilityCount",
+                "EventType.eventTypeColor",
+                "EventType.customReplyToEmail",
+                "EventType.allowReschedulingPastBookings",
+                "EventType.hideOrganizerEmail",
+                "EventType.disableCancelling",
+                "EventType.disableRescheduling",
+                "EventType.schedulingType",
+                "EventType.length",
+                jsonObjectFrom(
+                  eb
+                    .selectFrom("Team")
+                    .select(["Team.id", "Team.name", "Team.slug"])
+                    .whereRef("EventType.teamId", "=", "Team.id")
+                ).as("team"),
+              ])
+              .whereRef("EventType.id", "=", "Booking.eventTypeId")
+          ).as("eventType"),
+          jsonObjectFrom(
+            eb.selectFrom("Payment").select("id").whereRef("Payment.bookingId", "=", "Booking.id")
+          ).as("payment"),
+          jsonObjectFrom(
+            eb
+              .selectFrom("users")
+              .select(["users.id", "users.name", "users.email"])
+              .whereRef("Booking.userId", "=", "users.id")
+          ).as("user"),
+          jsonArrayFrom(
+            eb.selectFrom("Attendee").selectAll().whereRef("Attendee.bookingId", "=", "Booking.id")
+          ).as("attendees"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("BookingSeat")
+              .select((eb) => [
+                "BookingSeat.referenceUid",
+                jsonObjectFrom(
+                  eb
+                    .selectFrom("Attendee")
+                    .select(["Attendee.email"])
+                    .whereRef("BookingSeat.attendeeId", "=", "Attendee.id")
+                    .where("Attendee.email", "=", user.email)
+                ).as("attendee"),
+              ])
+              .whereRef("BookingSeat.bookingId", "=", "Booking.id")
+          ).as("seatsReferences"),
+          jsonArrayFrom(
+            eb
+              .selectFrom("AssignmentReason")
+              .selectAll()
+              .whereRef("AssignmentReason.bookingId", "=", "Booking.id")
+              .orderBy("AssignmentReason.createdAt", "desc")
+              .limit(1)
+          ).as("assignmentReason"),
+        ])
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: ThyMinimalDev
body: double check it's not missing any fields compared to previous prisma bookingSelect
created_at: 2025-05-05T09:57:26Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types";
+
+export type { DB, Booking };
+
+const connectionString = process.env.DATABASE_URL ?? "postgresql://postgres:@localhost:5450/calendso";
+
+const pool = new Pool({ connectionString });
+
+// 3. Create the Dialect, passing the configured pool instance
+const dialect = new PostgresDialect({
+  pool: pool, // Use the pool instance created above
+});
+
+// 4. Create the Kysely instance as before
+const db = new Kysely<DB>({
path: packages/kysely/index.ts
user: login: keithwillcode
body: Do we need to make this a singleton like we do with prisma right now? cc @zomars @emrysal 
created_at: 2025-05-05T14:55:20Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,12 @@
+{
+  "name": "@calcom/kysely",
+  "private": true,
+  "main": "index.ts",
+  "dependencies": {
+    "kysely": "^0.28.2",
path: packages/kysely/package.json
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll review the changed lines in the PR for any issues, focusing on the introduction of the Kysely package as a replacement for Prisma for the `getBookings` functionality.\n\nLet me first explore the repository structure to understand the context better.","toolCalls":[{"args":{"pattern":"packages/kysely/*"},"toolName":"listFiles"}]},{"text":"Let me check if there are any existing files related to Kysely or database queries:","toolCalls":[{"args":{"command":"grep -r \"kysely\" --include=\"*.ts\" --include=\"*.tsx\" ."},"toolName":"executeCommand"}]},{"text":"Let me check if there's an existing index.ts file in the kysely package:","toolCalls":[{"args":{"command":"grep -r \"index.ts\" --include=\"*.json\" packages/kysely"},"toolName":"executeCommand"}]},{"text":"Let me check if there's a types.ts file in the kysely package:","toolCalls":[{"args":{"command":"grep -r \"types.ts\" --include=\"*.ts\" packages/kysely"},"toolName":"executeCommand"}]},{"text":"Let me check the existing Prisma implementation to understand what's being replaced:","toolCalls":[{"args":{"command":"grep -r \"getBookings\" --include=\"*.ts\" ."},"toolName":"executeCommand"}]},{"text":"Let me look at the implementation of the getBookings function that's being refactored:","toolCalls":[{"args":{"command":"head -n 50 packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the implementation of the kysely index.ts file:","toolCalls":[{"args":{"command":"cat packages/kysely/index.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the types.ts file:","toolCalls":[{"args":{"command":"cat packages/kysely/types.ts"},"toolName":"executeCommand"}]}]} -->
Consider pinning the exact version of kysely to avoid unexpected breaking changes
created_at: 2025-05-05T18:31:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,12 @@
+{
path: packages/kysely/package.json
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":10,"steps":[{"text":"I'll review the changed lines in the PR for any issues, focusing on the introduction of the Kysely package as a replacement for Prisma for the `getBookings` functionality.\n\nLet me first explore the repository structure to understand the context better.","toolCalls":[{"args":{"pattern":"packages/kysely/*"},"toolName":"listFiles"}]},{"text":"Let me check if there are any existing files related to Kysely or database queries:","toolCalls":[{"args":{"command":"grep -r \"kysely\" --include=\"*.ts\" --include=\"*.tsx\" ."},"toolName":"executeCommand"}]},{"text":"Let me check if there's an existing index.ts file in the kysely package:","toolCalls":[{"args":{"command":"grep -r \"index.ts\" --include=\"*.json\" packages/kysely"},"toolName":"executeCommand"}]},{"text":"Let me check if there's a types.ts file in the kysely package:","toolCalls":[{"args":{"command":"grep -r \"types.ts\" --include=\"*.ts\" packages/kysely"},"toolName":"executeCommand"}]},{"text":"Let me check the existing Prisma implementation to understand what's being replaced:","toolCalls":[{"args":{"command":"grep -r \"getBookings\" --include=\"*.ts\" ."},"toolName":"executeCommand"}]},{"text":"Let me look at the implementation of the getBookings function that's being refactored:","toolCalls":[{"args":{"command":"head -n 50 packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the implementation of the kysely index.ts file:","toolCalls":[{"args":{"command":"cat packages/kysely/index.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the types.ts file:","toolCalls":[{"args":{"command":"cat packages/kysely/types.ts"},"toolName":"executeCommand"}]}]} -->
Missing types.ts file referenced in the code
created_at: 2025-05-05T18:31:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { DeduplicateJoinsPlugin, Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyReadService implements OnModuleDestroy {
+  private logger = new Logger("PrismaReadService");
path: apps/api/v2/src/modules/kysely/kysely-read.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":10,"steps":[{"text":"I'll review the changed lines in the file `apps/api/v2/src/modules/kysely/kysely-read.service.ts` for any issues. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"apps/api/v2/src/modules/kysely/*.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there's a similar service for writing operations to understand the pattern:","toolCalls":[{"args":{"command":"grep -r \"PrismaReadService\" apps/api/v2/src/modules/"},"toolName":"executeCommand"}]},{"text":"Let me check the original PrismaReadService to understand the pattern:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/prisma/prisma-read.service.ts"},"toolName":"executeCommand"}]},{"text":"Let me also check the KyselyModule to understand how this service is being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely.module.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the KyselyWriteService as well:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]}]} -->
Logger name is incorrect. It should be 'KyselyReadService' instead of 'PrismaReadService'.
created_at: 2025-05-05T18:31:46Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { DeduplicateJoinsPlugin, Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyReadService implements OnModuleDestroy {
path: apps/api/v2/src/modules/kysely/kysely-read.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll review the changed lines in the file `apps/api/v2/src/modules/kysely/kysely-read.service.ts` for any issues. Let me analyze the code first.","toolCalls":[{"args":{"pattern":"apps/api/v2/src/modules/kysely/*.ts"},"toolName":"listFiles"}]},{"text":"Let me check if there's a similar service for writing operations to understand the pattern:","toolCalls":[{"args":{"command":"grep -r \"PrismaReadService\" apps/api/v2/src/modules/"},"toolName":"executeCommand"}]},{"text":"Let me check the original PrismaReadService to understand the pattern:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/prisma/prisma-read.service.ts"},"toolName":"executeCommand"}]},{"text":"Let me also check the KyselyModule to understand how this service is being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely.module.ts"},"toolName":"executeCommand"}]},{"text":"Let me check the KyselyWriteService as well:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]}]} -->
Missing OnModuleInit implementation that's present in the original PrismaReadService.
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyWriteService implements OnModuleDestroy {
+  private logger = new Logger("KyselyWriteService");
path: apps/api/v2/src/modules/kysely/kysely-write.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll review the changed lines in the code for issues. Let me analyze the file first.","toolCalls":[{"args":{"pattern":"apps/api/v2/src/modules/kysely/**"},"toolName":"listFiles"}]},{"text":"Let me check if there's a related read service to understand the pattern being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely-read.service.ts"},"toolName":"executeCommand"}]},{"text":"Let me also check the module file to understand how these services are used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely.module.ts"},"toolName":"executeCommand"}]},{"text":"Now I'll look for any usage of these services to understand the context better:","toolCalls":[{"args":{"command":"grep -r \"KyselyWriteService\" apps/api/v2/src/ --include=\"*.ts\" | grep -v \"kysely.module.ts\" | grep -v \"kysely-write.service.ts\""},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"KyselyReadService\" apps/api/v2/src/ --include=\"*.ts\" | grep -v \"kysely.module.ts\" | grep -v \"kysely-read.service.ts\""},"toolName":"executeCommand"}]},{"text":"Let me check one of the files that uses the KyselyReadService to understand how it's being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts"},"toolName":"executeCommand"}]},{"text":"Now I'll check how the KyselyReadService is being used in the bookings service:","toolCalls":[{"args":{"command":"grep -A 10 -B 10 \"kysely: this.kyselyReadService.kysely\" apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts"},"toolName":"executeCommand"}]}]} -->
Logger name doesn't match the actual service name in the read service counterpart
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyWriteService implements OnModuleDestroy {
+  private logger = new Logger("KyselyWriteService");
+
+  public kysely: Kysely<DB>;
+
+  constructor(readonly configService: ConfigService) {
+    const dbUrl = configService.get("db.writeUrl", { infer: true });
+    const pool = new Pool({ connectionString: dbUrl });
+
+    // 3. Create the Dialect, passing the configured pool instance
+    const dialect = new PostgresDialect({
+      pool: pool, // Use the pool instance created above
+    });
+    this.kysely = new Kysely<DB>({
+      dialect,
+      plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+    });
+  }
+
+  async onModuleDestroy() {
path: apps/api/v2/src/modules/kysely/kysely-write.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":6,"steps":[{"text":"I'll review the changed lines in the code for issues. Let me analyze the file first.","toolCalls":[{"args":{"pattern":"apps/api/v2/src/modules/kysely/**"},"toolName":"listFiles"}]},{"text":"Let me check if there's a related read service to understand the pattern being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely-read.service.ts"},"toolName":"executeCommand"}]},{"text":"Let me also check the module file to understand how these services are used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely.module.ts"},"toolName":"executeCommand"}]},{"text":"Now I'll look for any usage of these services to understand the context better:","toolCalls":[{"args":{"command":"grep -r \"KyselyWriteService\" apps/api/v2/src/ --include=\"*.ts\" | grep -v \"kysely.module.ts\" | grep -v \"kysely-write.service.ts\""},"toolName":"executeCommand"}]},{"text":"","toolCalls":[{"args":{"command":"grep -r \"KyselyReadService\" apps/api/v2/src/ --include=\"*.ts\" | grep -v \"kysely.module.ts\" | grep -v \"kysely-read.service.ts\""},"toolName":"executeCommand"}]},{"text":"Let me check one of the files that uses the KyselyReadService to understand how it's being used:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts"},"toolName":"executeCommand"}]},{"text":"Now I'll check how the KyselyReadService is being used in the bookings service:","toolCalls":[{"args":{"command":"grep -A 10 -B 10 \"kysely: this.kyselyReadService.kysely\" apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts"},"toolName":"executeCommand"}]}]} -->
Error handling could be improved with more specific error information
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -99,6 +100,7 @@ export class BookingsController_2024_04_15 {
   constructor(
     private readonly oAuthFlowService: OAuthFlowService,
     private readonly prismaReadService: PrismaReadService,
+    private readonly kyselyReadService: KyselyReadService,
path: apps/api/v2/src/ee/bookings/2024-04-15/controllers/bookings.controller.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll review the changed lines in the PR for any issues. Let me analyze the code changes first.","toolCalls":[{"args":{"pattern":"**/kysely*.ts"},"toolName":"listFiles"}]},{"text":"Let me check the KyselyReadService to understand how it's implemented:","toolCalls":[{"args":{"command":"cat apps/api/v2/src/modules/kysely/kysely-read.service.ts"},"toolName":"executeCommand"}]},{"text":"Now let me check the getAllUserBookings function to understand how it's using Prisma and how it might be modified to use Kysely:","toolCalls":[{"args":{"command":"grep -r \"getAllUserBookings\" apps/api/v2/src"},"toolName":"executeCommand"}]},{"text":"Let me check the platform-libraries to see the implementation of getAllUserBookings:","toolCalls":[{"args":{"command":"grep -r \"export const getAllUserBookings\" --include=\"*.ts\" ."},"toolName":"executeCommand"}]},{"text":"Let me try a broader search:","toolCalls":[{"args":{"command":"grep -r \"getAllUserBookings\" --include=\"*.ts\" . | grep -v \"import\""},"toolName":"executeCommand"}]},{"text":"Let me check the implementation of getAllUserBookings:","toolCalls":[{"args":{"command":"cat ./packages/lib/bookings/getAllUserBookings.ts"},"toolName":"executeCommand"}]},{"text":"Now let me check the getBookings implementation:","toolCalls":[{"args":{"command":"cat ./packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Logger name in KyselyReadService doesn't match the service name
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -680,3 +850,150 @@ async function getUserIdsAndEmailsWhereUserIsAdminOrOwner(
   });
   return [users.map((user) => user.id), users.map((user) => user.email)];
 }
+
+function addStatusesQueryFilters(query: BookingsUnionQuery, statuses: InputByStatus[]) {
+  if (statuses?.length) {
+    return query.where(({ eb, or, and }) =>
+      or(
+        statuses.map((status) => {
+          if (status === "upcoming") {
+            return and([
+              eb("Booking.endTime", ">=", new Date()),
path: packages/trpc/server/routers/viewer/bookings/get.handler.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":9,"steps":[{"text":"I'll analyze the changed code for violations of the \"Prevent Direct NOW() Usage in Database Queries\" rule. Let me carefully review the code.\n\nFirst, I'll examine the code to identify any instances where NOW() might be used directly in database queries without timezone specification.","toolCalls":[{"args":{"command":"grep -r \"NOW()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Let me check for any other date-related functions or direct date usage in the code:","toolCalls":[{"args":{"command":"grep -r \"new Date()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"I see several instances of `new Date()` being used in the code. Let me check the context of these usages to determine if they violate the rule:","toolCalls":[{"args":{"command":"grep -A 5 -B 5 \"new Date()\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]},{"text":"Now I understand the context. The code is using `new Date()` in several places within the `addStatusesQueryFilters` function to filter bookings based on their status (upcoming, recurring, past, unconfirmed).\n\nLet me analyze if this violates the rule:\n\n1. The rule is about preventing direct NOW() usage in database queries without timezone specification.\n2. The code is using JavaScript's `new Date()` rather than SQL's NOW() function.\n3. However, `new Date()` in JavaScript creates a date object in the local timezone of the server, which could lead to inconsistent timestamp data if servers are in different timezones.\n\nThis is a potential issue because the application might be expecting UTC dates for consistency, but `new Date()` will create dates in the server's local timezone. In a distributed system, this could lead to inconsistent filtering based on which server processes the request.\n\nLet me check if there are any other date-related functions in the code that might be relevant:","toolCalls":[{"args":{"command":"grep -r \"dayjs\" packages/trpc/server/routers/viewer/bookings/get.handler.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Prevent Direct NOW() Usage in Database Queries**
      
      Using new Date() without timezone specification can lead to inconsistent timestamp data
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyWriteService implements OnModuleDestroy {
+  private logger = new Logger("KyselyWriteService");
+
+  public kysely: Kysely<DB>;
+
+  constructor(readonly configService: ConfigService) {
+    const dbUrl = configService.get("db.writeUrl", { infer: true });
+    const pool = new Pool({ connectionString: dbUrl });
+
+    // 3. Create the Dialect, passing the configured pool instance
+    const dialect = new PostgresDialect({
+      pool: pool, // Use the pool instance created above
+    });
+    this.kysely = new Kysely<DB>({
+      dialect,
+      plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+    });
+  }
+
+  async onModuleDestroy() {
+    try {
+      await this.kysely.destroy();
+    } catch (error) {
+      this.logger.error(error);
path: apps/api/v2/src/modules/kysely/kysely-write.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll review the changed lines in `apps/api/v2/src/modules/kysely/kysely-write.service.ts` against the rule \"Avoid Logging Sensitive Information\" to check if there are any violations where PII or sensitive data might be logged.\n\nLet me analyze the code:\n\n```typescript\n// This is a new file implementing a Kysely service for database write operations\n// The file sets up a connection to a database and handles cleanup on module destruction\n```\n\nFirst, I'll check if there's any potential logging of sensitive information in this code.","toolCalls":[{"args":{"command":"grep -r \"configService.get\" apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]},{"text":"I see that the code is retrieving a database URL from the configuration service. Let me check if there's any logging of this URL, which would be sensitive information:","toolCalls":[{"args":{"command":"grep -r \"logger\" apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]},{"text":"I see that there's a logger being used, and it's logging an error in the `onModuleDestroy` method. Let me check what exactly is being logged:","toolCalls":[{"args":{"command":"grep -A 5 -B 5 \"logger.error\" apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]},{"text":"I notice that in the `onModuleDestroy` method, there's a catch block that logs the entire error object directly. This is potentially problematic because:\n\n1. The error object might contain sensitive information related to the database connection, including the connection string which could have credentials\n2. Directly logging the entire error object without sanitizing it is generally not a good practice for sensitive operations\n\nLet me check if there are any other instances where sensitive information might be logged:","toolCalls":[{"args":{"command":"grep -r \"console.log\" apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]},{"text":"No direct console.log statements, which is good. Let me check if there are any other logging methods being used:","toolCalls":[{"args":{"command":"grep -r \"log\\|warn\\|info\\|debug\" apps/api/v2/src/modules/kysely/kysely-write.service.ts"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Directly logging the entire error object may expose sensitive database connection information
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { DeduplicateJoinsPlugin, Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyReadService implements OnModuleDestroy {
+  private logger = new Logger("PrismaReadService");
+
+  public kysely: Kysely<DB>;
+
+  constructor(readonly configService: ConfigService) {
+    const dbUrl = configService.get("db.readUrl", { infer: true });
+    const pool = new Pool({ connectionString: dbUrl });
+
+    // 3. Create the Dialect, passing the configured pool instance
+    const dialect = new PostgresDialect({
+      pool: pool, // Use the pool instance created above
+    });
+    this.kysely = new Kysely<DB>({
+      dialect,
+      plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
+    });
+  }
+
+  async onModuleDestroy() {
+    try {
+      await this.kysely.destroy();
+    } catch (error) {
+      this.logger.error(error);
path: apps/api/v2/src/modules/kysely/kysely-read.service.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Logging the entire error object could expose sensitive database credentials
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types";
+
+export type { DB, Booking };
+
+const connectionString = process.env.DATABASE_URL ?? "postgresql://postgres:@localhost:5450/calendso";
path: packages/kysely/index.ts
user: login: cubic-dev-ai[bot]
body: <!-- metadata:{"confidence":8,"steps":[{"text":"I'll analyze the changed lines in `packages/kysely/index.ts` against the rule \"Avoid Logging Sensitive Information\" to check if there are any violations related to logging PII or sensitive data.\n\nLet me examine the code carefully:\n\n```typescript\nimport { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from \"kysely\";\nimport { Pool } from \"pg\";\n\nimport type { DB, Booking } from \"./types\";\n\nexport type { DB, Booking };\n\nconst connectionString = process.env.DATABASE_URL ?? \"postgresql://postgres:@localhost:5450/calendso\";\n\nconst pool = new Pool({ connectionString });\n\n// 3. Create the Dialect, passing the configured pool instance\nconst dialect = new PostgresDialect({\n  pool: pool, // Use the pool instance created above\n});\n\n// 4. Create the Kysely instance as before\nconst db = new Kysely<DB>({\n  dialect,\n  plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],\n});\n\nexport default db;\n```\n\nLooking at this code, I notice a potential issue with sensitive information:\n\n1. Line 8 contains a hardcoded database connection string as a fallback: `\"postgresql://postgres:@localhost:5450/calendso\"`. While this appears to be a local development connection string without a password (note the empty string after the colon), it's still exposing database connection details directly in the code.\n\nLet me check if there are any other potential issues by examining the file structure to understand the context better.","toolCalls":[{"args":{"pattern":"packages/kysely/*"},"toolName":"listFiles"}]},{"text":"Let me try a broader pattern to see the file structure:","toolCalls":[{"args":{"pattern":"packages/*"},"toolName":"listFiles"}]},{"text":"Let me check if I can find the types file referenced in the import:","toolCalls":[{"args":{"command":"find . -name \"types.ts\" | grep kysely"},"toolName":"executeCommand"}]},{"text":"Let me check if there are any logging statements in the code that might expose sensitive information:","toolCalls":[{"args":{"command":"grep -r \"console.log\" --include=\"*.ts\" packages/kysely"},"toolName":"executeCommand"}]}]} -->
Rule violated: **Avoid Logging Sensitive Information**
      
      Hardcoded database connection string exposes sensitive database information
created_at: 2025-05-05T18:31:47Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+import type { OnModuleDestroy } from "@nestjs/common";
+import { Injectable, Logger } from "@nestjs/common";
+import { ConfigService } from "@nestjs/config";
+import { DeduplicateJoinsPlugin, Kysely, ParseJSONResultsPlugin, PostgresDialect } from "kysely";
+import { Pool } from "pg";
+
+import type { DB } from "@calcom/kysely/types";
+
+@Injectable()
+export class KyselyReadService implements OnModuleDestroy {
+  private logger = new Logger("PrismaReadService");
path: apps/api/v2/src/modules/kysely/kysely-read.service.ts
user: login: keithwillcode
body: ```suggestion
  private logger = new Logger("KyselyReadService");
```
created_at: 2025-05-05T19:35:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,23 @@
+import { Kysely, ParseJSONResultsPlugin, PostgresDialect, DeduplicateJoinsPlugin } from "kysely";
+import { Pool } from "pg";
+
+import type { DB, Booking } from "./types";
+
+export type { DB, Booking };
+
+const connectionString = process.env.DATABASE_URL ?? "postgresql://postgres:@localhost:5450/calendso";
+
+const pool = new Pool({ connectionString });
+
+// 3. Create the Dialect, passing the configured pool instance
+const dialect = new PostgresDialect({
+  pool: pool, // Use the pool instance created above
+});
+
+// 4. Create the Kysely instance as before
+const db = new Kysely<DB>({
path: packages/kysely/index.ts
user: login: zomars
body: I don't know the actual implications of doing it this way with Kysely. Maybe we can use globalThis like we do with prisma.

```suggestion
const db = globalThis.db ?? new Kysely<DB>({
  dialect,
  plugins: [new ParseJSONResultsPlugin(), new DeduplicateJoinsPlugin()],
});

if (!globalThis.db) {
  globalThis.db = db;
}
```
created_at: 2025-05-05T21:52:38Z
author_association: CONTRIBUTOR

PR comments:
user: login: vercel[bot]
created_at: 2025-05-02T13:59:04Z
body: [vc]: #Mh8IqPPUaJGmIl2RqQasUhn20C/8ezr3XezXsNDNc5g=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJjYWwiLCJyb290RGlyZWN0b3J5IjoiYXBwcy93ZWIiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoiIn0sImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9jYWwvY2FsL0NTZUxnNlJUdVUzWFlvM1NoSGc1UmljNnJFRFIiLCJuZXh0Q29tbWl0U3RhdHVzIjoiU0tJUFBFRCIsInByZXZpZXdVcmwiOiIifSx7Im5hbWUiOiJjYWxjb20td2ViLWNhbmFyeSIsInJvb3REaXJlY3RvcnkiOiJhcHBzL3dlYiIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiIifSwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2NhbC9jYWxjb20td2ViLWNhbmFyeS8zSmFQVjlGNnJNTW9wVG12Njd1aFU2alI1Q3RjIiwibmV4dENvbW1pdFN0YXR1cyI6IlNLSVBQRUQiLCJwcmV2aWV3VXJsIjoiIn1dfQ==
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)


<details><summary>2 Skipped Deployments</summary>

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **cal** | ⬜️ Skipped ([Inspect](https://vercel.com/cal/cal/CSeLg6RTuU3XYo3ShHg5Ric6rEDR)) |  |  | May 5, 2025 7:35pm |
| **calcom-web-canary** | ⬜️ Skipped ([Inspect](https://vercel.com/cal/calcom-web-canary/3JaPV9F6rMMopTmv67uhU6jR5Ctc)) |  |  | May 5, 2025 7:35pm |
</details>



author_association: NONE
user: login: ThyMinimalDev
created_at: 2025-05-02T19:27:52Z
body: `yarn prisma generate` in order to auto generate kysely types from prisma schema
author_association: CONTRIBUTOR
user: login: ThyMinimalDev
created_at: 2025-05-02T19:44:34Z
body: can be tested in api v2 using e2e tests:

`yarn test:e2e apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts`
author_association: CONTRIBUTOR
user: login: ThyMinimalDev
created_at: 2025-05-02T19:44:58Z
body: platform libraries needs to be built using `yarn local`
author_association: CONTRIBUTOR
user: login: socket-security[bot]
created_at: 2025-05-04T01:19:05Z
body: **Review the following changes in direct dependencies.** Learn more about [Socket for GitHub](https://socket.dev?utm_medium=gh).

<table>
<thead>
<tr>
<th>Diff</th>
<th width="200px">Package</th>
<th align="center" width="100px">Supply Chain<br/>Security</th>
<th align="center" width="100px">Vulnerability</th>
<th align="center" width="100px">Quality</th>
<th align="center" width="100px">Maintenance</th>
<th align="center" width="100px">License</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

[View full report](https://socket.dev/dashboard/org/calcom/diff/abc854d5-392a-4c66-9d97-27e2f872e8ba/22b9800e-7f13-4518-9cbe-c75adc37ca14?tab=dependencies)

<!-- overview-comment -->
author_association: NONE
user: login: github-actions[bot]
created_at: 2025-05-05T11:15:56Z
body: <!-- GENERATED-E2E-RESULTS -->
## E2E results are ready!
- [Workflow #58997.1 latest results](https://calcom.github.io/test-results/reports/chore-get-bookings-with-kysely/14844681360/1)
author_association: CONTRIBUTOR
user: login: keithwillcode
created_at: 2025-05-05T17:55:39Z
body: Converting to draft to prevent this from merging into current release
author_association: CONTRIBUTOR