schemas.ts — astro Source File
Architecture documentation for schemas.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 05094702_dfea_fe15_694a_0f5d1d294954["schemas.ts"] 22a59779_880d_0799_08b9_126d5432bad6["./types.js"] 05094702_dfea_fe15_694a_0f5d1d294954 --> 22a59779_880d_0799_08b9_126d5432bad6 befc0c6e_040a_fbf0_7cea_2d0ac6cf2570["./integration/error-map.js"] 05094702_dfea_fe15_694a_0f5d1d294954 --> befc0c6e_040a_fbf0_7cea_2d0ac6cf2570 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8["./core/types.js"] 05094702_dfea_fe15_694a_0f5d1d294954 --> 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8 6ae6435e_1314_7d59_4826_25e9a2ada03f["./utils.js"] 05094702_dfea_fe15_694a_0f5d1d294954 --> 6ae6435e_1314_7d59_4826_25e9a2ada03f 5e5ea2f4_4ff1_f558_0bea_0b3ded79b0ac["drizzle-orm"] 05094702_dfea_fe15_694a_0f5d1d294954 --> 5e5ea2f4_4ff1_f558_0bea_0b3ded79b0ac fb1af543_c710_bc94_95c6_6f94e01b66dd["sqlite-core"] 05094702_dfea_fe15_694a_0f5d1d294954 --> fb1af543_c710_bc94_95c6_6f94e01b66dd f8c9251e_f535_6281_2118_9e79a4155212["v4"] 05094702_dfea_fe15_694a_0f5d1d294954 --> f8c9251e_f535_6281_2118_9e79a4155212 style 05094702_dfea_fe15_694a_0f5d1d294954 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { SQL } from 'drizzle-orm';
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
import * as z from 'zod/v4';
import { SERIALIZED_SQL_KEY, type SerializedSQL } from '../runtime/types.js';
import { errorMap } from './integration/error-map.js';
import type { NumberColumn, TextColumn } from './types.js';
import { mapObject } from './utils.js';
export type MaybeArray<T> = T | T[];
// Transform to serializable object for migration files
const sqlite = new SQLiteAsyncDialect();
const sqlSchema = z.instanceof(SQL<any>).transform(
(sqlObj): SerializedSQL => ({
[SERIALIZED_SQL_KEY]: true,
sql: sqlite.sqlToQuery(sqlObj).sql,
}),
);
const baseColumnSchema = z.object({
label: z.string().optional(),
optional: z.boolean().optional().default(false),
unique: z.boolean().optional().default(false),
deprecated: z.boolean().optional().default(false),
// Defined when `defineDb()` is called to resolve `references`
name: z.string().optional(),
// TODO: Update to `table`. Will need migration file version change
collection: z.string().optional(),
});
export const booleanColumnSchema = z.object({
type: z.literal('boolean'),
schema: baseColumnSchema.extend({
default: z.union([z.boolean(), sqlSchema]).optional(),
}),
});
const numberColumnBaseSchema = baseColumnSchema.omit({ optional: true }).and(
z.union([
z.object({
primaryKey: z.literal(false).optional().default(false),
optional: baseColumnSchema.shape.optional,
default: z.union([z.number(), sqlSchema]).optional(),
}),
z.object({
// `integer primary key` uses ROWID as the default value.
// `optional` and `default` do not have an effect,
// so disable these config options for primary keys.
primaryKey: z.literal(true),
optional: z.literal(false).optional(),
default: z.literal(undefined).optional(),
}),
]),
);
export const numberColumnOptsSchema: z.ZodType<
z.infer<typeof numberColumnBaseSchema> & {
// ReferenceableColumn creates a circular type. Define ZodType to resolve.
// ... (191 more lines)
Domain
Subdomains
Dependencies
- ./core/types.js
- ./integration/error-map.js
- ./types.js
- ./utils.js
- drizzle-orm
- sqlite-core
- v4
Source
Frequently Asked Questions
What does schemas.ts do?
schemas.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in schemas.ts?
schemas.ts defines 4 function(s): dbConfigSchema, sqlSchema, tablesSchema, z.
What does schemas.ts depend on?
schemas.ts imports 7 module(s): ./core/types.js, ./integration/error-map.js, ./types.js, ./utils.js, drizzle-orm, sqlite-core, v4.
Where is schemas.ts in the architecture?
schemas.ts is located at packages/db/src/core/schemas.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/db/src/core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free