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
This commit is contained in:
1 parent
fdf7516cdd
commit
fe35cf6570
128 files changed
+349
-223
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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 `<user>`, `<pass>`, `<db-host>`, `<db-port>` with their applicable values
|
||||
1. Configure database in the `packages/prisma/.env` file. Replace `<user>`, `<pass>`, `<db-host>`, `<db-port>` with their applicable values
|
||||
|
||||
```text
|
||||
DATABASE_URL='postgresql://<user>:<pass>@<db-host>:<db-port>'
|
||||
```
|
||||
```text
|
||||
DATABASE_URL='postgresql://<user>:<pass>@<db-host>:<db-port>'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>If you don't know how to configure the DATABASE_URL, then follow the steps here to create a quick DB using Heroku</summary>
|
||||
<details>
|
||||
|
||||
1. Create a free account with [Heroku](https://www.heroku.com/).
|
||||
<summary>
|
||||
If you don't know how to configure the DATABASE_URL, then follow the steps here to create a quick DB
|
||||
using Heroku
|
||||
</summary>
|
||||
|
||||
2. Create a new app.
|
||||
<img width="306" alt="Create an App" src="https://user-images.githubusercontent.com/16905768/115322780-b3d58c00-a17e-11eb-8a52-b758fb0ea942.png" />
|
||||
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.
|
||||

|
||||
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.
|
||||

|
||||
<img
|
||||
width="306"
|
||||
alt="Create an App"
|
||||
src="https://user-images.githubusercontent.com/16905768/115322780-b3d58c00-a17e-11eb-8a52-b758fb0ea942.png"
|
||||
/>
|
||||
|
||||
5. Once the pop-up appears, click `Submit Order Form` - plan name should be `Hobby Dev - Free`.
|
||||
<img width="512" alt="Submit Order Form" src="https://user-images.githubusercontent.com/16905768/115323265-b4baed80-a17f-11eb-99f0-d67f019aa6df.png" />
|
||||
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.
|
||||

|
||||
|
||||
6. Once you completed the above steps, click on your newly created `Heroku Postgres` and go to its `Settings`.
|
||||

|
||||
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.
|
||||

|
||||
|
||||
7. In `Settings`, copy your URI to your Cal.com .env file and replace the `postgresql://<user>:<pass>@<db-host>:<db-port>` with it.
|
||||

|
||||

|
||||
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/).
|
||||
</details>
|
||||
<img
|
||||
width="512"
|
||||
alt="Submit Order Form"
|
||||
src="https://user-images.githubusercontent.com/16905768/115323265-b4baed80-a17f-11eb-99f0-d67f019aa6df.png"
|
||||
/>
|
||||
|
||||
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`.
|
||||

|
||||
|
||||
```sh
|
||||
npx prisma migrate deploy
|
||||
```
|
||||
7. In `Settings`, copy your URI to your Cal.com .env file and replace the `postgresql://<user>:<pass>@<db-host>:<db-port>` with it.
|
||||

|
||||

