types.ts — astro Source File
Architecture documentation for types.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR a146b99b_6ede_06f0_3c83_b19531b5f76a["types.ts"] d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> d3861967_b647_84d2_ff48_15013353bd56 c32d12e2_d85e_28c0_eea7_9b29629857e0["../types/public/config.js"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> c32d12e2_d85e_28c0_eea7_9b29629857e0 7f07e12d_4af0_1918_f31b_31410b415993["../types/public/content.js"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> 7f07e12d_4af0_1918_f31b_31410b415993 b1ad5044_5dee_93fa_9942_3365c09d93c8["../../content/data-store.js"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> b1ad5044_5dee_93fa_9942_3365c09d93c8 f0d8d494_c471_39a6_5e1f_0ed356c4f6d8["../../content/mutable-data-store.js"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> f0d8d494_c471_39a6_5e1f_0ed356c4f6d8 263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7 a2586aae_ce09_613d_4444_659268b61a89["core"] a146b99b_6ede_06f0_3c83_b19531b5f76a --> a2586aae_ce09_613d_4444_659268b61a89 style a146b99b_6ede_06f0_3c83_b19531b5f76a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { FSWatcher } from 'vite';
import type * as z from 'zod/v4/core';
import type { AstroIntegrationLogger } from '../../core/logger/core.js';
import type { AstroConfig } from '../../types/public/config.js';
import type {
ContentEntryType,
LiveDataCollection,
LiveDataEntry,
} from '../../types/public/content.js';
import type { RenderedContent } from '../data-store.js';
import type { DataStore, MetaStore } from '../mutable-data-store.js';
export type { DataStore, MetaStore };
export interface RenderMarkdownOptions {
/** The file URL of the markdown file being rendered */
fileURL?: URL;
}
export interface ParseDataOptions<TData extends Record<string, unknown>> {
/** The ID of the entry. Unique per collection */
id: string;
/** The raw, unvalidated data of the entry */
data: TData;
/** An optional file path, where the entry represents a local file. */
filePath?: string;
}
export interface LoaderContext {
/** The unique name of the collection */
collection: string;
/** A database to store the actual data */
store: DataStore;
/** A simple KV store, designed for things like sync tokens */
meta: MetaStore;
logger: AstroIntegrationLogger;
/** Astro config, with user config and merged defaults */
config: AstroConfig;
/** Validates and parses the data according to the collection schema */
parseData<TData extends Record<string, unknown>>(props: ParseDataOptions<TData>): Promise<TData>;
/** Renders markdown content to HTML and metadata */
renderMarkdown(content: string, options?: RenderMarkdownOptions): Promise<RenderedContent>;
/** Generates a non-cryptographic content digest. This can be used to check if the data has changed */
generateDigest(data: Record<string, unknown> | string): string;
/** When running in dev, this is a filesystem watcher that can be used to trigger updates */
watcher?: FSWatcher;
/** If the loader has been triggered by an integration, this may optionally contain extra data set by that integration */
refreshContextData?: Record<string, unknown>;
/** @internal */
entryTypes: Map<string, ContentEntryType>;
}
export type Loader = {
/** Unique name of the loader, e.g. the npm package name */
name: string;
/** Do the actual loading of the data */
load: (context: LoaderContext) => Promise<void>;
} & (
| {
/** Optionally, define the schema of the data. Will be overridden by user-defined schema */
schema?: z.$ZodType;
}
| {
/** Optionally, provide a function to dynamically provide a schema. Will be overridden by user-defined schema */
createSchema?: () => Promise<{
schema: z.$ZodType;
types: string;
}>;
}
);
export interface LoadEntryContext<TEntryFilter = never> {
filter: TEntryFilter extends never ? { id: string } : TEntryFilter;
collection: string;
}
export interface LoadCollectionContext<TCollectionFilter = unknown> {
filter?: TCollectionFilter;
collection: string;
}
export interface LiveLoader<
TData extends Record<string, any> = Record<string, unknown>,
TEntryFilter extends Record<string, any> | never = never,
TCollectionFilter extends Record<string, any> | never = never,
TError extends Error = Error,
> {
/** Unique name of the loader, e.g. the npm package name */
name: string;
/** Load a single entry */
loadEntry: (
context: LoadEntryContext<TEntryFilter>,
) => Promise<LiveDataEntry<TData> | undefined | { error: TError }>;
/** Load a collection of entries */
loadCollection: (
context: LoadCollectionContext<TCollectionFilter>,
) => Promise<LiveDataCollection<TData> | { error: TError }>;
}
Domain
Subdomains
Types
Dependencies
- ../../content/data-store.js
- ../../content/mutable-data-store.js
- ../core/logger/core.js
- ../types/public/config.js
- ../types/public/content.js
- core
- vite
Source
Frequently Asked Questions
What does types.ts do?
types.ts is a source file in the astro codebase, written in typescript. It belongs to the ContentCollections domain, DataLoaders subdomain.
What functions are defined in types.ts?
types.ts defines 2 function(s): context, z.
What does types.ts depend on?
types.ts imports 7 module(s): ../../content/data-store.js, ../../content/mutable-data-store.js, ../core/logger/core.js, ../types/public/config.js, ../types/public/content.js, core, vite.
Where is types.ts in the architecture?
types.ts is located at packages/astro/src/content/loaders/types.ts (domain: ContentCollections, subdomain: DataLoaders, directory: packages/astro/src/content/loaders).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free