-
Notifications
You must be signed in to change notification settings - Fork 453
fix(remix,nextjs,clerk-react): Export EmailLinkErrorCode from /errors #2732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| --- | ||
| '@clerk/nextjs': patch | ||
| '@clerk/clerk-react': patch | ||
| '@clerk/remix': patch | ||
| --- | ||
|
|
||
| Export `EmailLinkErrorCode` from `/errors` module |
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@clerk/remix': patch | ||
| --- | ||
|
|
||
| Introduce `/errors` module. This path exports all error-related APIs such as `isClerkAPIResponseError`, `isEmailLinkError`, `isKnownError`, `isMetamaskError`, `EmailLinkErrorCode` |
This file contains hidden or 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 hidden or 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 +1,7 @@ | ||
| export { isClerkAPIResponseError, isEmailLinkError, isKnownError, isMetamaskError } from './client-boundary/hooks'; | ||
| export { | ||
| isClerkAPIResponseError, | ||
| isEmailLinkError, | ||
| isKnownError, | ||
| isMetamaskError, | ||
| EmailLinkErrorCode, | ||
| } from './client-boundary/hooks'; |
This file contains hidden or 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 +1,7 @@ | ||
| export { isClerkAPIResponseError, isEmailLinkError, isKnownError, isMetamaskError } from '@clerk/shared/error'; | ||
| export { | ||
| isClerkAPIResponseError, | ||
| isEmailLinkError, | ||
| isKnownError, | ||
| isMetamaskError, | ||
| EmailLinkErrorCode, | ||
| } from '@clerk/shared/error'; |
This file contains hidden or 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,4 @@ | ||
| { | ||
| "main": "../dist/api/index.js", | ||
| "types": "../dist/api/index.d.ts" | ||
| } |
This file contains hidden or 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,4 @@ | ||
| { | ||
| "main": "../dist/errors.js", | ||
| "types": "../dist/errors.d.ts" | ||
| } |
This file contains hidden or 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 hidden or 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,84 +1,7 @@ | ||
| const createErrorMessage = (msg: string) => { | ||
| return `🔒 Clerk: ${msg.trim()} | ||
|
|
||
| For more info, check out the docs: https://clerk.com/docs, | ||
| or come say hi in our discord server: https://clerk.com/discord | ||
|
|
||
| `; | ||
| }; | ||
|
|
||
| const ssrExample = `Use 'rootAuthLoader' as your root loader. Then, simply wrap the App component with ClerkApp and make it the default export. | ||
| Example: | ||
|
|
||
| import { ClerkApp } from '@clerk/remix'; | ||
| import { rootAuthLoader } from '@clerk/remix/ssr.server'; | ||
|
|
||
| export const loader: LoaderFunction = args => rootAuthLoader(args) | ||
|
|
||
| function App() { | ||
| return ( | ||
| <html lang='en'> | ||
| ... | ||
| </html> | ||
| ); | ||
| } | ||
|
|
||
| export default ClerkApp(App, { publishableKey: '...' }); | ||
| `; | ||
|
|
||
| export const invalidClerkStatePropError = createErrorMessage(` | ||
| You're trying to pass an invalid object in "<ClerkProvider clerkState={...}>". | ||
|
|
||
| ${ssrExample} | ||
| `); | ||
|
|
||
| export const noClerkStateError = createErrorMessage(` | ||
| Looks like you didn't pass 'clerkState' to "<ClerkProvider clerkState={...}>". | ||
|
|
||
| ${ssrExample} | ||
| `); | ||
|
|
||
| export const noLoaderArgsPassedInGetAuth = createErrorMessage(` | ||
| You're calling 'getAuth()' from a loader, without providing the loader args object. | ||
| Example: | ||
|
|
||
| export const loader: LoaderFunction = async (args) => { | ||
| const { sessionId } = await getAuth(args); | ||
| ... | ||
| }; | ||
| `); | ||
|
|
||
| export const invalidRootLoaderCallbackReturn = createErrorMessage(` | ||
| You're returning an invalid response from the 'rootAuthLoader' called from the loader in root.tsx. | ||
| You can only return plain objects, responses created using the Remix 'json()' and 'redirect()' helpers, | ||
| custom redirect 'Response' instances (status codes in the range of 300 to 400), | ||
| or custom json 'Response' instances (containing a body that is a valid json string). | ||
| If you want to return a primitive value or an array, you can always wrap the response with an object. | ||
|
|
||
| Example: | ||
|
|
||
| export const loader: LoaderFunction = args => rootAuthLoader(args, ({ auth }) => { | ||
| const { userId } = auth; | ||
| const posts: Post[] = database.getPostsByUserId(userId); | ||
|
|
||
| return json({ data: posts }) | ||
| // or | ||
| return new Response(JSON.stringify({ data: posts }), { headers: { 'Content-Type': 'application/json' } }); | ||
| // or | ||
| return { data: posts }; | ||
| }) | ||
| `); | ||
|
|
||
| export const noSecretKeyError = createErrorMessage(` | ||
| A secretKey must be provided in order to use SSR and the exports from @clerk/remix/api.'); | ||
| If your runtime supports environment variables, you can add a CLERK_SECRET_KEY variable to your config. | ||
| Otherwise, you can pass a secretKey parameter to rootAuthLoader or getAuth. | ||
| `); | ||
|
|
||
| export const satelliteAndMissingProxyUrlAndDomain = createErrorMessage( | ||
| `Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl`, | ||
| ); | ||
|
|
||
| export const satelliteAndMissingSignInUrl = createErrorMessage(` | ||
| Invalid signInUrl. A satellite application requires a signInUrl for development instances. | ||
| Check if signInUrl is missing from your configuration or if it is not an absolute URL.`); | ||
| export { | ||
| isClerkAPIResponseError, | ||
| isEmailLinkError, | ||
| isKnownError, | ||
| isMetamaskError, | ||
| EmailLinkErrorCode, | ||
| } from '@clerk/clerk-react/errors'; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ import { isDevelopmentFromSecretKey } from '@clerk/shared/keys'; | |
| import { isHttpOrHttps, isProxyUrlRelative } from '@clerk/shared/proxy'; | ||
| import { isTruthy } from '@clerk/shared/underscore'; | ||
|
|
||
| import { noSecretKeyError, satelliteAndMissingProxyUrlAndDomain, satelliteAndMissingSignInUrl } from '../errors'; | ||
| import { getEnvVariable } from '../utils'; | ||
| import { noSecretKeyError, satelliteAndMissingProxyUrlAndDomain, satelliteAndMissingSignInUrl } from '../utils/errors'; | ||
| import { getEnvVariable } from '../utils/utils'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😓 this seems kind of weird, that's why i suggested the errors restructuring. |
||
| import type { LoaderFunctionArgs, RootAuthLoaderOptions } from './types'; | ||
|
|
||
| export const loadOptions = (args: LoaderFunctionArgs, overrides: RootAuthLoaderOptions = {}) => { | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,84 @@ | ||
| const createErrorMessage = (msg: string) => { | ||
| return `🔒 Clerk: ${msg.trim()} | ||
|
|
||
| For more info, check out the docs: https://clerk.com/docs, | ||
| or come say hi in our discord server: https://clerk.com/discord | ||
|
|
||
| `; | ||
| }; | ||
|
|
||
| const ssrExample = `Use 'rootAuthLoader' as your root loader. Then, simply wrap the App component with ClerkApp and make it the default export. | ||
| Example: | ||
|
|
||
| import { ClerkApp } from '@clerk/remix'; | ||
| import { rootAuthLoader } from '@clerk/remix/ssr.server'; | ||
|
|
||
| export const loader: LoaderFunction = args => rootAuthLoader(args) | ||
|
|
||
| function App() { | ||
| return ( | ||
| <html lang='en'> | ||
| ... | ||
| </html> | ||
| ); | ||
| } | ||
|
|
||
| export default ClerkApp(App, { publishableKey: '...' }); | ||
| `; | ||
|
|
||
| export const invalidClerkStatePropError = createErrorMessage(` | ||
| You're trying to pass an invalid object in "<ClerkProvider clerkState={...}>". | ||
|
|
||
| ${ssrExample} | ||
| `); | ||
|
|
||
| export const noClerkStateError = createErrorMessage(` | ||
| Looks like you didn't pass 'clerkState' to "<ClerkProvider clerkState={...}>". | ||
|
|
||
| ${ssrExample} | ||
| `); | ||
|
|
||
| export const noLoaderArgsPassedInGetAuth = createErrorMessage(` | ||
| You're calling 'getAuth()' from a loader, without providing the loader args object. | ||
| Example: | ||
|
|
||
| export const loader: LoaderFunction = async (args) => { | ||
| const { sessionId } = await getAuth(args); | ||
| ... | ||
| }; | ||
| `); | ||
|
|
||
| export const invalidRootLoaderCallbackReturn = createErrorMessage(` | ||
| You're returning an invalid response from the 'rootAuthLoader' called from the loader in root.tsx. | ||
| You can only return plain objects, responses created using the Remix 'json()' and 'redirect()' helpers, | ||
| custom redirect 'Response' instances (status codes in the range of 300 to 400), | ||
| or custom json 'Response' instances (containing a body that is a valid json string). | ||
| If you want to return a primitive value or an array, you can always wrap the response with an object. | ||
|
|
||
| Example: | ||
|
|
||
| export const loader: LoaderFunction = args => rootAuthLoader(args, ({ auth }) => { | ||
| const { userId } = auth; | ||
| const posts: Post[] = database.getPostsByUserId(userId); | ||
|
|
||
| return json({ data: posts }) | ||
| // or | ||
| return new Response(JSON.stringify({ data: posts }), { headers: { 'Content-Type': 'application/json' } }); | ||
| // or | ||
| return { data: posts }; | ||
| }) | ||
| `); | ||
|
|
||
| export const noSecretKeyError = createErrorMessage(` | ||
| A secretKey must be provided in order to use SSR and the exports from @clerk/remix/api.'); | ||
| If your runtime supports environment variables, you can add a CLERK_SECRET_KEY variable to your config. | ||
| Otherwise, you can pass a secretKey parameter to rootAuthLoader or getAuth. | ||
| `); | ||
|
|
||
| export const satelliteAndMissingProxyUrlAndDomain = createErrorMessage( | ||
| `Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl`, | ||
| ); | ||
|
|
||
| export const satelliteAndMissingSignInUrl = createErrorMessage(` | ||
| Invalid signInUrl. A satellite application requires a signInUrl for development instances. | ||
| Check if signInUrl is missing from your configuration or if it is not an absolute URL.`); |
This file contains hidden or 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 './utils'; |
2 changes: 1 addition & 1 deletion
2
packages/remix/src/utils.ts → packages/remix/src/utils/utils.ts
This file contains hidden or 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 hidden or 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,4 @@ | ||
| { | ||
| "main": "../dist/ssr/index.js", | ||
| "types": "../dist/ssr/index.d.ts" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 Wdyt about introducing a different structure to support subpath
errorsand error messages? EgI would prefer if we kept all the errors in the same place and avoid adding them to
utils"bucket".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, but we cannot do this using a single
errors.tsas this is the top-level entry file for the publicly available errors.This PR changes the top-level API. I will open follow-up PR that aligns the strategy used in clerk/remix with the other packages as well.
Having a
internalErrorscould be enough, or we could always have a./errors/containing internal error utils and a./errors.tstop level entry point for the public APIs