@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
1 lines • 7.24 kB
Source Map (JSON)
{"version":3,"file":"warnings.mjs","names":[],"sources":["../../../src/internal/clerk-js/warnings.ts"],"sourcesContent":["import type { Serializable } from '../../types';\n\nconst formatWarning = (msg: string) => {\n return `🔒 Clerk:\\n${msg.trim()}\\n(This notice only appears in development)`;\n};\n\nconst createMessageForDisabledOrganizations = (\n componentName:\n | 'OrganizationProfile'\n | 'OrganizationSwitcher'\n | 'OrganizationList'\n | 'CreateOrganization'\n | 'TaskChooseOrganization'\n | 'ConfigureSSO',\n) => {\n return formatWarning(\n `The <${componentName}/> cannot be rendered when the feature is turned off. Visit 'dashboard.clerk.com' to enable the feature. Since the feature is turned off, this is no-op.`,\n );\n};\n\nconst createCannotRenderComponentWhenOrgDoesNotExist = (componentName: 'OrganizationProfile' | 'ConfigureSSO') => {\n return formatWarning(\n `<${componentName}/> cannot render unless an organization is active. Since no organization is currently active, this is no-op.`,\n );\n};\n\nconst createMessageForDisabledBilling = (componentName: 'PricingTable' | 'Checkout' | 'PlanDetails') => {\n return formatWarning(\n `The <${componentName}/> component cannot be rendered when billing is disabled. Visit 'https://dashboard.clerk.com/last-active?path=billing/settings' to follow the necessary steps to enable billing. Since billing is disabled, this is no-op.`,\n );\n};\n\nconst propertyAsFunctionNotSupported = (property: 'proxyUrl' | 'domain') => {\n return formatWarning(\n `${property} as a function is not supported in this environment. The value will be ignored. Provide an absolute URL instead.`,\n );\n};\n\nconst warnings = {\n proxyUrlAsFunctionNotSupported: propertyAsFunctionNotSupported('proxyUrl'),\n domainAsFunctionNotSupported: propertyAsFunctionNotSupported('domain'),\n cannotRenderComponentWhenSessionExists:\n 'The <SignUp/> and <SignIn/> components cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the Home URL instead.',\n cannotRenderSignUpComponentWhenSessionExists:\n 'The <SignUp/> component cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the value set in `afterSignUp` URL instead.',\n cannotRenderSignUpComponentWhenTaskExists:\n 'The <SignUp/> component cannot render when a user has a pending task, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the task instead.',\n cannotRenderComponentWhenTaskDoesNotExist:\n '<TaskChooseOrganization/> cannot render unless a session task is pending. Clerk is redirecting to the value set in `redirectUrlComplete` instead.',\n cannotRenderSignInComponentWhenSessionExists:\n 'The <SignIn/> component cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the `afterSignIn` URL instead.',\n cannotRenderSignInComponentWhenTaskExists:\n 'The <SignIn/> component cannot render when a user has a pending task, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the task instead.',\n cannotRenderComponentWhenUserDoesNotExist:\n '<UserProfile/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.',\n createCannotRenderComponentWhenOrgDoesNotExist,\n cannotRenderAnyOrganizationComponent: createMessageForDisabledOrganizations,\n cannotRenderAnyBillingComponent: createMessageForDisabledBilling,\n cannotOpenUserProfile:\n 'The UserProfile modal cannot render unless a user is signed in. Since no user is signed in, this is no-op.',\n cannotOpenCheckout:\n 'The Checkout drawer cannot render unless a user is signed in. Since no user is signed in, this is no-op.',\n cannotOpenSignInOrSignUp:\n 'The <SignIn/> and <SignUp/> modals are hidden because a user is already signed in and this application is configured for single-session mode. This is expected behavior — no action is needed. To allow rendering while signed in, enable multi-session mode in your Clerk Dashboard.',\n cannotRenderAPIKeysComponent:\n 'The <APIKeys/> component cannot be rendered when API keys is disabled. Since API keys is disabled, this is no-op.',\n cannotRenderAPIKeysComponentForOrgWhenUnauthorized:\n 'The <APIKeys/> component cannot be rendered for an organization unless a user has the required permissions. Since the user does not have the necessary permissions, this is no-op.',\n cannotRenderAPIKeysComponentForUserWhenDisabled:\n 'The <APIKeys/> component cannot be rendered when user API keys are disabled. Since user API keys are disabled, this is no-op.',\n cannotRenderAPIKeysComponentForOrgWhenDisabled:\n 'The <APIKeys/> component cannot be rendered when organization API keys are disabled. Since organization API keys are disabled, this is no-op.',\n cannotRenderOAuthConsentComponentWhenUserDoesNotExist:\n '<OAuthConsent/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.',\n cannotRenderConfigureSSOComponentWhenUserDoesNotExist:\n '<ConfigureSSO/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.',\n cannotRenderConfigureSSOComponentWhenDisabled:\n 'The <ConfigureSSO/> component cannot be rendered when self-serve SSO is disabled. Visit `https://dashboard.clerk.com` to enable the feature. Since self-serve SSO is disabled, this is no-op.',\n cannotRenderConfigureSSOComponentWhenEmailAddressDisabled:\n 'The <ConfigureSSO/> component cannot be rendered when email addresses are disabled on the instance. Visit `https://dashboard.clerk.com` to enable email addresses. Since email addresses are disabled, this is no-op.',\n};\n\ntype SerializableWarnings = Serializable<typeof warnings>;\n\nfor (const key of Object.keys(warnings)) {\n const item = warnings[key as keyof typeof warnings];\n if (typeof item !== 'function') {\n warnings[key as keyof SerializableWarnings] = formatWarning(item);\n }\n}\n\nexport { warnings };\n"],"mappings":";AAEA,MAAM,iBAAiB,QAAgB;CACrC,OAAO,cAAc,IAAI,KAAK,EAAE;AAClC;AAEA,MAAM,yCACJ,kBAOG;CACH,OAAO,cACL,QAAQ,cAAc,yJACxB;AACF;AAEA,MAAM,kDAAkD,kBAA0D;CAChH,OAAO,cACL,IAAI,cAAc,6GACpB;AACF;AAEA,MAAM,mCAAmC,kBAA+D;CACtG,OAAO,cACL,QAAQ,cAAc,2NACxB;AACF;AAEA,MAAM,kCAAkC,aAAoC;CAC1E,OAAO,cACL,GAAG,SAAS,iHACd;AACF;AAEA,MAAM,WAAW;CACf,gCAAgC,+BAA+B,UAAU;CACzE,8BAA8B,+BAA+B,QAAQ;CACrE,wCACE;CACF,8CACE;CACF,2CACE;CACF,2CACE;CACF,8CACE;CACF,2CACE;CACF,2CACE;CACF;CACA,sCAAsC;CACtC,iCAAiC;CACjC,uBACE;CACF,oBACE;CACF,0BACE;CACF,8BACE;CACF,oDACE;CACF,iDACE;CACF,gDACE;CACF,uDACE;CACF,uDACE;CACF,+CACE;CACF,2DACE;AACJ;AAIA,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,GAAG;CACvC,MAAM,OAAO,SAAS;CACtB,IAAI,OAAO,SAAS,YAClB,SAAS,OAAqC,cAAc,IAAI;AAEpE"}