Home / File/ api.ts — ui Source File

api.ts — ui Source File

Architecture documentation for api.ts, a typescript file in the ui codebase. 14 imports, 5 dependents.

File typescript FrameworkTooling SchemaValidation 14 imports 5 dependents 16 functions

Entity Profile

Dependency Diagram

graph LR
  c41eed12_c415_48c8_bcf4_9d09d3424a18["api.ts"]
  d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5
  6cb39c88_2e7f_0418_0b3e_763f882f13ff["builder"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 6cb39c88_2e7f_0418_0b3e_763f882f13ff
  1f2f79fc_356c_e956_002d_737290df27fd["config"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 1f2f79fc_356c_e956_002d_737290df27fd
  2ae56314_aa15_5495_52a2_137787e7b210["constants"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 2ae56314_aa15_5495_52a2_137787e7b210
  ff842930_3a95_1c03_7d51_b342f47a7971["context"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> ff842930_3a95_1c03_7d51_b342f47a7971
  0ec72e6a_72c2_0fcf_92e9_0b0612e46d40["errors"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 0ec72e6a_72c2_0fcf_92e9_0b0612e46d40
  8b63e39d_c91e_6de3_796b_cdd80586252f["fetcher"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 8b63e39d_c91e_6de3_796b_cdd80586252f
  d51fcbb7_2296_ff31_c04b_1cb928fc5bc9["resolver"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> d51fcbb7_2296_ff31_c04b_1cb928fc5bc9
  50c29a7b_b93d_0a7c_57d5_beffcb095441["utils"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 50c29a7b_b93d_0a7c_57d5_beffcb095441
  a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> a3b2545e_3d8c_699d_ef11_6ab18db14666
  b2895591_2a74_d518_deda_2f26be766dcb["get-config"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> b2895591_2a74_d518_deda_2f26be766dcb
  6be7d8a9_c93c_8743_3ef7_968efff25479["handle-error"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 6be7d8a9_c93c_8743_3ef7_968efff25479
  1df8bbed_5110_29f0_12f0_996fc7a1eda1["logger"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 1df8bbed_5110_29f0_12f0_996fc7a1eda1
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  c41eed12_c415_48c8_bcf4_9d09d3424a18 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  style c41eed12_c415_48c8_bcf4_9d09d3424a18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from "path"
import { buildUrlAndHeadersForRegistryItem } from "@/src/registry/builder"
import { configWithDefaults } from "@/src/registry/config"
import {
  BASE_COLORS,
  BUILTIN_REGISTRIES,
  REGISTRY_URL,
} from "@/src/registry/constants"
import {
  clearRegistryContext,
  setRegistryHeaders,
} from "@/src/registry/context"
import {
  ConfigParseError,
  RegistriesIndexParseError,
  RegistryInvalidNamespaceError,
  RegistryNotFoundError,
  RegistryParseError,
} from "@/src/registry/errors"
import { fetchRegistry } from "@/src/registry/fetcher"
import {
  fetchRegistryItems,
  resolveRegistryTree,
} from "@/src/registry/resolver"
import { isUrl } from "@/src/registry/utils"
import {
  configJsonSchema,
  iconsSchema,
  registriesIndexSchema,
  registriesSchema,
  registryBaseColorSchema,
  registryConfigSchema,
  registryIndexSchema,
  registryItemSchema,
  registrySchema,
  stylesSchema,
} from "@/src/schema"
import { Config, explorer } from "@/src/utils/get-config"
import { handleError } from "@/src/utils/handle-error"
import { logger } from "@/src/utils/logger"
import { z } from "zod"

export async function getRegistry(
  name: string,
  options?: {
    config?: Partial<Config>
    useCache?: boolean
  }
) {
  const { config, useCache } = options || {}

  if (isUrl(name)) {
    const [result] = await fetchRegistry([name], { useCache })
    try {
      return registrySchema.parse(result)
    } catch (error) {
      throw new RegistryParseError(name, error)
    }
  }

// ... (284 more lines)

Subdomains

Dependencies

  • builder
  • config
  • constants
  • context
  • errors
  • fetcher
  • get-config
  • handle-error
  • logger
  • path
  • resolver
  • schema
  • utils
  • zod

Frequently Asked Questions

What does api.ts do?
api.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, SchemaValidation subdomain.
What functions are defined in api.ts?
api.ts defines 16 function(s): fetchTree, getItemTargetPath, getPreset, getPresets, getRegistries, getRegistriesConfig, getRegistriesIndex, getRegistry, getRegistryBaseColor, getRegistryBaseColors, and 6 more.
What does api.ts depend on?
api.ts imports 14 module(s): builder, config, constants, context, errors, fetcher, get-config, handle-error, and 6 more.
What files import api.ts?
api.ts is imported by 5 file(s): api.test.ts, get-item-target-path.test.ts, registry.test.ts, search.test.ts, search.ts.
Where is api.ts in the architecture?
api.ts is located at packages/shadcn/src/registry/api.ts (domain: FrameworkTooling, subdomain: SchemaValidation, directory: packages/shadcn/src/registry).

Analyze Your Own Codebase

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

Try Supermodel Free