-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose individual stores for user, session, sessionList etc (#179)
* feat: Expose individual stores for user, session, sessionList etc. * feat: Expose individual stores for user, session, sessionList etc. * chore: Update README * fix: Incorrect import path for nanostores
- Loading branch information
1 parent
205f597
commit c69c349
Showing
11 changed files
with
81 additions
and
29 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,12 @@ | ||
--- | ||
"astro-clerk-auth": minor | ||
--- | ||
|
||
Expose individual stores for client resources. | ||
- $userStore | ||
- $sessionStore | ||
- $sessionListStore | ||
- $clerkStore | ||
- $clerkStore | ||
- $signInStore | ||
- $signUpStore |
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,3 @@ | ||
{ | ||
"main": "../../dist/client/stores/index.js" | ||
} |
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 @@ | ||
export * from '../../stores/external'; |
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,30 @@ | ||
import { computed } from 'nanostores'; | ||
import { $clerk, $csrState, $initialState } from './internal'; | ||
import { deriveState } from './utils'; | ||
|
||
export const $authStore = computed([$csrState, $initialState], (state, initialState) => { | ||
return deriveState( | ||
state.isLoaded, | ||
{ | ||
session: state.session, | ||
user: state.user, | ||
organization: state.organization, | ||
client: state.client!, | ||
}, | ||
initialState, | ||
); | ||
}); | ||
|
||
export const $userStore = computed([$authStore], (auth) => auth.user); | ||
// TODO: on mounted subscriber log telemetry | ||
// onMount($userStore, () => { | ||
// // isomorphicClerk.telemetry?.record(eventMethodCalled('useSignIn')); | ||
// }); | ||
|
||
export const $sessionStore = computed([$authStore], (auth) => auth.session); | ||
export const $organizationStore = computed([$authStore], (auth) => auth.organization); | ||
export const $clientStore = computed([$csrState], (csr) => csr.client); | ||
export const $clerkStore = computed([$clerk], (clerk) => clerk); | ||
export const $sessionListStore = computed([$clientStore], (client) => client?.sessions); | ||
export const $signInStore = computed([$clientStore], (client) => client?.signIn); | ||
export const $signUpStore = computed([$clientStore], (client) => client?.signUp); |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// TODO: Don't expose everything | ||
// TODO: Don't expose internal | ||
export * from './internal'; |
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