|
||||
|
||||
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/).
|
||||
</details>
|
||||
|
||||
```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
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
# - Acquire a commercial license to remove these terms by visiting: cal.com/sales
|
||||
NEXT_PUBLIC_LICENSE_CONSENT=''
|
||||
|
||||
# DATABASE_URL='postgresql://<user>:<pass>@<db-host>:<db-port>/<db-name>'
|
||||
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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "@calcom/prisma/client";
|
||||
@@ -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";
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
# this file is a helper to run Cal.com locally
|
||||
# starts a postgres instance on port 5450 to use as a local db
|
||||
version: "3.6"
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13
|
||||
ports:
|
||||
- "5450:5432" # expose pg on port 5450 to not collide with pg from elswhere
|
||||
restart: always
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_DB: "cal-saml"
|
||||
POSTGRES_PASSWORD: ""
|
||||
POSTGRES_HOST_AUTH_METHOD: trust
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
postgres_is_ready:
|
||||
image: postgres
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
db_data:
|
||||
@@ -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";
|
||||
@@ -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";
|
||||
@@ -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
|
||||
|
||||
+6
-30
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import { Browser, chromium } from "@playwright/test";
|
||||
import fs from "fs";
|
||||
|
||||
async function loginAsUser(username: string, browser: Browser) {
|
||||
// Skip is file exists
|
||||
if (fs.existsSync(`playwright/artifacts/${username}StorageState.json`)) return;
|
||||
const page = await browser.newPage();
|
||||
await page.goto(`${process.env.PLAYWRIGHT_TEST_BASE_URL}/auth/login`);
|
||||
// Click input[name="email"]
|
||||
await page.click('input[name="email"]');
|
||||
// Fill input[name="email"]
|
||||
await page.fill('input[name="email"]', `${username}@example.com`);
|
||||
// Press Tab
|
||||
await page.press('input[name="email"]', "Tab");
|
||||
// Fill input[name="password"]
|
||||
await page.fill('input[name="password"]', username);
|
||||
// Press Enter
|
||||
await page.press('input[name="password"]', "Enter");
|
||||
await page.waitForSelector(
|
||||
username === "onboarding" ? "[data-testid=onboarding]" : "[data-testid=dashboard-shell]"
|
||||
);
|
||||
// Save signed-in state to '${username}StorageState.json'.
|
||||
await page.context().storageState({ path: `playwright/artifacts/${username}StorageState.json` });
|
||||
await page.context().close();
|
||||
}
|
||||
|
||||
async function globalSetup(/* config: FullConfig */) {
|
||||
const browser = await chromium.launch();
|
||||
await loginAsUser("onboarding", browser);
|
||||
// await loginAsUser("free-first-hidden", browser);
|
||||
await loginAsUser("pro", browser);
|
||||
await loginAsUser("trial", browser);
|
||||
await loginAsUser("free", browser);
|
||||
// await loginAsUser("usa", browser);
|
||||
// await loginAsUser("teamfree", browser);
|
||||
await loginAsUser("teampro", browser);
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
export default globalSetup;
|
||||
@@ -1,50 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "EventType" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"slug" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"locations" JSONB,
|
||||
"length" INTEGER NOT NULL,
|
||||
"hidden" BOOLEAN NOT NULL DEFAULT false,
|
||||
"userId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Credential" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"key" JSONB NOT NULL,
|
||||
"userId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "users" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"username" TEXT,
|
||||
"name" TEXT,
|
||||
"email" TEXT,
|
||||
"password" TEXT,
|
||||
"bio" TEXT,
|
||||
"avatar" TEXT,
|
||||
"timeZone" TEXT NOT NULL DEFAULT E'Europe/London',
|
||||
"weekStart" TEXT DEFAULT E'Sunday',
|
||||
"startTime" INTEGER NOT NULL DEFAULT 0,
|
||||
"endTime" INTEGER NOT NULL DEFAULT 1440,
|
||||
"created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users.email_unique" ON "users"("email");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventType" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Credential" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,48 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "BookingReference" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"uid" TEXT NOT NULL,
|
||||
"bookingId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Attendee" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"timeZone" TEXT NOT NULL,
|
||||
"bookingId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Booking" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"uid" TEXT NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
"title" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"startTime" TIMESTAMP(3) NOT NULL,
|
||||
"endTime" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Attendee" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Booking" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Booking" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BookingReference" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[uid]` on the table `Booking` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Booking.uid_unique" ON "Booking"("uid");
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "MembershipRole" AS ENUM ('MEMBER', 'OWNER');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Team" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Membership" (
|
||||
"teamId" INTEGER NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"accepted" BOOLEAN NOT NULL DEFAULT false,
|
||||
"role" "MembershipRole" NOT NULL,
|
||||
|
||||
PRIMARY KEY ("userId","teamId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,11 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "SelectedCalendar" (
|
||||
"userId" INTEGER NOT NULL,
|
||||
"integration" TEXT NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY ("userId","integration","externalId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "eventName" TEXT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "bufferTime" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -1,20 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "emailVerified" TIMESTAMP(3);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "VerificationRequest" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "VerificationRequest.token_unique" ON "VerificationRequest"("token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "VerificationRequest.identifier_token_unique" ON "VerificationRequest"("identifier", "token");
|
||||
@@ -1,13 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "EventTypeCustomInput" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"eventTypeId" INTEGER NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"required" BOOLEAN NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,10 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ResetPasswordRequest" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "hideBranding" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -1,22 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "timeZone" TEXT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Availability" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"label" TEXT,
|
||||
"userId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
"days" INTEGER[],
|
||||
"startTime" INTEGER NOT NULL,
|
||||
"endTime" INTEGER NOT NULL,
|
||||
"date" DATE,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "theme" TEXT;
|
||||
@@ -1,6 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "periodCountCalendarDays" BOOLEAN,
|
||||
ADD COLUMN "periodDays" INTEGER,
|
||||
ADD COLUMN "periodEndDate" TIMESTAMP(3),
|
||||
ADD COLUMN "periodStartDate" TIMESTAMP(3),
|
||||
ADD COLUMN "periodType" TEXT DEFAULT E'unlimited';
|
||||
@@ -1,6 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "confirmed" BOOLEAN NOT NULL DEFAULT true,
|
||||
ADD COLUMN "rejected" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "requiresConfirmation" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -1,13 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ReminderType" AS ENUM ('PENDING_BOOKING_CONFIRMATION');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ReminderMail" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"referenceId" INTEGER NOT NULL,
|
||||
"reminderType" "ReminderType" NOT NULL,
|
||||
"elapsedMinutes" INTEGER NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "minimumBookingNotice" INTEGER NOT NULL DEFAULT 120;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "location" TEXT;
|
||||
@@ -1,35 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PaymentType" AS ENUM ('STRIPE');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "paid" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "currency" TEXT NOT NULL DEFAULT E'usd',
|
||||
ADD COLUMN "price" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Payment" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"uid" TEXT NOT NULL,
|
||||
"type" "PaymentType" NOT NULL,
|
||||
"bookingId" INTEGER NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"fee" INTEGER NOT NULL,
|
||||
"currency" TEXT NOT NULL,
|
||||
"success" BOOLEAN NOT NULL,
|
||||
"refunded" BOOLEAN NOT NULL,
|
||||
"data" JSONB NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Payment.uid_unique" ON "Payment"("uid");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Payment.externalId_unique" ON "Payment"("externalId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" ADD COLUMN "slug" TEXT;
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EventTypeCustomInputType" AS ENUM ('text', 'textLong', 'number', 'bool');
|
||||
|
||||
--- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" RENAME COLUMN "type" TO "type_old";
|
||||
ALTER TABLE "EventTypeCustomInput" ADD COLUMN "type" "EventTypeCustomInputType";
|
||||
|
||||
-- UpdateTable
|
||||
UPDATE "EventTypeCustomInput" SET "type" = CAST( "type_old" AS "EventTypeCustomInputType" );
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" ALTER COLUMN "type" SET NOT NULL;
|
||||
ALTER TABLE "EventTypeCustomInput" DROP COLUMN "type_old";
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventTypeCustomInput" ADD COLUMN "placeholder" TEXT NOT NULL DEFAULT E'';
|
||||
@@ -1,4 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Team" ADD COLUMN "bio" TEXT,
|
||||
ADD COLUMN "hideBranding" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "logo" TEXT;
|
||||
@@ -1,19 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "completedOnboarding" BOOLEAN DEFAULT false;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Schedule" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
"title" TEXT,
|
||||
"freeBusyTimes" JSONB,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[slug]` on the table `Team` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Team.slug_unique" ON "Team"("slug");
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[userId,slug]` on the table `EventType` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventType.userId_slug_unique" ON "EventType"("userId", "slug");
|
||||
@@ -1,5 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "UserPlan" AS ENUM ('FREE', 'TRIAL', 'PRO');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "plan" "UserPlan" NOT NULL DEFAULT E'PRO';
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[username]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "users.username_unique" ON "users"("username");
|
||||
@@ -1,5 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "BookingStatus" AS ENUM ('cancelled', 'accepted', 'rejected', 'pending');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "status" "BookingStatus" NOT NULL DEFAULT E'accepted';
|
||||
@@ -1,30 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "SchedulingType" AS ENUM ('roundRobin', 'collective');
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "EventType" DROP CONSTRAINT "EventType_userId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "schedulingType" "SchedulingType",
|
||||
ADD COLUMN "teamId" INTEGER;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "_user_eventtype" (
|
||||
"A" INTEGER NOT NULL,
|
||||
"B" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "_user_eventtype_AB_unique" ON "_user_eventtype"("A", "B");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "_user_eventtype_B_index" ON "_user_eventtype"("B");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventType" ADD FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_user_eventtype" ADD FOREIGN KEY ("A") REFERENCES "EventType"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "_user_eventtype" ADD FOREIGN KEY ("B") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,15 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "DailyEventReference" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"dailyurl" TEXT NOT NULL DEFAULT E'dailycallurl',
|
||||
"dailytoken" TEXT NOT NULL DEFAULT E'dailytoken',
|
||||
"bookingId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DailyEventReference_bookingId_unique" ON "DailyEventReference"("bookingId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DailyEventReference" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "EventType.userId_slug_unique";
|
||||
@@ -1,4 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "BookingReference" ADD COLUMN "meetingId" TEXT,
|
||||
ADD COLUMN "meetingPassword" TEXT,
|
||||
ADD COLUMN "meetingUrl" TEXT;
|
||||
@@ -1,3 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "twoFactorEnabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN "twoFactorSecret" TEXT;
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[userId,slug]` on the table `EventType` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EventType.userId_slug_unique" ON "EventType"("userId", "slug");
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "locale" TEXT;
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "disableGuests" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -1,17 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "WebhookTriggerEvents" AS ENUM ('BOOKING_CREATED', 'BOOKING_RESCHEDULED', 'BOOKING_CANCELLED');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Webhook" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"subscriberUrl" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"active" BOOLEAN NOT NULL DEFAULT true,
|
||||
"eventTriggers" "WebhookTriggerEvents"[],
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Webhook.id_unique" ON "Webhook"("id");
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Made the column `periodType` on table `EventType` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `email` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `weekStart` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
- Made the column `completedOnboarding` on table `users` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ALTER COLUMN "periodType" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ALTER COLUMN "email" SET NOT NULL,
|
||||
ALTER COLUMN "weekStart" SET NOT NULL,
|
||||
ALTER COLUMN "completedOnboarding" SET NOT NULL;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1 +0,0 @@
|
||||
UPDATE "Booking" SET "status" = 'rejected' WHERE "rejected" = TRUE;
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
-- This is an empty migration.
|
||||
|
||||
ALTER TABLE "Availability" RENAME COLUMN "startTime" to "old_startTime";
|
||||
ALTER TABLE "Availability" RENAME COLUMN "endTime" to "old_endTime";
|
||||
ALTER TABLE "Availability" ADD COLUMN "startTime" TIME;
|
||||
ALTER TABLE "Availability" ADD COLUMN "endTime" TIME;
|
||||
|
||||
UPDATE "Availability" SET "startTime" = CAST(CONCAT(CAST(("old_startTime" / 60) AS text), ':00') AS time);
|
||||
UPDATE "Availability" SET "endTime" = CAST(CONCAT(CAST(("old_endTime" / 60) AS text), ':00') AS time);
|
||||
|
||||
ALTER TABLE "Availability" DROP COLUMN "old_startTime";
|
||||
ALTER TABLE "Availability" DROP COLUMN "old_endTime";
|
||||
ALTER TABLE "Availability" ALTER COLUMN "startTime" SET NOT NULL;
|
||||
ALTER TABLE "Availability" ALTER COLUMN "endTime" SET NOT NULL;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "position" INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -1,3 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "brandColor" TEXT NOT NULL DEFAULT E'#292929';
|
||||
UPDATE "users" SET "brandColor" = '#292929';
|
||||
@@ -1,6 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "IdentityProvider" AS ENUM ('CAL', 'GOOGLE');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "identityProvider" "IdentityProvider" NOT NULL DEFAULT E'CAL',
|
||||
ADD COLUMN "identityProviderId" TEXT;
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The `periodType` column on the `EventType` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "PeriodType" AS ENUM ('unlimited', 'rolling', 'range');
|
||||
|
||||
-- AlterTable
|
||||
|
||||
ALTER TABLE "EventType" RENAME COLUMN "periodType" to "old_periodType";
|
||||
ALTER TABLE "EventType" ADD COLUMN "periodType" "PeriodType" NOT NULL DEFAULT E'unlimited';
|
||||
|
||||
UPDATE "EventType" SET "periodType" = "old_periodType"::"PeriodType";
|
||||
ALTER TABLE "EventType" DROP COLUMN "old_periodType";
|
||||
@@ -1,2 +0,0 @@
|
||||
-- add the new value to the existing type
|
||||
ALTER TYPE "IdentityProvider" ADD VALUE 'SAML';
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
insert into "Availability" ("userId", "startTime", "endTime", "days")
|
||||
select
|
||||
id as "userId",
|
||||
CAST(CONCAT(CAST(("startTime") AS text), ' minute')::interval AS time) as "startTime",
|
||||
CAST(CONCAT(CAST(("endTime") AS text), ' minute')::interval AS time) as "endTime",
|
||||
ARRAY [0,1,2,3,4,5,6]
|
||||
from
|
||||
(
|
||||
select
|
||||
users.id,
|
||||
users."startTime",
|
||||
users."endTime",
|
||||
users."timeZone",
|
||||
count("Availability".id) as availability_count
|
||||
from users
|
||||
left join "Availability" on "Availability"."userId" = users.id
|
||||
group by users.id
|
||||
) usersWithAvailabilityNumber
|
||||
where availability_count < 1
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Webhook" ADD COLUMN "payloadTemplate" TEXT;
|
||||
@@ -1,29 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "DestinationCalendar" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"integration" TEXT NOT NULL,
|
||||
"externalId" TEXT NOT NULL,
|
||||
"userId" INTEGER,
|
||||
"bookingId" INTEGER,
|
||||
"eventTypeId" INTEGER,
|
||||
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.userId_unique" ON "DestinationCalendar"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.bookingId_unique" ON "DestinationCalendar"("bookingId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DestinationCalendar.eventTypeId_unique" ON "DestinationCalendar"("eventTypeId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DestinationCalendar" ADD FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterEnum
|
||||
ALTER TYPE "MembershipRole" ADD VALUE 'ADMIN';
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "invitedTo" INTEGER;
|
||||
@@ -1,74 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" DROP CONSTRAINT "EventTypeCustomInput_eventTypeId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_teamId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Payment" DROP CONSTRAINT "Payment_bookingId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "SelectedCalendar" DROP CONSTRAINT "SelectedCalendar_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Webhook" DROP CONSTRAINT "Webhook_userId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD CONSTRAINT "SelectedCalendar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EventTypeCustomInput" ADD CONSTRAINT "EventTypeCustomInput_eventTypeId_fkey" FOREIGN KEY ("eventTypeId") REFERENCES "EventType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Booking.uid_unique" RENAME TO "Booking_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.bookingId_unique" RENAME TO "DestinationCalendar_bookingId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.eventTypeId_unique" RENAME TO "DestinationCalendar_eventTypeId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar.userId_unique" RENAME TO "DestinationCalendar_userId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "EventType.userId_slug_unique" RENAME TO "EventType_userId_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.externalId_unique" RENAME TO "Payment_externalId_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment.uid_unique" RENAME TO "Payment_uid_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Team.slug_unique" RENAME TO "Team_slug_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest.identifier_token_unique" RENAME TO "VerificationRequest_identifier_token_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest.token_unique" RENAME TO "VerificationRequest_token_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Webhook.id_unique" RENAME TO "Webhook_id_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.email_unique" RENAME TO "users_email_key";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users.username_unique" RENAME TO "users_username_key";
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "slotInterval" INTEGER;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- UpdateTable
|
||||
UPDATE users SET email=LOWER(email);
|
||||
@@ -1,38 +0,0 @@
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Booking_uid_key" RENAME TO "Booking.uid_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_bookingId_key" RENAME TO "DestinationCalendar.bookingId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_eventTypeId_key" RENAME TO "DestinationCalendar.eventTypeId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "DestinationCalendar_userId_key" RENAME TO "DestinationCalendar.userId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "EventType_userId_slug_key" RENAME TO "EventType.userId_slug_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment_externalId_key" RENAME TO "Payment.externalId_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Payment_uid_key" RENAME TO "Payment.uid_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Team_slug_key" RENAME TO "Team.slug_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest_identifier_token_key" RENAME TO "VerificationRequest.identifier_token_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "VerificationRequest_token_key" RENAME TO "VerificationRequest.token_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "Webhook_id_key" RENAME TO "Webhook.id_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users_email_key" RENAME TO "users.email_unique";
|
||||
|
||||
-- RenameIndex
|
||||
ALTER INDEX "users_username_key" RENAME TO "users.username_unique";
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" ADD COLUMN "scAddress" TEXT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "metadata" JSONB;
|
||||
@@ -1,35 +0,0 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Availability" DROP CONSTRAINT "Availability_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Credential" DROP CONSTRAINT "Credential_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Membership" DROP CONSTRAINT "Membership_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Schedule" DROP CONSTRAINT "Schedule_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "SelectedCalendar" DROP CONSTRAINT "SelectedCalendar_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Webhook" DROP CONSTRAINT "Webhook_userId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Credential" ADD CONSTRAINT "Credential_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Membership" ADD CONSTRAINT "Membership_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Schedule" ADD CONSTRAINT "Schedule_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD CONSTRAINT "Availability_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "SelectedCalendar" ADD CONSTRAINT "SelectedCalendar_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Webhook" ADD CONSTRAINT "Webhook_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "away" BOOLEAN NOT NULL DEFAULT false;
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" DROP COLUMN "scAddress",
|
||||
ADD COLUMN "smartContractAddress" TEXT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ALTER COLUMN "plan" SET DEFAULT E'TRIAL';
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "cancellationReason" TEXT;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Attendee" ADD COLUMN "locale" TEXT DEFAULT E'en';
|
||||
-1
@@ -1 +0,0 @@
|
||||
ALTER TABLE "EventType" ADD COLUMN "metadata" JSONB;
|
||||
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `smartContractAddress` on the `EventType` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EventType" DROP COLUMN IF EXISTS "smartContractAddress";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "verified" BOOLEAN DEFAULT false;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Booking" ADD COLUMN "rejectionReason" TEXT;
|
||||
@@ -1,3 +0,0 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "postgresql"
|
||||
@@ -1,354 +0,0 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
generator zod {
|
||||
provider = "zod-prisma"
|
||||
output = "./zod"
|
||||
imports = "./zod-utils"
|
||||
relationModel = "default"
|
||||
}
|
||||
|
||||
enum SchedulingType {
|
||||
ROUND_ROBIN @map("roundRobin")
|
||||
COLLECTIVE @map("collective")
|
||||
}
|
||||
|
||||
enum PeriodType {
|
||||
UNLIMITED @map("unlimited")
|
||||
ROLLING @map("rolling")
|
||||
RANGE @map("range")
|
||||
}
|
||||
|
||||
model EventType {
|
||||
id Int @id @default(autoincrement())
|
||||
/// @zod.nonempty()
|
||||
title String
|
||||
/// @zod.custom(imports.eventTypeSlug)
|
||||
slug String
|
||||
description String?
|
||||
position Int @default(0)
|
||||
/// @zod.custom(imports.eventTypeLocations)
|
||||
locations Json?
|
||||
length Int
|
||||
hidden Boolean @default(false)
|
||||
users User[] @relation("user_eventtype")
|
||||
userId Int?
|
||||
team Team? @relation(fields: [teamId], references: [id])
|
||||
teamId Int?
|
||||
bookings Booking[]
|
||||
availability Availability[]
|
||||
destinationCalendar DestinationCalendar?
|
||||
eventName String?
|
||||
customInputs EventTypeCustomInput[]
|
||||
timeZone String?
|
||||
periodType PeriodType @default(UNLIMITED)
|
||||
periodStartDate DateTime?
|
||||
periodEndDate DateTime?
|
||||
periodDays Int?
|
||||
periodCountCalendarDays Boolean?
|
||||
requiresConfirmation Boolean @default(false)
|
||||
disableGuests Boolean @default(false)
|
||||
minimumBookingNotice Int @default(120)
|
||||
schedulingType SchedulingType?
|
||||
Schedule Schedule[]
|
||||
price Int @default(0)
|
||||
currency String @default("usd")
|
||||
slotInterval Int?
|
||||
metadata Json?
|
||||
|
||||
@@unique([userId, slug])
|
||||
}
|
||||
|
||||
model Credential {
|
||||
id Int @id @default(autoincrement())
|
||||
type String
|
||||
key Json
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
}
|
||||
|
||||
enum UserPlan {
|
||||
FREE
|
||||
TRIAL
|
||||
PRO
|
||||
}
|
||||
|
||||
enum IdentityProvider {
|
||||
CAL
|
||||
GOOGLE
|
||||
SAML
|
||||
}
|
||||
|
||||
model DestinationCalendar {
|
||||
id Int @id @default(autoincrement())
|
||||
integration String
|
||||
externalId String
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId Int? @unique
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
bookingId Int? @unique
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int? @unique
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String? @unique
|
||||
name String?
|
||||
/// @zod.email()
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
password String?
|
||||
bio String?
|
||||
avatar String?
|
||||
timeZone String @default("Europe/London")
|
||||
weekStart String @default("Sunday")
|
||||
// DEPRECATED - TO BE REMOVED
|
||||
startTime Int @default(0)
|
||||
endTime Int @default(1440)
|
||||
// </DEPRECATED>
|
||||
bufferTime Int @default(0)
|
||||
hideBranding Boolean @default(false)
|
||||
theme String?
|
||||
createdDate DateTime @default(now()) @map(name: "created")
|
||||
eventTypes EventType[] @relation("user_eventtype")
|
||||
credentials Credential[]
|
||||
teams Membership[]
|
||||
bookings Booking[]
|
||||
availability Availability[]
|
||||
selectedCalendars SelectedCalendar[]
|
||||
completedOnboarding Boolean @default(false)
|
||||
locale String?
|
||||
twoFactorSecret String?
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
identityProvider IdentityProvider @default(CAL)
|
||||
identityProviderId String?
|
||||
invitedTo Int?
|
||||
plan UserPlan @default(TRIAL)
|
||||
Schedule Schedule[]
|
||||
webhooks Webhook[]
|
||||
brandColor String @default("#292929")
|
||||
// the location where the events will end up
|
||||
destinationCalendar DestinationCalendar?
|
||||
away Boolean @default(false)
|
||||
metadata Json?
|
||||
verified Boolean? @default(false)
|
||||
|
||||
@@map(name: "users")
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
slug String? @unique
|
||||
logo String?
|
||||
bio String?
|
||||
hideBranding Boolean @default(false)
|
||||
members Membership[]
|
||||
eventTypes EventType[]
|
||||
}
|
||||
|
||||
enum MembershipRole {
|
||||
MEMBER
|
||||
ADMIN
|
||||
OWNER
|
||||
}
|
||||
|
||||
model Membership {
|
||||
teamId Int
|
||||
userId Int
|
||||
accepted Boolean @default(false)
|
||||
role MembershipRole
|
||||
team Team @relation(fields: [teamId], references: [id])
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([userId, teamId])
|
||||
}
|
||||
|
||||
model VerificationRequest {
|
||||
id Int @id @default(autoincrement())
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
||||
model BookingReference {
|
||||
id Int @id @default(autoincrement())
|
||||
type String
|
||||
uid String
|
||||
meetingId String?
|
||||
meetingPassword String?
|
||||
meetingUrl String?
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
bookingId Int?
|
||||
}
|
||||
|
||||
model Attendee {
|
||||
id Int @id @default(autoincrement())
|
||||
email String
|
||||
name String
|
||||
timeZone String
|
||||
locale String? @default("en")
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
bookingId Int?
|
||||
}
|
||||
|
||||
enum BookingStatus {
|
||||
CANCELLED @map("cancelled")
|
||||
ACCEPTED @map("accepted")
|
||||
REJECTED @map("rejected")
|
||||
PENDING @map("pending")
|
||||
}
|
||||
|
||||
model DailyEventReference {
|
||||
id Int @id @default(autoincrement())
|
||||
dailyurl String @default("dailycallurl")
|
||||
dailytoken String @default("dailytoken")
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
bookingId Int? @unique
|
||||
}
|
||||
|
||||
model Booking {
|
||||
id Int @id @default(autoincrement())
|
||||
uid String @unique
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
userId Int?
|
||||
references BookingReference[]
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int?
|
||||
title String
|
||||
description String?
|
||||
startTime DateTime
|
||||
endTime DateTime
|
||||
attendees Attendee[]
|
||||
location String?
|
||||
dailyRef DailyEventReference?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime?
|
||||
confirmed Boolean @default(true)
|
||||
rejected Boolean @default(false)
|
||||
status BookingStatus @default(ACCEPTED)
|
||||
paid Boolean @default(false)
|
||||
payment Payment[]
|
||||
destinationCalendar DestinationCalendar?
|
||||
cancellationReason String?
|
||||
rejectionReason String?
|
||||
}
|
||||
|
||||
model Schedule {
|
||||
id Int @id @default(autoincrement())
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int?
|
||||
title String?
|
||||
freeBusyTimes Json?
|
||||
}
|
||||
|
||||
model Availability {
|
||||
id Int @id @default(autoincrement())
|
||||
label String?
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int?
|
||||
days Int[]
|
||||
startTime DateTime @db.Time
|
||||
endTime DateTime @db.Time
|
||||
date DateTime? @db.Date
|
||||
}
|
||||
|
||||
model SelectedCalendar {
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int
|
||||
integration String
|
||||
externalId String
|
||||
|
||||
@@id([userId, integration, externalId])
|
||||
}
|
||||
|
||||
enum EventTypeCustomInputType {
|
||||
TEXT @map("text")
|
||||
TEXTLONG @map("textLong")
|
||||
NUMBER @map("number")
|
||||
BOOL @map("bool")
|
||||
}
|
||||
|
||||
model EventTypeCustomInput {
|
||||
id Int @id @default(autoincrement())
|
||||
eventTypeId Int
|
||||
eventType EventType @relation(fields: [eventTypeId], references: [id])
|
||||
label String
|
||||
type EventTypeCustomInputType
|
||||
required Boolean
|
||||
placeholder String @default("")
|
||||
}
|
||||
|
||||
model ResetPasswordRequest {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
email String
|
||||
expires DateTime
|
||||
}
|
||||
|
||||
enum ReminderType {
|
||||
PENDING_BOOKING_CONFIRMATION
|
||||
}
|
||||
|
||||
model ReminderMail {
|
||||
id Int @id @default(autoincrement())
|
||||
referenceId Int
|
||||
reminderType ReminderType
|
||||
elapsedMinutes Int
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
enum PaymentType {
|
||||
STRIPE
|
||||
}
|
||||
|
||||
model Payment {
|
||||
id Int @id @default(autoincrement())
|
||||
uid String @unique
|
||||
type PaymentType
|
||||
bookingId Int
|
||||
booking Booking? @relation(fields: [bookingId], references: [id])
|
||||
amount Int
|
||||
fee Int
|
||||
currency String
|
||||
success Boolean
|
||||
refunded Boolean
|
||||
data Json
|
||||
externalId String @unique
|
||||
}
|
||||
|
||||
enum WebhookTriggerEvents {
|
||||
BOOKING_CREATED
|
||||
BOOKING_RESCHEDULED
|
||||
BOOKING_CANCELLED
|
||||
}
|
||||
|
||||
model Webhook {
|
||||
id String @id @unique
|
||||
userId Int
|
||||
subscriberUrl String
|
||||
payloadTemplate String?
|
||||
createdAt DateTime @default(now())
|
||||
active Boolean @default(true)
|
||||
eventTriggers WebhookTriggerEvents[]
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
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";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function createUserAndEventType(opts: {
|
||||
user: {
|
||||
email: string;
|
||||
password: string;
|
||||
username: string;
|
||||
plan: UserPlan;
|
||||
name: string;
|
||||
completedOnboarding?: boolean;
|
||||
timeZone?: string;
|
||||
};
|
||||
eventTypes: Array<
|
||||
Prisma.EventTypeCreateInput & {
|
||||
_bookings?: Prisma.BookingCreateInput[];
|
||||
}
|
||||
>;
|
||||
}) {
|
||||
const userData: Prisma.UserCreateArgs["data"] = {
|
||||
...opts.user,
|
||||
password: await hashPassword(opts.user.password),
|
||||
emailVerified: new Date(),
|
||||
completedOnboarding: opts.user.completedOnboarding ?? true,
|
||||
locale: "en",
|
||||
availability: {
|
||||
createMany: {
|
||||
data: getAvailabilityFromSchedule(DEFAULT_SCHEDULE),
|
||||
},
|
||||
},
|
||||
};
|
||||
const user = await prisma.user.upsert({
|
||||
where: { email: opts.user.email },
|
||||
update: userData,
|
||||
create: userData,
|
||||
});
|
||||
|
||||
console.log(
|
||||
`👤 Upserted '${opts.user.username}' with email "${opts.user.email}" & password "${opts.user.password}". Booking page 👉 ${process.env.BASE_URL}/${opts.user.username}`
|
||||
);
|
||||
|
||||
for (const eventTypeInput of opts.eventTypes) {
|
||||
const { _bookings: bookingInputs = [], ...eventTypeData } = eventTypeInput;
|
||||
eventTypeData.userId = user.id;
|
||||
eventTypeData.users = { connect: { id: user.id } };
|
||||
|
||||
const eventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
slug: eventTypeData.slug,
|
||||
users: {
|
||||
some: {
|
||||
id: eventTypeData.userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (eventType) {
|
||||
console.log(
|
||||
`\t📆 Event type ${eventTypeData.slug} already seems seeded - ${process.env.BASE_URL}/${user.username}/${eventTypeData.slug}`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const { id } = await prisma.eventType.create({
|
||||
data: eventTypeData,
|
||||
});
|
||||
|
||||
console.log(
|
||||
`\t📆 Event type ${eventTypeData.slug}, length ${eventTypeData.length}min - ${process.env.BASE_URL}/${user.username}/${eventTypeData.slug}`
|
||||
);
|
||||
for (const bookingInput of bookingInputs) {
|
||||
await prisma.booking.create({
|
||||
data: {
|
||||
...bookingInput,
|
||||
user: {
|
||||
connect: {
|
||||
email: opts.user.email,
|
||||
},
|
||||
},
|
||||
attendees: {
|
||||
create: {
|
||||
email: opts.user.email,
|
||||
name: opts.user.name,
|
||||
timeZone: "Europe/London",
|
||||
},
|
||||
},
|
||||
eventType: {
|
||||
connect: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
confirmed: bookingInput.confirmed,
|
||||
},
|
||||
});
|
||||
console.log(
|
||||
`\t\t☎️ Created booking ${bookingInput.title} at ${new Date(
|
||||
bookingInput.startTime
|
||||
).toLocaleDateString()}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
async function createTeamAndAddUsers(
|
||||
teamInput: Prisma.TeamCreateInput,
|
||||
users: { id: number; username: string; role?: MembershipRole }[]
|
||||
) {
|
||||
const createTeam = async (team: Prisma.TeamCreateInput) => {
|
||||
try {
|
||||
return await prisma.team.create({
|
||||
data: {
|
||||
...team,
|
||||
},
|
||||
});
|
||||
} catch (_err) {
|
||||
if (_err instanceof Error && _err.message.indexOf("Unique constraint failed on the fields") !== -1) {
|
||||
console.log(`Team '${team.name}' already exists, skipping.`);
|
||||
return;
|
||||
}
|
||||
throw _err;
|
||||
}
|
||||
};
|
||||
|
||||
const team = await createTeam(teamInput);
|
||||
if (!team) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`🏢 Created team '${teamInput.name}' - ${process.env.BASE_URL}/team/${team.slug}`);
|
||||
|
||||
for (const user of users) {
|
||||
const { role = MembershipRole.OWNER, id, username } = user;
|
||||
await prisma.membership.create({
|
||||
data: {
|
||||
teamId: team.id,
|
||||
userId: id,
|
||||
role: role,
|
||||
accepted: true,
|
||||
},
|
||||
});
|
||||
console.log(`\t👤 Added '${teamInput.name}' membership for '${username}' with role '${role}'`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "delete-me",
|
||||
username: "delete-me",
|
||||
name: "delete-me",
|
||||
plan: "FREE",
|
||||
},
|
||||
eventTypes: [],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "onboarding",
|
||||
username: "onboarding",
|
||||
name: "onboarding",
|
||||
plan: "TRIAL",
|
||||
completedOnboarding: false,
|
||||
},
|
||||
eventTypes: [],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "free-first-hidden",
|
||||
username: "free-first-hidden",
|
||||
name: "Free First Hidden Example",
|
||||
plan: "FREE",
|
||||
},
|
||||
eventTypes: [
|
||||
{
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
length: 30,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
title: "60min",
|
||||
slug: "60min",
|
||||
length: 30,
|
||||
},
|
||||
],
|
||||
});
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
name: "Pro Example",
|
||||
password: "pro",
|
||||
username: "pro",
|
||||
plan: "PRO",
|
||||
},
|
||||
|
||||
eventTypes: [
|
||||
{
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
length: 30,
|
||||
_bookings: [
|
||||
{
|
||||
uid: uuid(),
|
||||
title: "30min",
|
||||
startTime: dayjs().add(1, "day").toDate(),
|
||||
endTime: dayjs().add(1, "day").add(30, "minutes").toDate(),
|
||||
},
|
||||
{
|
||||
uid: uuid(),
|
||||
title: "30min",
|
||||
startTime: dayjs().add(2, "day").toDate(),
|
||||
endTime: dayjs().add(2, "day").add(30, "minutes").toDate(),
|
||||
confirmed: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "60min",
|
||||
slug: "60min",
|
||||
length: 60,
|
||||
},
|
||||
{
|
||||
title: "paid",
|
||||
slug: "paid",
|
||||
length: 60,
|
||||
price: 50,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "trial",
|
||||
username: "trial",
|
||||
name: "Trial Example",
|
||||
plan: "TRIAL",
|
||||
},
|
||||
eventTypes: [
|
||||
{
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
length: 30,
|
||||
},
|
||||
{
|
||||
title: "60min",
|
||||
slug: "60min",
|
||||
length: 60,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "free",
|
||||
username: "free",
|
||||
name: "Free Example",
|
||||
plan: "FREE",
|
||||
},
|
||||
eventTypes: [
|
||||
{
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
length: 30,
|
||||
},
|
||||
{
|
||||
title: "60min",
|
||||
slug: "60min",
|
||||
length: 30,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "usa",
|
||||
username: "usa",
|
||||
name: "USA Timezone Example",
|
||||
plan: "FREE",
|
||||
timeZone: "America/Phoenix",
|
||||
},
|
||||
eventTypes: [
|
||||
{
|
||||
title: "30min",
|
||||
slug: "30min",
|
||||
length: 30,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const freeUserTeam = await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "teamfree",
|
||||
username: "teamfree",
|
||||
name: "Team Free Example",
|
||||
plan: "FREE",
|
||||
},
|
||||
eventTypes: [],
|
||||
});
|
||||
|
||||
const proUserTeam = await createUserAndEventType({
|
||||
user: {
|
||||
email: "[email protected]",
|
||||
password: "teampro",
|
||||
username: "teampro",
|
||||
name: "Team Pro Example",
|
||||
plan: "PRO",
|
||||
},
|
||||
eventTypes: [],
|
||||
});
|
||||
|
||||
await createTeamAndAddUsers(
|
||||
{
|
||||
name: "Seeded Team",
|
||||
slug: "seeded-team",
|
||||
},
|
||||
[
|
||||
{
|
||||
id: proUserTeam.id,
|
||||
username: proUserTeam.name || "Unknown",
|
||||
},
|
||||
{
|
||||
id: freeUserTeam.id,
|
||||
username: freeUserTeam.name || "Unknown",
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => {
|
||||
console.log("🌱 Seeded db");
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { LocationType } from "@lib/location";
|
||||
|
||||
export const eventTypeLocations = z.array(
|
||||
z.object({ type: z.nativeEnum(LocationType), address: z.string().optional() })
|
||||
);
|
||||
|
||||
export const eventTypeSlug = z.string().transform((val) => val.trim());
|
||||
export const stringToDate = z.string().transform((a) => new Date(a));
|
||||
export const stringOrNumber = z.union([z.string().transform((v) => parseInt(v, 10)), z.number().int()]);
|
||||
@@ -1,27 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteBooking, BookingModel } from "./index";
|
||||
|
||||
export const _AttendeeModel = z.object({
|
||||
id: z.number().int(),
|
||||
email: z.string(),
|
||||
name: z.string(),
|
||||
timeZone: z.string(),
|
||||
locale: z.string().nullish(),
|
||||
bookingId: z.number().int().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteAttendee extends z.infer<typeof _AttendeeModel> {
|
||||
booking?: CompleteBooking | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* AttendeeModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const AttendeeModel: z.ZodSchema<CompleteAttendee> = z.lazy(() =>
|
||||
_AttendeeModel.extend({
|
||||
booking: BookingModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,31 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteUser, UserModel, CompleteEventType, EventTypeModel } from "./index";
|
||||
|
||||
export const _AvailabilityModel = z.object({
|
||||
id: z.number().int(),
|
||||
label: z.string().nullish(),
|
||||
userId: z.number().int().nullish(),
|
||||
eventTypeId: z.number().int().nullish(),
|
||||
days: z.number().int().array(),
|
||||
startTime: z.date(),
|
||||
endTime: z.date(),
|
||||
date: z.date().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteAvailability extends z.infer<typeof _AvailabilityModel> {
|
||||
user?: CompleteUser | null;
|
||||
eventType?: CompleteEventType | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* AvailabilityModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const AvailabilityModel: z.ZodSchema<CompleteAvailability> = z.lazy(() =>
|
||||
_AvailabilityModel.extend({
|
||||
user: UserModel.nullish(),
|
||||
eventType: EventTypeModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,66 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { BookingStatus } from "@prisma/client";
|
||||
import {
|
||||
CompleteUser,
|
||||
UserModel,
|
||||
CompleteBookingReference,
|
||||
BookingReferenceModel,
|
||||
CompleteEventType,
|
||||
EventTypeModel,
|
||||
CompleteAttendee,
|
||||
AttendeeModel,
|
||||
CompleteDailyEventReference,
|
||||
DailyEventReferenceModel,
|
||||
CompletePayment,
|
||||
PaymentModel,
|
||||
CompleteDestinationCalendar,
|
||||
DestinationCalendarModel,
|
||||
} from "./index";
|
||||
|
||||
export const _BookingModel = z.object({
|
||||
id: z.number().int(),
|
||||
uid: z.string(),
|
||||
userId: z.number().int().nullish(),
|
||||
eventTypeId: z.number().int().nullish(),
|
||||
title: z.string(),
|
||||
description: z.string().nullish(),
|
||||
startTime: z.date(),
|
||||
endTime: z.date(),
|
||||
location: z.string().nullish(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date().nullish(),
|
||||
confirmed: z.boolean(),
|
||||
rejected: z.boolean(),
|
||||
status: z.nativeEnum(BookingStatus),
|
||||
paid: z.boolean(),
|
||||
cancellationReason: z.string().nullish(),
|
||||
rejectionReason: z.string().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteBooking extends z.infer<typeof _BookingModel> {
|
||||
user?: CompleteUser | null;
|
||||
references: CompleteBookingReference[];
|
||||
eventType?: CompleteEventType | null;
|
||||
attendees: CompleteAttendee[];
|
||||
dailyRef?: CompleteDailyEventReference | null;
|
||||
payment: CompletePayment[];
|
||||
destinationCalendar?: CompleteDestinationCalendar | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* BookingModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const BookingModel: z.ZodSchema<CompleteBooking> = z.lazy(() =>
|
||||
_BookingModel.extend({
|
||||
user: UserModel.nullish(),
|
||||
references: BookingReferenceModel.array(),
|
||||
eventType: EventTypeModel.nullish(),
|
||||
attendees: AttendeeModel.array(),
|
||||
dailyRef: DailyEventReferenceModel.nullish(),
|
||||
payment: PaymentModel.array(),
|
||||
destinationCalendar: DestinationCalendarModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,28 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteBooking, BookingModel } from "./index";
|
||||
|
||||
export const _BookingReferenceModel = z.object({
|
||||
id: z.number().int(),
|
||||
type: z.string(),
|
||||
uid: z.string(),
|
||||
meetingId: z.string().nullish(),
|
||||
meetingPassword: z.string().nullish(),
|
||||
meetingUrl: z.string().nullish(),
|
||||
bookingId: z.number().int().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteBookingReference extends z.infer<typeof _BookingReferenceModel> {
|
||||
booking?: CompleteBooking | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* BookingReferenceModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const BookingReferenceModel: z.ZodSchema<CompleteBookingReference> = z.lazy(() =>
|
||||
_BookingReferenceModel.extend({
|
||||
booking: BookingModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,33 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteUser, UserModel } from "./index";
|
||||
|
||||
// Helper schema for JSON fields
|
||||
type Literal = boolean | number | string;
|
||||
type Json = Literal | { [key: string]: Json } | Json[];
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||
);
|
||||
|
||||
export const _CredentialModel = z.object({
|
||||
id: z.number().int(),
|
||||
type: z.string(),
|
||||
key: jsonSchema,
|
||||
userId: z.number().int().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteCredential extends z.infer<typeof _CredentialModel> {
|
||||
user?: CompleteUser | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* CredentialModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const CredentialModel: z.ZodSchema<CompleteCredential> = z.lazy(() =>
|
||||
_CredentialModel.extend({
|
||||
user: UserModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,25 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteBooking, BookingModel } from "./index";
|
||||
|
||||
export const _DailyEventReferenceModel = z.object({
|
||||
id: z.number().int(),
|
||||
dailyurl: z.string(),
|
||||
dailytoken: z.string(),
|
||||
bookingId: z.number().int().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteDailyEventReference extends z.infer<typeof _DailyEventReferenceModel> {
|
||||
booking?: CompleteBooking | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DailyEventReferenceModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const DailyEventReferenceModel: z.ZodSchema<CompleteDailyEventReference> = z.lazy(() =>
|
||||
_DailyEventReferenceModel.extend({
|
||||
booking: BookingModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,38 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import {
|
||||
CompleteUser,
|
||||
UserModel,
|
||||
CompleteBooking,
|
||||
BookingModel,
|
||||
CompleteEventType,
|
||||
EventTypeModel,
|
||||
} from "./index";
|
||||
|
||||
export const _DestinationCalendarModel = z.object({
|
||||
id: z.number().int(),
|
||||
integration: z.string(),
|
||||
externalId: z.string(),
|
||||
userId: z.number().int().nullish(),
|
||||
bookingId: z.number().int().nullish(),
|
||||
eventTypeId: z.number().int().nullish(),
|
||||
});
|
||||
|
||||
export interface CompleteDestinationCalendar extends z.infer<typeof _DestinationCalendarModel> {
|
||||
user?: CompleteUser | null;
|
||||
booking?: CompleteBooking | null;
|
||||
eventType?: CompleteEventType | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DestinationCalendarModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const DestinationCalendarModel: z.ZodSchema<CompleteDestinationCalendar> = z.lazy(() =>
|
||||
_DestinationCalendarModel.extend({
|
||||
user: UserModel.nullish(),
|
||||
booking: BookingModel.nullish(),
|
||||
eventType: EventTypeModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,82 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { PeriodType, SchedulingType } from "@prisma/client";
|
||||
import {
|
||||
CompleteUser,
|
||||
UserModel,
|
||||
CompleteTeam,
|
||||
TeamModel,
|
||||
CompleteBooking,
|
||||
BookingModel,
|
||||
CompleteAvailability,
|
||||
AvailabilityModel,
|
||||
CompleteDestinationCalendar,
|
||||
DestinationCalendarModel,
|
||||
CompleteEventTypeCustomInput,
|
||||
EventTypeCustomInputModel,
|
||||
CompleteSchedule,
|
||||
ScheduleModel,
|
||||
} from "./index";
|
||||
|
||||
// Helper schema for JSON fields
|
||||
type Literal = boolean | number | string;
|
||||
type Json = Literal | { [key: string]: Json } | Json[];
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||
);
|
||||
|
||||
export const _EventTypeModel = z.object({
|
||||
id: z.number().int(),
|
||||
title: z.string().nonempty(),
|
||||
slug: imports.eventTypeSlug,
|
||||
description: z.string().nullish(),
|
||||
position: z.number().int(),
|
||||
locations: imports.eventTypeLocations,
|
||||
length: z.number().int(),
|
||||
hidden: z.boolean(),
|
||||
userId: z.number().int().nullish(),
|
||||
teamId: z.number().int().nullish(),
|
||||
eventName: z.string().nullish(),
|
||||
timeZone: z.string().nullish(),
|
||||
periodType: z.nativeEnum(PeriodType),
|
||||
periodStartDate: z.date().nullish(),
|
||||
periodEndDate: z.date().nullish(),
|
||||
periodDays: z.number().int().nullish(),
|
||||
periodCountCalendarDays: z.boolean().nullish(),
|
||||
requiresConfirmation: z.boolean(),
|
||||
disableGuests: z.boolean(),
|
||||
minimumBookingNotice: z.number().int(),
|
||||
schedulingType: z.nativeEnum(SchedulingType).nullish(),
|
||||
price: z.number().int(),
|
||||
currency: z.string(),
|
||||
slotInterval: z.number().int().nullish(),
|
||||
metadata: jsonSchema,
|
||||
});
|
||||
|
||||
export interface CompleteEventType extends z.infer<typeof _EventTypeModel> {
|
||||
users: CompleteUser[];
|
||||
team?: CompleteTeam | null;
|
||||
bookings: CompleteBooking[];
|
||||
availability: CompleteAvailability[];
|
||||
destinationCalendar?: CompleteDestinationCalendar | null;
|
||||
customInputs: CompleteEventTypeCustomInput[];
|
||||
Schedule: CompleteSchedule[];
|
||||
}
|
||||
|
||||
/**
|
||||
* EventTypeModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const EventTypeModel: z.ZodSchema<CompleteEventType> = z.lazy(() =>
|
||||
_EventTypeModel.extend({
|
||||
users: UserModel.array(),
|
||||
team: TeamModel.nullish(),
|
||||
bookings: BookingModel.array(),
|
||||
availability: AvailabilityModel.array(),
|
||||
destinationCalendar: DestinationCalendarModel.nullish(),
|
||||
customInputs: EventTypeCustomInputModel.array(),
|
||||
Schedule: ScheduleModel.array(),
|
||||
})
|
||||
);
|
||||
@@ -1,17 +0,0 @@
|
||||
import { _EventTypeModel } from "prisma/zod";
|
||||
|
||||
const createEventTypeBaseInput = _EventTypeModel
|
||||
.pick({
|
||||
title: true,
|
||||
slug: true,
|
||||
description: true,
|
||||
length: true,
|
||||
teamId: true,
|
||||
schedulingType: true,
|
||||
})
|
||||
.refine((data) => (data.teamId ? data.teamId && data.schedulingType : true), {
|
||||
path: ["schedulingType"],
|
||||
message: "You must select a scheduling type for team events",
|
||||
});
|
||||
|
||||
export const createEventTypeInput = createEventTypeBaseInput;
|
||||
@@ -1,28 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { EventTypeCustomInputType } from "@prisma/client";
|
||||
import { CompleteEventType, EventTypeModel } from "./index";
|
||||
|
||||
export const _EventTypeCustomInputModel = z.object({
|
||||
id: z.number().int(),
|
||||
eventTypeId: z.number().int(),
|
||||
label: z.string(),
|
||||
type: z.nativeEnum(EventTypeCustomInputType),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string(),
|
||||
});
|
||||
|
||||
export interface CompleteEventTypeCustomInput extends z.infer<typeof _EventTypeCustomInputModel> {
|
||||
eventType: CompleteEventType;
|
||||
}
|
||||
|
||||
/**
|
||||
* EventTypeCustomInputModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const EventTypeCustomInputModel: z.ZodSchema<CompleteEventTypeCustomInput> = z.lazy(() =>
|
||||
_EventTypeCustomInputModel.extend({
|
||||
eventType: EventTypeModel,
|
||||
})
|
||||
);
|
||||
@@ -1,19 +0,0 @@
|
||||
export * from "./eventtype";
|
||||
export * from "./credential";
|
||||
export * from "./destinationcalendar";
|
||||
export * from "./user";
|
||||
export * from "./team";
|
||||
export * from "./membership";
|
||||
export * from "./verificationrequest";
|
||||
export * from "./bookingreference";
|
||||
export * from "./attendee";
|
||||
export * from "./dailyeventreference";
|
||||
export * from "./booking";
|
||||
export * from "./schedule";
|
||||
export * from "./availability";
|
||||
export * from "./selectedcalendar";
|
||||
export * from "./eventtypecustominput";
|
||||
export * from "./resetpasswordrequest";
|
||||
export * from "./remindermail";
|
||||
export * from "./payment";
|
||||
export * from "./webhook";
|
||||
@@ -1,28 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { MembershipRole } from "@prisma/client";
|
||||
import { CompleteTeam, TeamModel, CompleteUser, UserModel } from "./index";
|
||||
|
||||
export const _MembershipModel = z.object({
|
||||
teamId: z.number().int(),
|
||||
userId: z.number().int(),
|
||||
accepted: z.boolean(),
|
||||
role: z.nativeEnum(MembershipRole),
|
||||
});
|
||||
|
||||
export interface CompleteMembership extends z.infer<typeof _MembershipModel> {
|
||||
team: CompleteTeam;
|
||||
user: CompleteUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* MembershipModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const MembershipModel: z.ZodSchema<CompleteMembership> = z.lazy(() =>
|
||||
_MembershipModel.extend({
|
||||
team: TeamModel,
|
||||
user: UserModel,
|
||||
})
|
||||
);
|
||||
@@ -1,41 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { PaymentType } from "@prisma/client";
|
||||
import { CompleteBooking, BookingModel } from "./index";
|
||||
|
||||
// Helper schema for JSON fields
|
||||
type Literal = boolean | number | string;
|
||||
type Json = Literal | { [key: string]: Json } | Json[];
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||
);
|
||||
|
||||
export const _PaymentModel = z.object({
|
||||
id: z.number().int(),
|
||||
uid: z.string(),
|
||||
type: z.nativeEnum(PaymentType),
|
||||
bookingId: z.number().int(),
|
||||
amount: z.number().int(),
|
||||
fee: z.number().int(),
|
||||
currency: z.string(),
|
||||
success: z.boolean(),
|
||||
refunded: z.boolean(),
|
||||
data: jsonSchema,
|
||||
externalId: z.string(),
|
||||
});
|
||||
|
||||
export interface CompletePayment extends z.infer<typeof _PaymentModel> {
|
||||
booking?: CompleteBooking | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* PaymentModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const PaymentModel: z.ZodSchema<CompletePayment> = z.lazy(() =>
|
||||
_PaymentModel.extend({
|
||||
booking: BookingModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,11 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { ReminderType } from "@prisma/client";
|
||||
|
||||
export const _ReminderMailModel = z.object({
|
||||
id: z.number().int(),
|
||||
referenceId: z.number().int(),
|
||||
reminderType: z.nativeEnum(ReminderType),
|
||||
elapsedMinutes: z.number().int(),
|
||||
createdAt: z.date(),
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
|
||||
export const _ResetPasswordRequestModel = z.object({
|
||||
id: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
email: z.string(),
|
||||
expires: z.date(),
|
||||
});
|
||||
@@ -1,36 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteUser, UserModel, CompleteEventType, EventTypeModel } from "./index";
|
||||
|
||||
// Helper schema for JSON fields
|
||||
type Literal = boolean | number | string;
|
||||
type Json = Literal | { [key: string]: Json } | Json[];
|
||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||
const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||
);
|
||||
|
||||
export const _ScheduleModel = z.object({
|
||||
id: z.number().int(),
|
||||
userId: z.number().int().nullish(),
|
||||
eventTypeId: z.number().int().nullish(),
|
||||
title: z.string().nullish(),
|
||||
freeBusyTimes: jsonSchema,
|
||||
});
|
||||
|
||||
export interface CompleteSchedule extends z.infer<typeof _ScheduleModel> {
|
||||
user?: CompleteUser | null;
|
||||
eventType?: CompleteEventType | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ScheduleModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const ScheduleModel: z.ZodSchema<CompleteSchedule> = z.lazy(() =>
|
||||
_ScheduleModel.extend({
|
||||
user: UserModel.nullish(),
|
||||
eventType: EventTypeModel.nullish(),
|
||||
})
|
||||
);
|
||||
@@ -1,24 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteUser, UserModel } from "./index";
|
||||
|
||||
export const _SelectedCalendarModel = z.object({
|
||||
userId: z.number().int(),
|
||||
integration: z.string(),
|
||||
externalId: z.string(),
|
||||
});
|
||||
|
||||
export interface CompleteSelectedCalendar extends z.infer<typeof _SelectedCalendarModel> {
|
||||
user: CompleteUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* SelectedCalendarModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const SelectedCalendarModel: z.ZodSchema<CompleteSelectedCalendar> = z.lazy(() =>
|
||||
_SelectedCalendarModel.extend({
|
||||
user: UserModel,
|
||||
})
|
||||
);
|
||||
@@ -1,29 +0,0 @@
|
||||
import * as z from "zod";
|
||||
import * as imports from "../zod-utils";
|
||||
import { CompleteMembership, MembershipModel, CompleteEventType, EventTypeModel } from "./index";
|
||||
|
||||
export const _TeamModel = z.object({
|
||||
id: z.number().int(),
|
||||
name: z.string().nullish(),
|
||||
slug: z.string().nullish(),
|
||||
logo: z.string().nullish(),
|
||||
bio: z.string().nullish(),
|
||||
hideBranding: z.boolean(),
|
||||
});
|
||||
|
||||
export interface CompleteTeam extends z.infer<typeof _TeamModel> {
|
||||
members: CompleteMembership[];
|
||||
eventTypes: CompleteEventType[];
|
||||
}
|
||||
|
||||
/**
|
||||
* TeamModel contains all relations on your model in addition to the scalars
|
||||
*
|
||||
* NOTE: Lazy required in case of potential circular dependencies within schema
|
||||
*/
|
||||
export const TeamModel: z.ZodSchema<CompleteTeam> = z.lazy(() =>
|
||||
_TeamModel.extend({
|
||||
members: MembershipModel.array(),
|
||||
eventTypes: EventTypeModel.array(),
|
||||
})
|
||||
);
|
||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user