Files
twenty/packages/twenty-front/src/testing/mock-data/config.ts
T
Marie d8b494d530 Make subdomain minimum length configurable via env var (#23209)
## What

Introduces a `SUBDOMAIN_MIN_LENGTH` environment variable (default `3`)
controlling the minimum number of characters allowed for a workspace
subdomain.

Until now the minimum was hardcoded (`3`), baked into the shared
`SUBDOMAIN_PATTERN` regex.

## How

- Added the `SUBDOMAIN_MIN_LENGTH` config variable (default `3`) in
`config-variables.ts`.
- Relaxed `SUBDOMAIN_PATTERN` in `twenty-shared` to validate format and
max length only, so the minimum length policy now lives with the caller
instead of being embedded in the regex.
- `isSubdomainValid` now takes a `minLength` argument (defaulting to
`3`) and enforces it explicitly.
- `SubdomainManagerService` reads `SUBDOMAIN_MIN_LENGTH` from config and
passes it to every validation call, making the server the authoritative
source.

## Scope

Server-side only. The frontend validation schema keeps its default
`.min(3)` UX check and is unchanged; the server remains the source of
truth for what subdomains are accepted.

## Tests

- Updated the shared `isValidTwentySubdomain` tests to reflect that the
pattern no longer enforces a minimum length.
- Added tests for the configurable minimum in
`is-subdomain-valid.util.spec.ts`.
- Updated the service spec config mock to return a numeric value for
`SUBDOMAIN_MIN_LENGTH`.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/23209?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
2026-08-06 11:03:18 +00:00

75 lines
2.0 KiB
TypeScript

import { type ClientConfig } from '@/client-config/types/ClientConfig';
import { CaptchaDriverType, SupportDriver } from '~/generated-metadata/graphql';
export const mockedClientConfig: ClientConfig = {
aiModels: [],
signInPrefilled: true,
isMultiWorkspaceEnabled: false,
isCookieSessionEnabled: false,
isEmailVerificationRequired: false,
authProviders: {
google: true,
magicLink: false,
password: true,
microsoft: false,
sso: [],
},
frontDomain: 'localhost',
defaultSubdomain: 'app',
subdomainMinLength: 3,
analyticsEnabled: true,
support: {
supportDriver: SupportDriver.FRONT,
supportFrontChatId: null,
},
sentry: {
dsn: 'MOCKED_DSN',
release: 'MOCKED_RELEASE',
environment: 'MOCKED_ENVIRONMENT',
},
billing: {
isBillingEnabled: true,
billingUrl: '',
trialPeriods: [
{
duration: 30,
isCreditCardRequired: true,
},
{
duration: 7,
isCreditCardRequired: false,
},
],
},
captcha: {
provider: CaptchaDriverType.GOOGLE_RECAPTCHA,
siteKey: 'MOCKED_SITE_KEY',
},
api: { mutationMaximumAffectedRecords: 100 },
onboarding: {
importContactsCreditsReward: 2,
inviteTeamMaxCreditsReward: 9,
inviteTeamCreditsRewardPerUser: 3,
upgradeCreditsReward: 5,
installAppsCreditsRewardPerApp: 1,
},
canManageFeatureFlags: true,
publicFeatureFlags: [],
isMicrosoftMessagingEnabled: true,
isMicrosoftCalendarEnabled: true,
isGoogleMessagingEnabled: true,
isGoogleCalendarEnabled: true,
isAttachmentPreviewEnabled: true,
isConfigVariablesInDbEnabled: false,
isImapSmtpCaldavEnabled: false,
isTwoFactorAuthenticationEnabled: false,
isEmailingDomainInDemoMode: false,
allowRequestsToTwentyIcons: true,
isCloudflareIntegrationEnabled: false,
isClickHouseConfigured: false,
isWorkspaceSchemaDDLLocked: false,
isOnboardingAiChatEnabled: false,
isBookCallOnboardingStepEnabled: false,
isCompanyEnrichmentEnabled: false,
};