@niledatabase/react 4.0.0-alpha.20 → 4.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,38 +2,39 @@ import * as React$1 from 'react';
2
2
  import React__default from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- import * as next_auth_react from 'next-auth/react';
6
- import { SignInOptions, LiteralUnion, ClientSafeProvider, SignOutParams, SignOutResponse, SignInAuthorizationParams, SignInResponse as SignInResponse$1, UseSessionOptions } from 'next-auth/react';
5
+ import { IncomingMessage } from 'http';
7
6
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
8
7
  import { VariantProps } from 'class-variance-authority';
9
- import { CtxOrReq } from 'next-auth/client/_utils';
10
- import { BuiltInProviderType, RedirectableProviderType } from 'next-auth/providers/index';
11
8
 
12
- type EmailSignInInfo = SignInOptions;
13
- type SignInSuccess = (response: Response) => void;
14
- type AllowedAny$3 = any;
15
- type Props$5 = {
16
- redirect?: boolean;
17
- onSuccess?: SignInSuccess;
18
- onError?: (e: Error, info: EmailSignInInfo) => void;
19
- beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
20
- buttonText?: string;
21
- client?: QueryClient;
9
+ interface SignInResponse$1 {
10
+ error: string | null;
11
+ status: number;
12
+ ok: boolean;
13
+ url: string | null;
14
+ }
15
+ type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
16
+ interface SignInOptions extends Record<string, unknown> {
17
+ /**
18
+ * Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from.
19
+ *
20
+ * [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)
21
+ */
22
22
  callbackUrl?: string;
23
- init?: RequestInit;
24
- };
25
-
26
- declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
27
-
28
- declare const buttonVariants: (props?: ({
29
- variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
30
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
31
- } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
32
- interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
33
- asChild?: boolean;
34
- loading?: boolean;
23
+ /** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
24
+ redirect?: boolean;
35
25
  }
36
-
26
+ type SignInAuthorizationParams = string | string[][] | Record<string, string> | URLSearchParams;
27
+ type ProviderType = 'oauth' | 'email' | 'credentials';
28
+ interface ClientSafeProvider {
29
+ id: LiteralUnion<BuiltInProviderType>;
30
+ name: string;
31
+ type: ProviderType;
32
+ signinUrl: string;
33
+ callbackUrl: string;
34
+ }
35
+ type RedirectableProviderType = 'email' | 'credentials';
36
+ type OAuthProviderType = 'linkedin' | 'hubspot' | 'google' | 'azure-ad' | 'slack' | 'github' | 'twitter' | 'discord';
37
+ type BuiltInProviderType = RedirectableProviderType | OAuthProviderType;
37
38
  type JWT = {
38
39
  email: string;
39
40
  sub: string;
@@ -93,6 +94,48 @@ type PartialAuthorizer = null | {
93
94
  };
94
95
  requestInit?: RequestInit | undefined;
95
96
  };
97
+ interface CtxOrReq {
98
+ req?: Partial<IncomingMessage> & {
99
+ body?: any;
100
+ };
101
+ ctx?: {
102
+ req: Partial<IncomingMessage> & {
103
+ body?: any;
104
+ };
105
+ };
106
+ }
107
+ interface SignOutParams<R extends boolean = true> {
108
+ callbackUrl?: string;
109
+ redirect?: R;
110
+ }
111
+ interface SignOutResponse {
112
+ url: string;
113
+ }
114
+
115
+ type EmailSignInInfo = SignInOptions;
116
+ type SignInSuccess = (response: Response) => void;
117
+ type AllowedAny$3 = any;
118
+ type Props$5 = {
119
+ redirect?: boolean;
120
+ onSuccess?: SignInSuccess;
121
+ onError?: (e: Error, info: EmailSignInInfo) => void;
122
+ beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
123
+ buttonText?: string;
124
+ client?: QueryClient;
125
+ callbackUrl?: string;
126
+ init?: RequestInit;
127
+ };
128
+
129
+ declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
130
+
131
+ declare const buttonVariants: (props?: ({
132
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
133
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
134
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
135
+ interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
136
+ asChild?: boolean;
137
+ loading?: boolean;
138
+ }
96
139
 
97
140
  type WarningCode = 'NEXTAUTH_URL' | 'NO_SECRET' | 'TWITTER_OAUTH_2_BETA' | 'DEBUG_ENABLED';
98
141
  /**
@@ -235,7 +278,7 @@ declare const EmailSignInButton: {
235
278
  displayName: string;
236
279
  };
237
280
 
238
- declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, next_auth_react.SignInOptions, unknown>;
281
+ declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, SignInOptions, unknown>;
239
282
 
240
283
  /**
241
284
  * A component for a Google login button, according to their design language.
@@ -346,7 +389,7 @@ type Props$3 = ComponentFetchProps & {
346
389
 
347
390
  declare function SigningIn({ className, ...props }: Props$3): React__default.JSX.Element;
348
391
 
349
- declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<next_auth_react.SignInResponse | undefined, Error, LoginInfo, any>;
392
+ declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<SignInResponse$1 | undefined, Error, LoginInfo, any>;
350
393
 
351
394
  type Props$2 = ButtonProps & ComponentFetchProps & {
352
395
  redirect?: boolean;
@@ -410,6 +453,11 @@ declare const SessionContext: React__default.Context<{
410
453
  data: null | undefined;
411
454
  status: "unauthenticated" | "loading";
412
455
  } | undefined>;
456
+ interface UseSessionOptions<R extends boolean> {
457
+ required: R;
458
+ /** Defaults to `signIn` */
459
+ onUnauthenticated?: () => void;
460
+ }
413
461
  /**
414
462
  * React Hook that gives you access
415
463
  * to the logged in user's session data.
package/dist/index.d.ts CHANGED
@@ -2,38 +2,39 @@ import * as React$1 from 'react';
2
2
  import React__default from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- import * as next_auth_react from 'next-auth/react';
6
- import { SignInOptions, LiteralUnion, ClientSafeProvider, SignOutParams, SignOutResponse, SignInAuthorizationParams, SignInResponse as SignInResponse$1, UseSessionOptions } from 'next-auth/react';
5
+ import { IncomingMessage } from 'http';
7
6
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
8
7
  import { VariantProps } from 'class-variance-authority';
9
- import { CtxOrReq } from 'next-auth/client/_utils';
10
- import { BuiltInProviderType, RedirectableProviderType } from 'next-auth/providers/index';
11
8
 
12
- type EmailSignInInfo = SignInOptions;
13
- type SignInSuccess = (response: Response) => void;
14
- type AllowedAny$3 = any;
15
- type Props$5 = {
16
- redirect?: boolean;
17
- onSuccess?: SignInSuccess;
18
- onError?: (e: Error, info: EmailSignInInfo) => void;
19
- beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
20
- buttonText?: string;
21
- client?: QueryClient;
9
+ interface SignInResponse$1 {
10
+ error: string | null;
11
+ status: number;
12
+ ok: boolean;
13
+ url: string | null;
14
+ }
15
+ type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
16
+ interface SignInOptions extends Record<string, unknown> {
17
+ /**
18
+ * Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from.
19
+ *
20
+ * [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)
21
+ */
22
22
  callbackUrl?: string;
23
- init?: RequestInit;
24
- };
25
-
26
- declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
27
-
28
- declare const buttonVariants: (props?: ({
29
- variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
30
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
31
- } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
32
- interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
33
- asChild?: boolean;
34
- loading?: boolean;
23
+ /** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
24
+ redirect?: boolean;
35
25
  }
36
-
26
+ type SignInAuthorizationParams = string | string[][] | Record<string, string> | URLSearchParams;
27
+ type ProviderType = 'oauth' | 'email' | 'credentials';
28
+ interface ClientSafeProvider {
29
+ id: LiteralUnion<BuiltInProviderType>;
30
+ name: string;
31
+ type: ProviderType;
32
+ signinUrl: string;
33
+ callbackUrl: string;
34
+ }
35
+ type RedirectableProviderType = 'email' | 'credentials';
36
+ type OAuthProviderType = 'linkedin' | 'hubspot' | 'google' | 'azure-ad' | 'slack' | 'github' | 'twitter' | 'discord';
37
+ type BuiltInProviderType = RedirectableProviderType | OAuthProviderType;
37
38
  type JWT = {
38
39
  email: string;
39
40
  sub: string;
@@ -93,6 +94,48 @@ type PartialAuthorizer = null | {
93
94
  };
94
95
  requestInit?: RequestInit | undefined;
95
96
  };
97
+ interface CtxOrReq {
98
+ req?: Partial<IncomingMessage> & {
99
+ body?: any;
100
+ };
101
+ ctx?: {
102
+ req: Partial<IncomingMessage> & {
103
+ body?: any;
104
+ };
105
+ };
106
+ }
107
+ interface SignOutParams<R extends boolean = true> {
108
+ callbackUrl?: string;
109
+ redirect?: R;
110
+ }
111
+ interface SignOutResponse {
112
+ url: string;
113
+ }
114
+
115
+ type EmailSignInInfo = SignInOptions;
116
+ type SignInSuccess = (response: Response) => void;
117
+ type AllowedAny$3 = any;
118
+ type Props$5 = {
119
+ redirect?: boolean;
120
+ onSuccess?: SignInSuccess;
121
+ onError?: (e: Error, info: EmailSignInInfo) => void;
122
+ beforeMutate?: (data: AllowedAny$3) => AllowedAny$3;
123
+ buttonText?: string;
124
+ client?: QueryClient;
125
+ callbackUrl?: string;
126
+ init?: RequestInit;
127
+ };
128
+
129
+ declare function EmailSigningIn(props: Props$5): React__default.JSX.Element;
130
+
131
+ declare const buttonVariants: (props?: ({
132
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
133
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
134
+ } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
135
+ interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
136
+ asChild?: boolean;
137
+ loading?: boolean;
138
+ }
96
139
 
97
140
  type WarningCode = 'NEXTAUTH_URL' | 'NO_SECRET' | 'TWITTER_OAUTH_2_BETA' | 'DEBUG_ENABLED';
98
141
  /**
@@ -235,7 +278,7 @@ declare const EmailSignInButton: {
235
278
  displayName: string;
236
279
  };
237
280
 
238
- declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, next_auth_react.SignInOptions, unknown>;
281
+ declare function useEmailSignIn(params?: Props$5): _tanstack_react_query.UseMutateFunction<Response, Error, SignInOptions, unknown>;
239
282
 
240
283
  /**
241
284
  * A component for a Google login button, according to their design language.
@@ -346,7 +389,7 @@ type Props$3 = ComponentFetchProps & {
346
389
 
347
390
  declare function SigningIn({ className, ...props }: Props$3): React__default.JSX.Element;
348
391
 
349
- declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<next_auth_react.SignInResponse | undefined, Error, LoginInfo, any>;
392
+ declare function useSignIn(params?: Props$3): _tanstack_react_query.UseMutateFunction<SignInResponse$1 | undefined, Error, LoginInfo, any>;
350
393
 
351
394
  type Props$2 = ButtonProps & ComponentFetchProps & {
352
395
  redirect?: boolean;
@@ -410,6 +453,11 @@ declare const SessionContext: React__default.Context<{
410
453
  data: null | undefined;
411
454
  status: "unauthenticated" | "loading";
412
455
  } | undefined>;
456
+ interface UseSessionOptions<R extends boolean> {
457
+ required: R;
458
+ /** Defaults to `signIn` */
459
+ onUnauthenticated?: () => void;
460
+ }
413
461
  /**
414
462
  * React Hook that gives you access
415
463
  * to the logged in user's session data.