From e878e1a6653f1cccfe93fb6d3beefcd366651fb6 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo <6601142+agustif@users.noreply.github.com> Date: Wed, 3 Aug 2022 21:18:26 +0200 Subject: [PATCH] Fix/api build (#3675) * fix: shared next-auth calendso session type fix * fix: move imports from @lib -> @calcom/lib to fix types * Consolidates next-auth definitions Co-authored-by: Agusti Fernandez Pardo Co-authored-by: zomars --- .../app-store/ee/routing_forms/trpc-router.ts | 5 ++--- packages/app-store/next-auth.d.ts | 15 --------------- packages/app-store/next.d.ts | 12 ------------ packages/app-store/tsconfig.json | 4 ++-- packages/lib/auth.ts | 2 +- packages/trpc/server/createContext.ts | 4 ++-- packages/trpc/tsconfig.json | 3 +++ packages/tsconfig/nextjs.json | 3 ++- packages/tsconfig/react-library.json | 4 +++- packages/types/next-auth.d.ts | 2 +- packages/types/next.d.ts | 2 ++ 11 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 packages/app-store/next-auth.d.ts delete mode 100644 packages/app-store/next.d.ts create mode 100644 packages/trpc/tsconfig.json diff --git a/packages/app-store/ee/routing_forms/trpc-router.ts b/packages/app-store/ee/routing_forms/trpc-router.ts index c736eec0d7..adaf57e886 100644 --- a/packages/app-store/ee/routing_forms/trpc-router.ts +++ b/packages/app-store/ee/routing_forms/trpc-router.ts @@ -2,12 +2,11 @@ import { Prisma, WebhookTriggerEvents } from "@prisma/client"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; +import { sendGenericWebhookPayload } from "@calcom/lib/webhooks/sendPayload"; +import getWebhooks from "@calcom/lib/webhooks/subscriptions"; import { TRPCError } from "@calcom/trpc/server"; import { createProtectedRouter, createRouter } from "@calcom/trpc/server/createRouter"; -import { sendGenericWebhookPayload } from "@lib/webhooks/sendPayload"; -import getWebhooks from "@lib/webhooks/subscriptions"; - import { zodFields, zodRoutes } from "./zod"; const app_RoutingForms = createRouter() diff --git a/packages/app-store/next-auth.d.ts b/packages/app-store/next-auth.d.ts deleted file mode 100644 index 066f312922..0000000000 --- a/packages/app-store/next-auth.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import NextAuth, { DefaultSession } from "next-auth"; - -declare module "next-auth" { - type DefaultSessionUser = NonNullable; - type CalendsoSessionUser = DefaultSessionUser & { - id: number; - username: string; - }; - /** - * Returned by `useSession`, `getSession` and received as a prop on the `Provider` React Context - */ - interface Session { - user: CalendsoSessionUser; - } -} diff --git a/packages/app-store/next.d.ts b/packages/app-store/next.d.ts deleted file mode 100644 index 865eacefbf..0000000000 --- a/packages/app-store/next.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { IncomingMessage } from "http"; -import type { Session } from "next-auth"; - -import "./next-auth"; - -export declare module "next" { - interface NextApiRequest extends IncomingMessage { - // args is defined by /integrations/[...args] endpoint - query: Partial<{ [key: string]: string | string[] }> & { args: string[] }; - session?: Session | null; - } -} diff --git a/packages/app-store/tsconfig.json b/packages/app-store/tsconfig.json index 2cf1a3c3df..ec53741a1c 100644 --- a/packages/app-store/tsconfig.json +++ b/packages/app-store/tsconfig.json @@ -13,8 +13,8 @@ "include": [ "next-env.d.ts", "@calcom/types", - "../../packages/types/*.d.ts", - "../../packages/types/next-auth.d.ts", + "../types/*.d.ts", + "../types/next-auth.d.ts", "**/*.ts", "**/*.tsx", "../../apps/web/server/**/*.ts", diff --git a/packages/lib/auth.ts b/packages/lib/auth.ts index 94691cd5fe..3b5b429ad1 100644 --- a/packages/lib/auth.ts +++ b/packages/lib/auth.ts @@ -1,5 +1,5 @@ import { compare, hash } from "bcryptjs"; -import { Session } from "next-auth"; +import type { Session } from "next-auth"; import { getSession as getSessionInner, GetSessionParams } from "next-auth/react"; export async function hashPassword(password: string) { diff --git a/packages/trpc/server/createContext.ts b/packages/trpc/server/createContext.ts index 9585e34d46..6295a85fb2 100644 --- a/packages/trpc/server/createContext.ts +++ b/packages/trpc/server/createContext.ts @@ -1,5 +1,5 @@ -import { GetServerSidePropsContext } from "next"; -import { Session } from "next-auth"; +import type { GetServerSidePropsContext } from "next"; +import type { Session } from "next-auth"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { getSession } from "@calcom/lib/auth"; diff --git a/packages/trpc/tsconfig.json b/packages/trpc/tsconfig.json new file mode 100644 index 0000000000..11e86362e1 --- /dev/null +++ b/packages/trpc/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@calcom/tsconfig/react-library.json" +} diff --git a/packages/tsconfig/nextjs.json b/packages/tsconfig/nextjs.json index 048d2671ac..367eb4454e 100644 --- a/packages/tsconfig/nextjs.json +++ b/packages/tsconfig/nextjs.json @@ -15,11 +15,12 @@ "esModuleInterop": true, "module": "esnext", "resolveJsonModule": true, + "strict": true, "isolatedModules": true, "jsx": "preserve", "strictNullChecks": true, "useUnknownInCatchVariables": true }, - "include": ["src", "next-env.d.ts"], + "include": ["src", "next-env.d.ts", "../types/next-auth.d.ts", "../types/*.d.ts"], "exclude": ["node_modules"] } diff --git a/packages/tsconfig/react-library.json b/packages/tsconfig/react-library.json index 6d6a7fea97..35821a5236 100644 --- a/packages/tsconfig/react-library.json +++ b/packages/tsconfig/react-library.json @@ -7,5 +7,7 @@ "module": "ESNext", "target": "ES6", "jsx": "react-jsx" - } + }, + "include": [".", "../types/next-auth.d.ts"], + "exclude": ["dist", "build", "node_modules"] } diff --git a/packages/types/next-auth.d.ts b/packages/types/next-auth.d.ts index b447c8fb78..188d2d66e0 100644 --- a/packages/types/next-auth.d.ts +++ b/packages/types/next-auth.d.ts @@ -1,5 +1,5 @@ import { UserPermissionRole } from "@prisma/client"; -import NextAuth, { DefaultSession } from "next-auth"; +import { DefaultSession } from "next-auth"; declare module "next-auth" { type DefaultSessionUser = NonNullable; diff --git a/packages/types/next.d.ts b/packages/types/next.d.ts index aa0e02c1c2..865eacefbf 100644 --- a/packages/types/next.d.ts +++ b/packages/types/next.d.ts @@ -5,6 +5,8 @@ import "./next-auth"; export declare module "next" { interface NextApiRequest extends IncomingMessage { + // args is defined by /integrations/[...args] endpoint + query: Partial<{ [key: string]: string | string[] }> & { args: string[] }; session?: Session | null; } }