builder.ts — ui Source File
Architecture documentation for builder.ts, a typescript file in the ui codebase. 9 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 8c5b2947_9033_b37b_2596_f9777d2a7f77["builder.ts"] 2ae56314_aa15_5495_52a2_137787e7b210["constants"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 2ae56314_aa15_5495_52a2_137787e7b210 cb7fc1a5_a9db_7ce3_c6b9_af10f42826a9["env"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> cb7fc1a5_a9db_7ce3_c6b9_af10f42826a9 0ec72e6a_72c2_0fcf_92e9_0b0612e46d40["errors"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 0ec72e6a_72c2_0fcf_92e9_0b0612e46d40 0ce0166b_94b8_3d75_f122_e290dcdf3f26["parser"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 0ce0166b_94b8_3d75_f122_e290dcdf3f26 50c29a7b_b93d_0a7c_57d5_beffcb095441["utils"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 50c29a7b_b93d_0a7c_57d5_beffcb095441 57e5010f_701c_22f8_5921_3e11fc3c65aa["validator"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 57e5010f_701c_22f8_5921_3e11fc3c65aa a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> a3b2545e_3d8c_699d_ef11_6ab18db14666 b2895591_2a74_d518_deda_2f26be766dcb["get-config"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> b2895591_2a74_d518_deda_2f26be766dcb 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] 8c5b2947_9033_b37b_2596_f9777d2a7f77 --> 6802ce19_522d_e5fb_e458_8826d9f6952e b14232bc_8c42_35f7_fc72_f9cbe7c4e302["builder.test.ts"] b14232bc_8c42_35f7_fc72_f9cbe7c4e302 --> 8c5b2947_9033_b37b_2596_f9777d2a7f77 style 8c5b2947_9033_b37b_2596_f9777d2a7f77 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { BUILTIN_REGISTRIES, REGISTRY_URL } from "@/src/registry/constants"
import { expandEnvVars } from "@/src/registry/env"
import { RegistryNotConfiguredError } from "@/src/registry/errors"
import { parseRegistryAndItemFromString } from "@/src/registry/parser"
import { isLocalFile, isUrl } from "@/src/registry/utils"
import { validateRegistryConfig } from "@/src/registry/validator"
import { registryConfigItemSchema } from "@/src/schema"
import { Config } from "@/src/utils/get-config"
import { z } from "zod"
const NAME_PLACEHOLDER = "{name}"
const STYLE_PLACEHOLDER = "{style}"
const ENV_VAR_PATTERN = /\${(\w+)}/g
const QUERY_PARAM_SEPARATOR = "?"
const QUERY_PARAM_DELIMITER = "&"
function isLocalPath(path: string) {
return path.startsWith("./") || path.startsWith("/")
}
export function buildUrlAndHeadersForRegistryItem(
name: string,
config?: Config
) {
let { registry, item } = parseRegistryAndItemFromString(name)
// If no registry prefix, check if it's a URL or local path.
// These should be handled directly, not through a registry.
if (!registry) {
if (isUrl(name) || isLocalFile(name) || isLocalPath(name)) {
return null
}
registry = "@shadcn"
}
const registries = { ...BUILTIN_REGISTRIES, ...config?.registries }
const registryConfig = registries[registry]
if (!registryConfig) {
throw new RegistryNotConfiguredError(registry)
}
// TODO: I don't like this here.
// But this will do for now.
validateRegistryConfig(registry, registryConfig)
return {
url: buildUrlFromRegistryConfig(item, registryConfig, config),
headers: buildHeadersFromRegistryConfig(registryConfig),
}
}
export function buildUrlFromRegistryConfig(
item: string,
registryConfig: z.infer<typeof registryConfigItemSchema>,
config?: Config
) {
if (typeof registryConfig === "string") {
let url = registryConfig.replace(NAME_PLACEHOLDER, item)
if (config?.style && url.includes(STYLE_PLACEHOLDER)) {
url = url.replace(STYLE_PLACEHOLDER, config.style)
// ... (103 more lines)
Domain
Subdomains
Functions
Dependencies
- constants
- env
- errors
- get-config
- parser
- schema
- utils
- validator
- zod
Imported By
Source
Frequently Asked Questions
What does builder.ts do?
builder.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 builder.ts?
builder.ts defines 7 function(s): appendQueryParams, buildHeadersFromRegistryConfig, buildUrlAndHeadersForRegistryItem, buildUrlFromRegistryConfig, isLocalPath, resolveRegistryUrl, shouldIncludeHeader.
What does builder.ts depend on?
builder.ts imports 9 module(s): constants, env, errors, get-config, parser, schema, utils, validator, and 1 more.
What files import builder.ts?
builder.ts is imported by 1 file(s): builder.test.ts.
Where is builder.ts in the architecture?
builder.ts is located at packages/shadcn/src/registry/builder.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