import type { NextResponse } from 'next/server.js'; import type { Languages } from 'next/dist/lib/metadata/types/alternative-urls-types'; import type { Videos } from 'next/dist/lib/metadata/types/metadata-types'; import type { CookieConsentDialogProps } from '../cookie_consent/client/components/cookie_consent_dialog.js'; import type { PrivacyPolicyUpdateDialogProps } from '../cookie_consent/client/components/privacy_policy_update_dialog.js'; import type { ConsentValue } from '../cookie_consent/types.js'; import type { User } from '@firebase/auth'; import type { ConfigValue, FallibleConfigValue, DbRoutingConfig, SupabaseDbConfig } from 'cloudflare-next-intl-db'; export type MiddlewareCustomHandler = (locale: string, rewriteUrl: URL | undefined, redirectUrl: URL | undefined) => NextResponse | null | Promise | null>; export type Locales = readonly string[]; export type LocalePrefixMode = 'always' | 'as-needed' | 'never'; export interface RoutingConfig { locales: AppLocales; defaultLocale: string; localePrefix?: AppLocalePrefixMode; localeCookie?: false | CookieAttributes; localeDetection?: boolean; firebaseAuth?: FirebaseAuthRoutingConfig; db?: DbRoutingConfig; cookieConsent?: CookieConsentRoutingConfig; generate?: GenerateRoutingConfig; errorHandling?: ErrorHandlingRoutingConfig; link?: LinkRoutingConfig; } export interface LinkRoutingConfig { defaultPrefetch?: boolean; } export interface GenerateRoutingConfig { env?: object | Record | (() => object | Record | Promise>); ctx?: { waitUntil?: (promise: Promise) => void; } | (() => { waitUntil?: (promise: Promise) => void; } | undefined); getCloudflareContext?: CookieConsentGetCloudflareContext; countryHeaderNames?: readonly string[]; countryCookieName?: string; timezoneHeaderNames?: readonly string[]; timezoneCookieName?: string; } export type RequestOrHeaders = Request | Headers | { headers?: Headers | Record; cookies?: { get?: (name: string) => { value?: string; } | string | undefined; }; cf?: { country?: string; timezone?: string; [key: string]: unknown; }; } | undefined; export interface ErrorHandlingParams { error: unknown; classOrMethodName: string; params?: unknown; isClient?: boolean; consent?: ConsentValue; formattedMessage?: string; dedupKey?: string; useAuthUser?: boolean; } export interface ErrorHandlingRoutingConfig { enable?: boolean; onError?: (params: ErrorHandlingParams) => void | Promise; logToConsole?: boolean; overrideConsoleError?: boolean; suppressClientConsoleError?: boolean; ignoreConsoleErrors?: readonly string[]; staleDeployPatterns?: readonly string[]; staleDeployReloadHtml?: string; ignoreConsoleError?: (message: string) => boolean; overrideWindowErrors?: boolean; dedup?: boolean; throttleMs?: number; resetDedup?: boolean; } export interface CookieConsentRoutingConfig { privacyPolicyDate?: string | Date; privacyPolicyPath?: string | false; showPrivacyPolicy?: boolean; consentCookieName?: string; privacyPolicyDateCookieName?: string; cookieMaxAge?: number; autoWireAnalytics?: boolean; analytics?: CookieConsentAnalyticsConfig; getAnalytics?: () => CookieConsentAnalyticsConfig | Promise; autoAnalyticsEvents?: AutoAnalyticsEventsConfig; getCountryCode?: () => string | undefined | Promise; countryHeaderNames?: readonly string[]; countryCookieName?: string; gdprCountries?: readonly string[]; enableAnalyticsInDevMode?: boolean; autoWireDialogs?: boolean; dialogProps?: CookieConsentDialogProps; updateDialogProps?: PrivacyPolicyUpdateDialogProps; } export interface CookieConsentCloudflareContext { cf?: Record; ctx?: { waitUntil?: (promise: Promise) => void; }; } export interface CookieConsentGetCloudflareContext { (options: { async: true; }): Promise; (options?: { async: false; }): CookieConsentCloudflareContext | null; } export type AutoAnalyticsEventName = 'screen_view' | 'web_cls' | 'web_fcp' | 'web_fid' | 'web_lcp' | 'web_ttfb' | 'web_inp'; export interface AutoAnalyticsEventsConfig { events?: readonly AutoAnalyticsEventName[]; getScreenName?: (path: string) => string; } export interface CookieConsentAnalyticsConfig { cloudflareBeaconToken?: string; googleAnalyticsId?: string; googleAdsId?: string; googleAdSenseId?: string; clarityProjectId?: string; } export interface FirebaseAuthRoutingConfig { middlewareEnabled?: boolean; autoWireClientProvider?: boolean; apiKey: string; authDomain: string; projectId: string; storageBucket?: string; messagingSenderId?: string; appId: string; measurementId?: string; performance?: boolean; appCheck?: FirebaseAppCheckConfig; redirectAuthPath: string; homePath: string; verifyEmailPath?: string; resetPasswordPath?: string; recoverEmailPath?: string; signInPath?: string; actionModePaths?: Readonly>; actionLinkRedirectEnabled?: boolean; followSameOriginContinueUrl?: boolean; actionLinkPath?: string; stripActionLinkQuery?: boolean; preserveRedirectQuery?: boolean; isAuthPath: (path: string) => boolean; whiteListPaths?: readonly string[]; protectedPaths?: (path: string) => boolean; sessionCookieMaxAge?: number; refreshTokenCookieMaxAge?: number; sessionCookieName?: string; refreshTokenCookieName?: string; emailVerifiedHintCookieName?: string; appCheckTokenCookieName?: string; appCheckTokenCookieMaxAge?: number; onSignIn?: (user: User) => void | Promise; onEmailVerified?: (user: User) => void | Promise; onSignOut?: () => void | Promise; } export interface FirebaseAppCheckConfig { recaptchaV3SiteKey?: string; recaptchaEnterpriseSiteKey?: string; useExplicitRecaptchaScript?: boolean; debugToken?: boolean | string; isTokenAutoRefreshEnabled?: boolean; clientEmail: string; privateKey?: string; oauthClientId?: string; oauthClientSecret?: string; oauthRefreshToken?: string; appId: string; reportMissingServerCredentials?: boolean; } export interface CookieAttributes { domain?: string | undefined; encode?(value: string): string; expires?: Date | undefined; httpOnly?: boolean | undefined; maxAge?: number | undefined; partitioned?: boolean | undefined; path?: string | undefined; priority?: "low" | "medium" | "high" | undefined; sameSite?: true | false | "lax" | "strict" | "none" | undefined; secure?: boolean | undefined; } export type TranslationEntry = string | TranslationObject | TranslationEntry[]; export interface TranslationObject { [key: string]: TranslationEntry; } export type ReturnType = string; export interface TranslatorReturnType { (key: string): ReturnType; raw(key: string): TranslationEntry; } export type changeFrequency = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never' | undefined; export type Alternates = { languages?: Languages | undefined; } | undefined; export interface IntlSitemap { link?: string; changeFrequency?: changeFrequency; priority?: number | undefined; images?: string[] | undefined; lastModified: Date | string | undefined; videos?: Videos[] | undefined; } export type { ConfigValue, FallibleConfigValue, DbRoutingConfig, SupabaseDbConfig };