blocks.ts — ui Source File
Architecture documentation for blocks.ts, a typescript file in the ui codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 79002c8a_43c0_28c4_2b18_096fa400899d["blocks.ts"] ceec689a_1334_a657_3c35_094070222b09["schema"] 79002c8a_43c0_28c4_2b18_096fa400899d --> ceec689a_1334_a657_3c35_094070222b09 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] 79002c8a_43c0_28c4_2b18_096fa400899d --> 6802ce19_522d_e5fb_e458_8826d9f6952e style 79002c8a_43c0_28c4_2b18_096fa400899d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use server"
import { registryItemSchema } from "shadcn/schema"
import { type z } from "zod"
export async function getAllBlockIds(
types: z.infer<typeof registryItemSchema>["type"][] = [
"registry:block",
"registry:internal",
],
categories: string[] = []
): Promise<string[]> {
const blocks = await getAllBlocks(types, categories)
return blocks.map((block) => block.name)
}
export async function getAllBlocks(
types: z.infer<typeof registryItemSchema>["type"][] = [
"registry:block",
"registry:internal",
],
categories: string[] = []
) {
const { Index } = await import("@/registry/__index__")
// Collect all blocks from all styles.
const allBlocks: z.infer<typeof registryItemSchema>[] = []
for (const style in Index) {
const styleIndex = Index[style]
if (typeof styleIndex === "object" && styleIndex !== null) {
for (const itemName in styleIndex) {
const item = styleIndex[itemName]
allBlocks.push(item)
}
}
}
// Validate each block.
const validatedBlocks = allBlocks
.map((block) => {
const result = registryItemSchema.safeParse(block)
return result.success ? result.data : null
})
.filter(
(block): block is z.infer<typeof registryItemSchema> => block !== null
)
return validatedBlocks.filter(
(block) =>
types.includes(block.type) &&
(categories.length === 0 ||
block.categories?.some((category) => categories.includes(category))) &&
!block.name.startsWith("chart-")
)
}
Domain
Subdomains
Functions
Dependencies
- schema
- zod
Source
Frequently Asked Questions
What does blocks.ts do?
blocks.ts is a source file in the ui codebase, written in typescript. It belongs to the DocumentationAtlas domain, Changelog subdomain.
What functions are defined in blocks.ts?
blocks.ts defines 2 function(s): getAllBlockIds, getAllBlocks.
What does blocks.ts depend on?
blocks.ts imports 2 module(s): schema, zod.
Where is blocks.ts in the architecture?
blocks.ts is located at apps/v4/lib/blocks.ts (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free