Home / File/ refined.ts — astro Source File

refined.ts — astro Source File

Architecture documentation for refined.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  64f1a8c8_b6f3_9ca7_111f_46db95c72a38["refined.ts"]
  c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"]
  64f1a8c8_b6f3_9ca7_111f_46db95c72a38 --> c32d12e2_d85e_28c0_eea7_9b29629857e0
  f8c9251e_f535_6281_2118_9e79a4155212["v4"]
  64f1a8c8_b6f3_9ca7_111f_46db95c72a38 --> f8c9251e_f535_6281_2118_9e79a4155212
  style 64f1a8c8_b6f3_9ca7_111f_46db95c72a38 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as z from 'zod/v4';
import type { AstroConfig } from '../../../types/public/config.js';

export const AstroConfigRefinedSchema = z.custom<AstroConfig>().superRefine((config, ctx) => {
	if (
		config.build.assetsPrefix &&
		typeof config.build.assetsPrefix !== 'string' &&
		!config.build.assetsPrefix.fallback
	) {
		ctx.addIssue({
			code: z.ZodIssueCode.custom,
			message: 'The `fallback` is mandatory when defining the option as an object.',
			path: ['build', 'assetsPrefix'],
		});
	}

	for (let i = 0; i < config.image.remotePatterns.length; i++) {
		const { hostname, pathname } = config.image.remotePatterns[i];

		if (
			hostname &&
			hostname.includes('*') &&
			!(hostname.startsWith('*.') || hostname.startsWith('**.'))
		) {
			ctx.addIssue({
				code: z.ZodIssueCode.custom,
				message: 'wildcards can only be placed at the beginning of the hostname',
				path: ['image', 'remotePatterns', i, 'hostname'],
			});
		}

		if (
			pathname &&
			pathname.includes('*') &&
			!(pathname.endsWith('/*') || pathname.endsWith('/**'))
		) {
			ctx.addIssue({
				code: z.ZodIssueCode.custom,
				message: 'wildcards can only be placed at the end of a pathname',
				path: ['image', 'remotePatterns', i, 'pathname'],
			});
		}
	}

	if (
		config.i18n &&
		typeof config.i18n.routing !== 'string' &&
		config.i18n.routing.prefixDefaultLocale === false &&
		config.i18n.routing.redirectToDefaultLocale === true
	) {
		ctx.addIssue({
			code: z.ZodIssueCode.custom,
			message:
				'The option `i18n.routing.redirectToDefaultLocale` can be used only when `i18n.routing.prefixDefaultLocale` is set to `true`, otherwise redirects might cause infinite loops. Remove the option `i18n.routing.redirectToDefaultLocale`, or change its value to `false`.',
			path: ['i18n', 'routing', 'redirectToDefaultLocale'],
		});
	}

	if (config.outDir.toString().startsWith(config.publicDir.toString())) {
		ctx.addIssue({
// ... (130 more lines)

Domain

Subdomains

Dependencies

  • ../types/public/config.js
  • v4

Frequently Asked Questions

What does refined.ts do?
refined.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in refined.ts?
refined.ts defines 1 function(s): AstroConfigRefinedSchema.
What does refined.ts depend on?
refined.ts imports 2 module(s): ../types/public/config.js, v4.
Where is refined.ts in the architecture?
refined.ts is located at packages/astro/src/core/config/schemas/refined.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/core/config/schemas).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free