From fe35cf65709363247c819c2c9f3c8d22d39862f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Tue, 15 Feb 2022 13:30:52 -0700 Subject: [PATCH] Extract prisma to it's own package (#1823) * Moved prisma to packages * Add missing prisma configs * Extracts common libs and types * Build and pipeline fixes * Adds missing package * Prisma scripts cleanup * Updates lint staged * Type fixes * Sort imports * Updates yarn lock file * Fixes for yarn dx * Revert "Sort imports" This reverts commit 076109decab9b9ba307fc03696c3b0da5c4896f3. * Formatting * Prevent double TS version * Fix conflict * Extracted e2e configs --- .env.example | 1 + .eslintignore | 2 +- .github/workflows/e2e.yml | 1 + .gitignore | 1 + .prettierignore | 2 +- .prettierrc.js | 2 +- README.md | 1 + apps/docs/README.md | 6 + apps/docs/pages/self-hosting/install.mdx | 82 ++++++----- apps/web/.env.example | 3 +- apps/web/@prisma/client.ts | 1 + .../components/eventtype/CreateEventType.tsx | 3 +- apps/web/lib/availability.ts | 127 +----------------- apps/web/lib/location.ts | 11 +- apps/web/next.config.js | 2 +- apps/web/package.json | 36 +---- apps/web/server/routers/viewer/eventTypes.tsx | 9 +- apps/web/tsconfig.json | 2 +- package.json | 4 + packages/lib/auth.ts | 11 ++ packages/lib/availability.ts | 126 +++++++++++++++++ packages/lib/location.ts | 10 ++ packages/lib/package.json | 16 +++ packages/lib/tsconfig.json | 5 + packages/prisma/.env.example | 2 + packages/prisma/client/index.d.ts | 1 + packages/prisma/client/runtime.d.ts | 1 + .../prisma}/docker-compose.yml | 0 packages/prisma/index.ts | 13 ++ .../20210605225044_init/migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../20210902121313_user_plan/migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../20211222174947_placeholder/migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../prisma/migrations/migration_lock.toml | 0 packages/prisma/package.json | 34 +++++ {apps/web => packages}/prisma/schema.prisma | 0 {apps/web => packages}/prisma/seed.ts | 4 +- {apps/web => packages}/prisma/zod-utils.ts | 2 +- {apps/web => packages}/prisma/zod/attendee.ts | 0 .../prisma/zod/availability.ts | 0 {apps/web => packages}/prisma/zod/booking.ts | 0 .../prisma/zod/bookingreference.ts | 0 .../web => packages}/prisma/zod/credential.ts | 0 .../prisma/zod/dailyeventreference.ts | 0 .../prisma/zod/destinationcalendar.ts | 0 .../web => packages}/prisma/zod/eventtype.ts | 0 .../prisma/zod/eventtypeCustom.ts | 2 +- .../prisma/zod/eventtypecustominput.ts | 0 {apps/web => packages}/prisma/zod/index.ts | 0 .../web => packages}/prisma/zod/membership.ts | 0 {apps/web => packages}/prisma/zod/payment.ts | 0 .../prisma/zod/remindermail.ts | 0 .../prisma/zod/resetpasswordrequest.ts | 0 {apps/web => packages}/prisma/zod/schedule.ts | 0 .../prisma/zod/selectedcalendar.ts | 0 {apps/web => packages}/prisma/zod/team.ts | 0 {apps/web => packages}/prisma/zod/user.ts | 0 .../prisma/zod/verificationrequest.ts | 0 {apps/web => packages}/prisma/zod/webhook.ts | 0 packages/types/package.json | 6 + packages/types/schedule.d.ts | 18 +++ .../lib => tests/config}/globalSetup.ts | 0 .../config/playwright.config.ts | 10 +- turbo.json | 13 +- yarn.lock | 2 +- 128 files changed, 349 insertions(+), 223 deletions(-) create mode 100644 apps/web/@prisma/client.ts create mode 100644 packages/lib/auth.ts create mode 100644 packages/lib/availability.ts create mode 100644 packages/lib/location.ts create mode 100644 packages/lib/package.json create mode 100644 packages/lib/tsconfig.json create mode 100644 packages/prisma/.env.example create mode 100644 packages/prisma/client/index.d.ts create mode 100644 packages/prisma/client/runtime.d.ts rename {apps/web => packages/prisma}/docker-compose.yml (100%) create mode 100644 packages/prisma/index.ts rename {apps/web => packages}/prisma/migrations/20210605225044_init/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210605225507_added_bookings/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210615140247_added_selected_calendar/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210615142134_added_custom_event_name/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210615153546_added_buffer_time/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210615153759_add_email_verification_column/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210618140954_added_event_type_custom/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210628153550_password_reset_request/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210629160507_hide_branding/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210630014738_schedule_availability/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210709231256_add_user_theme/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210714151216_event_type_period_settings/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210717120159_booking_confirmation/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210718184017_reminder_mails/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210722225431_minimum_booking_notice/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210725123357_add_location_to_booking/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210813142905_event_payment/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210813194355_add_slug_to_team/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210814175645_custom_inputs_type_enum/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210820130519_add_placeholder_to_custom_event_types/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210824054220_add_bio_branding_logo_to_team/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210825004801_schedule_schema/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210830064354_add_unique_to_team_slug/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210902112455_event_type_unique_user_id_slug/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210902121313_user_plan/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210902125945_user_username_unique/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210904162403_add_booking_status_enum/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210908042159_teams_feature/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210908220336_add_daily_data_table/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210908235519_undo_unique_user_id_slug/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210913211650_add_meeting_info/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210918013258_add_two_factor_fields/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210918152354_user_id_slug_fix/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210919174415_add_user_locale/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211004231654_add_webhook_model/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211011152041_non_optionals/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211028233838_add_user_webhooks_relation/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211105200545_availability_start_and_end_time_as_time/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211106121119_add_event_type_position/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211110063531_add_custom_brand_color/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211110142845_add_identity_provider_columns/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211111013358_period_type_enum/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211112145539_add_saml_login/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211115182559_availability_issue/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211120211639_add_payload_template/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211207010154_add_destination_calendar/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211209201138_membership_admin_role/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211210182230_add_invited_to/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211217201940_upgrade_to_v3/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211217215952_added_slot_interval_to_event_type/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211220192703_email_to_lowercase/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211222174947_placeholder/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211222181246_add_sc_address/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211228004752_adds_user_metadata/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20211231142312_add_user_on_delete_cascade/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220105104913_add_away_field/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220113145333_rename_column_sc_address_to_smart_contract_address/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220117193242_trial_users_by_default/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220121210720_add_cancellation_reason/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220125035907_add_attendee_locale/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220131170110_add_metadata_column_to_event_type/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220205135022_add_verified_column/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/20220209082843_add_rejection_reason/migration.sql (100%) rename {apps/web => packages}/prisma/migrations/migration_lock.toml (100%) create mode 100644 packages/prisma/package.json rename {apps/web => packages}/prisma/schema.prisma (100%) rename {apps/web => packages}/prisma/seed.ts (98%) rename {apps/web => packages}/prisma/zod-utils.ts (88%) rename {apps/web => packages}/prisma/zod/attendee.ts (100%) rename {apps/web => packages}/prisma/zod/availability.ts (100%) rename {apps/web => packages}/prisma/zod/booking.ts (100%) rename {apps/web => packages}/prisma/zod/bookingreference.ts (100%) rename {apps/web => packages}/prisma/zod/credential.ts (100%) rename {apps/web => packages}/prisma/zod/dailyeventreference.ts (100%) rename {apps/web => packages}/prisma/zod/destinationcalendar.ts (100%) rename {apps/web => packages}/prisma/zod/eventtype.ts (100%) rename {apps/web => packages}/prisma/zod/eventtypeCustom.ts (90%) rename {apps/web => packages}/prisma/zod/eventtypecustominput.ts (100%) rename {apps/web => packages}/prisma/zod/index.ts (100%) rename {apps/web => packages}/prisma/zod/membership.ts (100%) rename {apps/web => packages}/prisma/zod/payment.ts (100%) rename {apps/web => packages}/prisma/zod/remindermail.ts (100%) rename {apps/web => packages}/prisma/zod/resetpasswordrequest.ts (100%) rename {apps/web => packages}/prisma/zod/schedule.ts (100%) rename {apps/web => packages}/prisma/zod/selectedcalendar.ts (100%) rename {apps/web => packages}/prisma/zod/team.ts (100%) rename {apps/web => packages}/prisma/zod/user.ts (100%) rename {apps/web => packages}/prisma/zod/verificationrequest.ts (100%) rename {apps/web => packages}/prisma/zod/webhook.ts (100%) create mode 100644 packages/types/package.json create mode 100644 packages/types/schedule.d.ts rename {apps/web/playwright/lib => tests/config}/globalSetup.ts (100%) rename playwright.config.ts => tests/config/playwright.config.ts (86%) diff --git a/.env.example b/.env.example index 985d564f9..e97496b15 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ # It now lives at `apps/web/.env.example` +# DATABASE_URL got moved to `packages/prisma/.env.example` diff --git a/.eslintignore b/.eslintignore index 44c7b9df2..f68ab303b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,2 @@ node_modules -apps/web/prisma/zod +packages/prisma/zod diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bc48ffdbd..9a13c1bde 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -93,6 +93,7 @@ jobs: with: name: videos path: | + test-results playwright/screenshots playwright/videos playwright/results diff --git a/.gitignore b/.gitignore index 44d784ca1..ea33396e7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ node_modules # testing coverage +/test-results/ playwright/videos playwright/screenshots playwright/artifacts diff --git a/.prettierignore b/.prettierignore index c60e0d94e..8c05cece8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,4 +13,4 @@ public .prettierignore .DS_Store .eslintignore -apps/web/prisma/zod +packages/prisma/zod diff --git a/.prettierrc.js b/.prettierrc.js index 26ec750ba..b1047eaf1 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -7,7 +7,7 @@ module.exports = { semi: true, printWidth: 110, arrowParens: "always", - importOrder: ["^@ee/(.*)$", "^@lib/(.*)$", "^@components/(.*)$", "^@(server|trpc)/(.*)$", "^[./]"], + importOrder: ["^@(calcom|ee)/(.*)$", "^@lib/(.*)$", "^@components/(.*)$", "^@(server|trpc)/(.*)$", "^[./]"], importOrderSeparation: true, plugins: [require("./merged-prettier-plugin")], }; diff --git a/README.md b/README.md index 6740a342a..e5a846304 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Here is what you need to be able to run Cal. ```sh cp apps/web/.env.example apps/web/.env + cp packages/prisma/.env.example packages/prisma/.env ``` 1. Install packages with yarn diff --git a/apps/docs/README.md b/apps/docs/README.md index 7195e2cbe..a6ccc7272 100644 --- a/apps/docs/README.md +++ b/apps/docs/README.md @@ -13,22 +13,27 @@ The official product, support and developer documentation, containing information and guides about using the product as well as support for self-hosted installations. This documentation site runs on [Nextra](https://nextra.vercel.app), so you may refer to their documentation should you need information on anything that isn't covered here. ## Prerequisites + - Git - Node.js & npm - Yarn ## Installation + Firstly, clone the repository using Git: + ```console git clone https://github.com/calcom/docs.git ``` Now, you can install the dependencies with yarn: + ```console yarn install ``` ## Editing + To create, edit and delete documentation pages, you can simply create markdown (.mdx) files in the `pages/` folder. You can edit Markdown with any text editor, but VS Code and WebStorm have side-by-side previews so you can see your formatted content whilst writing markdown. You will also need to add it as an entry to the `meta.json` file found in whichever directory that the .mdx file is in. @@ -52,6 +57,7 @@ This command generates static content into the `build` directory and can be serv ## How to easily contribute ## Existing Page + 1. From the documentation's GitHub repository, head to the folder called 'pages' and open it. 2. From here you can view all current pages on the documentation site. Select the page you would like to contribute to. 3. You should now be able to view the page you have selected. Located at the top right of the page will be a pencil icon. Pressing this will bring you up an editor to edit and make changes. You can add formatting using the buttons at the top, which will automatically insert the relevant markdown content needed to style the text. diff --git a/apps/docs/pages/self-hosting/install.mdx b/apps/docs/pages/self-hosting/install.mdx index 3481b4f24..a692f73d7 100644 --- a/apps/docs/pages/self-hosting/install.mdx +++ b/apps/docs/pages/self-hosting/install.mdx @@ -23,13 +23,14 @@ Here is what you need to be able to run Cal. 1. Go to the project folder ```sh - cd calendso + cd cal.com ``` 1. Copy `.env.example` to `.env` ```sh - cp .env.example .env + cp apps/web/.env.example apps/web/.env + cp packages/prisma/.env.example packages/prisma/.env ``` 1. Install packages with yarn @@ -42,57 +43,72 @@ Here is what you need to be able to run Cal. > - **Requires Docker and Docker Compose to be installed** > - Will start a local Postgres instance with a few test users - the credentials will be logged in the console + ```sh yarn dx ``` ### Manual setup -1. Configure environment variables in the .env file. Replace ``, ``, ``, `` with their applicable values +1. Configure database in the `packages/prisma/.env` file. Replace ``, ``, ``, `` with their applicable values - ```text - DATABASE_URL='postgresql://:@:' - ``` + ```text + DATABASE_URL='postgresql://:@:' + ``` -
- If you don't know how to configure the DATABASE_URL, then follow the steps here to create a quick DB using Heroku +
- 1. Create a free account with [Heroku](https://www.heroku.com/). + + If you don't know how to configure the DATABASE_URL, then follow the steps here to create a quick DB + using Heroku + - 2. Create a new app. - Create an App + 1. Create a free account with [Heroku](https://www.heroku.com/). - 3. In your new app, go to `Overview` and next to `Installed add-ons`, click `Configure Add-ons`. We need this to set up our database. - ![image](https://user-images.githubusercontent.com/16905768/115323232-a53ba480-a17f-11eb-98db-58e2f8c52426.png) + 2. Create a new app. - 4. Once you clicked on `Configure Add-ons`, click on `Find more add-ons` and search for `postgres`. One of the options will be `Heroku Postgres` - click on that option. - ![image](https://user-images.githubusercontent.com/16905768/115323126-5beb5500-a17f-11eb-8030-7380310807a9.png) + Create an App - 5. Once the pop-up appears, click `Submit Order Form` - plan name should be `Hobby Dev - Free`. - Submit Order Form + 3. In your new app, go to `Overview` and next to `Installed add-ons`, click `Configure Add-ons`. We need this to set up our database. + ![image](https://user-images.githubusercontent.com/16905768/115323232-a53ba480-a17f-11eb-98db-58e2f8c52426.png) - 6. Once you completed the above steps, click on your newly created `Heroku Postgres` and go to its `Settings`. - ![image](https://user-images.githubusercontent.com/16905768/115323367-e92ea980-a17f-11eb-9ff4-dec95f2ec349.png) + 4. Once you clicked on `Configure Add-ons`, click on `Find more add-ons` and search for `postgres`. One of the options will be `Heroku Postgres` - click on that option. + ![image](https://user-images.githubusercontent.com/16905768/115323126-5beb5500-a17f-11eb-8030-7380310807a9.png) - 7. In `Settings`, copy your URI to your Cal.com .env file and replace the `postgresql://:@:` with it. - ![image](https://user-images.githubusercontent.com/16905768/115323556-4591c900-a180-11eb-9808-2f55d2aa3995.png) - ![image](https://user-images.githubusercontent.com/16905768/115323697-7a9e1b80-a180-11eb-9f08-a742b1037f90.png) + 5. Once the pop-up appears, click `Submit Order Form` - plan name should be `Hobby Dev - Free`. - 8. To view your DB, once you add new data in Prisma, you can use [Heroku Data Explorer](https://heroku-data-explorer.herokuapp.com/). -
+ Submit Order Form -1. Set a 32 character random string in your .env file for the `CALENDSO_ENCRYPTION_KEY` (You can use a command like `openssl rand -base64 24` to generate one). -1. Set up the database using the Prisma schema (found in `prisma/schema.prisma`) + 6. Once you completed the above steps, click on your newly created `Heroku Postgres` and go to its `Settings`. + ![image](https://user-images.githubusercontent.com/16905768/115323367-e92ea980-a17f-11eb-9ff4-dec95f2ec349.png) - ```sh - npx prisma migrate deploy - ``` + 7. In `Settings`, copy your URI to your Cal.com .env file and replace the `postgresql://:@:` with it. + ![image](https://user-images.githubusercontent.com/16905768/115323556-4591c900-a180-11eb-9808-2f55d2aa3995.png) + ![image](https://user-images.githubusercontent.com/16905768/115323697-7a9e1b80-a180-11eb-9f08-a742b1037f90.png) -1. Run (in development mode) + 8. To view your DB, once you add new data in Prisma, you can use [Heroku Data Explorer](https://heroku-data-explorer.herokuapp.com/). +
- ```sh - yarn dev --scope=@calcom/web - ``` +1. Set a 32 character random string in your `apps/web/.env` file for the `CALENDSO_ENCRYPTION_KEY` (You can use a command like `openssl rand -base64 24` to generate one). +1. Set up the database using the Prisma schema (found in `packages/prisma/schema.prisma`) + + ```sh + npx prisma migrate deploy + ``` + +1. Run (in development mode) + + ```sh + yarn dev --scope=@calcom/web + ``` ### Setting up your first user diff --git a/apps/web/.env.example b/apps/web/.env.example index fb02fe6f4..f3eccbfd2 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -7,8 +7,7 @@ # - Acquire a commercial license to remove these terms by visiting: cal.com/sales NEXT_PUBLIC_LICENSE_CONSENT='' -# DATABASE_URL='postgresql://:@:/' -DATABASE_URL="postgresql://postgres:@localhost:5450/calendso" +# ⚠️ ⚠️ ⚠️ DATABASE_URL got moved to `packages/prisma/.env.example` ⚠️ ⚠️ ⚠️ # Needed to enable Google Calendar integration and Login with Google # @see https://github.com/calendso/calendso#obtaining-the-google-api-credentials diff --git a/apps/web/@prisma/client.ts b/apps/web/@prisma/client.ts new file mode 100644 index 000000000..8391ec8eb --- /dev/null +++ b/apps/web/@prisma/client.ts @@ -0,0 +1 @@ +export * from "@calcom/prisma/client"; diff --git a/apps/web/components/eventtype/CreateEventType.tsx b/apps/web/components/eventtype/CreateEventType.tsx index e6a53c39e..30b137941 100644 --- a/apps/web/components/eventtype/CreateEventType.tsx +++ b/apps/web/components/eventtype/CreateEventType.tsx @@ -2,11 +2,12 @@ import { ChevronDownIcon, PlusIcon } from "@heroicons/react/solid"; import { zodResolver } from "@hookform/resolvers/zod/dist/zod"; import { SchedulingType } from "@prisma/client"; import { useRouter } from "next/router"; -import { createEventTypeInput } from "prisma/zod/eventtypeCustom"; import React, { useEffect } from "react"; import { useForm } from "react-hook-form"; import type { z } from "zod"; +import { createEventTypeInput } from "@calcom/prisma/zod/eventtypeCustom"; + import { HttpError } from "@lib/core/http/error"; import { useLocale } from "@lib/hooks/useLocale"; import { useToggleQuery } from "@lib/hooks/useToggleQuery"; diff --git a/apps/web/lib/availability.ts b/apps/web/lib/availability.ts index 6a8c67cae..68fe5cc72 100644 --- a/apps/web/lib/availability.ts +++ b/apps/web/lib/availability.ts @@ -1,126 +1 @@ -import { Availability } from "@prisma/client"; -import dayjs, { ConfigType } from "dayjs"; -import customParseFormat from "dayjs/plugin/customParseFormat"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; - -import { Schedule, TimeRange, WorkingHours } from "./types/schedule"; - -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(customParseFormat); -// sets the desired time in current date, needs to be current date for proper DST translation -export const defaultDayRange: TimeRange = { - start: new Date(new Date().setUTCHours(9, 0, 0, 0)), - end: new Date(new Date().setUTCHours(17, 0, 0, 0)), -}; - -export const DEFAULT_SCHEDULE: Schedule = [ - [], - [defaultDayRange], - [defaultDayRange], - [defaultDayRange], - [defaultDayRange], - [defaultDayRange], - [], -]; - -export function getAvailabilityFromSchedule(schedule: Schedule): Availability[] { - return schedule.reduce((availability: Availability[], times: TimeRange[], day: number) => { - const addNewTime = (time: TimeRange) => - ({ - days: [day], - startTime: time.start, - endTime: time.end, - } as Availability); - - const filteredTimes = times.filter((time) => { - let idx; - if ( - (idx = availability.findIndex( - (schedule) => schedule.startTime === time.start && schedule.endTime === time.end - )) !== -1 - ) { - availability[idx].days.push(day); - return false; - } - return true; - }); - filteredTimes.forEach((time) => { - availability.push(addNewTime(time)); - }); - return availability; - }, [] as Availability[]); -} - -export const MINUTES_IN_DAY = 60 * 24; -export const MINUTES_DAY_END = MINUTES_IN_DAY - 1; -export const MINUTES_DAY_START = 0; - -/** - * Allows "casting" availability (days, startTime, endTime) given in UTC to a timeZone or utcOffset - */ -export function getWorkingHours( - relativeTimeUnit: { - timeZone?: string; - utcOffset?: number; - }, - availability: { days: number[]; startTime: ConfigType; endTime: ConfigType }[] -) { - // clearly bail when availability is not set, set everything available. - if (!availability.length) { - return [ - { - days: [0, 1, 2, 3, 4, 5, 6], - // shorthand for: dayjs().startOf("day").tz(timeZone).diff(dayjs.utc().startOf("day"), "minutes") - startTime: MINUTES_DAY_START, - endTime: MINUTES_DAY_END, - }, - ]; - } - - const utcOffset = relativeTimeUnit.utcOffset ?? dayjs().tz(relativeTimeUnit.timeZone).utcOffset(); - - const workingHours = availability.reduce((workingHours: WorkingHours[], schedule) => { - // Get times localised to the given utcOffset/timeZone - const startTime = - dayjs.utc(schedule.startTime).get("hour") * 60 + - dayjs.utc(schedule.startTime).get("minute") - - utcOffset; - const endTime = - dayjs.utc(schedule.endTime).get("hour") * 60 + dayjs.utc(schedule.endTime).get("minute") - utcOffset; - - // add to working hours, keeping startTime and endTimes between bounds (0-1439) - const sameDayStartTime = Math.max(MINUTES_DAY_START, Math.min(MINUTES_DAY_END, startTime)); - const sameDayEndTime = Math.max(MINUTES_DAY_START, Math.min(MINUTES_DAY_END, endTime)); - if (sameDayStartTime !== sameDayEndTime) { - workingHours.push({ - days: schedule.days, - startTime: sameDayStartTime, - endTime: sameDayEndTime, - }); - } - // check for overflow to the previous day - if (startTime < MINUTES_DAY_START || endTime < MINUTES_DAY_START) { - workingHours.push({ - days: schedule.days.map((day) => day - 1), - startTime: startTime + MINUTES_IN_DAY, - endTime: Math.min(endTime + MINUTES_IN_DAY, MINUTES_DAY_END), - }); - } - // else, check for overflow in the next day - else if (startTime > MINUTES_DAY_END || endTime > MINUTES_DAY_END) { - workingHours.push({ - days: schedule.days.map((day) => day + 1), - startTime: Math.max(startTime - MINUTES_IN_DAY, MINUTES_DAY_START), - endTime: endTime - MINUTES_IN_DAY, - }); - } - - return workingHours; - }, []); - - workingHours.sort((a, b) => a.startTime - b.startTime); - - return workingHours; -} +export * from "@calcom/lib/availability"; diff --git a/apps/web/lib/location.ts b/apps/web/lib/location.ts index 5401d8882..16e426598 100644 --- a/apps/web/lib/location.ts +++ b/apps/web/lib/location.ts @@ -1,10 +1 @@ -export enum LocationType { - InPerson = "inPerson", - Phone = "phone", - GoogleMeet = "integrations:google:meet", - Zoom = "integrations:zoom", - Daily = "integrations:daily", - Jitsi = "integrations:jitsi", - Huddle01 = "integrations:huddle01", - Tandem = "integrations:tandem", -} +export * from "@calcom/lib/location"; diff --git a/apps/web/next.config.js b/apps/web/next.config.js index e676aefb8..2b4ac2c90 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const withTM = require("@vercel/edge-functions-ui/transpile")([]); +const withTM = require("@vercel/edge-functions-ui/transpile")(["@calcom/lib", "@calcom/prisma"]); const { i18n } = require("./next-i18next.config"); // So we can test deploy previews preview diff --git a/apps/web/package.json b/apps/web/package.json index 480376977..33b5ff68b 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -8,25 +8,14 @@ "analyze:browser": "BUNDLE_ANALYZE=browser next build", "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next", "dev": "next dev", - "db-up": "docker-compose up -d", - "db-migrate": "yarn prisma migrate deploy", - "db-deploy": "yarn prisma migrate deploy", - "db-seed": "yarn prisma db seed", - "db-nuke": "docker-compose down --volumes --remove-orphans", - "db-setup": "run-s db-up db-migrate db-seed", - "db-reset": "run-s db-nuke db-setup", - "deploy": "run-s build db-deploy", - "dx": "env-cmd run-s db-setup dev", + "dx": "next dev", "test": "jest", - "test-e2e": "cd ../.. && yarn playwright test", + "test-e2e": "cd ../.. && yarn playwright test --config=tests/config/playwright.config.ts --project=chromium", "playwright-report": "playwright show-report playwright/reports/playwright-html-report", "test-codegen": "yarn playwright codegen http://localhost:3000", "type-check": "tsc --pretty --noEmit", "build": "next build", "start": "next start", - "generate-schemas": "prisma generate", - "postinstall": "yarn generate-schemas", - "pre-commit": "lint-staged", "lint": "eslint . --ext .ts,.js,.tsx,.jsx", "lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix", "check-changed-files": "ts-node scripts/ts-check-changed-files.ts" @@ -37,6 +26,9 @@ }, "dependencies": { "@boxyhq/saml-jackson": "0.3.6", + "@calcom/lib": "*", + "@calcom/prisma": "*", + "@calcom/tsconfig": "*", "@daily-co/daily-js": "^0.21.0", "@headlessui/react": "^1.4.2", "@heroicons/react": "^1.0.5", @@ -45,7 +37,6 @@ "@jitsu/sdk-js": "^2.2.4", "@metamask/providers": "^8.1.1", "@next/bundle-analyzer": "11.1.2", - "@prisma/client": "3.0.2", "@radix-ui/react-avatar": "^0.1.0", "@radix-ui/react-collapsible": "^0.1.0", "@radix-ui/react-dialog": "^0.1.0", @@ -144,30 +135,15 @@ "eslint-plugin-react": "^7.27.1", "eslint-plugin-react-hooks": "^4.3.0", "jest": "^26.0.0", - "lint-staged": "^11.1.2", "mockdate": "^3.0.5", "module-alias": "^2.2.2", "npm-run-all": "^4.1.5", "postcss": "^8.4.4", "prettier": "^2.5.1", "prettier-plugin-tailwindcss": "^0.1.6", - "prisma": "3.0.2", "tailwindcss": "^3.0.0", "ts-jest": "^26.0.0", "ts-node": "^10.2.1", - "typescript": "^4.5.2", - "zod-prisma": "^0.5.4" - }, - "lint-staged": { - "./{*,{ee,pages,components,lib}/**/*}.{js,ts,jsx,tsx}": [ - "prettier --write", - "eslint" - ], - "./prisma/schema.prisma": [ - "prisma format" - ] - }, - "prisma": { - "seed": "ts-node ./prisma/seed.ts" + "typescript": "^4.5.3" } } diff --git a/apps/web/server/routers/viewer/eventTypes.tsx b/apps/web/server/routers/viewer/eventTypes.tsx index 6bf48a88a..82b257e79 100644 --- a/apps/web/server/routers/viewer/eventTypes.tsx +++ b/apps/web/server/routers/viewer/eventTypes.tsx @@ -1,13 +1,14 @@ import { EventTypeCustomInput, MembershipRole, PeriodType, Prisma } from "@prisma/client"; +import { z } from "zod"; + import { _AvailabilityModel, _DestinationCalendarModel, _EventTypeCustomInputModel, _EventTypeModel, -} from "prisma/zod"; -import { stringOrNumber } from "prisma/zod-utils"; -import { createEventTypeInput } from "prisma/zod/eventtypeCustom"; -import { z } from "zod"; +} from "@calcom/prisma/zod"; +import { stringOrNumber } from "@calcom/prisma/zod-utils"; +import { createEventTypeInput } from "@calcom/prisma/zod/eventtypeCustom"; import { createProtectedRouter } from "@server/createRouter"; import { viewerRouter } from "@server/routers/viewer"; diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 644c64f61..a8423c252 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../packages/tsconfig/nextjs.json", + "extends": "@calcom/tsconfig/nextjs.json", "compilerOptions": { "baseUrl": ".", "paths": { diff --git a/package.json b/package.json index f3be640d9..df987adba 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "format": "prettier --write \"**/*.{ts,tsx,md}\"", "heroku-postbuild": "turbo run @calcom/web#build", "lint": "turbo run lint", + "pre-commit": "lint-staged", "prepare": "husky install", "start": "turbo run start", "test": "turbo run test", @@ -41,6 +42,9 @@ ], "*.json": [ "prettier --write" + ], + "packages/prisma/schema.prisma": [ + "prisma format" ] }, "engines": { diff --git a/packages/lib/auth.ts b/packages/lib/auth.ts new file mode 100644 index 000000000..976b6c32c --- /dev/null +++ b/packages/lib/auth.ts @@ -0,0 +1,11 @@ +import { compare, hash } from "bcryptjs"; + +export async function hashPassword(password: string) { + const hashedPassword = await hash(password, 12); + return hashedPassword; +} + +export async function verifyPassword(password: string, hashedPassword: string) { + const isValid = await compare(password, hashedPassword); + return isValid; +} diff --git a/packages/lib/availability.ts b/packages/lib/availability.ts new file mode 100644 index 000000000..d74ae30d2 --- /dev/null +++ b/packages/lib/availability.ts @@ -0,0 +1,126 @@ +import dayjs, { ConfigType } from "dayjs"; +import customParseFormat from "dayjs/plugin/customParseFormat"; +import timezone from "dayjs/plugin/timezone"; +import utc from "dayjs/plugin/utc"; + +import type { Availability } from "@calcom/prisma/client"; +import type { Schedule, TimeRange, WorkingHours } from "@calcom/types/schedule"; + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(customParseFormat); +// sets the desired time in current date, needs to be current date for proper DST translation +export const defaultDayRange: TimeRange = { + start: new Date(new Date().setUTCHours(9, 0, 0, 0)), + end: new Date(new Date().setUTCHours(17, 0, 0, 0)), +}; + +export const DEFAULT_SCHEDULE: Schedule = [ + [], + [defaultDayRange], + [defaultDayRange], + [defaultDayRange], + [defaultDayRange], + [defaultDayRange], + [], +]; + +export function getAvailabilityFromSchedule(schedule: Schedule): Availability[] { + return schedule.reduce((availability: Availability[], times: TimeRange[], day: number) => { + const addNewTime = (time: TimeRange) => + ({ + days: [day], + startTime: time.start, + endTime: time.end, + } as Availability); + + const filteredTimes = times.filter((time) => { + let idx; + if ( + (idx = availability.findIndex( + (schedule) => schedule.startTime === time.start && schedule.endTime === time.end + )) !== -1 + ) { + availability[idx].days.push(day); + return false; + } + return true; + }); + filteredTimes.forEach((time) => { + availability.push(addNewTime(time)); + }); + return availability; + }, [] as Availability[]); +} + +export const MINUTES_IN_DAY = 60 * 24; +export const MINUTES_DAY_END = MINUTES_IN_DAY - 1; +export const MINUTES_DAY_START = 0; + +/** + * Allows "casting" availability (days, startTime, endTime) given in UTC to a timeZone or utcOffset + */ +export function getWorkingHours( + relativeTimeUnit: { + timeZone?: string; + utcOffset?: number; + }, + availability: { days: number[]; startTime: ConfigType; endTime: ConfigType }[] +) { + // clearly bail when availability is not set, set everything available. + if (!availability.length) { + return [ + { + days: [0, 1, 2, 3, 4, 5, 6], + // shorthand for: dayjs().startOf("day").tz(timeZone).diff(dayjs.utc().startOf("day"), "minutes") + startTime: MINUTES_DAY_START, + endTime: MINUTES_DAY_END, + }, + ]; + } + + const utcOffset = relativeTimeUnit.utcOffset ?? dayjs().tz(relativeTimeUnit.timeZone).utcOffset(); + + const workingHours = availability.reduce((workingHours: WorkingHours[], schedule) => { + // Get times localised to the given utcOffset/timeZone + const startTime = + dayjs.utc(schedule.startTime).get("hour") * 60 + + dayjs.utc(schedule.startTime).get("minute") - + utcOffset; + const endTime = + dayjs.utc(schedule.endTime).get("hour") * 60 + dayjs.utc(schedule.endTime).get("minute") - utcOffset; + + // add to working hours, keeping startTime and endTimes between bounds (0-1439) + const sameDayStartTime = Math.max(MINUTES_DAY_START, Math.min(MINUTES_DAY_END, startTime)); + const sameDayEndTime = Math.max(MINUTES_DAY_START, Math.min(MINUTES_DAY_END, endTime)); + if (sameDayStartTime !== sameDayEndTime) { + workingHours.push({ + days: schedule.days, + startTime: sameDayStartTime, + endTime: sameDayEndTime, + }); + } + // check for overflow to the previous day + if (startTime < MINUTES_DAY_START || endTime < MINUTES_DAY_START) { + workingHours.push({ + days: schedule.days.map((day) => day - 1), + startTime: startTime + MINUTES_IN_DAY, + endTime: Math.min(endTime + MINUTES_IN_DAY, MINUTES_DAY_END), + }); + } + // else, check for overflow in the next day + else if (startTime > MINUTES_DAY_END || endTime > MINUTES_DAY_END) { + workingHours.push({ + days: schedule.days.map((day) => day + 1), + startTime: Math.max(startTime - MINUTES_IN_DAY, MINUTES_DAY_START), + endTime: endTime - MINUTES_IN_DAY, + }); + } + + return workingHours; + }, []); + + workingHours.sort((a, b) => a.startTime - b.startTime); + + return workingHours; +} diff --git a/packages/lib/location.ts b/packages/lib/location.ts new file mode 100644 index 000000000..5401d8882 --- /dev/null +++ b/packages/lib/location.ts @@ -0,0 +1,10 @@ +export enum LocationType { + InPerson = "inPerson", + Phone = "phone", + GoogleMeet = "integrations:google:meet", + Zoom = "integrations:zoom", + Daily = "integrations:daily", + Jitsi = "integrations:jitsi", + Huddle01 = "integrations:huddle01", + Tandem = "integrations:tandem", +} diff --git a/packages/lib/package.json b/packages/lib/package.json new file mode 100644 index 000000000..8d375e967 --- /dev/null +++ b/packages/lib/package.json @@ -0,0 +1,16 @@ +{ + "name": "@calcom/lib", + "version": "0.0.0", + "main": "./index.ts", + "types": "./index.ts", + "license": "MIT", + "dependencies": { + "bcryptjs": "^2.4.3", + "dayjs": "^1.10.6", + "dayjs-business-time": "^1.0.4" + }, + "devDependencies": { + "@calcom/tsconfig": "*", + "typescript": "^4.5.3" + } +} diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json new file mode 100644 index 000000000..f9701e8ae --- /dev/null +++ b/packages/lib/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "@calcom/tsconfig/base.json", + "include": ["."], + "exclude": ["dist", "build", "node_modules"] +} diff --git a/packages/prisma/.env.example b/packages/prisma/.env.example new file mode 100644 index 000000000..6e7be9511 --- /dev/null +++ b/packages/prisma/.env.example @@ -0,0 +1,2 @@ +# DATABASE_URL='postgresql://:@:/' +DATABASE_URL="postgresql://postgres:@localhost:5450/calendso" diff --git a/packages/prisma/client/index.d.ts b/packages/prisma/client/index.d.ts new file mode 100644 index 000000000..554f9f41f --- /dev/null +++ b/packages/prisma/client/index.d.ts @@ -0,0 +1 @@ +export * from ".prisma/client/index.d"; diff --git a/packages/prisma/client/runtime.d.ts b/packages/prisma/client/runtime.d.ts new file mode 100644 index 000000000..f85afaee0 --- /dev/null +++ b/packages/prisma/client/runtime.d.ts @@ -0,0 +1 @@ +export * from "@prisma/client/runtime"; diff --git a/apps/web/docker-compose.yml b/packages/prisma/docker-compose.yml similarity index 100% rename from apps/web/docker-compose.yml rename to packages/prisma/docker-compose.yml diff --git a/packages/prisma/index.ts b/packages/prisma/index.ts new file mode 100644 index 000000000..de2d3fdd3 --- /dev/null +++ b/packages/prisma/index.ts @@ -0,0 +1,13 @@ +import { PrismaClient } from "@prisma/client"; + +export const prisma = + globalThis.prisma || + new PrismaClient({ + log: ["query", "error", "warn"], + }); + +if (process.env.NODE_ENV !== "production") { + globalThis.prisma = prisma; +} + +export default prisma; diff --git a/apps/web/prisma/migrations/20210605225044_init/migration.sql b/packages/prisma/migrations/20210605225044_init/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210605225044_init/migration.sql rename to packages/prisma/migrations/20210605225044_init/migration.sql diff --git a/apps/web/prisma/migrations/20210605225507_added_bookings/migration.sql b/packages/prisma/migrations/20210605225507_added_bookings/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210605225507_added_bookings/migration.sql rename to packages/prisma/migrations/20210605225507_added_bookings/migration.sql diff --git a/apps/web/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql b/packages/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql rename to packages/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql diff --git a/apps/web/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql b/packages/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql rename to packages/prisma/migrations/20210613133618_add_team_membership_verification/migration.sql diff --git a/apps/web/prisma/migrations/20210615140247_added_selected_calendar/migration.sql b/packages/prisma/migrations/20210615140247_added_selected_calendar/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210615140247_added_selected_calendar/migration.sql rename to packages/prisma/migrations/20210615140247_added_selected_calendar/migration.sql diff --git a/apps/web/prisma/migrations/20210615142134_added_custom_event_name/migration.sql b/packages/prisma/migrations/20210615142134_added_custom_event_name/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210615142134_added_custom_event_name/migration.sql rename to packages/prisma/migrations/20210615142134_added_custom_event_name/migration.sql diff --git a/apps/web/prisma/migrations/20210615153546_added_buffer_time/migration.sql b/packages/prisma/migrations/20210615153546_added_buffer_time/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210615153546_added_buffer_time/migration.sql rename to packages/prisma/migrations/20210615153546_added_buffer_time/migration.sql diff --git a/apps/web/prisma/migrations/20210615153759_add_email_verification_column/migration.sql b/packages/prisma/migrations/20210615153759_add_email_verification_column/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210615153759_add_email_verification_column/migration.sql rename to packages/prisma/migrations/20210615153759_add_email_verification_column/migration.sql diff --git a/apps/web/prisma/migrations/20210618140954_added_event_type_custom/migration.sql b/packages/prisma/migrations/20210618140954_added_event_type_custom/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210618140954_added_event_type_custom/migration.sql rename to packages/prisma/migrations/20210618140954_added_event_type_custom/migration.sql diff --git a/apps/web/prisma/migrations/20210628153550_password_reset_request/migration.sql b/packages/prisma/migrations/20210628153550_password_reset_request/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210628153550_password_reset_request/migration.sql rename to packages/prisma/migrations/20210628153550_password_reset_request/migration.sql diff --git a/apps/web/prisma/migrations/20210629160507_hide_branding/migration.sql b/packages/prisma/migrations/20210629160507_hide_branding/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210629160507_hide_branding/migration.sql rename to packages/prisma/migrations/20210629160507_hide_branding/migration.sql diff --git a/apps/web/prisma/migrations/20210630014738_schedule_availability/migration.sql b/packages/prisma/migrations/20210630014738_schedule_availability/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210630014738_schedule_availability/migration.sql rename to packages/prisma/migrations/20210630014738_schedule_availability/migration.sql diff --git a/apps/web/prisma/migrations/20210709231256_add_user_theme/migration.sql b/packages/prisma/migrations/20210709231256_add_user_theme/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210709231256_add_user_theme/migration.sql rename to packages/prisma/migrations/20210709231256_add_user_theme/migration.sql diff --git a/apps/web/prisma/migrations/20210714151216_event_type_period_settings/migration.sql b/packages/prisma/migrations/20210714151216_event_type_period_settings/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210714151216_event_type_period_settings/migration.sql rename to packages/prisma/migrations/20210714151216_event_type_period_settings/migration.sql diff --git a/apps/web/prisma/migrations/20210717120159_booking_confirmation/migration.sql b/packages/prisma/migrations/20210717120159_booking_confirmation/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210717120159_booking_confirmation/migration.sql rename to packages/prisma/migrations/20210717120159_booking_confirmation/migration.sql diff --git a/apps/web/prisma/migrations/20210718184017_reminder_mails/migration.sql b/packages/prisma/migrations/20210718184017_reminder_mails/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210718184017_reminder_mails/migration.sql rename to packages/prisma/migrations/20210718184017_reminder_mails/migration.sql diff --git a/apps/web/prisma/migrations/20210722225431_minimum_booking_notice/migration.sql b/packages/prisma/migrations/20210722225431_minimum_booking_notice/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210722225431_minimum_booking_notice/migration.sql rename to packages/prisma/migrations/20210722225431_minimum_booking_notice/migration.sql diff --git a/apps/web/prisma/migrations/20210725123357_add_location_to_booking/migration.sql b/packages/prisma/migrations/20210725123357_add_location_to_booking/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210725123357_add_location_to_booking/migration.sql rename to packages/prisma/migrations/20210725123357_add_location_to_booking/migration.sql diff --git a/apps/web/prisma/migrations/20210813142905_event_payment/migration.sql b/packages/prisma/migrations/20210813142905_event_payment/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210813142905_event_payment/migration.sql rename to packages/prisma/migrations/20210813142905_event_payment/migration.sql diff --git a/apps/web/prisma/migrations/20210813194355_add_slug_to_team/migration.sql b/packages/prisma/migrations/20210813194355_add_slug_to_team/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210813194355_add_slug_to_team/migration.sql rename to packages/prisma/migrations/20210813194355_add_slug_to_team/migration.sql diff --git a/apps/web/prisma/migrations/20210814175645_custom_inputs_type_enum/migration.sql b/packages/prisma/migrations/20210814175645_custom_inputs_type_enum/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210814175645_custom_inputs_type_enum/migration.sql rename to packages/prisma/migrations/20210814175645_custom_inputs_type_enum/migration.sql diff --git a/apps/web/prisma/migrations/20210820130519_add_placeholder_to_custom_event_types/migration.sql b/packages/prisma/migrations/20210820130519_add_placeholder_to_custom_event_types/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210820130519_add_placeholder_to_custom_event_types/migration.sql rename to packages/prisma/migrations/20210820130519_add_placeholder_to_custom_event_types/migration.sql diff --git a/apps/web/prisma/migrations/20210824054220_add_bio_branding_logo_to_team/migration.sql b/packages/prisma/migrations/20210824054220_add_bio_branding_logo_to_team/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210824054220_add_bio_branding_logo_to_team/migration.sql rename to packages/prisma/migrations/20210824054220_add_bio_branding_logo_to_team/migration.sql diff --git a/apps/web/prisma/migrations/20210825004801_schedule_schema/migration.sql b/packages/prisma/migrations/20210825004801_schedule_schema/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210825004801_schedule_schema/migration.sql rename to packages/prisma/migrations/20210825004801_schedule_schema/migration.sql diff --git a/apps/web/prisma/migrations/20210830064354_add_unique_to_team_slug/migration.sql b/packages/prisma/migrations/20210830064354_add_unique_to_team_slug/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210830064354_add_unique_to_team_slug/migration.sql rename to packages/prisma/migrations/20210830064354_add_unique_to_team_slug/migration.sql diff --git a/apps/web/prisma/migrations/20210902112455_event_type_unique_user_id_slug/migration.sql b/packages/prisma/migrations/20210902112455_event_type_unique_user_id_slug/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210902112455_event_type_unique_user_id_slug/migration.sql rename to packages/prisma/migrations/20210902112455_event_type_unique_user_id_slug/migration.sql diff --git a/apps/web/prisma/migrations/20210902121313_user_plan/migration.sql b/packages/prisma/migrations/20210902121313_user_plan/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210902121313_user_plan/migration.sql rename to packages/prisma/migrations/20210902121313_user_plan/migration.sql diff --git a/apps/web/prisma/migrations/20210902125945_user_username_unique/migration.sql b/packages/prisma/migrations/20210902125945_user_username_unique/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210902125945_user_username_unique/migration.sql rename to packages/prisma/migrations/20210902125945_user_username_unique/migration.sql diff --git a/apps/web/prisma/migrations/20210904162403_add_booking_status_enum/migration.sql b/packages/prisma/migrations/20210904162403_add_booking_status_enum/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210904162403_add_booking_status_enum/migration.sql rename to packages/prisma/migrations/20210904162403_add_booking_status_enum/migration.sql diff --git a/apps/web/prisma/migrations/20210908042159_teams_feature/migration.sql b/packages/prisma/migrations/20210908042159_teams_feature/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210908042159_teams_feature/migration.sql rename to packages/prisma/migrations/20210908042159_teams_feature/migration.sql diff --git a/apps/web/prisma/migrations/20210908220336_add_daily_data_table/migration.sql b/packages/prisma/migrations/20210908220336_add_daily_data_table/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210908220336_add_daily_data_table/migration.sql rename to packages/prisma/migrations/20210908220336_add_daily_data_table/migration.sql diff --git a/apps/web/prisma/migrations/20210908235519_undo_unique_user_id_slug/migration.sql b/packages/prisma/migrations/20210908235519_undo_unique_user_id_slug/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210908235519_undo_unique_user_id_slug/migration.sql rename to packages/prisma/migrations/20210908235519_undo_unique_user_id_slug/migration.sql diff --git a/apps/web/prisma/migrations/20210913211650_add_meeting_info/migration.sql b/packages/prisma/migrations/20210913211650_add_meeting_info/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210913211650_add_meeting_info/migration.sql rename to packages/prisma/migrations/20210913211650_add_meeting_info/migration.sql diff --git a/apps/web/prisma/migrations/20210918013258_add_two_factor_fields/migration.sql b/packages/prisma/migrations/20210918013258_add_two_factor_fields/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210918013258_add_two_factor_fields/migration.sql rename to packages/prisma/migrations/20210918013258_add_two_factor_fields/migration.sql diff --git a/apps/web/prisma/migrations/20210918152354_user_id_slug_fix/migration.sql b/packages/prisma/migrations/20210918152354_user_id_slug_fix/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210918152354_user_id_slug_fix/migration.sql rename to packages/prisma/migrations/20210918152354_user_id_slug_fix/migration.sql diff --git a/apps/web/prisma/migrations/20210919174415_add_user_locale/migration.sql b/packages/prisma/migrations/20210919174415_add_user_locale/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210919174415_add_user_locale/migration.sql rename to packages/prisma/migrations/20210919174415_add_user_locale/migration.sql diff --git a/apps/web/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql b/packages/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql rename to packages/prisma/migrations/20210922004424_add_disable_guests_to_event_type/migration.sql diff --git a/apps/web/prisma/migrations/20211004231654_add_webhook_model/migration.sql b/packages/prisma/migrations/20211004231654_add_webhook_model/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211004231654_add_webhook_model/migration.sql rename to packages/prisma/migrations/20211004231654_add_webhook_model/migration.sql diff --git a/apps/web/prisma/migrations/20211011152041_non_optionals/migration.sql b/packages/prisma/migrations/20211011152041_non_optionals/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211011152041_non_optionals/migration.sql rename to packages/prisma/migrations/20211011152041_non_optionals/migration.sql diff --git a/apps/web/prisma/migrations/20211028233838_add_user_webhooks_relation/migration.sql b/packages/prisma/migrations/20211028233838_add_user_webhooks_relation/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211028233838_add_user_webhooks_relation/migration.sql rename to packages/prisma/migrations/20211028233838_add_user_webhooks_relation/migration.sql diff --git a/apps/web/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql b/packages/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql rename to packages/prisma/migrations/20211101151249_update_rejected_bookings/migration.sql diff --git a/apps/web/prisma/migrations/20211105200545_availability_start_and_end_time_as_time/migration.sql b/packages/prisma/migrations/20211105200545_availability_start_and_end_time_as_time/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211105200545_availability_start_and_end_time_as_time/migration.sql rename to packages/prisma/migrations/20211105200545_availability_start_and_end_time_as_time/migration.sql diff --git a/apps/web/prisma/migrations/20211106121119_add_event_type_position/migration.sql b/packages/prisma/migrations/20211106121119_add_event_type_position/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211106121119_add_event_type_position/migration.sql rename to packages/prisma/migrations/20211106121119_add_event_type_position/migration.sql diff --git a/apps/web/prisma/migrations/20211110063531_add_custom_brand_color/migration.sql b/packages/prisma/migrations/20211110063531_add_custom_brand_color/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211110063531_add_custom_brand_color/migration.sql rename to packages/prisma/migrations/20211110063531_add_custom_brand_color/migration.sql diff --git a/apps/web/prisma/migrations/20211110142845_add_identity_provider_columns/migration.sql b/packages/prisma/migrations/20211110142845_add_identity_provider_columns/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211110142845_add_identity_provider_columns/migration.sql rename to packages/prisma/migrations/20211110142845_add_identity_provider_columns/migration.sql diff --git a/apps/web/prisma/migrations/20211111013358_period_type_enum/migration.sql b/packages/prisma/migrations/20211111013358_period_type_enum/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211111013358_period_type_enum/migration.sql rename to packages/prisma/migrations/20211111013358_period_type_enum/migration.sql diff --git a/apps/web/prisma/migrations/20211112145539_add_saml_login/migration.sql b/packages/prisma/migrations/20211112145539_add_saml_login/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211112145539_add_saml_login/migration.sql rename to packages/prisma/migrations/20211112145539_add_saml_login/migration.sql diff --git a/apps/web/prisma/migrations/20211115182559_availability_issue/migration.sql b/packages/prisma/migrations/20211115182559_availability_issue/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211115182559_availability_issue/migration.sql rename to packages/prisma/migrations/20211115182559_availability_issue/migration.sql diff --git a/apps/web/prisma/migrations/20211120211639_add_payload_template/migration.sql b/packages/prisma/migrations/20211120211639_add_payload_template/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211120211639_add_payload_template/migration.sql rename to packages/prisma/migrations/20211120211639_add_payload_template/migration.sql diff --git a/apps/web/prisma/migrations/20211207010154_add_destination_calendar/migration.sql b/packages/prisma/migrations/20211207010154_add_destination_calendar/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211207010154_add_destination_calendar/migration.sql rename to packages/prisma/migrations/20211207010154_add_destination_calendar/migration.sql diff --git a/apps/web/prisma/migrations/20211209201138_membership_admin_role/migration.sql b/packages/prisma/migrations/20211209201138_membership_admin_role/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211209201138_membership_admin_role/migration.sql rename to packages/prisma/migrations/20211209201138_membership_admin_role/migration.sql diff --git a/apps/web/prisma/migrations/20211210182230_add_invited_to/migration.sql b/packages/prisma/migrations/20211210182230_add_invited_to/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211210182230_add_invited_to/migration.sql rename to packages/prisma/migrations/20211210182230_add_invited_to/migration.sql diff --git a/apps/web/prisma/migrations/20211217201940_upgrade_to_v3/migration.sql b/packages/prisma/migrations/20211217201940_upgrade_to_v3/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211217201940_upgrade_to_v3/migration.sql rename to packages/prisma/migrations/20211217201940_upgrade_to_v3/migration.sql diff --git a/apps/web/prisma/migrations/20211217215952_added_slot_interval_to_event_type/migration.sql b/packages/prisma/migrations/20211217215952_added_slot_interval_to_event_type/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211217215952_added_slot_interval_to_event_type/migration.sql rename to packages/prisma/migrations/20211217215952_added_slot_interval_to_event_type/migration.sql diff --git a/apps/web/prisma/migrations/20211220192703_email_to_lowercase/migration.sql b/packages/prisma/migrations/20211220192703_email_to_lowercase/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211220192703_email_to_lowercase/migration.sql rename to packages/prisma/migrations/20211220192703_email_to_lowercase/migration.sql diff --git a/apps/web/prisma/migrations/20211222174947_placeholder/migration.sql b/packages/prisma/migrations/20211222174947_placeholder/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211222174947_placeholder/migration.sql rename to packages/prisma/migrations/20211222174947_placeholder/migration.sql diff --git a/apps/web/prisma/migrations/20211222181246_add_sc_address/migration.sql b/packages/prisma/migrations/20211222181246_add_sc_address/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211222181246_add_sc_address/migration.sql rename to packages/prisma/migrations/20211222181246_add_sc_address/migration.sql diff --git a/apps/web/prisma/migrations/20211228004752_adds_user_metadata/migration.sql b/packages/prisma/migrations/20211228004752_adds_user_metadata/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211228004752_adds_user_metadata/migration.sql rename to packages/prisma/migrations/20211228004752_adds_user_metadata/migration.sql diff --git a/apps/web/prisma/migrations/20211231142312_add_user_on_delete_cascade/migration.sql b/packages/prisma/migrations/20211231142312_add_user_on_delete_cascade/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20211231142312_add_user_on_delete_cascade/migration.sql rename to packages/prisma/migrations/20211231142312_add_user_on_delete_cascade/migration.sql diff --git a/apps/web/prisma/migrations/20220105104913_add_away_field/migration.sql b/packages/prisma/migrations/20220105104913_add_away_field/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220105104913_add_away_field/migration.sql rename to packages/prisma/migrations/20220105104913_add_away_field/migration.sql diff --git a/apps/web/prisma/migrations/20220113145333_rename_column_sc_address_to_smart_contract_address/migration.sql b/packages/prisma/migrations/20220113145333_rename_column_sc_address_to_smart_contract_address/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220113145333_rename_column_sc_address_to_smart_contract_address/migration.sql rename to packages/prisma/migrations/20220113145333_rename_column_sc_address_to_smart_contract_address/migration.sql diff --git a/apps/web/prisma/migrations/20220117193242_trial_users_by_default/migration.sql b/packages/prisma/migrations/20220117193242_trial_users_by_default/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220117193242_trial_users_by_default/migration.sql rename to packages/prisma/migrations/20220117193242_trial_users_by_default/migration.sql diff --git a/apps/web/prisma/migrations/20220121210720_add_cancellation_reason/migration.sql b/packages/prisma/migrations/20220121210720_add_cancellation_reason/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220121210720_add_cancellation_reason/migration.sql rename to packages/prisma/migrations/20220121210720_add_cancellation_reason/migration.sql diff --git a/apps/web/prisma/migrations/20220125035907_add_attendee_locale/migration.sql b/packages/prisma/migrations/20220125035907_add_attendee_locale/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220125035907_add_attendee_locale/migration.sql rename to packages/prisma/migrations/20220125035907_add_attendee_locale/migration.sql diff --git a/apps/web/prisma/migrations/20220131170110_add_metadata_column_to_event_type/migration.sql b/packages/prisma/migrations/20220131170110_add_metadata_column_to_event_type/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220131170110_add_metadata_column_to_event_type/migration.sql rename to packages/prisma/migrations/20220131170110_add_metadata_column_to_event_type/migration.sql diff --git a/apps/web/prisma/migrations/20220205135022_add_verified_column/migration.sql b/packages/prisma/migrations/20220205135022_add_verified_column/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220205135022_add_verified_column/migration.sql rename to packages/prisma/migrations/20220205135022_add_verified_column/migration.sql diff --git a/apps/web/prisma/migrations/20220209082843_add_rejection_reason/migration.sql b/packages/prisma/migrations/20220209082843_add_rejection_reason/migration.sql similarity index 100% rename from apps/web/prisma/migrations/20220209082843_add_rejection_reason/migration.sql rename to packages/prisma/migrations/20220209082843_add_rejection_reason/migration.sql diff --git a/apps/web/prisma/migrations/migration_lock.toml b/packages/prisma/migrations/migration_lock.toml similarity index 100% rename from apps/web/prisma/migrations/migration_lock.toml rename to packages/prisma/migrations/migration_lock.toml diff --git a/packages/prisma/package.json b/packages/prisma/package.json new file mode 100644 index 000000000..ebdfcaa04 --- /dev/null +++ b/packages/prisma/package.json @@ -0,0 +1,34 @@ +{ + "name": "@calcom/prisma", + "version": "0.0.0", + "private": true, + "scripts": { + "build": "yarn generate-schemas", + "clean": "rm -rf .turbo && rm -rf node_modules", + "db-deploy": "yarn prisma migrate deploy", + "db-migrate": "yarn prisma migrate dev", + "db-nuke": "docker-compose down --volumes --remove-orphans", + "db-reset": "run-s db-nuke db-setup", + "db-seed": "yarn prisma db seed", + "db-setup": "run-s db-up db-deploy db-seed", + "db-up": "docker-compose up -d", + "deploy": "run-s build db-deploy", + "dx": "yarn db-setup", + "generate-schemas": "prisma generate" + }, + "devDependencies": { + "npm-run-all": "^4.1.5", + "prisma": "3.0.2", + "ts-node": "^10.2.1", + "zod-prisma": "^0.5.4" + }, + "dependencies": { + "@calcom/lib": "*", + "@prisma/client": "3.0.2" + }, + "main": "index.ts", + "types": "index.d.ts", + "prisma": { + "seed": "ts-node ./seed.ts" + } +} diff --git a/apps/web/prisma/schema.prisma b/packages/prisma/schema.prisma similarity index 100% rename from apps/web/prisma/schema.prisma rename to packages/prisma/schema.prisma diff --git a/apps/web/prisma/seed.ts b/packages/prisma/seed.ts similarity index 98% rename from apps/web/prisma/seed.ts rename to packages/prisma/seed.ts index df41bf461..80d008a48 100644 --- a/apps/web/prisma/seed.ts +++ b/packages/prisma/seed.ts @@ -2,8 +2,8 @@ import { MembershipRole, Prisma, PrismaClient, UserPlan } from "@prisma/client"; import dayjs from "dayjs"; import { uuid } from "short-uuid"; -import { hashPassword } from "../lib/auth"; -import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "../lib/availability"; +import { hashPassword } from "@calcom/lib/auth"; +import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability"; const prisma = new PrismaClient(); diff --git a/apps/web/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts similarity index 88% rename from apps/web/prisma/zod-utils.ts rename to packages/prisma/zod-utils.ts index 22a7fd6f4..76dc746bd 100644 --- a/apps/web/prisma/zod-utils.ts +++ b/packages/prisma/zod-utils.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { LocationType } from "@lib/location"; +import { LocationType } from "@calcom/lib/location"; export const eventTypeLocations = z.array( z.object({ type: z.nativeEnum(LocationType), address: z.string().optional() }) diff --git a/apps/web/prisma/zod/attendee.ts b/packages/prisma/zod/attendee.ts similarity index 100% rename from apps/web/prisma/zod/attendee.ts rename to packages/prisma/zod/attendee.ts diff --git a/apps/web/prisma/zod/availability.ts b/packages/prisma/zod/availability.ts similarity index 100% rename from apps/web/prisma/zod/availability.ts rename to packages/prisma/zod/availability.ts diff --git a/apps/web/prisma/zod/booking.ts b/packages/prisma/zod/booking.ts similarity index 100% rename from apps/web/prisma/zod/booking.ts rename to packages/prisma/zod/booking.ts diff --git a/apps/web/prisma/zod/bookingreference.ts b/packages/prisma/zod/bookingreference.ts similarity index 100% rename from apps/web/prisma/zod/bookingreference.ts rename to packages/prisma/zod/bookingreference.ts diff --git a/apps/web/prisma/zod/credential.ts b/packages/prisma/zod/credential.ts similarity index 100% rename from apps/web/prisma/zod/credential.ts rename to packages/prisma/zod/credential.ts diff --git a/apps/web/prisma/zod/dailyeventreference.ts b/packages/prisma/zod/dailyeventreference.ts similarity index 100% rename from apps/web/prisma/zod/dailyeventreference.ts rename to packages/prisma/zod/dailyeventreference.ts diff --git a/apps/web/prisma/zod/destinationcalendar.ts b/packages/prisma/zod/destinationcalendar.ts similarity index 100% rename from apps/web/prisma/zod/destinationcalendar.ts rename to packages/prisma/zod/destinationcalendar.ts diff --git a/apps/web/prisma/zod/eventtype.ts b/packages/prisma/zod/eventtype.ts similarity index 100% rename from apps/web/prisma/zod/eventtype.ts rename to packages/prisma/zod/eventtype.ts diff --git a/apps/web/prisma/zod/eventtypeCustom.ts b/packages/prisma/zod/eventtypeCustom.ts similarity index 90% rename from apps/web/prisma/zod/eventtypeCustom.ts rename to packages/prisma/zod/eventtypeCustom.ts index 162959076..0f9c1e6f8 100644 --- a/apps/web/prisma/zod/eventtypeCustom.ts +++ b/packages/prisma/zod/eventtypeCustom.ts @@ -1,4 +1,4 @@ -import { _EventTypeModel } from "prisma/zod"; +import { _EventTypeModel } from "./eventtype"; const createEventTypeBaseInput = _EventTypeModel .pick({ diff --git a/apps/web/prisma/zod/eventtypecustominput.ts b/packages/prisma/zod/eventtypecustominput.ts similarity index 100% rename from apps/web/prisma/zod/eventtypecustominput.ts rename to packages/prisma/zod/eventtypecustominput.ts diff --git a/apps/web/prisma/zod/index.ts b/packages/prisma/zod/index.ts similarity index 100% rename from apps/web/prisma/zod/index.ts rename to packages/prisma/zod/index.ts diff --git a/apps/web/prisma/zod/membership.ts b/packages/prisma/zod/membership.ts similarity index 100% rename from apps/web/prisma/zod/membership.ts rename to packages/prisma/zod/membership.ts diff --git a/apps/web/prisma/zod/payment.ts b/packages/prisma/zod/payment.ts similarity index 100% rename from apps/web/prisma/zod/payment.ts rename to packages/prisma/zod/payment.ts diff --git a/apps/web/prisma/zod/remindermail.ts b/packages/prisma/zod/remindermail.ts similarity index 100% rename from apps/web/prisma/zod/remindermail.ts rename to packages/prisma/zod/remindermail.ts diff --git a/apps/web/prisma/zod/resetpasswordrequest.ts b/packages/prisma/zod/resetpasswordrequest.ts similarity index 100% rename from apps/web/prisma/zod/resetpasswordrequest.ts rename to packages/prisma/zod/resetpasswordrequest.ts diff --git a/apps/web/prisma/zod/schedule.ts b/packages/prisma/zod/schedule.ts similarity index 100% rename from apps/web/prisma/zod/schedule.ts rename to packages/prisma/zod/schedule.ts diff --git a/apps/web/prisma/zod/selectedcalendar.ts b/packages/prisma/zod/selectedcalendar.ts similarity index 100% rename from apps/web/prisma/zod/selectedcalendar.ts rename to packages/prisma/zod/selectedcalendar.ts diff --git a/apps/web/prisma/zod/team.ts b/packages/prisma/zod/team.ts similarity index 100% rename from apps/web/prisma/zod/team.ts rename to packages/prisma/zod/team.ts diff --git a/apps/web/prisma/zod/user.ts b/packages/prisma/zod/user.ts similarity index 100% rename from apps/web/prisma/zod/user.ts rename to packages/prisma/zod/user.ts diff --git a/apps/web/prisma/zod/verificationrequest.ts b/packages/prisma/zod/verificationrequest.ts similarity index 100% rename from apps/web/prisma/zod/verificationrequest.ts rename to packages/prisma/zod/verificationrequest.ts diff --git a/apps/web/prisma/zod/webhook.ts b/packages/prisma/zod/webhook.ts similarity index 100% rename from apps/web/prisma/zod/webhook.ts rename to packages/prisma/zod/webhook.ts diff --git a/packages/types/package.json b/packages/types/package.json new file mode 100644 index 000000000..3a873153e --- /dev/null +++ b/packages/types/package.json @@ -0,0 +1,6 @@ +{ + "name": "@calcom/types", + "version": "0.0.0", + "private": true, + "main": "index.js" +} diff --git a/packages/types/schedule.d.ts b/packages/types/schedule.d.ts new file mode 100644 index 000000000..ba5e74b45 --- /dev/null +++ b/packages/types/schedule.d.ts @@ -0,0 +1,18 @@ +export type TimeRange = { + start: Date; + end: Date; +}; + +export type Schedule = TimeRange[][]; + +/** + * ```text + * Ensure startTime and endTime in minutes since midnight; serialized to UTC by using the organizer timeZone, either by using the schedule timeZone or the user timeZone. + * @see lib/availability.ts getWorkingHours(timeZone: string, availability: Availability[]) + * ``` + */ +export type WorkingHours = { + days: number[]; + startTime: number; + endTime: number; +}; diff --git a/apps/web/playwright/lib/globalSetup.ts b/tests/config/globalSetup.ts similarity index 100% rename from apps/web/playwright/lib/globalSetup.ts rename to tests/config/globalSetup.ts diff --git a/playwright.config.ts b/tests/config/playwright.config.ts similarity index 86% rename from playwright.config.ts rename to tests/config/playwright.config.ts index 39caf0ee7..09b5a136b 100644 --- a/playwright.config.ts +++ b/tests/config/playwright.config.ts @@ -1,5 +1,6 @@ import { PlaywrightTestConfig, devices } from "@playwright/test"; import { addAliases } from "module-alias"; +import * as path from "path"; // Add aliases for the paths specified in the tsconfig.json file. // This is needed because playwright does not consider tsconfig.json @@ -13,6 +14,9 @@ addAliases({ "@ee": __dirname + "/apps/web/ee", }); +const outputDir = path.join(__dirname, "..", "..", "test-results"); +const testDir = path.join(__dirname, "..", "..", "apps/web/playwright"); + const config: PlaywrightTestConfig = { forbidOnly: !!process.env.CI, timeout: 60_000, @@ -21,8 +25,8 @@ const config: PlaywrightTestConfig = { ["html", { outputFolder: "./playwright/reports/playwright-html-report", open: "never" }], ["junit", { outputFile: "./playwright/reports/results.xml" }], ], - globalSetup: require.resolve("./apps/web/playwright/lib/globalSetup"), - outputDir: "./playwright/results", + globalSetup: require.resolve("./globalSetup"), + outputDir, webServer: { command: "yarn workspace @calcom/web start -p 3000", port: 3000, @@ -38,7 +42,7 @@ const config: PlaywrightTestConfig = { projects: [ { name: "chromium", - testDir: "apps/web/playwright", + testDir, use: { ...devices["Desktop Chrome"] }, }, /* { diff --git a/turbo.json b/turbo.json index 021f394fb..1ee7e8ebe 100644 --- a/turbo.json +++ b/turbo.json @@ -3,13 +3,15 @@ "baseBranch": "origin/main", "globalDependencies": ["apps/web/.env", "packages/prisma/.env"], "pipeline": { - "@calcom/web#db-deploy": {}, - "@calcom/web#db-seed": { - "dependsOn": ["@calcom/web#db-deploy"] + "@calcom/prisma#db-deploy": {}, + "@calcom/prisma#db-reset": {}, + "@calcom/prisma#db-seed": { + "dependsOn": ["@calcom/prisma#db-deploy"] }, "@calcom/web#build": { "dependsOn": [ "^build", + "@calcom/prisma#build", "$BASE_URL", "$CALENDSO_ENCRYPTION_KEY", "$CRON_API_KEY", @@ -49,6 +51,9 @@ ], "outputs": [".next/**"] }, + "@calcom/web#dx": { + "dependsOn": ["@calcom/prisma#dx"] + }, "@calcom/web#start": {}, "build": { "dependsOn": ["^build"], @@ -73,7 +78,7 @@ }, "start": {}, "test": { - "dependsOn": ["@calcom/web#build", "@calcom/web#db-seed"] + "dependsOn": ["@calcom/web#build", "@calcom/prisma#db-reset"] }, "test-e2e": { "dependsOn": ["^test"] diff --git a/yarn.lock b/yarn.lock index 06f60f8e9..41667bfa8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13137,7 +13137,7 @@ typeorm@0.2.41: yargs "^17.0.1" zen-observable-ts "^1.0.0" -typescript@^4.5.2: +typescript@^4.5.3: version "4.5.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==