Compare commits

...

6 Commits

Author SHA1 Message Date
zomars 13f1040de5 Update CreateEventType.tsx 2022-02-17 17:31:22 -07:00
Omar López 0a30970fb7
Merge branch 'main' into tweak/gitignore-prisma-zod 2022-02-17 17:25:30 -07:00
zomars 977f2afb47 Adds postinstall script 2022-02-17 17:17:21 -07:00
zomars a6d0a0ebe7 Extracts ignored createEventTypeBaseInput 2022-02-17 17:07:06 -07:00
kodiakhq[bot] 5be554143d
Merge branch 'main' into tweak/gitignore-prisma-zod 2022-02-18 00:02:24 +00:00
Alex van Andel 9aeb8f2507 Gitignored prisma/zod 2022-02-17 21:50:37 +01:00
23 changed files with 6 additions and 610 deletions

6
.gitignore vendored
View File

@ -59,5 +59,9 @@ yarn-error.log*
# Typescript
tsconfig.tsbuildinfo
# turbo
.turbo
.turbo
# prisma
packages/prisma/zod

View File

@ -6,7 +6,7 @@ import React, { useEffect } from "react";
import { useForm } from "react-hook-form";
import type { z } from "zod";
import { createEventTypeInput } from "@calcom/prisma/zod/eventtypeCustom";
import { createEventTypeInput } from "@calcom/prisma/zod-utils";
import { HttpError } from "@lib/core/http/error";
import { useLocale } from "@lib/hooks/useLocale";

View File

