Compare commits

...
107 Commits
Author SHA1 Message Date
Erik 937a9a0276 v3.9.2
release.yml / release (push) Canceled after 0s
2024-03-26 18:07:38 -03:00
Crowdin Bot 7a01e0427d New Crowdin translations by Github Action 2024-03-26 19:07:35 +00:00
Peer Richelsen 3336f8f017 Update README.md 2024-03-26 19:02:45 +00:00
Peer Richelsen 724ce9f446 Delete apps/api/v2/ee directory 2024-03-26 19:02:14 +00:00
Peer Richelsen 55737a0ad3 Create README.md 2024-03-26 19:01:48 +00:00
Peer Richelsen 06695f41ee Update LICENSE 2024-03-26 19:00:59 +00:00
Peer Richelsen 32f5f8b670 Update LICENSE 2024-03-26 18:59:35 +00:00
Peer Richelsen 78e7aa860a Update LICENSE 2024-03-26 18:59:15 +00:00
Peer Richelsen e4a2ebb545 Create README.md 2024-03-26 18:58:37 +00:00
Peer Richelsen 244dfd30ff Create LICENSE 2024-03-26 18:56:24 +00:00
Peer Richelsen d990bacf3b Update README.md 2024-03-26 18:56:01 +00:00
Alex van Andel 5d139a7ba8 Bump all postgres:12 -> postgres:13.13 (#14217) 2024-03-26 16:51:06 +00:00
Andreas Thomasandsean-brydon 091d3cdd17 feat: use unkey for global ratelimiting and identifier overrides (#14173)
* feat: use unkey for global ratelimiting and identifier overrides

fixes #13672

* revert: make test pass

* chore: push timeout incase unkey ever dies

* chore: push timeout incase unkey ever dies

---------

Co-authored-by: sean-brydon <sean@cal.com>
2024-03-26 15:52:00 +00:00
Lauris Skraucis a8d95d54e7 feat: v1 api connected-calendars endpoint (#14176)
* feat: v1 api connected-calendars endpoint

* refactor: flatten return data

* refactor: shorten code

* refactor: document userId for admins
2024-03-26 13:58:54 +00:00
sean-brydon af8d38e3a6 feat: hide if team slider if org is private (#14201)
* feat: hide if org is private

* fix: allow owners and admin to see page
2024-03-26 12:51:03 +00:00
Syed Ali Shahbaz fd91c5da79 feat: SSO for orgs (#13794)
* WIP

Adds the capability to add SSO setup in orgs
if you are an Admin or an Owner of the org

* remove sso setup from teams

* allows account creation on first login

* auto-add on login and dsync fixes

* allow SP & idP initiated login for SAML

* revert change to checkIfUserShouldbelongToOrg

* fixes SP initiated Login for first time

* removed stale comment

* code improvement

* --

* minor fixes

* more fix

* add description for non-admin sso settings page
2024-03-26 11:11:51 +00:00
Udit Takkar 452ea6a993 fix: instant meeting fixes (#14214)
* fix: instant meeting fixes

* chore: improvements

* fix: platform type check

* fix: start_video_off
2024-03-26 09:57:34 +00:00
0223db1f7c feat: v2 api endpoints and hooks to list private and public event types of user (#14192)
* refactor: extract getEventTypeByViewer for private user dashboard event types

* refactor: extract getEventTypesPublic for public event types to book

* refactor: group event-types lib functions in single folder

* refactor: rename getEventTypeByViewer to getEventTypesByViewer

* feat: add event type helpers from lib to platform libraries

* feat: v2 endpoint for private event types

* driveby:fix: fixed date in docs instead of being re-generated

* feature: endpoint to fetch public endpoints

* fix: getting private event types

* tests: fetch private event types

* tests: fetch private event types

* feat: hooks for public and private events

* fix: yarn test

* tests: IMO better mocking

* refactor: track dynamic prop in react query

* fix: distinct query key for public events

* fix: username in query key and example app demo

* fix: swagger for endpoint get public event input

---------

Co-authored-by: Morgan Vernay <morgan@cal.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2024-03-26 08:35:17 +00:00
Joe Au-YeungandBailey Pumfleet da7c5ec407 fix: Fixes Jelly type mismatch and passes conference credential id when confirm bookings (#14209)
* On confirmation get the conference credential id

* Fix misconfigured location type

---------

Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk>
2024-03-25 23:15:23 -04:00
Crowdin Bot d391f35389 New Crowdin translations by Github Action 2024-03-25 17:52:46 +00:00
Lauris Skraucis ef498c6ed6 feat: distinguish managed platform users (#14207)
* feat: add isPlatformManaged property to user

* do not allow deleting non managed users

* refactor: rename managed user create and update inputs

* refactor response code

* feat: add isPlatformManaged when creating managed user

* fix TS
2024-03-25 18:48:51 +01:00
Crowdin Bot bec1453148 New Crowdin translations by Github Action 2024-03-25 16:18:19 +00:00
Crowdin Bot a2b83bbb03 New Crowdin translations by Github Action 2024-03-25 16:10:33 +00:00
Crowdin Bot d84dce0f05 New Crowdin translations by Github Action 2024-03-25 16:04:02 +00:00
Crowdin Bot 9896875006 New Crowdin translations by Github Action 2024-03-25 15:57:45 +00:00
Crowdin Bot f12a6b27b7 New Crowdin translations by Github Action 2024-03-25 15:52:45 +00:00
Crowdin Bot f3eeb2a50f New Crowdin translations by Github Action 2024-03-25 15:47:38 +00:00
Crowdin Bot 49017ad4b7 New Crowdin translations by Github Action 2024-03-25 15:41:53 +00:00
Crowdin Bot 09bbb19fe1 New Crowdin translations by Github Action 2024-03-25 15:36:19 +00:00
Lauris Skraucis dd3dd32a3e refactor: v2 API remove defaultScheduleId when creating a managed user (#14205)
* refactor: v2 api remove defaultScheduleId from create user input

* refactor: ensure user from test is deleted

* fix: oauth-client-users test and allow deleting oauth users
2024-03-25 15:30:14 +00:00
Morgan 75c3c596c2 feat: display connected calendars on platform calendars page (#14203)
* feat: display connected calendars on platform calendars page

* fixup! feat: display connected calendars on platform calendars page
2024-03-25 14:53:11 +02:00
Crowdin Bot 59d45afc56 New Crowdin translations by Github Action 2024-03-25 11:26:18 +00:00
Lauris Skraucis 070548555c feat: prevent OAuth client creation for non platform orgs (#14200)
* feat: isPlatform flag for teams

* feat: create organizations service to check if org is platform

* feat: check if organization is platform in the OrganizationRolesGuard used by OAuthClientsController

* remove unused variable

* refactor: reduce nesting in create handler and abstract check in function

* feat: dont create domain for platform orgs
2024-03-25 12:21:41 +01:00
zomars b520238d33 Update yarn.lock 2024-03-22 12:23:40 -07:00
e04a8f0344 chore: moved GTM into signup (#14175)
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
2024-03-22 18:40:25 +00:00
Somay Chauhan 9acc21d882 fix: removing apps from team events (#14182)
* fix: removing apps from team events

* fix: lnstalling an app to a team enables it on all the team-events by default
2024-03-22 13:42:49 -04:00
Anwar SadathandJoe Au-Yeung fbff9a9a3f fix: Attendee address and phone number field not shown in booking questions (#13989)
* fix: Attendee address and phone number field not shown in booking questions

* Address review comments

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-22 13:41:40 -04:00
Crowdin Bot de41f20145 New Crowdin translations by Github Action 2024-03-22 14:00:34 +00:00
81b34420dc fix: Adding missing multiple_duration_timeUnit on both zh-tw and zh-cn locales. (#14181)
* Add missing multiple_duration_timeUnit

* Add missing multiple_duration_timeUnit

* chore: add in other translation files

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-22 13:55:08 +00:00
Crowdin Bot 71c657f9c1 New Crowdin translations by Github Action 2024-03-22 13:02:11 +00:00
eb580e91de return empty array if no bookings available (#14159)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-22 12:56:06 +00:00
Morgan 896ba104fd refactor: dialog auto swap platform primitives (#14186)
* refactor: dialog auto swap platform primities

* fixup! refactor: dialog auto swap platform primities

* fixup! fixup! refactor: dialog auto swap platform primities
2024-03-22 13:48:17 +02:00
Omar López d08c3fdc71 fix: revalidation replacing availability form values (#14114) 2024-03-21 23:07:32 +00:00
Lauris Skraucis 74e5f4bf37 feat: atoms as npm package (#14160)
* fix: getEnv not returning fallback API_URL breaking examples app

* refactor: use vite as the only way to build atoms

* refactor: web use atoms from web.ts and rest from dist

* refactor: update atoms version, description and set privacy to public

* fix: lib and ui import from web atoms

* refactor: rename @calcom/platform-atoms to @calcom/atoms

* feat: atoms as npm works with example app outside monorepo

* start atoms from v1.0.0

* refactor: monorepo atoms for internal use

* document atoms publishing

* refactor: remove unused import in v2

* fix: mistakes made during main merge

* refactor: move back examples app while still having it in atoms-examples repo

* refactor: monorepo examples readme

* feat: atoms yarn publish command

* refactor: atoms css file simplify

* fix: mocking atoms in ui unit test

* fix: mocking atoms in app-store unit test
2024-03-21 14:33:10 -03:00
61a8543e08 feat: select team members to receive emails (#13957)
* Add UI to select members to receive emails in routing form

* Add backend changes to support frontend to select team members to get routing form updates to

* Fix type error

* Fix all the members of all the teams the user is part of shown instead of only the current team where the routing form is created

* Fix type error

* Refactor components to a shared folder

* fix type error

* Fix review comment: only include emails

* Remove listMembers trpc call in frontend and get the data in formQuery.handler

* Address review comments

* Remove unrelated changes

* Update SingleForm.tsx

---------

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-21 15:16:59 +00:00
Rajat.SandJoe Au-Yeung 82c7e595ea fix: url input field overflows when update profile & editing event (#14033)
* the url input field overflows

* overflow text input changes

* Update UsernameTextfield.tsx

* Eslint error fix

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-21 14:11:12 +00:00
Morgan e19e829ff7 refactor: availabilitySettings atoms web wrapper and translations (#14167)
* refactor: availabilitySettings atoms web wrapper and translations

* fixup! refactor: availabilitySettings atoms web wrapper and translations
2024-03-21 15:26:33 +02:00
Udit Takkar 0fc79f93de fix: rescheduling in round robin (#14109)
* fix: rescheduling in round robin

* chore: remove new calendar

* chore: update logic

* fix: simplify code

* chore: update deletevents
2024-03-21 11:35:34 +00:00
Crowdin Bot 0ad82bdf52 New Crowdin translations by Github Action 2024-03-21 11:10:20 +00:00
Syed Ali Shahbaz b4c62b3c43 fix create check for managed events (#14165) 2024-03-21 15:05:52 +04:00
alannnc 0df68cce3b add favicon.ico to app/ (#14076) 2024-03-21 03:56:57 +00:00
Crowdin Bot 2d90def37b New Crowdin translations by Github Action 2024-03-20 19:12:23 +00:00
602fd6879f fix: Broken reschedule link in email created by workflow for team event (#13893)
* add reschedule link if event if type team

* fix type errors

* fix type errors

* change team.name to team.slug

* fix type_errors

* fix type-errors

* fix type-errors

* fetch team from db

* make rescheduleLink dynamic (temp_changes)

* fix type-error

* add org support

* fix type errors

* remove old org code

* use /reschedule/uid instead

* remove not needed changes

* implement feedback

* code clean up

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-20 19:07:48 +00:00
6ea13b7c9a fix: improve defined slot start times (#14107)
* add 15 and 5 to intervalsWithDefinedStartTimes

* change slot start time logic

* test if we run tests

* remove unwanted changes

* add tests

* remove console.log

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-20 12:04:38 -04:00
sean-brydonandMorgan e169d9e8d1 fix: migrated users admin update (#14152)
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2024-03-20 14:24:16 +00:00
Omar López 0e8fa22b09 chore: adds Intercom admin link (#14146) 2024-03-20 14:00:32 +00:00
Erik c50e04e18b chore: Platform SDK (#14154) 2024-03-20 12:33:49 +00:00
Peer RichelsenandUdit Takkar 9bb13a0b47 added hideEventTypeDetails to hide org banner (#14119)
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-20 11:54:50 +00:00
Crowdin Bot 25c0955aa5 New Crowdin translations by Github Action 2024-03-20 11:32:25 +00:00
+24 0a15483c46 feat: platform atoms + api v2 (#14106)
* add connect to cal atom

* add connect to cal to atoms package index

* shadcn setup

* update packages

* button component from shadcn

* dumb button component

* replace button with dumb button component

* update commenst and change url param

* chore: setting up monorepo packages for platforms (#12572)

* chore: init platform folders strucutre and api proxy

* fixup! chore: init platform folders strucutre and api proxy

* chore: init database oAuth platform client schema

* fixup! chore: init database oAuth platform client schema

* fix config path after move to folder /v1

* feat: scaffold v2 API (#12554)

* init nest project

* add kysely as a separate package

* add ee folder with license

* prettier: format v2 api same as mono repo

* migrate over Eriks nestjs poc

* schema generation script

* ee license file

* nest poc eslint file

* remove prisma-kysely from v2 api

* prepare for mergin platform: remove prisma-kysely because incorrect checksum

* add prisma-kysely to packages/prisma

* move to apps/api/v2

* rename v2 package

* readme update

* Update apps/api/v2/env.example

* env typo

* env typo

---------

Co-authored-by: Erik <erik@erosemberg.com>
Co-authored-by: Morgan Vernay <morgan@cal.com>

* chore: init platform packages (#12603)

* chore: init platform packages

* fixup! chore: init platform packages

* fixup! fixup! chore: init platform packages

* fix: type in package.json

* fixup! fixup! fixup! chore: init platform packages

* fixup! fixup! fixup! fixup! chore: init platform packages

* fixup! fixup! fixup! fixup! fixup! chore: init platform packages

* fixup! fixup! fixup! fixup! fixup! fixup! chore: init platform packages

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>

* chore: platform more permissions utils and tests (#12613)

* chore: more permisions utils and tests

* chore: tests

* feat: validate `CalProvider` api keys (#12672)

* fix: signup nit (#12585)

* Disable submit on empty form

* Fix submit

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>

* New Crowdin translations by Github Action

* fix: Signup options are not disabled (#12610)

* fix: Signup options are not disabled

* fixes/signup disabling suggested changes done

* chore: signup and login improvements

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>

* fix: typo in @calcom/emails readme (#12615)

* fix: handle reschedule request for dynamic meetings (#12275)

* chore: [app-router-migration-1] migrate the pages in `settings/admin` to the app directory (#12561)

Co-authored-by: Dmytro Hryshyn <dev.dmytroh@gmail.com>
Co-authored-by: DmytroHryshyn <125881252+DmytroHryshyn@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>

* chore: added cursor-pointer to img upload (#12624)

* added cursor-pointer to img upload

* nit

* feat: add clear filters option in bookings page (#12629)

* add clear filters option

* fix vscode settings.json

* use removeAllQueryParams()

* fix yarn lock

* remove toggleoption

* feat: display long durations in hours on booking (#12631)

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>

* New Crowdin translations by Github Action

* fix: workaround for future app dir routes

* feat: Allow only first slot to be booked (#12636)

Co-authored-by: Morgan Vernay <morgan@cal.com>

* New Crowdin translations by Github Action

* feat: add matomo analytics app (#12646)

* chore: Sentry Wrapper with Performance and Error Tracing (#12642)

* add wrapper for sentry and update functions in 'getUserAvailability'. Update tracesSampleRate to 1.0

* Make Sentry Wrapper utilize parent transaction, if it exists.

* Update wrapper for functions to inherit parameters from the child function

* add comment of when to use the wrapper

* check for sentry before wrapping, if not call unwrapped function

* refactored wrapper to have async and sync separate functions that utilize helpers for common behaviour

* update type of args to unknown

* fixed types of returns from wrapped functions

---------

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>

* validate api keys to set error and key states for api keys

* organize error messages into one place

* set error messages from errors file instead of hardcoding value

* fix incorrect constant name

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: Pratik Kumar <70286186+Pratik-Kumar-621@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Samyabrata Maji <116789799+samyabrata-maji@users.noreply.github.com>
Co-authored-by: Manpreet Singh <manpoffc@gmail.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Dmytro Hryshyn <dev.dmytroh@gmail.com>
Co-authored-by: DmytroHryshyn <125881252+DmytroHryshyn@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Varun Prahlad Balani <varunprahladbalani@gmail.com>
Co-authored-by: Mike Zhou <mikezhoudev@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Haran Rajkumar <haranrajkumar97@gmail.com>
Co-authored-by: Morgan Vernay <morgan@cal.com>
Co-authored-by: Harshith Pabbati <pabbatiharshith@gmail.com>
Co-authored-by: Brendan Woodward <73412688+bwoody13@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>

* fix: storybook atom import

* feat: oauth clients management (#12604)

* feat: oAuth create and update dtos

* feat: WIP oAuth repository

* feat: oAuth controller and module

* refactor: rename cal oAuth to simply oauth

* fix: controller update client

* add oAuth client module to endpoints module

* refactor: OAuthClientRepository

* refactor

* status codes for controller

* oauth create return

* fix: oAuth client only for v2 API

* remove repository as provider from its module

* fix: oAuth module, have repository in providers

* fix: make endpoints run

* comment out oauth prisma schema code: coming next

* refactor: remove api-key authguard (#12675)

* chore: Prisma exception filters (#12679)

* fix: get prisma schema from package @calcom/prisma (#12692)

* fix: get prisma schema from package @calcom/prisma

* fixup! fix: get prisma schema from package @calcom/prisma

* fixup! fixup! fix: get prisma schema from package @calcom/prisma

* fix: prettier config

* fixup! fix: prettier config

* chore: create authenticated user guard (#12677)

* chore: wip next-auth-guard for apiv2

* refactor: use NextAuthGuard on all OAuthClientController routes

* refactor: use passport to get next user

* exclude password from prisma read service

* Revert "exclude password from prisma read service"

This reverts commit 24b1f8ed59f6d99f0ecc589c691efb0ac1f2ac3b.

* fix: userRepo sanitize password

* refactor: function order in UserRepository

* implement user repository service

* refactor: strict null checks for TS

* refactor: fix strict null checks

* delete res locals type

* refactor: switch from zod to class-validator for oAuth client

* refactor: switch from zod to class-validator for booking

* refactor: rename dtos folder to input folder

* fix: create migration for prisma schema oauth clients table

* feature: post oAuth client

* refactor: rename oAuth client_secret to secret

* stricter ts config + oauth secret

* remove migrations

* fix: improve response type

* improve error code types

* fix: prettier by removing eslint as its not needed

* refactor: eslint fix files

* wip organization oauth_lcient

* fix import types

* fix team schema platformOAuthClient name

* fix: import packages transpiled

* feat: roles guard

* refactor: use organisationId instead of userId

* fix: jwt secret signing not having jwt_secret

* fix: stop importing input DTOs as types

* fix: jwt sign expecting plain object

* add sentry, routes logger, generic response type

* fix test config

* fixup! fix test config

* refactor: dont await async function return

* feat: fallback value for getEnv

* feat: add helmet for security

* feat: organization guard

* refactor: check if user set in RolesGuard

* refactor: remove roles requirement for oauth read

* chore: add exceptions filters

* fix: api key strategy throws errors

* chore: set e2e tests

* chore: centralize api type in package

* feat: user repository relations

* feat: user repository relations

* Revert "feat: user repository relations"

This reverts commit 1802b256b5a6e5c9b6a62138c8cb1b6f75ed401b.

* Revert "feat: user repository relations"

This reverts commit 4a8f52583d95ff15b6254694c976d8ec9ce0e546.

* test: mock next auth

* fixup! test: mock next auth

* test:oAuth  authed user but no org

* refactor: remove unused type

* refactor: organisation guard based on Membership table

* refactor: folder and file structure

* fix: small changes exception filters

* refactor: merge organization and roles guards into one guard

* fix: remove old export

* fix: org roles guard

---------

Co-authored-by: supalarry <lauris.skraucis@gmail.com>

* chore: OAuth clients tests and fixes (#12762)

* chore: add tests and fixes

* fixup! chore: add tests and fixes

* fixup! fixup! chore: add tests and fixes

* fixup! fixup! fixup! chore: add tests and fixes

* fixup! fixup! fixup! fixup! chore: add tests and fixes

* fixup! fixup! fixup! fixup! fixup! chore: add tests and fixes

* fixup! fixup! fixup! fixup! fixup! fixup! chore: add tests and fixes

* fix: remove unused imports

* chore: move repos to feature folder (#12769)

* chore: rename repositories

* fix yarn.lock

* feat: oauth client guard (#12814)

* feat: oAuth client guard

* refactor test

* refactor: move oauth-client guard to oauth module

* refactor: separate jest config from package.json

* fix: resolving paths in jest tests

* fix: tests

* jest setup file

* fix: jest test warnings about .js platform constants imports

* refactor: test repository fixtures

* remove allowjs

* ignore js files in ts-jest

* make oauth client module global

* make oauth client module global

* feat: platform oAuth clients frontend (#12867)

* add oauth client to settings

* fix imports

* add react and axios

* oauth client form and card components

* hooks for oauth clients data

* index page for oauth clients

* oauth client list component

* oauth client form page

* shift atoms into platform

* init platform folder

* refactor handleSubmit functioin

* platform

* platform

* platform parts

* revert tsconfig constant platform

* fix: useOauthClients

* feat: create oauth client with api

* fix: add prettier to platform type package

* fixup! fix: add prettier to platform type package

* chore: class-validator types in platform package

* add types for delete oauth client iput

* add onSuccess and onError methods

* update oauth client card view with client id and secret

* cleanup comments

* split oauth persisit hook into create and delete hooks

* fix: oauth client creation / deletion / listing

* fixup! fix: oauth client creation / deletion / listing

* fix: comment logo for now

* fix: layout setting org keys

* cleanup comments

* minor style fixes, add logic for client permissions

* show toast after deleting client

* not passing clint logo at the moment

---------

Co-authored-by: Morgan Vernay <morgan@cal.com>

* chore(platform): OAuth Flow (#12798)

* fixup! chore(platform): OAuth Flow (#12798)

* feat: CRUD for oAuth users (#12853)

* user controller with oauth guard

* crud repository and controller operations

* add user controller to user module

* refactor: oauth guard

* connect user with oauth client upon creation

* fix: test

* wip: e2e test

* refactor: findUniqueOrThrow -> findUnique user

* test: POST user request

* feat: permissions guard

* e2e tests

* e2e

* e2e refactor

* e2e refactor

* reflector decorator check refactor

* refactor oauth guard

* remov unused imports

* log message

* delete permissions decorator and guard

* remove delete user endpoint

* remove delete user endpoint

* refactor: route structure

* remove get oauth client decorator

* delete unecessary e2e config changes

* remove set header in post test

* fix: oauth guard test on empty db

* revert: add previously removed constant to fulfill merge platform

* fix: import to satisfy platform branch merge

* use real implementation of access token guard

* generate access & refresh tokens and fix e2e

* fix: oauth client e2e test

* refactor: variable naming

* refactor

* rename test file

* remove oauth client from request

* refactor: v2 API (#12913)

* Use Boolean only instead of git add src/modules/auth/guard/organization-roles/organization-roles.guard.ts

* move tests next to files they test

* replace .. in import paths with absolute path

* camelCase instead of snake_case for access and refresh token variables

* user sanitize function Typescript friendly

* restructure oAuth clients folder: example for other folders

* restructure bookings module

* organize modules in auth, endpoints, repositories, services

* organize auth module

* organize repositories

* organize inputs

* rename OAuthClientGuard to OAuthClientCredentialsGuard

* add error messages

* add error messages

* clientId as param in oauth-flow & schema mapping

* camelCase instead of snake_case for clientId and clientSecret

* access token guard as passport strategy

* folder structure as features

* get rid of index files

* feat: endpoint for deleting oAuth users & oAuth users returned data (#12912)

* feat: delete oAuth users

* check if access token matches userId in parameter

* driveby: return only user id and email in oauth users endpoints

* refactor: access token errors (#12932)

* change error messages

* error message if access token does not exist in our database

* token expired 498

* access token expired message as constant

* store 498 status code as const

* fix: access token error less information given

* chore: invalid access token const

---------

Co-authored-by: Morgan Vernay <morgan@cal.com>

* feat: external gcal (#12954)

* wip connect gcal

* feat: add external google calendar

* fixup! feat: add external google calendar

* fix: google calendar oauth check invalid

* google cal check tests

* use zod

* fix: await validate access token service

* chore: e2e tests for oAuth flow (#13005)

* fix: accessing length of undefined

* refactor: GetUser throw error if no user provided

* fix: cascade delete PlatformAuthorizationToken if owner or client deleted

* test: POST /authorize

* refactor oauth-flow controller

* refactor oauth-flow controller

* new function to get authorization token by client user ids

* refactor token service

* fix: re-created access and refresh tokens having not unique secret

* oauth flow tests

* oauth flow tests

* feat: abstracted jwt service (#13016)

* remove unused JwtModule from the auth module

* feat: create abstracted jwt service

* refactor: tokens module and service use new jwt service

* refactor: oauth-client module and repository use new jwt service

* implement Morgans requests

* Basic atoms in barebone example platform apps (#13006)

* example app

* example app

* dev move

* fix: more entry points

* fixup! fix: more entry points

* refactor: v2 API (#12913)

* Use Boolean only instead of git add src/modules/auth/guard/organization-roles/organization-roles.guard.ts

* move tests next to files they test

* replace .. in import paths with absolute path

* camelCase instead of snake_case for access and refresh token variables

* user sanitize function Typescript friendly

* restructure oAuth clients folder: example for other folders

* restructure bookings module

* organize modules in auth, endpoints, repositories, services

* organize auth module

* organize repositories

* organize inputs

* rename OAuthClientGuard to OAuthClientCredentialsGuard

* add error messages

* add error messages

* clientId as param in oauth-flow & schema mapping

* camelCase instead of snake_case for clientId and clientSecret

* access token guard as passport strategy

* folder structure as features

* get rid of index files

* feat: endpoint for deleting oAuth users & oAuth users returned data (#12912)

* feat: delete oAuth users

* check if access token matches userId in parameter

* driveby: return only user id and email in oauth users endpoints

* Connect CalProvider and GCal

* Connect CalProvider and GCal

* return response interceptor to handle failed requests

* handle failed requests using axios intercepter

* cal provider refresh tokens, external gcal

* external gcal

* cal provider refresh and retries

* remove console.log

* refactor

* ignore built atoms css

* remove change to token repo

* refactor

* refactor

* downdgrade vite of unrelated packages

* move gcal endpoints to platform

* gcal service

* refactor: use atoms provider

---------

Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: Ryukemeister <sahalrajiv-extc@atharvacoe.ac.in>

* feat: user schedule management (#13053)

* platform-constants package: list of accepted schedule timezones

* feat: schedules endpoint to create schedule with default availability

* refactor: rename function

* refactor: store userId for availabilities

* feat: createSchedule endpoint

* feat: get schedules/default

* feat: getSchedule by id

* feat: get all schedules

* feat: delete schedule

* feat: update schedule

* check user owns schedule

* empty test

* define returned data on controller level not repository

* define returned data on controller level not repository

* Revert "define returned data on controller level not repository"

This reverts commit 4c292a0f0762f58bdcad0707ad8eef7408390800.

* use luxton

* put availabilities out of ee

* use guard on controller level

* refactor

* e2e test schedule creation

* remove log

* test

* default schedule get test

* update schedule test

* delete schedule test

* fix update test

* different email for schedules e2e

* driveby: fix yarn test

* schedule inputs availabilities as array

* re-use BaseStrategy class

* feat: me endpoint v2 api (#13274)

* feat: me endpoint v2 api

* simplify

* chore: NestJS throttling (#13011)

* fix: v2 throttling setup (#13402)

* fix: v2 throttling

* fix: setup redis locally

* move sentry files to api v1

* chore: calcom platform libraries (#13444)

* fixup! chore: calcom platform libraries (#13444)

* fix: fix managed users

* feat: user timezone management in `CalProvider` (#13361)

* hooks to fetch and update user timezone

* add react query package

* add logic to check for change in user timezone and update it

* hook to handle timezone changes

* shift timezone handling logic into separate custom hook

* rename variables

* rename hook to get a user

* call useTimezone hook inside of cal provider

* minor refactors

* add variables for api endpoints

* use URL constructor for creating endpoints

* key prop not needed

* use URL constructor for creating endpoints

* chore: package json scripts

* fix(atoms): fix import path of useUpdateUserTimezone

* fix(atoms): build constants and fix ENDPOINTS const

* feat: v2 api event type endpoints (#13449)

* build platform-libraries

* make getEventTypeById compatible with default PrismaClient

* feat: fetch event type endpoint

* handle event type not found

* e2e test for GET

* test

* determine is user org admin for getEventTypeId correctly

* prisma type like before

* add negative test

* POST event-type and return event-type for api and atom

* POST event-type and return event-type for api and atom

* feat: create default user event types when creating managed user

* feat: v2 api me PUT endpoint (#13486)

* add timeZone to me endpoint

* feat: me endpoint PUT

* reset package.json

* standardize creation and updating of user

* user creation: capitalize timezones and week start

* default event type constants in const file

* refactor: defaultTimezone Europe/London in response schema

* refactor: validators

* refactor: default schedule in schedules endpoints

* refactor: patch instead of put

* fix: getEventTypeById organizationId (#13554)

* chore: transpile more libraries functions

* feat: overlay calendar busy dates events (#13581)

* feat: overlay calendar busy times events

* fixup! feat: overlay calendar busy times events

* fixup! fixup! feat: overlay calendar busy times events

* fixup! fixup! fixup! feat: overlay calendar busy times events

* refactor: schedules for atom (#13585)

* schedules get.handler transformers as util functions

* export schedule transformers from platform-libraries package

* schedules for atom

* refactor: schedules response service format response

* remove unused injected dependency

* fix: prevent duplicate calendar account linking (#13310)

* fix: prevent signing up multiple times from same account

* revert: lark calendar changes

* credential clean up if duplicate

* fix code duplication and check before credential creation

* feat: useRouterQuery allow unset queryParam

* feat: showToast on account duplication attempt

* Small tweak to copy

* Updated other calendars not to use checkDuplicateCalendar

* Add account already linked to apps/installed/calendar

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>

* Revert event-type profile based querying (#13588)

* test: Bookings: Add more automated tests for organization (#13576)

* Avoid selecting unused props

* Add automated tests

* Add existing user invite and booking

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* fix: organization user shouldn't be asked for payment for a premium username (#13535)

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* chore: refactor handle new reccuring booking (#13597)

* chore: refactor handle new reccuring booking

* fixup! chore: refactor handle new reccuring booking

* fixup! fixup! chore: refactor handle new reccuring booking

* test: Create unit tests for the questions (teste2e-multiSelectQuestion) (#11569)

* Remove unnecessary changes

* add changes

* Requested changes

* Requested changes

* FIx failing tests

* FIx failing tests

* Update regularBookings.ts

* FIx failing tests

* Refactor

* add unit tests for all questions

---------

Co-authored-by: gitstart-calcom <gitstart-calcom@users.noreply.github.com>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>

* fix: update valid_for_secs (#13604)

* fix: Fixes teams UI load issue (#13593)

* fixes teams uiload issue

* revert: yarn.lock

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>

* chore: upgrades boxyhq jackson (#13477)

* chore: upgrades boxyhq jackson

* Update jackson.ts

reduces bundle size

* Update yarn.lock

* Update apps/web/next.config.js

* Upgrades again

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>

* upgrades copycat

* feat: PLA-47 Reserve Slots Handler (#13607)

* PLA-44 feat: Platform getPublicEvent (#13596)

* chore: getPublicEvent

* chore: fix

* feat: booker atom bookings platform endpoints (#13613)

* feat: handle new booking

* wip

* feat: handle recurring and instant booking

* fixup! feat: handle recurring and instant booking

---------

Co-authored-by: Peer Richelsen <peeroke@gmail.com>

* fix: v2 not running (#13636)

* fix: import from platform-libraries instead of lib

* fix: typescript error

* fix: provide EventTypesRepository to SlotsService

* fix: small change

* Merge branch 'main' into platform

* fix: make v2 run after user model changes (#13653)

* feat: event type atom user connected and destination calendars endpoint (#13559)

* extract connected calendars logic in re-usable platform-libraries function

* extract connected calendars logic in re-usable platform-libraries function

* extract connected calendars logic in re-usable platform-libraries function

* calendars endpoints

* enable calendars endpoint

* calendars type form platform-libraries instead of lib

* finish merging platform branch

* fix dbWrite

* fix: issue after merge platform

* fix: new abstracted function export

* change ee/overlay-calendars to ee/calendars endpoint

* refactor: merge overlay service with calendars service

* ts fix

* body -> query

* chore: Platform get schedule (#13696)

* chore: get available slots

* chore: infer event type isTeam

* chore: nit

* chore: Delete selected slot (#13692)

Co-authored-by: Morgan Vernay <morgan@cal.com>

* feat: v2 endpoint for availability atom timezones (#13687)

* refactor: move cityTimezones handler to lib

* test: incorrect timezone when creating oauth user

* refactor: standardize time zone validation

* feat: schedules/time-zones endpoint returning possible time zones

* refactor: @IsValidTimezone load allowed timezones dynamically

* chore: split timezones to its own trpc router

---------

Co-authored-by: Morgan Vernay <morgan@cal.com>

* fix after merge main

* feat: platform useGetPublicEvent (#13752)

* feat: platform useGetPublicEvent

* chore: move public event type to libraries

* chore: use const for query key

* fixup CalendarBusyTimesInput optional params

* feat: platform use get available slots (#13756)

* feat: platform use get available slots

* fixup! feat: platform use get available slots

* feat: platform use get connected calendars (#13757)

* chore: platform enable cors (#13774)

* chore: enable cors

* fixup! chore: enable cors

* feat: platform use get calendars busy times (#13759)

* fixup! feat: platform use get calendars busy times (#13759)

* feat: platform use slots hooks (#13785)

* feat: platform use slots hooks

* fixup! feat: platform use slots hooks

* fixup! fixup! feat: platform use slots hooks

* fixup! fixup! fixup! feat: platform use slots hooks

* fixup! fixup! fixup! fixup! feat: platform use slots hooks

* fixup! feat: platform use slots hooks (#13785)

* feat: platform use create boookings hooks (#13797)

* feat:  `Availability Settings` atom (#13762)

* styling and updating the examples app

* add custom hooks for availability settings atom

* update default exports

* minor updates

* update cal provider to use react query

* availability settings atom

* dialog from shadcn

* navbar for examples app

* add select skeleton loader in calcom ui packages

* refactors

* define rtl for cal provider

* fox trpc call to avoid merge conflicts

* fix issues caused by merges

* revert changes for rtl

* hook to fetch every city timezones

* implement useGetCityTimezones into timezone component

* minor fix

* update hooks

* add props and intergrate into avaialibility component

* add missing await

* remove logs

* add comments

* invalidate queries after settled

* toaster from shadcn

* add toaster into cal provider

* implement toast on event handlers

* add classnames prop to accept custom styles

* passing custom styles

* update packages

* remove comments

* fix: styling

* fix: useUpdateSchedule

* fixup! fix: useUpdateSchedule

* wip

* feat: availability setting atom

* fixup! feat: availability setting atom

* fixup! fixup! feat: availability setting atom

* fixup! fixup! fixup! feat: availability setting atom

* fixup! fixup! fixup! fixup! feat: availability setting atom

---------

Co-authored-by: Morgan Vernay <morgan@cal.com>

* fix: atoms import

* chore: lock

* fix: types

* fixup! fix: types

* refactor: v2 user timezones (#13944)

* fix: OAuth client form improvements (#13837)

* rename app to apps

* fix type errors, validate redirect url and other fixes

* enable user to add multiple redirect uris

* add id to input to make labels clickable

* translations for oauth form

* improve styles, add translations and add select all button for permissions

* add permissions for profile read and write

* fixes

* nit

* use `useFieldArray` for dynamic fields

---------

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>

* refactor: check organizationId primarily on user profile (#13969)

* refactor: attach movedToProfile to user

* refactor: check organizationId primarily on user profile

* fix: resolve TS errors to build v2 for prod (#13858)

* feat: atoms typescript build (#13864)

* fix: atoms typescript build

* refactor: dayjs

* refactor: meticulous

* refactor: use vite for type generation

* tsconfig

* feat: given user timezone update update default schedule timezone (#13981)

* refactor: standardize schedules api response

* fix: schedules e2e tests

* refactor: use IsTimeZone class-validator instead of custom built one

* feat: validate managed user timezone

* feat: update default schedule when me schedule updated

* refactor: standardize v2 api returned data (#13984)

* feat: V2 api swagger (#13804)

* feat: v2 API swagger docs

* fix: query param not showing up in docs

* latest swagger.json

* refactor: remove scaffolded sample endpoint

* separate internal endpoints

* oauth-clients and oauth flow docs only in dev

* oauth-clients and oauth flow docs only in dev

* create oauth client response doc

* responses for oauth-clients

* document development only endpoints

* chore: consume auth token on exchange (#13993)

* feat: docker build for v2 (#13918)

* fix: resolve TS errors to build v2 for prod

* WIP: api v2 docker

* arg env dockerfile

* wip

* Revert "wip"

This reverts commit 232adf5b969ef004ae907f3e85b12c2715d9b6bc.

* wip

* wip

* fix docker

* fix docker

* fix docker

* docker

* docker

* expose port 80

* feat: oauth client permissions guard (#14020)

* feat: Permissions guard

* feat: Permissions guard

* tests

* feat: use permissions guard for event types

* extra permissions test

* fix tests

* bokings, gcal, me and schedules permissions

* chore: use availability settings atom and fix useTimezone platform hook (#13934)

* replace availabiilty settings with atom component

* add more props for custom styles

* replace intl with dayjs

* review feedback fixes

* fix: v2 api typescript errors (#14059)

* fix: start:prod script

* fix: v2 me module dependencies (#14073)

* feat: check v2 request origin (#14074)

* feat: check v2 request origin

* drive by: remove console log in test

---------

Co-authored-by: Lauris <lauris@Lauriss-Laptop.local>

* fix date overrides typing issues (#14091)

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>

* fix: v2 e2e tests (#14088)

* fix: v2 e2e tests

* fix: yarn e2e tests run 1 after another

* fix gcal test

---------

Co-authored-by: Lauris <lauris@Lauriss-Laptop.local>

* fix: availability atom and access token origin strategy

* fix: availability atom get error from unknown

* feat: booker atom platform wrapper (#14036)

* feat: booker atom, fix hooks

* wip

* feat: booker atom platform wrapper

* fix conflicts

* fix: build v2 internal dependencies upon v2 build

* fix typing of useDeleteOAuth

* fix: isplatform timezone select improt booker event meta

* fixup! Merge branch 'platform' into feat-booker-atom-platform

* refactor

* add video call event types

* disable email and set managed user names

---------

Co-authored-by: supalarry <lauris.skraucis@gmail.com>

* update yarn.lock

* Update .prettierignore

* update post install

* fix: post install

* fix yarn lock

* fix: post install

* fix: types

* feat: enable user control over timezone changes and helpers for query params (#14049)

* helpers to get and set value of a query paramater

* add event handlers and props to figure out the timezone preference of a user

* make onTimeZoneChange handler optional

* fixup

* fix merge conflicts

* fixup

* revert changes

* fixup

* fixup

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>

* fix: usetimezone import

* fix: prisma client import

* fix: prisma client import

* fix: prisma client import

* remove post install using vite

* ts fix attempt: pin prisma to same version

* Revert "ts fix attempt: pin prisma to same version"

This reverts commit 2c309f52e3a881e2dbda4185f45e77967bef6925.

* resolve v2 prisma to calcom prisma

* sync v2 and typescript deps

* sync atoms package

* lock file updat

* fix: platform web components move out of pages folder

* ui: allow experimental decorators to fix ts ci error

* app-store: allow experimental decorators to fix ts ci error

* web: allow experimental decorators to fix ts ci error

* fix: github actions v2 api secrets

* add license

* mock useIsPlatform for tests

* fix timezone select tests

* mock useLocale

* fix tests

* fix tests

* fix tests

* fix github actions

* chore: temporarily disable redis (#14142)

* fix: only one migration file for platform

* fix api v1 files location

* fix: disable apiv2 test in ci

---------

Co-authored-by: Ryukemeister <sahalrajiv-extc@atharvacoe.ac.in>
Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
Co-authored-by: Erik <erik@erosemberg.com>
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: Pratik Kumar <70286186+Pratik-Kumar-621@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Samyabrata Maji <116789799+samyabrata-maji@users.noreply.github.com>
Co-authored-by: Manpreet Singh <manpoffc@gmail.com>
Co-authored-by: Benny Joo <sldisek783@gmail.com>
Co-authored-by: Dmytro Hryshyn <dev.dmytroh@gmail.com>
Co-authored-by: DmytroHryshyn <125881252+DmytroHryshyn@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Varun Prahlad Balani <varunprahladbalani@gmail.com>
Co-authored-by: Mike Zhou <mikezhoudev@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Haran Rajkumar <haranrajkumar97@gmail.com>
Co-authored-by: Harshith Pabbati <pabbatiharshith@gmail.com>
Co-authored-by: Brendan Woodward <73412688+bwoody13@users.noreply.github.com>
Co-authored-by: Amit Sharma <74371312+Amit91848@users.noreply.github.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: gitstart-app[bot] <57568882+gitstart-app[bot]@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart-calcom@users.noreply.github.com>
Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com>
Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
Co-authored-by: Anant Jain <75206987+anantJjain@users.noreply.github.com>
Co-authored-by: Lauris <lauris@Lauriss-Laptop.local>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
2024-03-20 13:23:19 +02:00
5aa922559a fix: email displayed as organizer eventtype settings (#14102)
* fix: email displayed as organizer eventtype settings

* fix: quotation in i18n file

* fix: unwanted changes

* fix: dropdown not visible

---------

Co-authored-by: v0ltZzie <161201747+v0ltZzie@users.noreply.github.com>
Co-authored-by: supalarry <laurisskraucis@gmail.com>
Co-authored-by: v0ltZzie <samit091848@gmail.com>
2024-03-20 10:27:28 +00:00
Alex van Andel 9abf004880 Adding 'hosts' instead of 'users' (#14105) 2024-03-19 23:24:24 +00:00
Crowdin Bot 253f57bce1 New Crowdin translations by Github Action 2024-03-19 18:20:19 +00:00
a55ffca013 fix: timezone display on booking page to reflect event availability timezone (#14127)
* fix timezone display on booking page to reflect event availability timezone

* migrate fetching event owner's schedule to server side

* migrate fetching event owner's schedule to server side

* fix e2e test errors

---------

Co-authored-by: Shaik-Sirajuddin <sirajuddinshaik30gmail.com>
Co-authored-by: Shaik-Sirajuddin <sirajudddinshaik30@gmail.com>
Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-19 18:15:08 +00:00
Alex van Andel 86addf3793 fix: Some tests weren't running (#14145) 2024-03-19 15:30:37 +00:00
Crowdin Bot 68599fc189 New Crowdin translations by Github Action 2024-03-19 14:54:48 +00:00
Erik 0e29c518d0 v3.9.1
release.yml / release (push) Canceled after 0s
2024-03-19 11:48:40 -03:00
Alex van Andel 8edf55f946 fix: Minor UI fix to team profile / fallback to parent org logo (#14143) 2024-03-19 14:45:15 +00:00
Alex van Andel 85425649d4 fix: Crash of event types page if the upId is incorrect (#14136) 2024-03-19 11:41:16 -03:00
Udit TakkarandJoe Au-Yeung b39cbea82b chore: improve apple calendar message (#14139)
* chore: add better error message for apple calendar

* chore

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-19 14:33:12 +00:00
b1d31613d9 style: Provide Visual Feedback to Users Upon Button Click to Indicate Processing Time #13553 (#14137)
* Update UserSettings.tsx

i am trying to solve Processing button

* chore: use loading property and undo changes

* chore: add in other pages

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-19 14:23:37 +00:00
Udit Takkar d6605d6dfd feat: display org banner on personal event types (#14101)
* feat: display org banner on personal event types

* chore: add banner url

* fix: type error
2024-03-19 14:20:40 +00:00
sean-brydonandUdit Takkar 0f1f0a29e6 fix: pass org slug to useSchedule (#14138)
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-19 11:17:04 +00:00
sean-brydonandUdit Takkar e4e1d91068 fix: fix indicator size (#14125)
* fix: fix indicator size

* chore: import

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
2024-03-19 08:42:50 +00:00
Peer RichelsenandUdit Takkar 848318a771 feat: golden verified badge for org members (#14131)
* added orange verified badge for orgs

* nit

* fix: add isOrg

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
2024-03-19 08:18:16 +00:00
Carina WollendorferandCarinaWolli aaf630ed18 fix: booking limits for team event types (#14135)
* use bookings from all users

* add same changes to handleNewBooking

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2024-03-19 13:12:09 +05:30
Shobana Chandrasekaran ece74cbc49 fix: dynamic event length change on reschedule (#14110)
* fixed dynamic event length change on reschedule

* fixed dynamic event length change on reschedule

* Update get-booking.ts

Type check: added endTime

* Update get-booking.ts

* Fix: typeCheck error

* Revert yarn.lock to its state before unintended changes
2024-03-18 14:53:53 -04:00
Udit TakkarandJoe Au-Yeung 3c5a007125 fix: date picker arrow positioning (#14129)
* fix: date picker arroe

* chore: improvements

* fix: add extra row

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-18 18:27:54 +00:00
sean-brydonandUdit Takkar 9694aa443f feat: add 2fa removal for admins (#14126)
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-18 10:49:48 -07:00
Somay ChauhanandJoe Au-Yeung 7e557889b6 feat: support for platform wide webhooks (#14092)
* db migration

* adjusted ui to include `platform` in dropdown for admin webhooks

* adjusted webhook/create.handler for platform

* adjusted `edit.handler` so that only ADMIN can update `platform` webhooks

* update `getWebhooks` for platform wide webhooks

* list platform webhooks if admin

* createFunction refactor

* update subscriberUrlReserved for platform webhooks

* fix delete webhook handler

* fix: added readOnly to WebhookListItem

* fix: admin cannot delete its own webhooks

* fix: ts error

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-18 13:42:28 -04:00
Morgan 9e17042a72 chore: update github actions for platform (#14130) 2024-03-18 16:20:15 +00:00
Carina WollendorferandCarinaWolli 4b764436e5 catch error (#14104)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2024-03-18 15:47:12 +00:00
Udit Takkar c42571df03 fix: email embed displaying wrong date (#14128) 2024-03-18 20:25:57 +05:30
Omar López a30555018f fix: deprecated code in new credential sync endpoints (#14116) 2024-03-16 23:26:13 +04:00
Alex van Andel 0c2d1bff2b v3.9.0
release.yml / release (push) Canceled after 0s
2024-03-15 18:55:46 +00:00
Joe Au-Yeung 7a790aaabe refactor: Moving credential syncing to API (#13963)
* Implement credential sync secret

* Create auth middleware for credential syncing

* Create GET endpoint

* Update swagger comment

* Add verifyCredentialSyncEnabled middleware

* Fix middleware input

* Fix APP_CREDENTIAL_SHARING_ENABLED to return boolean

* Add check for admin API key

* Add GET method

* Middleware require credential sync secret

* Return only the credentialId

* Update default CALCOM_CREDENTIAL_SYNC_HEADER_NAME value

* Add post endpoint

* Return credential object for get endpoint

* Require a userId in the param

* POST add keys to body

* Add PATCH endpoint

* Add DELETE endpoint

* Fix minimumTokenResponseSchema

* Add encrypted key

* Remove prototype

* Add swagger doc comments

* Fix parsing and error handling

* Add create selectedCalendar and destinationCalendar params
2024-03-15 16:03:49 +00:00
Hariom Balhara 8fe8beb686 fix: Avoid CSP related warnings in console on booking pages. (#14072) 2024-03-15 15:42:10 +00:00
Carina WollendorferandCarinaWolli 71b0dd2aa3 fix: don't show 'send event details to' for team events (#14093)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2024-03-14 16:12:21 +00:00
Amit Sharma 28c793c3fe fix: Exclude current rescheduled booking from limit (#13870)
* fix: Exclude current rescheduled booking from limit

* fix: type check

* chore: test for rescheduling during limit
2024-03-14 11:53:30 -04:00
Gabbar af6899d122 Fix Misspelled in .github/PULL_REQUEST_TEMPLATE (#14081) 2024-03-14 13:40:36 +00:00
Crowdin Bot f4baf88ed5 New Crowdin translations by Github Action 2024-03-14 09:11:51 +00:00
09ca75eb1f feat: lock event types for org users (#14000)
* chroe: org settings schema

* wip: UI work + modal on toggle

* chore: update i18n

* fix: list handler

* fix: update handler on untoggle

* chore: extract

* feat: update handler for hide and delete logic

* chore: radio translations

* chore: fix modal state from flickering

* feat: update copy & add danger colour on delete focus

* chore: update copy

* design: remove modal icon

* chore: include more seeds

* fix: update handler

* feat: hide create for profile user

* feat: use readonly instead

* feat: hide personal event type header when read only

* chore: move away form readOnly as it was used in other ways

* chore: fix read-only bug

* fix: hide readonly create screen

* fix: show managed event types when events are locked

* fix: hide if not admin

* Update packages/trpc/server/routers/viewer/eventTypes/create.handler.ts

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>

* fix: feedback

* fix: lock eventtype single switch

* fix: empty state create button

* fix: more profileGroup check outside CTA to pass value to filter too

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2024-03-14 09:07:37 +00:00
Joe Au-Yeung 3aff79e7d1 fix: Get dsyncData based on database (#14067)
* Set unique tenant

* Rely on current DB for dsync data

* Fix rendering dsync config

* Remove console.log

* Address feedback

* Add relationship between dsync data and team group mapping

* Fix `dsyncData` and `organizationSetting` relationship
2024-03-14 01:25:50 +00:00
Omar López a7405db0d4 refactor: removes deprecated customPrisma for API (#14069) 2024-03-13 23:57:19 +00:00
Joe Au-Yeung 802fbdf491 fix: Do not refund payments when cancelling bookings (#13924)
* Remove logic that refunds on cancel booking

* Remove cancelled refund booking test
2024-03-13 21:46:07 +00:00
Alex van Andelandzomars 2803b5072c fix: Remove the right date override on removal (#13988)
Co-authored-by: zomars <zomars@me.com>
2024-03-13 20:30:28 +00:00
502a3241e4 chore: run migrations conditionally (#13925)
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-13 19:52:27 +00:00
a4bc0793d7 chore: update to see webhook creation error handling to see error in prod (#14071)
* chore: update to see erorr in prod

* fix: keep try ctach

* chore: add logger from lib

* chore: improvement

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-03-13 17:55:53 +00:00
Crowdin Bot 4af209fc9d New Crowdin translations by Github Action 2024-03-13 16:00:31 +00:00
Udit Takkar 76b33165e5 fix: hide hidden fields on booking page (#13843)
* fix: hide hidden fields on booking page

* fix: only display for organizer

* fix: hide response

* chore: fix type err

* fix: type err

* fix: unit tests
2024-03-13 11:54:11 -04:00
Keith Williams 5109075494 v3.8.9
release.yml / release (push) Canceled after 0s
2024-03-12 16:31:33 -03:00
Keith Williams 52791599e1 Revert "fix: view team bookings (#13591)" (#14066)
This reverts commit 4585199b5e.
2024-03-12 19:01:41 +00:00
Anwar SadathandAlex van Andel 54db9a42a9 fix: Create team events using admin token (#14044)
* fix: Create team events using admin token

* Revert `import {` to `import type {`

---------

Co-authored-by: Alex van Andel <me@alexvanandel.com>
2024-03-12 16:39:01 +00:00
Crowdin Bot ce204d7a98 New Crowdin translations by Github Action 2024-03-12 16:27:29 +00:00
Candous 44170b267f chore: add pt-BR translations (#14022) 2024-03-12 16:22:15 +00:00
cb30e5f1e0 fix: metadata for seats in webhooks (#14025)
* add metadata to seats for workflows and webhooks

* add test

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2024-03-12 16:15:19 +00:00
d6d2aae67f fix event length in webhooks payload (#14039)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2024-03-12 16:07:07 +00:00
833 changed files with 44599 additions and 4924 deletions

No files matched your search

+8 -3
View File
@@ -26,8 +26,6 @@ DATABASE_URL="postgresql://postgres:@localhost:5450/calendso"
# Needed to run migrations while using a connection pooler like PgBouncer # Needed to run migrations while using a connection pooler like PgBouncer
# Use the same one as DATABASE_URL if you're not using a connection pooler # Use the same one as DATABASE_URL if you're not using a connection pooler
DATABASE_DIRECT_URL="postgresql://postgres:@localhost:5450/calendso" DATABASE_DIRECT_URL="postgresql://postgres:@localhost:5450/calendso"
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
INSIGHTS_DATABASE_URL= INSIGHTS_DATABASE_URL=
# Uncomment to enable a dedicated connection pool for Prisma using Prisma Data Proxy # Uncomment to enable a dedicated connection pool for Prisma using Prisma Data Proxy
@@ -232,6 +230,7 @@ NEXT_PUBLIC_COMPANY_NAME="Cal.com, Inc."
# NEXT_PUBLIC_DISABLE_SIGNUP=true # NEXT_PUBLIC_DISABLE_SIGNUP=true
NEXT_PUBLIC_DISABLE_SIGNUP= NEXT_PUBLIC_DISABLE_SIGNUP=
# Set this to 'non-strict' to enable CSP for support pages. 'strict' isn't supported yet. Also, check the README for details.
# Content Security Policy # Content Security Policy
CSP_POLICY= CSP_POLICY=
@@ -296,7 +295,7 @@ E2E_TEST_CALCOM_GCAL_KEYS=
# You can use: `openssl rand -base64 32` to generate one # You can use: `openssl rand -base64 32` to generate one
CALCOM_CREDENTIAL_SYNC_SECRET="" CALCOM_CREDENTIAL_SYNC_SECRET=""
# This is the header name that will be used to verify the webhook secret. Should be in lowercase # This is the header name that will be used to verify the webhook secret. Should be in lowercase
CALCOM_CREDENTIAL_SYNC_SECRET_HEADER_NAME="calcom-webhook-secret" CALCOM_CREDENTIAL_SYNC_HEADER_NAME="calcom-credential-sync-secret"
CALCOM_CREDENTIAL_SYNC_ENDPOINT="" CALCOM_CREDENTIAL_SYNC_ENDPOINT=""
# Key should match on Cal.com and your application # Key should match on Cal.com and your application
# must be 24 bytes for AES256 encryption algorithm # must be 24 bytes for AES256 encryption algorithm
@@ -341,3 +340,9 @@ APP_ROUTER_TEAMS_ENABLED=0
# disable setry server source maps # disable setry server source maps
SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN=1 SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN=1
# api v2
NEXT_PUBLIC_API_V2_URL="http://localhost:5555/api/v2"
# Ratelimiting via unkey
UNKEY_ROOT_KEY=
+1 -1
View File
@@ -13,7 +13,7 @@ Fixes # (issue)
<!-- Please provide all documents that are important to understand the reason of that PR. --> <!-- Please provide all documents that are important to understand the reason of that PR. -->
- If there is a requirement document, please, share it here. - If there is a requirement document, please, share it here.
- If there is ab UI/UX design document, please, share it here. - If there is a UI/UX design document, please, share it here.
## Type of change ## Type of change
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: buildjet-4vcpu-ubuntu-2204 runs-on: buildjet-4vcpu-ubuntu-2204
services: services:
postgres: postgres:
image: postgres:12.1 image: postgres:13.13
credentials: credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: buildjet-4vcpu-ubuntu-2204 runs-on: buildjet-4vcpu-ubuntu-2204
services: services:
postgres: postgres:
image: postgres:12.1 image: postgres:13.13
credentials: credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: buildjet-4vcpu-ubuntu-2204 runs-on: buildjet-4vcpu-ubuntu-2204
services: services:
postgres: postgres:
image: postgres:12.1 image: postgres:13.13
credentials: credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: buildjet-4vcpu-ubuntu-2204 runs-on: buildjet-4vcpu-ubuntu-2204
services: services:
postgres: postgres:
image: postgres:12.1 image: postgres:13.13
credentials: credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -29,6 +29,7 @@ env:
SENDGRID_EMAIL: ${{ secrets.CI_SENDGRID_EMAIL }} SENDGRID_EMAIL: ${{ secrets.CI_SENDGRID_EMAIL }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NEXT_PUBLIC_API_V2_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_URL }}
jobs: jobs:
build: build:
+2 -1
View File
@@ -33,6 +33,7 @@ env:
SENDGRID_EMAIL: ${{ secrets.CI_SENDGRID_EMAIL }} SENDGRID_EMAIL: ${{ secrets.CI_SENDGRID_EMAIL }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NEXT_PUBLIC_API_V2_URL: ${{ secrets.CI_NEXT_PUBLIC_API_V2_URL }}
jobs: jobs:
build: build:
@@ -41,7 +42,7 @@ jobs:
timeout-minutes: 30 timeout-minutes: 30
services: services:
postgres: postgres:
image: postgres:12.1 image: postgres:13.13
credentials: credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
+1
View File
@@ -16,3 +16,4 @@ public
packages/prisma/zod packages/prisma/zod
packages/prisma/enums packages/prisma/enums
apps/web/public/embed apps/web/public/embed
apps/api/v2/swagger/documentation.json
+2 -1
View File
@@ -2,7 +2,8 @@ Copyright (c) 2020-present Cal.com, Inc.
Portions of this software are licensed as follows: Portions of this software are licensed as follows:
* All content that resides under https://github.com/calcom/cal.com/tree/main/packages/features/ee and https://github.com/calcom/cal.com/tree/main/apps/api/ directory of this repository (Commercial License) is licensed under the license defined in "ee/LICENSE". * All content that resides under https://github.com/calcom/cal.com/tree/main/packages/features/ee and
https://github.com/calcom/cal.com/tree/main/apps/api/v2/src/ee directory of this repository (Commercial License) is licensed under the license defined in "ee/LICENSE".
* All third party components incorporated into the Cal.com Software are licensed under the original license provided by the owner of the applicable component. * All third party components incorporated into the Cal.com Software are licensed under the original license provided by the owner of the applicable component.
* Content outside of the above mentioned directories or restrictions above is available under the "AGPLv3" license as defined below. * Content outside of the above mentioned directories or restrictions above is available under the "AGPLv3" license as defined below.
+18
View File
@@ -0,0 +1,18 @@
const http = require("http");
const connect = require("connect");
const { createProxyMiddleware } = require("http-proxy-middleware");
const apiProxyV1 = createProxyMiddleware({
target: "http://localhost:3003",
});
const apiProxyV2 = createProxyMiddleware({
target: "http://localhost:3004",
});
const app = connect();
app.use("/", apiProxyV1);
app.use("/v2", apiProxyV2);
http.createServer(app).listen(3002);
-43
View File
@@ -1,43 +0,0 @@
import type { NextMiddleware } from "next-api-middleware";
import { CONSOLE_URL } from "@calcom/lib/constants";
import { customPrisma } from "@calcom/prisma";
const LOCAL_CONSOLE_URL = process.env.NEXT_PUBLIC_CONSOLE_URL || CONSOLE_URL;
// This replaces the prisma client for the custom one if the key is valid
export const customPrismaClient: NextMiddleware = async (req, res, next) => {
const {
query: { key },
} = req;
// If no custom api Id is provided, attach to request the regular cal.com prisma client.
if (!key) {
req.prisma = customPrisma();
await next();
return;
}
// If we have a key, we check if the deployment matching the key, has a databaseUrl value set.
const databaseUrl = await fetch(`${LOCAL_CONSOLE_URL}/api/deployments/database?key=${key}`)
.then((res) => res.json())
.then((res) => res.databaseUrl);
if (!databaseUrl) {
res.status(400).json({ error: "no databaseUrl set up at your instance yet" });
return;
}
req.prisma = customPrisma({ datasources: { db: { url: databaseUrl } } });
/* @note:
In order to skip verifyApiKey for customPrisma requests,
we pass isAdmin true, and userId 0, if we detect them later,
we skip verifyApiKey logic and pass onto next middleware instead.
*/
req.isAdmin = true;
req.isCustomPrisma = true;
// We don't need the key from here and on. Prevents unrecognized key errors.
delete req.query.key;
await next();
await req.prisma.$disconnect();
// @ts-expect-error testing
delete req.prisma;
};
+9 -39
View File
@@ -1,46 +1,16 @@
{ {
"name": "@calcom/api", "name": "@calcom/api-proxy",
"version": "1.0.0", "version": "1.0.0",
"description": "Public API for Cal.com", "description": "",
"main": "index.ts", "main": "index.js",
"repository": "git@github.com:calcom/api.git",
"author": "Cal.com Inc.",
"private": true,
"scripts": { "scripts": {
"build": "next build", "dev": "node ./index.js"
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
"dev": "PORT=3002 next dev",
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix",
"start": "PORT=3002 next start",
"docker-start-api": "PORT=80 next start",
"type-check": "tsc --pretty --noEmit"
},
"devDependencies": {
"@calcom/tsconfig": "*",
"@calcom/types": "*",
"node-mocks-http": "^1.11.0"
}, },
"author": "",
"license": "ISC",
"dependencies": { "dependencies": {
"@calcom/app-store": "*", "connect": "^3.7.0",
"@calcom/core": "*", "http": "^0.0.1-security",
"@calcom/dayjs": "*", "http-proxy-middleware": "^2.0.6"
"@calcom/emails": "*",
"@calcom/features": "*",
"@calcom/lib": "*",
"@calcom/prisma": "*",
"@calcom/trpc": "*",
"@sentry/nextjs": "^7.73.0",
"bcryptjs": "^2.4.3",
"memory-cache": "^0.2.0",
"next": "^13.5.4",
"next-api-middleware": "^1.0.1",
"next-axiom": "^0.17.0",
"next-swagger-doc": "^0.3.6",
"next-validations": "^0.2.0",
"typescript": "^4.9.4",
"tzdata": "^1.0.30",
"uuid": "^8.3.2",
"zod": "^3.22.4"
} }
} }
@@ -1,17 +0,0 @@
import { describe, vi, it, expect, afterEach } from "vitest";
import { middlewareOrder } from "../../../lib/helpers/withMiddleware";
afterEach(() => {
vi.resetAllMocks();
});
// Not sure if there is much point testing this order is actually applied via an integration test:
// It is tested internally https://github.com/htunnicliff/next-api-middleware/blob/368b12aa30e79f4bd7cfe7aacc18da263cc3de2f/lib/label.spec.ts#L62
describe("API - withMiddleware test", () => {
it("Custom prisma should be before verifyApiKey", async () => {
const customPrismaClientIndex = middlewareOrder.indexOf("customPrismaClient");
const verifyApiKeyIndex = middlewareOrder.indexOf("verifyApiKey");
expect(customPrismaClientIndex).toBeLessThan(verifyApiKeyIndex);
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,6 +3,7 @@ import type { NextMiddleware } from "next-api-middleware";
import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys"; import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
import checkLicense from "@calcom/features/ee/common/server/checkLicense"; import checkLicense from "@calcom/features/ee/common/server/checkLicense";
import { IS_PRODUCTION } from "@calcom/lib/constants"; import { IS_PRODUCTION } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import { isAdminGuard } from "../utils/isAdmin"; import { isAdminGuard } from "../utils/isAdmin";
@@ -16,15 +17,9 @@ export const dateNotInPast = function (date: Date) {
// This verifies the apiKey and sets the user if it is valid. // This verifies the apiKey and sets the user if it is valid.
export const verifyApiKey: NextMiddleware = async (req, res, next) => { export const verifyApiKey: NextMiddleware = async (req, res, next) => {
const { prisma, isCustomPrisma, isAdmin } = req;
const hasValidLicense = await checkLicense(prisma); const hasValidLicense = await checkLicense(prisma);
if (!hasValidLicense && IS_PRODUCTION) if (!hasValidLicense && IS_PRODUCTION)
return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" }); return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
// If the user is an admin and using a license key (from customPrisma), skip the apiKey check.
if (isCustomPrisma && isAdmin) {
await next();
return;
}
// Check if the apiKey query param is provided. // Check if the apiKey query param is provided.
if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" }); if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" });
// remove the prefix from the user provided api_key. If no env set default to "cal_" // remove the prefix from the user provided api_key. If no env set default to "cal_"
@@ -43,6 +38,5 @@ export const verifyApiKey: NextMiddleware = async (req, res, next) => {
req.userId = apiKey.userId; req.userId = apiKey.userId;
// save the isAdmin boolean here for later use // save the isAdmin boolean here for later use
req.isAdmin = await isAdminGuard(req); req.isAdmin = await isAdminGuard(req);
req.isCustomPrisma = false;
await next(); await next();
}; };
@@ -0,0 +1,24 @@
import type { NextMiddleware } from "next-api-middleware";
import { APP_CREDENTIAL_SHARING_ENABLED } from "@calcom/lib/constants";
export const verifyCredentialSyncEnabled: NextMiddleware = async (req, res, next) => {
const { isAdmin } = req;
if (!isAdmin) {
return res.status(403).json({ error: "Only admin API keys can access credential syncing endpoints" });
}
if (!APP_CREDENTIAL_SHARING_ENABLED) {
return res.status(501).json({ error: "Credential syncing is not enabled" });
}
if (
req.headers[process.env.CALCOM_CREDENTIAL_SYNC_HEADER_NAME || "calcom-credential-sync-secret"] !==
process.env.CALCOM_CREDENTIAL_SYNC_SECRET
) {
return res.status(401).json({ message: "Invalid credential sync secret" });
}
await next();
};
@@ -2,7 +2,6 @@ import { label } from "next-api-middleware";
import { addRequestId } from "./addRequestid"; import { addRequestId } from "./addRequestid";
import { captureErrors } from "./captureErrors"; import { captureErrors } from "./captureErrors";
import { customPrismaClient } from "./customPrisma";
import { extendRequest } from "./extendRequest"; import { extendRequest } from "./extendRequest";
import { import {
HTTP_POST, HTTP_POST,
@@ -14,6 +13,7 @@ import {
} from "./httpMethods"; } from "./httpMethods";
import { rateLimitApiKey } from "./rateLimitApiKey"; import { rateLimitApiKey } from "./rateLimitApiKey";
import { verifyApiKey } from "./verifyApiKey"; import { verifyApiKey } from "./verifyApiKey";
import { verifyCredentialSyncEnabled } from "./verifyCredentialSyncEnabled";
import { withPagination } from "./withPagination"; import { withPagination } from "./withPagination";
const middleware = { const middleware = {
@@ -26,25 +26,22 @@ const middleware = {
addRequestId, addRequestId,
verifyApiKey, verifyApiKey,
rateLimitApiKey, rateLimitApiKey,
customPrismaClient,
extendRequest, extendRequest,
pagination: withPagination, pagination: withPagination,
captureErrors, captureErrors,
verifyCredentialSyncEnabled,
}; };
type Middleware = keyof typeof middleware; type Middleware = keyof typeof middleware;
const middlewareOrder = const middlewareOrder = [
// The order here, determines the order of execution // The order here, determines the order of execution
[ "extendRequest",
"extendRequest", "captureErrors",
"captureErrors", "verifyApiKey",
// - Put customPrismaClient before verifyApiKey always. "rateLimitApiKey",
"customPrismaClient", "addRequestId",
"verifyApiKey", ] as Middleware[]; // <-- Provide a list of middleware to call automatically
"rateLimitApiKey",
"addRequestId",
] as Middleware[]; // <-- Provide a list of middleware to call automatically
const withMiddleware = label(middleware, middlewareOrder); const withMiddleware = label(middleware, middlewareOrder);
File renamed without changes.
@@ -1,9 +1,10 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import prisma from "@calcom/prisma";
import { UserPermissionRole } from "@calcom/prisma/enums"; import { UserPermissionRole } from "@calcom/prisma/enums";
export const isAdminGuard = async (req: NextApiRequest) => { export const isAdminGuard = async (req: NextApiRequest) => {
const { userId, prisma } = req; const { userId } = req;
const user = await prisma.user.findUnique({ where: { id: userId } }); const user = await prisma.user.findUnique({ where: { id: userId } });
return user?.role === UserPermissionRole.ADMIN; return user?.role === UserPermissionRole.ADMIN;
}; };
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,18 @@
import { z } from "zod";
const CalendarSchema = z.object({
externalId: z.string(),
name: z.string(),
primary: z.boolean(),
readOnly: z.boolean(),
});
const IntegrationSchema = z.object({
name: z.string(),
appId: z.string(),
userId: z.number(),
integration: z.string(),
calendars: z.array(CalendarSchema),
});
export const schemaConnectedCalendarsReadPublic = z.array(IntegrationSchema);
@@ -0,0 +1,64 @@
import { z } from "zod";
import { HttpError } from "@calcom/lib/http-error";
const userId = z.string().transform((val) => {
const userIdInt = parseInt(val);
if (isNaN(userIdInt)) {
throw new HttpError({ message: "userId is not a valid number", statusCode: 400 });
}
return userIdInt;
});
const appSlug = z.string();
const credentialId = z.string().transform((val) => {
const credentialIdInt = parseInt(val);
if (isNaN(credentialIdInt)) {
throw new HttpError({ message: "credentialId is not a valid number", statusCode: 400 });
}
return credentialIdInt;
});
const encryptedKey = z.string();
export const schemaCredentialGetParams = z.object({
userId,
appSlug: appSlug.optional(),
});
export const schemaCredentialPostParams = z.object({
userId,
createSelectedCalendar: z
.string()
.optional()
.transform((val) => {
return val === "true";
}),
createDestinationCalendar: z
.string()
.optional()
.transform((val) => {
return val === "true";
}),
});
export const schemaCredentialPostBody = z.object({
appSlug,
encryptedKey,
});
export const schemaCredentialPatchParams = z.object({
userId,
credentialId,
});
export const schemaCredentialPatchBody = z.object({
encryptedKey,
});
export const schemaCredentialDeleteParams = z.object({
userId,
credentialId,
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,7 @@ const i18nConfig = require("@calcom/config/next-i18next.config");
/** @type {import("next-i18next").UserConfig} */ /** @type {import("next-i18next").UserConfig} */
const config = { const config = {
...i18nConfig, ...i18nConfig,
localePath: path.resolve("../web/public/static/locales"), localePath: path.resolve("../../web/public/static/locales"),
}; };
module.exports = config; module.exports = config;
File renamed without changes.
-4
View File
@@ -1,8 +1,6 @@
import type { Session } from "next-auth"; import type { Session } from "next-auth";
import type { NextApiRequest as BaseNextApiRequest } from "next/types"; import type { NextApiRequest as BaseNextApiRequest } from "next/types";
import type { PrismaClient } from "@calcom/prisma";
export type * from "next/types"; export type * from "next/types";
export declare module "next" { export declare module "next" {
@@ -11,11 +9,9 @@ export declare module "next" {
userId: number; userId: number;
method: string; method: string;
prisma: PrismaClient;
// session: { user: { id: number } }; // session: { user: { id: number } };
// query: Partial<{ [key: string]: string | string[] }>; // query: Partial<{ [key: string]: string | string[] }>;
isAdmin: boolean; isAdmin: boolean;
isCustomPrisma: boolean;
pagination: { take: number; skip: number }; pagination: { take: number; skip: number };
} }
} }
+46
View File
@@ -0,0 +1,46 @@
{
"name": "@calcom/api",
"version": "1.0.0",
"description": "Public API for Cal.com",
"main": "index.ts",
"repository": "git@github.com:calcom/api.git",
"author": "Cal.com Inc.",
"private": true,
"scripts": {
"build": "next build",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
"dev": "PORT=3003 next dev",
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix",
"start": "PORT=3003 next start",
"docker-start-api": "PORT=80 next start",
"type-check": "tsc --pretty --noEmit"
},
"devDependencies": {
"@calcom/tsconfig": "*",
"@calcom/types": "*",
"node-mocks-http": "^1.11.0"
},
"dependencies": {
"@calcom/app-store": "*",
"@calcom/core": "*",
"@calcom/dayjs": "*",
"@calcom/emails": "*",
"@calcom/features": "*",
"@calcom/lib": "*",
"@calcom/prisma": "*",
"@calcom/trpc": "*",
"@sentry/nextjs": "^7.73.0",
"bcryptjs": "^2.4.3",
"memory-cache": "^0.2.0",
"next": "^13.5.4",
"next-api-middleware": "^1.0.1",
"next-axiom": "^0.17.0",
"next-swagger-doc": "^0.3.6",
"next-validations": "^0.2.0",
"typescript": "^4.9.4",
"tzdata": "^1.0.30",
"uuid": "^8.3.2",
"zod": "^3.22.4"
}
}
@@ -1,11 +1,12 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import prisma from "@calcom/prisma";
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString"; import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
export async function authMiddleware(req: NextApiRequest) { export async function authMiddleware(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const { id } = schemaQueryIdAsString.parse(req.query); const { id } = schemaQueryIdAsString.parse(req.query);
// Admin can check any api key // Admin can check any api key
if (isAdmin) return; if (isAdmin) return;
@@ -1,11 +1,12 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString"; import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
async function deleteHandler(req: NextApiRequest) { async function deleteHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdAsString.parse(query); const { id } = schemaQueryIdAsString.parse(query);
await prisma.apiKey.delete({ where: { id } }); await prisma.apiKey.delete({ where: { id } });
return { message: `ApiKey with id: ${id} deleted` }; return { message: `ApiKey with id: ${id} deleted` };
@@ -1,12 +1,13 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { apiKeyPublicSchema } from "~/lib/validations/api-key"; import { apiKeyPublicSchema } from "~/lib/validations/api-key";
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString"; import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
async function getHandler(req: NextApiRequest) { async function getHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdAsString.parse(query); const { id } = schemaQueryIdAsString.parse(query);
const api_key = await prisma.apiKey.findUniqueOrThrow({ where: { id } }); const api_key = await prisma.apiKey.findUniqueOrThrow({ where: { id } });
return { api_key: apiKeyPublicSchema.parse(api_key) }; return { api_key: apiKeyPublicSchema.parse(api_key) };
@@ -1,12 +1,13 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { apiKeyEditBodySchema, apiKeyPublicSchema } from "~/lib/validations/api-key"; import { apiKeyEditBodySchema, apiKeyPublicSchema } from "~/lib/validations/api-key";
import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString"; import { schemaQueryIdAsString } from "~/lib/validations/shared/queryIdString";
async function patchHandler(req: NextApiRequest) { async function patchHandler(req: NextApiRequest) {
const { prisma, body } = req; const { body } = req;
const { id } = schemaQueryIdAsString.parse(req.query); const { id } = schemaQueryIdAsString.parse(req.query);
const data = apiKeyEditBodySchema.parse(body); const data = apiKeyEditBodySchema.parse(body);
const api_key = await prisma.apiKey.update({ where: { id }, data }); const api_key = await prisma.apiKey.update({ where: { id }, data });
@@ -2,6 +2,7 @@ import type { Prisma } from "@prisma/client";
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import type { Ensure } from "@calcom/types/utils"; import type { Ensure } from "@calcom/types/utils";
import { apiKeyPublicSchema } from "~/lib/validations/api-key"; import { apiKeyPublicSchema } from "~/lib/validations/api-key";
@@ -29,7 +30,7 @@ function hasReqArgs(req: CustomNextApiRequest): req is Ensure<CustomNextApiReque
} }
async function getHandler(req: CustomNextApiRequest) { async function getHandler(req: CustomNextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
req.args = isAdmin ? {} : { where: { userId } }; req.args = isAdmin ? {} : { where: { userId } };
// Proof of concept: allowing mutation in exchange of composability // Proof of concept: allowing mutation in exchange of composability
handleAdminRequests(req); handleAdminRequests(req);
@@ -5,11 +5,12 @@ import { v4 } from "uuid";
import { generateUniqueAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys"; import { generateUniqueAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { apiKeyCreateBodySchema, apiKeyPublicSchema } from "~/lib/validations/api-key"; import { apiKeyCreateBodySchema, apiKeyPublicSchema } from "~/lib/validations/api-key";
async function postHandler(req: NextApiRequest) { async function postHandler(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const { neverExpires, userId: bodyUserId, ...input } = apiKeyCreateBodySchema.parse(req.body); const { neverExpires, userId: bodyUserId, ...input } = apiKeyCreateBodySchema.parse(req.body);
const [hashedKey, apiKey] = generateUniqueAPIKey(); const [hashedKey, apiKey] = generateUniqueAPIKey();
const args: Prisma.ApiKeyCreateArgs = { const args: Prisma.ApiKeyCreateArgs = {
File renamed without changes.
@@ -1,11 +1,12 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
async function authMiddleware(req: NextApiRequest) { async function authMiddleware(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const query = schemaQueryIdParseInt.parse(req.query); const query = schemaQueryIdParseInt.parse(req.query);
// @note: Here we make sure to only return attendee's of the user's own bookings if the user is not an admin. // @note: Here we make sure to only return attendee's of the user's own bookings if the user is not an admin.
if (isAdmin) return; if (isAdmin) return;
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -34,7 +35,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function deleteHandler(req: NextApiRequest) { export async function deleteHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
await prisma.attendee.delete({ where: { id } }); await prisma.attendee.delete({ where: { id } });
return { message: `Attendee with id: ${id} deleted successfully` }; return { message: `Attendee with id: ${id} deleted successfully` };
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaAttendeeReadPublic } from "~/lib/validations/attendee"; import { schemaAttendeeReadPublic } from "~/lib/validations/attendee";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -35,7 +36,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Attendee was not found * description: Attendee was not found
*/ */
export async function getHandler(req: NextApiRequest) { export async function getHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const attendee = await prisma.attendee.findUnique({ where: { id } }); const attendee = await prisma.attendee.findUnique({ where: { id } });
return { attendee: schemaAttendeeReadPublic.parse(attendee) }; return { attendee: schemaAttendeeReadPublic.parse(attendee) };
@@ -3,6 +3,7 @@ import type { z } from "zod";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaAttendeeEditBodyParams, schemaAttendeeReadPublic } from "~/lib/validations/attendee"; import { schemaAttendeeEditBodyParams, schemaAttendeeReadPublic } from "~/lib/validations/attendee";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -53,7 +54,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
*/ */
export async function patchHandler(req: NextApiRequest) { export async function patchHandler(req: NextApiRequest) {
const { prisma, query, body } = req; const { query, body } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const data = schemaAttendeeEditBodyParams.parse(body); const data = schemaAttendeeEditBodyParams.parse(body);
await checkPermissions(req, data); await checkPermissions(req, data);
@@ -62,7 +63,7 @@ export async function patchHandler(req: NextApiRequest) {
} }
async function checkPermissions(req: NextApiRequest, body: z.infer<typeof schemaAttendeeEditBodyParams>) { async function checkPermissions(req: NextApiRequest, body: z.infer<typeof schemaAttendeeEditBodyParams>) {
const { isAdmin, prisma } = req; const { isAdmin } = req;
if (isAdmin) return; if (isAdmin) return;
const { userId } = req; const { userId } = req;
const { bookingId } = body; const { bookingId } = body;
@@ -3,6 +3,7 @@ import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaAttendeeReadPublic } from "~/lib/validations/attendee"; import { schemaAttendeeReadPublic } from "~/lib/validations/attendee";
@@ -30,7 +31,7 @@ import { schemaAttendeeReadPublic } from "~/lib/validations/attendee";
* description: No attendees were found * description: No attendees were found
*/ */
async function handler(req: NextApiRequest) { async function handler(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const args: Prisma.AttendeeFindManyArgs = isAdmin ? {} : { where: { booking: { userId } } }; const args: Prisma.AttendeeFindManyArgs = isAdmin ? {} : { where: { booking: { userId } } };
const data = await prisma.attendee.findMany(args); const data = await prisma.attendee.findMany(args);
const attendees = data.map((attendee) => schemaAttendeeReadPublic.parse(attendee)); const attendees = data.map((attendee) => schemaAttendeeReadPublic.parse(attendee));
@@ -2,6 +2,7 @@ import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaAttendeeCreateBodyParams, schemaAttendeeReadPublic } from "~/lib/validations/attendee"; import { schemaAttendeeCreateBodyParams, schemaAttendeeReadPublic } from "~/lib/validations/attendee";
@@ -51,7 +52,7 @@ import { schemaAttendeeCreateBodyParams, schemaAttendeeReadPublic } from "~/lib/
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
async function postHandler(req: NextApiRequest) { async function postHandler(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const body = schemaAttendeeCreateBodyParams.parse(req.body); const body = schemaAttendeeCreateBodyParams.parse(req.body);
if (!isAdmin) { if (!isAdmin) {
@@ -1,9 +1,11 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
async function authMiddleware(req: NextApiRequest) { async function authMiddleware(req: NextApiRequest) {
const { userId, prisma, isAdmin, query } = req; const { userId, isAdmin, query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
/** Admins can skip the ownership verification */ /** Admins can skip the ownership verification */
if (isAdmin) return; if (isAdmin) return;
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -36,7 +37,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function deleteHandler(req: NextApiRequest) { export async function deleteHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
await prisma.availability.delete({ where: { id } }); await prisma.availability.delete({ where: { id } });
return { message: `Availability with id: ${id} deleted successfully` }; return { message: `Availability with id: ${id} deleted successfully` };
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaAvailabilityReadPublic } from "~/lib/validations/availability"; import { schemaAvailabilityReadPublic } from "~/lib/validations/availability";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -37,7 +38,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Availability not found * description: Availability not found
*/ */
export async function getHandler(req: NextApiRequest) { export async function getHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const availability = await prisma.availability.findUnique({ const availability = await prisma.availability.findUnique({
where: { id }, where: { id },
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { import {
schemaAvailabilityEditBodyParams, schemaAvailabilityEditBodyParams,
@@ -72,7 +73,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function patchHandler(req: NextApiRequest) { export async function patchHandler(req: NextApiRequest) {
const { prisma, query, body } = req; const { query, body } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const data = schemaAvailabilityEditBodyParams.parse(body); const data = schemaAvailabilityEditBodyParams.parse(body);
const availability = await prisma.availability.update({ const availability = await prisma.availability.update({
@@ -2,6 +2,7 @@ import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { import {
schemaAvailabilityCreateBodyParams, schemaAvailabilityCreateBodyParams,
@@ -71,7 +72,6 @@ import {
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
async function postHandler(req: NextApiRequest) { async function postHandler(req: NextApiRequest) {
const { prisma } = req;
const data = schemaAvailabilityCreateBodyParams.parse(req.body); const data = schemaAvailabilityCreateBodyParams.parse(req.body);
await checkPermissions(req); await checkPermissions(req);
const availability = await prisma.availability.create({ const availability = await prisma.availability.create({
@@ -86,7 +86,7 @@ async function postHandler(req: NextApiRequest) {
} }
async function checkPermissions(req: NextApiRequest) { async function checkPermissions(req: NextApiRequest) {
const { userId, prisma, isAdmin } = req; const { userId, isAdmin } = req;
if (isAdmin) return; if (isAdmin) return;
const data = schemaAvailabilityCreateBodyParams.parse(req.body); const data = schemaAvailabilityCreateBodyParams.parse(req.body);
const schedule = await prisma.schedule.findFirst({ const schedule = await prisma.schedule.findFirst({
@@ -4,6 +4,7 @@ import { z } from "zod";
import { getUserAvailability } from "@calcom/core/getUserAvailability"; import { getUserAvailability } from "@calcom/core/getUserAvailability";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { availabilityUserSelect } from "@calcom/prisma"; import { availabilityUserSelect } from "@calcom/prisma";
import { MembershipRole } from "@calcom/prisma/enums"; import { MembershipRole } from "@calcom/prisma/enums";
import { stringOrNumber } from "@calcom/prisma/zod-utils"; import { stringOrNumber } from "@calcom/prisma/zod-utils";
@@ -188,7 +189,7 @@ const availabilitySchema = z
); );
async function handler(req: NextApiRequest) { async function handler(req: NextApiRequest) {
const { prisma, isAdmin, userId: reqUserId } = req; const { isAdmin, userId: reqUserId } = req;
const { username, userId, eventTypeId, dateTo, dateFrom, teamId } = availabilitySchema.parse(req.query); const { username, userId, eventTypeId, dateTo, dateFrom, teamId } = availabilitySchema.parse(req.query);
if (!teamId) if (!teamId)
return getUserAvailability({ return getUserAvailability({
@@ -1,11 +1,12 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { HttpError } from "@calcom/lib/http-error"; import { HttpError } from "@calcom/lib/http-error";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
async function authMiddleware(req: NextApiRequest) { async function authMiddleware(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const { id } = schemaQueryIdParseInt.parse(req.query); const { id } = schemaQueryIdParseInt.parse(req.query);
// Here we make sure to only return references of the user's own bookings if the user is not an admin. // Here we make sure to only return references of the user's own bookings if the user is not an admin.
if (isAdmin) return; if (isAdmin) return;
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -34,7 +35,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function deleteHandler(req: NextApiRequest) { export async function deleteHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
await prisma.bookingReference.delete({ where: { id } }); await prisma.bookingReference.delete({ where: { id } });
return { message: `BookingReference with id: ${id} deleted` }; return { message: `BookingReference with id: ${id} deleted` };
@@ -1,6 +1,7 @@
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference"; import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference";
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt"; import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
@@ -35,7 +36,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: BookingReference was not found * description: BookingReference was not found
*/ */
export async function getHandler(req: NextApiRequest) { export async function getHandler(req: NextApiRequest) {
const { prisma, query } = req; const { query } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const booking_reference = await prisma.bookingReference.findUniqueOrThrow({ where: { id } }); const booking_reference = await prisma.bookingReference.findUniqueOrThrow({ where: { id } });
return { booking_reference: schemaBookingReferenceReadPublic.parse(booking_reference) }; return { booking_reference: schemaBookingReferenceReadPublic.parse(booking_reference) };
@@ -2,6 +2,7 @@ import type { Prisma } from "@prisma/client";
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { import {
schemaBookingEditBodyParams, schemaBookingEditBodyParams,
@@ -59,7 +60,7 @@ import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransform
* description: Authorization information is missing or invalid. * description: Authorization information is missing or invalid.
*/ */
export async function patchHandler(req: NextApiRequest) { export async function patchHandler(req: NextApiRequest) {
const { prisma, query, body, isAdmin, userId } = req; const { query, body, isAdmin, userId } = req;
const { id } = schemaQueryIdParseInt.parse(query); const { id } = schemaQueryIdParseInt.parse(query);
const data = schemaBookingEditBodyParams.parse(body); const data = schemaBookingEditBodyParams.parse(body);
/* If user tries to update bookingId, we run extra checks */ /* If user tries to update bookingId, we run extra checks */
@@ -2,6 +2,7 @@ import type { Prisma } from "@prisma/client";
import type { NextApiRequest } from "next"; import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server"; import { defaultResponder } from "@calcom/lib/server";
import prisma from "@calcom/prisma";
import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference"; import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference";
@@ -29,7 +30,7 @@ import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-refe
* description: No booking references were found * description: No booking references were found
*/ */
async function getHandler(req: NextApiRequest) { async function getHandler(req: NextApiRequest) {
const { userId, isAdmin, prisma } = req; const { userId, isAdmin } = req;
const args: Prisma.BookingReferenceFindManyArgs = isAdmin ? {} : { where: { booking: { userId } } }; const args: Prisma.BookingReferenceFindManyArgs = isAdmin ? {} : { where: { booking: { userId } } };
const data = await prisma.bookingReference.findMany(args); const data = await prisma.bookingReference.findMany(args);
return { booking_references: data.map((br) => schemaBookingReferenceReadPublic.parse(br)) }; return { booking_references: data.map((br) => schemaBookingReferenceReadPublic.parse(br)) };
Loaded 100 of 833 files, more files were not shown because too many files have changed in this diff. Show more