2023-04-13 02:10:23 +00:00
|
|
|
import type { Prisma } from "@prisma/client";
|
2023-03-02 18:15:28 +00:00
|
|
|
import type { UnitTypeLongPlural } from "dayjs";
|
2022-10-07 20:48:41 +00:00
|
|
|
import z, { ZodNullable, ZodObject, ZodOptional } from "zod";
|
|
|
|
|
|
|
|
/* eslint-disable no-underscore-dangle */
|
|
|
|
import type {
|
2023-08-31 22:27:51 +00:00
|
|
|
AnyZodObject,
|
2022-10-07 20:48:41 +00:00
|
|
|
objectInputType,
|
|
|
|
objectOutputType,
|
|
|
|
ZodNullableDef,
|
|
|
|
ZodOptionalDef,
|
|
|
|
ZodRawShape,
|
|
|
|
ZodTypeAny,
|
|
|
|
} from "zod";
|
2022-01-21 21:35:31 +00:00
|
|
|
|
2022-10-14 18:35:30 +00:00
|
|
|
import { appDataSchemas } from "@calcom/app-store/apps.schemas.generated";
|
2022-06-28 20:40:58 +00:00
|
|
|
import dayjs from "@calcom/dayjs";
|
2023-08-29 11:56:45 +00:00
|
|
|
import { isPasswordValid } from "@calcom/features/auth/lib/isPasswordValid";
|
2023-07-20 05:03:50 +00:00
|
|
|
import type { FieldType as FormBuilderFieldType } from "@calcom/features/form-builder/schema";
|
|
|
|
import { fieldsSchema as formBuilderFieldsSchema } from "@calcom/features/form-builder/schema";
|
2023-07-18 16:09:31 +00:00
|
|
|
import { isSupportedTimeZone } from "@calcom/lib/date-fns";
|
2022-02-21 18:45:35 +00:00
|
|
|
import { slugify } from "@calcom/lib/slugify";
|
2023-05-02 11:44:05 +00:00
|
|
|
import { EventTypeCustomInputType } from "@calcom/prisma/enums";
|
2022-01-21 21:35:31 +00:00
|
|
|
|
2023-07-20 05:03:50 +00:00
|
|
|
export const nonEmptyString = () => z.string().refine((value: string) => value.trim().length > 0);
|
|
|
|
|
2022-06-10 00:32:34 +00:00
|
|
|
// Let's not import 118kb just to get an enum
|
|
|
|
export enum Frequency {
|
|
|
|
YEARLY = 0,
|
|
|
|
MONTHLY = 1,
|
|
|
|
WEEKLY = 2,
|
|
|
|
DAILY = 3,
|
|
|
|
HOURLY = 4,
|
|
|
|
MINUTELY = 5,
|
|
|
|
SECONDLY = 6,
|
|
|
|
}
|
|
|
|
|
2023-06-06 15:31:43 +00:00
|
|
|
export enum BookerLayouts {
|
|
|
|
MONTH_VIEW = "month_view",
|
|
|
|
WEEK_VIEW = "week_view",
|
|
|
|
COLUMN_VIEW = "column_view",
|
|
|
|
}
|
|
|
|
|
|
|
|
export const bookerLayoutOptions = [
|
|
|
|
BookerLayouts.MONTH_VIEW,
|
|
|
|
BookerLayouts.WEEK_VIEW,
|
|
|
|
BookerLayouts.COLUMN_VIEW,
|
|
|
|
];
|
|
|
|
|
|
|
|
const layoutOptions = z.union([
|
|
|
|
z.literal(bookerLayoutOptions[0]),
|
|
|
|
z.literal(bookerLayoutOptions[1]),
|
|
|
|
z.literal(bookerLayoutOptions[2]),
|
|
|
|
]);
|
|
|
|
|
|
|
|
export const bookerLayouts = z
|
|
|
|
.object({
|
|
|
|
enabledLayouts: z.array(layoutOptions),
|
|
|
|
defaultLayout: layoutOptions,
|
|
|
|
})
|
|
|
|
.nullable();
|
|
|
|
|
2023-06-08 12:32:17 +00:00
|
|
|
export const defaultBookerLayoutSettings = {
|
|
|
|
defaultLayout: BookerLayouts.MONTH_VIEW,
|
|
|
|
// if the user has no explicit layouts set (not in user profile and not in event settings), all layouts are enabled.
|
|
|
|
enabledLayouts: bookerLayoutOptions,
|
|
|
|
};
|
|
|
|
|
2023-06-06 15:31:43 +00:00
|
|
|
export type BookerLayoutSettings = z.infer<typeof bookerLayouts>;
|
|
|
|
|
2022-12-05 12:12:14 +00:00
|
|
|
export const RequiresConfirmationThresholdUnits: z.ZodType<UnitTypeLongPlural> = z.enum(["hours", "minutes"]);
|
|
|
|
|
2022-10-14 16:24:43 +00:00
|
|
|
export const EventTypeMetaDataSchema = z
|
|
|
|
.object({
|
|
|
|
smartContractAddress: z.string().optional(),
|
|
|
|
blockchainId: z.number().optional(),
|
2022-11-28 18:14:01 +00:00
|
|
|
multipleDuration: z.number().array().optional(),
|
2022-10-14 16:24:43 +00:00
|
|
|
giphyThankYouPage: z.string().optional(),
|
|
|
|
apps: z.object(appDataSchemas).partial().optional(),
|
2022-10-17 09:43:16 +00:00
|
|
|
additionalNotesRequired: z.boolean().optional(),
|
2023-01-02 08:41:39 +00:00
|
|
|
disableSuccessPage: z.boolean().optional(),
|
2023-05-09 17:08:14 +00:00
|
|
|
disableStandardEmails: z
|
|
|
|
.object({
|
|
|
|
confirmation: z
|
|
|
|
.object({
|
|
|
|
host: z.boolean().optional(),
|
|
|
|
attendee: z.boolean().optional(),
|
|
|
|
})
|
|
|
|
.optional(),
|
|
|
|
})
|
|
|
|
.optional(),
|
2023-04-13 02:10:23 +00:00
|
|
|
managedEventConfig: z
|
|
|
|
.object({
|
|
|
|
unlockedFields: z.custom<{ [k in keyof Omit<Prisma.EventTypeSelect, "id">]: true }>().optional(),
|
|
|
|
})
|
|
|
|
.optional(),
|
2022-12-05 12:12:14 +00:00
|
|
|
requiresConfirmationThreshold: z
|
|
|
|
.object({
|
|
|
|
time: z.number(),
|
|
|
|
unit: RequiresConfirmationThresholdUnits,
|
|
|
|
})
|
|
|
|
.optional(),
|
2022-11-03 14:24:07 +00:00
|
|
|
config: z
|
|
|
|
.object({
|
|
|
|
useHostSchedulesForTeamEvent: z.boolean().optional(),
|
|
|
|
})
|
|
|
|
.optional(),
|
2023-06-06 15:31:43 +00:00
|
|
|
bookerLayouts: bookerLayouts.optional(),
|
2022-10-14 16:24:43 +00:00
|
|
|
})
|
|
|
|
.nullable();
|
|
|
|
|
2023-03-02 18:15:28 +00:00
|
|
|
export const eventTypeBookingFields = formBuilderFieldsSchema;
|
2023-07-20 05:03:50 +00:00
|
|
|
export const BookingFieldTypeEnum = eventTypeBookingFields.element.shape.type.Enum;
|
|
|
|
export type BookingFieldType = FormBuilderFieldType;
|
2023-03-02 18:15:28 +00:00
|
|
|
|
|
|
|
// Validation of user added bookingFields' responses happen using `getBookingResponsesSchema` which requires `eventType`.
|
|
|
|
// So it is a dynamic validation and thus entire validation can't exist here
|
|
|
|
export const bookingResponses = z
|
|
|
|
.object({
|
|
|
|
email: z.string(),
|
2023-07-20 05:03:50 +00:00
|
|
|
//TODO: Why don't we move name out of bookingResponses and let it be handled like user fields?
|
|
|
|
name: z.union([
|
|
|
|
nonEmptyString(),
|
|
|
|
z.object({
|
|
|
|
firstName: nonEmptyString(),
|
|
|
|
lastName: nonEmptyString()
|
|
|
|
.refine((value: string) => value.trim().length > 0)
|
|
|
|
.optional(),
|
|
|
|
}),
|
|
|
|
]),
|
2023-03-02 18:15:28 +00:00
|
|
|
guests: z.array(z.string()).optional(),
|
|
|
|
notes: z.string().optional(),
|
|
|
|
location: z
|
|
|
|
.object({
|
|
|
|
optionValue: z.string(),
|
|
|
|
value: z.string(),
|
|
|
|
})
|
|
|
|
.optional(),
|
|
|
|
smsReminderNumber: z.string().optional(),
|
|
|
|
rescheduleReason: z.string().optional(),
|
|
|
|
})
|
|
|
|
.nullable();
|
|
|
|
|
2022-01-21 21:35:31 +00:00
|
|
|
export const eventTypeLocations = z.array(
|
2022-03-13 15:56:56 +00:00
|
|
|
z.object({
|
2022-08-26 00:48:50 +00:00
|
|
|
// TODO: Couldn't find a way to make it a union of types from App Store locations
|
|
|
|
// Creating a dynamic union by iterating over the object doesn't seem to make TS happy
|
|
|
|
type: z.string(),
|
2022-03-13 15:56:56 +00:00
|
|
|
address: z.string().optional(),
|
|
|
|
link: z.string().url().optional(),
|
2022-05-25 20:34:08 +00:00
|
|
|
displayLocationPublicly: z.boolean().optional(),
|
2022-05-16 15:50:12 +00:00
|
|
|
hostPhoneNumber: z.string().optional(),
|
feat: Enable Apps for Teams & Orgs [CAL-1782] (#9337)
* Initial commit
* Adding feature flag
* Add schema relation for teams and credentials
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* Create getUserAdminTeams function & tRPC endpoint
* Get user admin teams on app store page
* Create UserAdminTeams type
* Add user query to getUserAdminTeams
* Letting duplicate slugs for teams to support orgs
* Covering null on unique clauses
* Add dropdown to install button on app store
* Supporting having the orgId in the session cookie
* On app page, only show dropdown if there are teams
* Add teamId to OAuth state
* Create team credential for OAuth flow
* Create team credential for GCal
* Add create user or team credential for Stripe
* Create webex credentials for users or teams
* Fix type error on useAddAppMutation
* Hubspot create credential on user or team
* Zoho create create credential for user or team
* Zoom create credentials on user or team
* Salesforce create credential on user or teams
* OAuth create credentials for user or teams
* Revert Outlook changes
* Revert GCal changes
* Default app instal, create credential on user or team
* Add teamId to credential creation
* Disable installing for teams for calendars
* Include teams when querying installed apps
* Render team credentials on installed page
* Uninstall team apps
* Type fix on app card
* Add input to include user in teams query
* Add dropdown to install app page for user or team
* Type fixes on category page
* Install app from eventType page to user or team
* Render user and team apps on event type app page
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* Render user and team apps on event type app page
* Add credentialOwner to eventTypeAppCard types
* Type fixes
* Create hook to check if app is enabled
* Clean up console.logs
* Fix useIsAppEnabled by returning not an array
* Convert event type apps to useIsAppEnabled
* Abstract credential owner type
* Remove console.logs
* On installed app page, show apps if only team credential is installed
* Clean up commented lines
* Handle installing app to just an team event from event type page
* Fix early return when creating team app credential
* Zoom add state to callback
* Get team location credentials and save credential id to location
* 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>
* Type fix
* Grab team location credentials
* Add isInstalled to eventType apps query
* 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
* Enable payment apps for team credentials
* Fix for team-user apps for event types
* Fix layout and add teamId to app card
* Disable apps on managed event types
* Add managed event type fields to event type apps
* Include organizations in query
* Change createAppCredential to createOAuthAppCredential
* Show app installed on teams
* Making sure we let localhost still work
* UI show installed for which team
* Type fixes
* For team events move use host location to top
* Add around to appStore
* New team event types organizer default conf app
* Fix app card bug
* Clean up
* Search for teamId or userId when deleting credential
* Type fixes
* Type fixes
* Type fixes
* Type fixes
* Address feedback
* 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
* Address feedback
* fix issue getting org slug from domain
* Improving orgDomains util
* Host comes with port
* Update useRouterQuery.ts
* Fix app card bug
* Fix schema
* Type fixes
* Revert changes to location apps
* Remove console.log
* Fix app store test
* Handle install app dropdown
* Add CalendarApp to `getCalendar`
* Add PaymentApp type fix
* Payment type fix
* Type fixes
* Match with main
* Change type to account for team
* Fix app count for team events
* Type fixes
* More type fixes
* Type fix?
* Fix the type fix
* Remove UserAdminTeams empty array union
* Type fix
* Type fix
* Type fix
* Uses type predicates
* Use teamId. Fixes installation for teams after user installation
* Fix Team Events not working
* Get embed for org events working
* Fix rewrites
* Address feedback
* Type fix
* Fixes
* Add useAppContextWithSchema in useIsAppEnabled
* Type fix for apps using useIsAppEnabled
* Integrations.handler change credentialIds to userCredentialIds
* Remove apps endpoint
* Add LockedIcon and disabled props to event type app context
* Type fixes
* Type fix
* Type fixes
* Show team installed apps for members
* Type fix
* Reverting findFirst
* Revert findFirst
* Avoid a possible 500
* Fix missing tanslation
* Avoid possible 500
* Undo default app for teams
* Type fix
* Fix test
* Update package.json
* feat: Fix invite bug - added tests (#9945)
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
* chore: Button Component Tidy up (#9888)
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
* feat: Make Team Private
## What does this PR do?
Fixes https://github.com/calcom/cal.com/issues/8974
1) When user is admin
<img width="1440" alt="Screenshot 2023-07-03 at 6 45 50 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce15158f-d278-4f1a-ba2e-8b63e4274793">
2) When user is not admin and team is private
<img width="1440" alt="Screenshot 2023-07-03 at 6 47 15 PM" src="https://github.com/calcom/cal.com/assets/53316345/ce23560e-690a-4c42-a76d-49691260aa4d">
3)
<img width="1440" alt="Screenshot 2023-07-03 at 6 51 56 PM" src="https://github.com/calcom/cal.com/assets/53316345/13af38f8-5618-4dae-b359-b24dc91e4eb4">
## Type of change
<!-- Please delete bullets that are not relevant. -->
- New feature (non-breaking change which adds functionality)
## How should this be tested?
1) go to Team members page and turn on switch Make Team Private.
Now after making the team private only admin would be able to see all the members list in the settings. There will not be a button to Book a team member instead on the team page like before.
## Mandatory Tasks
- [ ] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
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: Alan <alannnc@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2023-07-06 16:48:39 +00:00
|
|
|
credentialId: z.number().optional(),
|
2023-08-02 03:54:28 +00:00
|
|
|
teamName: z.string().optional(),
|
2022-03-13 15:56:56 +00:00
|
|
|
})
|
2022-01-21 21:35:31 +00:00
|
|
|
);
|
|
|
|
|
2022-05-05 21:16:25 +00:00
|
|
|
// Matching RRule.Options: rrule/dist/esm/src/types.d.ts
|
2022-06-10 00:32:34 +00:00
|
|
|
export const recurringEventType = z
|
|
|
|
.object({
|
|
|
|
dtstart: z.date().optional(),
|
|
|
|
interval: z.number(),
|
|
|
|
count: z.number(),
|
|
|
|
freq: z.nativeEnum(Frequency),
|
|
|
|
until: z.date().optional(),
|
|
|
|
tzid: z.string().optional(),
|
|
|
|
})
|
|
|
|
.nullable();
|
2022-05-05 21:16:25 +00:00
|
|
|
|
2022-10-17 09:07:49 +00:00
|
|
|
// dayjs iso parsing is very buggy - cant use :( - turns ISO string into Date object
|
|
|
|
export const iso8601 = z.string().transform((val, ctx) => {
|
|
|
|
const time = Date.parse(val);
|
|
|
|
if (!time) {
|
|
|
|
ctx.addIssue({
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
message: "Invalid ISO Date",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const d = new Date();
|
|
|
|
d.setTime(time);
|
|
|
|
return d;
|
|
|
|
});
|
|
|
|
|
2023-03-10 20:00:19 +00:00
|
|
|
export const intervalLimitsType = z
|
2022-10-12 05:29:04 +00:00
|
|
|
.object({
|
|
|
|
PER_DAY: z.number().optional(),
|
|
|
|
PER_WEEK: z.number().optional(),
|
|
|
|
PER_MONTH: z.number().optional(),
|
|
|
|
PER_YEAR: z.number().optional(),
|
|
|
|
})
|
|
|
|
.nullable();
|
|
|
|
|
2022-02-21 16:53:16 +00:00
|
|
|
export const eventTypeSlug = z.string().transform((val) => slugify(val.trim()));
|
2022-06-10 00:32:34 +00:00
|
|
|
|
2022-01-21 21:35:31 +00:00
|
|
|
export const stringToDate = z.string().transform((a) => new Date(a));
|
2022-06-10 00:32:34 +00:00
|
|
|
|
|
|
|
export const stringOrNumber = z.union([
|
|
|
|
z.string().transform((v, ctx) => {
|
|
|
|
const parsed = parseInt(v);
|
|
|
|
if (isNaN(parsed)) {
|
|
|
|
ctx.addIssue({
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
message: "Not a number",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return parsed;
|
|
|
|
}),
|
|
|
|
z.number().int(),
|
|
|
|
]);
|
|
|
|
|
|
|
|
export const stringToDayjs = z.string().transform((val) => dayjs(val));
|
2022-06-10 18:38:46 +00:00
|
|
|
|
|
|
|
export const bookingCreateBodySchema = z.object({
|
2023-06-02 19:29:52 +00:00
|
|
|
end: z.string().optional(),
|
2022-06-10 18:38:46 +00:00
|
|
|
eventTypeId: z.number(),
|
2022-06-11 21:30:52 +00:00
|
|
|
eventTypeSlug: z.string().optional(),
|
2022-06-10 18:38:46 +00:00
|
|
|
rescheduleUid: z.string().optional(),
|
|
|
|
recurringEventId: z.string().optional(),
|
|
|
|
start: z.string(),
|
2023-07-18 16:09:31 +00:00
|
|
|
timeZone: z.string().refine((value: string) => isSupportedTimeZone(value), { message: "Invalid timezone" }),
|
2022-06-10 18:38:46 +00:00
|
|
|
user: z.union([z.string(), z.array(z.string())]).optional(),
|
|
|
|
language: z.string(),
|
|
|
|
bookingUid: z.string().optional(),
|
|
|
|
metadata: z.record(z.string()),
|
2022-06-11 21:30:52 +00:00
|
|
|
hasHashedBookingLink: z.boolean().optional(),
|
2022-06-10 18:38:46 +00:00
|
|
|
hashedLink: z.string().nullish(),
|
2023-03-14 04:19:05 +00:00
|
|
|
seatReferenceUid: z.string().optional(),
|
2022-06-10 18:38:46 +00:00
|
|
|
});
|
|
|
|
|
2022-08-29 13:04:22 +00:00
|
|
|
export const requiredCustomInputSchema = z.union([
|
|
|
|
// string must be given & nonempty
|
|
|
|
z.string().trim().min(1),
|
|
|
|
// boolean must be true if set.
|
|
|
|
z.boolean().refine((v) => v === true),
|
|
|
|
]);
|
|
|
|
|
2022-06-11 21:30:52 +00:00
|
|
|
export type BookingCreateBody = z.input<typeof bookingCreateBodySchema>;
|
|
|
|
|
2022-08-26 21:58:08 +00:00
|
|
|
export const bookingConfirmPatchBodySchema = z.object({
|
|
|
|
bookingId: z.number(),
|
|
|
|
confirmed: z.boolean(),
|
|
|
|
recurringEventId: z.string().optional(),
|
|
|
|
reason: z.string().optional(),
|
|
|
|
});
|
|
|
|
|
2023-03-02 18:15:28 +00:00
|
|
|
// `responses` is merged with it during handleNewBooking call because `responses` schema is dynamic and depends on eventType
|
2022-06-10 18:38:46 +00:00
|
|
|
export const extendedBookingCreateBody = bookingCreateBodySchema.merge(
|
|
|
|
z.object({
|
|
|
|
noEmail: z.boolean().optional(),
|
|
|
|
recurringCount: z.number().optional(),
|
2022-11-08 20:59:44 +00:00
|
|
|
allRecurringDates: z.string().array().optional(),
|
|
|
|
currentRecurringIndex: z.number().optional(),
|
2022-10-19 16:11:50 +00:00
|
|
|
appsStatus: z
|
|
|
|
.array(
|
|
|
|
z.object({
|
|
|
|
appName: z.string(),
|
|
|
|
success: z.number(),
|
|
|
|
failures: z.number(),
|
|
|
|
type: z.string(),
|
2022-11-22 20:44:08 +00:00
|
|
|
errors: z.string().array(),
|
|
|
|
warnings: z.string().array().optional(),
|
2022-10-19 16:11:50 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
.optional(),
|
2022-06-10 18:38:46 +00:00
|
|
|
})
|
|
|
|
);
|
2022-06-14 20:07:54 +00:00
|
|
|
|
2023-03-02 18:15:28 +00:00
|
|
|
// It has only the legacy props that are part of `responses` now. The API can still hit old props
|
|
|
|
export const bookingCreateSchemaLegacyPropsForApi = z.object({
|
|
|
|
email: z.string(),
|
|
|
|
name: z.string(),
|
|
|
|
guests: z.array(z.string()).optional(),
|
|
|
|
notes: z.string().optional(),
|
|
|
|
location: z.string(),
|
|
|
|
smsReminderNumber: z.string().optional().nullable(),
|
|
|
|
rescheduleReason: z.string().optional(),
|
|
|
|
customInputs: z.array(z.object({ label: z.string(), value: z.union([z.string(), z.boolean()]) })),
|
|
|
|
});
|
|
|
|
|
|
|
|
// This is the schema that is used for the API. It has all the legacy props that are part of `responses` now.
|
|
|
|
export const bookingCreateBodySchemaForApi = extendedBookingCreateBody.merge(
|
2023-04-18 12:35:06 +00:00
|
|
|
bookingCreateSchemaLegacyPropsForApi.partial()
|
2023-03-02 18:15:28 +00:00
|
|
|
);
|
|
|
|
|
2022-10-20 23:28:02 +00:00
|
|
|
export const schemaBookingCancelParams = z.object({
|
|
|
|
id: z.number().optional(),
|
|
|
|
uid: z.string().optional(),
|
|
|
|
allRemainingBookings: z.boolean().optional(),
|
|
|
|
cancellationReason: z.string().optional(),
|
2023-03-14 04:19:05 +00:00
|
|
|
seatReferenceUid: z.string().optional(),
|
2022-10-20 23:28:02 +00:00
|
|
|
});
|
|
|
|
|
2022-06-14 20:07:54 +00:00
|
|
|
export const vitalSettingsUpdateSchema = z.object({
|
|
|
|
connected: z.boolean().optional(),
|
|
|
|
selectedParam: z.string().optional(),
|
|
|
|
sleepValue: z.number().optional(),
|
|
|
|
});
|
|
|
|
|
2022-09-05 19:13:49 +00:00
|
|
|
export const createdEventSchema = z
|
|
|
|
.object({
|
|
|
|
id: z.string(),
|
|
|
|
password: z.union([z.string(), z.undefined()]),
|
|
|
|
onlineMeetingUrl: z.string().nullable(),
|
2023-04-03 17:13:57 +00:00
|
|
|
iCalUID: z.string().optional(),
|
2022-09-05 19:13:49 +00:00
|
|
|
})
|
|
|
|
.passthrough();
|
|
|
|
|
2022-06-14 20:07:54 +00:00
|
|
|
export const userMetadata = z
|
|
|
|
.object({
|
2022-06-16 19:33:23 +00:00
|
|
|
proPaidForByTeamId: z.number().optional(),
|
2022-06-14 20:07:54 +00:00
|
|
|
stripeCustomerId: z.string().optional(),
|
|
|
|
vitalSettings: vitalSettingsUpdateSchema.optional(),
|
2022-07-06 19:31:07 +00:00
|
|
|
isPremium: z.boolean().optional(),
|
2023-01-31 20:44:14 +00:00
|
|
|
sessionTimeout: z.number().optional(), // Minutes
|
2023-02-13 22:55:32 +00:00
|
|
|
defaultConferencingApp: z
|
|
|
|
.object({
|
|
|
|
appSlug: z.string().default("daily-video").optional(),
|
|
|
|
appLink: z.string().optional(),
|
|
|
|
})
|
|
|
|
.optional(),
|
2023-06-06 15:31:43 +00:00
|
|
|
defaultBookerLayouts: bookerLayouts.optional(),
|
2022-06-14 20:07:54 +00:00
|
|
|
})
|
|
|
|
.nullable();
|
2022-08-01 21:44:08 +00:00
|
|
|
|
2022-11-10 20:23:56 +00:00
|
|
|
export const teamMetadataSchema = z
|
|
|
|
.object({
|
|
|
|
requestedSlug: z.string(),
|
|
|
|
paymentId: z.string(),
|
|
|
|
subscriptionId: z.string().nullable(),
|
|
|
|
subscriptionItemId: z.string().nullable(),
|
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
|
|
|
isOrganization: z.boolean().nullable(),
|
feat: org invite billing (#9291)
* Initial commit
* Adding feature flag
* Desktop first banner, mobile pending
* Removing dead code and img
* AppInstallButtonBase
* WIP
* Adds Email verification template+translations for organizations (#9202)
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Session logic to show org label
* Step 2 done, avatar not working
* List orgs and list teams specific if orgs exist
* Conditionally show org - fix settings layout - add labels for all pages
* Profile Page + update
* Org specific team creation
* appearance page
* Ensure members cant of org cant update settings in UI
* Fix update handler imports
* hide billing on sub teams
* Update profile slug page
* Letting duplicate slugs for teams to support orgs
* Add slug coliisions for org
* Covering null on unique clauses
* Covering null on unique clauses
* Extract to utils
* Update settings to use subdomain path in team url , team + org
* Supporting having the orgId in the session cookie
* Onboarding admins step
* Last step to create teams
* Update handler comments
* Upgrade ORG banner - disabled team banner for child teams
* Handle publishing ORGS
* Fix licenese issue
* Update packages/trpc/server/routers/viewer/teams/create.handler.ts
* Split into function calls to make this file more explisit
* Update parents stripe sub not teamID
* 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
* Create org membership also - billing portal page
* A11ly
* Hide create team if no valid permisisons
* Get Org members router
* Handle updating subscription if orgId
* Fix double upgrade banner
* Update constants
* Feedback
* Copy change
* Making an org avatar (temp)
* Add slug colission detection for user and team name
* Fix Import
* Remove update password func
* Fix module import over relative
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* Fix import again
* Throw no team found before auth error
* Check if invited found user is already in differnt org
* Move to for of loop to throw errors in usenamelist
* Remove app install button sa its in 9337
* Remove i18n key not being used
* 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
* Fix router
* feat: organization settings general and members page (#9266)
* feat: organization settings general page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* feat: add members page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: remove
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use invalidate
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: delete mutation
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: remove organization id
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use zod schema
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Type fixes
* Use org Stripe product when upgrading
* Removed unused code
* Reverting changes
* Update UsernameTextfield.tsx
* More reverts
* Update next-auth-options.ts
* Update common.json
* Type fixes
* Include invite token for orgs
* Update org schema
* Make token settings optional as it isnt used in orgs yet
* Reverts
* remove yarn.lock from commit
* Fix types
* feat: orgs unverified (#9415)
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
* Fix wrong banner being displayed
* Type fix
* Fix type issues
* Update packages/trpc/server/routers/viewer/teams/inviteMember.handler.ts
Co-authored-by: alannnc <alannnc@gmail.com>
* fix missing input on trpc query
* Fix for parentId value for createProvisionalMembership
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
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: zomars <zomars@me.com>
Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
2023-07-02 18:40:12 +00:00
|
|
|
isOrganizationVerified: z.boolean().nullable(),
|
2023-08-23 21:01:12 +00:00
|
|
|
isOrganizationConfigured: z.boolean().nullable(),
|
feat: org invite billing (#9291)
* Initial commit
* Adding feature flag
* Desktop first banner, mobile pending
* Removing dead code and img
* AppInstallButtonBase
* WIP
* Adds Email verification template+translations for organizations (#9202)
* feat: Orgs Schema Changing `scopedMembers` to `orgUsers` (#9209)
* Change scopedMembers to orgMembers
* Change to orgUsers
* First step done
* Merge branch 'feat/organizations-onboarding' of github.com:calcom/cal.com into feat/organizations-onboarding
* Session logic to show org label
* Step 2 done, avatar not working
* List orgs and list teams specific if orgs exist
* Conditionally show org - fix settings layout - add labels for all pages
* Profile Page + update
* Org specific team creation
* appearance page
* Ensure members cant of org cant update settings in UI
* Fix update handler imports
* hide billing on sub teams
* Update profile slug page
* Letting duplicate slugs for teams to support orgs
* Add slug coliisions for org
* Covering null on unique clauses
* Covering null on unique clauses
* Extract to utils
* Update settings to use subdomain path in team url , team + org
* Supporting having the orgId in the session cookie
* Onboarding admins step
* Last step to create teams
* Update handler comments
* Upgrade ORG banner - disabled team banner for child teams
* Handle publishing ORGS
* Fix licenese issue
* Update packages/trpc/server/routers/viewer/teams/create.handler.ts
* Split into function calls to make this file more explisit
* Update parents stripe sub not teamID
* 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
* Create org membership also - billing portal page
* A11ly
* Hide create team if no valid permisisons
* Get Org members router
* Handle updating subscription if orgId
* Fix double upgrade banner
* Update constants
* Feedback
* Copy change
* Making an org avatar (temp)
* Add slug colission detection for user and team name
* Fix Import
* Remove update password func
* Fix module import over relative
* feat: organization event type filter (#9253)
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Missing changes to support orgs schema changes
* Fix import again
* Throw no team found before auth error
* Check if invited found user is already in differnt org
* Move to for of loop to throw errors in usenamelist
* Remove app install button sa its in 9337
* Remove i18n key not being used
* 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
* Fix router
* feat: organization settings general and members page (#9266)
* feat: organization settings general page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* feat: add members page
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore: remove
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use invalidate
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: delete mutation
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: remove organization id
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* chore
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* fix: use zod schema
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
* Type fixes
* Use org Stripe product when upgrading
* Removed unused code
* Reverting changes
* Update UsernameTextfield.tsx
* More reverts
* Update next-auth-options.ts
* Update common.json
* Type fixes
* Include invite token for orgs
* Update org schema
* Make token settings optional as it isnt used in orgs yet
* Reverts
* remove yarn.lock from commit
* Fix types
* feat: orgs unverified (#9415)
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
* Fix wrong banner being displayed
* Type fix
* Fix type issues
* Update packages/trpc/server/routers/viewer/teams/inviteMember.handler.ts
Co-authored-by: alannnc <alannnc@gmail.com>
* fix missing input on trpc query
* Fix for parentId value for createProvisionalMembership
---------
Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
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: zomars <zomars@me.com>
Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
Co-authored-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: alannnc <alannnc@gmail.com>
2023-07-02 18:40:12 +00:00
|
|
|
orgAutoAcceptEmail: z.string().nullable(),
|
2022-11-10 20:23:56 +00:00
|
|
|
})
|
|
|
|
.partial()
|
|
|
|
.nullable();
|
|
|
|
|
2022-12-15 21:43:07 +00:00
|
|
|
export const bookingMetadataSchema = z
|
|
|
|
.object({
|
|
|
|
videoCallUrl: z.string().optional(),
|
|
|
|
})
|
2023-02-20 02:00:23 +00:00
|
|
|
.and(z.record(z.string()))
|
2022-12-15 21:43:07 +00:00
|
|
|
.nullable();
|
|
|
|
|
2022-12-01 21:53:52 +00:00
|
|
|
export const customInputOptionSchema = z.array(
|
|
|
|
z.object({
|
|
|
|
label: z.string(),
|
|
|
|
type: z.string(),
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
export const customInputSchema = z.object({
|
|
|
|
id: z.number(),
|
|
|
|
eventTypeId: z.number(),
|
|
|
|
label: z.string(),
|
|
|
|
type: z.nativeEnum(EventTypeCustomInputType),
|
|
|
|
options: customInputOptionSchema.optional().nullable(),
|
|
|
|
required: z.boolean(),
|
|
|
|
placeholder: z.string(),
|
2022-12-26 10:55:58 +00:00
|
|
|
hasToBeCreated: z.boolean().optional(),
|
2022-12-01 21:53:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export type CustomInputSchema = z.infer<typeof customInputSchema>;
|
|
|
|
|
2022-12-27 21:03:39 +00:00
|
|
|
export const recordingItemSchema = z.object({
|
|
|
|
id: z.string(),
|
|
|
|
room_name: z.string(),
|
|
|
|
start_ts: z.number(),
|
|
|
|
status: z.string(),
|
|
|
|
max_participants: z.number(),
|
|
|
|
duration: z.number(),
|
|
|
|
share_token: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const recordingItemsSchema = z.array(recordingItemSchema);
|
|
|
|
|
|
|
|
export type RecordingItemSchema = z.infer<typeof recordingItemSchema>;
|
|
|
|
|
|
|
|
export const getRecordingsResponseSchema = z.union([
|
|
|
|
z.object({
|
|
|
|
total_count: z.number(),
|
|
|
|
data: recordingItemsSchema,
|
|
|
|
}),
|
|
|
|
z.object({}),
|
|
|
|
]);
|
|
|
|
|
|
|
|
export type GetRecordingsResponseSchema = z.infer<typeof getRecordingsResponseSchema>;
|
|
|
|
|
2022-08-01 21:44:08 +00:00
|
|
|
/**
|
|
|
|
* Ensures that it is a valid HTTP URL
|
|
|
|
* It automatically avoids
|
|
|
|
* - XSS attempts through javascript:alert('hi')
|
|
|
|
* - mailto: links
|
|
|
|
*/
|
|
|
|
export const successRedirectUrl = z
|
2022-08-02 00:45:47 +00:00
|
|
|
.union([
|
|
|
|
z.literal(""),
|
|
|
|
z
|
|
|
|
.string()
|
|
|
|
.url()
|
|
|
|
.regex(/^http(s)?:\/\/.*/),
|
|
|
|
])
|
|
|
|
.optional();
|
2022-10-07 20:48:41 +00:00
|
|
|
|
2022-11-03 14:40:03 +00:00
|
|
|
export const RoutingFormSettings = z
|
|
|
|
.object({
|
|
|
|
emailOwnerOnSubmission: z.boolean(),
|
|
|
|
})
|
|
|
|
.nullable();
|
|
|
|
|
2023-01-26 20:36:15 +00:00
|
|
|
export const DeploymentTheme = z
|
|
|
|
.object({
|
|
|
|
brand: z.string().default("#292929"),
|
|
|
|
textBrand: z.string().default("#ffffff"),
|
|
|
|
darkBrand: z.string().default("#fafafa"),
|
|
|
|
textDarkBrand: z.string().default("#292929"),
|
|
|
|
bookingHighlight: z.string().default("#10B981"),
|
|
|
|
bookingLightest: z.string().default("#E1E1E1"),
|
|
|
|
bookingLighter: z.string().default("#ACACAC"),
|
|
|
|
bookingLight: z.string().default("#888888"),
|
|
|
|
bookingMedian: z.string().default("#494949"),
|
|
|
|
bookingDark: z.string().default("#313131"),
|
|
|
|
bookingDarker: z.string().default("#292929"),
|
|
|
|
fontName: z.string().default("Cal Sans"),
|
|
|
|
fontSrc: z.string().default("https://cal.com/cal.ttf"),
|
|
|
|
})
|
|
|
|
.optional();
|
|
|
|
|
2022-10-07 20:48:41 +00:00
|
|
|
export type ZodDenullish<T extends ZodTypeAny> = T extends ZodNullable<infer U> | ZodOptional<infer U>
|
|
|
|
? ZodDenullish<U>
|
|
|
|
: T;
|
|
|
|
|
|
|
|
export type ZodDenullishShape<T extends ZodRawShape> = {
|
|
|
|
[k in keyof T]: ZodDenullish<T[k]>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const denullish = <T extends ZodTypeAny>(schema: T): ZodDenullish<T> =>
|
|
|
|
(schema instanceof ZodNullable || schema instanceof ZodOptional
|
|
|
|
? denullish((schema._def as ZodNullableDef | ZodOptionalDef).innerType)
|
|
|
|
: schema) as ZodDenullish<T>;
|
|
|
|
|
|
|
|
type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see https://github.com/3x071c/lsg-remix/blob/e2a9592ba3ec5103556f2cf307c32f08aeaee32d/app/lib/util/zod.ts
|
|
|
|
*/
|
|
|
|
export function denullishShape<
|
|
|
|
T extends ZodRawShape,
|
|
|
|
UnknownKeys extends UnknownKeysParam = "strip",
|
|
|
|
Catchall extends ZodTypeAny = ZodTypeAny,
|
|
|
|
Output = objectOutputType<T, Catchall>,
|
|
|
|
Input = objectInputType<T, Catchall>
|
|
|
|
>(
|
|
|
|
obj: ZodObject<T, UnknownKeys, Catchall, Output, Input>
|
|
|
|
): ZodObject<ZodDenullishShape<T>, UnknownKeys, Catchall> {
|
|
|
|
const a = entries(obj.shape).map(([field, schema]) => [field, denullish(schema)] as const) as {
|
|
|
|
[K in keyof T]: [K, ZodDenullish<T[K]>];
|
|
|
|
}[keyof T][];
|
|
|
|
return new ZodObject({
|
|
|
|
...obj._def,
|
|
|
|
shape: () => fromEntries(a) as unknown as ZodDenullishShape<T>, // TODO: Safely assert type
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like Object.entries, but with actually useful typings
|
|
|
|
* @param obj The object to turn into a tuple array (`[key, value][]`)
|
|
|
|
* @returns The constructed tuple array from the given object
|
|
|
|
* @see https://github.com/3x071c/lsg-remix/blob/e2a9592ba3ec5103556f2cf307c32f08aeaee32d/app/lib/util/entries.ts
|
|
|
|
*/
|
2023-01-27 01:50:56 +00:00
|
|
|
export const entries = <O extends Record<string, unknown>>(
|
2022-10-07 20:48:41 +00:00
|
|
|
obj: O
|
|
|
|
): {
|
|
|
|
readonly [K in keyof O]: [K, O[K]];
|
|
|
|
}[keyof O][] => {
|
|
|
|
return Object.entries(obj) as {
|
|
|
|
[K in keyof O]: [K, O[K]];
|
|
|
|
}[keyof O][];
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a type with all readonly notations removed (traverses recursively on an object)
|
|
|
|
*/
|
|
|
|
type DeepWriteable<T> = T extends Readonly<{
|
|
|
|
-readonly [K in keyof T]: T[K];
|
|
|
|
}>
|
|
|
|
? {
|
|
|
|
-readonly [K in keyof T]: DeepWriteable<T[K]>;
|
|
|
|
}
|
|
|
|
: T; /* Make it work with readonly types (this is not strictly necessary) */
|
|
|
|
|
|
|
|
type FromEntries<T> = T extends [infer Keys, unknown][]
|
|
|
|
? { [K in Keys & PropertyKey]: Extract<T[number], [K, unknown]>[1] }
|
|
|
|
: never;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like Object.fromEntries, but with actually useful typings
|
|
|
|
* @param arr The tuple array (`[key, value][]`) to turn into an object
|
|
|
|
* @returns Object constructed from the given entries
|
|
|
|
* @see https://github.com/3x071c/lsg-remix/blob/e2a9592ba3ec5103556f2cf307c32f08aeaee32d/app/lib/util/fromEntries.ts
|
|
|
|
*/
|
|
|
|
export const fromEntries = <
|
|
|
|
E extends [PropertyKey, unknown][] | ReadonlyArray<readonly [PropertyKey, unknown]>
|
|
|
|
>(
|
|
|
|
entries: E
|
|
|
|
): FromEntries<DeepWriteable<E>> => {
|
|
|
|
return Object.fromEntries(entries) as FromEntries<DeepWriteable<E>>;
|
|
|
|
};
|
2023-03-05 12:59:07 +00:00
|
|
|
|
|
|
|
export const getAccessLinkResponseSchema = z.object({
|
|
|
|
download_link: z.string().url(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export type GetAccessLinkResponseSchema = z.infer<typeof getAccessLinkResponseSchema>;
|
2023-04-13 02:10:23 +00:00
|
|
|
|
2023-04-15 00:04:48 +00:00
|
|
|
/** Facilitates converting values from Select inputs to plain ones before submitting */
|
|
|
|
export const optionToValueSchema = <T extends z.ZodTypeAny>(valueSchema: T) =>
|
|
|
|
z
|
|
|
|
.object({
|
|
|
|
label: z.string(),
|
|
|
|
value: valueSchema,
|
|
|
|
})
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
.transform((foo) => (foo as any).value as z.infer<T>);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows parsing without losing original data inference.
|
|
|
|
* @url https://github.com/colinhacks/zod/discussions/1655#discussioncomment-4367368
|
|
|
|
*/
|
|
|
|
export const getParserWithGeneric =
|
2023-08-31 22:27:51 +00:00
|
|
|
<T extends AnyZodObject>(valueSchema: T) =>
|
2023-04-15 00:04:48 +00:00
|
|
|
<Data>(data: Data) => {
|
2023-08-31 22:27:51 +00:00
|
|
|
type Output = z.infer<T>;
|
|
|
|
type SimpleFormValues = string | number | null | undefined;
|
2023-04-15 00:04:48 +00:00
|
|
|
return valueSchema.parse(data) as {
|
2023-08-31 22:27:51 +00:00
|
|
|
// TODO: Invesitage why this broke on zod 3.22.2 upgrade
|
|
|
|
[key in keyof Data]: Data[key] extends SimpleFormValues ? Data[key] : Output[key];
|
2023-04-15 00:04:48 +00:00
|
|
|
};
|
|
|
|
};
|
2023-04-13 19:07:10 +00:00
|
|
|
export const sendDailyVideoRecordingEmailsSchema = z.object({
|
|
|
|
recordingId: z.string(),
|
|
|
|
bookingUID: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const downloadLinkSchema = z.object({
|
|
|
|
download_link: z.string(),
|
|
|
|
});
|
|
|
|
|
2023-04-13 02:10:23 +00:00
|
|
|
// All properties within event type that can and will be updated if needed
|
|
|
|
export const allManagedEventTypeProps: { [k in keyof Omit<Prisma.EventTypeSelect, "id">]: true } = {
|
|
|
|
title: true,
|
|
|
|
description: true,
|
|
|
|
currency: true,
|
|
|
|
periodDays: true,
|
|
|
|
position: true,
|
|
|
|
price: true,
|
|
|
|
slug: true,
|
|
|
|
length: true,
|
2023-05-17 11:56:55 +00:00
|
|
|
offsetStart: true,
|
2023-04-13 02:10:23 +00:00
|
|
|
locations: true,
|
|
|
|
hidden: true,
|
|
|
|
availability: true,
|
|
|
|
recurringEvent: true,
|
|
|
|
customInputs: true,
|
|
|
|
disableGuests: true,
|
|
|
|
requiresConfirmation: true,
|
|
|
|
eventName: true,
|
|
|
|
metadata: true,
|
|
|
|
children: true,
|
|
|
|
hideCalendarNotes: true,
|
|
|
|
minimumBookingNotice: true,
|
|
|
|
beforeEventBuffer: true,
|
|
|
|
afterEventBuffer: true,
|
|
|
|
successRedirectUrl: true,
|
|
|
|
seatsPerTimeSlot: true,
|
|
|
|
seatsShowAttendees: true,
|
|
|
|
periodType: true,
|
|
|
|
hashedLink: true,
|
|
|
|
webhooks: true,
|
|
|
|
periodStartDate: true,
|
|
|
|
periodEndDate: true,
|
|
|
|
destinationCalendar: true,
|
|
|
|
periodCountCalendarDays: true,
|
|
|
|
bookingLimits: true,
|
|
|
|
slotInterval: true,
|
2023-05-09 14:15:13 +00:00
|
|
|
scheduleId: true,
|
2023-04-13 02:10:23 +00:00
|
|
|
workflows: true,
|
|
|
|
bookingFields: true,
|
|
|
|
durationLimits: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// All properties that are defined as unlocked based on all managed props
|
|
|
|
// Eventually this is going to be just a default and the user can change the config through the UI
|
|
|
|
export const unlockedManagedEventTypeProps = {
|
2023-08-18 18:13:21 +00:00
|
|
|
locations: allManagedEventTypeProps.locations,
|
|
|
|
scheduleId: allManagedEventTypeProps.scheduleId,
|
|
|
|
destinationCalendar: allManagedEventTypeProps.destinationCalendar,
|
2023-04-13 02:10:23 +00:00
|
|
|
};
|
2023-07-05 00:37:52 +00:00
|
|
|
|
|
|
|
// The PR at https://github.com/colinhacks/zod/pull/2157 addresses this issue and improves email validation
|
|
|
|
// I introduced this refinement(to be used with z.email()) as a short term solution until we upgrade to a zod
|
|
|
|
// version that will include updates in the above PR.
|
|
|
|
export const emailSchemaRefinement = (value: string) => {
|
2023-07-11 15:11:08 +00:00
|
|
|
const emailRegex = /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,}$/i;
|
|
|
|
return emailRegex.test(value);
|
|
|
|
};
|
2023-07-31 17:51:11 +00:00
|
|
|
|
2023-08-29 11:56:45 +00:00
|
|
|
export const signupSchema = z.object({
|
|
|
|
username: z.string().refine((value) => !value.includes("+"), {
|
|
|
|
message: "String should not contain a plus symbol (+).",
|
|
|
|
}),
|
|
|
|
email: z.string().email(),
|
|
|
|
password: z.string().superRefine((data, ctx) => {
|
|
|
|
const isStrict = false;
|
|
|
|
const result = isPasswordValid(data, true, isStrict);
|
|
|
|
Object.keys(result).map((key: string) => {
|
|
|
|
if (!result[key as keyof typeof result]) {
|
|
|
|
ctx.addIssue({
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
path: [key],
|
|
|
|
message: key,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
language: z.string().optional(),
|
|
|
|
token: z.string().optional(),
|
|
|
|
});
|
|
|
|
|
2023-07-31 17:51:11 +00:00
|
|
|
export const ZVerifyCodeInputSchema = z.object({
|
|
|
|
email: z.string().email(),
|
|
|
|
code: z.string(),
|
|
|
|
});
|
|
|
|
|
|
|
|
export type ZVerifyCodeInputSchema = z.infer<typeof ZVerifyCodeInputSchema>;
|
2023-08-25 13:29:04 +00:00
|
|
|
|
|
|
|
export const coerceToDate = z.coerce.date();
|