-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(shared,types,clerk-react,vue): Share hook return types (#4583)
- Loading branch information
1 parent
aba63de
commit e47eb58
Showing
15 changed files
with
137 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@clerk/clerk-react": patch | ||
"@clerk/shared": patch | ||
"@clerk/types": patch | ||
"@clerk/vue": patch | ||
--- | ||
|
||
Share hook return types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import type { OrganizationCustomRoleKey } from 'organizationMembership'; | ||
import type { SignInResource } from 'signIn'; | ||
|
||
import type { SetActive, SignOut } from './clerk'; | ||
import type { ActJWTClaim } from './jwt'; | ||
import type { | ||
ActiveSessionResource, | ||
CheckAuthorizationWithCustomPermissions, | ||
GetToken, | ||
SessionResource, | ||
} from './session'; | ||
import type { SignUpResource } from './signUp'; | ||
import type { UserResource } from './user'; | ||
|
||
type CheckAuthorizationSignedOut = undefined; | ||
type CheckAuthorizationWithoutOrgOrUser = (params: Parameters<CheckAuthorizationWithCustomPermissions>[0]) => false; | ||
|
||
export type UseAuthReturn = | ||
| { | ||
isLoaded: false; | ||
isSignedIn: undefined; | ||
userId: undefined; | ||
sessionId: undefined; | ||
actor: undefined; | ||
orgId: undefined; | ||
orgRole: undefined; | ||
orgSlug: undefined; | ||
has: CheckAuthorizationSignedOut; | ||
signOut: SignOut; | ||
getToken: GetToken; | ||
} | ||
| { | ||
isLoaded: true; | ||
isSignedIn: false; | ||
userId: null; | ||
sessionId: null; | ||
actor: null; | ||
orgId: null; | ||
orgRole: null; | ||
orgSlug: null; | ||
has: CheckAuthorizationWithoutOrgOrUser; | ||
signOut: SignOut; | ||
getToken: GetToken; | ||
} | ||
| { | ||
isLoaded: true; | ||
isSignedIn: true; | ||
userId: string; | ||
sessionId: string; | ||
actor: ActJWTClaim | null; | ||
orgId: null; | ||
orgRole: null; | ||
orgSlug: null; | ||
has: CheckAuthorizationWithCustomPermissions; | ||
signOut: SignOut; | ||
getToken: GetToken; | ||
} | ||
| { | ||
isLoaded: true; | ||
isSignedIn: true; | ||
userId: string; | ||
sessionId: string; | ||
actor: ActJWTClaim | null; | ||
orgId: string; | ||
orgRole: OrganizationCustomRoleKey; | ||
orgSlug: string | null; | ||
has: CheckAuthorizationWithCustomPermissions; | ||
signOut: SignOut; | ||
getToken: GetToken; | ||
}; | ||
|
||
export type UseSignInReturn = | ||
| { | ||
isLoaded: false; | ||
signIn: undefined; | ||
setActive: undefined; | ||
} | ||
| { | ||
isLoaded: true; | ||
signIn: SignInResource; | ||
setActive: SetActive; | ||
}; | ||
|
||
export type UseSignUpReturn = | ||
| { | ||
isLoaded: false; | ||
signUp: undefined; | ||
setActive: undefined; | ||
} | ||
| { | ||
isLoaded: true; | ||
signUp: SignUpResource; | ||
setActive: SetActive; | ||
}; | ||
|
||
export type UseSessionReturn = | ||
| { isLoaded: false; isSignedIn: undefined; session: undefined } | ||
| { isLoaded: true; isSignedIn: false; session: null } | ||
| { isLoaded: true; isSignedIn: true; session: ActiveSessionResource }; | ||
|
||
export type UseSessionListReturn = | ||
| { | ||
isLoaded: false; | ||
sessions: undefined; | ||
setActive: undefined; | ||
} | ||
| { | ||
isLoaded: true; | ||
sessions: SessionResource[]; | ||
setActive: SetActive; | ||
}; | ||
|
||
export type UseUserReturn = | ||
| { isLoaded: false; isSignedIn: undefined; user: undefined } | ||
| { isLoaded: true; isSignedIn: false; user: null } | ||
| { isLoaded: true; isSignedIn: true; user: UserResource }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.