Shared
Architecture notes for @ucdjs-internal/shared
@ucdjs-internal/shared holds internal cross-package helpers.
Role
- Provides reusable internal utilities for async work, fetch behavior, filtering, files, guards, and hashing.
- Supports workspace packages without promising external stability.
- Sits below domain packages such as client, store, and pipeline tooling.
Related Docs
Utils
The stable public facade re-exports a small subset of shared helpers.
Client
Client resources rely on customFetch and guards from shared.
UCD Store
Store operations depend heavily on wrapTry, path filters, and file helpers.
Package Layers
See why shared stays internal and below business packages.
Mental Model
This package is the workspace’s implementation toolbox.
It is deliberately broad, but the exports still cluster into a few clear families:
- async helpers: concurrency limiting,
wrapTry,tryOr - fetch helpers:
customFetch, normalized fetch errors, schema-aware responses - path/file helpers: flattening, normalization, tree filtering
- glob and filter helpers
- small guards and serialization helpers
Helper Families
Method Flows
customFetch.safe()
createPathFilter(options)
wrapTry(operation)
tryOr({ try, err })
Internal Boundary
Testing Use
The highest-value tests here are:
- fetch normalization, retry, timeout, and schema-validation branches
- filter/path matching edge cases and default exclusions
wrapTry/tryOrsync and async behavior- file tree normalization and flattening helpers