chore: bring up to date booking references, bookings, and credentials
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
User,
|
||||
ApiKey,
|
||||
Team,
|
||||
Credential,
|
||||
SelectedCalendar,
|
||||
EventType,
|
||||
Attendee,
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _BookingReferenceModel as BookingReference } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaBookingReferenceBodyParams = BookingReference.omit({ id: true });
|
||||
export const schemaBookingReferenceBaseBodyParams = BookingReference.omit({ id: true }).partial();
|
||||
|
||||
export const schemaBookingReferencePublic = BookingReference.omit({});
|
||||
|
||||
const schemaBookingReferenceRequiredParams = z.object({
|
||||
type: z.string(),
|
||||
uid: z.string(),
|
||||
});
|
||||
|
||||
export const schemaBookingReferenceBodyParams = schemaBookingReferenceBaseBodyParams.merge(
|
||||
schemaBookingReferenceRequiredParams
|
||||
);
|
||||
|
||||
export const withValidBookingReference = withValidation({
|
||||
schema: schemaBookingReferenceBodyParams,
|
||||
type: "Zod",
|
||||
|
||||
@@ -3,10 +3,8 @@ import { z } from "zod";
|
||||
|
||||
import { _BookingModel as Booking } from "@calcom/prisma/zod";
|
||||
|
||||
// Here we remove any parameters that are not needed for the API with omit.
|
||||
const schemaBookingBaseBodyParams = Booking.omit({ id: true }).partial();
|
||||
// Here we redeclare the required ones after removing the ones we don't need.
|
||||
// and making the rest optional with .partial()
|
||||
|
||||
const schemaBookingRequiredParams = z.object({
|
||||
uid: z.string(),
|
||||
title: z.string(),
|
||||
|
||||
@@ -1,8 +1,20 @@
|
||||
import { withValidation } from "next-validations";
|
||||
import { z } from "zod";
|
||||
|
||||
import { _CredentialModel as Credential } from "@calcom/prisma/zod";
|
||||
|
||||
export const schemaCredentialBodyParams = Credential.omit({ id: true });
|
||||
import { jsonSchema } from "./shared/jsonSchema";
|
||||
|
||||
const schemaCredentialBaseBodyParams = Credential.omit({ id: true, userId: true }).partial();
|
||||
|
||||
const schemaCredentialRequiredParams = z.object({
|
||||
type: z.string(),
|
||||
key: jsonSchema,
|
||||
});
|
||||
|
||||
export const schemaCredentialBodyParams = schemaCredentialBaseBodyParams.merge(
|
||||
schemaCredentialRequiredParams
|
||||
);
|
||||
|
||||
export const schemaCredentialPublic = Credential.omit({});
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// Helper schema for JSON fields
|
||||
type Literal = boolean | number | string;
|
||||
type Json = Literal | { [key: string]: Json } | Json[];
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
export const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||
);
|
||||
Reference in New Issue
Block a user