import type { Lang } from "@scandic-hotels/common/constants/language" import type { User } from "next-auth" import type { JWT } from "next-auth/jwt" import type { getBasicUser } from "./routers/user/utils/getBasicUser" import type { getVerifiedUser } from "./routers/user/utils/getVerifiedUser" type Session = { token: JWT expires: string user?: User error?: "RefreshAccessTokenError" } type ScandicUser = Awaited> type ScandicBasicUser = Awaited> type CreateContextOptions = { auth: () => Promise lang: Lang pathname: string uid?: string | null url: string webToken?: string contentType?: string app: "scandic-web" | "partner-sas" getScandicUserToken: () => Promise getUserPointsBalance: () => Promise getScandicUser: (input?: { withExtendedPartnerData: boolean }) => Promise getScandicBasicUser: () => Promise } export function createContext(opts: CreateContextOptions) { return { auth: opts.auth, lang: opts.lang, pathname: opts.pathname, uid: opts.uid, url: opts.url, webToken: opts.webToken, contentType: opts.contentType, app: opts.app, getScandicUserToken: opts.getScandicUserToken, getUserPointsBalance: opts.getUserPointsBalance, getScandicUser: opts.getScandicUser, getScandicBasicUser: opts.getScandicBasicUser, } } export type Context = Awaited>