2023-03-10 23:45:24 +00:00
import type { Prisma , UserPermissionRole } from "@prisma/client" ;
2021-09-14 08:45:28 +00:00
import { uuid } from "short-uuid" ;
2021-09-22 19:52:38 +00:00
2022-08-26 00:48:50 +00:00
import dailyMeta from "@calcom/app-store/dailyvideo/_metadata" ;
import googleMeetMeta from "@calcom/app-store/googlevideo/_metadata" ;
import zoomMeta from "@calcom/app-store/zoomvideo/_metadata" ;
2022-06-28 20:40:58 +00:00
import dayjs from "@calcom/dayjs" ;
2023-03-10 23:45:24 +00:00
import { hashPassword } from "@calcom/features/auth/lib/hashPassword" ;
2022-02-15 20:30:52 +00:00
import { DEFAULT_SCHEDULE , getAvailabilityFromSchedule } from "@calcom/lib/availability" ;
2023-05-02 11:44:05 +00:00
import { BookingStatus , MembershipRole } from "@calcom/prisma/enums" ;
2021-09-22 19:52:38 +00:00
2022-05-02 20:39:35 +00:00
import prisma from "." ;
2022-07-28 10:50:25 +00:00
import mainAppStore from "./seed-app-store" ;
2022-03-26 00:39:38 +00:00
2021-09-02 15:20:36 +00:00
async function createUserAndEventType ( opts : {
2021-10-12 09:35:44 +00:00
user : {
email : string ;
password : string ;
username : string ;
name : string ;
completedOnboarding? : boolean ;
2021-11-18 01:03:19 +00:00
timeZone? : string ;
2022-07-21 17:02:20 +00:00
role? : UserPermissionRole ;
2021-10-12 09:35:44 +00:00
} ;
2021-09-28 09:16:02 +00:00
eventTypes : Array <
Prisma . EventTypeCreateInput & {
_bookings? : Prisma.BookingCreateInput [ ] ;
}
> ;
2021-09-02 15:20:36 +00:00
} ) {
2022-03-22 19:43:57 +00:00
const userData = {
2021-09-02 15:20:36 +00:00
. . . opts . user ,
password : await hashPassword ( opts . user . password ) ,
emailVerified : new Date ( ) ,
2021-10-12 09:35:44 +00:00
completedOnboarding : opts.user.completedOnboarding ? ? true ,
2021-12-09 15:51:37 +00:00
locale : "en" ,
2022-03-22 19:43:57 +00:00
schedules :
opts . user . completedOnboarding ? ? true
? {
create : {
name : "Working Hours" ,
availability : {
createMany : {
data : getAvailabilityFromSchedule ( DEFAULT_SCHEDULE ) ,
} ,
2022-03-17 16:48:23 +00:00
} ,
} ,
2022-03-22 19:43:57 +00:00
}
: undefined ,
2021-09-02 15:20:36 +00:00
} ;
2022-03-22 19:43:57 +00:00
2021-09-02 15:20:36 +00:00
const user = await prisma . user . upsert ( {
feat: Organizations (#8993)
* Initial commit
* Adding feature flag
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Supporting having the orgId in the session cookie
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* feat: Onboarding process to create an organization (#9184)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Making sure we check requestedSlug now
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: [CAL-1816] Organization subdomain support (#9345)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* Covering users and subteams, excluding non-org users
* Unpublished teams shows correctly
* Create subdomain in Vercel
* feedback
* Renaming Vercel env vars
* Vercel domain check before creation
* Supporting cal-staging.com
* Change to have vercel detect it
* vercel domain check data message error
* Remove check domain
* Making sure we check requestedSlug now
* Feedback and unneeded code
* Reverting unneeded changes
* Unneeded changes
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Vercel subdomain creation in PROD only
* Making sure we let localhost still work
* Feedback
* Type check fixes
* feat: Organization branding in side menu (#9279)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Making sure we show the set up profile on org only
* Profile username availability rely on org hook
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Update apps/web/pages/team/[slug].tsx
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* feat: Organization support for event types page (#9449)
* Desktop first banner, mobile pending
* Removing dead code and img
* WIP
* Adds Email verification template+translations for organizations (#9202)
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Step 2 done, avatar not working
* Covering null on unique clauses
* Onboarding admins step
* Last step to create teams
* Moving change password handler, improving verifying code flow
* Clearing error before submitting
* Reverting email testing api changes
* Reverting having the banner for now
* Consistent exported components
* Remove unneeded files from banner
* Removing uneeded code
* Fixing avatar selector
* Org branding provider used in shell sidebar
* Using meta component for head/descr
* Missing i18n strings
* Feedback
* Making an org avatar (temp)
* Using org avatar (temp)
* Not showing org logo if not set
* User onboarding with org branding (slug)
* Check for subteams slug clashes with usernames
* Fixing create teams onsuccess
* feedback
* Feedback
* Org public profile
* Public profiles for team event types
* Added setup profile alert
* Using org avatar on subteams avatar
* Processing orgs and children as profile options
* Reverting change not belonging to this PR
* Making sure we show the set up profile on org only
* Removing console.log
* Comparing memberships to choose the highest one
---------
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
* Type errors
* Refactor and type fixes
* Update orgDomains.ts
* Feedback
* Reverting
* NIT
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Feedback
* Feedback
* Feedback
* Feedback: SSR for user event-types to have org context
* chore: Cache node_modules (#9492)
* Adding check for cache hit
* Adding a separate install step first
* Put the restore cache steps back
* Revert the uses type for restoring cache
* Added step to restore nm cache
* Removed the cache-hit check
* Comments and naming
* Removed extra install command
* Updated the name of the linting step to be more clear
* Removes the need for useEffect here
* Feedback
* Feedback
* Cookie domain needs a dot
* Type fix
* Update apps/web/public/static/locales/en/common.json
Co-authored-by: Omar López <zomars@me.com>
* Update packages/emails/src/templates/OrganizationAccountVerifyEmail.tsx
* Feedback
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-06-14 21:40:20 +00:00
where : { email_username : { email : opts.user.email , username : opts.user.username } } ,
2021-09-02 15:20:36 +00:00
update : userData ,
create : userData ,
} ) ;
console . log (
2022-03-26 00:39:38 +00:00
` 👤 Upserted ' ${ opts . user . username } ' with email " ${ opts . user . email } " & password " ${ opts . user . password } ". Booking page 👉 ${ process . env . NEXT_PUBLIC_WEBAPP_URL } / ${ opts . user . username } `
2021-09-02 15:20:36 +00:00
) ;
2021-10-28 19:36:45 +00:00
2021-09-28 09:16:02 +00:00
for ( const eventTypeInput of opts . eventTypes ) {
2023-03-02 18:15:28 +00:00
const { _bookings : bookingFields = [ ] , . . . eventTypeData } = eventTypeInput ;
2021-09-02 15:20:36 +00:00
eventTypeData . userId = user . id ;
2021-09-21 09:57:01 +00:00
eventTypeData . users = { connect : { id : user.id } } ;
2021-09-14 08:45:28 +00:00
const eventType = await prisma . eventType . findFirst ( {
2021-09-02 15:20:36 +00:00
where : {
2021-09-14 08:45:28 +00:00
slug : eventTypeData.slug ,
users : {
some : {
id : eventTypeData.userId ,
} ,
2021-09-06 13:51:15 +00:00
} ,
2021-09-02 15:20:36 +00:00
} ,
2021-09-14 08:45:28 +00:00
select : {
id : true ,
} ,
2021-09-02 15:20:36 +00:00
} ) ;
2021-09-14 08:45:28 +00:00
if ( eventType ) {
2021-09-28 09:16:02 +00:00
console . log (
2022-03-26 00:39:38 +00:00
` \ t📆 Event type ${ eventTypeData . slug } already seems seeded - ${ process . env . NEXT_PUBLIC_WEBAPP_URL } / ${ user . username } / ${ eventTypeData . slug } `
2021-09-28 09:16:02 +00:00
) ;
continue ;
2021-09-14 08:45:28 +00:00
}
2021-09-28 09:16:02 +00:00
const { id } = await prisma . eventType . create ( {
data : eventTypeData ,
} ) ;
2021-09-14 08:45:28 +00:00
2021-09-02 15:20:36 +00:00
console . log (
2022-07-21 16:44:23 +00:00
` \ t📆 Event type ${ eventTypeData . slug } with id ${ id } , length ${ eventTypeData . length } min - ${ process . env . NEXT_PUBLIC_WEBAPP_URL } / ${ user . username } / ${ eventTypeData . slug } `
2021-09-02 15:20:36 +00:00
) ;
2023-03-02 18:15:28 +00:00
for ( const bookingInput of bookingFields ) {
2021-09-28 09:16:02 +00:00
await prisma . booking . create ( {
data : {
. . . bookingInput ,
user : {
connect : {
email : opts.user.email ,
} ,
} ,
attendees : {
create : {
email : opts.user.email ,
name : opts.user.name ,
timeZone : "Europe/London" ,
} ,
} ,
eventType : {
connect : {
id ,
} ,
} ,
2022-06-06 16:54:47 +00:00
status : bookingInput.status ,
2021-09-28 09:16:02 +00:00
} ,
} ) ;
console . log (
` \ t \ t☎️ Created booking ${ bookingInput . title } at ${ new Date (
bookingInput . startTime
) . toLocaleDateString ( ) } `
) ;
}
2021-09-02 15:20:36 +00:00
}
2021-10-28 19:36:45 +00:00
return user ;
}
async function createTeamAndAddUsers (
teamInput : Prisma.TeamCreateInput ,
users : { id : number ; username : string ; role? : MembershipRole } [ ]
) {
const createTeam = async ( team : Prisma.TeamCreateInput ) = > {
try {
return await prisma . team . create ( {
data : {
. . . team ,
} ,
} ) ;
} catch ( _err ) {
if ( _err instanceof Error && _err . message . indexOf ( "Unique constraint failed on the fields" ) !== - 1 ) {
console . log ( ` Team ' ${ team . name } ' already exists, skipping. ` ) ;
return ;
}
throw _err ;
}
} ;
const team = await createTeam ( teamInput ) ;
if ( ! team ) {
return ;
}
2022-03-26 00:39:38 +00:00
console . log (
` 🏢 Created team ' ${ teamInput . name } ' - ${ process . env . NEXT_PUBLIC_WEBAPP_URL } /team/ ${ team . slug } `
) ;
2021-10-28 19:36:45 +00:00
for ( const user of users ) {
const { role = MembershipRole . OWNER , id , username } = user ;
await prisma . membership . create ( {
data : {
teamId : team.id ,
userId : id ,
role : role ,
accepted : true ,
} ,
} ) ;
console . log ( ` \ t👤 Added ' ${ teamInput . name } ' membership for ' ${ username } ' with role ' ${ role } ' ` ) ;
}
2021-09-02 15:20:36 +00:00
}
async function main() {
2022-01-14 13:49:15 +00:00
await createUserAndEventType ( {
user : {
email : "delete-me@example.com" ,
password : "delete-me" ,
username : "delete-me" ,
name : "delete-me" ,
} ,
eventTypes : [ ] ,
} ) ;
2021-09-02 15:20:36 +00:00
await createUserAndEventType ( {
user : {
2021-10-12 09:35:44 +00:00
email : "onboarding@example.com" ,
password : "onboarding" ,
username : "onboarding" ,
name : "onboarding" ,
completedOnboarding : false ,
2021-09-02 15:20:36 +00:00
} ,
2021-10-12 09:35:44 +00:00
eventTypes : [ ] ,
2021-09-02 15:20:36 +00:00
} ) ;
2021-09-06 13:51:15 +00:00
await createUserAndEventType ( {
user : {
email : "free-first-hidden@example.com" ,
password : "free-first-hidden" ,
username : "free-first-hidden" ,
2021-09-21 09:57:01 +00:00
name : "Free First Hidden Example" ,
2021-09-06 13:51:15 +00:00
} ,
eventTypes : [
{
title : "30min" ,
slug : "30min" ,
length : 30 ,
hidden : true ,
} ,
{
title : "60min" ,
slug : "60min" ,
length : 30 ,
} ,
] ,
} ) ;
2021-09-02 15:20:36 +00:00
await createUserAndEventType ( {
user : {
email : "pro@example.com" ,
2021-09-21 09:57:01 +00:00
name : "Pro Example" ,
2021-09-02 15:20:36 +00:00
password : "pro" ,
username : "pro" ,
} ,
eventTypes : [
{
title : "30min" ,
slug : "30min" ,
length : 30 ,
2021-09-28 09:16:02 +00:00
_bookings : [
{
uid : uuid ( ) ,
title : "30min" ,
startTime : dayjs ( ) . add ( 1 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 30 , "minutes" ) . toDate ( ) ,
} ,
{
uid : uuid ( ) ,
title : "30min" ,
startTime : dayjs ( ) . add ( 2 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2021-09-28 09:16:02 +00:00
} ,
2022-12-07 20:08:34 +00:00
{
// hardcode UID so that we can easily test rescheduling in embed
uid : "qm3kwt3aTnVD7vmP9tiT2f" ,
title : "30min Seeded Booking" ,
startTime : dayjs ( ) . add ( 3 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 3 , "day" ) . add ( 30 , "minutes" ) . toDate ( ) ,
status : BookingStatus.PENDING ,
} ,
2021-09-28 09:16:02 +00:00
] ,
2021-09-02 15:20:36 +00:00
} ,
{
title : "60min" ,
slug : "60min" ,
length : 60 ,
} ,
2022-11-28 18:14:01 +00:00
{
title : "Multiple duration" ,
slug : "multiple-duration" ,
length : 75 ,
metadata : {
multipleDuration : [ 30 , 75 , 90 ] ,
} ,
} ,
2021-12-17 16:58:23 +00:00
{
title : "paid" ,
slug : "paid" ,
length : 60 ,
2022-04-06 17:20:30 +00:00
price : 100 ,
2021-12-17 16:58:23 +00:00
} ,
2022-03-24 02:13:04 +00:00
{
title : "In person meeting" ,
slug : "in-person" ,
length : 60 ,
locations : [ { type : "inPerson" , address : "London" } ] ,
} ,
{
title : "Zoom Event" ,
slug : "zoom" ,
length : 60 ,
2022-08-26 00:48:50 +00:00
locations : [ { type : zoomMeta . appData ? . location . type } ] ,
2022-03-24 02:13:04 +00:00
} ,
{
title : "Daily Event" ,
slug : "daily" ,
length : 60 ,
2022-08-26 00:48:50 +00:00
locations : [ { type : dailyMeta . appData ? . location . type } ] ,
2022-03-24 02:13:04 +00:00
} ,
{
title : "Google Meet" ,
slug : "google-meet" ,
length : 60 ,
2022-08-26 00:48:50 +00:00
locations : [ { type : googleMeetMeta . appData ? . location . type } ] ,
2022-03-24 02:13:04 +00:00
} ,
2022-05-05 21:16:25 +00:00
{
title : "Yoga class" ,
slug : "yoga-class" ,
length : 30 ,
recurringEvent : { freq : 2 , count : 12 , interval : 1 } ,
_bookings : [
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . add ( 1 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 1 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . add ( 2 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 2 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . add ( 3 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 3 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . add ( 4 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 4 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Yoga class" ,
recurringEventId : Buffer.from ( "yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 1 , "day" ) . add ( 5 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 1 , "day" ) . add ( 5 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
2022-10-06 19:23:22 +00:00
status : BookingStatus.ACCEPTED ,
2022-05-05 21:16:25 +00:00
} ,
2022-10-24 22:37:55 +00:00
{
uid : uuid ( ) ,
title : "Seeded Yoga class" ,
description : "seeded" ,
recurringEventId : Buffer.from ( "seeded-yoga-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . subtract ( 4 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 30 , "minutes" ) . toDate ( ) ,
status : BookingStatus.ACCEPTED ,
} ,
{
uid : uuid ( ) ,
title : "Seeded Yoga class" ,
description : "seeded" ,
recurringEventId : Buffer.from ( "seeded-yoga-class" ) . toString ( "base64" ) ,
2022-11-04 16:43:02 +00:00
startTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 1 , "week" ) . toDate ( ) ,
2022-10-24 22:37:55 +00:00
endTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 1 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
status : BookingStatus.ACCEPTED ,
} ,
{
uid : uuid ( ) ,
title : "Seeded Yoga class" ,
description : "seeded" ,
recurringEventId : Buffer.from ( "seeded-yoga-class" ) . toString ( "base64" ) ,
2022-11-04 16:43:02 +00:00
startTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 2 , "week" ) . toDate ( ) ,
2022-10-24 22:37:55 +00:00
endTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 2 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
status : BookingStatus.ACCEPTED ,
} ,
{
uid : uuid ( ) ,
title : "Seeded Yoga class" ,
description : "seeded" ,
recurringEventId : Buffer.from ( "seeded-yoga-class" ) . toString ( "base64" ) ,
2022-11-04 16:43:02 +00:00
startTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 3 , "week" ) . toDate ( ) ,
2022-10-24 22:37:55 +00:00
endTime : dayjs ( ) . subtract ( 4 , "day" ) . add ( 3 , "week" ) . add ( 30 , "minutes" ) . toDate ( ) ,
status : BookingStatus.ACCEPTED ,
} ,
2022-05-05 21:16:25 +00:00
] ,
} ,
{
title : "Tennis class" ,
slug : "tennis-class" ,
length : 60 ,
recurringEvent : { freq : 2 , count : 10 , interval : 2 } ,
requiresConfirmation : true ,
_bookings : [
{
uid : uuid ( ) ,
title : "Tennis class" ,
recurringEventId : Buffer.from ( "tennis-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 2 , "day" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 60 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Tennis class" ,
recurringEventId : Buffer.from ( "tennis-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 2 , "day" ) . add ( 2 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 2 , "week" ) . add ( 60 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Tennis class" ,
recurringEventId : Buffer.from ( "tennis-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 2 , "day" ) . add ( 4 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 4 , "week" ) . add ( 60 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Tennis class" ,
recurringEventId : Buffer.from ( "tennis-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 2 , "day" ) . add ( 8 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 8 , "week" ) . add ( 60 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2022-05-05 21:16:25 +00:00
} ,
{
uid : uuid ( ) ,
title : "Tennis class" ,
recurringEventId : Buffer.from ( "tennis-class" ) . toString ( "base64" ) ,
startTime : dayjs ( ) . add ( 2 , "day" ) . add ( 10 , "week" ) . toDate ( ) ,
endTime : dayjs ( ) . add ( 2 , "day" ) . add ( 10 , "week" ) . add ( 60 , "minutes" ) . toDate ( ) ,
2022-06-06 16:54:47 +00:00
status : BookingStatus.PENDING ,
2022-05-05 21:16:25 +00:00
} ,
] ,
} ,
2021-09-02 15:20:36 +00:00
] ,
} ) ;
2021-09-14 08:45:28 +00:00
2021-09-02 15:20:36 +00:00
await createUserAndEventType ( {
user : {
email : "trial@example.com" ,
password : "trial" ,
username : "trial" ,
2021-09-21 09:57:01 +00:00
name : "Trial Example" ,
2021-09-02 15:20:36 +00:00
} ,
eventTypes : [
{
title : "30min" ,
slug : "30min" ,
length : 30 ,
} ,
{
title : "60min" ,
slug : "60min" ,
length : 60 ,
} ,
] ,
} ) ;
2021-10-12 09:35:44 +00:00
await createUserAndEventType ( {
user : {
email : "free@example.com" ,
password : "free" ,
username : "free" ,
name : "Free Example" ,
} ,
eventTypes : [
{
title : "30min" ,
slug : "30min" ,
length : 30 ,
} ,
{
title : "60min" ,
slug : "60min" ,
length : 30 ,
} ,
] ,
} ) ;
2021-11-18 01:03:19 +00:00
await createUserAndEventType ( {
user : {
email : "usa@example.com" ,
password : "usa" ,
username : "usa" ,
name : "USA Timezone Example" ,
timeZone : "America/Phoenix" ,
} ,
eventTypes : [
{
title : "30min" ,
slug : "30min" ,
length : 30 ,
} ,
] ,
} ) ;
2021-10-28 19:36:45 +00:00
const freeUserTeam = await createUserAndEventType ( {
user : {
email : "teamfree@example.com" ,
password : "teamfree" ,
username : "teamfree" ,
name : "Team Free Example" ,
} ,
eventTypes : [ ] ,
} ) ;
const proUserTeam = await createUserAndEventType ( {
user : {
email : "teampro@example.com" ,
password : "teampro" ,
username : "teampro" ,
name : "Team Pro Example" ,
} ,
eventTypes : [ ] ,
} ) ;
2022-07-21 17:02:20 +00:00
await createUserAndEventType ( {
user : {
email : "admin@example.com" ,
2022-11-23 21:54:41 +00:00
/** To comply with admin password requirements */
password : "ADMINadmin2022!" ,
2022-07-21 17:02:20 +00:00
username : "admin" ,
name : "Admin Example" ,
role : "ADMIN" ,
} ,
eventTypes : [ ] ,
} ) ;
2022-03-18 20:28:12 +00:00
const pro2UserTeam = await createUserAndEventType ( {
user : {
email : "teampro2@example.com" ,
password : "teampro2" ,
username : "teampro2" ,
name : "Team Pro Example 2" ,
} ,
eventTypes : [ ] ,
} ) ;
const pro3UserTeam = await createUserAndEventType ( {
user : {
email : "teampro3@example.com" ,
password : "teampro3" ,
username : "teampro3" ,
name : "Team Pro Example 3" ,
} ,
eventTypes : [ ] ,
} ) ;
const pro4UserTeam = await createUserAndEventType ( {
user : {
email : "teampro4@example.com" ,
password : "teampro4" ,
username : "teampro4" ,
name : "Team Pro Example 4" ,
} ,
eventTypes : [ ] ,
} ) ;
2021-10-28 19:36:45 +00:00
await createTeamAndAddUsers (
{
name : "Seeded Team" ,
slug : "seeded-team" ,
2022-03-18 20:28:12 +00:00
eventTypes : {
createMany : {
data : [
{
title : "Collective Seeded Team Event" ,
slug : "collective-seeded-team-event" ,
length : 15 ,
schedulingType : "COLLECTIVE" ,
} ,
{
title : "Round Robin Seeded Team Event" ,
slug : "round-robin-seeded-team-event" ,
length : 15 ,
schedulingType : "ROUND_ROBIN" ,
} ,
] ,
} ,
} ,
2022-11-10 20:23:56 +00:00
createdAt : new Date ( ) ,
2021-10-28 19:36:45 +00:00
} ,
[
{
id : proUserTeam.id ,
username : proUserTeam.name || "Unknown" ,
} ,
{
id : freeUserTeam.id ,
username : freeUserTeam.name || "Unknown" ,
} ,
2022-03-18 20:28:12 +00:00
{
id : pro2UserTeam.id ,
username : pro2UserTeam.name || "Unknown" ,
2022-07-21 17:02:20 +00:00
role : "MEMBER" ,
2022-03-18 20:28:12 +00:00
} ,
{
id : pro3UserTeam.id ,
username : pro3UserTeam.name || "Unknown" ,
} ,
{
id : pro4UserTeam.id ,
username : pro4UserTeam.name || "Unknown" ,
} ,
2021-10-28 19:36:45 +00:00
]
) ;
2021-09-02 15:20:36 +00:00
}
main ( )
2022-07-28 10:50:25 +00:00
. then ( ( ) = > mainAppStore ( ) )
2021-09-02 15:20:36 +00:00
. catch ( ( e ) = > {
console . error ( e ) ;
process . exit ( 1 ) ;
2022-02-22 19:04:55 +00:00
} )
. finally ( async ( ) = > {
await prisma . $disconnect ( ) ;
2021-09-02 15:20:36 +00:00
} ) ;