From deec45005f4cc383deb7e0a6ccd37d5ea001a92e Mon Sep 17 00:00:00 2001 From: Tim Stone Date: Sat, 12 Aug 2023 09:42:12 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=8F=B7=EF=B8=8F=20Include=20types?= =?UTF-8?q?=20required=20by=20solid-start=20framework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include types required by solid-start framework that are currently imported from `next-auth/react`, which is not a dependency of the solid-start framework. This provides the referenced types directly in the framework's client.ts and builds to client.d.ts. --- packages/frameworks-solid-start/src/client.ts | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/packages/frameworks-solid-start/src/client.ts b/packages/frameworks-solid-start/src/client.ts index 000a12dc57..51f8b3db0d 100644 --- a/packages/frameworks-solid-start/src/client.ts +++ b/packages/frameworks-solid-start/src/client.ts @@ -1,14 +1,50 @@ -import type { - LiteralUnion, - SignInOptions, - SignInAuthorizationParams, - SignOutParams, -} from "next-auth/react" import type { BuiltInProviderType, + ProviderType, RedirectableProviderType, } from "@auth/core/providers" +/** + * Util type that matches some strings literally, but allows any other string as well. + * @source https://github.com/microsoft/TypeScript/issues/29729#issuecomment-832522611 + */ +export type LiteralUnion = + | T + | (U & Record) + +export interface ClientSafeProvider { + id: LiteralUnion + name: string + type: ProviderType + signinUrl: string + callbackUrl: string +} + +export interface SignInOptions extends Record { + /** + * Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from. + * + * [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl) + */ + callbackUrl?: string + /** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */ + redirect?: boolean +} + +/** Match `inputType` of `new URLSearchParams(inputType)` */ +export type SignInAuthorizationParams = + | string + | string[][] + | Record + | URLSearchParams + +export interface SignOutParams { + /** [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl-1) */ + callbackUrl?: string + /** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1 */ + redirect?: R +} + /** * Client-side method to initiate a signin flow * or send the user to the signin page listing all possible providers.