Skip to content

Commit 950dfff

Browse files
committed
docs: productize user-facing documentation
1 parent 75151b4 commit 950dfff

194 files changed

Lines changed: 3253 additions & 9388 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 19 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,12 @@ npm install monsqlize
1515

1616
MongoDB is the first complete adapter. MySQL and PostgreSQL adapters are planned as database-native runtime adapters, not as a transparent promise that every database already accepts the same query syntax.
1717

18-
## Table of Contents
19-
20-
- [Why monSQLize](#why-monsqlize)
21-
- [Adapter Status](#adapter-status)
22-
- [Runtime Consistency Contract](#runtime-consistency-contract)
23-
- [When to Use It](#when-to-use-it)
24-
- [Installation](#installation)
25-
- [Quick Start](#quick-start)
26-
- [Model Layer](#model-layer)
27-
- [Caching and Performance](#caching-and-performance)
28-
- [Advanced Capabilities](#advanced-capabilities)
29-
- [Migration from the MongoDB Driver](#migration-from-the-mongodb-driver)
30-
- [Compatibility](#compatibility)
31-
- [Documentation](#documentation)
32-
- [Development](#development)
33-
- [Release Status](#release-status)
34-
- [Roadmap](#roadmap)
35-
- [License](#license)
36-
- [Support](#support)
37-
3818
## Why monSQLize
3919

4020
monSQLize is not an ORM and it is not just a CRUD wrapper. It is a production data runtime layer: the database driver remains visible, while the operational features teams usually build around the driver are provided in one runtime.
4121

4222
- Database-native adapter APIs: the current stable adapter preserves MongoDB-style CRUD, aggregation, indexes, transactions, and Change Streams.
43-
- Smart caching through `cache-hub`, including local memory caching, optional Redis-backed L2 caching, automatic invalidation, and function-level caching.
23+
- Smart database caching through `cache-hub`, including local memory caching, optional Redis-backed L2 caching, and automatic invalidation.
4424
- A lightweight Model layer with `schema-dsl` validation, hooks, relations, populate, custom methods, timestamps, soft delete, optimistic locking, and production-safe index preflight.
4525
- Multi-connection-pool support, pool health checks, pool-scoped collections/models, and fallback strategies.
4626
- Change Stream sync helpers with resume token storage.
@@ -103,13 +83,7 @@ monSQLize is usually not the best first choice for pure write-heavy workloads, e
10383
npm install monsqlize
10484
```
10585

106-
Runtime dependencies installed with the package:
107-
108-
- `mongodb` - official MongoDB driver.
109-
- `schema-dsl` - model schema validation runtime dependency.
110-
- `cache-hub` - cache and function-cache foundation.
111-
- `ioredis` - Redis-backed L2 cache and distributed invalidation support.
112-
- `ssh2` - SSH tunnel support for restricted/private network deployment.
86+
Use Node.js 18 or newer and provide a MongoDB connection URI. Optional Redis, SSH tunnel, cache, Model, and sync features are configured only when your application enables them.
11387

11488
## Quick Start
11589

@@ -143,7 +117,7 @@ await users.insertOne({
143117
});
144118

145119
const user = await users.findOne({ email: 'john@example.com' });
146-
const userById = await users.findOneById('507f1f77bcf86cd799439011');
120+
const sameUser = await users.findOne({ _id: '507f1f77bcf86cd799439011' });
147121

148122
await users.updateOne(
149123
{ email: 'john@example.com' },
@@ -189,7 +163,7 @@ The package root exports only the public package contract. Deep imports into his
189163

190164
The Model layer is optional. Use it when you want schema validation, hooks, relations, populate, custom methods, timestamps, soft delete, or optimistic locking.
191165

192-
`schema-dsl` is installed automatically as a runtime dependency of monSQLize. monSQLize creates an isolated `schema-dsl/runtime` instance for each `MonSQLize` runtime, then compiles Model schema callbacks when a Model is bound to that runtime.
166+
Models use the current `schema-dsl/runtime` path through monSQLize. monSQLize creates an isolated schema runtime for each `MonSQLize` instance, then compiles Model schema callbacks when a Model is bound to that runtime.
193167

194168
### Manual Model Registration
195169

@@ -198,7 +172,7 @@ const MonSQLize = require('monsqlize');
198172
const { Model } = MonSQLize;
199173

200174
Model.define('users', {
201-
schema: (dsl) => dsl({
175+
schema: (s) => s({
202176
username: 'string:3-32!',
203177
email: 'email!',
204178
password: 'string:6-!',
@@ -263,7 +237,7 @@ const schemaRuntime = createRuntime({
263237
});
264238

265239
Model.define('tenantUsers', {
266-
schema: (dsl) => dsl({
240+
schema: (s) => s({
267241
tenantId: 'tenantId!',
268242
email: 'email!'
269243
})
@@ -302,7 +276,7 @@ const User = msq.model('users');
302276
// models/user.model.js
303277
module.exports = {
304278
name: 'users',
305-
schema: (dsl) => dsl({
279+
schema: (s) => s({
306280
username: 'string:3-32!',
307281
email: 'email!'
308282
}),
@@ -372,7 +346,7 @@ await User.updateMany({ status: 'pending' }, { $set: { status: 'active' } }, {
372346

373347
```js
374348
Model.define('posts', {
375-
schema: (dsl) => dsl({
349+
schema: (s) => s({
376350
title: 'string:1-200!',
377351
content: 'string!',
378352
userId: 'objectId!'
@@ -400,7 +374,7 @@ For aggregation, monSQLize prepends a soft-delete `$match` stage before the user
400374

401375
## Caching and Performance
402376

403-
monSQLize can cache collection queries and arbitrary async functions.
377+
monSQLize can cache collection queries and coordinate local/Redis-backed invalidation for database runtime usage.
404378

405379
```js
406380
const users = msq.collection('users');
@@ -411,31 +385,14 @@ const hotUser = await users.findOne(
411385
);
412386
```
413387

414-
```js
415-
const { withCache } = require('monsqlize');
416-
417-
async function getUserProfile(userId) {
418-
const user = await msq.collection('users').findOneById(userId);
419-
const orders = await msq.collection('orders').find({ userId }).toArray();
420-
return { user, orders };
421-
}
422-
423-
const cachedGetUserProfile = withCache(getUserProfile, {
424-
ttl: 300_000,
425-
cache: msq.getCache()
426-
});
427-
428-
await cachedGetUserProfile('user-1');
429-
```
430-
431388
Cache capabilities include:
432389

433390
- In-memory L1 cache.
434391
- Optional Redis-backed L2 cache.
435392
- Automatic invalidation after writes.
436-
- Function-level caching through `withCache()`.
437-
- In-flight request deduplication.
438-
- Namespaces, TTLs, statistics, and conditional caching.
393+
- Cache namespace, TTL, and distributed invalidation controls.
394+
395+
`withCache()` and `FunctionCache` remain exported for legacy compatibility, but non-database function caching is no longer promoted as a current monSQLize feature area.
439396

440397
## Advanced Capabilities
441398

@@ -532,7 +489,7 @@ See the current support and verification documents:
532489

533490
- [English documentation](https://github.com/vextjs/monSQLize/blob/main/docs/en/README.md)
534491
- [Chinese documentation](https://github.com/vextjs/monSQLize/blob/main/docs/zh/README.md)
535-
- [English recipes](https://github.com/vextjs/monSQLize/blob/main/docs/en/recipes.md)
492+
- [English common scenarios](https://github.com/vextjs/monSQLize/blob/main/docs/en/recipes.md)
536493
- [Support matrix](https://github.com/vextjs/monSQLize/blob/main/docs/en/support-matrix.md)
537494
- [Verification entry points](https://github.com/vextjs/monSQLize/blob/main/docs/en/verification-entrypoints.md)
538495
- [test/compatibility/README.md](https://github.com/vextjs/monSQLize/blob/main/test/compatibility/README.md)
@@ -543,12 +500,11 @@ See the current support and verification documents:
543500
Current TypeScript documentation and examples are the source of truth for the v2 package:
544501

545502
- Complete docs: [English](https://vextjs.github.io/monSQLize/) · [简体中文](https://vextjs.github.io/monSQLize/zh/)
546-
- `docs/en/**` - default English documentation.
547-
- `docs/zh/**` - Simplified Chinese documentation.
548-
- `docs/en/recipes.md` / `docs/zh/recipes.md` - shortest copy-ready paths for common setup scenarios.
549-
- `examples/**` - TypeScript examples.
550-
- `test/compatibility/**` - package exports and compatibility guards.
551-
- `test/validation/**` - verification ledgers and mapping notes.
503+
- Common scenarios: [English](https://vextjs.github.io/monSQLize/recipes) · [简体中文](https://vextjs.github.io/monSQLize/zh/recipes)
504+
- Example source: [examples index](https://github.com/vextjs/monSQLize/blob/main/examples/README.md)
505+
- Documentation source: [docs/en](https://github.com/vextjs/monSQLize/tree/main/docs/en) · [docs/zh](https://github.com/vextjs/monSQLize/tree/main/docs/zh)
506+
- Compatibility checks: [test/compatibility](https://github.com/vextjs/monSQLize/tree/main/test/compatibility)
507+
- Verification mapping: [test/validation](https://github.com/vextjs/monSQLize/tree/main/test/validation)
552508

553509
Historical v1 assets are useful for tracing old behavior, but they are not the current publishing surface for v2.
554510

@@ -586,98 +542,24 @@ npm run test:server-matrix
586542
npm run test:real-env:private
587543
```
588544

589-
`check:docs-examples` verifies the 97/97 bilingual documentation matrix, runnable-example runner parity, shared-example targets, doc-check targets, and user-facing path text.
545+
`check:docs-examples` verifies the 98/98 bilingual documentation matrix, runnable-example runner parity, shared-example targets, doc-check targets, and user-facing path text.
590546

591547
`test:examples`, `test:server-matrix`, and `config.useMemoryServer` use a fixed `mongodb-memory-server` policy: MongoDB `7.0.14` by default, binaries cached under `.cache/mongodb-memory-server/binaries`, and temporary data paths created under `.cache/mongodb-memory-server/db` with forced cleanup for project-managed paths. Stale managed data paths whose owner PID is no longer alive are pruned before new memory-server launches. Override with `MONSQLIZE_MEMORY_MONGO_BINARY_VERSION`, `MONSQLIZE_REPLSET_BINARY_VERSION`, `MONGOMS_DOWNLOAD_DIR`, or `MONSQLIZE_MEMORY_SERVER_DB_DIR` when needed.
592548

593549
`test:coverage` is the independent 90% coverage governance gate for the published CJS runtime artifact. `test:audit` checks production dependencies against the npm registry. `test:real-env:private` is intentionally opt-in and expects private environment variables. Coverage and private real-environment checks are not part of the default CI or release gate.
594550

595-
## Release Status
596-
597-
The current release train targets `v2.0.7`.
598-
599-
Key release-readiness points:
600-
601-
- TypeScript rewrite completed for the current runtime and test entry points.
602-
- Package exports are consolidated under `dist/cjs`, `dist/esm`, and `dist/types`.
603-
- npm packages include the runtime bundles and declaration files only; source maps are disabled by default and can be generated locally with `MONSQLIZE_BUILD_SOURCEMAPS=1 npm run build`.
604-
- v1 smooth-upgrade compatibility has been validated against the target workspace consumers.
605-
- `schema-dsl` follows the npm `latest` TypeScript line `schema-dsl@2.1.1`; deprecated `2.3.x` mistake releases are intentionally excluded.
606-
- GitHub Actions publishes to npm from `v*` tags after running `npm run release:preflight`; the publish step skips duplicate lifecycle scripts because the gate already ran in the same job.
607-
608551
## Roadmap
609552

610-
### Adapter roadmap
611-
612553
- MongoDB remains the stable adapter and the current production runtime.
613554
- MySQL and PostgreSQL adapters will be introduced as database-native adapters under the same production runtime contract.
614555
- Adapter status will move from planned to alpha/stable only after runtime support, public types, examples, and verification coverage are present.
615556
- The project does not currently promise production-ready "one query syntax automatically adapts to every database" behavior.
616-
617-
### v2.0.7
618-
619-
- Package metadata and public release indexes now match the current data-runtime positioning without promoting business lock or Saga orchestration as primary package capabilities.
620-
- Hidden business lock and Saga compatibility pages now make their v2 runtime boundaries explicit for existing callers.
621-
- `npm run test:unit` uses the maintained unified runner unit group.
622-
- Validation ledgers now match the current 56 runnable TypeScript documentation examples.
623-
- Model v1 methods factory warnings now route through the runtime logger instead of direct console output.
624-
625-
### v2.0.8
626-
627-
- Model schema validation now uses an isolated `schema-dsl/runtime` instance per MonSQLize runtime, with `schemaDsl` configuration for runtime options, extension registration, runtime injection, explicit validation disablement, and fail-closed dependency resolution diagnostics.
628-
629-
### v2.0.6
630-
631-
- Dependency alignment carried the shared schema-dsl ESM/CJS custom type registry fix to downstream vext applications.
632-
- NodeNext declaration compatibility for ESM consumers through generated `*.d.mts` mirrors and import-side `types` conditions.
633-
- Restored v1-compatible root option type exports.
634-
635-
### v2.0.4
636-
637-
- Production-safe Model index rollout controls with `autoIndex`, dry-run preflight, conflict reporting, and explicit `ensureIndexes()` / `ensureModelIndexes()` APIs.
638-
- `schema-dsl` updated to `2.0.9`, with transitive `cache-hub` aligned to `2.2.4`.
639-
- User-facing capability and verification documentation wording cleaned up, plus documentation home experience refinements.
640-
641-
### v2.0.3
642-
643-
- v1 compatibility patch for documented `findPage({ cache })` behavior.
644-
- Public transaction and distributed cache invalidator statistics APIs.
645-
- Standalone documentation-site link safety and bilingual docs consistency fixes.
646-
- Release preflight alignment for bilingual docs paths and production dependency audit.
647-
648-
### v2.0.2
649-
650-
- Deterministic dependency metadata patch.
651-
- `ioredis` and `ssh2` are installed with monSQLize by default, so Redis-backed cache invalidation and SSH tunnels no longer require a separate dependency install step.
652-
653-
### v2.0.1
654-
655-
- v1 smooth-upgrade compatibility patch for Model actual collection names, scoped pools/databases, automatic-index dedupe, and cache/pool option aliases.
656-
- Documentation and public types aligned with the current runtime behavior.
657-
658-
### v2.0.0
659-
660-
- TypeScript-native runtime and declarations.
661-
- v1 smooth-upgrade compatibility bridge.
662-
- Multi-level cache and function-cache support through `cache-hub`.
663-
- Transactions, connection pools, Change Stream sync, and slow-query logging.
664-
- Model layer with `schema-dsl` validation, relations, populate, hooks, and custom methods.
665-
666-
### v2.x
667-
668557
- Query analyzer improvements.
669558
- Automatic index suggestions.
670559
- Migration tooling.
671560
- GraphQL integration experiments.
672561
- More real-environment validation coverage.
673562

674-
### v3.0+
675-
676-
- MySQL runtime adapter experiments.
677-
- PostgreSQL runtime adapter experiments.
678-
- Shared production runtime capabilities across database-native adapters.
679-
- Cross-database sync middleware experiments.
680-
681563
## License
682564

683565
monSQLize is released under the [Apache License 2.0](./LICENSE).

changelogs/unreleased.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Upgraded `schema-dsl` to `2.1.1` and moved Model schema compilation/validation onto a MonSQLize runtime-scoped `schema-dsl/runtime` engine. `schemaDsl` now supports runtime options, extension registration, external runtime injection, explicit validation disablement, and fail-closed dependency resolution diagnostics.
1919
- Fixed `schemaDsl: { runtime, extensions }` lifecycle handling so injected runtimes register extensions once during `connect()` instead of registering the same factory during construction and reconnect setup.
2020
- Made injected `schema-dsl/runtime` extension registration idempotent across failed connect retries, close/reconnect cycles, shared external runtime instances, incremental/reordered extension sets, partial extension-registration failures, external runtime resets, and source-stable function-valued definitions. Function fingerprinting now distinguishes closure-sensitive definitions from stable local scopes, including destructuring, nested helpers, templates, class/object methods, private/member access, regex literals, reserved syntax tokens, semicolonless local declarations with and without initializers, and break/continue labels; conflicting closure definitions still surface through schema-dsl.
21+
- Hardened `schema-dsl/runtime` loading across CJS, ESM, and TypeScript-generated CJS test entry points; extended function fingerprinting for numeric literals and Unicode identifiers; and aligned full-document Model validation, docs, examples, and public type examples with the recommended `schema: (s) => s(...)` DSL callback style.
2122
- Cleaned Model schema validation documentation so the primary path consistently describes runtime-scoped `schema-dsl/runtime`, and added schema-dsl runtime resolution to the `INVALID_CONFIG` troubleshooting surface.
2223
- Raised the default `mongodb-memory-server` launch timeout to 30 seconds for test, validation, examples, and `useMemoryServer` paths while keeping `MONSQLIZE_MEMORY_MONGO_LAUNCH_TIMEOUT_MS` as the override.
2324
- Added a short-lived read-cache dirty barrier around writes and transaction commits. Cached reads now bypass and avoid refilling query cache while a namespace is being invalidated, reducing stale-cache windows when a process exits between a database write and post-write invalidation.
@@ -48,3 +49,7 @@
4849
- Clarified the `db()` / `collection()` / `use()` documentation path: quick-start and import examples now name the runtime `msq`, cross-database business examples prefer `use(name).collection(name)`, and `db(null)` validation docs now match the current runtime behavior.
4950
- Repositioned README, package metadata, and bilingual documentation as a database-native production data runtime layer, with MongoDB stable today and MySQL/PostgreSQL adapters clearly marked as planned.
5051
- Enhanced the documentation home hero illustration with CSS-driven SVG line flow, moving data packets, staggered node pulses, subtle scene breathing, and reduced-motion-safe visible cues.
52+
- Fixed documentation-site footer localization so the English and Chinese home pages no longer show both language footer navigation blocks at the same time.
53+
- Hid hand-written Markdown table-of-contents blocks in the Rspress documentation site so they no longer duplicate the generated right-side page outline.
54+
- Corrected the multi-pool documentation path: the page now presents `new MonSQLize({ pools: [...] })` as the recommended setup, removes stale pinned install versions, and aligns adjacent connection, pool-chain, API index, capability index, function-cache, and Saga installation docs with the current package.
55+
- Repositioned `withCache()` / `FunctionCache` as hidden legacy compatibility surfaces, removed them from current cache/navigation/API recommendation paths, aligned cache examples with database query caching, and corrected stable docs drift for pool health status, Node.js runtime version, and the 98/98 docs-example matrix.

0 commit comments

Comments
 (0)