Home / Function/ getRegistryItem() — ui Function Reference

getRegistryItem() — ui Function Reference

Architecture documentation for the getRegistryItem() function in registry.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  9ad02a82_006c_477a_ceba_832cde81fa46["getRegistryItem()"]
  c2827044_b928_a1b2_3033_3282c0588350["registry.ts"]
  9ad02a82_006c_477a_ceba_832cde81fa46 -->|defined in| c2827044_b928_a1b2_3033_3282c0588350
  40a8af4b_5790_4349_e8f7_061bc4fd234c["getFileContent()"]
  9ad02a82_006c_477a_ceba_832cde81fa46 -->|calls| 40a8af4b_5790_4349_e8f7_061bc4fd234c
  0657e55f_4db1_fbf1_7517_70374cad1f6d["getFileMeta()"]
  9ad02a82_006c_477a_ceba_832cde81fa46 -->|calls| 0657e55f_4db1_fbf1_7517_70374cad1f6d
  9048841a_f467_e053_7d9c_7b747f2eff93["fixFilePaths()"]
  9ad02a82_006c_477a_ceba_832cde81fa46 -->|calls| 9048841a_f467_e053_7d9c_7b747f2eff93
  style 9ad02a82_006c_477a_ceba_832cde81fa46 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/lib/registry.ts lines 24–77

export async function getRegistryItem(
  name: string,
  style: Style["name"] = DEFAULT_REGISTRY_STYLE
) {
  const item = memoizedIndex[style][name]

  if (!item) {
    return null
  }

  // Convert all file paths to object.
  // TODO: remove when we migrate to new registry.
  item.files = item.files.map((file: unknown) =>
    typeof file === "string" ? { path: file } : file
  )

  // Fail early before doing expensive file operations.
  const result = registryItemSchema.safeParse(item)
  if (!result.success) {
    return null
  }

  let files: typeof result.data.files = []
  for (const file of item.files) {
    const content = await getFileContent(file)
    const relativePath = path.relative(process.cwd(), file.path)

    files.push({
      ...file,
      path: relativePath,
      content,
    })
  }

  // Get meta.
  // Assume the first file is the main file.
  // const meta = await getFileMeta(files[0].path)

  // Fix file paths.
  files = fixFilePaths(files)

  const parsed = registryItemSchema.safeParse({
    ...result.data,
    files,
    // meta,
  })

  if (!parsed.success) {
    console.error(parsed.error.message)
    return null
  }

  return parsed.data
}

Subdomains

Frequently Asked Questions

What does getRegistryItem() do?
getRegistryItem() is a function in the ui codebase, defined in deprecated/www/lib/registry.ts.
Where is getRegistryItem() defined?
getRegistryItem() is defined in deprecated/www/lib/registry.ts at line 24.
What does getRegistryItem() call?
getRegistryItem() calls 3 function(s): fixFilePaths, getFileContent, getFileMeta.

Analyze Your Own Codebase

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

Try Supermodel Free