-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: v2 event-types #15457
base: main
Are you sure you want to change the base?
refactor: v2 event-types #15457
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Ignored Deployments
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@mux/mux-player-react@2.7.0, npm/@mux/mux-player@2.7.0, npm/@mux/mux-video@0.19.0, npm/@mux/playback-core@0.24.0, npm/castable-video@1.0.10, npm/custom-media-element@1.2.3, npm/hls.js@1.5.11 |
Graphite Automations"Add foundation team as reviewer" took an action on this PR • (06/19/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add platform team as reviewer" took an action on this PR • (06/19/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add consumer team as reviewer" took an action on this PR • (06/19/24)1 reviewer was added to this PR based on Keith Williams's automation. |
apps/api/v2/src/ee/event-types/event-types_2024_06_14/constants/constants.ts
Show resolved
Hide resolved
apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs/create-event-type.output.ts
Outdated
Show resolved
Hide resolved
apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs/get-event-type.output.ts
Outdated
Show resolved
Hide resolved
apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs/get-event-types.output.ts
Outdated
Show resolved
Hide resolved
apps/api/v2/src/ee/event-types/event-types_2024_06_14/outputs/update-event-type.output.ts
Show resolved
Hide resolved
apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/event-types.service.ts
Outdated
Show resolved
Hide resolved
placeholder: z.string().optional(), | ||
}); | ||
|
||
const SystemFieldsSchema = z.object({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does System mean ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you see file transformApiEventTypeForAtom.ts and then function getBookingFields, then you can see that system fields are the default booking fields added by us.
The logic is taken from "packages/features/bookings/lib/getBookingFields.ts" that takes event-type booking fields and using "ensureBookingInputsHaveSystemFields" function adds default fields.
Overview
4.1
transformApiEventTypeForAtom.ts
is then using thouse transformers to transform event-type returned by one of the hooks that return event-type in the new format and make it compatible for using it in the rest of our code.4.2 v2 API's
input-event-types.service.ts
is using the transformers to parse event-type input as we have defined it into event-type compatible with rest of our code.4.3 v2 API's
output-event-types.service.ts
uses transformers to then convert internal representation of event-types into output it defines. Event-types output of v2 is defined based on input, so we perform bi-directional transformation when receiving input and then responding with an output.4.4 As you see, there is no function
transformAtomEventTypeForApi.ts
just like we have with schedulestransformAtomScheduleForApi
- that is because there is no event-types atom yet, andtransformAtomEventTypeForApi.ts
will have to use transformers to take internal representation of event-type and convert it into format that api v2 expect when we allow creating / updating an event-type using atom. So why do we needtransformApiEventTypeForAtom.ts
if we don't have event-types atom? BecauseBookerPlatformWrapper
is using event-type viauseEventType()
hook, andBookerPlatformWrapper
usestransformApiEventTypeForAtom.ts
to transform received event-type into format compatible with theBooker
atom.cd apps/api/v2
and then runniing:v2 API updates
First I will show examples of requests, and then walk through possible "locations" and "bookingFields" values and describe what properties have changed in this release.
Requests
Create event type - POST
http://localhost:5555/api/v2/event-types
Requires access token
As you see in the request, in the booking fields we have radio button group. When booking this event-type it looks like:
and in the e-mail sent to the person booked the booking field appears too:
Get one by id - GET
http://localhost:5555/api/v2/event-types/:id
Requires access token
Get one by username and event slug - GET
http://localhost:5555/api/v2/event-types?username=X&eventSlug=Y
Does not require any authentication. Since we are using event-types endpoint, it returns data containing array with 1 element`.
Get many by username - GET
http://localhost:5555/api/v2/event-types?username=X
Does not require any authentication
Update - PATCH
http://localhost:5555/api/v2/event-types/:id
Let's add a text field when booking. We include existing radio group booking field + new one in the request body:
Which makes it look like in the booker:
Accessing booking fields responses - GET booking by it's UID
http://localhost:5555/api/v2/ee/bookings/:uid
:If we book the event-type, then the responses to
bookingFields
of the event-type appears under"responses"
and their key is the "slug" you passed when creating the event-type. Here is booking responses for booker in the last screenshot:locations
As you see in requests above, event-type locations is an array that can accept event-type location objects. Here are the possible location examples:
location - address
location - link
location - integration
location - phone
The public property controls whether or not the location is seen in booker during booking the event-type.
With
public: true
:With
public: false
:The locations types can be seen in locations.input.ts.
bookingFields
As you see in requests above, event-type booking fields is an array that can accept booking field objects. Here are the possible booking fields examples:
booking field - name
booking field - email
booking field - phone
booking field - address
booking field - text
booking field - number
booking field - textarea
booking field - select
booking field - multiselect
booking field - multiemail
booking field - checkbox
booking field - radio
booking field - boolean
booking fields types can be seen in file booking-fields.input.ts
default bookingFields
If no booking fields are provided, then only user name and email fields will appear in the booker. There are no more default fields like "What is this meeting about" or "Additional notes" - it's up to users to set it up.
Properties changed
event-type length
Previously event-type length was denoted by "length" property in the request and response bodies, but now it's made more specific and is named "lengthInMinutes" for more clarity.
location visibility
Previously whether or not to display event-type location during booking was controlled by "location.displayLocationPublicly", but now it's "location.public".
booking field name
Booking field has "name" property to access it in the responses of a booking. In requests and responses it is re-named to "slug", because we have event-type slug, and most probably one would format it in slug like "x-y-z" way.
Hooks
It's possible to import following hooks from the atoms package:
useEventType
Fetch event type using username and eventSlug
useEventTypes
Fetch all event types by username
useEventTypeById
Fetch specifify event type by id, but since there is no username this hook is only available with managed user's access token.