Home / File/ typegen.ts — astro Source File

typegen.ts — astro Source File

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

File typescript CoreAstro CoreMiddleware 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  cfd4bd09_8623_b9e9_1f9b_643824244dcb["typegen.ts"]
  eda9bb18_dc7e_2d22_8ac4_4f2697d51221["./consts.js"]
  cfd4bd09_8623_b9e9_1f9b_643824244dcb --> eda9bb18_dc7e_2d22_8ac4_4f2697d51221
  97fa73a6_cf67_73a5_b60d_d52bfb00c7d8["./core/types.js"]
  cfd4bd09_8623_b9e9_1f9b_643824244dcb --> 97fa73a6_cf67_73a5_b60d_d52bfb00c7d8
  style cfd4bd09_8623_b9e9_1f9b_643824244dcb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { RUNTIME_IMPORT } from '../consts.js';
import type { DBTable, DBTables } from '../types.js';

export function getDtsContent(tables: DBTables) {
	const content = `// This file is generated by Astro DB
declare module 'astro:db' {
${Object.entries(tables)
	.map(([name, table]) => generateTableType(name, table))
	.join('\n')}
}
`;
	return content;
}

function generateTableType(name: string, table: DBTable): string {
	const sanitizedColumnsList = Object.entries(table.columns)
		// Filter out deprecated columns from the typegen, so that they don't
		// appear as queryable fields in the generated types / your codebase.
		.filter(([, val]) => !val.schema.deprecated);
	const sanitizedColumns = Object.fromEntries(sanitizedColumnsList);
	let tableType = `	export const ${name}: import(${RUNTIME_IMPORT}).Table<
		${JSON.stringify(name)},
		${JSON.stringify(sanitizedColumns)}
	>;`;
	return tableType;
}

Domain

Subdomains

Dependencies

  • ./consts.js
  • ./core/types.js

Frequently Asked Questions

What does typegen.ts do?
typegen.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 typegen.ts?
typegen.ts defines 2 function(s): generateTableType, getDtsContent.
What does typegen.ts depend on?
typegen.ts imports 2 module(s): ./consts.js, ./core/types.js.
Where is typegen.ts in the architecture?
typegen.ts is located at packages/db/src/core/integration/typegen.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/db/src/core/integration).

Analyze Your Own Codebase

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

Try Supermodel Free