How salmon42/ts-data-objects works
Project Type and Purpose
• This is a TypeScript library (not a full-stack application) called ts-data-objects.
• Its purpose is to provide a lightweight, modular toolkit for runtime type-safe data objects, guards, parsers, and default-filled constructors.
• There are three main logical modules: common, core, and deep (experimental deep validation).
File Structure
• Top-Level Files
• package.json, tsconfig.json, vitest.config.ts, vite.config.ts – build, test, and bundling configurations
• scripts/ – automation for cleaning, deploying, and generating docs
• Source Code
• lib/ – compiled output (mirrors src/)
• src/ – authorative TypeScript source modules
– src/core, src/deep, plus example files and an entrypoint main.ts
• Documentation
• docs/ – the generated static site (via typedoc)
• readme/ – changelog, development notes, scaffolding guidelines
• Tests
• tests/ – unit tests for each assertion, core, and performance tests
README for Additional Insights
• The library exports multiple entry points:
– ts-data-objects/common – basic type-checking predicates (isStr, isNum, etc.)
– ts-data-objects/core – dataGuard, dataObject, defineObject, dataParser
– ts-data-objects/deep – experimental deep-nested validation
• Scripts:
– scripts/doc.ts invokes TypeDoc to generate docs into docs/
– scripts/deploy.ts publishes to NPM / GitHub Pages
Main Components & Their Interactions
a. Modules
• Common Module: array.ts, boolean.ts, number.ts, object.ts, string.ts → exports primitive guards
• Core Module: dataGuard, dataObject, dataParser, defineObject → composes common predicates
• Deep Module: dataDeepGuard, dataDeepParser → builds upon core for recursive structures
• Examples: ExampleDataSimple, ExampleDataDeep – illustrate usage
• Tests: validate each module’s public API
• Build & Publish: TypeScript compiler → lib/, then bundle for NPM; TypeDoc → docs/
b. Relationships
• src/**/* → compiles to lib/**/*
• core depends on common; deep depends on core
• test suites import from src or lib for unit and performance tests
• scripts invoke CLI tools (tsc, typedoc, vitest, rimraf)
c. Architectural Patterns
• Modular, layered design:
1. Primitive Guards (common)
2. Composite Guards & Parsers (core)
3. Deep/Recursive Validation (deep)
• Separation of concerns: validation logic vs object construction
• Build pipeline: source → compile → test → doc → publish
d. Key Technologies
• TypeScript (tsc), Vitest for testing, TypeDoc for documentation, ESBuild/Vite for bundling (if used), Node.js scripts
Detailed Elements
• Labels: module names, build steps, external services
• Annotations:
• Modular entry points (common, core, deep)
• “experimental” on deep module
• versioning and changelog (readme/CHANGELOG.md)