Home / File/ schema.ts — astro Source File

schema.ts — astro Source File

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

File typescript CoreAstro RenderingEngine 1 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  d9c64fcc_8e8a_5778_7acf_2d11fa82f9c4["schema.ts"]
  f8c9251e_f535_6281_2118_9e79a4155212["v4"]
  d9c64fcc_8e8a_5778_7acf_2d11fa82f9c4 --> f8c9251e_f535_6281_2118_9e79a4155212
  style d9c64fcc_8e8a_5778_7acf_2d11fa82f9c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as z from 'zod/v4';

const StringSchema = z.object({
	type: z.literal('string'),
	optional: z.boolean().optional(),
	default: z.string().optional(),
	max: z.number().optional(),
	min: z.number().min(0).optional(),
	length: z.number().optional(),
	url: z.boolean().optional(),
	includes: z.string().optional(),
	startsWith: z.string().optional(),
	endsWith: z.string().optional(),
});
export type StringSchema = z.infer<typeof StringSchema>;
const NumberSchema = z.object({
	type: z.literal('number'),
	optional: z.boolean().optional(),
	default: z.number().optional(),
	gt: z.number().optional(),
	min: z.number().optional(),
	lt: z.number().optional(),
	max: z.number().optional(),
	int: z.boolean().optional(),
});
export type NumberSchema = z.infer<typeof NumberSchema>;
const BooleanSchema = z.object({
	type: z.literal('boolean'),
	optional: z.boolean().optional(),
	default: z.boolean().optional(),
});
const EnumSchema = z.object({
	type: z.literal('enum'),
	values: z.array(
		// We use "'" for codegen so it can't be passed here
		z
			.string()
			.refine((v) => !v.includes("'"), {
				message: `The "'" character can't be used as an enum value`,
			}),
	),
	optional: z.boolean().optional(),
	default: z.string().optional(),
});
export type EnumSchema = z.infer<typeof EnumSchema>;

const EnvFieldType = z.union([
	StringSchema,
	NumberSchema,
	BooleanSchema,
	EnumSchema.superRefine((schema, ctx) => {
		if (schema.default) {
			if (!schema.values.includes(schema.default)) {
				ctx.addIssue({
					code: z.ZodIssueCode.custom,
					message: `The default value "${
						schema.default
					}" must be one of the specified values: ${schema.values.join(', ')}.`,
				});
			}
// ... (84 more lines)

Domain

Subdomains

Dependencies

  • v4

Frequently Asked Questions

What does schema.ts do?
schema.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 schema.ts?
schema.ts defines 3 function(s): EnvFieldMetadata, EnvFieldType, EnvSchemaKey.
What does schema.ts depend on?
schema.ts imports 1 module(s): v4.
Where is schema.ts in the architecture?
schema.ts is located at packages/astro/src/env/schema.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/env).

Analyze Your Own Codebase

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

Try Supermodel Free