Rules
Principles
Section titled “Principles”- SOLID — Each layer has a clear responsibility
- DRY — Don’t duplicate logic between layers
- Edge-first — Runtime never depends on Node
- Type-first — Types are generated, not written manually
- AST-first — Pure separation between construction and execution
Module augmentation vs Generics
Section titled “Module augmentation vs Generics”Why no module augmentation for models?
ModelsTypes is used as a generic in Jsorm<TModels>, not via module augmentation, because:
- LS performance: module augmentation forces TS to globally resolve all declared types. A
ModelsTypesgeneric resolves only when used. - 0 conditional types:
from(model)mapsmodel.name→TModels[name]directly, without inference chains. - No build order dependency: module augmentation requires
types.d.tsto exist before TS resolves types. The generic works from the first save.
ESM-only
Section titled “ESM-only”All packages are ESM-only (.mjs + .d.mts or .d.ts). No CJS support.
Bundle
Section titled “Bundle”The CLI uses tsdown to generate bundles. typescript is an external dependency (not bundled) — the bundle is ~41 KB.