@ -1,25 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteBooking, BookingModel } from "./index"
export const _AttendeeModel = z.object({
id: z.number().int(),
email: z.string(),
name: z.string(),
timeZone: z.string(),
locale: z.string().nullish(),
bookingId: z.number().int().nullish(),
})
export interface CompleteAttendee extends z.infer<typeof _AttendeeModel> {
booking?: CompleteBooking | null
}
/**
* AttendeeModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const AttendeeModel: z.ZodSchema<CompleteAttendee> = z.lazy(() => _AttendeeModel.extend({
booking: BookingModel.nullish(),
}))

View File

@ -1,29 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteUser, UserModel, CompleteEventType, EventTypeModel } from "./index"
export const _AvailabilityModel = z.object({
id: z.number().int(),
label: z.string().nullish(),
userId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
days: z.number().int().array(),
startTime: z.date(),
endTime: z.date(),
date: z.date().nullish(),
})
export interface CompleteAvailability extends z.infer<typeof _AvailabilityModel> {
user?: CompleteUser | null
eventType?: CompleteEventType | null
}
/**
* AvailabilityModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const AvailabilityModel: z.ZodSchema<CompleteAvailability> = z.lazy(() => _AvailabilityModel.extend({
user: UserModel.nullish(),
eventType: EventTypeModel.nullish(),
}))

View File

@ -1,49 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { BookingStatus } from "@prisma/client"
import { CompleteUser, UserModel, CompleteBookingReference, BookingReferenceModel, CompleteEventType, EventTypeModel, CompleteAttendee, AttendeeModel, CompleteDailyEventReference, DailyEventReferenceModel, CompletePayment, PaymentModel, CompleteDestinationCalendar, DestinationCalendarModel } from "./index"
export const _BookingModel = z.object({
id: z.number().int(),
uid: z.string(),
userId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
title: z.string(),
description: z.string().nullish(),
startTime: z.date(),
endTime: z.date(),
location: z.string().nullish(),
createdAt: z.date(),
updatedAt: z.date().nullish(),
confirmed: z.boolean(),
rejected: z.boolean(),
status: z.nativeEnum(BookingStatus),
paid: z.boolean(),
cancellationReason: z.string().nullish(),
rejectionReason: z.string().nullish(),
})
export interface CompleteBooking extends z.infer<typeof _BookingModel> {
user?: CompleteUser | null
references: CompleteBookingReference[]
eventType?: CompleteEventType | null
attendees: CompleteAttendee[]
dailyRef?: CompleteDailyEventReference | null
payment: CompletePayment[]
destinationCalendar?: CompleteDestinationCalendar | null
}
/**
* BookingModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const BookingModel: z.ZodSchema<CompleteBooking> = z.lazy(() => _BookingModel.extend({
user: UserModel.nullish(),
references: BookingReferenceModel.array(),
eventType: EventTypeModel.nullish(),
attendees: AttendeeModel.array(),
dailyRef: DailyEventReferenceModel.nullish(),
payment: PaymentModel.array(),
destinationCalendar: DestinationCalendarModel.nullish(),
}))

View File

@ -1,26 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteBooking, BookingModel } from "./index"
export const _BookingReferenceModel = z.object({
id: z.number().int(),
type: z.string(),
uid: z.string(),
meetingId: z.string().nullish(),
meetingPassword: z.string().nullish(),
meetingUrl: z.string().nullish(),
bookingId: z.number().int().nullish(),
})
export interface CompleteBookingReference extends z.infer<typeof _BookingReferenceModel> {
booking?: CompleteBooking | null
}
/**
* BookingReferenceModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const BookingReferenceModel: z.ZodSchema<CompleteBookingReference> = z.lazy(() => _BookingReferenceModel.extend({
booking: BookingModel.nullish(),
}))

View File

@ -1,29 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteUser, UserModel } from "./index"
// 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()])
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
export const _CredentialModel = z.object({
id: z.number().int(),
type: z.string(),
key: jsonSchema,
userId: z.number().int().nullish(),
})
export interface CompleteCredential extends z.infer<typeof _CredentialModel> {
user?: CompleteUser | null
}
/**
* CredentialModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const CredentialModel: z.ZodSchema<CompleteCredential> = z.lazy(() => _CredentialModel.extend({
user: UserModel.nullish(),
}))

View File

@ -1,23 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteBooking, BookingModel } from "./index"
export const _DailyEventReferenceModel = z.object({
id: z.number().int(),
dailyurl: z.string(),
dailytoken: z.string(),
bookingId: z.number().int().nullish(),
})
export interface CompleteDailyEventReference extends z.infer<typeof _DailyEventReferenceModel> {
booking?: CompleteBooking | null
}
/**
* DailyEventReferenceModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const DailyEventReferenceModel: z.ZodSchema<CompleteDailyEventReference> = z.lazy(() => _DailyEventReferenceModel.extend({
booking: BookingModel.nullish(),
}))

View File

@ -1,29 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteUser, UserModel, CompleteBooking, BookingModel, CompleteEventType, EventTypeModel } from "./index"
export const _DestinationCalendarModel = z.object({
id: z.number().int(),
integration: z.string(),
externalId: z.string(),
userId: z.number().int().nullish(),
bookingId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
})
export interface CompleteDestinationCalendar extends z.infer<typeof _DestinationCalendarModel> {
user?: CompleteUser | null
booking?: CompleteBooking | null
eventType?: CompleteEventType | null
}
/**
* DestinationCalendarModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const DestinationCalendarModel: z.ZodSchema<CompleteDestinationCalendar> = z.lazy(() => _DestinationCalendarModel.extend({
user: UserModel.nullish(),
booking: BookingModel.nullish(),
eventType: EventTypeModel.nullish(),
}))

View File

@ -1,63 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { PeriodType, SchedulingType } from "@prisma/client"
import { CompleteUser, UserModel, CompleteTeam, TeamModel, CompleteBooking, BookingModel, CompleteAvailability, AvailabilityModel, CompleteDestinationCalendar, DestinationCalendarModel, CompleteEventTypeCustomInput, EventTypeCustomInputModel, CompleteSchedule, ScheduleModel } from "./index"
// 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()])
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
export const _EventTypeModel = z.object({
id: z.number().int(),
title: z.string().nonempty(),
slug: imports.eventTypeSlug,
description: z.string().nullish(),
position: z.number().int(),
locations: imports.eventTypeLocations,
length: z.number().int(),
hidden: z.boolean(),
userId: z.number().int().nullish(),
teamId: z.number().int().nullish(),
eventName: z.string().nullish(),
timeZone: z.string().nullish(),
periodType: z.nativeEnum(PeriodType),
periodStartDate: z.date().nullish(),
periodEndDate: z.date().nullish(),
periodDays: z.number().int().nullish(),
periodCountCalendarDays: z.boolean().nullish(),
requiresConfirmation: z.boolean(),
disableGuests: z.boolean(),
minimumBookingNotice: z.number().int(),
schedulingType: z.nativeEnum(SchedulingType).nullish(),
price: z.number().int(),
currency: z.string(),
slotInterval: z.number().int().nullish(),
metadata: jsonSchema,
})
export interface CompleteEventType extends z.infer<typeof _EventTypeModel> {
users: CompleteUser[]
team?: CompleteTeam | null
bookings: CompleteBooking[]
availability: CompleteAvailability[]
destinationCalendar?: CompleteDestinationCalendar | null
customInputs: CompleteEventTypeCustomInput[]
Schedule: CompleteSchedule[]
}
/**
* EventTypeModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const EventTypeModel: z.ZodSchema<CompleteEventType> = z.lazy(() => _EventTypeModel.extend({
users: UserModel.array(),
team: TeamModel.nullish(),
bookings: BookingModel.array(),
availability: AvailabilityModel.array(),
destinationCalendar: DestinationCalendarModel.nullish(),
customInputs: EventTypeCustomInputModel.array(),
Schedule: ScheduleModel.array(),
}))

View File

@ -1,17 +0,0 @@
import { _EventTypeModel } from "./eventtype";
const createEventTypeBaseInput = _EventTypeModel
.pick({
title: true,
slug: true,
description: true,
length: true,
teamId: true,
schedulingType: true,
})
.refine((data) => (data.teamId ? data.teamId && data.schedulingType : true), {
path: ["schedulingType"],
message: "You must select a scheduling type for team events",
});
export const createEventTypeInput = createEventTypeBaseInput;

View File

@ -1,26 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { EventTypeCustomInputType } from "@prisma/client"
import { CompleteEventType, EventTypeModel } from "./index"
export const _EventTypeCustomInputModel = z.object({
id: z.number().int(),
eventTypeId: z.number().int(),
label: z.string(),
type: z.nativeEnum(EventTypeCustomInputType),
required: z.boolean(),
placeholder: z.string(),
})
export interface CompleteEventTypeCustomInput extends z.infer<typeof _EventTypeCustomInputModel> {
eventType: CompleteEventType
}
/**
* EventTypeCustomInputModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const EventTypeCustomInputModel: z.ZodSchema<CompleteEventTypeCustomInput> = z.lazy(() => _EventTypeCustomInputModel.extend({
eventType: EventTypeModel,
}))

View File

@ -1,19 +0,0 @@
export * from "./eventtype"
export * from "./credential"
export * from "./destinationcalendar"
export * from "./user"
export * from "./team"
export * from "./membership"
export * from "./verificationrequest"
export * from "./bookingreference"
export * from "./attendee"
export * from "./dailyeventreference"
export * from "./booking"
export * from "./schedule"
export * from "./availability"
export * from "./selectedcalendar"
export * from "./eventtypecustominput"
export * from "./resetpasswordrequest"
export * from "./remindermail"
export * from "./payment"
export * from "./webhook"

View File

@ -1,26 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { MembershipRole } from "@prisma/client"
import { CompleteTeam, TeamModel, CompleteUser, UserModel } from "./index"
export const _MembershipModel = z.object({
teamId: z.number().int(),
userId: z.number().int(),
accepted: z.boolean(),
role: z.nativeEnum(MembershipRole),
})
export interface CompleteMembership extends z.infer<typeof _MembershipModel> {
team: CompleteTeam
user: CompleteUser
}
/**
* MembershipModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const MembershipModel: z.ZodSchema<CompleteMembership> = z.lazy(() => _MembershipModel.extend({
team: TeamModel,
user: UserModel,
}))

View File

@ -1,37 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { PaymentType } from "@prisma/client"
import { CompleteBooking, BookingModel } from "./index"
// 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()])
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
export const _PaymentModel = z.object({
id: z.number().int(),
uid: z.string(),
type: z.nativeEnum(PaymentType),
bookingId: z.number().int(),
amount: z.number().int(),
fee: z.number().int(),
currency: z.string(),
success: z.boolean(),
refunded: z.boolean(),
data: jsonSchema,
externalId: z.string(),
})
export interface CompletePayment extends z.infer<typeof _PaymentModel> {
booking?: CompleteBooking | null
}
/**
* PaymentModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const PaymentModel: z.ZodSchema<CompletePayment> = z.lazy(() => _PaymentModel.extend({
booking: BookingModel.nullish(),
}))

View File

@ -1,11 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { ReminderType } from "@prisma/client"
export const _ReminderMailModel = z.object({
id: z.number().int(),
referenceId: z.number().int(),
reminderType: z.nativeEnum(ReminderType),
elapsedMinutes: z.number().int(),
createdAt: z.date(),
})

View File

@ -1,10 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
export const _ResetPasswordRequestModel = z.object({
id: z.string(),
createdAt: z.date(),
updatedAt: z.date(),
email: z.string(),
expires: z.date(),
})

View File

@ -1,32 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteUser, UserModel, CompleteEventType, EventTypeModel } from "./index"
// 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()])
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
export const _ScheduleModel = z.object({
id: z.number().int(),
userId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
title: z.string().nullish(),
freeBusyTimes: jsonSchema,
})
export interface CompleteSchedule extends z.infer<typeof _ScheduleModel> {
user?: CompleteUser | null
eventType?: CompleteEventType | null
}
/**
* ScheduleModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const ScheduleModel: z.ZodSchema<CompleteSchedule> = z.lazy(() => _ScheduleModel.extend({
user: UserModel.nullish(),
eventType: EventTypeModel.nullish(),
}))

View File

@ -1,22 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteUser, UserModel } from "./index"
export const _SelectedCalendarModel = z.object({
userId: z.number().int(),
integration: z.string(),
externalId: z.string(),
})
export interface CompleteSelectedCalendar extends z.infer<typeof _SelectedCalendarModel> {
user: CompleteUser
}
/**
* SelectedCalendarModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const SelectedCalendarModel: z.ZodSchema<CompleteSelectedCalendar> = z.lazy(() => _SelectedCalendarModel.extend({
user: UserModel,
}))

View File

@ -1,27 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { CompleteMembership, MembershipModel, CompleteEventType, EventTypeModel } from "./index"
export const _TeamModel = z.object({
id: z.number().int(),
name: z.string().nullish(),
slug: z.string().nullish(),
logo: z.string().nullish(),
bio: z.string().nullish(),
hideBranding: z.boolean(),
})
export interface CompleteTeam extends z.infer<typeof _TeamModel> {
members: CompleteMembership[]
eventTypes: CompleteEventType[]
}
/**
* TeamModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const TeamModel: z.ZodSchema<CompleteTeam> = z.lazy(() => _TeamModel.extend({
members: MembershipModel.array(),
eventTypes: EventTypeModel.array(),
}))

View File

@ -1,70 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { IdentityProvider, UserPlan } from "@prisma/client"
import { CompleteEventType, EventTypeModel, CompleteCredential, CredentialModel, CompleteMembership, MembershipModel, CompleteBooking, BookingModel, CompleteAvailability, AvailabilityModel, CompleteSelectedCalendar, SelectedCalendarModel, CompleteSchedule, ScheduleModel, CompleteWebhook, WebhookModel, CompleteDestinationCalendar, DestinationCalendarModel } from "./index"
// 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()])
const jsonSchema: z.ZodSchema<Json> = z.lazy(() => z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]))
export const _UserModel = z.object({
id: z.number().int(),
username: z.string().nullish(),
name: z.string().nullish(),
email: z.string().email(),
emailVerified: z.date().nullish(),
password: z.string().nullish(),
bio: z.string().nullish(),
avatar: z.string().nullish(),
timeZone: z.string(),
weekStart: z.string(),
startTime: z.number().int(),
endTime: z.number().int(),
bufferTime: z.number().int(),
hideBranding: z.boolean(),
theme: z.string().nullish(),
createdDate: z.date(),
completedOnboarding: z.boolean(),
locale: z.string().nullish(),
twoFactorSecret: z.string().nullish(),
twoFactorEnabled: z.boolean(),
identityProvider: z.nativeEnum(IdentityProvider),
identityProviderId: z.string().nullish(),
invitedTo: z.number().int().nullish(),
plan: z.nativeEnum(UserPlan),
brandColor: z.string(),
away: z.boolean(),
metadata: jsonSchema,
verified: z.boolean().nullish(),
})
export interface CompleteUser extends z.infer<typeof _UserModel> {
eventTypes: CompleteEventType[]
credentials: CompleteCredential[]
teams: CompleteMembership[]
bookings: CompleteBooking[]
availability: CompleteAvailability[]
selectedCalendars: CompleteSelectedCalendar[]
Schedule: CompleteSchedule[]
webhooks: CompleteWebhook[]
destinationCalendar?: CompleteDestinationCalendar | null
}
/**
* UserModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const UserModel: z.ZodSchema<CompleteUser> = z.lazy(() => _UserModel.extend({
eventTypes: EventTypeModel.array(),
credentials: CredentialModel.array(),
teams: MembershipModel.array(),
bookings: BookingModel.array(),
availability: AvailabilityModel.array(),
selectedCalendars: SelectedCalendarModel.array(),
Schedule: ScheduleModel.array(),
webhooks: WebhookModel.array(),
destinationCalendar: DestinationCalendarModel.nullish(),
}))

View File

@ -1,11 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
export const _VerificationRequestModel = z.object({
id: z.number().int(),
identifier: z.string(),
token: z.string(),
expires: z.date(),
createdAt: z.date(),
updatedAt: z.date(),
})

View File

@ -1,27 +0,0 @@
import * as z from "zod"
import * as imports from "../zod-utils"
import { WebhookTriggerEvents } from "@prisma/client"
import { CompleteUser, UserModel } from "./index"
export const _WebhookModel = z.object({
id: z.string(),
userId: z.number().int(),
subscriberUrl: z.string(),
payloadTemplate: z.string().nullish(),
createdAt: z.date(),
active: z.boolean(),
eventTriggers: z.nativeEnum(WebhookTriggerEvents).array(),
})
export interface CompleteWebhook extends z.infer<typeof _WebhookModel> {
user: CompleteUser
}
/**
* WebhookModel contains all relations on your model in addition to the scalars
*
* NOTE: Lazy required in case of potential circular dependencies within schema
*/
export const WebhookModel: z.ZodSchema<CompleteWebhook> = z.lazy(() => _WebhookModel.extend({
user: UserModel,
}))